Start work on serviceapi
authorJeroen van der Heijden <jeroen@transceptor.technology>
Mon, 13 Jan 2020 17:17:30 +0000 (18:17 +0100)
committerJeroen van der Heijden <jeroen@transceptor.technology>
Mon, 13 Jan 2020 17:17:30 +0000 (18:17 +0100)
include/siri/api.h
src/siri/api.c
src/siri/service/account.c

index 2ea8ae0d92aa4e5fe923506a7d1732498a754325..24857a9996557a3edfb94e256d5d186ec5116cf7 100644 (file)
@@ -20,6 +20,7 @@ typedef enum
     SIRI_API_RT_NONE,
     SIRI_API_RT_QUERY,
     SIRI_API_RT_INSERT,
+    SIRI_APT_RT_SERVICE,
 } siri_api_req_t;
 
 typedef enum
@@ -60,6 +61,7 @@ struct siri_api_request_s
     uv_stream_t * stream;
     siri_api_content_t content_type;
     siri_api_req_t request_type;
+    service_request_t service_type;
     http_parser parser;
     uv_write_t req;
 };
index d2944a07a9f6769e1c695decdb3a0e1be446f2a4..93e724fa3b19768d7c92be3f7db1bf83635ad8e5 100644 (file)
@@ -26,6 +26,9 @@ typedef struct
 #define API__ICMP_WITH(__s, __n, __w) \
     (__n == strlen(__w) && strncasecmp(__s, __w, __n) == 0)
 
+#define API__CMP_WITH(__s, __n, __w) \
+    (__n == strlen(__w) && strncmp(__s, __w, __n) == 0)
+
 static const char api__content_type[3][20] = {
         "text/plain",
         "application/json",
@@ -205,6 +208,10 @@ static int api__url_cb(http_parser * parser, const char * at, size_t n)
         ar->request_type = SIRI_API_RT_INSERT;
         api__get_siridb(ar, at, n);
     }
+    else if (API__CMP_WITH(at, n, "/new-account"))
+    {
+        ar->request_type = SIRI_API_RT_INSERT;
+    }
 
     return 0;
 }
index 44870b72107d54e02a5486871bf4881d3dded80e..1f7af0304ee30f5b1d765e5624d4e8afdc0cbbd9 100644 (file)
@@ -207,7 +207,7 @@ int siri_service_account_check(
         return -1;
     }
 
-    password= strndup(
+    password = strndup(
             (const char *) qp_password->via.raw, qp_password->len);
 
     if (password == NULL)