-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathuripathparser.rl
More file actions
41 lines (35 loc) · 819 Bytes
/
uripathparser.rl
File metadata and controls
41 lines (35 loc) · 819 Bytes
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
33
34
35
36
37
38
39
40
41
#include <stddef.h>
#include "uriparser.h"
%%{
machine uripath_parser;
include uriparser_common "uriparser_common.rl";
main := full_path;
write data;
}%%
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)
{
const char *p = buf_start;
const char *pe = p + buf_len;
int cs;
const char *eof = pe;
int err = 0;
*path = NULL;
*path_len = 0;
size_t max_params = *num_params;
*num_params = 0;
*fragment = NULL;
*fragment_len = 0;
%%{
write init;
write exec;
}%%
if (err) {
return err;
} else if (cs < uripath_parser_first_final) {
return URI_PARSE_ERR;
}
return 0;
}