aboutsummaryrefslogtreecommitdiff
path: root/src/ctl.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-01-05 20:17:51 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-01-05 20:19:03 +0200
commit659ed5b33cf70a6898697c7c5886ae068a3be966 (patch)
tree9887be03351861823d59081321072eb568298241 /src/ctl.c
parent9dbd617046f19979d8c8ed9e31e4b71d18e20235 (diff)
downloadpies-659ed5b33cf70a6898697c7c5886ae068a3be966.tar.gz
pies-659ed5b33cf70a6898697c7c5886ae068a3be966.tar.bz2
control interface: pass JSON as query for GET, DELETE, and PUT
Diffstat (limited to 'src/ctl.c')
-rw-r--r--src/ctl.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/ctl.c b/src/ctl.c
index 8845390..0960d54 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -917,7 +917,7 @@ static struct ctlio_resource *
917find_resource (struct ctlio *io, const char *endpoint) 917find_resource (struct ctlio *io, const char *endpoint)
918{ 918{
919 struct ctlio_resource *p; 919 struct ctlio_resource *p;
920 size_t len = strlen (endpoint); 920 size_t len = strcspn (endpoint, "?");
921 921
922 if (len == 0) 922 if (len == 0)
923 return NULL; 923 return NULL;
@@ -927,7 +927,9 @@ find_resource (struct ctlio *io, const char *endpoint)
927 927
928 for (p = restab; p->uri; p++) 928 for (p = restab; p->uri; p++)
929 if (len >= p->uri_len && memcmp (p->uri, endpoint, p->uri_len) == 0 929 if (len >= p->uri_len && memcmp (p->uri, endpoint, p->uri_len) == 0
930 && (endpoint[p->uri_len] == 0 || endpoint[p->uri_len] == '/')) 930 && (endpoint[p->uri_len] == 0
931 || endpoint[p->uri_len] == '/'
932 || endpoint[p->uri_len] == '?'))
931 return p; 933 return p;
932 return NULL; 934 return NULL;
933} 935}
@@ -935,11 +937,8 @@ find_resource (struct ctlio *io, const char *endpoint)
935static char * 937static char *
936json_extract (char *uri) 938json_extract (char *uri)
937{ 939{
938 char *p = strrchr (uri, '/'); 940 char *p = strchr (uri, '?');
939 if (p && (strchr ("\"{[", p[1]) 941 if (p)
940 || strcmp ("true", p + 1) == 0
941 || strcmp ("false", p + 1) == 0
942 || strcmp ("null", p + 1) == 0))
943 { 942 {
944 *p++ = 0; 943 *p++ = 0;
945 return p; 944 return p;

Return to:

Send suggestions and report system problems to the System administrator.