Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

parse.h File Reference

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Typedefs

typedef context ParseContext

Functions

ParseContextparse_context_create (Octstr *str)
void parse_context_destroy (ParseContext *context)
int parse_error (ParseContext *context)
void parse_clear_error (ParseContext *context)
void parse_set_error (ParseContext *context)
int parse_limit (ParseContext *context, long length)
int parse_pop_limit (ParseContext *context)
long parse_octets_left (ParseContext *context)
int parse_skip (ParseContext *context, long count)
void parse_skip_to_limit (ParseContext *context)
int parse_skip_to (ParseContext *context, long pos)
int parse_peek_char (ParseContext *context)
int parse_get_char (ParseContext *context)
Octstrparse_get_octets (ParseContext *context, long length)
unsigned long parse_get_uintvar (ParseContext *context)
Octstrparse_get_nul_string (ParseContext *context)
Octstrparse_get_line (ParseContext *context)
Octstrparse_get_seperated_block (ParseContext *context, Octstr *seperator)
Octstrparse_get_rest (ParseContext *context)


Typedef Documentation

typedef struct context ParseContext
 

Definition at line 79 of file parse.h.

Referenced by mime_decompile(), mime_entity_body(), mime_something_to_entity(), parse_clear_error(), parse_context_create(), parse_context_destroy(), parse_error(), parse_get_char(), parse_get_line(), parse_get_nul_string(), parse_get_octets(), parse_get_rest(), parse_get_seperated_block(), parse_get_uintvar(), parse_limit(), parse_octets_left(), parse_peek_char(), parse_pop_limit(), parse_set_error(), parse_skip(), parse_skip_to(), parse_skip_to_limit(), proxy_unpack_credentials(), radius_attr_unpack(), radius_pdu_unpack(), read_mime_headers(), unpack_accept_language_general_form(), unpack_broken_parameters(), unpack_cache_directive(), unpack_challenge(), unpack_content_range(), unpack_credentials(), unpack_disposition(), unpack_encoding_version(), unpack_field_name(), unpack_multi_octet_integer(), unpack_optional_q_value(), unpack_parameter(), unpack_q_value(), unpack_range_value(), unpack_retry_after(), unpack_warning_value(), wsp_field_value(), wsp_headers_unpack(), wsp_secondary_field_value(), wsp_skip_field_value(), wsp_unpack_accept_charset_general_form(), wsp_unpack_accept_general_form(), wsp_unpack_all_parameters(), wsp_unpack_app_header(), wsp_unpack_date_value(), wsp_unpack_integer_value(), and wsp_unpack_well_known_field().


Function Documentation

void parse_clear_error ParseContext context  ) 
 

Definition at line 107 of file parse.c.

References context::error, gw_assert, and ParseContext.

Referenced by unpack_range_value().

00108 {
00109     gw_assert(context != NULL);
00110 
00111     context->error = 0;
00112 }

ParseContext* parse_context_create Octstr str  ) 
 

Definition at line 74 of file parse.c.

References context::data, octstr_len(), ParseContext, and result.

Referenced by mime_decompile(), mime_entity_body(), mime_something_to_entity(), radius_pdu_unpack(), and wsp_headers_unpack().

00075 {
00076     ParseContext *result;
00077 
00078     result = gw_malloc(sizeof(*result));
00079     result->data = str;
00080     result->pos = 0;
00081     result->limit = octstr_len(str);
00082     result->limit_stack = NULL;
00083     result->error = 0;
00084 
00085     return result;
00086 }

Here is the call graph for this function:

void parse_context_destroy ParseContext context  ) 
 

Definition at line 88 of file parse.c.

References gw_assert, gwlist_destroy(), gwlist_extract_first(), gwlist_len(), context::limit_stack, and ParseContext.

Referenced by mime_entity_body(), mime_something_to_entity(), radius_pdu_unpack(), and wsp_headers_unpack().

