5 * System control handler. This covers control over all aspects of the system.
6 * E.g: Actuators, system commands (start/stop experiment/recording) etc
7 * @param context The context to work in
8 * @param params The input parameters
10 void Control_Handler(FCGIContext *context, char *params) {
11 const char *key, *value, *loginkey = NULL, *action = NULL;
14 while ((params = FCGI_KeyPair(params, &key, &value))) {
15 if (!strcmp(key, "action"))
17 else if (!strcmp(key, "key"))
19 else if (!strcmp(key, "force"))
21 else if (!strcmp(key, "id")) {
24 else if (!strcmp(key, "value")) {
29 if (!strcmp(action, "start")) {
30 FCGI_Authorize(context, force);
31 } else if (!strcmp(action, "stop")) { //Don't require control key to stop...
33 FCGI_BeginJSON(context, STATUS_OK);
34 FCGI_JSONPair("description", "stopped!"); //Not really
37 if (!FCGI_Authorized(context, loginkey)) {
38 FCGI_BeginJSON(context, STATUS_UNAUTHORIZED);
39 FCGI_JSONPair("description", "Invalid key specified.");
42 } else if (!strcmp(action, "end")) {
43 FCGI_AuthorizeEnd(context);
44 } else if (!strcmp(action, "set")) {
45 FCGI_BeginJSON(context, STATUS_OK);
46 FCGI_JSONPair("description", "actuated!");