- switch(mode) {
- case START:
- if (!*name) {
- FCGI_RejectJSON(context, "An experiment name must be provided");
- } else if (ExperimentExists(name) && !force) {
- FCGI_RejectJSONEx(context, STATUS_ALREADYEXISTS,
- "An experiment with the specified name already exists.");
- } else if (!Control_Start(name)) {
- FCGI_RejectJSON(context, "An experiment is already running.");
- } else {
- FCGI_BeginJSON(context, STATUS_OK);
- FCGI_EndJSON();
- }
- break;
- case PAUSE:
- if (!Control_Pause()) {
- FCGI_RejectJSON(context, "No experiment to pause.");
- } else {
- FCGI_BeginJSON(context, STATUS_OK);
- FCGI_EndJSON();
- }
- break;
- case RESUME:
- if (!Control_Resume()) {
- FCGI_RejectJSON(context, "No experiment to resume.");
- } else {
- FCGI_BeginJSON(context, STATUS_OK);
- FCGI_EndJSON();
- }
- break;
- case STOP:
- if (!Control_Stop()) {
- FCGI_RejectJSON(context, "No experiment to stop.");
- } else {
- FCGI_BeginJSON(context, STATUS_OK);
- FCGI_EndJSON();
- }
- break;
- }
-}
+ void *arg = NULL;
+ if (desired_mode == CONTROL_START) {
+ int len = strlen(name);
+ if (len <= 0) {
+ FCGI_RejectJSON(context, "An experiment name must be specified.");
+ return;
+ } else if (PathExists(name) && !force) {
+ FCGI_RejectJSON(context, "An experiment with that name already exists.");
+ return;
+ }