00089 {
00090     gw_assert(context != NULL);
00091 
00092     if (context->limit_stack) {
00093         while (gwlist_len(context->limit_stack) > 0)
00094             gw_free(gwlist_extract_first(context->limit_stack));
00095         gwlist_destroy(context->limit_stack, NULL);
00096     }
00097     gw_free(context);
00098 }

Here is the call graph for this function:

int parse_error ParseContext context  ) 
 

Definition at line 100 of file parse.c.

References context::error, gw_assert, and ParseContext.

Referenced by parse_client_specifier(), proxy_unpack_credentials(), receive_push_reply(), unpack_accept_language_general_form(), unpack_broken_parameters(), unpack_cache_directive(), unpack_credentials(), unpack_field_name(), unpack_multi_octet_integer(), unpack_parameter(), unpack_range_value(), unpack_warning_value(), wsp_headers_unpack(), wsp_unpack_accept_charset_general_form(), wsp_unpack_accept_general_form(), wsp_unpack_all_parameters(), wsp_unpack_app_header(), and wsp_unpack_well_known_field().

00101 {
00102     gw_assert(context != NULL);
00103 
00104     return context->error;
00105 }

int parse_get_char ParseContext context  ) 
 

Definition at line 218 of file parse.c.

References context::data, context::error, gw_assert, context::limit, octstr_get_char(), ParseContext, and context::pos.

Referenced by radius_pdu_unpack(), unpack_disposition(), unpack_encoding_version(), unpack_multi_octet_integer(), unpack_q_value(), unpack_range_value(), unpack_retry_after(), wsp_field_value(), wsp_headers_unpack(), wsp_secondary_field_value(), wsp_unpack_date_value(), and wsp_unpack_integer_value().

00219 {
00220     gw_assert(context != NULL);
00221 
00222     if (context->pos == context->limit) {
00223         context->error = 1;
00224         return -1;
00225     }
00226 
00227     return octstr_get_char(context->data, context->pos++);
00228 }

Here is the call graph for this function:

Octstr* parse_get_line ParseContext context  ) 
 

Definition at line 282 of file parse.c.

References context::data, context::error, gw_assert, context::limit, octstr_copy, octstr_search_char(), octstr_strip_crlfs(), ParseContext, context::pos, and result.

Referenced by mime_something_to_entity(), and read_mime_headers().

00283 {
00284     Octstr *result;
00285     long pos;
00286 
00287     gw_assert(context != NULL);
00288 
00289     pos = octstr_search_char(context->data, '\n', context->pos);
00290     if (pos < 0 || pos >= context->limit) {
00291         context->error = 1;
00292         return NULL;
00293     }
00294     
00295     result = octstr_copy(context->data, context->pos, pos - context->pos);
00296     context->pos = pos + 1;
00297 
00298     octstr_strip_crlfs(result);
00299 
00300     return result;
00301 }

Here is the call graph for this function:

Octstr* parse_get_nul_string ParseContext context  ) 
 

Definition at line 263 of file parse.c.

References context::data, context::error, gw_assert, context::limit, octstr_copy, octstr_search_char(), ParseContext, context::pos, and result.

Referenced by proxy_unpack_credentials(), unpack_accept_language_general_form(), unpack_cache_directive(), unpack_challenge(), unpack_credentials(), unpack_field_name(), unpack_parameter(), unpack_warning_value(), wsp_unpack_accept_charset_general_form(), wsp_unpack_accept_general_form(), wsp_unpack_app_header(), and wsp_unpack_well_known_field().

00264 {
00265     Octstr *result;
00266     long pos;
00267 
00268     gw_assert(context != NULL);
00269 
00270     pos = octstr_search_char(context->data, 0, context->pos);
00271     if (pos < 0 || pos >= context->limit) {
00272         context->error = 1;
00273         return NULL;
00274     }
00275 
00276     result = octstr_copy(context->data, context->pos, pos - context->pos);
00277     context->pos = pos + 1;
00278 
00279     return result;
00280 }

