Ignore:
Timestamp:
Nov 11, 2005 7:01:31 PM (18 years ago)
Author:
bennylp
Message:

First clean compile of pjsip

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/main/pjlib-util/include/pjlib-util/scanner.h

    r29 r43  
    11/* $Id$ 
    2  * 
    3  */ 
    4  
    5 #ifndef __PJ_PARSER_H__ 
    6 #define __PJ_PARSER_H__ 
     2 */ 
     3#ifndef __PJ_SCANNER_H__ 
     4#define __PJ_SCANNER_H__ 
    75 
    86/** 
     
    2018 * @brief 
    2119 * Text scanning utility. 
    22  */ 
    23  
    24 /** 
    25  * @defgroup PJ_CHARSPEC Character Filter Specification 
    26  * @ingroup PJ_SCAN 
    27  * @brief 
    28  * The type pj_char_spec is a specification of character set used in 
    29  * scanner. Application can define multiple character specs, such as to 
    30  * scan alpha numerics, numbers, tokens, etc. 
     20 * 
    3121 * @{ 
    3222 */ 
     
    3424/** 
    3525 * This describes the type of individual character specification in 
    36  * #pj_char_spec. 
    37  */ 
    38 typedef pj_uint8_t pj_char_spec_element_t; 
    39  
    40 /** 
    41  * The character specification is implemented as array of boolean flags. Each 
    42  * flag indicates the membership of the character in the spec. If the flag 
    43  * at one position is non-zero, then the character at that position belongs 
    44  * to the specification, and vice versa. 
    45  */ 
    46 typedef pj_char_spec_element_t pj_char_spec[256]; 
    47 // Note: it's got to be 256 (not 128) to cater for extended character in input. 
    48  
    49 /** 
    50  * Initialize character spec. 
    51  * @param cs the scanner character specification. 
    52  */ 
    53 PJ_DECL(void) pj_cs_init( pj_char_spec cs); 
    54  
    55 /** 
    56  * Set the membership of the specified character to TRUE. 
    57  * @param cs the scanner character specification. 
    58  * @param c the character. 
    59  */ 
    60 PJ_DECL(void) pj_cs_set( pj_char_spec cs, int c); 
     26 * #pj_cis_buf_t. Basicly the number of bits here 
     27 */ 
     28#ifndef PJ_CIS_ELEM_TYPE 
     29#   define PJ_CIS_ELEM_TYPE pj_uint32_t 
     30#endif 
     31 
     32/** 
     33 * This describes the type of individual character specification in 
     34 * #pj_cis_buf_t. 
     35 */ 
     36typedef PJ_CIS_ELEM_TYPE pj_cis_elem_t; 
     37 
     38/** 
     39 * Maximum number of input specification in a buffer. 
     40 * Effectively this means the number of bits in pj_cis_elem_t. 
     41 */ 
     42#define PJ_CIS_MAX_INDEX   (sizeof(pj_cis_elem_t) << 3) 
     43 
     44/** 
     45 * The scanner input specification buffer. 
     46 */ 
     47typedef struct pj_cis_buf_t 
     48{ 
     49    pj_cis_elem_t    cis_buf[256];  /**< Must be 256 (not 128)! */ 
     50    pj_cis_elem_t    use_mask;      /**< To keep used indexes.  */ 
     51} pj_cis_buf_t; 
     52 
     53/** 
     54 * Character input specification. 
     55 */ 
     56typedef struct pj_cis_t 
     57{ 
     58    pj_cis_elem_t   *cis_buf;       /**< Pointer to buffer.     */ 
     59    int              cis_id;        /**< Id.                    */ 
     60} pj_cis_t; 
     61 
     62/** 
     63 * Initialize scanner input specification buffer. 
     64 * 
     65 * @param cs_buf    The scanner character specification. 
     66 */ 
     67PJ_DECL(void) pj_cis_buf_init(pj_cis_buf_t *cs_buf); 
     68 
     69/** 
     70 * Create a new input specification. 
     71 * 
     72 * @param cs_buf    Specification buffer. 
     73 * @param cis       Character input specification to be initialized. 
     74 * 
     75 * @return          PJ_SUCCESS if new specification has been successfully 
     76 *                  created, or PJ_ETOOMANY if there are already too many 
     77 *                  specifications in the buffer. 
     78 */ 
     79PJ_DECL(pj_status_t) pj_cis_init(pj_cis_buf_t *cs_buf, pj_cis_t *cis); 
     80 
     81/** 
     82 * Create a new input specification based on an existing specification. 
     83 * 
     84 * @param new_cis   The new specification to be initialized. 
     85 * @param existing  The existing specification, from which the input 
     86 *                  bitmask will be copied to the new specification. 
     87 * 
     88 * @return          PJ_SUCCESS if new specification has been successfully 
     89 *                  created, or PJ_ETOOMANY if there are already too many 
     90 *                  specifications in the buffer. 
     91 */ 
     92PJ_DECL(pj_status_t) pj_cis_dup(pj_cis_t *new_cis, pj_cis_t *existing); 
     93 
     94/** 
     95 * Set the membership of the specified character. 
     96 * Note that this is a macro, and arguments may be evaluated more than once. 
     97 * 
     98 * @param cis       Pointer to character input specification. 
     99 * @param c         The character. 
     100 */ 
     101#define PJ_CIS_SET(cis,c)   ((cis)->cis_buf[(c)] |= (1 << (cis)->cis_id)) 
     102 
     103/** 
     104 * Remove the membership of the specified character. 
     105 * Note that this is a macro, and arguments may be evaluated more than once. 
     106 * 
     107 * @param cis       Pointer to character input specification. 
     108 * @param c         The character to be removed from the membership. 
     109 */ 
     110#define PJ_CIS_CLR(cis,c)   ((cis)->cis_buf[c] &= ~(1 << (cis)->cis_id)) 
     111 
     112/** 
     113 * Check the membership of the specified character. 
     114 * Note that this is a macro, and arguments may be evaluated more than once. 
     115 * 
     116 * @param cis       Pointer to character input specification. 
     117 * @param c         The character. 
     118 */ 
     119#define PJ_CIS_ISSET(cis,c) ((cis)->cis_buf[c] & (1 << (cis)->cis_id)) 
    61120 
    62121/** 
    63122 * Add the characters in the specified range '[cstart, cend)' to the  
    64123 * specification (the last character itself ('cend') is not added). 
    65  * @param cs the scanner character specification. 
    66  * @param cstart the first character in the range. 
    67  * @param cend the next character after the last character in the range. 
    68  */ 
    69 PJ_DECL(void) pj_cs_add_range( pj_char_spec cs, int cstart, int cend); 
     124 * 
     125 * @param cis       The scanner character specification. 
     126 * @param cstart    The first character in the range. 
     127 * @param cend      The next character after the last character in the range. 
     128 */ 
     129PJ_DECL(void) pj_cis_add_range( pj_cis_t *cis, int cstart, int cend); 
    70130 
    71131/** 
    72132 * Add alphabetic characters to the specification. 
    73  * @param cs the scanner character specification. 
    74  */ 
    75 PJ_DECL(void) pj_cs_add_alpha( pj_char_spec cs); 
     133 * 
     134 * @param cis       The scanner character specification. 
     135 */ 
     136PJ_DECL(void) pj_cis_add_alpha( pj_cis_t *cis); 
    76137 
    77138/** 
    78139 * Add numeric characters to the specification. 
    79  * @param cs the scanner character specification. 
    80  */ 
    81 PJ_DECL(void) pj_cs_add_num( pj_char_spec cs); 
     140 * 
     141 * @param cis       The scanner character specification. 
     142 */ 
     143PJ_DECL(void) pj_cis_add_num( pj_cis_t *cis); 
    82144 
    83145/** 
    84146 * Add the characters in the string to the specification. 
    85  * @param cs the scanner character specification. 
    86  * @param str the string. 
    87  */ 
    88 PJ_DECL(void) pj_cs_add_str( pj_char_spec cs, const char *str); 
     147 * 
     148 * @param cis       The scanner character specification. 
     149 * @param str       The string. 
     150 */ 
     151PJ_DECL(void) pj_cis_add_str( pj_cis_t *cis, const char *str); 
    89152 
    90153/** 
    91154 * Delete characters in the specified range from the specification. 
    92  * @param cs the scanner character specification. 
    93  * @param cstart the first character in the range. 
    94  * @param cend the next character after the last character in the range. 
    95  */ 
    96 PJ_DECL(void) pj_cs_del_range( pj_char_spec cs, int cstart, int cend); 
     155 * 
     156 * @param cis       The scanner character specification. 
     157 * @param cstart    The first character in the range. 
     158 * @param cend      The next character after the last character in the range. 
     159 */ 
     160PJ_DECL(void) pj_cis_del_range( pj_cis_t *cis, int cstart, int cend); 
    97161 
    98162/** 
    99163 * Delete characters in the specified string from the specification. 
    100  * @param cs the scanner character specification. 
    101  * @param str the string. 
    102  */ 
    103 PJ_DECL(void) pj_cs_del_str( pj_char_spec cs, const char *str); 
     164 * 
     165 * @param cis       The scanner character specification. 
     166 * @param str       The string. 
     167 */ 
     168PJ_DECL(void) pj_cis_del_str( pj_cis_t *cis, const char *str); 
    104169 
    105170/** 
    106171 * Invert specification. 
    107  * @param cs the scanner character specification. 
    108  */ 
    109 PJ_DECL(void) pj_cs_invert( pj_char_spec cs ); 
     172 * 
     173 * @param cis       The scanner character specification. 
     174 */ 
     175PJ_DECL(void) pj_cis_invert( pj_cis_t *cis ); 
    110176 
    111177/** 
    112178 * Check whether the specified character belongs to the specification. 
    113  * @param cs the scanner character specification. 
    114  * @param c the character to check for matching. 
    115  */ 
    116 PJ_INLINE(int) pj_cs_match( const pj_char_spec cs, int c ) 
    117 { 
    118     return cs[c]; 
     179 * 
     180 * @param cis       The scanner character specification. 
     181 * @param c         The character to check for matching. 
     182 */ 
     183PJ_INLINE(int) pj_cis_match( const pj_cis_t *cis, int c ) 
     184{ 
     185    return PJ_CIS_ISSET(cis, c); 
    119186} 
    120187 
    121 /** 
    122  * @} 
    123  */ 
    124  
    125 /** 
    126  * @defgroup PJ_SCANNER Text Scanner 
    127  * @ingroup PJ_SCAN 
    128  * @{ 
    129  */ 
    130188 
    131189/** 
     
    157215 * The callback function type to be called by the scanner when it encounters 
    158216 * syntax error. 
    159  * @param scanner   The scanner instance that calls the callback . 
     217 * 
     218 * @param scanner       The scanner instance that calls the callback . 
    160219 */ 
    161220typedef void (*pj_syn_err_func_ptr)(struct pj_scanner *scanner); 
     
    245304 */ 
    246305PJ_DECL(int) pj_scan_peek( pj_scanner *scanner, 
    247                             const pj_char_spec spec, pj_str_t *out); 
     306                           const pj_cis_t *spec, pj_str_t *out); 
    248307 
    249308 
     
    262321 */ 
    263322PJ_DECL(int) pj_scan_peek_n( pj_scanner *scanner, 
    264                               pj_size_t len, pj_str_t *out); 
     323                             pj_size_t len, pj_str_t *out); 
    265324 
    266325 
     
    278337 */ 
    279338PJ_DECL(int) pj_scan_peek_until( pj_scanner *scanner, 
    280                                   const pj_char_spec spec,  
    281                                   pj_str_t *out); 
     339                                 const pj_cis_t *spec,  
     340                                 pj_str_t *out); 
    282341 
    283342 
     
    294353 */ 
    295354PJ_DECL(void) pj_scan_get( pj_scanner *scanner, 
    296                             const pj_char_spec spec, pj_str_t *out); 
     355                           const pj_cis_t *spec, pj_str_t *out); 
    297356 
    298357 
     
    318377 */ 
    319378PJ_DECL(void) pj_scan_get_n( pj_scanner *scanner, 
    320                               unsigned N, pj_str_t *out); 
     379                             unsigned N, pj_str_t *out); 
    321380 
    322381 
     
    326385 * @param scanner   The scanner. 
    327386 * 
    328  * @return (unknown) 
     387 * @return The character. 
    329388 */ 
    330389PJ_DECL(int) pj_scan_get_char( pj_scanner *scanner ); 
     
    349408 */ 
    350409PJ_DECL(void) pj_scan_get_until( pj_scanner *scanner, 
    351                                   const pj_char_spec spec, pj_str_t *out); 
     410                                 const pj_cis_t *spec, pj_str_t *out); 
    352411 
    353412 
     
    361420 */ 
    362421PJ_DECL(void) pj_scan_get_until_ch( pj_scanner *scanner,  
    363                                      int until_char, pj_str_t *out); 
     422                                    int until_char, pj_str_t *out); 
    364423 
    365424 
     
    373432 */ 
    374433PJ_DECL(void) pj_scan_get_until_chr( pj_scanner *scanner, 
    375                                       const char *until_spec, pj_str_t *out); 
     434                                     const char *until_spec, pj_str_t *out); 
    376435 
    377436/**  
     
    385444 */ 
    386445PJ_DECL(void) pj_scan_advance_n( pj_scanner *scanner, 
    387                                   unsigned N, pj_bool_t skip); 
     446                                 unsigned N, pj_bool_t skip); 
    388447 
    389448 
     
    446505 */ 
    447506 
    448 #if PJ_FUNCTIONS_ARE_INLINED 
    449 #  include "scanner_i.h" 
     507 
     508PJ_END_DECL 
     509 
    450510#endif 
    451511 
    452  
    453 PJ_END_DECL 
    454  
    455 #endif 
    456  
Note: See TracChangeset for help on using the changeset viewer.