You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@commons.apache.org by gs...@apache.org on 2003/10/27 15:29:03 UTC

svn commit: rev 52 - in commons/serf/branches/gen2: . buckets

Author: gstein
Date: Mon Oct 27 06:29:03 2003
New Revision: 52

Added:
   commons/serf/branches/gen2/buckets/
   commons/serf/branches/gen2/buckets/buckets.c
   commons/serf/branches/gen2/connection.c
   commons/serf/branches/gen2/context.c
Modified:
   commons/serf/branches/gen2/serf.h
   commons/serf/branches/gen2/serf_bucket_types.h
Log:
Add more documentation, and bare skeleton of the basic functions.

* serf/branches/gen2/serf.h:
  (serf_bucket_create): new basic bucket creation function
  (serf_default_read_bucket): new function for a default read-bucket
    function.
  (serf_default_destroy): new function for a default bucket destroy
    function.

* serf/branches/gen2/serf_bucket_type.h:
  (serf_bucket_aggregate_become): new function to alter a bucket structure
    to become an aggregate bucket.

* serf/branches/gen2/context.c: new file. basic context functions.
* serf/branches/gen2/connection.c: new file. basic connection functions.
* serf/branches/gen2/buckets/buckets.c: new file. basic bucket functions.


Added: commons/serf/branches/gen2/buckets/buckets.c
==============================================================================
--- (empty file)
+++ commons/serf/branches/gen2/buckets/buckets.c	Mon Oct 27 06:29:03 2003
@@ -0,0 +1,140 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ */
+
+#include <apr_pools.h>
+
+#include "serf.h"
+
+
+struct serf_bucket_alloc_t {
+    apr_allocator_t *allocator;
+};
+
+
+SERF_DECLARE(serf_bucket_t *) serf_bucket_create(
+    serf_bucket_type_t *type,
+    serf_bucket_alloc_t *allocator,
+    void *data)
+{
+    serf_bucket_t *bkt = serf_bucket_mem_alloc(allocator, sizeof(*bkt));
+
+    bkt->type = type;
+    bkt->data = data;
+    bkt->metadata = NULL;
+    bkt->allocator = allocator;
+
+    return bkt;
+}
+
+SERF_DECLARE(apr_status_t) serf_default_set_metadata(serf_bucket_t *bucket,
+                                                     const char *md_type,
+                                                     const char *md_name,
+                                                     const void *md_value)
+{
+    return APR_ENOTIMPL;
+}
+
+
+SERF_DECLARE(apr_status_t) serf_default_get_metadata(serf_bucket_t *bucket,
+                                                     const char *md_type,
+                                                     const char *md_name,
+                                                     const void **md_value)
+{
+    return APR_ENOTIMPL;
+}
+
+SERF_DECLARE(serf_bucket_t *) serf_default_read_bucket(
+    serf_bucket_t *bucket,
+    serf_bucket_type_t *type)
+{
+    return NULL;
+}
+
+SERF_DECLARE(void) serf_default_destroy(serf_bucket_t *bucket)
+{
+    serf_bucket_mem_free(bucket->allocator, bucket);
+}
+
+
+/* ==================================================================== */
+
+
+SERF_DECLARE(serf_bucket_alloc_t *) serf_bucket_allocator_create(
+    apr_allocator_t *allocator)
+{
+    serf_bucket_alloc_t *a = apr_allocator_alloc(allocator, sizeof(*a));
+
+    a->allocator = allocator;
+
+    /* ### more */
+
+    return a;
+}
+
+SERF_DECLARE(void) serf_bucket_allocator_destroy(
+    serf_bucket_alloc_t *allocator)
+{
+    apr_allocator_destroy(allocator->allocator);
+}
+
+SERF_DECLARE(void *) serf_bucket_mem_alloc(
+    serf_bucket_alloc_t *allocator,
+    apr_size_t size)
+{
+    /* ### need real code */
+    return NULL;
+}
+
+SERF_DECLARE(void) serf_bucket_mem_free(
+    serf_bucket_alloc_t *allocator,
+    void *block)
+{
+    /* ### need real code */
+}