Here is the call graph for this function:

Octstr* parse_get_octets ParseContext context,
long  length
 

Definition at line 230 of file parse.c.

References context::data, context::error, gw_assert, context::limit, octstr_copy, ParseContext, context::pos, and result.

Referenced by mime_decompile(), radius_pdu_unpack(), and wsp_unpack_well_known_field().

00231 {
00232     Octstr *result;
00233 
00234     gw_assert(context != NULL);
00235 
00236     if (context->pos + length > context->limit) {
00237         context->error = 1;
00238         return NULL;
00239     }
00240 
00241     result = octstr_copy(context->data, context->pos, length);
00242     context->pos += length;
00243     return result;
00244 }

Octstr* parse_get_rest ParseContext context  ) 
 

Definition at line 329 of file parse.c.

References context::data, gw_assert, octstr_delete(), octstr_duplicate, ParseContext, and context::pos.

Referenced by mime_entity_body(), and mime_something_to_entity().

00330 {
00331     Octstr *rest;
00332     
00333     gw_assert(context != NULL);
00334     
00335     octstr_delete(context->data, 0, context->pos);
00336     rest = octstr_duplicate(context->data);   
00337     
00338     return rest;   
00339 }

Here is the call graph for this function:

Octstr* parse_get_seperated_block ParseContext context,
Octstr seperator
 

Definition at line 303 of file parse.c.

References context::data, context::error, gw_assert, context::limit, octstr_copy, octstr_len(), octstr_search(), ParseContext, context::pos, and result.

Referenced by mime_something_to_entity().

00304 {
00305     Octstr *result;
00306     long spos, epos;
00307 
00308     gw_assert(context != NULL);
00309     gw_assert(seperator != NULL);
00310 
00311     spos = octstr_search(context->data, seperator, context->pos);
00312     if (spos < 0 || spos >= context->limit) {
00313         context->error = 1;
00314         return NULL;
00315     }
00316     epos = octstr_search(context->data, seperator, spos + octstr_len(seperator));
00317     if (epos < 0 || epos >= context->limit) {
00318         context->error = 1;
00319         return NULL;
00320     }
00321 
00322     spos = spos + octstr_len(seperator);
00323     result = octstr_copy(context->data, spos, epos - spos);
00324     context->pos = epos;
00325 
00326     return result;
00327 }

Here is the call graph for this function:

unsigned long parse_get_uintvar ParseContext context  ) 
 

Definition at line 246 of file parse.c.

References context::data, context::error, gw_assert, context::limit, octstr_extract_uintvar(), ParseContext, and context::pos.

Referenced by mime_decompile(), unpack_range_value(), wsp_field_value(), and wsp_secondary_field_value().

00247 {
00248     long pos;
00249     unsigned long value;
00250 
00251     gw_assert(context != NULL);
00252 
00253     pos = octstr_extract_uintvar(context->data, &value, context->pos);
00254     if (pos < 0 || pos > context->limit) {
00255         context->error = 1;
00256         return 0;
00257     }
00258 
00259     context->pos = pos;
00260     return value;
00261 }

Here is the call graph for this function:

int parse_limit ParseContext context,
long  length
 

Definition at line 121 of file parse.c.

References context::error, gw_assert, gwlist_create, gwlist_insert(), context::limit, context::limit_stack, ParseContext, and context::pos.

Referenced by wsp_field_value().

00122 {
00123     long *elem;
00124 
00125     gw_assert(context != NULL);
00126 
00127     if (context->pos + length > context->limit) {
00128         context->error = 1;
00129         return -1;
00130     }
00131 
00132     if (context->limit_stack == NULL)
00133         context->limit_stack = gwlist_create();
00134 
00135     elem = gw_malloc(sizeof(*elem));
00136     *elem = context->limit;
00137     gwlist_insert(context->limit_stack, 0, elem);
00138     context->limit = context->pos + length;
00139     return 0;
00140 }

