From: Sam Moore Date: Fri, 13 Sep 2013 13:47:02 +0000 (+0800) Subject: Merge branch 'master' of github:szmoore/MCTX3420 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=81531e1d969957d5757887f1646d26093af96ff1;p=matches%2FMCTX3420.git Merge branch 'master' of github:szmoore/MCTX3420 Conflicts: server/data.c server/sensor.c It's pretty scary how much got automatically merged. Almost as if git is sentient. --- 81531e1d969957d5757887f1646d26093af96ff1 diff --cc server/data.c index 8bfd8b1,c4d7b58..add8d9f --- a/server/data.c +++ b/server/data.c @@@ -14,9 -14,7 +14,8 @@@ void Data_Init(DataFile * df { // Everything is NULL df->filename = NULL; - df->read_file = NULL; - df->write_file = NULL; + pthread_mutex_init(&(df->mutex), NULL); + df->file = NULL; } /** diff --cc server/sensor.c index 55a9eaa,5d61858..b065708 --- a/server/sensor.c +++ b/server/sensor.c @@@ -300,17 -314,29 +313,16 @@@ void Sensor_Handler(FCGIContext *contex // Error occured; FCGI_RejectJSON already called return; } - else if (id < 0 || id >= NUMSENSORS) + - + // Error checking on sensor id + if (id < 0 || id >= NUMSENSORS) { - FCGI_RejectJSON(context, "Invalid sensor id specified"); + FCGI_RejectJSON(context, "Invalid sensor id"); return; } - - // Get Sensor and format Sensor * s = g_sensors+id; - DataFormat format = JSON; - - // Check if format type was specified - if (FCGI_RECEIVED(values[FORMAT].flags)) - { - if (strcmp(fmt_str, "json") == 0) - format = JSON; - else if (strcmp(fmt_str, "tsv") == 0) - format = TSV; - else - { - FCGI_RejectJSON(context, "Unknown format type specified."); - return; - } - } + + DataFormat format = Data_GetFormat(&(values[FORMAT])); // Begin response Sensor_BeginResponse(context, id, format);