Added: commons/serf/branches/gen2/connection.c
==============================================================================
--- (empty file)
+++ commons/serf/branches/gen2/connection.c	Mon Oct 27 06:29:03 2003
@@ -0,0 +1,90 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ */
+
+#include <apr_pools.h>
+
+#include "serf.h"
+
+
+struct serf_connection_t {
+    int foo;
+};
+
+SERF_DECLARE(serf_connection_t *) serf_connection_create(
+    serf_context_t *ctx,
+    apr_sockaddr_t *address,
+    serf_response_acceptor_t acceptor,
+    void *acceptor_baton,
+    serf_connection_closed_t closed,
+    void *closed_baton,
+    apr_pool_t *pool)
+{
+    return apr_pcalloc(pool, sizeof(serf_connection_t));
+}
+
+
+SERF_DECLARE(apr_status_t) serf_connection_request_create(
+    serf_connection_t *conn,
+    serf_bucket_t *request,
+    serf_response_handler_t handler,
+    void *handler_baton,
+    serf_bucket_alloc_t *allocator,
+    apr_pool_t *pool)
+{
+    return APR_ENOTIMPL;
+}
+
+
+SERF_DECLARE(apr_status_t) serf_connection_request_cancel(
+    serf_connection_t *conn,
+    serf_bucket_t *request)
+{
+    return APR_ENOTIMPL;
+}

Added: commons/serf/branches/gen2/context.c
==============================================================================
--- (empty file)
+++ commons/serf/branches/gen2/context.c	Mon Oct 27 06:29:03 2003
@@ -0,0 +1,71 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2002 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" must
+ *    not be used to endorse or promote products derived from this
+ *    software without prior written permission. For written
+ *    permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    nor may "Apache" appear in their name, without prior written
+ *    permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ */
+
+#include <apr_pools.h>
+
+#include "serf.h"
+
+
+struct serf_context_t {
+    int foo;
+};
+
+
+SERF_DECLARE(serf_context_t *) serf_context_create(apr_pool_t *pool)
+{
+    return apr_pcalloc(pool, sizeof(serf_context_t));
+}
+
+SERF_DECLARE(apr_status_t) serf_context_run(serf_context_t *ctx,
+                                            apr_short_interval_time_t duration,
+                                            apr_pool_t *pool)
+{
+    return APR_ENOTIMPL;
+}

Modified: commons/serf/branches/gen2/serf.h
==============================================================================
--- commons/serf/branches/gen2/serf.h	(original)
+++ commons/serf/branches/gen2/serf.h	Mon Oct 27 06:29:03 2003
@@ -381,6 +381,20 @@
 
 
 /**
+ * Basic bucket creation function.
+ *
+ * This function will create a bucket of @a type, allocating the necessary
+ * memory from @a allocator. The @a data bucket-private information will
+ * be stored into the bucket.
+ *
+ * The metadata for the bucket will be empty.
+ */
+SERF_DECLARE(serf_bucket_t *) serf_bucket_create(
+    serf_bucket_type_t *type,
+    serf_bucket_alloc_t *allocator,
+    void *data);
+
+/**
  * Default implementation to set metadata within a bucket.
  *
  * Stores @a md_value into @a bucket under the metadata type @a md_type
@@ -392,12 +406,34 @@
                                                      const void *md_value);
 
 /**
- * Default implementation to get metadata from a bucket.
+ * Default implementation to get metadata from @a bucket.
+ *
+ * The @a md_value for the specified @a md_type and @a md_name will
+ * be returned. If the metadata is not present, then NULL will be stored
+ * into @a md_value.
  */
 SERF_DECLARE(apr_status_t) serf_default_get_metadata(serf_bucket_t *bucket,
                                                      const char *md_type,
                                                      const char *md_name,
                                                      const void **md_value);
+
+/**
+ * Default implementation of the @see read_bucket functionality.
+ *
+ * This function will always return NULL, indicating that the @a type
+ * of bucket cannot be found within @a bucket.
+ */
+SERF_DECLARE(serf_bucket_t *) serf_default_read_bucket(
+    serf_bucket_t *bucket,
+    serf_bucket_type_t *type);
+
+/**
+ * Default implementation of the @see destroy functionality.
+ *
+ * This function will return the @a bucket to its allcoator.
+ */
+SERF_DECLARE(void) serf_default_destroy(serf_bucket_t *bucket);
+
 
 /** @} */
 

Modified: commons/serf/branches/gen2/serf_bucket_types.h
==============================================================================
--- commons/serf/branches/gen2/serf_bucket_types.h	(original)
+++ commons/serf/branches/gen2/serf_bucket_types.h	Mon Oct 27 06:29:03 2003
@@ -113,6 +113,8 @@
 SERF_DECALRE(serf_bucket_t *) serf_bucket_aggregate_create(
     serf_bucket_alloc_t *allocator);
 
+SERF_DECLARE(void) serf_bucket_aggregate_become(serf_bucket_t *bucket);
+
 SERF_DECLARE(void) serf_bucket_aggregate_prepend(
     serf_bucket_t *aggregate_bucket,
     serf_bucket_t *prepend_bucket);