axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r519603 [2/2] - in /webservices/axis2/trunk/c: include/ modules/core/transport/http/common/ modules/core/transport/http/util/
Date Sun, 18 Mar 2007 12:20:33 GMT
Modified: webservices/axis2/trunk/c/modules/core/transport/http/common/http_out_transport_info.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/common/http_out_transport_info.c?view=diff&rev=519603&r1=519602&r2=519603
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/common/http_out_transport_info.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/common/http_out_transport_info.c Sun Mar 18 05:20:32 2007
@@ -20,108 +20,55 @@
 #include <axis2_http_transport.h>
 #include <axis2_string.h>
 
-
-/**
- * HTTP Header struct impl
- * Axis2 HTTP Header impl
- */
-
-typedef struct axis2_http_out_transport_info_impl
+struct axis2_http_out_transport_info
 {
-    axis2_http_out_transport_info_t out_transport_info;
     axis2_http_simple_response_t *response;
     axis2_char_t *encoding;
-}
-axis2_http_out_transport_info_impl_t;
+};
 
-#define AXIS2_INTF_TO_IMPL(out_transport_info) \
-                ((axis2_http_out_transport_info_impl_t *)(out_transport_info))
-
-/***************************** Function headers *******************************/
-axis2_status_t AXIS2_CALL
-axis2_http_out_transport_info_set_content_type(
-    axis2_http_out_transport_info_t *info,
-    const axis2_env_t *env,
-    const axis2_char_t *content_type);
-
-axis2_status_t AXIS2_CALL
-axis2_http_out_transport_info_set_char_encoding(
-    axis2_http_out_transport_info_t *info,
-    const axis2_env_t *env,
-    const axis2_char_t *encoding);
-
-axis2_status_t AXIS2_CALL
-axis2_http_out_transport_info_free(
-    axis2_http_out_transport_info_t *out_transport_info,
-    const axis2_env_t *env);
-
-axis2_http_out_transport_info_t *AXIS2_CALL
+AXIS2_EXTERN axis2_http_out_transport_info_t *AXIS2_CALL
 axis2_http_out_transport_info_create(
     const axis2_env_t *env,
     axis2_http_simple_response_t *response)
 {
-    axis2_http_out_transport_info_impl_t *info_impl = NULL;
+    axis2_http_out_transport_info_t *http_out_transport_info = NULL;
     AXIS2_ENV_CHECK(env, NULL);
 
-    info_impl = (axis2_http_out_transport_info_impl_t *)AXIS2_MALLOC
+    http_out_transport_info = (axis2_http_out_transport_info_t *)AXIS2_MALLOC
             (env->allocator, sizeof(
-                        axis2_http_out_transport_info_impl_t));
-
-    if (NULL == info_impl)
-    {
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-    }
-    info_impl->response = response;
-    info_impl->encoding = NULL;
+                        axis2_http_out_transport_info_t));
 
-    info_impl->out_transport_info.ops = AXIS2_MALLOC(env->allocator,
-            sizeof(axis2_http_out_transport_info_ops_t));
-    if (NULL == info_impl->out_transport_info.ops)
+    if (NULL == http_out_transport_info)
     {
-        axis2_http_out_transport_info_free((axis2_http_out_transport_info_t*)
-                info_impl, env);
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
+    http_out_transport_info->response = response;
+    http_out_transport_info->encoding = NULL;
 
-    info_impl->out_transport_info.ops->set_content_type =
-        axis2_http_out_transport_info_set_content_type;
-    info_impl->out_transport_info.ops->set_char_encoding =
-        axis2_http_out_transport_info_set_char_encoding;
-    info_impl->out_transport_info.ops->free =
-        axis2_http_out_transport_info_free;
-
-    return &(info_impl->out_transport_info);
+    return http_out_transport_info;
 }
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_out_transport_info_free(
-    axis2_http_out_transport_info_t *info,
+    axis2_http_out_transport_info_t *http_out_transport_info,
     const axis2_env_t *env)
 {
-    axis2_http_out_transport_info_impl_t *info_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    info_impl = AXIS2_INTF_TO_IMPL(info);
 
-    if(info_impl->response)
+    if(http_out_transport_info->response)
     {
-        AXIS2_HTTP_SIMPLE_RESPONSE_FREE(info_impl->response, env);
-        info_impl->response = NULL;
+        AXIS2_HTTP_SIMPLE_RESPONSE_FREE(http_out_transport_info->response, env);
     }
-    if (info_impl->encoding)
+    if (http_out_transport_info->encoding)
     {
-        AXIS2_FREE(env->allocator, info_impl->encoding);
-        info_impl->encoding = NULL;
+        AXIS2_FREE(env->allocator, http_out_transport_info->encoding);
     }
-    if (info->ops)
-        AXIS2_FREE(env->allocator, info->ops);
-
-    AXIS2_FREE(env->allocator, info_impl);
+    AXIS2_FREE(env->allocator, http_out_transport_info);
     return AXIS2_SUCCESS;
 }
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_out_transport_info_free_void_arg(
     void *transport_info,
     const axis2_env_t *env)
@@ -133,29 +80,26 @@
     return axis2_http_out_transport_info_free(transport_info_l, env);
 }
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_out_transport_info_set_content_type(
-    axis2_http_out_transport_info_t *info,
+    axis2_http_out_transport_info_t *http_out_transport_info,
     const axis2_env_t *env,
     const axis2_char_t *content_type)
 {
     axis2_char_t *tmp1 = NULL;
     axis2_char_t *tmp2 = NULL;
-    axis2_http_out_transport_info_impl_t *info_impl = NULL;
 
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, content_type, AXIS2_FAILURE);
 
-    info_impl = AXIS2_INTF_TO_IMPL(info);
-
-    if (info_impl->encoding)
+    if (http_out_transport_info->encoding)
     {
         axis2_char_t *charset_pos = axis2_strcasestr(content_type, "charset");
         if (!charset_pos)
         {
             tmp1 = axis2_stracat(content_type, ";charset=", env);
-            tmp2 = axis2_stracat(tmp1, info_impl->encoding, env);
-            AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(info_impl->response, env,
+            tmp2 = axis2_stracat(tmp1, http_out_transport_info->encoding, env);
+            AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(http_out_transport_info->response, env,
                     axis2_http_header_create(env, AXIS2_HTTP_HEADER_CONTENT_TYPE,
                             tmp2));
             AXIS2_FREE(env->allocator, tmp1);
@@ -163,15 +107,15 @@
         }
         else
         {
-            AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(info_impl->response, env,
+            AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(http_out_transport_info->response, env,
                 axis2_http_header_create(env, AXIS2_HTTP_HEADER_CONTENT_TYPE,
                         content_type));
         }
     }
     else
     {
-        if(info_impl->response)
-            AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(info_impl->response, env,
+        if(http_out_transport_info->response)
+            AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(http_out_transport_info->response, env,
                 axis2_http_header_create(env, AXIS2_HTTP_HEADER_CONTENT_TYPE,
                         content_type));
     }
@@ -179,23 +123,20 @@
 }
 
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_out_transport_info_set_char_encoding(
-    axis2_http_out_transport_info_t *info,
+    axis2_http_out_transport_info_t *http_out_transport_info,
     const axis2_env_t *env,
     const axis2_char_t *encoding)
 {
-    axis2_http_out_transport_info_impl_t *info_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, encoding, AXIS2_FAILURE);
 
-    info_impl = AXIS2_INTF_TO_IMPL(info);
-
-    if (info_impl->encoding)
+    if (http_out_transport_info->encoding)
     {
-        AXIS2_FREE(env->allocator, info_impl->encoding);
+        AXIS2_FREE(env->allocator, http_out_transport_info->encoding);
     }
-    info_impl->encoding = axis2_strdup(encoding, env);
+    http_out_transport_info->encoding = axis2_strdup(encoding, env);
 
     return AXIS2_SUCCESS;
 }

Modified: webservices/axis2/trunk/c/modules/core/transport/http/common/http_request_line.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/common/http_request_line.c?view=diff&rev=519603&r1=519602&r2=519603
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/common/http_request_line.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/common/http_request_line.c Sun Mar 18 05:20:32 2007
@@ -20,60 +20,13 @@
 #include <string.h>
 #include <axis2_http_transport.h>
 #include <stdio.h>
-/**
- * @brief HTTP Request Line struct impl
- *   Axis2 HTTP Request Line impl
- */
 
-typedef struct axis2_http_request_line_impl
+struct axis2_http_request_line
 {
-    axis2_http_request_line_t request_line;
     axis2_char_t *http_version;
     axis2_char_t *method;
     axis2_char_t *uri;
-}
-axis2_http_request_line_impl_t;
-
-#define AXIS2_INTF_TO_IMPL(request_line) \
-                 ((axis2_http_request_line_impl_t *)(request_line))
-
-/***************************** Function headers *******************************/
-
-/*
- *  This is just a function
- *  Not assciated with an ops struct
- */
-axis2_http_request_line_t *AXIS2_CALL
-axis2_http_request_line_parse_line(
-    const axis2_env_t *env,
-    const axis2_char_t *str);
-
-axis2_char_t *AXIS2_CALL
-axis2_http_request_line_get_method(
-    const axis2_http_request_line_t *request_line,
-    const axis2_env_t *env);
-
-axis2_char_t *AXIS2_CALL
-axis2_http_request_line_get_http_version(
-    const axis2_http_request_line_t *request_line,
-    const axis2_env_t *env);
-
-axis2_char_t *AXIS2_CALL
-axis2_http_request_line_get_uri(
-    const axis2_http_request_line_t *request_line,
-    const axis2_env_t *env);
-
-axis2_char_t *AXIS2_CALL
-axis2_http_request_line_to_string(
-    axis2_http_request_line_t *request_line,
-    const axis2_env_t *env);
-
-axis2_status_t AXIS2_CALL
-axis2_http_request_line_free(
-    axis2_http_request_line_t *request_line,
-    const axis2_env_t *env);
-
-/***************************** End of function headers ************************/
+};
 
 AXIS2_EXTERN axis2_http_request_line_t *AXIS2_CALL
 axis2_http_request_line_create(
@@ -82,47 +35,26 @@
     const axis2_char_t *uri,
     const axis2_char_t *http_version)
 {
-    axis2_http_request_line_impl_t *request_line_impl = NULL;
+    axis2_http_request_line_t *request_line = NULL;
     AXIS2_ENV_CHECK(env, NULL);
     AXIS2_PARAM_CHECK(env->error, method, NULL);
     AXIS2_PARAM_CHECK(env->error, uri, NULL);
     AXIS2_PARAM_CHECK(env->error, http_version, NULL);
 
-    request_line_impl = (axis2_http_request_line_impl_t *)AXIS2_MALLOC
-            (env->allocator, sizeof(
-                        axis2_http_request_line_impl_t));
+    request_line = (axis2_http_request_line_t *)AXIS2_MALLOC
+            (env->allocator, sizeof(axis2_http_request_line_t));
 
-    if (NULL == request_line_impl)
+    if (NULL == request_line)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
-    request_line_impl->method = (axis2_char_t *)axis2_strdup(method, env);
-    request_line_impl->uri = (axis2_char_t *)axis2_strdup(uri, env);
-    request_line_impl->http_version = (axis2_char_t *)axis2_strdup(
+    request_line->method = (axis2_char_t *)axis2_strdup(method, env);
+    request_line->uri = (axis2_char_t *)axis2_strdup(uri, env);
+    request_line->http_version = (axis2_char_t *)axis2_strdup(
                 http_version, env);
 
-    request_line_impl->request_line.ops = AXIS2_MALLOC(env->allocator,
-            sizeof(axis2_http_request_line_ops_t));
-    if (NULL == request_line_impl->request_line.ops)
-    {
-        axis2_http_request_line_free((axis2_http_request_line_t *)
-                request_line_impl, env);
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-    }
-
-    request_line_impl->request_line.ops->get_method =
-        axis2_http_request_line_get_method;
-    request_line_impl->request_line.ops->get_http_version =
-        axis2_http_request_line_get_http_version;
-    request_line_impl->request_line.ops->get_uri =
-        axis2_http_request_line_get_uri;
-    request_line_impl->request_line.ops->to_string =
-        axis2_http_request_line_to_string;
-    request_line_impl->request_line.ops->free =
-        axis2_http_request_line_free;
-    return &(request_line_impl->request_line);
+    return request_line;
 }
 
 axis2_status_t AXIS2_CALL
@@ -130,29 +62,22 @@
     axis2_http_request_line_t *request_line,
     const axis2_env_t *env)
 {
-    axis2_http_request_line_impl_t *request_line_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    request_line_impl = AXIS2_INTF_TO_IMPL(request_line);
 
-    if (request_line_impl->method)
+    if (request_line->method)
     {
-        AXIS2_FREE(env->allocator, request_line_impl->method);
-        request_line_impl->method = NULL;
+        AXIS2_FREE(env->allocator, request_line->method);
     }
-    if (request_line_impl->uri)
+    if (request_line->uri)
     {
-        AXIS2_FREE(env->allocator, request_line_impl->uri);
-        request_line_impl->uri = NULL;
+        AXIS2_FREE(env->allocator, request_line->uri);
     }
-    if (request_line_impl->http_version)
+    if (request_line->http_version)
     {
-        AXIS2_FREE(env->allocator, request_line_impl->http_version);
-        request_line_impl->http_version = NULL;
+        AXIS2_FREE(env->allocator, request_line->http_version);
     }
-    if (request_line->ops)
-        AXIS2_FREE(env->allocator, request_line->ops);
 
-    AXIS2_FREE(env->allocator, AXIS2_INTF_TO_IMPL(request_line));
+    AXIS2_FREE(env->allocator, request_line);
     return AXIS2_SUCCESS;
 }
 
