HTTP Parser and message builder / objects in plain C Snapshot
|
uri parser More...
Classes | |
struct | tagURI |
Defines | |
#define | URI_FLAGS_PARSE_PARTS 1 |
#define | URI_FLAGS_IS_ABSOLUTE_URI 2 |
#define | URI_FLAGS_IS_OPAQUE 4 |
#define | URI_FLAGS_HOST_IPv4 8 |
#define | URI_FLAGS_HOST_IPv6 16 |
#define | URI_FLAGS_HOST_HOSTNAME 32 |
#define | URI_FLAGS_HAS_SCHEME 64 |
Typedefs | |
typedef struct tagURI | URI |
Functions | |
M_INLINE void | URI_init (URI *url) |
int | URI_parse (URI *url, char *line) |
M_INLINE void | URI_free (URI *url) |
M_INLINE const char * | URI_scheme (URI *url) |
M_INLINE const char * | URI_userinfo_raw (URI *url) |
M_INLINE const char * | URI_userinfo (URI *url) |
M_INLINE const char * | URI_host (URI *url) |
M_INLINE int | URI_port (URI *url) |
M_INLINE const char * | URI_path_raw (URI *url) |
M_INLINE const char * | URI_path (URI *url) |
M_INLINE const char * | URI_query_raw (URI *url) |
M_INLINE const char * | URI_query (URI *url) |
M_INLINE const char * | URI_fragment_raw (URI *url) |
M_INLINE const char * | URI_fragment (URI *url) |
M_INLINE const char * | URI_opaque_raw (URI *url) |
M_INLINE const char * | URI_opaque (URI *url) |
uri parser
M_INLINE const char* URI_fragment | ( | URI * | url | ) |
M_INLINE const char* URI_fragment_raw | ( | URI * | url | ) |
Definition at line 126 of file uri.h.
{ return url->fragment_raw; }
M_INLINE void URI_free | ( | URI * | url | ) |
Definition at line 65 of file uri.h.
{ if (url->cdata_raw) { free( url->cdata_raw ); } if (url->cdata) { free(url->cdata); } if ( url->cdata_is_escaped ) { free( url->cdata_is_escaped ); } URI_init( url ); }
M_INLINE const char* URI_host | ( | URI * | url | ) |
M_INLINE void URI_init | ( | URI * | url | ) |
M_INLINE const char* URI_opaque | ( | URI * | url | ) |
M_INLINE const char* URI_opaque_raw | ( | URI * | url | ) |
Definition at line 136 of file uri.h.
{ return url->opaque_raw; }
int URI_parse | ( | URI * | url, |
char * | line | ||
) |
Definition at line 523 of file uri.c.
{ URI_init( url ); URIPARSECTX ctx; char *ptr,*next; size_t slen; ctx.rep = url; slen = strlen( line ); url->cdata = (char *) malloc( slen ); if (!url->cdata) { goto err; } ctx.cdata_pos_off = ctx.cdata_pos_start = ctx.cdata_pos = url->cdata; url->cdata_raw = (char *) malloc( slen ); if (!url->cdata_raw) { goto err; } url->cdata_is_escaped = (char *) malloc( slen ); if (!url->cdata_is_escaped) { goto err; } memset( url->cdata_is_escaped, 0, slen ); ctx.cdata_is_escaped_start = url->cdata_is_escaped; ctx.cdata_raw_pos = url->cdata_raw; ptr = line; if (ptr[0] == '/') { if ( parse_hier_part( &ctx, ptr, &next, 0) ) { goto err; } } else { if (! parse_scheme( &ctx, ptr, &next )) { ptr = next; if ( parse_hier_part( &ctx, ptr, &next, 1 ) ) { goto err; } } else { if ( parse_authority( &ctx, ptr, &next )) { goto err; } } } if (*next == '\0') { return 0; } err: URI_free( url ); return -1; }
M_INLINE const char* URI_path | ( | URI * | url | ) |
M_INLINE const char* URI_path_raw | ( | URI * | url | ) |
M_INLINE const char* URI_query | ( | URI * | url | ) |
M_INLINE const char* URI_query_raw | ( | URI * | url | ) |
M_INLINE const char* URI_scheme | ( | URI * | url | ) |
M_INLINE const char* URI_userinfo | ( | URI * | url | ) |
M_INLINE const char* URI_userinfo_raw | ( | URI * | url | ) |
Definition at line 85 of file uri.h.
{ return url->userinfo_raw; }