Annotation of gpl/axl/src/axl_stream.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  *  LibAxl:  Another XML library
                      3:  *  Copyright (C) 2006 Advanced Software Production Line, S.L.
                      4:  *
                      5:  *  This program is free software; you can redistribute it and/or
                      6:  *  modify it under the terms of the GNU Lesser General Public License
                      7:  *  as published by the Free Software Foundation; either version 2.1 of
                      8:  *  the License, or (at your option) any later version.
                      9:  *
                     10:  *  This program is distributed in the hope that it will be useful,
                     11:  *  but WITHOUT ANY WARRANTY; without even the implied warranty of 
                     12:  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
                     13:  *  GNU Lesser General Public License for more details.
                     14:  *
                     15:  *  You should have received a copy of the GNU Lesser General Public
                     16:  *  License along with this program; if not, write to the Free
                     17:  *  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
                     18:  *  02111-1307 USA
                     19:  *  
                     20:  *  You may find a copy of the license under this software is released
                     21:  *  at COPYING file. This is LGPL software: you are welcome to
                     22:  *  develop proprietary applications using this library without any
                     23:  *  royalty or fee but returning back any change, improvement or
                     24:  *  addition in the form of source code, project image, documentation
                     25:  *  patches, etc. 
                     26:  *
                     27:  *  For commercial support on build XML enabled solutions contact us:
                     28:  *          
                     29:  *      Postal address:
                     30:  *         Advanced Software Production Line, S.L.
                     31:  *         Edificio Alius A, Oficina 102,
                     32:  *         C/ Antonio Suarez Nº 10,
                     33:  *         Alcalá de Henares 28802 Madrid
                     34:  *         Spain
                     35:  *
                     36:  *      Email address:
                     37:  *         info@aspl.es - http://www.aspl.es/xml
                     38:  */
                     39: #ifndef __AXL_STREAM_H__
                     40: #define __AXL_STREAM_H__
                     41: 
                     42: #include <axl_decl.h>
                     43: 
                     44: BEGIN_C_DECLS
                     45: 
                     46: /** 
                     47:  * \addtogroup axl_stream_module
                     48:  * @{
                     49:  */
                     50: 
                     51: axlStream * axl_stream_new             (const char  * stream_source, 
                     52:                                        int           stream_size,
                     53:                                        const char  * file_path,
                     54:                                        int           fd_handler,
                     55:                                        axlError   ** error);
                     56: 
                     57: int         axl_stream_inspect         (axlStream * stream, const char * chunk, int inspected_size);
                     58: 
                     59: int         axl_stream_inspect_code    (axlStream * stream, char value, int index_desp);
                     60: 
                     61: int         axl_stream_peek            (axlStream * stream, const char * chunk, int inspected_size);
                     62: 
                     63: int         axl_stream_inspect_several (axlStream * stream, int chunk_num, ...);
                     64: 
                     65: void        axl_stream_accept          (axlStream * stream);
                     66: 
                     67: void        axl_stream_move            (axlStream * stream, int index);
                     68: 
                     69: void        axl_stream_step            (axlStream * stream, int bytes);
                     70: 
                     71: void        axl_stream_push            (axlStream * stream, const char * content, int size);
                     72: 
                     73: axl_bool    axl_stream_fall_outside    (axlStream * stream, int inspected_size);
                     74: 
                     75: axl_bool    axl_stream_check           (axlStream * stream, char * chunk, int inspected_size);
                     76: 
                     77: char      * axl_stream_get_until       (axlStream * stream, 
                     78:                                        char      * valid_chars, 
                     79:                                        int       * chunk_matched,
                     80:                                        axl_bool    accept_terminator,
                     81:                                        int         chunk_num, ...);
                     82: 
                     83: char      * axl_stream_get_until_ref   (axlStream * stream, 
                     84:                                        char      * valid_chars, 
                     85:                                        int       * chunk_matched,
                     86:                                        axl_bool    accept_terminator,
                     87:                                        int       * result_size,
                     88:                                        int         chunk_num, ...);
                     89: 
                     90: char      * axl_stream_get_until_zero  (axlStream * stream, 
                     91:                                        char      * valid_chars, 
                     92:                                        int       * chunk_matched,
                     93:                                        axl_bool    accept_terminator,
                     94:                                        int         chunk_num, ...);
                     95: 
                     96: char      * axl_stream_get_until_ref_zero  (axlStream * stream, 
                     97:                                            char      * valid_chars, 
                     98:                                            int       * chunk_matched,
                     99:                                            axl_bool    accept_terminator,
                    100:                                            int       * result_size,
                    101:                                            int         chunk_num, ...);
                    102: 
                    103: void       axl_stream_set_buffer_alloc   (axlStream * stream,
                    104:                                          axlStreamAlloc handler,
                    105:                                          axlPointer     data);
                    106: 
                    107: /** 
                    108:  * @brief Enum value that allows to configure which item to nullify
                    109:  * inside the provided \ref axlStream reference.
                    110:  * 
                    111:  */
                    112: typedef enum { 
                    113:        /** 
                    114:         * @brief Nullify the last chunk returned due to call from \ref axl_stream_get_until.
                    115:         */
                    116:        LAST_CHUNK, 
                    117:        /** 
                    118:         * @brief Nullify the last chunk returned by \ref axl_stream_get_near_to function.
                    119:         */
                    120:        LAST_NEAR_TO, 
                    121:        /** 
                    122:         * @brief Nullify the last chunk returned by \ref axl_stream_get_following function.
                    123:         */
                    124:        LAST_GET_FOLLOWING
                    125: } NullifyItem;
                    126: 
                    127: void        axl_stream_nullify         (axlStream * stream,
                    128:                                        NullifyItem item);
                    129:                                        
                    130: 
                    131: char      * axl_stream_get_untilv      (axlStream * stream, 
                    132:                                        char      * valid_chars, 
                    133:                                        int       * chunk_matched,
                    134:                                        axl_bool    accept_terminator,
                    135:                                        int       * result_size,
                    136:                                        int         chunk_num,
                    137:                                        va_list args);
                    138: 
                    139: int         axl_stream_get_index       (axlStream * stream);
                    140: 
                    141: int         axl_stream_get_global_index (axlStream * stream);
                    142: 
                    143: int         axl_stream_get_size        (axlStream * stream);
                    144: 
                    145: const char * axl_stream_get_near_to    (axlStream * stream, int count);
                    146: 
                    147: const char * axl_stream_get_following  (axlStream * stream, int count);
                    148: 
                    149: void        axl_stream_link            (axlStream  *   stream,
                    150:                                        axlPointer     element,
                    151:                                        axlDestroyFunc func);
                    152: 
                    153: void        axl_stream_link_full       (axlStream  *   stream,
                    154:                                        axlPointer     element,
                    155:                                        axlDestroyFunc func,
                    156:                                        axl_bool       free_on_finish);
                    157: 
                    158: void        axl_stream_unlink          (axlStream * stream);
                    159: 
                    160: void        axl_stream_free            (axlStream * stream);
                    161: 
                    162: axl_bool    axl_stream_is_white_space  (char * chunk);
                    163: 
                    164: void        axl_stream_consume_white_spaces (axlStream * stream);
                    165: 
                    166: axl_bool    axl_stream_remains         (axlStream * stream);
                    167: 
                    168: /* @} */
                    169: 
                    170: /* string handling interface */
                    171: 
                    172: void        axl_stream_trim              (char * chunk);
                    173: 
                    174: void        axl_stream_trim_with_size    (char * chunk, int * trimmed);
                    175: 
                    176: void        axl_stream_remove            (char * chunk, const char * value, axl_bool first);
                    177: 
                    178: axl_bool    axl_stream_cmp               (const char * chunk1, const char * chunk2, int size);
                    179: 
                    180: axl_bool    axl_stream_casecmp           (const char * chunk1, const char * chunk2, int size);
                    181: 
                    182: char      * axl_stream_strdup            (const char * chunk);
                    183: 
                    184: char      * axl_stream_strdup_n          (const char * chunk, int n);
                    185: 
                    186: int         axl_stream_vprintf_len       (const char * format, 
                    187:                                          va_list args);
                    188: 
                    189: int         axl_stream_printf_len        (const char * format, 
                    190:                                          ...);
                    191: 
                    192: char      * axl_stream_strdup_printf     (const char * chunk, ...);
                    193: 
                    194: char      * axl_stream_strdup_printfv    (const char * chunk, va_list args);
                    195: 
                    196: char      * axl_stream_strdup_printf_len (const char * chunk, 
                    197:                                          int  * chunk_size, ...);
                    198: 
                    199: int         axl_stream_printf_buffer     (char * buffer, 
                    200:                                          int    buffer_size, 
                    201:                                          int  * real_size,
                    202:                                          const char * format, ...);
                    203: 
                    204: char     ** axl_stream_split           (const char * chunk, int separator_num, ...);
                    205: 
                    206: void        axl_stream_clean_split     (char ** split);
                    207: 
                    208: char      * axl_stream_join            (char ** strings, const char * separator);
                    209: 
                    210: char      * axl_stream_concat          (const char * chunk1, const char * chunk2);
                    211: 
                    212: int         axl_stream_strv_num        (char ** chunks);
                    213: 
                    214: void        axl_stream_freev           (char ** chunks);
                    215: 
                    216: char      * axl_stream_to_upper        (char  * chunk);
                    217: 
                    218: char      * axl_stream_to_lower        (char  * chunk);
                    219: 
                    220: char      * axl_stream_to_upper_copy   (const char  * chunk);
                    221: 
                    222: char      * axl_stream_to_lower_copy   (const char  * chunk);
                    223: 
                    224: axl_bool    axl_cmp (const char * string, const char * string2);
                    225: 
                    226: axl_bool    axl_casecmp (const char * string, const char * string2);
                    227: 
                    228: axl_bool    axl_memcmp (const char * string, const char * string2, int size);
                    229: 
                    230: char      * axl_strdup (const char * string);
                    231: 
                    232: axl_bool    axl_stream_setup_decode        (axlStream         * stream,
                    233:                                            const char        * source_encoding,
                    234:                                            axlStreamDecode     decode_f,
                    235:                                            axlPointer          user_data,
                    236:                                            axlError         ** error);
                    237: 
                    238: axl_bool    axl_stream_setup_check         (axlStream                * stream,
                    239:                                            const char               * source_encoding,
                    240:                                            axlStreamContentCheck      check,
                    241:                                            axlPointer                 user_data,
                    242:                                            axlError                ** error);
                    243: 
                    244: axl_bool    axl_stream_decode              (axlStream  * stream, 
                    245:                                            char       * output, 
                    246:                                            int          output_max_size, 
                    247:                                            int        * output_decoded, 
                    248:                                            int        * op_result, 
                    249:                                            axlError  ** error);
                    250: 
                    251: axl_bool    axl_stream_content_check       (axlStream   * stream,
                    252:                                            const char  * content,
                    253:                                            int           content_length,
                    254:                                            axlError   ** error);
                    255: 
                    256: /** 
                    257:  * \addtogroup axl_string_module
                    258:  * @{
                    259:  */
                    260: 
                    261: /** 
                    262:  * @brief Alias definition for \ref axl_stream_strdup_printf.
                    263:  *
                    264:  * See \ref axl_stream_strdup_printf information for more details.
                    265:  */
                    266: #define axl_strdup_printf axl_stream_strdup_printf
                    267: 
                    268: /** 
                    269:  * @brief Alias definition for \ref axl_stream_strdup_printfv.
                    270:  */
                    271: #define axl_strdup_printfv axl_stream_strdup_printfv
                    272: 
                    273: /**
                    274:  * @brief Alias definition for the \ref axl_stream_concat.
                    275:  */
                    276: #define     axl_concat axl_stream_concat
                    277: 
                    278: /**
                    279:  * @brief Alias definition for the \ref axl_stream_join.
                    280:  */
                    281: #define     axl_join   axl_stream_join
                    282: 
                    283: /**
                    284:  * @brief Alias definition for the \ref axl_stream_split.
                    285:  */
                    286: #define     axl_split  axl_stream_split
                    287: 
                    288: /**
                    289:  * @brief Alias definition for the \ref axl_stream_freev.
                    290:  */
                    291: #define     axl_freev  axl_stream_freev
                    292: 
                    293: /**
                    294:  * @brief Convenient interface to check if an string reference is NULL
                    295:  * to return an static "undefined string". This is useful in the case
                    296:  * string references are used on functions that can't handle NULL
                    297:  * values.
                    298:  *
                    299:  * @param ref An string reference to check.
                    300:  */
                    301: #define     axl_check_undef(ref) (ref ? ref : "NULL")
                    302: 
                    303: /* @} */
                    304: 
                    305: END_C_DECLS
                    306: 
                    307: #endif

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>