@@ -227,8 +152,7 @@
     const axis2_http_request_line_t *request_line,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    return AXIS2_INTF_TO_IMPL(request_line)->method;
+    return request_line->method;
 }
 
 
@@ -237,8 +161,7 @@
     const axis2_http_request_line_t *request_line,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    return AXIS2_INTF_TO_IMPL(request_line)->http_version;
+    return request_line->http_version;
 }
 
 
@@ -247,8 +170,7 @@
     const axis2_http_request_line_t *request_line,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    return AXIS2_INTF_TO_IMPL(request_line)->uri;
+    return request_line->uri;
 }
 
 
@@ -257,17 +179,14 @@
     axis2_http_request_line_t *request_line,
     const axis2_env_t *env)
 {
-    axis2_http_request_line_impl_t *req_line_impl = NULL;
     int alloc_len = 0;
     axis2_char_t *ret = NULL;
 
     AXIS2_ENV_CHECK(env, NULL);
 
-    req_line_impl = AXIS2_INTF_TO_IMPL(
-                request_line);
-    alloc_len = axis2_strlen(req_line_impl->method) +
-            axis2_strlen(req_line_impl->uri) +
-            axis2_strlen(req_line_impl->http_version) + 6;
+    alloc_len = axis2_strlen(request_line->method) +
+            axis2_strlen(request_line->uri) +
+            axis2_strlen(request_line->http_version) + 6;
     /* 5 = 2 * spaces + '/' +CR + LF + '\0' */
 
     ret = AXIS2_MALLOC(env->allocator,
@@ -277,15 +196,15 @@
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
-    if (req_line_impl->uri[0] != '/')
+    if (request_line->uri[0] != '/')
     {
-        sprintf(ret, "%s /%s %s%s", req_line_impl->method, req_line_impl->uri,
-                req_line_impl->http_version, AXIS2_HTTP_CRLF);
+        sprintf(ret, "%s /%s %s%s", request_line->method, request_line->uri,
+                request_line->http_version, AXIS2_HTTP_CRLF);
     }
     else
     {
-        sprintf(ret, "%s %s %s%s", req_line_impl->method, req_line_impl->uri,
-                req_line_impl->http_version, AXIS2_HTTP_CRLF);
+        sprintf(ret, "%s %s %s%s", request_line->method, request_line->uri,
+                request_line->http_version, AXIS2_HTTP_CRLF);
     }
     return ret;
 }

Modified: webservices/axis2/trunk/c/modules/core/transport/http/common/http_simple_request.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/common/http_simple_request.c?view=diff&rev=519603&r1=519602&r2=519603
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/common/http_simple_request.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/common/http_simple_request.c Sun Mar 18 05:20:32 2007
@@ -22,107 +22,15 @@
 #include <string.h>
 #include <axis2_types.h>
 
-/**
- * @brief HTTP Simple Request struct impl
- *   Axis2 HTTP Simple Request impl
- */
-
-typedef struct axis2_http_simple_request_impl
+struct axis2_http_simple_request
 {
-    axis2_http_simple_request_t simple_request;
     axis2_http_request_line_t *request_line;
     axis2_array_list_t *header_group;
     axis2_stream_t *stream;
     axis2_bool_t owns_stream;
-}
-axis2_http_simple_request_impl_t;
-
-#define AXIS2_INTF_TO_IMPL(simple_request) \
-                 ((axis2_http_simple_request_impl_t *)(simple_request))
-
-/***************************** Function headers *******************************/
-
-axis2_http_request_line_t *AXIS2_CALL
-axis2_http_simple_request_get_request_line(
-    const axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env);
-
-axis2_status_t AXIS2_CALL
-axis2_http_simple_request_set_request_line(
-    axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env,
-    axis2_http_request_line_t *request_line);
-
-axis2_bool_t AXIS2_CALL
-axis2_http_simple_request_contains_header(
-    axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env,
-    const axis2_char_t *name);
-
-axis2_array_list_t *AXIS2_CALL
-axis2_http_simple_request_get_headers(
-    const axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env);
-
-axis2_http_header_t *AXIS2_CALL
-axis2_http_simple_request_get_first_header(
-    const axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env,
-    const axis2_char_t *str);
-
-axis2_status_t AXIS2_CALL
-axis2_http_simple_request_remove_headers(
-    axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env,
-    const axis2_char_t *str);
-
-axis2_status_t AXIS2_CALL
-axis2_http_simple_request_add_header(
-    axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env,
-    axis2_http_header_t *header);
-
-const axis2_char_t *AXIS2_CALL
-axis2_http_simple_request_get_content_type(
-    const axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env);
-
-const axis2_char_t *AXIS2_CALL
-axis2_http_simple_request_get_charset(
-    const axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env);
-
-axis2_ssize_t AXIS2_CALL
-axis2_http_simple_request_get_content_length(
-    const axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env);
-
-axis2_stream_t *AXIS2_CALL
-axis2_http_simple_request_get_body(
-    const axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env);
-
-axis2_ssize_t AXIS2_CALL
-axis2_http_simple_request_get_body_bytes(
-    const axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env,
-    char **buf);
-
-axis2_status_t AXIS2_CALL
-axis2_http_simple_request_set_body_string(
-    axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env,
-    void *str,
-    unsigned int str_len);
+};
 
-axis2_status_t AXIS2_CALL
-axis2_http_simple_request_free(
-    axis2_http_simple_request_t *simple_request,
-    const axis2_env_t *env);
-
-/***************************** End of function headers ************************/
-
-axis2_http_simple_request_t *AXIS2_CALL
+AXIS2_EXTERN axis2_http_simple_request_t *AXIS2_CALL
 axis2_http_simple_request_create(
     const axis2_env_t *env,
     axis2_http_request_line_t *request_line,
@@ -130,152 +38,102 @@
     axis2_ssize_t http_hdr_count,
     axis2_stream_t *content)
 {
-    axis2_http_simple_request_impl_t *simple_request_impl = NULL;
+    axis2_http_simple_request_t *simple_request = NULL;
     AXIS2_ENV_CHECK(env, NULL);
     AXIS2_ENV_CHECK(env, NULL);
 
-    simple_request_impl = (axis2_http_simple_request_impl_t *)AXIS2_MALLOC
+    simple_request = (axis2_http_simple_request_t *)AXIS2_MALLOC
             (env->allocator, sizeof(
-                        axis2_http_simple_request_impl_t));
+                        axis2_http_simple_request_t));
 
-    if (NULL == simple_request_impl)
+    if (NULL == simple_request)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
-    simple_request_impl->request_line = request_line;
-    simple_request_impl->stream = content;
-    simple_request_impl->header_group = NULL;
-    simple_request_impl->owns_stream = AXIS2_FALSE;
+    simple_request->request_line = request_line;
+    simple_request->stream = content;
+    simple_request->header_group = NULL;
+    simple_request->owns_stream = AXIS2_FALSE;
 
