axutil_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 AXUTIL_STREAM_H
00018 #define AXUTIL_STREAM_H
00019 
00020 #include <axutil_utils.h>
00021 #include <axutil_utils_defines.h>
00022 #include <axutil_env.h>
00023 #include <stdio.h>
00024 
00025 #ifdef __cplusplus
00026 extern "C"
00027 {
00028 #endif
00029 
00030 #define AXIS2_STREAM_DEFAULT_BUF_SIZE 2048
00031 
00044     enum axutil_stream_type
00045     {
00046         AXIS2_STREAM_BASIC = 0,
00047         AXIS2_STREAM_FILE,
00048         AXIS2_STREAM_SOCKET,
00049         AXIS2_STREAM_MANAGED /* Example Wrapper stream for Apache2 read mechanism */
00050     };
00051 
00052     typedef enum axutil_stream_type axutil_stream_type_t;
00053     typedef struct axutil_stream axutil_stream_t;
00054 
00055     struct axutil_stream
00056     {
00057         axutil_stream_type_t stream_type;
00058         int len;
00059         int max_len;
00060         /* Only one of these is used for a perticlar
00061          * instance depending on the type
00062          */
00063         axis2_char_t *buffer;
00064         axis2_char_t *buffer_head;
00065         FILE *fp;
00066         int socket;
00067 
00068         int axis2_eof;
00069 
00076         int(AXIS2_CALL *
00077         read)(axutil_stream_t *stream,
00078             const axutil_env_t *env,
00079             void *buffer,
00080             size_t count);
00081 
00088         int(AXIS2_CALL *
00089         write)(axutil_stream_t *stream,
00090             const axutil_env_t *env,
00091             const void *buffer,
00092             size_t count);
00093 
00099         int(AXIS2_CALL *
00100         skip)(axutil_stream_t *stream,
00101             const axutil_env_t *env,
00102             int count);
00103     };
00104 
00109     AXIS2_EXTERN void AXIS2_CALL
00110     axutil_stream_free(axutil_stream_t *stream,
00111         const axutil_env_t *env);
00112 
00113     AXIS2_EXTERN void  AXIS2_CALL
00114     axutil_stream_free_void_arg(void *stream,
00115         const axutil_env_t *env);
00116 
00123     AXIS2_EXTERN int AXIS2_CALL
00124     axutil_stream_read(axutil_stream_t *stream,
00125         const axutil_env_t *env,
00126         void *buffer,
00127         size_t count);
00128 
00135     AXIS2_EXTERN int AXIS2_CALL
00136     axutil_stream_write(axutil_stream_t *stream,
00137         const axutil_env_t *env,
00138         const void *buffer,
00139         size_t count);
00140 
00146     AXIS2_EXTERN int AXIS2_CALL
00147     axutil_stream_skip(axutil_stream_t *stream,
00148         const axutil_env_t *env,
00149         int count);
00150 
00156     AXIS2_EXTERN int AXIS2_CALL
00157     axutil_stream_get_len(axutil_stream_t *stream,
00158         const axutil_env_t *env);
00159 
00163     AXIS2_EXTERN axutil_stream_t * AXIS2_CALL
00164     axutil_stream_create_basic(const axutil_env_t *env);
00165 
00170     AXIS2_EXTERN axutil_stream_t * AXIS2_CALL
00171     axutil_stream_create_file(const axutil_env_t *env, FILE *fp);
00172 
00177     AXIS2_EXTERN axutil_stream_t * AXIS2_CALL
00178     axutil_stream_create_socket(const axutil_env_t *env, int socket);
00179 
00183         AXIS2_EXTERN void AXIS2_CALL
00184         axutil_stream_free(axutil_stream_t *stream, const axutil_env_t *env);   
00185         
00192     AXIS2_EXTERN void AXIS2_CALL
00193     axutil_stream_free_void_arg(void *stream,
00194         const axutil_env_t *env);
00195 
00199     AXIS2_EXTERN axis2_char_t * AXIS2_CALL
00200     axutil_stream_get_buffer(const axutil_stream_t *stream,
00201         const axutil_env_t *env);
00202 
00203     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00204     axutil_stream_flush_buffer(axutil_stream_t *stream,
00205         const axutil_env_t *env);
00206 
00207     AXIS2_EXTERN int AXIS2_CALL
00208     axutil_stream_peek_socket(axutil_stream_t *stream, const axutil_env_t *env,
00209         void *buffer, size_t count);
00210 
00211     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00212     axutil_stream_flush(axutil_stream_t *stream,
00213         const axutil_env_t *env);
00214 
00215     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00216     axutil_stream_close(axutil_stream_t *stream,
00217         const axutil_env_t *env);
00218 
00219     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00220     axutil_stream_set_read(axutil_stream_t *stream,
00221         const axutil_env_t *env, 
00222         void *func);
00223 
00224     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00225     axutil_stream_set_write(axutil_stream_t *stream,
00226         const axutil_env_t *env, 
00227         void *func);
00228 
00229     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00230     axutil_stream_set_skip(axutil_stream_t *stream,
00231         const axutil_env_t *env, 
00232         void *func);
00233 
00236 #ifdef __cplusplus
00237 }
00238 #endif
00239 
00240 #endif                          /* AXIS2_STREAM_H */

Generated on Thu May 3 12:31:01 2007 for Axis2/C by  doxygen 1.4.6