3 * @brief Headers for the fastcgi web interface
10 * Status codes that fcgi module handlers can return
11 * Success status codes have values > 0
12 * Failure status codes have values <(=) 0
13 * Note: 0 is counted as an error code to minimise confusion
14 * with in-browser JSON parsing error codes
16 typedef enum StatusCodes {
19 STATUS_UNAUTHORIZED = -2,
20 STATUS_OUTOFRANGE = -3
23 #define FCGI_PARAM_REQUIRED (1 << 0)
24 #define FCGI_PARAM_RECEIVED (1 << 1)
25 #define FCGI_BOOL_T (1 << 2)
26 #define FCGI_LONG_T (1 << 3)
27 #define FCGI_DOUBLE_T (1 << 4)
28 #define FCGI_STRING_T (1 << 5)
29 #define FCGI_REQUIRED(x) ((x) | FCGI_PARAM_REQUIRED)
30 #define FCGI_IS_REQUIRED(x) ((x) & FCGI_PARAM_REQUIRED)
31 #define FCGI_RECEIVED(x) ((x) & FCGI_PARAM_RECEIVED)
32 #define FCGI_TYPE(x) ((x) & ~(FCGI_PARAM_REQUIRED | FCGI_PARAM_RECEIVED))
34 typedef struct FCGIValue {
40 typedef struct FCGIContext FCGIContext;
41 typedef void (*ModuleHandler) (FCGIContext *context, char *params);
43 extern void FCGI_BeginControl(FCGIContext *context, bool force);
44 extern void FCGI_EndControl(FCGIContext *context);
45 extern bool FCGI_HasControl(FCGIContext *context, const char *key);
46 extern char *FCGI_KeyPair(char *in, const char **key, const char **value);
47 extern bool FCGI_ParseRequest(FCGIContext *context, char *params, FCGIValue values[], size_t count);
48 extern void FCGI_BeginJSON(FCGIContext *context, StatusCodes status_code);
49 extern void FCGI_JSONPair(const char *key, const char *value);
50 extern void FCGI_JSONLong(const char *key, long value);
51 extern void FCGI_JSONDouble(const char *key, double value);
52 extern void FCGI_JSONBool(const char *key, bool value);
53 extern void FCGI_JSONKey(const char *key);
54 extern void FCGI_PrintRaw(const char *format, ...);
55 extern void FCGI_EndJSON();
56 extern char *FCGI_EscapeJSON(char *buf);
57 extern void FCGI_RejectJSONEx(FCGIContext *context, StatusCodes status, const char *description);
58 extern void *FCGI_RequestLoop (void *data);
61 * Shortcut to calling FCGI_RejectJSONEx. Sets the error code
63 * @param context The context to work in
64 * @param description A short description of why the request was rejected.
65 * @see FCGI_RejectJSONEx
67 #define FCGI_RejectJSON(context, description) FCGI_RejectJSONEx(context, STATUS_ERROR, description)
70 * Custom formatting function for the JSON value. To be used in
71 * conjunction with FCGI_JSONKey. Care should be taken to ensure
72 * that valid JSON is produced.
73 * @see FCGI_PrintRaw for calling syntax
75 #define FCGI_JSONValue FCGI_PrintRaw