-    if (!(simple_request_impl->stream))
+    if (!(simple_request->stream))
     {
-        simple_request_impl->stream = axis2_stream_create_basic(env);
-        if (NULL == simple_request_impl->stream)
+        simple_request->stream = axis2_stream_create_basic(env);
+        if (NULL == simple_request->stream)
         {
             axis2_http_simple_request_free((axis2_http_simple_request_t *)
-                    simple_request_impl, env);
+                    simple_request, env);
             AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
             return NULL;
         }
-        simple_request_impl->owns_stream = AXIS2_TRUE;
+        simple_request->owns_stream = AXIS2_TRUE;
     }
 
     if (http_hdr_count > 0 &&  http_headers)
     {
         int i = 0;
-        simple_request_impl->header_group = axis2_array_list_create(env,
+        simple_request->header_group = axis2_array_list_create(env,
                 http_hdr_count);
 
         for (i = 0; i < http_hdr_count; i++)
         {
-            axis2_array_list_add(simple_request_impl->header_group, env,
+            axis2_array_list_add(simple_request->header_group, env,
                     (void *)http_headers[i]);
         }
     }
-    /*
-        TODO : handle chunked streams
-    */
-    simple_request_impl->simple_request.ops = AXIS2_MALLOC(env->allocator,
-            sizeof(axis2_http_simple_request_ops_t));
-    if (NULL == simple_request_impl->simple_request.ops)
-    {
-        axis2_http_simple_request_free((axis2_http_simple_request_t*)
-                simple_request_impl, env);
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-    }
-
-    simple_request_impl->simple_request.ops->get_request_line =
-        axis2_http_simple_request_get_request_line;
-    simple_request_impl->simple_request.ops->set_request_line =
-        axis2_http_simple_request_set_request_line;
-    simple_request_impl->simple_request.ops->contains_header =
-        axis2_http_simple_request_contains_header;
-    simple_request_impl->simple_request.ops->get_headers =
-        axis2_http_simple_request_get_headers;
-    simple_request_impl->simple_request.ops->get_first_header =
-        axis2_http_simple_request_get_first_header;
-    simple_request_impl->simple_request.ops->remove_headers =
-        axis2_http_simple_request_remove_headers;
-    simple_request_impl->simple_request.ops->add_header =
-        axis2_http_simple_request_add_header;
-    simple_request_impl->simple_request.ops->get_content_type =
-        axis2_http_simple_request_get_content_type;
-    simple_request_impl->simple_request.ops->get_charset =
-        axis2_http_simple_request_get_charset;
-    simple_request_impl->simple_request.ops->get_content_length =
-        axis2_http_simple_request_get_content_length;
-    simple_request_impl->simple_request.ops->get_body =
-        axis2_http_simple_request_get_body;
-    simple_request_impl->simple_request.ops->get_body_bytes =
-        axis2_http_simple_request_get_body_bytes;
-    simple_request_impl->simple_request.ops->set_body_string =
-        axis2_http_simple_request_set_body_string;
-    simple_request_impl->simple_request.ops->free =
-        axis2_http_simple_request_free;
 
-    return &(simple_request_impl->simple_request);
+    return simple_request;
 }
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_simple_request_free(
     axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env)
 {
-    axis2_http_simple_request_impl_t *simple_request_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
-    simple_request_impl = AXIS2_INTF_TO_IMPL(simple_request);
-    if (AXIS2_TRUE == simple_request_impl->owns_stream)
+    if (AXIS2_TRUE == simple_request->owns_stream)
     {
-        AXIS2_STREAM_FREE(simple_request_impl->stream, env);
-        simple_request_impl->stream = NULL;
+        AXIS2_STREAM_FREE(simple_request->stream, env);
     }
     /*
         Don't free the stream since it belongs to the socket
         TODO : if chunked remove the chunked stream.
     */
-    if (simple_request_impl->request_line)
+    if (simple_request->request_line)
     {
-        AXIS2_HTTP_REQUEST_LINE_FREE(simple_request_impl->request_line, env);
-        simple_request_impl->request_line = NULL;
+        AXIS2_HTTP_REQUEST_LINE_FREE(simple_request->request_line, env);
     }
-    if (simple_request_impl->header_group)
+    if (simple_request->header_group)
     {
         int i = 0;
         axis2_http_header_t *tmp = NULL;
-        for (i = 0; i < axis2_array_list_size(simple_request_impl->header_group,
+        for (i = 0; i < axis2_array_list_size(simple_request->header_group,
                 env); i++)
         {
             tmp = (axis2_http_header_t *)axis2_array_list_get(
-                        simple_request_impl->header_group, env, i);
+                        simple_request->header_group, env, i);
             AXIS2_HTTP_HEADER_FREE(tmp, env);
 
         }
-        axis2_array_list_free(simple_request_impl->header_group, env);
-        simple_request_impl->header_group = NULL;
+        axis2_array_list_free(simple_request->header_group, env);
     }
 
-    if (simple_request->ops)
-        AXIS2_FREE(env->allocator, simple_request->ops);
-
-    AXIS2_FREE(env->allocator, simple_request_impl);
+    AXIS2_FREE(env->allocator, simple_request);
 
     return AXIS2_SUCCESS;
 }
 
-axis2_http_request_line_t *AXIS2_CALL
+AXIS2_EXTERN axis2_http_request_line_t *AXIS2_CALL
 axis2_http_simple_request_get_request_line(
     const axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    return AXIS2_INTF_TO_IMPL(simple_request)->request_line;
+    return simple_request->request_line;
 }
 
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_simple_request_set_request_line(
     axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env,
@@ -283,12 +141,12 @@
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, request_line, AXIS2_FAILURE);
-    AXIS2_INTF_TO_IMPL(simple_request)->request_line = request_line;
+    simple_request->request_line = request_line;
     return AXIS2_SUCCESS;
 }
 
 
-axis2_bool_t AXIS2_CALL
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
 axis2_http_simple_request_contains_header(
     axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env,
@@ -296,20 +154,17 @@
 {
     int i = 0;
     axis2_char_t *header_name = NULL;
-    axis2_http_simple_request_impl_t *simple_request_impl = NULL;
     int count = 0;
 
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, name, AXIS2_FAILURE);
 
-    simple_request_impl = AXIS2_INTF_TO_IMPL(simple_request);
-
-    if (NULL == simple_request_impl->header_group)
+    if (NULL == simple_request->header_group)
     {
         return AXIS2_FALSE;
     }
 
-    count = axis2_array_list_size(simple_request_impl->header_group, env);
+    count = axis2_array_list_size(simple_request->header_group, env);
 
     if (0 == count)
     {
@@ -319,7 +174,7 @@
     for (i = 0; i < count; i++)
     {
         header_name = AXIS2_HTTP_HEADER_GET_NAME((axis2_http_header_t *)
-                axis2_array_list_get(simple_request_impl->header_group,
+                axis2_array_list_get(simple_request->header_group,
                         env, i), env);
         if (0 == axis2_strcasecmp(name, header_name))
             return AXIS2_TRUE;
@@ -328,23 +183,21 @@
 }
 
 
-axis2_array_list_t *AXIS2_CALL
+AXIS2_EXTERN axis2_array_list_t *AXIS2_CALL
 axis2_http_simple_request_get_headers(
     const axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    return AXIS2_INTF_TO_IMPL(simple_request)->header_group;
+    return simple_request->header_group;
 }
 
 
-axis2_http_header_t *AXIS2_CALL
+AXIS2_EXTERN axis2_http_header_t *AXIS2_CALL
 axis2_http_simple_request_get_first_header(
     const axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env,
     const axis2_char_t *str)
 {
-    axis2_http_simple_request_impl_t *simple_request_impl = NULL;
     axis2_array_list_t *header_group = NULL;
     int i = 0;
     int count = 0;
@@ -354,10 +207,8 @@
     AXIS2_ENV_CHECK(env, NULL);
     AXIS2_PARAM_CHECK(env->error, str, NULL);
 
-    simple_request_impl = AXIS2_INTF_TO_IMPL(simple_request);
-
-    header_group = simple_request_impl->header_group;
-    if (NULL == simple_request_impl->header_group)
+    header_group = simple_request->header_group;
+    if (NULL == simple_request->header_group)
     {
         return NULL;
     }
@@ -385,7 +236,7 @@
 }
 
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_simple_request_remove_headers(
     axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env,
@@ -400,7 +251,7 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, str, AXIS2_FAILURE);
 
-    header_group = AXIS2_INTF_TO_IMPL(simple_request)->header_group;
+    header_group = simple_request->header_group;
 
     if (NULL == header_group)
     {
@@ -429,28 +280,25 @@
 }
 
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_simple_request_add_header(
     axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env,
     axis2_http_header_t *header)
 {
-    axis2_http_simple_request_impl_t *simple_request_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, header, AXIS2_FAILURE);
 
-    simple_request_impl = AXIS2_INTF_TO_IMPL(
-                simple_request);
-    if (NULL == simple_request_impl->header_group)
+    if (NULL == simple_request->header_group)
     {
-        simple_request_impl->header_group = axis2_array_list_create(env, 1);
+        simple_request->header_group = axis2_array_list_create(env, 1);
     }
-    return axis2_array_list_add(AXIS2_INTF_TO_IMPL(simple_request)->header_group,
+    return axis2_array_list_add(simple_request->header_group,
             env, header);
 }
 
 
-const axis2_char_t *AXIS2_CALL
+AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
 axis2_http_simple_request_get_content_type(
     const axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env)
@@ -466,7 +314,7 @@
 }
 
 
-const axis2_char_t *AXIS2_CALL
+AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
 axis2_http_simple_request_get_charset(
     const axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env)
@@ -491,7 +339,7 @@
 }
 
 
-axis2_ssize_t AXIS2_CALL
+AXIS2_EXTERN axis2_ssize_t AXIS2_CALL
 axis2_http_simple_request_get_content_length(
     const axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env)
@@ -508,17 +356,16 @@
 }
 
 
-axis2_stream_t *AXIS2_CALL
+AXIS2_EXTERN axis2_stream_t *AXIS2_CALL
 axis2_http_simple_request_get_body(
     const axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    return AXIS2_INTF_TO_IMPL(simple_request)->stream;
+    return simple_request->stream;
 }
 
 
-axis2_ssize_t AXIS2_CALL
+AXIS2_EXTERN axis2_ssize_t AXIS2_CALL
 axis2_http_simple_request_get_body_bytes(
     const axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env,
@@ -533,7 +380,7 @@
 
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
-    body = AXIS2_INTF_TO_IMPL(simple_request)->stream;
+    body = simple_request->stream;
     if (NULL == body)
     {
         *buf = (char*)AXIS2_MALLOC(env->allocator, 1);
@@ -570,7 +417,7 @@
     return -1;
 }
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_simple_request_set_body_string(
     axis2_http_simple_request_t *simple_request,
     const axis2_env_t *env,
@@ -581,7 +428,7 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, str, AXIS2_FAILURE);
 
-    body_stream = AXIS2_INTF_TO_IMPL(simple_request)->stream;
+    body_stream = simple_request->stream;
     if (NULL == body_stream)
     {
         body_stream = axis2_stream_create_basic(env);
@@ -589,8 +436,8 @@
         {
             return AXIS2_FAILURE;
         }
-        AXIS2_INTF_TO_IMPL(simple_request)->stream = body_stream;
-        AXIS2_INTF_TO_IMPL(simple_request)->owns_stream = AXIS2_TRUE;
+        simple_request->stream = body_stream;
+        simple_request->owns_stream = AXIS2_TRUE;
     }
     AXIS2_STREAM_WRITE(body_stream, env, str, str_len);
     return AXIS2_SUCCESS;

Modified: webservices/axis2/trunk/c/modules/core/transport/http/common/http_simple_response.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/common/http_simple_response.c?view=diff&rev=519603&r1=519602&r2=519603
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/common/http_simple_response.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/common/http_simple_response.c Sun Mar 18 05:20:32 2007
@@ -21,128 +21,14 @@
 #include <string.h>
 #include <axis2_types.h>
 
-/**
- * @brief HTTP Simple Response struct impl
- *   Axis2 HTTP Simple Response impl
- */
-#define READ_SIZE 2048
+#define AXIS2_HTTP_SIMPLE_RESPONSE_READ_SIZE 2048
 
-
-typedef struct axis2_http_simple_response_impl
+struct axis2_http_simple_response
 {
-    axis2_http_simple_response_t simple_response;
     axis2_http_status_line_t *status_line;
     axis2_array_list_t *header_group;
     axis2_stream_t *stream;
-}
-axis2_http_simple_response_impl_t;
-
-#define AXIS2_INTF_TO_IMPL(simple_response) \
-                 ((axis2_http_simple_response_impl_t *)(simple_response))
-
-/***************************** Function headers *******************************/
-
-axis2_status_t AXIS2_CALL
-axis2_http_simple_response_set_status_line(
-    struct axis2_http_simple_response *simple_response,
-    const axis2_env_t *env,
-    const axis2_char_t *http_ver,
-    const int status_code,
-    const axis2_char_t *phrase);
-
-axis2_char_t *AXIS2_CALL
-axis2_http_simple_response_get_phrase(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env);
-
-int AXIS2_CALL
-axis2_http_simple_response_get_status_code(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env);
-
-axis2_char_t *AXIS2_CALL
-axis2_http_simple_response_get_http_version(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env);
-
-axis2_char_t *AXIS2_CALL
-axis2_http_simple_response_get_status_line(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env);
-
-axis2_bool_t AXIS2_CALL
-axis2_http_simple_response_contains_header(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env,
-    const axis2_char_t *name);
-
-axis2_array_list_t *AXIS2_CALL
-axis2_http_simple_response_get_headers(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env);
-
-axis2_http_header_t *AXIS2_CALL
-axis2_http_simple_response_get_first_header(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env,
-    const axis2_char_t *str);
-
-axis2_status_t AXIS2_CALL
-axis2_http_simple_response_remove_headers(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env,
-    const axis2_char_t *str);
-
-axis2_status_t AXIS2_CALL
-axis2_http_simple_response_set_header(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env,
-    axis2_http_header_t *header);
-
-const axis2_char_t *AXIS2_CALL
-axis2_http_simple_response_get_charset(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env);
-
-axis2_ssize_t AXIS2_CALL
-axis2_http_simple_response_get_content_length(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env);
-
-const axis2_char_t *AXIS2_CALL
-axis2_http_simple_response_get_content_type(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env);
-
-axis2_status_t AXIS2_CALL
-axis2_http_simple_response_set_body_string(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env,
-    axis2_char_t *str);
-
-axis2_status_t AXIS2_CALL
-axis2_http_simple_response_set_body_stream(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env,
-    axis2_stream_t *stream);
-
-axis2_stream_t *AXIS2_CALL
-axis2_http_simple_response_get_body(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env);
-
-axis2_ssize_t AXIS2_CALL
-axis2_http_simple_response_get_body_bytes(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env,
-    axis2_char_t **buf);
-
-axis2_status_t AXIS2_CALL
-axis2_http_simple_response_free(
-    axis2_http_simple_response_t *simple_response,
-    const axis2_env_t *env);
-
-/***************************** End of function headers ************************/
+};
 
 AXIS2_EXTERN axis2_http_simple_response_t *AXIS2_CALL
 axis2_http_simple_response_create(
@@ -153,7 +39,7 @@
     axis2_stream_t *content)
 {
     axis2_http_simple_response_t *ret = NULL;
-    axis2_http_simple_response_impl_t *simple_response_impl = NULL;
+    axis2_http_simple_response_t *simple_response = NULL;
     AXIS2_ENV_CHECK(env, NULL);
     AXIS2_ENV_CHECK(env, NULL);
 
@@ -162,27 +48,27 @@
     {
         return NULL;
     }
-    simple_response_impl = AXIS2_INTF_TO_IMPL(ret);
+    simple_response = ret;
 
-    if (NULL == simple_response_impl)
+    if (NULL == simple_response)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
-    simple_response_impl->status_line = status_line;
+    simple_response->status_line = status_line;
     if (http_hdr_count > 0 &&  http_headers)
     {
         int i = 0;
-        simple_response_impl->header_group = axis2_array_list_create(env,
+        simple_response->header_group = axis2_array_list_create(env,
                 http_hdr_count);
 
         for (i = 0; i < http_hdr_count; i++)
         {
-            axis2_array_list_add(simple_response_impl->header_group, env,
+            axis2_array_list_add(simple_response->header_group, env,
                     (void *)http_headers[i]);
         }
     }
-    simple_response_impl->stream = content;
+    simple_response->stream = content;
 
     return ret;
 }
@@ -192,64 +78,18 @@
 axis2_http_simple_response_create_default(
     const axis2_env_t *env)
 {
-    axis2_http_simple_response_impl_t *simple_response_impl = NULL;
+    axis2_http_simple_response_t *simple_response = NULL;
     AXIS2_ENV_CHECK(env, NULL);
 
-    simple_response_impl = (axis2_http_simple_response_impl_t *)AXIS2_MALLOC
+    simple_response = (axis2_http_simple_response_t *)AXIS2_MALLOC
             (env->allocator, sizeof(
-                        axis2_http_simple_response_impl_t));
+                        axis2_http_simple_response_t));
 
-    simple_response_impl->simple_response.ops = AXIS2_MALLOC(env->allocator,
-            sizeof(axis2_http_simple_response_ops_t));
-    if (NULL == simple_response_impl->simple_response.ops)
-    {
-        axis2_http_simple_response_free((axis2_http_simple_response_t *)
-                simple_response_impl, env);
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-    }
-    simple_response_impl->status_line = NULL;
-    simple_response_impl->header_group = NULL;
-    simple_response_impl->stream = NULL;
-
-    simple_response_impl->simple_response.ops->set_status_line =
-        axis2_http_simple_response_set_status_line;
-    simple_response_impl->simple_response.ops->get_phrase =
-        axis2_http_simple_response_get_phrase;
-    simple_response_impl->simple_response.ops->get_status_code =
-        axis2_http_simple_response_get_status_code;
-    simple_response_impl->simple_response.ops->get_http_version =
-        axis2_http_simple_response_get_http_version;
-    simple_response_impl->simple_response.ops->get_status_line =
-        axis2_http_simple_response_get_status_line;
-    simple_response_impl->simple_response.ops->contains_header =
-        axis2_http_simple_response_contains_header;
-    simple_response_impl->simple_response.ops->get_headers =
-        axis2_http_simple_response_get_headers;
-    simple_response_impl->simple_response.ops->get_first_header =
-        axis2_http_simple_response_get_first_header;
-    simple_response_impl->simple_response.ops->remove_headers =
-        axis2_http_simple_response_remove_headers;
-    simple_response_impl->simple_response.ops->set_header =
-        axis2_http_simple_response_set_header;
-    simple_response_impl->simple_response.ops->get_charset =
-        axis2_http_simple_response_get_charset;
-    simple_response_impl->simple_response.ops->get_content_type =
-        axis2_http_simple_response_get_content_type;
-    simple_response_impl->simple_response.ops->get_content_length =
-        axis2_http_simple_response_get_content_length;
-    simple_response_impl->simple_response.ops->set_body_string =
-        axis2_http_simple_response_set_body_string;
-    simple_response_impl->simple_response.ops->set_body_stream =
-        axis2_http_simple_response_set_body_stream;
-    simple_response_impl->simple_response.ops->get_body =
-        axis2_http_simple_response_get_body;
-    simple_response_impl->simple_response.ops->get_body_bytes =
-        axis2_http_simple_response_get_body_bytes;
-    simple_response_impl->simple_response.ops->free =
-        axis2_http_simple_response_free;
+    simple_response->status_line = NULL;
+    simple_response->header_group = NULL;
+    simple_response->stream = NULL;
 
-    return &(simple_response_impl->simple_response);
+    return simple_response;
 }
 
 axis2_status_t AXIS2_CALL
@@ -257,36 +97,30 @@
     axis2_http_simple_response_t *simple_response,
     const axis2_env_t *env)
 {
-    axis2_http_simple_response_impl_t *simple_response_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    simple_response_impl = AXIS2_INTF_TO_IMPL(simple_response);
 
-    if (simple_response_impl->status_line)
+    if (simple_response->status_line)
     {
-        AXIS2_HTTP_STATUS_LINE_FREE(simple_response_impl->status_line, env);
-        simple_response_impl->status_line = NULL;
+        AXIS2_HTTP_STATUS_LINE_FREE(simple_response->status_line, env);
     }
-    if (simple_response_impl->header_group)
+    if (simple_response->header_group)
     {
         int i = 0;
         axis2_http_header_t *tmp = NULL;
-        for (i = 0; i < axis2_array_list_size(simple_response_impl->header_group,
+        for (i = 0; i < axis2_array_list_size(simple_response->header_group,
                 env); i++)
         {
             tmp = (axis2_http_header_t *)axis2_array_list_get(
-                        simple_response_impl->header_group, env, i);
+                        simple_response->header_group, env, i);
             if (tmp)
             {
                 AXIS2_HTTP_HEADER_FREE(tmp, env);
             }
         }
-        axis2_array_list_free(simple_response_impl->header_group, env);
-        simple_response_impl->header_group = NULL;
+        axis2_array_list_free(simple_response->header_group, env);
     }
-    if (simple_response->ops)
-        AXIS2_FREE(env->allocator, simple_response->ops);
 
-    AXIS2_FREE(env->allocator, AXIS2_INTF_TO_IMPL(simple_response));
+    AXIS2_FREE(env->allocator, simple_response);
     /* Stream is not freed
      * Assumption : stream doesn't belong to the response
      */
@@ -302,7 +136,6 @@
     const axis2_char_t *phrase)
 {
     axis2_char_t *tmp_status_line_str = NULL;
-    axis2_http_simple_response_impl_t *simple_response_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, http_ver, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, status_code, AXIS2_FAILURE);
@@ -313,18 +146,16 @@
             sizeof(axis2_char_t *));
     sprintf(tmp_status_line_str, "%s %3d %s%s", http_ver, status_code, phrase,
             AXIS2_HTTP_CRLF);
