# 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     typedef int(
    00057         AXIS2_CALL
    00058         * AXUTIL_STREAM_READ)(
    00059             axutil_stream_t * stream,
    00060             const axutil_env_t * env,
    00061             void *buffer,
    00062             size_t count);
    00063
    00064     typedef int(
    00065         AXIS2_CALL
    00066         * AXUTIL_STREAM_WRITE)(
    00067             axutil_stream_t * stream,
    00068             const axutil_env_t * env,
    00069             const void *buffer,
    00070             size_t count);
    00071
    00072     typedef int(
    00073         AXIS2_CALL
    00074         * AXUTIL_STREAM_SKIP)(
    00075             axutil_stream_t * stream,
    00076             const axutil_env_t * env,
    00077             int count);
    00078
    00079     struct axutil_stream
    00080     {
    00081         axutil_stream_type_t stream_type;
    00082         int len;
    00083         int max_len;
    00084         /* Only one of these is used for a perticlar
    00085          * instance depending on the type
    00086          */
    00087         axis2_char_t *buffer;
    00088         axis2_char_t *buffer_head;
    00089         FILE *fp;
    00090         int socket;
    00091
    00092         int axis2_eof;
    00093
    00100         int(
    00101             AXIS2_CALL
    00102             * read)(
    00103                 axutil_stream_t * stream,
    00104                 const axutil_env_t * env,
    00105                 void *buffer,
    00106                 size_t count);
    00107
    00114         int(
    00115             AXIS2_CALL
    00116             * write)(
    00117                 axutil_stream_t * stream,
    00118                 const axutil_env_t * env,
    00119                 const void *buffer,
    00120                 size_t count);
    00121
    00127         int(
    00128             AXIS2_CALL
    00129             * skip)(
    00130                 axutil_stream_t * stream,
    00131                 const axutil_env_t * env,
    00132                 int count);
    00133     };
    00134
    00139     AXIS2_EXTERN void AXIS2_CALL
    00140     axutil_stream_free(
    00141         axutil_stream_t * stream,
    00142         const axutil_env_t * env);
    00143
    00144     AXIS2_EXTERN void AXIS2_CALL
    00145     axutil_stream_free_void_arg(
    00146         void *stream,
    00147         const axutil_env_t * env);
    00148
    00155     AXIS2_EXTERN int AXIS2_CALL
    00156     axutil_stream_read(
    00157         axutil_stream_t * stream,
    00158         const axutil_env_t * env,
    00159         void *buffer,
    00160         size_t count);
    00161
    00168     AXIS2_EXTERN int AXIS2_CALL
    00169     axutil_stream_write(
    00170         axutil_stream_t * stream,
    00171         const axutil_env_t * env,
    00172         const void *buffer,
    00173         size_t count);
    00174
    00180     AXIS2_EXTERN int AXIS2_CALL
    00181     axutil_stream_skip(
    00182         axutil_stream_t * stream,
    00183         const axutil_env_t * env,
    00184         int count);
    00185
    00191     AXIS2_EXTERN int AXIS2_CALL
    00192     axutil_stream_get_len(
    00193         axutil_stream_t * stream,
    00194         const axutil_env_t * env);
    00195
    00199     AXIS2_EXTERN axutil_stream_t *AXIS2_CALL
    00200     axutil_stream_create_basic(
    00201         const axutil_env_t * env);
    00202
    00207     AXIS2_EXTERN axutil_stream_t *AXIS2_CALL
    00208     axutil_stream_create_file(
    00209         const axutil_env_t * env,
    00210         FILE * fp);
    00211
    00216     AXIS2_EXTERN axutil_stream_t *AXIS2_CALL
    00217     axutil_stream_create_socket(
    00218         const axutil_env_t * env,
    00219         int socket);
    00220
    00224     AXIS2_EXTERN void AXIS2_CALL
    00225     axutil_stream_free(
    00226         axutil_stream_t * stream,
    00227         const axutil_env_t * env);
    00228
    00235     AXIS2_EXTERN void AXIS2_CALL
    00236     axutil_stream_free_void_arg(
    00237         void *stream,
    00238         const axutil_env_t * env);
    00239
    00243     AXIS2_EXTERN axis2_char_t *AXIS2_CALL
    00244     axutil_stream_get_buffer(
    00245         const axutil_stream_t * stream,
    00246         const axutil_env_t * env);
    00247
    00248     AXIS2_EXTERN axis2_status_t AXIS2_CALL
    00249     axutil_stream_flush_buffer(
    00250         axutil_stream_t * stream,
    00251         const axutil_env_t * env);
    00252
    00253     AXIS2_EXTERN int AXIS2_CALL
    00254     axutil_stream_peek_socket(
    00255         axutil_stream_t * stream,
    00256         const axutil_env_t * env,
    00257         void *buffer,
    00258         size_t count);
    00259
    00260     AXIS2_EXTERN axis2_status_t AXIS2_CALL
    00261     axutil_stream_flush(
    00262         axutil_stream_t * stream,
    00263         const axutil_env_t * env);
    00264
    00265     AXIS2_EXTERN axis2_status_t AXIS2_CALL
    00266     axutil_stream_close(
    00267         axutil_stream_t * stream,
    00268         const axutil_env_t * env);
    00269
    00270     AXIS2_EXTERN axis2_status_t AXIS2_CALL
    00271     axutil_stream_set_read(
    00272         axutil_stream_t * stream,
    00273         const axutil_env_t * env,
    00274         AXUTIL_STREAM_READ func);
    00275
    00276     AXIS2_EXTERN axis2_status_t AXIS2_CALL
    00277     axutil_stream_set_write(
    00278         axutil_stream_t * stream,
    00279         const axutil_env_t * env,
    00280         AXUTIL_STREAM_WRITE func);
    00281
    00282     AXIS2_EXTERN axis2_status_t AXIS2_CALL
    00283     axutil_stream_set_skip(
    00284         axutil_stream_t * stream,
    00285         const axutil_env_t * env,
    00286         AXUTIL_STREAM_SKIP func);
    00287
    00290 #ifdef __cplusplus
    00291 }
    00292 #endif
    00293
    00294 #endif                          /* AXIS2_STREAM_H */