-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathuriparser.h
32 lines (25 loc) · 1.01 KB
/
uriparser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef __URL_PARSER_H
#define __URL_PARSER_H
#include <sys/types.h>
#define URI_PARSE_ERR -1
#define URI_TOOMANYPARAMS_ERR -2
// contains name and value of a parameter (value == NULL if is a param without value
struct uri_keyvalue {
const char* name;
size_t name_len;
const char* value;
size_t value_len;
};
// if port is absent then the return value is set to -1
int parse_uri(const char* buf_start, size_t buf_len,
const char** scheme, size_t* scheme_len,
const char** host, size_t* host_len,
int* port,
const char** path, size_t* path_len,
struct uri_keyvalue* params, size_t* num_params,
const char** fragment, size_t* fragment_len);
int parse_uri_path(const char* buf_start, size_t buf_len,
const char** path, size_t* path_len,
struct uri_keyvalue* params, size_t* num_params,
const char** fragment, size_t* fragment_len);
#endif