# guththila_buffer.h

    00001
    00002 /*
    00003  * Licensed to the Apache Software Foundation (ASF) under one or more
    00004  * contributor license agreements.  See the NOTICE file distributed with
    00005  * this work for additional information regarding copyright ownership.
    00006  * The ASF licenses this file to You under the Apache License, Version 2.0
    00007  * (the "License"); you may not use this file except in compliance with
    00008  * the License.  You may obtain a copy of the License at
    00009  *
    00010  *      http://www.apache.org/licenses/LICENSE-2.0
    00011  *
    00012  * Unless required by applicable law or agreed to in writing, software
    00013  * distributed under the License is distributed on an "AS IS" BASIS,
    00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    00015  * See the License for the specific language governing permissions and
    00016  * limitations under the License.
    00017  */
    00018 #ifndef GUTHTHILA_BUFFER_H
    00019 #define GUTHTHILA_BUFFER_H
    00020
    00021 #include <guththila_defines.h>
    00022 #include <axutil_utils.h>
    00023
    00024 EXTERN_C_START()
    00025
    00026 typedef enum guththila_buffer_type
    00027 {
    00028     GUTHTHILA_SINGLE_BUFFER = 0, /* One buffer */
    00029     GUTHTHILA_MULTIPLE_BUFFER    /* Mulitple buffers in a buff array */
    00030 } guththila_buffer_type_t;
    00031
    00032 typedef struct guththila_buffer_s
    00033 {
    00034     /* Required to manupulate multiple buffers */
    00035     size_t *data_size;                  /* Array containing filled sizes of buffers */
    00036     size_t *buffs_size;                 /* Array containing actual sizes of buffers */
    00037     guththila_char_t **buff;    /* Array of buffers */
    00038     int cur_buff;                               /* Current buffer */
    00039     int cur_buff_pos;                   /* Position of the current buffer */
    00040     size_t pre_tot_data;                /* All the data in the previous buffers. Not include cur */
    00041     unsigned int no_buffers;    /* No of buffers */
    00042     short type;                                 /* Buffer type */
    00043     guththila_char_t *xml;              /* All the buffers serialized together */
    00044 } guththila_buffer_t;
    00045
    00046 #define GUTHTHILA_BUFFER_DEF_SIZE 16384
    00047 #define GUTHTHILA_BUFFER_DEF_MIN_SIZE 512
    00048 #define GUTHTHILA_BUFFER_NUMBER_OF_BUFFERS 16
    00049
    00050 #ifndef GUTHTHILA_BUFFER_SIZE
    00051 #define GUTHTHILA_BUFFER_SIZE(_buffer) (_buffer.size)
    00052 #endif
    00053
    00054 #ifndef GUTHTHILA_BUFFER_CURRENT_BUFF
    00055 #define GUTHTHILA_BUFFER_CURRENT_BUFF(_buffer) ((_buffer).buff[(_buffer).cur_buff] + (_buffer).data_size[(_buffer).cur_buff])
    00056 #endif
    00057
    00058 #ifndef GUTHTHILA_BUFFER_CURRENT_BUFF_SIZE
    00059 #define GUTHTHILA_BUFFER_CURRENT_BUFF_SIZE(_buffer) ((_buffer).buffs_size[(_buffer).cur_buff] - (_buffer).data_size[(_buffer).cur_buff])
    00060 #endif
    00061
    00062 #ifndef GUTHTHILA_BUFFER_CURRENT_DATA_SIZE
    00063 #define GUTHTHILA_BUFFER_CURRENT_DATA_SIZE(_buffer) ((_buffer).data_size[(_buffer).cur_buff])
    00064 #endif
    00065
    00066 #ifndef GUTHTHILA_BUFFER_PRE_DATA_SIZE
    00067 #define GUTHTHILA_BUFFER_PRE_DATA_SIZE(_buffer) ((_buffer).pre_tot_data)
    00068 #endif
    00069
    00070 /*We never consider tokens not in the current buffer*/
    00071 #ifndef GUTHTHILA_BUF_POS
    00072 #define GUTHTHILA_BUF_POS(_buffer, _pos) ((_buffer).buff[(_buffer).cur_buff] + _pos - (_buffer).pre_tot_data)
    00073 #endif
    00074
    00083 int GUTHTHILA_CALL
    00084 guththila_buffer_init(guththila_buffer_t * buffer,
    00085                                           int size,
    00086                                           const axutil_env_t * env);
    00087
    00095 int GUTHTHILA_CALL
    00096 guththila_buffer_un_init(guththila_buffer_t * buffer,
    00097                                            const axutil_env_t * env);
    00098
    00109 int GUTHTHILA_CALL
    00110 guththila_buffer_init_for_buffer(guththila_buffer_t * mu_buff,
    00111                                                                  guththila_char_t *buffer,
    00112                                                                  int size,
    00113                                                                  const axutil_env_t * env);
    00114
    00115 void *GUTHTHILA_CALL
    00116 guththila_get_position(guththila_buffer_t * buffer,
    00117                                            int pos,
    00118                                            const axutil_env_t * env);
    00119
    00120 int GUTHTHILA_CALL
    00121 guththila_buffer_next(guththila_buffer_t * buffer,
    00122                                           const axutil_env_t * env);
    00123
    00124
    00133 void *GUTHTHILA_CALL
    00134 guththila_buffer_get(guththila_buffer_t * buffer,
    00135                                          const axutil_env_t * env);
    00136
    00137
    00138 int GUTHTHILA_CALL
    00139 guththila_buffer_shift(guththila_buffer_t * buffer,
    00140                                            int no, const axutil_env_t * env);
    00141
    00142 int GUTHTHILA_CALL
    00143 guththila_buffer_insert_data(guththila_buffer_t * buffer,
    00144                                                          void *buff, size_t buff_len,
    00145                                                          const axutil_env_t * env);
    00146
    00147 EXTERN_C_END()
    00148 #endif
    00149
    00150
    00151
    00152