MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / get_httpd_cb

Function get_httpd_cb

modules/httpd/httpd_proc.c:194–226  ·  view source on GitHub ↗

* Function that retrieves the callback function that should * handle the current request. * * @param url Pointer to the root part of the HTTP URL. * @return The callback function to handle the HTTP request. */

Source from the content-addressed store, hash-verified

192 * @return The callback function to handle the HTTP request.
193 */
194struct httpd_cb *get_httpd_cb(const char *url)
195{
196 int url_len;
197 int index;
198 struct httpd_cb *cb;
199 str *http_root;
200
201 if (!url) {
202 LM_ERR("NULL URL\n"); return NULL;
203 }
204 url_len = strlen(url);
205 if (url_len<=0) {
206 LM_ERR("Invalid url length [%d]\n", url_len); return NULL;
207 }
208 if (url[0] != '/') {
209 LM_ERR("URL starting with [%c] instead of'/'\n", *url);
210 return NULL;
211 }
212 cb = httpd_cb_list;
213 while(cb) {
214 index = 1;
215 http_root = cb->http_root;
216 if (url_len - index < http_root->len) goto skip;
217 if (strncmp(http_root->s, &url[index], http_root->len) != 0) goto skip;
218 index += http_root->len;
219 if (url_len - index == 0) return cb;
220 if (url[index] == '/') return cb;
221skip:
222 cb = cb->next;
223 }
224
225 return NULL;
226}
227
228#ifdef LIBMICROHTTPD
229/**

Callers 1

answer_to_connectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected