/*
- * Copyright (C) 2015, 2016, 2017 "IoT.bzh"
+ * Copyright (C) 2015-2018 "IoT.bzh"
* Author "Fulup Ar Foll"
* Author José Bollo <jose.bollo@iot.bzh>
*
/* global variables */
static struct afb_wsj1 *wsj1;
static struct afb_proto_ws *pws;
+static int breakcon;
static int exonrep;
static int callcount;
static int human;
{
char *name = strrchr(arg0, '/');
name = name ? name + 1 : arg0;
- fprintf(status ? stderr : stdout, "usage: %s [-H [-r]] uri [api verb [data]]\n", name);
- fprintf(status ? stderr : stdout, " %s -d [-H [-r]] uri [verb [data]]\n", name);
+ fprintf(status ? stderr : stdout, "usage: %s [-H [-r]] [-b] uri [api verb [data]]\n", name);
+ fprintf(status ? stderr : stdout, " %s -d [-H [-r]] [-b] uri [verb [data]]\n", name);
exit(status);
}
else if (!strcmp(av[1], "--direct")) /* request for direct api */
direct = 1;
+ else if (!strcmp(av[1], "--break")) /* request to break connection */
+ breakcon = 1;
+
/* emit usage and exit */
else
usage(!!strcmp(av[1], "--help"), a0);
case 'H': human = 1; break;
case 'r': raw = 1; break;
case 'd': direct = 1; break;
+ case 'b': breakcon = 1; break;
default: usage(av[1][rc] != 'h', a0);
}
}
wsj1_event(verb, object);
else
wsj1_call(api, verb, object);
+ if (breakcon)
+ exit(0);
}
/* called when something happens on stdin */
o = json_object_new_string(object);
}
rc = afb_proto_ws_client_call(pws, verb, o, sessionid, key);
+ json_object_put(o);
if (rc < 0) {
fprintf(stderr, "calling %s(%s) failed: %m\n", verb, object?:"");
dec_callcount();
}
+ if (breakcon)
+ exit(0);
}
/* called when pws hangsup */