- char *ptr;
- int id = ACT_NONE;
-
- while ((params = FCGI_KeyPair(params, &key, &value))) {
- if (!strcmp(key, "action"))
- action = value;
- else if (!strcmp(key, "key"))
- control_key = value;
- else if (!strcmp(key, "force"))
- force = !force;
- else if (!strcmp(key, "id") && *value) { //Ensure non-empty value
- int parsed = strtol(value, &ptr, 10);
- if (*ptr == '\0') {
- id = parsed;
- }
- } else if (!strcmp(key, "value")) {
- set_value = value;
- }
- }
-
- if (action == NULL) { //Must have an action
- FCGI_RejectJSON(context);
- } else if (!strcmp(action, "start")) {
+
+ FCGIValue values[5] = {
+ {"action", &action, FCGI_REQUIRED(FCGI_STRING_T)},
+ {"key", &key, FCGI_STRING_T},
+ {"force", &force, FCGI_BOOL_T},
+ {"mode", &mode, FCGI_STRING_T},
+ {"name", &name, FCGI_STRING_T}
+ };
+
+ if (!FCGI_ParseRequest(context, params, values, 5))
+ return;
+
+ if (!strcmp(action, "gain")) {