From: Jeroen van der Heijden Date: Mon, 13 Jan 2020 17:17:30 +0000 (+0100) Subject: Start work on serviceapi X-Git-Tag: archive/raspbian/2.0.44-1+rpi1~1^2~3^2~5^2~31 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=e0470996b4861f3bcd57fad89c2df231af0edd24;p=siridb-server.git Start work on serviceapi --- diff --git a/include/siri/api.h b/include/siri/api.h index 2ea8ae0d..24857a99 100644 --- a/include/siri/api.h +++ b/include/siri/api.h @@ -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; }; diff --git a/src/siri/api.c b/src/siri/api.c index d2944a07..93e724fa 100644 --- a/src/siri/api.c +++ b/src/siri/api.c @@ -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; } diff --git a/src/siri/service/account.c b/src/siri/service/account.c index 44870b72..1f7af030 100644 --- a/src/siri/service/account.c +++ b/src/siri/service/account.c @@ -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)