-    simple_response_impl = AXIS2_INTF_TO_IMPL
-            (simple_response);
-    if (simple_response_impl->status_line)
+    if (simple_response->status_line)
     {
-        AXIS2_HTTP_STATUS_LINE_FREE(simple_response_impl->status_line, env);
-        simple_response_impl->status_line = NULL;
+        AXIS2_HTTP_STATUS_LINE_FREE(simple_response->status_line, env);
+        simple_response->status_line = NULL;
     }
-    simple_response_impl->status_line = axis2_http_status_line_create(env,
+    simple_response->status_line = axis2_http_status_line_create(env,
             tmp_status_line_str);
     AXIS2_FREE(env->allocator, tmp_status_line_str);
 
-    if (NULL == simple_response_impl->status_line)
+    if (NULL == simple_response->status_line)
     {
         return AXIS2_FAILURE;
     }
@@ -337,13 +168,11 @@
     axis2_http_simple_response_t *simple_response,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    if (NULL == AXIS2_INTF_TO_IMPL(simple_response)->status_line)
+    if (!(simple_response->status_line))
     {
         return NULL;
     }
-    return AXIS2_HTTP_STATUS_LINE_GET_REASON_PHRASE(AXIS2_INTF_TO_IMPL(
-                simple_response)->status_line, env);
+    return AXIS2_HTTP_STATUS_LINE_GET_REASON_PHRASE(simple_response->status_line, env);
 }
 
 
