File:  [ELWIX - Embedded LightWeight unIX -] / gpl / axl / src / axl_stream.h
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Fri Feb 17 12:50:03 2012 UTC (12 years, 4 months ago) by misho
Branches: axl, MAIN
CVS tags: HEAD, AXL0_6_7
version 0.6.7

    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: int         axl_stream_peek            (axlStream * stream, const char * chunk, int inspected_size);
   61: 
   62: int         axl_stream_inspect_several (axlStream * stream, int chunk_num, ...);
   63: 
   64: void        axl_stream_accept          (axlStream * stream);
   65: 
   66: void        axl_stream_move            (axlStream * stream, int index);
   67: 
   68: void        axl_stream_step            (axlStream * stream, int bytes);
   69: 
   70: void        axl_stream_push            (axlStream * stream, const char * content, int size);
   71: 
   72: axl_bool    axl_stream_fall_outside    (axlStream * stream, int inspected_size);
   73: 
   74: axl_bool    axl_stream_check           (axlStream * stream, char * chunk, int inspected_size);
   75: 
   76: char      * axl_stream_get_until       (axlStream * stream, 
   77: 					char      * valid_chars, 
   78: 					int       * chunk_matched,
   79: 					axl_bool    accept_terminator,
   80: 					int         chunk_num, ...);
   81: 
   82: char      * axl_stream_get_until_ref   (axlStream * stream, 
   83: 					char      * valid_chars, 
   84: 					int       * chunk_matched,
   85: 					axl_bool    accept_terminator,
   86: 					int       * result_size,
   87: 					int         chunk_num, ...);
   88: 
   89: char      * axl_stream_get_until_zero  (axlStream * stream, 
   90: 					char      * valid_chars, 
   91: 					int       * chunk_matched,
   92: 					axl_bool    accept_terminator,
   93: 					int         chunk_num, ...);
   94: 
   95: char      * axl_stream_get_until_ref_zero  (axlStream * stream, 
   96: 					    char      * valid_chars, 
   97: 					    int       * chunk_matched,
   98: 					    axl_bool    accept_terminator,
   99: 					    int       * result_size,
  100: 					    int         chunk_num, ...);
  101: 
  102: void       axl_stream_set_buffer_alloc   (axlStream * stream,
  103: 					  axlStreamAlloc handler,
  104: 					  axlPointer     data);
  105: 
  106: /** 
  107:  * @brief Enum value that allows to configure which item to nullify
  108:  * inside the provided \ref axlStream reference.
  109:  * 
  110:  */
  111: typedef enum { 
  112: 	/** 
  113: 	 * @brief Nullify the last chunk returned due to call from \ref axl_stream_get_until.
  114: 	 */
  115: 	LAST_CHUNK, 
  116: 	/** 
  117: 	 * @brief Nullify the last chunk returned by \ref axl_stream_get_near_to function.
  118: 	 */
  119: 	LAST_NEAR_TO, 
  120: 	/** 
  121: 	 * @brief Nullify the last chunk returned by \ref axl_stream_get_following function.
  122: 	 */
  123: 	LAST_GET_FOLLOWING
  124: } NullifyItem;
  125: 
  126: void        axl_stream_nullify         (axlStream * stream,
  127: 					NullifyItem item);
  128: 					
  129: 
  130: char      * axl_stream_get_untilv      (axlStream * stream, 
  131: 					char      * valid_chars, 
  132: 					int       * chunk_matched,
  133: 					axl_bool    accept_terminator,
  134: 					int       * result_size,
  135: 					int         chunk_num,
  136: 					va_list args);
  137: 
  138: int         axl_stream_get_index       (axlStream * stream);
  139: 
  140: int         axl_stream_get_global_index (axlStream * stream);
  141: 
  142: int         axl_stream_get_size        (axlStream * stream);
  143: 
  144: const char * axl_stream_get_near_to    (axlStream * stream, int count);
  145: 
  146: const char * axl_stream_get_following  (axlStream * stream, int count);
  147: 
  148: void        axl_stream_link            (axlStream  *   stream,
  149: 					axlPointer     element,
  150: 					axlDestroyFunc func);
  151: 
  152: void        axl_stream_link_full       (axlStream  *   stream,
  153: 					axlPointer     element,
  154: 					axlDestroyFunc func,
  155: 					axl_bool       free_on_finish);
  156: 
  157: void        axl_stream_unlink          (axlStream * stream);
  158: 
  159: void        axl_stream_free            (axlStream * stream);
  160: 
  161: axl_bool    axl_stream_is_white_space  (char * chunk);
  162: 
  163: void        axl_stream_consume_white_spaces (axlStream * stream);
  164: 
  165: axl_bool    axl_stream_remains         (axlStream * stream);
  166: 
  167: /* @} */
  168: 
  169: /* string handling interface */
  170: 
  171: void        axl_stream_trim              (char * chunk);
  172: 
  173: void        axl_stream_trim_with_size    (char * chunk, int * trimmed);
  174: 
  175: void        axl_stream_remove            (char * chunk, const char * value, axl_bool first);
  176: 
  177: axl_bool    axl_stream_cmp               (const char * chunk1, const char * chunk2, int size);
  178: 
  179: axl_bool    axl_stream_casecmp           (const char * chunk1, const char * chunk2, int size);
  180: 
  181: char      * axl_stream_strdup            (const char * chunk);
  182: 
  183: char      * axl_stream_strdup_n          (const char * chunk, int n);
  184: 
  185: int         axl_stream_vprintf_len       (const char * format, 
  186: 					  va_list args);
  187: 
  188: int         axl_stream_printf_len        (const char * format, 
  189: 					  ...);
  190: 
  191: char      * axl_stream_strdup_printf     (const char * chunk, ...);
  192: 
  193: char      * axl_stream_strdup_printfv    (const char * chunk, va_list args);
  194: 
  195: char      * axl_stream_strdup_printf_len (const char * chunk, 
  196: 					  int  * chunk_size, ...);
  197: 
  198: int         axl_stream_printf_buffer     (char * buffer, 
  199: 					  int    buffer_size, 
  200: 					  int  * real_size,
  201: 					  const char * format, ...);
  202: 
  203: char     ** axl_stream_split           (const char * chunk, int separator_num, ...);
  204: 
  205: void        axl_stream_clean_split     (char ** split);
  206: 
  207: char      * axl_stream_join            (char ** strings, const char * separator);
  208: 
  209: int         axl_stream_replace         (char ** source, int source_len, 
  210: 					const char * string, int string_len, 
  211: 					const char * replacement, int replacement_len);
  212: 
  213: char      * axl_stream_concat          (const char * chunk1, const char * chunk2);
  214: 
  215: int         axl_stream_strv_num        (char ** chunks);
  216: 
  217: void        axl_stream_freev           (char ** chunks);
  218: 
  219: char      * axl_stream_to_upper        (char  * chunk);
  220: 
  221: char      * axl_stream_to_lower        (char  * chunk);
  222: 
  223: char      * axl_stream_to_upper_copy   (const char  * chunk);
  224: 
  225: char      * axl_stream_to_lower_copy   (const char  * chunk);
  226: 
  227: axl_bool    axl_cmp (const char * string, const char * string2);
  228: 
  229: axl_bool    axl_casecmp (const char * string, const char * string2);
  230: 
  231: axl_bool    axl_memcmp (const char * string, const char * string2, int size);
  232: 
  233: char      * axl_strdup (const char * string);
  234: 
  235: axl_bool    axl_stream_setup_decode        (axlStream         * stream,
  236: 					    const char        * source_encoding,
  237: 					    axlStreamDecode     decode_f,
  238: 					    axlPointer          user_data,
  239: 					    axlError         ** error);
  240: 
  241: axl_bool    axl_stream_setup_check         (axlStream                * stream,
  242: 					    const char               * source_encoding,
  243: 					    axlStreamContentCheck      check,
  244: 					    axlPointer                 user_data,
  245: 					    axlError                ** error);
  246: 
  247: axl_bool    axl_stream_decode              (axlStream  * stream, 
  248: 					    char       * output, 
  249: 					    int          output_max_size, 
  250: 					    int        * output_decoded, 
  251: 					    int        * op_result, 
  252: 					    axlError  ** error);
  253: 
  254: axl_bool    axl_stream_content_check       (axlStream   * stream,
  255: 					    const char  * content,
  256: 					    int           content_length,
  257: 					    axlError   ** error);
  258: 
  259: /** 
  260:  * \addtogroup axl_string_module
  261:  * @{
  262:  */
  263: 
  264: /** 
  265:  * @brief Alias definition for \ref axl_stream_strdup_printf.
  266:  *
  267:  * See \ref axl_stream_strdup_printf information for more details.
  268:  */
  269: #define axl_strdup_printf axl_stream_strdup_printf
  270: 
  271: /** 
  272:  * @brief Alias definition for \ref axl_stream_strdup_printfv.
  273:  */
  274: #define axl_strdup_printfv axl_stream_strdup_printfv
  275: 
  276: /**
  277:  * @brief Alias definition for the \ref axl_stream_concat.
  278:  */
  279: #define     axl_concat axl_stream_concat
  280: 
  281: /**
  282:  * @brief Alias definition for the \ref axl_stream_join.
  283:  */
  284: #define     axl_join   axl_stream_join
  285: 
  286: /**
  287:  * @brief Alias definition for the \ref axl_stream_split.
  288:  */
  289: #define     axl_split  axl_stream_split
  290: 
  291: /** 
  292:  * @brief Simple macro that implements a non-binary string replace. To
  293:  * use it:
  294:  * \code
  295:  * axl_replace (source, string, replacement);
  296:  * axl_replace (source, "test", "..test..");
  297:  * \endcode
  298:  * See \ref axl_stream_replace for more info.
  299:  */
  300: #define axl_replace(source,string,replacement) axl_stream_replace(&source,-1,string,-1,replacement,-1)
  301: 
  302: /**
  303:  * @brief Alias definition for the \ref axl_stream_freev.
  304:  */
  305: #define     axl_freev  axl_stream_freev
  306: 
  307: /**
  308:  * @brief Convenient interface to check if an string reference is NULL
  309:  * to return an static "undefined string". This is useful in the case
  310:  * string references are used on functions that can't handle NULL
  311:  * values.
  312:  *
  313:  * @param ref An string reference to check.
  314:  */
  315: #define     axl_check_undef(ref) (ref ? ref : "NULL")
  316: 
  317: /* @} */
  318: 
  319: END_C_DECLS
  320: 
  321: #endif

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