#include "actuator.h"
#include "control.h"
#include "options.h"
+ #include "image.h"
-/**The time period (in seconds) before the control key expires @ */
+/**The time period (in seconds) before the control key expires */
#define CONTROL_TIMEOUT 180
/**Contextual information related to FCGI requests*/
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);
+ }
+
+/**
+ * Escapes a string so it can be used safely.
+ * Currently escapes to ensure the validity for use as a JSON string
+ * Does not support unicode specifiers in the form of \uXXXX.
+ * @param buf The string to be escaped
+ * @return The escaped string (return value == buf)
+ */
+char *FCGI_EscapeText(char *buf)
+{
+ int length, i;
+ length = strlen(buf);
+
+ //Escape special characters. Must count down to escape properly
+ for (i = length - 1; i >= 0; i--) {
+ if (buf[i] < 0x20) { //Control characters
+ buf[i] = ' ';
+ } else if (buf[i] == '"') {
+ if (i-1 >= 0 && buf[i-1] == '\\')
+ i--;
+ else
+ buf[i] = '\'';
+ } else if (buf[i] == '\\') {
+ if (i-1 >= 0 && buf[i-1] == '\'')
+ i--;
+ else
+ buf[i] = ' ';
+ }
+ }
+ return buf;
+}
+
/**
* Main FCGI request loop that receives/responds to client requests.
* @param data Reserved.
extern void FCGI_JSONKey(const char *key);
extern void FCGI_PrintRaw(const char *format, ...);
extern void FCGI_EndJSON();
-extern char *FCGI_EscapeJSON(char *buf);
extern void FCGI_RejectJSONEx(FCGIContext *context, StatusCodes status, const char *description);
+extern char *FCGI_EscapeText(char *buf);
extern void *FCGI_RequestLoop (void *data);
+ extern void FCGI_WriteBinary(void * data, size_t size, size_t num_elem);
+
/**
* Shortcut to calling FCGI_RejectJSONEx. Sets the error code
* to STATUS_ERROR.