axutil_stream.h

00001 
00002 /*
00003  * Copyright 2004,2005 The Apache Software Foundation.
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain count 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 AXUTIL_STREAM_H
00019 #define AXUTIL_STREAM_H
00020 
00021 #include <axutil_utils.h>
00022 #include <axutil_utils_defines.h>
00023 #include <axutil_env.h>
00024 #include <stdio.h>
00025 
00026 #ifdef __cplusplus
00027 extern "C"
00028 {
00029 #endif
00030 
00031 #define AXIS2_STREAM_DEFAULT_BUF_SIZE 2048
00032 
00045     enum axutil_stream_type
00046     {
00047         AXIS2_STREAM_BASIC = 0,
00048         AXIS2_STREAM_FILE,
00049         AXIS2_STREAM_SOCKET,
00050         AXIS2_STREAM_MANAGED    /* Example Wrapper stream for Apache2 read mechanism */
00051     };
00052 
00053     typedef enum axutil_stream_type axutil_stream_type_t;
00054     typedef struct axutil_stream axutil_stream_t;
00055 
00056     struct axutil_stream
00057     {
00058         axutil_stream_type_t stream_type;
00059         int len;
00060         int max_len;
00061         /* Only one of these is used for a perticlar
00062          * instance depending on the type
00063          */
00064         axis2_char_t *buffer;
00065         axis2_char_t *buffer_head;
00066         FILE *fp;
00067         int socket;
00068 
00069         int axis2_eof;
00070 
00077         int(
00078             AXIS2_CALL
00079             * read)(
00080                 axutil_stream_t * stream,
00081                 const axutil_env_t * env,
00082                 void *buffer,
00083                 size_t count);
00084 
00091         int(
00092             AXIS2_CALL
00093             * write)(
00094                 axutil_stream_t * stream,
00095                 const axutil_env_t * env,
00096                 const void *buffer,
00097                 size_t count);
00098 
00104         int(
00105             AXIS2_CALL
00106             * skip)(
00107                 axutil_stream_t * stream,
00108                 const axutil_env_t * env,
00109                 int count);
00110     };
00111 
00116     AXIS2_EXTERN void AXIS2_CALL
00117     axutil_stream_free(
00118         axutil_stream_t * stream,
00119         const axutil_env_t * env);
00120 
00121     AXIS2_EXTERN void AXIS2_CALL
00122     axutil_stream_free_void_arg(
00123         void *stream,
00124         const axutil_env_t * env);
00125 
00132     AXIS2_EXTERN int AXIS2_CALL
00133     axutil_stream_read(
00134         axutil_stream_t * stream,
00135         const axutil_env_t * env,
00136         void *buffer,
00137         size_t count);
00138 
00145     AXIS2_EXTERN int AXIS2_CALL
00146     axutil_stream_write(
00147         axutil_stream_t * stream,
00148         const axutil_env_t * env,
00149         const void *buffer,
00150         size_t count);
00151 
00157     AXIS2_EXTERN int AXIS2_CALL
00158     axutil_stream_skip(
00159         axutil_stream_t * stream,
00160         const axutil_env_t * env,
00161         int count);
00162 
00168     AXIS2_EXTERN int AXIS2_CALL
00169     axutil_stream_get_len(
00170         axutil_stream_t * stream,
00171         const axutil_env_t * env);
00172 
00176     AXIS2_EXTERN axutil_stream_t *AXIS2_CALL
00177     axutil_stream_create_basic(
00178         const axutil_env_t * env);
00179 
00184     AXIS2_EXTERN axutil_stream_t *AXIS2_CALL
00185     axutil_stream_create_file(
00186         const axutil_env_t * env,
00187         FILE * fp);
00188 
00193     AXIS2_EXTERN axutil_stream_t *AXIS2_CALL
00194     axutil_stream_create_socket(
00195         const axutil_env_t * env,
00196         int socket);
00197 
00201     AXIS2_EXTERN void AXIS2_CALL
00202     axutil_stream_free(
00203         axutil_stream_t * stream,
00204         const axutil_env_t * env);
00205 
00212     AXIS2_EXTERN void AXIS2_CALL
00213     axutil_stream_free_void_arg(
00214         void *stream,
00215         const axutil_env_t * env);
00216 
00220     AXIS2_EXTERN axis2_char_t *AXIS2_CALL
00221     axutil_stream_get_buffer(
00222         const axutil_stream_t * stream,
00223         const axutil_env_t * env);
00224 
00225     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00226     axutil_stream_flush_buffer(
00227         axutil_stream_t * stream,
00228         const axutil_env_t * env);
00229 
00230     AXIS2_EXTERN int AXIS2_CALL
00231     axutil_stream_peek_socket(
00232         axutil_stream_t * stream,
00233         const axutil_env_t * env,
00234         void *buffer,
00235         size_t count);
00236 
00237     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00238     axutil_stream_flush(
00239         axutil_stream_t * stream,
00240         const axutil_env_t * env);
00241 
00242     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00243     axutil_stream_close(
00244         axutil_stream_t * stream,
00245         const axutil_env_t * env);
00246 
00247     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00248     axutil_stream_set_read(
00249         axutil_stream_t * stream,
00250         const axutil_env_t * env,
00251         void *func);
00252 
00253     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00254     axutil_stream_set_write(
00255         axutil_stream_t * stream,
00256         const axutil_env_t * env,
00257         void *func);
00258 
00259     AXIS2_EXTERN axis2_status_t AXIS2_CALL
00260     axutil_stream_set_skip(
00261         axutil_stream_t * stream,
00262         const axutil_env_t * env,
00263         void *func);
00264 
00267 #ifdef __cplusplus
00268 }
00269 #endif
00270 
00271 #endif                          /* AXIS2_STREAM_H */

Generated on Tue Jan 8 01:23:16 2008 for Axis2/C by  doxygen 1.5.1