+ struct dirent * ent;
+ FCGI_BeginJSON(context, STATUS_OK);
+ FCGI_JSONKey("experiments");
+ FCGI_PrintRaw("[");
+
+ bool first = true;
+ while ((ent = readdir(dir)) != NULL)
+ {
+ char * c;
+ for (c = ent->d_name; *c != '\0' && *c != '.'; ++c);
+
+ if (*c != '\0' && strcmp(c, ".exp") == 0)
+ {
+ if (!first)
+ FCGI_PrintRaw(",");
+ *c = '\0'; // Ummm... probably not a great idea
+ FCGI_PrintRaw(ent->d_name);
+ first = false;
+ }
+ }
+ FCGI_PrintRaw("]");
+ FCGI_EndJSON();
+
+ return; // Dear god this is terrible
+ }
+ //TODO: Need a "load" action to set data files (but not run) from a past experiment
+
+ //TODO: Need a "delete" action so that people can overwrite experiments (without all this "force" shenanigans)
+
+ if (!strcmp(action, "emergency")) {
+ desired_mode = CONTROL_EMERGENCY;
+ } 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;