-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have added axis2_http_out_out_transport_info.c  and
axis2_http_out_out_transport_info.h. Please commit them

- - Sahan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iQEVAwUBQ6ZQYanIlEsDdb85AQLYTgf+MPLuyq8wtdy4QVwGrxFn5mo/gLI0gbsl
lekHCUjf6FJ5xltsokjRm+XiOD9RmGVQBqzj2/1pL7MV1eLI/v4gp7Jw57yelHtW
67C2EDdV5Flt2T0bXdGW3bj+C1GogIgO40yUE2Wu/bXZBD641FTclEVTviFUQXic
yV06ONzzSvuW5wCY6dSwk70efzq8XsllNNQVdPouraSs6IHsDuGL8KGWhFBMepro
De6J2w5rEnl6luxuol8uMAD6lxqYY7p/4qDeSrt4hgTVFrZ2iipIwtNVU/2JTY0b
yVzq1RFuyEhN+zmrih4EABXn8tjXin80FyOX0WLU5Tkq8kndTHWrEA==
=1aJU
-----END PGP SIGNATURE-----

/*
 * Copyright 2004,2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
#include <axis2_http_out_transport_info.h>
#include <axis2_string.h>
#include <axis2_http_transport.h>
#include <axis2_string.h>


/** 
 * @brief HTTP Header struct impl
 *	Axis2 HTTP Header impl  
 */
typedef struct axis2_http_out_transport_info_impl 
				axis2_http_out_transport_info_impl_t;  
  
struct axis2_http_out_transport_info_impl
{
	axis2_http_out_transport_info_t out_transport_info;
	axis2_http_simple_response_t *response;
	axis2_char_t *encoding;
};

#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, axis2_env_t **env, 
				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, axis2_env_t **env,
				axis2_char_t *encoding);
    
axis2_status_t AXIS2_CALL 
axis2_http_out_transport_info_free 
				(axis2_http_out_transport_info_t *out_transport_info, 
				axis2_env_t **env);

/***************************** End of function headers ************************/

axis2_http_out_transport_info_t * AXIS2_CALL 
axis2_http_out_transport_info_create(axis2_env_t **env,
					axis2_http_simple_response_t *response)
{
    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_FUNC_PARAM_CHECK(response, env, NULL);
        
    axis2_http_out_transport_info_impl_t *info_impl = 
                        (axis2_http_out_transport_info_impl_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, NULL);
	}
    info_impl->response = response;
  	info_impl->encoding = NULL;  
     
    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)
	{
		axis2_http_out_transport_info_free((axis2_http_out_transport_info_t*)
                         info_impl, env);
        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, NULL);
		return 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);
}


axis2_status_t AXIS2_CALL 
axis2_http_out_transport_info_free (axis2_http_out_transport_info_t *info, 
						axis2_env_t **env)
{
	AXIS2_FUNC_PARAM_CHECK(info, env, AXIS2_FAILURE);
    axis2_http_out_transport_info_impl_t *info_impl =
                        AXIS2_INTF_TO_IMPL(info);
	
	info_impl->response = NULL; /* response doesn't belong to info */
    if(NULL != info_impl->encoding)
    {
        AXIS2_FREE((*env)->allocator, info_impl->encoding);
        info_impl->encoding = NULL;
    }
    if(NULL != info->ops)
        AXIS2_FREE((*env)->allocator, info->ops);
    
	AXIS2_FREE((*env)->allocator, info_impl);
	return AXIS2_SUCCESS;
}


axis2_status_t AXIS2_CALL 
axis2_http_out_transport_info_set_content_type 
				(axis2_http_out_transport_info_t *info, axis2_env_t **env, 
				axis2_char_t *content_type)
{
    axis2_char_t *tmp1 = NULL;
	axis2_char_t *tmp2 = NULL;
	
	AXIS2_FUNC_PARAM_CHECK(info, env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK((*env)->error, content_type, AXIS2_FAILURE);
	
	axis2_http_out_transport_info_impl_t *info_impl = AXIS2_INTF_TO_IMPL(info);
	
	if(NULL != info_impl->encoding)
	{
		
		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, 
				axis2_http_header_create(env, AXIS2_HTTP_HEADER_CONTENT_TYPE, 
				tmp2));
		AXIS2_FREE((*env)->allocator, tmp1);
		AXIS2_FREE((*env)->allocator, tmp2);		
	}
	else
	{
		AXIS2_HTTP_SIMPLE_RESPONSE_SET_HEADER(info_impl->response, env, 
				axis2_http_header_create(env, AXIS2_HTTP_HEADER_CONTENT_TYPE, 
				content_type));
	}
	return AXIS2_SUCCESS;
}


