1 /*
2 * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
3 * Version 2, December 2004
4 *
5 * Copyright (C) 2012-2013 Sebastien Tricaud <sebastien@honeynet.org>
6 *
7 * Everyone is permitted to copy and distribute verbatim or modified
8 * copies of this license document, and changing it is allowed as long
9 * as the name is changed.
10 *
11 * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
12 * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
13 *
14 * 0. You just DO WHAT THE FUCK YOU WANT TO.
15 */
16
17 #include <faup/faup.h>
18 #ifdef FAUP_LUA_MODULES
19 #include <faup/modules.h>
20 #endif
21
22
23 #include <stdlib.h>
24
faup_init(faup_options_t * options)25 faup_handler_t *faup_init(faup_options_t *options)
26 {
27 faup_handler_t *fh;
28 int retval;
29
30 fh = malloc(sizeof(faup_handler_t));
31 fh->faup.decoded = false;
32 fh->faup.url_type = FAUP_URL_HAS_NO_TLD;
33 memset(&fh->faup.features, 0, sizeof(fh->faup.features));
34
35 if (options) {
36 fh->options = options;
37 } else {
38 fh->options = faup_options_new();
39 }
40 #ifdef FAUP_LUA_MODULES
41 retval = faup_modules_new(fh);
42 #endif
43
44 return fh;
45 }
46
faup_get_version(void)47 char *faup_get_version(void)
48 {
49 return FAUP_VERSION;
50 }
51
faup_terminate(faup_handler_t * fh)52 void faup_terminate(faup_handler_t *fh)
53 {
54 #ifdef FAUP_LUA_MODULES
55 faup_modules_terminate(fh->modules);
56 #endif
57 free(fh);
58 }
59
faup_get_scheme_pos(faup_handler_t * fh)60 int32_t faup_get_scheme_pos(faup_handler_t *fh)
61 {
62 return faup_get_pos(fh, scheme);
63 }
64
faup_get_scheme_size(faup_handler_t * fh)65 uint32_t faup_get_scheme_size(faup_handler_t *fh)
66 {
67 return faup_get_size(fh, scheme);
68 }
69
faup_get_credential_pos(faup_handler_t * fh)70 int32_t faup_get_credential_pos(faup_handler_t *fh)
71 {
72 return faup_get_pos(fh, credential);
73 }
74
faup_get_credential_size(faup_handler_t * fh)75 uint32_t faup_get_credential_size(faup_handler_t *fh)
76 {
77 return faup_get_size(fh, credential);
78 }
79
faup_get_subdomain_pos(faup_handler_t * fh)80 int32_t faup_get_subdomain_pos(faup_handler_t *fh)
81 {
82 return faup_get_pos(fh, subdomain);
83 }
84
faup_get_subdomain_size(faup_handler_t * fh)85 uint32_t faup_get_subdomain_size(faup_handler_t *fh)
86 {
87 return faup_get_size(fh, subdomain);
88 }
89
faup_get_domain_pos(faup_handler_t * fh)90 int32_t faup_get_domain_pos(faup_handler_t *fh)
91 {
92 return faup_get_pos(fh, domain);
93 }
94
faup_get_domain_size(faup_handler_t * fh)95 uint32_t faup_get_domain_size(faup_handler_t *fh)
96 {
97 return faup_get_size(fh, domain);
98 }
99
faup_get_domain_without_tld_pos(faup_handler_t * fh)100 int32_t faup_get_domain_without_tld_pos(faup_handler_t *fh)
101 {
102 return faup_get_pos(fh, domain_without_tld);
103 }
104
faup_get_domain_without_tld_size(faup_handler_t * fh)105 uint32_t faup_get_domain_without_tld_size(faup_handler_t *fh)
106 {
107 return faup_get_size(fh, domain_without_tld);
108 }
109
faup_get_host_pos(faup_handler_t * fh)110 int32_t faup_get_host_pos(faup_handler_t *fh)
111 {
112 return faup_get_pos(fh, host);
113 }
114
faup_get_host_size(faup_handler_t * fh)115 uint32_t faup_get_host_size(faup_handler_t *fh)
116 {
117 return faup_get_size(fh, host);
118 }
119
faup_get_tld_pos(faup_handler_t * fh)120 int32_t faup_get_tld_pos(faup_handler_t *fh)
121 {
122 return faup_get_pos(fh, tld);
123 }
124
faup_get_tld_size(faup_handler_t * fh)125 uint32_t faup_get_tld_size(faup_handler_t *fh)
126 {
127 return faup_get_size(fh, tld);
128 }
129
faup_get_port_pos(faup_handler_t * fh)130 int32_t faup_get_port_pos(faup_handler_t *fh)
131 {
132 return faup_get_pos(fh, port);
133 }
134
faup_get_port_size(faup_handler_t * fh)135 uint32_t faup_get_port_size(faup_handler_t *fh)
136 {
137 return faup_get_size(fh, port);
138 }
139
faup_get_resource_path_pos(faup_handler_t * fh)140 int32_t faup_get_resource_path_pos(faup_handler_t *fh)
141 {
142 return faup_get_pos(fh, resource_path);
143 }
144
faup_get_resource_path_size(faup_handler_t * fh)145 uint32_t faup_get_resource_path_size(faup_handler_t *fh)
146 {
147 return faup_get_size(fh, resource_path);
148 }
149
faup_get_query_string_pos(faup_handler_t * fh)150 int32_t faup_get_query_string_pos(faup_handler_t *fh)
151 {
152 return faup_get_pos(fh, query_string);
153 }
154
faup_get_query_string_size(faup_handler_t * fh)155 uint32_t faup_get_query_string_size(faup_handler_t *fh)
156 {
157 return faup_get_size(fh, query_string);
158 }
159
faup_get_fragment_pos(faup_handler_t * fh)160 int32_t faup_get_fragment_pos(faup_handler_t *fh)
161 {
162 return faup_get_pos(fh, fragment);
163 }
164
faup_get_fragment_size(faup_handler_t * fh)165 uint32_t faup_get_fragment_size(faup_handler_t *fh)
166 {
167 return faup_get_size(fh, fragment);
168 }
169
170