@@ -352,13 +181,11 @@
     axis2_http_simple_response_t *simple_response,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    if (NULL == AXIS2_INTF_TO_IMPL(simple_response)->status_line)
+    if (!(simple_response->status_line))
     {
         return -1;
     }
-    return AXIS2_HTTP_STATUS_LINE_GET_STATUS_CODE(AXIS2_INTF_TO_IMPL(
-                simple_response)->status_line, env);
+    return AXIS2_HTTP_STATUS_LINE_GET_STATUS_CODE(simple_response->status_line, env);
 }
 
 
@@ -367,13 +194,11 @@
     axis2_http_simple_response_t *simple_response,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    if (NULL == AXIS2_INTF_TO_IMPL(simple_response)->status_line)
+    if (!(simple_response->status_line))
     {
         return NULL;
     }
-    return AXIS2_HTTP_STATUS_LINE_GET_HTTP_VERSION(AXIS2_INTF_TO_IMPL(
-                simple_response)->status_line, env);
+    return AXIS2_HTTP_STATUS_LINE_GET_HTTP_VERSION(simple_response->status_line, env);
 }
 
 
@@ -383,12 +208,11 @@
     const axis2_env_t *env)
 {
     AXIS2_ENV_CHECK(env, NULL);
-    if (NULL == AXIS2_INTF_TO_IMPL(simple_response)->status_line)
+    if (!(simple_response->status_line))
     {
         return NULL;
     }
-    return AXIS2_HTTP_STATUS_LINE_TO_STRING(AXIS2_INTF_TO_IMPL(
-                simple_response)->status_line, env);
+    return AXIS2_HTTP_STATUS_LINE_TO_STRING(simple_response->status_line, env);
 }
 
 axis2_array_list_t *AXIS2_CALL
@@ -396,8 +220,7 @@
     axis2_http_simple_response_t *simple_response,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    return AXIS2_INTF_TO_IMPL(simple_response)->header_group;
+    return simple_response->header_group;
 }
 
 axis2_http_header_t *AXIS2_CALL
@@ -406,7 +229,6 @@
     const axis2_env_t *env,
     const axis2_char_t *str)
 {
-    axis2_http_simple_response_impl_t *simple_response_impl = NULL;
     axis2_http_header_t *tmp_header = NULL;
     axis2_char_t *tmp_name = NULL;
     int i = 0;
@@ -416,9 +238,8 @@
     AXIS2_ENV_CHECK(env, NULL);
     AXIS2_PARAM_CHECK(env->error, str, NULL);
 
-    simple_response_impl = AXIS2_INTF_TO_IMPL(simple_response);
-    header_group = simple_response_impl->header_group;
-    if (NULL == simple_response_impl->header_group)
+    header_group = simple_response->header_group;
+    if (NULL == simple_response->header_group)
     {
         return NULL;
     }
@@ -459,8 +280,7 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, str, AXIS2_FAILURE);
 
-    header_group = AXIS2_INTF_TO_IMPL(simple_response)->
-            header_group;
+    header_group = simple_response->header_group;
     if (NULL == header_group)
     {
         /* Even though we couldn't complete the op, we are sure that the
@@ -499,25 +319,21 @@
     axis2_http_header_t *tmp_header = NULL;
     axis2_char_t *tmp_name = NULL;
     axis2_array_list_t *header_group = NULL;
-    axis2_http_simple_response_impl_t *simple_response_impl = NULL;
 
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, header, AXIS2_FAILURE);
 
-    simple_response_impl = AXIS2_INTF_TO_IMPL
-            (simple_response);
-
-    if (NULL == simple_response_impl->header_group)
+    if (NULL == simple_response->header_group)
     {
-        simple_response_impl->header_group = axis2_array_list_create(env, 10);
-        axis2_array_list_add(simple_response_impl->header_group, env, header);
+        simple_response->header_group = axis2_array_list_create(env, 10);
+        axis2_array_list_add(simple_response->header_group, env, header);
         return AXIS2_SUCCESS;
     }
 
     /* If a header with the same name exists
      * search and remove the old header
      */
-    header_group = AXIS2_INTF_TO_IMPL(simple_response)->header_group;
+    header_group = simple_response->header_group;
 
     count = axis2_array_list_size(header_group, env);
     for (i = 0; i < count; i++)
@@ -533,7 +349,7 @@
             break;
         }
     }
-    axis2_array_list_add(simple_response_impl->header_group, env,
+    axis2_array_list_add(simple_response->header_group, env,
             (void *)header);
     return AXIS2_SUCCESS;
 }
@@ -607,7 +423,7 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, str, AXIS2_FAILURE);
 
-    body_stream = AXIS2_INTF_TO_IMPL(simple_response)->stream;
+    body_stream = simple_response->stream;
     if (NULL == body_stream)
     {
         body_stream = axis2_stream_create_basic(env);
@@ -615,7 +431,7 @@
         {
             return AXIS2_FAILURE;
         }
-        AXIS2_INTF_TO_IMPL(simple_response)->stream = body_stream;
+        simple_response->stream = body_stream;
     }
     AXIS2_STREAM_WRITE(body_stream, env, str, axis2_strlen(str));
     return AXIS2_SUCCESS;
@@ -627,13 +443,12 @@
     const axis2_env_t *env,
     axis2_stream_t *stream)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     /*
      * We don't free the stream
      * Problem in freeing is most of the time the stream doesn't belong
      * to the http_simple_response
      */
-    AXIS2_INTF_TO_IMPL(simple_response)->stream = stream;
+    simple_response->stream = stream;
     return AXIS2_SUCCESS;
 }
 
@@ -642,8 +457,7 @@
     axis2_http_simple_response_t *simple_response,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    return AXIS2_INTF_TO_IMPL(simple_response)->stream;
+    return simple_response->stream;
 }
 
 
@@ -653,15 +467,12 @@
     const axis2_env_t *env,
     axis2_char_t **buffer)
 {
-    axis2_http_simple_response_impl_t *response_impl = NULL;
     axis2_stream_t *tmp_stream = NULL;
     int return_size = -1;
 
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
-
-    response_impl = AXIS2_INTF_TO_IMPL(simple_response);
-    if (NULL == response_impl->stream)
+    if (NULL == simple_response->stream)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NULL_BODY, AXIS2_FAILURE);
         return -1;
@@ -671,15 +482,15 @@
     {
         int read = 0;
         int write = 0;
-        /*   int READ_SIZE = 32; */
-        char buf[READ_SIZE];
-        read = AXIS2_STREAM_READ(response_impl->stream, env, buf, READ_SIZE);
+        /*   int AXIS2_HTTP_SIMPLE_RESPONSE_READ_SIZE = 32; */
+        char buf[AXIS2_HTTP_SIMPLE_RESPONSE_READ_SIZE];
+        read = AXIS2_STREAM_READ(simple_response->stream, env, buf, AXIS2_HTTP_SIMPLE_RESPONSE_READ_SIZE);
         if (read < 0)
         {
             break;
         }
         write = AXIS2_STREAM_WRITE(tmp_stream, env, buf, read);
-        if (read < (READ_SIZE - 1))
+        if (read < (AXIS2_HTTP_SIMPLE_RESPONSE_READ_SIZE - 1))
         {
             break;
         }
@@ -704,19 +515,16 @@
     const axis2_char_t *name)
 {
     axis2_char_t *header_name = NULL;
-    axis2_http_simple_response_impl_t *simple_response_impl = NULL;
     int count = 0;
     int i = 0;
 
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, name, AXIS2_FAILURE);
-    simple_response_impl = AXIS2_INTF_TO_IMPL(
-                simple_response);
-    if (NULL == simple_response_impl->header_group)
+    if (NULL == simple_response->header_group)
     {
         return AXIS2_FALSE;
     }
