00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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
00052 };
00053
00054 typedef enum axis2_stream_type axis2_stream_type_t;
00055
00061 struct axis2_stream_ops
00062 {
00063
00068 axis2_status_t (AXIS2_CALL *
00069 free_fn)(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_len) (axis2_stream_t *stream,
00116 const axis2_env_t *env);
00117 };
00118
00124 struct axis2_stream
00125 {
00127 axis2_stream_ops_t *ops;
00129 int axis2_eof;
00130 };
00131
00135 AXIS2_EXTERN axis2_stream_t *AXIS2_CALL axis2_stream_create_basic (const axis2_env_t *env);
00136
00141 AXIS2_EXTERN axis2_stream_t * AXIS2_CALL
00142 axis2_stream_create_file (const axis2_env_t *env, FILE *fp);
00143
00148 AXIS2_EXTERN axis2_stream_t * AXIS2_CALL
00149 axis2_stream_create_socket (const axis2_env_t *env, int socket);
00150
00156 AXIS2_EXTERN axis2_status_t AXIS2_CALL
00157 axis2_stream_free_void_arg (void *stream,
00158 const axis2_env_t *env);
00159
00160 #define AXIS2_STREAM_FREE(stream, env) ((stream->ops)->free_fn(stream, env))
00161
00162 #define AXIS2_STREAM_FREE_VOID_ARG(stream, env) \
00163 ((stream->ops)->free_void_arg(stream, env))
00164
00165 #define AXIS2_STREAM_READ(stream, env, buffer, count) \
00166 ((stream)->ops->read(stream, env, buffer, count))
00167
00168 #define AXIS2_STREAM_WRITE(stream, env, buffer, count) \
00169 ((stream)->ops->write(stream, env, buffer, count))
00170
00171 #define AXIS2_STREAM_SKIP(stream, env, count) \
00172 ((stream)->ops->write(stream, env, count))
00173
00174 #define AXIS2_STREAM_BASIC_GET_LEN(stream, env) \
00175 ((stream)->ops->get_len(stream, env))
00176
00179 #ifdef __cplusplus
00180 }
00181 #endif
00182
00183 #endif