From d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb Mon Sep 17 00:00:00 2001 From: ng0 Date: Sun, 8 Sep 2019 12:33:09 +0000 Subject: uncrustify as demanded. --- src/rest/rest.c | 79 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 40 deletions(-) (limited to 'src/rest/rest.c') diff --git a/src/rest/rest.c b/src/rest/rest.c index b0c2da6c2..44af5f2e0 100644 --- a/src/rest/rest.c +++ b/src/rest/rest.c @@ -11,7 +11,7 @@ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. - + You should have received a copy of the GNU Affero General Public License along with this program. If not, see . @@ -33,17 +33,17 @@ * REST Utilities */ - /** - * Check if namespace is in URL. - * - * @param url URL to check - * @param namespace namespace to check against - * @retun GNUNET_YES if namespace matches - */ +/** + * Check if namespace is in URL. + * + * @param url URL to check + * @param namespace namespace to check against + * @retun GNUNET_YES if namespace matches + */ int -GNUNET_REST_namespace_match (const char *url, const char *namespace) +GNUNET_REST_namespace_match(const char *url, const char *namespace) { - return 0 == strncmp (namespace, url, strlen (namespace)); + return 0 == strncmp(namespace, url, strlen(namespace)); } /** @@ -53,30 +53,29 @@ GNUNET_REST_namespace_match (const char *url, const char *namespace) * @retun MHD response */ struct MHD_Response* -GNUNET_REST_create_response (const char *data) +GNUNET_REST_create_response(const char *data) { struct MHD_Response *resp; size_t len; if (NULL == data) - { - len = 0; - data = ""; - } + { + len = 0; + data = ""; + } else - len = strlen (data); - resp = MHD_create_response_from_buffer (len, - (void*)data, - MHD_RESPMEM_MUST_COPY); + len = strlen(data); + resp = MHD_create_response_from_buffer(len, + (void*)data, + MHD_RESPMEM_MUST_COPY); return resp; - } int -GNUNET_REST_handle_request (struct GNUNET_REST_RequestHandle *conn, - const struct GNUNET_REST_RequestHandler *handlers, - struct GNUNET_REST_RequestHandlerError *err, - void *cls) +GNUNET_REST_handle_request(struct GNUNET_REST_RequestHandle *conn, + const struct GNUNET_REST_RequestHandler *handlers, + struct GNUNET_REST_RequestHandlerError *err, + void *cls) { int count; int i; @@ -86,23 +85,23 @@ GNUNET_REST_handle_request (struct GNUNET_REST_RequestHandle *conn, while (NULL != handlers[count].method) count++; - GNUNET_asprintf (&url, "%s", conn->url); - if (url[strlen (url)-1] == '/') - url[strlen (url)-1] = '\0'; + GNUNET_asprintf(&url, "%s", conn->url); + if (url[strlen(url) - 1] == '/') + url[strlen(url) - 1] = '\0'; for (i = 0; i < count; i++) - { - if (0 != strcasecmp (conn->method, handlers[i].method)) - continue; - if (strlen (url) < strlen (handlers[i].namespace)) - continue; - if (GNUNET_NO == GNUNET_REST_namespace_match (url, handlers[i].namespace)) - continue; - //Match - handlers[i].proc (conn, (const char*)url, cls); - GNUNET_free (url); - return GNUNET_YES; - } - GNUNET_free (url); + { + if (0 != strcasecmp(conn->method, handlers[i].method)) + continue; + if (strlen(url) < strlen(handlers[i].namespace)) + continue; + if (GNUNET_NO == GNUNET_REST_namespace_match(url, handlers[i].namespace)) + continue; + //Match + handlers[i].proc(conn, (const char*)url, cls); + GNUNET_free(url); + return GNUNET_YES; + } + GNUNET_free(url); err->error_code = MHD_HTTP_BAD_REQUEST; return GNUNET_NO; } -- cgit v1.2.3