oxs_buffer.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef OXS_BUFFER_H
00019 #define OXS_BUFFER_H
00020 
00021 
00027 #include <axis2_defines.h>
00028 #include <axis2_env.h>
00029 #include <axis2_util.h>
00030 
00031 #ifdef __cplusplus
00032 extern "C"
00033 {
00034 #endif
00035 
00041 #define OXS_BUFFER_INITIAL_SIZE 1024
00042 
00048     typedef enum {
00049         oxs_alloc_mode_exact = 0,
00050         oxs_alloc_mode_double
00051     } oxs_AllocMode;
00052 
00054     typedef struct oxs_buffer_ops oxs_buffer_ops_t;
00055 
00057     typedef struct oxs_buffer oxs_buffer_t;
00058 
00059     struct oxs_buffer_ops
00060     {
00067         axis2_status_t (AXIS2_CALL *
00068                 free)(
00069                     oxs_buffer_t *buffer,
00070                     const axis2_env_t *env
00071                 );
00079         axis2_status_t (AXIS2_CALL *
00080                 remove_head)(
00081                     oxs_buffer_t *buffer,
00082                     const axis2_env_t *env,
00083                     int size
00084                 );
00092         axis2_status_t (AXIS2_CALL *
00093                 remove_tail)(
00094                     oxs_buffer_t *buffer,
00095                     const axis2_env_t *env,
00096                     int size
00097                 );
00106         axis2_status_t (AXIS2_CALL *
00107                 populate)(
00108                     oxs_buffer_t *buffer,
00109                     const axis2_env_t *env,
00110                     unsigned char *data,
00111                     int size
00112                 );
00121         axis2_status_t (AXIS2_CALL *
00122                 append)(
00123                     oxs_buffer_t *buffer,
00124                     const axis2_env_t *env,
00125                     unsigned char *data,
00126                     int size
00127                 );
00136         axis2_status_t (AXIS2_CALL *
00137                 prepend)(
00138                     oxs_buffer_t *buffer,
00139                     const axis2_env_t *env,
00140                     unsigned char *data,
00141                     int size
00142                 );
00150         axis2_status_t (AXIS2_CALL *
00151                 read_file)(
00152                     oxs_buffer_t *buffer,
00153                     const axis2_env_t *env,
00154                     const axis2_char_t *filename
00155                 );
00163         axis2_status_t (AXIS2_CALL *
00164                 set_size)(
00165                     oxs_buffer_t *buffer,
00166                     const axis2_env_t *env,
00167                     int size
00168                 );
00176         axis2_status_t (AXIS2_CALL *
00177                 set_max_size)(
00178                     oxs_buffer_t *buffer,
00179                     const axis2_env_t *env,
00180                     int size
00181                 );
00188         unsigned char* (AXIS2_CALL *
00189                 get_data)(
00190                     oxs_buffer_t *buffer,
00191                     const axis2_env_t *env
00192                 );
00199         int (AXIS2_CALL *
00200                 get_size)(
00201                     oxs_buffer_t *buffer,
00202                     const axis2_env_t *env
00203                 );
00210         int (AXIS2_CALL *
00211                 get_max_size)(
00212                     oxs_buffer_t *buffer,
00213                     const axis2_env_t *env
00214                 );
00215     };
00216 
00217     struct oxs_buffer
00218     {
00219         oxs_buffer_ops_t *ops;
00220     };
00221 
00222 AXIS2_EXTERN oxs_buffer_t *AXIS2_CALL
00223 oxs_buffer_create(const axis2_env_t *env);
00224 
00225 /*Macros*/
00226 
00227 #define OXS_BUFFER_FREE(buffer,env)\
00228     ((buffer)->ops->free(buffer,env))
00229 
00230 #define OXS_BUFFER_REMOVE_HEAD(buffer,env, size)\
00231     ((buffer)->ops->remove_head(buffer,env, size))
00232 
00233 #define OXS_BUFFER_REMOVE_TAIL(buffer,env, size)\
00234     ((buffer)->ops->remove_tail(buffer,env, size))
00235 
00236 #define OXS_BUFFER_POPULATE(buffer,env, data, size)\
00237     ((buffer)->ops->populate(buffer,env, data, size))
00238 
00239 #define OXS_BUFFER_APPEND(buffer,env, data, size)\
00240     ((buffer)->ops->append(buffer,env, data, size))
00241 
00242 #define OXS_BUFFER_PREPEND(buffer,env, data, size)\
00243     ((buffer)->ops->prepend(buffer,env, data, size))
00244 
00245 #define OXS_BUFFER_READ_FILE(buffer,env, file_name)\
00246     ((buffer)->ops->read_file(buffer,env, file_name))
00247 
00248 #define OXS_BUFFER_SET_SIZE(buffer,env, size)\
00249     ((buffer)->ops->set_size(buffer,env, size))
00250 
00251 #define OXS_BUFFER_SET_MAX_SIZE(buffer, env, size)\
00252     ((buffer)->ops->set_max_size(buffer, env, size))
00253 
00254 #define OXS_BUFFER_GET_DATA(buffer,env)\
00255     ((buffer)->ops->get_data(buffer,env))
00256 
00257 #define OXS_BUFFER_GET_SIZE(buffer,env)\
00258     ((buffer)->ops->get_size(buffer,env))
00259 
00260 #define OXS_BUFFER_GET_MAX_SIZE(buffer,env)\
00261     ((buffer)->ops->get_max_size(buffer,env))
00262 
00263 
00265 #ifdef __cplusplus
00266 }
00267 #endif
00268 
00269 #endif                          /* OXS_BUFFER_H */

Generated on Wed Dec 20 20:14:10 2006 for Axis2/C by  doxygen 1.5.1