axis2_status_t AXIS2_CALL 
axis2_http_out_transport_info_set_char_encoding 
				(axis2_http_out_transport_info_t *info, axis2_env_t **env,
				axis2_char_t *encoding)
{
    AXIS2_FUNC_PARAM_CHECK(info, env, AXIS2_FAILURE);
	AXIS2_PARAM_CHECK((*env)->error, encoding, AXIS2_FAILURE);
	
    axis2_http_out_transport_info_impl_t *info_impl = AXIS2_INTF_TO_IMPL(info);
	
	if(NULL != info_impl->encoding)
	{
		AXIS2_FREE((*env)->allocator, info_impl->encoding);
	}
	info_impl->encoding = AXIS2_STRDUP(encoding, env);
	
	return AXIS2_SUCCESS;
}
/*
 * Copyright 2004,2005 The Apache Software Foundation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
#ifndef AXIS2_HTTP_OUT_TRANSPORT_INFO_H
#define AXIS2_HTTP_OUT_TRANSPORT_INFO_H

/**
 * @file axis2_http_out_transport_info.h
 * @brief axis2 HTTP Out Transport Info
 */

#include <axis2.h>
#include <axis2_defines.h>
#include <axis2_env.h>
#include <axis2_http_simple_response.h>


#ifdef __cplusplus
extern "C" 
{
#endif
/** 
  * @ingroup axis2_core_transport_http
  * @{
  */

typedef struct axis2_http_out_transport_info_ops 
					axis2_http_out_transport_info_ops_t;
typedef struct axis2_http_out_transport_info axis2_http_out_transport_info_t;
    
    
/** 
 * @brief HTTP Out Transport Info ops struct
 * Encapsulator struct for ops of axis2_http_out_transport_info
 */
AXIS2_DECLARE_DATA struct axis2_http_out_transport_info_ops
{
    int (AXIS2_CALL *set_content_type) (axis2_http_out_transport_info_t *info, 
					axis2_env_t **env, axis2_char_t *content_type);
    
    axis2_status_t (AXIS2_CALL *set_char_encoding) 
                    (axis2_http_out_transport_info_t *info, axis2_env_t **env,
					axis2_char_t *encoding);
    
    axis2_status_t (AXIS2_CALL *free) 
					(axis2_http_out_transport_info_t *out_transport_info, 
					axis2_env_t **env);
};

/**
 * @brief HTTP out transport info
 * Axis2 HTTP out transport info
 */
AXIS2_DECLARE_DATA struct axis2_http_out_transport_info
{
    axis2_http_out_transport_info_ops_t *ops;
};


axis2_http_out_transport_info_t * AXIS2_CALL 
axis2_http_out_transport_info_create(axis2_env_t **env,
					axis2_http_simple_response_t *response);

/************************* Start of function macros    ***************************/

#define AXIS2_HTTP_OUT_TRANSPORT_INFO_SET_CONTENT_TYPE(out_transport_info, \
					env, content_type) ((out_transport_info)->ops->\
					set_content_type (out_transport_info, env, content_type))
#define AXIS2_HTTP_OUT_TRANSPORT_INFO_SET_CHAR_ENCODING(out_transport_info,\
					env) ((out_transport_info)->ops->set_char_encoding \
					(out_transport_info, env, encoding))
#define AXIS2_HTTP_OUT_TRANSPORT_INFO_FREE(out_transport_info, env)\
                    ((out_transport_info)->ops->free(out_transport_info, env))

/************************* End of function macros *****************************/

/** @} */
#ifdef __cplusplus
}
#endif
#endif /* AXIS2_HTTP_OUT_TRANSPORT_INFO_H */

Reply via email to