X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=server%2Ffastcgi.c;h=62978eabf2cfc12339a4ae2ac6de656cf1bd5c3a;hb=851c1d78e4530ecaac3aca9d39b19932d8607431;hp=b58ba79ba545c8b7e3f3b168eac95dccf8507ae1;hpb=d0f77e15cfa58191a7683caf343037c25be9f31c;p=matches%2FMCTX3420.git diff --git a/server/fastcgi.c b/server/fastcgi.c index b58ba79..62978ea 100644 --- a/server/fastcgi.c +++ b/server/fastcgi.c @@ -12,8 +12,10 @@ #include "common.h" #include "sensor.h" +#include "actuator.h" #include "control.h" #include "options.h" +#include "image.h" /**The time period (in seconds) before the control key expires @ */ #define CONTROL_TIMEOUT 180 @@ -237,14 +239,19 @@ bool FCGI_ParseRequest(FCGIContext *context, char *params, FCGIValue values[], s case FCGI_BOOL_T: *((bool*) val->value) = true; break; - case FCGI_LONG_T: - *((long*) val->value) = strtol(value, &ptr, 10); + case FCGI_INT_T: case FCGI_LONG_T: { + long parsed = strtol(value, &ptr, 10); if (!*value || *ptr) { snprintf(buf, BUFSIZ, "Expected int for '%s' but got '%s'", key, value); FCGI_RejectJSON(context, FCGI_EscapeJSON(buf)); return false; } - break; + + if (FCGI_TYPE(val->flags) == FCGI_INT_T) + *((int*) val->value) = parsed; + else + *((long*) val->value) = parsed; + } break; case FCGI_DOUBLE_T: *((double*) val->value) = strtod(value, &ptr); if (!*value || *ptr) { @@ -427,6 +434,17 @@ void FCGI_PrintRaw(const char *format, ...) va_end(list); } + +/** + * Write binary data + * See fwrite + */ +void FCGI_WriteBinary(void * data, size_t size, size_t num_elem) +{ + Log(LOGDEBUG,"Writing!"); + fwrite(data, size, num_elem, stdout); +} + /** * Main FCGI request loop that receives/responds to client requests. * @param data Reserved. @@ -439,8 +457,6 @@ void * FCGI_RequestLoop (void *data) Log(LOGDEBUG, "First request..."); while (FCGI_Accept() >= 0) { - - Log(LOGDEBUG, "Got request #%d", context.response_number); ModuleHandler module_handler = NULL; char module[BUFSIZ], params[BUFSIZ]; @@ -464,6 +480,10 @@ void * FCGI_RequestLoop (void *data) module_handler = Control_Handler; } else if (!strcmp("sensors", module)) { module_handler = Sensor_Handler; + } else if (!strcmp("actuators", module)) { + module_handler = Actuator_Handler; + } else if (!strcmp("image", module)) { + module_handler = Image_Handler; } context.current_module = module;