Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Examples

axis2_stream.h

00001 /*
00002  * Copyright 2004,2005 The Apache Software Foundation.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain count copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef AXIS2_STREAM_H
00018 #define AXIS2_STREAM_H
00019 
00020 #include <axis2_utils.h>
00021 #include <axis2_utils_defines.h>
00022 #include <axis2_env.h>
00023 #include <stdio.h>
00024 
00025 #ifdef __cplusplus
00026 extern "C"
00027 {
00028 #endif
00029 
00030 typedef struct axis2_stream axis2_stream_t;
00031 typedef struct axis2_stream_ops axis2_stream_ops_t;
00032 
00033 #define AXIS2_STREAM_DEFAULT_BUF_SIZE 512
00034 
00046 enum axis2_stream_type 
00047 {
00048    AXIS2_STREAM_BASIC = 0,
00049    AXIS2_STREAM_FILE,
00050    AXIS2_STREAM_SOCKET,
00051     AXIS2_STREAM_MANAGED /* Example Wrapper stream for Apache2 read mechanism */
00052 };
00053 
00054 typedef enum axis2_stream_type axis2_stream_type_t;
00055 
00061 AXIS2_DECLARE_DATA struct axis2_stream_ops
00062 {
00063 
00068       axis2_status_t (AXIS2_CALL *
00069    free)(axis2_stream_t *stream, 
00070         const axis2_env_t *env);
00071       
00072     axis2_status_t (AXIS2_CALL *
00073     free_void_arg) (void *stream, 
00074                   const axis2_env_t *env);
00075    
00083    int (AXIS2_CALL *
00084    read) (axis2_stream_t *stream, 
00085          const axis2_env_t *env, 
00086          void *buffer, 
00087          size_t count);
00094    int (AXIS2_CALL *
00095    write) (axis2_stream_t *stream, 
00096          const axis2_env_t *env, 
00097          const void *buffer, 
00098          size_t count);
00104    int (AXIS2_CALL *
00105    skip) (axis2_stream_t *stream, 
00106          const axis2_env_t *env, 
00107          int count);
00108                   
00114    int (AXIS2_CALL *
00115    get_char) (axis2_stream_t *stream, 
00116               const axis2_env_t *env);
00117    
00124    int (AXIS2_CALL *
00125    unget_char) (axis2_stream_t *stream, 
00126              const axis2_env_t *env, 
00127              int ch);
00128 
00134    int (AXIS2_CALL *
00135    get_len) (axis2_stream_t *stream, 
00136              const axis2_env_t *env);
00137    
00142    axis2_stream_type_t (AXIS2_CALL *
00143    get_type) (axis2_stream_t *stream, 
00144             const axis2_env_t *env); 
00145    
00146 };
00147 
00153 AXIS2_DECLARE_DATA struct axis2_stream
00154 {
00156    axis2_stream_ops_t *ops;
00158     int axis2_eof;
00159 };
00160 
00164 AXIS2_EXTERN axis2_stream_t *AXIS2_CALL axis2_stream_create_basic (const axis2_env_t *env);
00165 
00170 AXIS2_EXTERN axis2_stream_t * AXIS2_CALL
00171 axis2_stream_create_file (const axis2_env_t *env, FILE *fp);
00172 
00177 AXIS2_EXTERN axis2_stream_t * AXIS2_CALL
00178 axis2_stream_create_socket (const axis2_env_t *env, int socket);
00179 
00185 AXIS2_EXTERN axis2_status_t AXIS2_CALL 
00186 axis2_stream_free_void_arg (void *stream,
00187                             const axis2_env_t *env);
00188 
00189 #define AXIS2_STREAM_FREE(stream, env) ((stream->ops)->free(stream, env))
00190 
00191 #define AXIS2_STREAM_FREE_VOID_ARG(stream, env) \
00192         ((stream->ops)->free_void_arg(stream, env))
00193 
00194 #define AXIS2_STREAM_READ(stream, env, buffer, count) \
00195       ((stream)->ops->read(stream, env, buffer, count))
00196       
00197 #define AXIS2_STREAM_WRITE(stream, env, buffer, count) \
00198       ((stream)->ops->write(stream, env, buffer, count))
00199       
00200 #define AXIS2_STREAM_SKIP(stream, env, count) \
00201       ((stream)->ops->write(stream, env, count))
00202       
00203 #define AXIS2_STREAM_GET_CHAR(stream, env) \
00204       ((stream)->ops->get_char(stream, env))
00205       
00206 #define AXIS2_STREAM_UNGET_CHAR(stream, env, ch) \
00207       ((stream)->ops->unget_char(stream, env, ch))
00208 
00209 #define AXIS2_STREAM_BASIC_GET_LEN(stream, env) \
00210       ((stream)->ops->get_len(stream, env))
00211       
00212 #define AXIS2_STREAM_GET_TYPE(stream, env)\
00213         ((stream)->ops->get_type(stream, env))
00214 
00216 #ifdef __cplusplus
00217 }
00218 #endif
00219 
00220 #endif                          /* AXIS2_STREAM_H */

Generated on Fri Jun 16 18:02:31 2006 for Axis2/C by  doxygen 1.4.2