/** The same as INVALID_CHARACTERS, except escaped for use in JSON strings **/
#define INVALID_CHARACTERS_JSON "\\\"*/:<>?\\\\|. "
+#define NOAUTH_USERNAME "_anonymous_noauth"
+
extern void Control_Handler(FCGIContext *context, char *params);
extern const char* Control_SetMode(ControlModes desired_mode, void * arg);
extern ControlModes Control_GetMode();
FCGI_BeginJSON(context, STATUS_OK);
FCGI_JSONPair("description", "MCTX3420 Server API (2013)");
FCGI_JSONPair("build_date", __DATE__ " " __TIME__);
- struct timespec t;
- t.tv_sec = 0; t.tv_nsec = 0;
+ struct timespec t = {0};
clock_getres(CLOCK_MONOTONIC, &t);
FCGI_JSONDouble("clock_getres", TIMEVAL_TO_DOUBLE(t));
FCGI_JSONLong("api_version", API_VERSION);
if (module_handler)
{
- if (g_options.auth_method != AUTH_NONE && module_handler != Login_Handler && module_handler != IdentifyHandler && module_handler)
+ if (module_handler != Login_Handler && module_handler != IdentifyHandler && module_handler)
//if (false) // Testing
{
if (!FCGI_HasControl(&context))
{
- FCGI_RejectJSON(&context, "Please login. Invalid control key.");
- continue;
+ if (g_options.auth_method == AUTH_NONE)
+ { //:(
+ Log(LOGWARN, "Locking control (no auth!)");
+ FCGI_LockControl(&context, NOAUTH_USERNAME, USER_ADMIN);
+ }
+ else
+ {
+ FCGI_RejectJSON(&context, "Please login. Invalid control key.");
+ continue;
+ }
}
//Escape all special characters.
// Try and start things
- const char *ret;
- if ((ret = Control_SetMode(CONTROL_START, "test")) != NULL)
- Fatal("Control_SetMode failed with '%s'", ret);
+ //const char *ret;
+ //if ((ret = Control_SetMode(CONTROL_START, "test")) != NULL)
+ // Fatal("Control_SetMode failed with '%s'", ret);
// run request thread in the main thread
FCGI_RequestLoop(NULL);
- if ((ret = Control_SetMode(CONTROL_STOP, "test")) != NULL)
- Fatal("Control_SetMode failed with '%s'", ret);
+ Conrol_SetMode(CONTROL_STOP, NULL);
+ //if ((ret = Control_SetMode(CONTROL_STOP, "test")) != NULL)
+ // Fatal("Control_SetMode failed with '%s'", ret);
//Sensor_StopAll();
//Actuator_StopAll();