-    count = axis2_array_list_size(simple_response_impl->header_group, env);
+    count = axis2_array_list_size(simple_response->header_group, env);
     if (0 == count)
     {
         return AXIS2_FALSE;
@@ -725,7 +533,7 @@
     for (i = 0; i < count; i++)
     {
         header_name = AXIS2_HTTP_HEADER_GET_NAME((axis2_http_header_t *)
-                axis2_array_list_get(simple_response_impl->header_group,
+                axis2_array_list_get(simple_response->header_group,
                         env, i), env);
         if (0 == axis2_strcasecmp(name, header_name))
             return AXIS2_TRUE;

Modified: webservices/axis2/trunk/c/modules/core/transport/http/common/http_status_line.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/common/http_status_line.c?view=diff&rev=519603&r1=519602&r2=519603
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/common/http_status_line.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/common/http_status_line.c Sun Mar 18 05:20:32 2007
@@ -21,56 +21,13 @@
 #include <string.h>
 #include <axis2_types.h>
 
-/**
- * @brief HTTP Status Line struct impl
- * Axis2 HTTP Status Line impl
- */
-
-typedef struct axis2_http_status_line_impl
+struct axis2_http_status_line
 {
-    axis2_http_status_line_t status_line;
     axis2_char_t *line;
     axis2_char_t *http_version;
     axis2_char_t *status_code;
     axis2_char_t *reason_phrase;
-}
-axis2_http_status_line_impl_t;
-
-#define AXIS2_INTF_TO_IMPL(status_line) \
-                    ((axis2_http_status_line_impl_t *)(status_line))
-
-/***************************** Function headers *******************************/
-int AXIS2_CALL
-axis2_http_status_line_get_status_code(
-    const axis2_http_status_line_t *status_line,
-    const axis2_env_t *env);
-
-axis2_char_t *AXIS2_CALL
-axis2_http_status_line_get_http_version(
-    const axis2_http_status_line_t *status_line,
-    const axis2_env_t *env);
-
-axis2_char_t *AXIS2_CALL
-axis2_http_status_line_get_reason_phrase(
-    const axis2_http_status_line_t *status_line,
-    const axis2_env_t *env);
-
-axis2_bool_t AXIS2_CALL
-axis2_http_status_line_starts_with_http(
-    axis2_http_status_line_t *status_line,
-    const axis2_env_t *env);
-
-axis2_char_t *AXIS2_CALL
-axis2_http_status_line_to_string(
-    axis2_http_status_line_t *status_line,
-    const axis2_env_t *env);
-
-axis2_status_t AXIS2_CALL
-axis2_http_status_line_free(
-    axis2_http_status_line_t *status_line,
-    const axis2_env_t *env);
-
-/***************************** End of function headers ************************/
+};
 
 AXIS2_EXTERN axis2_http_status_line_t *AXIS2_CALL
 axis2_http_status_line_create(
@@ -83,30 +40,30 @@
     axis2_char_t *http_version = NULL;
     int i = 0;
     axis2_char_t *tmp = NULL;
-    axis2_http_status_line_impl_t *status_line_impl  = NULL;
+    axis2_http_status_line_t *status_line  = NULL;
 
     AXIS2_ENV_CHECK(env, NULL);
 
-    status_line_impl = (axis2_http_status_line_impl_t *)AXIS2_MALLOC
+    status_line = (axis2_http_status_line_t *)AXIS2_MALLOC
             (env->allocator, sizeof(
-                        axis2_http_status_line_impl_t));
+                        axis2_http_status_line_t));
 
-    if (NULL == status_line_impl)
+    if (NULL == status_line)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
-    status_line_impl->status_line.ops = NULL;
-    status_line_impl->line = (axis2_char_t *)axis2_strdup(str, env);
-    status_line_impl->http_version = NULL;
-    status_line_impl->reason_phrase = NULL;
-    status_line_impl->status_code = NULL;
+
+	status_line->line = (axis2_char_t *)axis2_strdup(str, env);
+    status_line->http_version = NULL;
+    status_line->reason_phrase = NULL;
+    status_line->status_code = NULL;
 
     tmp = strstr(str, AXIS2_HTTP_CRLF);
     if (NULL == tmp)
     {
         axis2_http_status_line_free((axis2_http_status_line_t *)
-                status_line_impl, env);
+                status_line, env);
         AXIS2_ERROR_SET(env->error,
                 AXIS2_ERROR_INVALID_HTTP_HEADER_START_LINE,
                 AXIS2_FAILURE);
@@ -118,7 +75,7 @@
     if (NULL == tmp_status_line)
     {
         axis2_http_status_line_free((axis2_http_status_line_t *)
-                status_line_impl, env);
+                status_line, env);
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
@@ -132,7 +89,7 @@
     {
         AXIS2_FREE(env->allocator, tmp_status_line);
         axis2_http_status_line_free((axis2_http_status_line_t *)
-                status_line_impl, env);
+                status_line, env);
         AXIS2_ERROR_SET(env->error,
                 AXIS2_ERROR_INVALID_HTTP_HEADER_START_LINE,
                 AXIS2_FAILURE);
@@ -145,7 +102,7 @@
     {
         AXIS2_FREE(env->allocator, tmp_status_line);
         axis2_http_status_line_free((axis2_http_status_line_t *)
-                status_line_impl, env);
+                status_line, env);
         AXIS2_ERROR_SET(env->error,
                 AXIS2_ERROR_INVALID_HTTP_HEADER_START_LINE,
                 AXIS2_FAILURE);
@@ -153,94 +110,64 @@
     }
     *tmp++ = '\0';
     reason_phrase = tmp;
-    status_line_impl->http_version = (axis2_char_t *)
+    status_line->http_version = (axis2_char_t *)
             axis2_strdup(http_version, env);
-    status_line_impl->status_code = (axis2_char_t *)
+    status_line->status_code = (axis2_char_t *)
             axis2_strdup(status_code, env);
-    status_line_impl->reason_phrase = (axis2_char_t *)
+    status_line->reason_phrase = (axis2_char_t *)
             axis2_strdup(reason_phrase, env);
 
-    if (NULL == status_line_impl->http_version ||
-            NULL == status_line_impl->reason_phrase)
+    if (NULL == status_line->http_version ||
+            NULL == status_line->reason_phrase)
     {
         AXIS2_FREE(env->allocator, tmp_status_line);
         axis2_http_status_line_free((axis2_http_status_line_t *)
-                status_line_impl, env);
+                status_line, env);
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
     AXIS2_FREE(env->allocator, tmp_status_line);
 
-    status_line_impl->status_line.ops = AXIS2_MALLOC(env->allocator,
-            sizeof(axis2_http_status_line_ops_t));
-    if (NULL == status_line_impl->status_line.ops)
-    {
-        axis2_http_status_line_free((axis2_http_status_line_t *)
-                status_line_impl, env);
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-    }
-
-    status_line_impl->status_line.ops->get_status_code =
-        axis2_http_status_line_get_status_code;
-    status_line_impl->status_line.ops->get_http_version =
-        axis2_http_status_line_get_http_version;
-    status_line_impl->status_line.ops->get_reason_phrase =
-        axis2_http_status_line_get_reason_phrase;
-    status_line_impl->status_line.ops->starts_with_http =
-        axis2_http_status_line_starts_with_http;
-    status_line_impl->status_line.ops->to_string =
-        axis2_http_status_line_to_string;
-    status_line_impl->status_line.ops->free =
-        axis2_http_status_line_free;
-    return &(status_line_impl->status_line);
+    return status_line;
 }
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_status_line_free(
     axis2_http_status_line_t *status_line,
     const axis2_env_t *env)
 {
-    axis2_http_status_line_impl_t *status_line_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    status_line_impl = AXIS2_INTF_TO_IMPL(status_line);
 
-    if (status_line_impl->line)
+    if (status_line->line)
     {
-        AXIS2_FREE(env->allocator, status_line_impl->line);
-        status_line_impl->line = NULL;
+        AXIS2_FREE(env->allocator, status_line->line);
     }
-    if (status_line_impl->http_version)
+    if (status_line->http_version)
     {
-        AXIS2_FREE(env->allocator, status_line_impl->http_version);
-        status_line_impl->http_version = NULL;
+        AXIS2_FREE(env->allocator, status_line->http_version);
     }
-    if (status_line_impl->status_code)
+    if (status_line->status_code)
     {
-        AXIS2_FREE(env->allocator, status_line_impl->status_code);
-        status_line_impl->status_code = NULL;
+        AXIS2_FREE(env->allocator, status_line->status_code);
     }
-    if (status_line_impl->reason_phrase)
+    if (status_line->reason_phrase)
     {
-        AXIS2_FREE(env->allocator, status_line_impl->reason_phrase);
-        status_line_impl->reason_phrase = NULL;
+        AXIS2_FREE(env->allocator, status_line->reason_phrase);
     }
-    if (status_line->ops)
-        AXIS2_FREE(env->allocator, status_line->ops);
 
-    AXIS2_FREE(env->allocator, AXIS2_INTF_TO_IMPL(status_line));
+    AXIS2_FREE(env->allocator, status_line);
     return AXIS2_SUCCESS;
 }
 
-int AXIS2_CALL
+AXIS2_EXTERN int AXIS2_CALL
 axis2_http_status_line_get_status_code(
     const axis2_http_status_line_t *status_line,
     const axis2_env_t *env)
 {
     AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
-    if (AXIS2_INTF_TO_IMPL(status_line)->status_code)
+    if (status_line->status_code)
     {
-        return AXIS2_ATOI(AXIS2_INTF_TO_IMPL(status_line)->status_code);
+        return AXIS2_ATOI(status_line->status_code);
     }
     else
     {
@@ -249,43 +176,39 @@
 
 }
 
-axis2_char_t *AXIS2_CALL
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
 axis2_http_status_line_get_http_version(
     const axis2_http_status_line_t *status_line,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    return AXIS2_INTF_TO_IMPL(status_line)->http_version;
+    return status_line->http_version;
 }
 
-axis2_char_t *AXIS2_CALL
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
 axis2_http_status_line_get_reason_phrase(
     const axis2_http_status_line_t *status_line,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    return AXIS2_INTF_TO_IMPL(status_line)->reason_phrase;
+    return status_line->reason_phrase;
 }
 
 
-axis2_bool_t AXIS2_CALL
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
 axis2_http_status_line_starts_with_http(
     axis2_http_status_line_t *status_line,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    if (0 == axis2_strncasecmp(AXIS2_INTF_TO_IMPL(status_line)->line, "HTTP", 4))
+    if (0 == axis2_strncasecmp(status_line->line, "HTTP", 4))
     {
         return AXIS2_TRUE;
     }
     return AXIS2_FALSE;
 }
 
-axis2_char_t *AXIS2_CALL
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
 axis2_http_status_line_to_string(
     axis2_http_status_line_t *status_line,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, NULL);
-    return AXIS2_INTF_TO_IMPL(status_line)->line;
+    return status_line->line;
 }

