- while ((params = FCGI_KeyPair(params, &key, &value))) {
- if (!strcmp(key, "action"))
- action = value;
- else if (!strcmp(key, "key"))
- loginkey = value;
- else if (!strcmp(key, "force"))
- force = !force;
- else if (!strcmp(key, "id")) {
-
+ if (!strcmp(action, "lock")) {
+ FCGI_LockControl(context, force);
+ return;
+ } else if (!strcmp(action, "emergency")) {
+ desired_mode = CONTROL_EMERGENCY;
+ } else if (!strcmp(action, "query")) {
+ FCGI_BeginJSON(context, STATUS_OK);
+ FCGI_JSONPair("state", Control_GetModeName(Control_GetMode()));
+ FCGI_EndJSON();
+ return;
+ } else if (FCGI_HasControl(context, key)) {
+ if (!strcmp(action, "release")) {
+ FCGI_ReleaseControl(context);
+ } else if (!strcmp(action, "start")) {
+ desired_mode = CONTROL_START;
+ } else if (!strcmp(action, "pause")) {
+ desired_mode = CONTROL_PAUSE;
+ } else if (!strcmp(action, "resume")) {
+ desired_mode = CONTROL_RESUME;
+ } else if (!strcmp(action, "stop")) {
+ desired_mode = CONTROL_STOP;
+ } else {
+ FCGI_RejectJSON(context, "Unknown action specified.");
+ return;