aboutsummaryrefslogtreecommitdiff
path: root/src/rest/rest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rest/rest.c')
-rw-r--r--src/rest/rest.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/rest/rest.c b/src/rest/rest.c
index 44af5f2e0..b83530ee1 100644
--- a/src/rest/rest.c
+++ b/src/rest/rest.c
@@ -41,9 +41,9 @@
41 * @retun GNUNET_YES if namespace matches 41 * @retun GNUNET_YES if namespace matches
42 */ 42 */
43int 43int
44GNUNET_REST_namespace_match(const char *url, const char *namespace) 44GNUNET_REST_namespace_match (const char *url, const char *namespace)
45{ 45{
46 return 0 == strncmp(namespace, url, strlen(namespace)); 46 return 0 == strncmp (namespace, url, strlen (namespace));
47} 47}
48 48
49/** 49/**
@@ -53,29 +53,29 @@ GNUNET_REST_namespace_match(const char *url, const char *namespace)
53 * @retun MHD response 53 * @retun MHD response
54 */ 54 */
55struct MHD_Response* 55struct MHD_Response*
56GNUNET_REST_create_response(const char *data) 56GNUNET_REST_create_response (const char *data)
57{ 57{
58 struct MHD_Response *resp; 58 struct MHD_Response *resp;
59 size_t len; 59 size_t len;
60 60
61 if (NULL == data) 61 if (NULL == data)
62 { 62 {
63 len = 0; 63 len = 0;
64 data = ""; 64 data = "";
65 } 65 }
66 else 66 else
67 len = strlen(data); 67 len = strlen (data);
68 resp = MHD_create_response_from_buffer(len, 68 resp = MHD_create_response_from_buffer (len,
69 (void*)data, 69 (void*) data,
70 MHD_RESPMEM_MUST_COPY); 70 MHD_RESPMEM_MUST_COPY);
71 return resp; 71 return resp;
72} 72}
73 73
74int 74int
75GNUNET_REST_handle_request(struct GNUNET_REST_RequestHandle *conn, 75GNUNET_REST_handle_request (struct GNUNET_REST_RequestHandle *conn,
76 const struct GNUNET_REST_RequestHandler *handlers, 76 const struct GNUNET_REST_RequestHandler *handlers,
77 struct GNUNET_REST_RequestHandlerError *err, 77 struct GNUNET_REST_RequestHandlerError *err,
78 void *cls) 78 void *cls)
79{ 79{
80 int count; 80 int count;
81 int i; 81 int i;
@@ -85,23 +85,23 @@ GNUNET_REST_handle_request(struct GNUNET_REST_RequestHandle *conn,
85 while (NULL != handlers[count].method) 85 while (NULL != handlers[count].method)
86 count++; 86 count++;
87 87
88 GNUNET_asprintf(&url, "%s", conn->url); 88 GNUNET_asprintf (&url, "%s", conn->url);
89 if (url[strlen(url) - 1] == '/') 89 if (url[strlen (url) - 1] == '/')
90 url[strlen(url) - 1] = '\0'; 90 url[strlen (url) - 1] = '\0';
91 for (i = 0; i < count; i++) 91 for (i = 0; i < count; i++)
92 { 92 {
93 if (0 != strcasecmp(conn->method, handlers[i].method)) 93 if (0 != strcasecmp (conn->method, handlers[i].method))
94 continue; 94 continue;
95 if (strlen(url) < strlen(handlers[i].namespace)) 95 if (strlen (url) < strlen (handlers[i].namespace))
96 continue; 96 continue;
97 if (GNUNET_NO == GNUNET_REST_namespace_match(url, handlers[i].namespace)) 97 if (GNUNET_NO == GNUNET_REST_namespace_match (url, handlers[i].namespace))
98 continue; 98 continue;
99 //Match 99 // Match
100 handlers[i].proc(conn, (const char*)url, cls); 100 handlers[i].proc (conn, (const char*) url, cls);
101 GNUNET_free(url); 101 GNUNET_free (url);
102 return GNUNET_YES; 102 return GNUNET_YES;
103 } 103 }
104 GNUNET_free(url); 104 GNUNET_free (url);
105 err->error_code = MHD_HTTP_BAD_REQUEST; 105 err->error_code = MHD_HTTP_BAD_REQUEST;
106 return GNUNET_NO; 106 return GNUNET_NO;
107} 107}