Modified: webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c?view=diff&rev=519603&r1=519602&r2=519603
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/common/http_worker.c Sun Mar 18 05:20:32 2007
@@ -31,32 +31,13 @@
 #include <axis2_url.h>
 #include <axis2_property.h>
 
-/**
- * @brief HTTP Worker struct impl
- * Axis2 HTTP Worker impl
- */
-
-typedef struct axis2_http_worker_impl
+struct axis2_http_worker
 {
-    axis2_http_worker_t http_worker;
     axis2_conf_ctx_t *conf_ctx;
     int svr_port;
-}
-axis2_http_worker_impl_t;
-
-#define AXIS2_INTF_TO_IMPL(http_worker) ((axis2_http_worker_impl_t *)\
-                                                                (http_worker))
-
-/***************************** Function headers *******************************/
-
-axis2_bool_t AXIS2_CALL
-axis2_http_worker_process_request(
-    axis2_http_worker_t *http_worker,
-    const axis2_env_t *env,
-    axis2_simple_http_svr_conn_t *svr_conn,
-    axis2_http_simple_request_t *simple_request);
+};
 
-axis2_status_t AXIS2_CALL
+static axis2_status_t 
 axis2_http_worker_set_response_headers(
     axis2_http_worker_t *http_worker,
     const axis2_env_t *env,
@@ -65,93 +46,61 @@
     axis2_http_simple_response_t *simple_response,
     axis2_ssize_t content_length);
 
-axis2_status_t AXIS2_CALL
+static axis2_status_t 
 axis2_http_worker_set_transport_out_config(
     axis2_http_worker_t *http_worker,
     const axis2_env_t *env,
     axis2_conf_ctx_t *conf_ctx,
     axis2_http_simple_response_t *simple_response);
 
-axis2_hash_t *AXIS2_CALL
+static axis2_hash_t *
 axis2_http_worker_get_headers(
     axis2_http_worker_t *http_worker,
     const axis2_env_t *env,
     axis2_http_simple_request_t *request);
 
-axis2_status_t AXIS2_CALL
-axis2_http_worker_set_svr_port(
-    axis2_http_worker_t *worker,
-    const axis2_env_t *env,
-    int port);
-
-axis2_status_t AXIS2_CALL
-axis2_http_worker_free(
-    axis2_http_worker_t *http_worker,
-    const axis2_env_t *env);
-
-/***************************** End of function headers ************************/
-
 AXIS2_EXTERN axis2_http_worker_t *AXIS2_CALL
 axis2_http_worker_create(
     const axis2_env_t *env,
     axis2_conf_ctx_t *conf_ctx)
 {
-    axis2_http_worker_impl_t *http_worker_impl = NULL;
+    axis2_http_worker_t *http_worker = NULL;
     AXIS2_ENV_CHECK(env, NULL);
-    http_worker_impl = (axis2_http_worker_impl_t *)
-            AXIS2_MALLOC(env->allocator, sizeof(axis2_http_worker_impl_t));
+    http_worker = (axis2_http_worker_t *)
+            AXIS2_MALLOC(env->allocator, sizeof(axis2_http_worker_t));
 
-    if (NULL == http_worker_impl)
+    if (NULL == http_worker)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
-    http_worker_impl->conf_ctx = conf_ctx;
-    http_worker_impl->svr_port = 9090; /* default - must set later*/
+    http_worker->conf_ctx = conf_ctx;
+    http_worker->svr_port = 9090; /* default - must set later*/
 
-    http_worker_impl->http_worker.ops = AXIS2_MALLOC(env->allocator,
-            sizeof(axis2_http_worker_ops_t));
-    if (NULL == http_worker_impl->http_worker.ops)
-    {
-        axis2_http_worker_free((axis2_http_worker_t *)http_worker_impl, env);
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-    }
-
-    http_worker_impl->http_worker.ops->process_request =
-        axis2_http_worker_process_request;
-    http_worker_impl->http_worker.ops->set_svr_port =
-        axis2_http_worker_set_svr_port;
-    http_worker_impl->http_worker.ops->free = axis2_http_worker_free;
-
-    return &(http_worker_impl->http_worker);
+    return http_worker;
 }
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_worker_free(
     axis2_http_worker_t *http_worker,
     const axis2_env_t *env)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
-    AXIS2_INTF_TO_IMPL(http_worker)->conf_ctx = NULL;
+    http_worker->conf_ctx = NULL;
 
-    if (http_worker->ops)
-        AXIS2_FREE(env->allocator, http_worker->ops);
-
-    AXIS2_FREE(env->allocator, AXIS2_INTF_TO_IMPL(http_worker));
+    AXIS2_FREE(env->allocator, http_worker);
 
     return AXIS2_SUCCESS;
 }
 
-axis2_bool_t AXIS2_CALL
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
 axis2_http_worker_process_request(
     axis2_http_worker_t *http_worker,
     const axis2_env_t *env,
     axis2_simple_http_svr_conn_t *svr_conn,
     axis2_http_simple_request_t *simple_request)
 {
-    axis2_http_worker_impl_t *http_worker_impl = NULL;
     axis2_conf_ctx_t *conf_ctx = NULL;
     axis2_msg_ctx_t *msg_ctx = NULL;
     axis2_stream_t *request_body = NULL;
@@ -180,8 +129,7 @@
     AXIS2_PARAM_CHECK(env->error, svr_conn, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, simple_request, AXIS2_FAILURE);
 
-    http_worker_impl = AXIS2_INTF_TO_IMPL(http_worker);
-    conf_ctx = http_worker_impl->conf_ctx;
+    conf_ctx = http_worker->conf_ctx;
 
     if (NULL == conf_ctx)
     {
@@ -233,10 +181,10 @@
     request_body = AXIS2_HTTP_SIMPLE_REQUEST_GET_BODY(simple_request, env);
 
     out_desc = AXIS2_CONF_GET_TRANSPORT_OUT( axis2_conf_ctx_get_conf
-            (http_worker_impl->conf_ctx, env), env,
+            (http_worker->conf_ctx, env), env,
             AXIS2_TRANSPORT_ENUM_HTTP);
     in_desc = AXIS2_CONF_GET_TRANSPORT_IN( axis2_conf_ctx_get_conf
-            (http_worker_impl->conf_ctx, env), env,
+            (http_worker->conf_ctx, env), env,
             AXIS2_TRANSPORT_ENUM_HTTP);
     msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc);
      axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);
@@ -255,7 +203,7 @@
 	    simple_request, env), env);
 
     request_url = axis2_url_create(env, "http", svr_ip,
-				   http_worker_impl->svr_port,
+				   http_worker->svr_port,
 				   path);
 
 	url_external_form = axis2_url_to_external_form(request_url, env);
@@ -436,8 +384,7 @@
     return status;
 }
 
-
-axis2_status_t AXIS2_CALL
+static axis2_status_t 
 axis2_http_worker_set_response_headers(
     axis2_http_worker_t *http_worker,
     const axis2_env_t *env,
@@ -530,7 +477,7 @@
  * This is only called for HTTP/1.1 to enable 1.1 specific parameters.
  *
  */
-axis2_status_t AXIS2_CALL
+static axis2_status_t 
 axis2_http_worker_set_transport_out_config(
     axis2_http_worker_t *http_worker,
     const axis2_env_t *env,
@@ -551,7 +498,7 @@
     return AXIS2_SUCCESS;
 }
 
-axis2_hash_t *AXIS2_CALL
+static axis2_hash_t *
 axis2_http_worker_get_headers(
     axis2_http_worker_t *http_worker,
     const axis2_env_t *env,
@@ -597,13 +544,12 @@
     return header_map;
 }
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_worker_set_svr_port(
     axis2_http_worker_t *worker,
     const axis2_env_t *env,
     int port)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    AXIS2_INTF_TO_IMPL(worker)->svr_port = port;
+    worker->svr_port = port;
     return AXIS2_SUCCESS;
 }

Modified: webservices/axis2/trunk/c/modules/core/transport/http/util/http_chunked_stream.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/modules/core/transport/http/util/http_chunked_stream.c?view=diff&rev=519603&r1=519602&r2=519603
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/util/http_chunked_stream.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/util/http_chunked_stream.c Sun Mar 18 05:20:32 2007
@@ -21,123 +21,59 @@
 #include <axis2_http_transport.h>
 #include <stdlib.h>
 
-/**
- * HTTP Chunked Stream struct impl
- * Axis2 HTTP Chunked Stream impl
- */
-
-typedef struct axis2_http_chunked_stream_impl
+struct axis2_http_chunked_stream
 {
-    axis2_http_chunked_stream_t chunked_stream;
     axis2_stream_t *stream;
     int current_chunk_size;
     int unread_len;
     axis2_bool_t end_of_chunks;
     axis2_bool_t chunk_started;
-}
-axis2_http_chunked_stream_impl_t;
-
-#define AXIS2_INTF_TO_IMPL(chunked_stream) \
-                 ((axis2_http_chunked_stream_impl_t *)(chunked_stream))
-
-/***************************** Function headers *******************************/
-int AXIS2_CALL
-axis2_http_chunked_stream_read(
-    axis2_http_chunked_stream_t *chunked_stream,
-    const axis2_env_t *env,
-    void *buffer,
-    size_t count);
+};
 
-int AXIS2_CALL
-axis2_http_chunked_stream_write(
-    axis2_http_chunked_stream_t *chunked_stream,
-    const axis2_env_t *env,
-    const void *buffer,
-    size_t count);
-
-int AXIS2_CALL
-axis2_http_chunked_stream_get_current_chunk_size(
-    const axis2_http_chunked_stream_t *chunked_stream,
-    const axis2_env_t *env);
-
-axis2_status_t AXIS2_CALL
+static axis2_status_t
 axis2_http_chunked_stream_start_chunk(
     axis2_http_chunked_stream_t *chunked_stream,
     const axis2_env_t *env);
 
-axis2_status_t AXIS2_CALL
-axis2_http_chunked_stream_write_last_chunk(
-    axis2_http_chunked_stream_t *chunked_stream,
-    const axis2_env_t *env);
-
-axis2_status_t AXIS2_CALL
-axis2_http_chunked_stream_free(
-    axis2_http_chunked_stream_t *chunked_stream,
-    const axis2_env_t *env);
-
-/***************************** End of function headers ************************/
-
 AXIS2_EXTERN axis2_http_chunked_stream_t *AXIS2_CALL
 axis2_http_chunked_stream_create(
     const axis2_env_t *env,
     axis2_stream_t *stream)
 {
-    axis2_http_chunked_stream_impl_t *chunked_stream_impl = NULL;
+    axis2_http_chunked_stream_t *chunked_stream = NULL;
     AXIS2_ENV_CHECK(env, NULL);
     AXIS2_PARAM_CHECK(env->error, stream, NULL);
 
-    chunked_stream_impl = (axis2_http_chunked_stream_impl_t *)AXIS2_MALLOC
+    chunked_stream = (axis2_http_chunked_stream_t *)AXIS2_MALLOC
             (env->allocator, sizeof(
-                        axis2_http_chunked_stream_impl_t));
+                        axis2_http_chunked_stream_t));
 
-    if (NULL == chunked_stream_impl)
+    if (NULL == chunked_stream)
     {
         AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
         return NULL;
     }
-    chunked_stream_impl->stream = stream;
-    chunked_stream_impl->current_chunk_size = -1;
-    chunked_stream_impl->unread_len = -1;
-    chunked_stream_impl->end_of_chunks = AXIS2_FALSE;
-    chunked_stream_impl->chunk_started = AXIS2_FALSE;
-
-    chunked_stream_impl->chunked_stream.ops = AXIS2_MALLOC(env->allocator,
-            sizeof(axis2_http_chunked_stream_ops_t));
-    if (NULL == chunked_stream_impl->chunked_stream.ops)
-    {
-        axis2_http_chunked_stream_free((axis2_http_chunked_stream_t *)
-                chunked_stream_impl, env);
-        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
-        return NULL;
-    }
+    chunked_stream->stream = stream;
+    chunked_stream->current_chunk_size = -1;
+    chunked_stream->unread_len = -1;
+    chunked_stream->end_of_chunks = AXIS2_FALSE;
+    chunked_stream->chunk_started = AXIS2_FALSE;
 
-    chunked_stream_impl->chunked_stream.ops->read =
-        axis2_http_chunked_stream_read;
-    chunked_stream_impl->chunked_stream.ops->write =
-        axis2_http_chunked_stream_write;
-    chunked_stream_impl->chunked_stream.ops->get_current_chunk_size =
-        axis2_http_chunked_stream_get_current_chunk_size;
-    chunked_stream_impl->chunked_stream.ops->write_last_chunk =
-        axis2_http_chunked_stream_write_last_chunk;
-    chunked_stream_impl->chunked_stream.ops->free =
-        axis2_http_chunked_stream_free;
-    return &(chunked_stream_impl->chunked_stream);
+    return chunked_stream;
 }
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_chunked_stream_free(
     axis2_http_chunked_stream_t *chunked_stream,
     const axis2_env_t *env)
 {
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    if (chunked_stream->ops)
-        AXIS2_FREE(env->allocator, chunked_stream->ops);
 
-    AXIS2_FREE(env->allocator, AXIS2_INTF_TO_IMPL(chunked_stream));
+    AXIS2_FREE(env->allocator, chunked_stream);
     return AXIS2_SUCCESS;
 }
 
-int AXIS2_CALL
+AXIS2_EXTERN int AXIS2_CALL
 axis2_http_chunked_stream_read(
     axis2_http_chunked_stream_t *chunked_stream,
     const axis2_env_t *env,
@@ -146,9 +82,7 @@
 {
     int len = -1;
     int yet_to_read = 0;
-    axis2_http_chunked_stream_impl_t *chunked_stream_impl = AXIS2_INTF_TO_IMPL
-            (chunked_stream);
-    axis2_stream_t *stream = chunked_stream_impl->stream;
+    axis2_stream_t *stream = chunked_stream->stream;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
     if (NULL == buffer)
@@ -161,49 +95,49 @@
                 , AXIS2_FAILURE);
         return -1;
     }
-    if (AXIS2_TRUE == chunked_stream_impl->end_of_chunks)
+    if (AXIS2_TRUE == chunked_stream->end_of_chunks)
     {
         return 0;
     }
-    if (AXIS2_FALSE == chunked_stream_impl->chunk_started)
+    if (AXIS2_FALSE == chunked_stream->chunk_started)
     {
         axis2_http_chunked_stream_start_chunk(chunked_stream, env);
     }
     yet_to_read = count;
-    while (AXIS2_FALSE == chunked_stream_impl->end_of_chunks && yet_to_read > 0)
+    while (AXIS2_FALSE == chunked_stream->end_of_chunks && yet_to_read > 0)
     {
-        if (chunked_stream_impl->unread_len < yet_to_read)
+        if (chunked_stream->unread_len < yet_to_read)
         {
-            len = AXIS2_STREAM_READ(chunked_stream_impl->stream, env,
+            len = AXIS2_STREAM_READ(chunked_stream->stream, env,
                     (axis2_char_t *)buffer + count - yet_to_read,
-                    chunked_stream_impl->unread_len);
+                    chunked_stream->unread_len);
             yet_to_read -= len;
-            chunked_stream_impl->unread_len -= len;
-            if (chunked_stream_impl->unread_len <= 0)
+            chunked_stream->unread_len -= len;
+            if (chunked_stream->unread_len <= 0)
             {
                 axis2_http_chunked_stream_start_chunk(chunked_stream, env);
             }
         }
         else
         {
-            len = AXIS2_STREAM_READ(chunked_stream_impl->stream, env,
+            len = AXIS2_STREAM_READ(chunked_stream->stream, env,
                     (axis2_char_t *)buffer + count - yet_to_read,
                     yet_to_read);
             yet_to_read -= len;
-            chunked_stream_impl->unread_len -= len;
+            chunked_stream->unread_len -= len;
         }
     }
     return count - yet_to_read;
 }
 
-int AXIS2_CALL
+AXIS2_EXTERN int AXIS2_CALL
 axis2_http_chunked_stream_write(
     axis2_http_chunked_stream_t *chunked_stream,
     const axis2_env_t *env,
     const void *buffer,
     size_t count)
 {
-    axis2_stream_t *stream = AXIS2_INTF_TO_IMPL(chunked_stream)->stream;
+    axis2_stream_t *stream = chunked_stream->stream;
     int len = -1;
     axis2_char_t tmp_buf[10];
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
@@ -226,17 +160,16 @@
 }
 
 
-int AXIS2_CALL
+AXIS2_EXTERN int AXIS2_CALL
 axis2_http_chunked_stream_get_current_chunk_size(
     const axis2_http_chunked_stream_t *chunked_stream,
     const axis2_env_t *env)
 {
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    return AXIS2_INTF_TO_IMPL(chunked_stream)->current_chunk_size;
+    return chunked_stream->current_chunk_size;
 }
 
 
-axis2_status_t AXIS2_CALL
+static axis2_status_t
 axis2_http_chunked_stream_start_chunk(
     axis2_http_chunked_stream_t *chunked_stream,
     const axis2_env_t *env)
@@ -245,18 +178,16 @@
     axis2_char_t str_chunk_len[512] = "";
     axis2_char_t *tmp = NULL;
     int read = -1;
-    axis2_http_chunked_stream_impl_t *chunked_stream_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
-    chunked_stream_impl = AXIS2_INTF_TO_IMPL(chunked_stream);
     /* remove the last CRLF of the previous chunk if any */
-    if (AXIS2_TRUE == chunked_stream_impl->chunk_started)
+    if (AXIS2_TRUE == chunked_stream->chunk_started)
     {
-        read = AXIS2_STREAM_READ(chunked_stream_impl->stream, env, tmp_buf, 2);
-        chunked_stream_impl->chunk_started = AXIS2_FALSE;
+        read = AXIS2_STREAM_READ(chunked_stream->stream, env, tmp_buf, 2);
+        chunked_stream->chunk_started = AXIS2_FALSE;
     }
     /* read the len and chunk extension */
-    while ((read = AXIS2_STREAM_READ(chunked_stream_impl->stream, env, tmp_buf,
+    while ((read = AXIS2_STREAM_READ(chunked_stream->stream, env, tmp_buf,
             1)) > 0)
     {
         tmp_buf[read] = '\0';
@@ -273,23 +204,23 @@
         /* we don't use extensions right now */
         *tmp = '\0';
     }
-    chunked_stream_impl->current_chunk_size = strtol(str_chunk_len, NULL, 16);
-    if (0 == chunked_stream_impl->current_chunk_size)
+    chunked_stream->current_chunk_size = strtol(str_chunk_len, NULL, 16);
+    if (0 == chunked_stream->current_chunk_size)
     {
         /* Read the last CRLF */
-        read = AXIS2_STREAM_READ(chunked_stream_impl->stream, env, tmp_buf, 2);
-        chunked_stream_impl->end_of_chunks = AXIS2_TRUE;
+        read = AXIS2_STREAM_READ(chunked_stream->stream, env, tmp_buf, 2);
+        chunked_stream->end_of_chunks = AXIS2_TRUE;
     }
     else
     {
-        chunked_stream_impl->chunk_started = AXIS2_TRUE;
-        chunked_stream_impl->unread_len =
-            chunked_stream_impl->current_chunk_size;
+        chunked_stream->chunk_started = AXIS2_TRUE;
+        chunked_stream->unread_len =
+            chunked_stream->current_chunk_size;
     }
     return AXIS2_SUCCESS;
 }
 
-axis2_status_t AXIS2_CALL
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_chunked_stream_write_last_chunk(
     axis2_http_chunked_stream_t *chunked_stream,
     const axis2_env_t *env)
@@ -297,7 +228,7 @@
     axis2_stream_t *stream = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 
-    stream = AXIS2_INTF_TO_IMPL(chunked_stream)->stream;
+    stream = chunked_stream->stream;
     if (AXIS2_STREAM_WRITE(stream, env, "0\r\n\r\n", 5) == 5)
     {
         return AXIS2_SUCCESS;



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message