uncrustify as demanded.
[oweals/gnunet.git] / src / rest / rest.c
index b0c2da6c2a389af9fa3bca081897be15e1e580c4..44af5f2e0e013605a20e934d7134e8d5f1822e47 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
 
  * 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;
 }