summaryrefslogtreecommitdiffabout
path: root/src/ctl.c
authorSergey Poznyakoff <gray@gnu.org.ua>2016-01-05 18:17:51 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-01-05 18:19:03 (GMT)
commit659ed5b33cf70a6898697c7c5886ae068a3be966 (patch) (side-by-side diff)
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') (more/less context) (ignore whitespace changes)
-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 *
find_resource (struct ctlio *io, const char *endpoint)
{
struct ctlio_resource *p;
- size_t len = strlen (endpoint);
+ size_t len = strcspn (endpoint, "?");
if (len == 0)
return NULL;
@@ -927,7 +927,9 @@ find_resource (struct ctlio *io, const char *endpoint)
for (p = restab; p->uri; p++)
if (len >= p->uri_len && memcmp (p->uri, endpoint, p->uri_len) == 0
- && (endpoint[p->uri_len] == 0 || endpoint[p->uri_len] == '/'))
+ && (endpoint[p->uri_len] == 0
+ || endpoint[p->uri_len] == '/'
+ || endpoint[p->uri_len] == '?'))
return p;
return NULL;
}
@@ -935,11 +937,8 @@ find_resource (struct ctlio *io, const char *endpoint)
static char *
json_extract (char *uri)
{
- char *p = strrchr (uri, '/');
- if (p && (strchr ("\"{[", p[1])
- || strcmp ("true", p + 1) == 0
- || strcmp ("false", p + 1) == 0
- || strcmp ("null", p + 1) == 0))
+ char *p = strchr (uri, '?');
+ if (p)
{
*p++ = 0;
return p;

Return to:

Send suggestions and report system problems to the System administrator.