Here is the call graph for this function:

long parse_octets_left ParseContext context  ) 
 

Definition at line 159 of file parse.c.

References gw_assert, context::limit, ParseContext, and context::pos.

Referenced by mime_decompile(), unpack_broken_parameters(), unpack_cache_directive(), unpack_challenge(), unpack_optional_q_value(), wsp_headers_unpack(), wsp_unpack_all_parameters(), and wsp_unpack_well_known_field().

00160 {
00161     gw_assert(context != NULL);
00162 
00163     return context->limit - context->pos;
00164 }

int parse_peek_char ParseContext context  ) 
 

Definition at line 206 of file parse.c.

References context::data, context::error, gw_assert, context::limit, octstr_get_char(), ParseContext, and context::pos.

Referenced by proxy_unpack_credentials(), unpack_challenge(), and unpack_credentials().

00207 {
00208     gw_assert(context != NULL);
00209 
00210     if (context->pos == context->limit) {
00211         context->error = 1;
00212         return -1;
00213     }
00214 
00215     return octstr_get_char(context->data, context->pos);
00216 }

Here is the call graph for this function:

int parse_pop_limit ParseContext context  ) 
 

Definition at line 142 of file parse.c.

References context::error, gw_assert, gwlist_extract_first(), gwlist_len(), context::limit, context::limit_stack, and ParseContext.

Referenced by wsp_skip_field_value(), and wsp_unpack_well_known_field().

00143 {
00144     long *elem;
00145 
00146     gw_assert(context != NULL);
00147 
00148     if (context->limit_stack == NULL || gwlist_len(context->limit_stack) == 0) {
00149         context->error = 1;
00150         return -1;
00151     }
00152 
00153     elem = gwlist_extract_first(context->limit_stack);
00154     context->limit = *elem;
00155     gw_free(elem);
00156     return 0;
00157 }

Here is the call graph for this function:

void parse_set_error ParseContext context  ) 
 

Definition at line 114 of file parse.c.

References context::error, gw_assert, and ParseContext.

Referenced by unpack_parameter().

00115 {
00116     gw_assert(context != NULL);
00117 
00118     context->error = 1;
00119 }

int parse_skip ParseContext context,
long  count
 

Definition at line 166 of file parse.c.

References context::error, gw_assert, context::limit, ParseContext, and context::pos.

Referenced by proxy_unpack_credentials(), radius_pdu_unpack(), unpack_challenge(), unpack_credentials(), wsp_field_value(), wsp_headers_unpack(), wsp_secondary_field_value(), and wsp_unpack_well_known_field().

00167 {
00168     gw_assert(context != NULL);
00169 
00170     if (context->pos + count > context->limit) {
00171         context->pos = context->limit;
00172         context->error = 1;
00173         return -1;
00174     }
00175 
00176     context->pos += count;
00177     return 0;
00178 }

int parse_skip_to ParseContext context,
long  pos
 

Definition at line 187 of file parse.c.

References context::error, gw_assert, context::limit, ParseContext, and context::pos.

00188 {
00189     gw_assert(context != NULL);
00190 
00191     if (pos < 0) {
00192         context->error = 1;
00193         return -1;
00194     }
00195 
00196     if (pos > context->limit) {
00197         context->pos = context->limit;
00198         context->error = 1;
00199         return -1;
00200     }
00201 
00202     context->pos = pos;
00203     return 0;
00204 }

void parse_skip_to_limit ParseContext context  ) 
 

Definition at line 180 of file parse.c.

References gw_assert, context::limit, ParseContext, and context::pos.

Referenced by unpack_parameter(), wsp_skip_field_value(), and wsp_unpack_well_known_field().

00181 {
00182     gw_assert(context != NULL);
00183 
00184     context->pos = context->limit;
00185 }

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.