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_INT_T (1 << 3)
27 #define FCGI_LONG_T (1 << 4)
28 #define FCGI_DOUBLE_T (1 << 5)
29 #define FCGI_STRING_T (1 << 6)
30 #define FCGI_REQUIRED(x) ((x) | FCGI_PARAM_REQUIRED)
31 #define FCGI_IS_REQUIRED(x) ((x) & FCGI_PARAM_REQUIRED)
32 #define FCGI_RECEIVED(x) ((x) & FCGI_PARAM_RECEIVED)
33 #define FCGI_TYPE(x) ((x) & ~(FCGI_PARAM_REQUIRED | FCGI_PARAM_RECEIVED))
35 typedef struct FCGIValue {
41 typedef struct FCGIContext FCGIContext;
42 typedef void (*ModuleHandler) (FCGIContext *context, char *params);
44 extern void FCGI_BeginControl(FCGIContext *context, bool force);
45 extern void FCGI_EndControl(FCGIContext *context);
46 extern bool FCGI_HasControl(FCGIContext *context, const char *key);
47 extern char *FCGI_KeyPair(char *in, const char **key, const char **value);
48 extern bool FCGI_ParseRequest(FCGIContext *context, char *params, FCGIValue values[], size_t count);
49 extern void FCGI_BeginJSON(FCGIContext *context, StatusCodes status_code);
50 extern void FCGI_JSONPair(const char *key, const char *value);
51 extern void FCGI_JSONLong(const char *key, long value);
52 extern void FCGI_JSONDouble(const char *key, double value);
53 extern void FCGI_JSONBool(const char *key, bool value);
54 extern void FCGI_JSONKey(const char *key);
55 extern void FCGI_PrintRaw(const char *format, ...);
56 extern void FCGI_EndJSON();
57 extern char *FCGI_EscapeJSON(char *buf);
58 extern void FCGI_RejectJSONEx(FCGIContext *context, StatusCodes status, const char *description);
59 extern void *FCGI_RequestLoop (void *data);
61 extern void FCGI_WriteBinary(void * data, size_t size, size_t num_elem);
64 * Shortcut to calling FCGI_RejectJSONEx. Sets the error code
66 * @param context The context to work in
67 * @param description A short description of why the request was rejected.
68 * @see FCGI_RejectJSONEx
70 #define FCGI_RejectJSON(context, description) FCGI_RejectJSONEx(context, STATUS_ERROR, description)
73 * Custom formatting function for the JSON value. To be used in
74 * conjunction with FCGI_JSONKey. Care should be taken to ensure
75 * that valid JSON is produced.
76 * @see FCGI_PrintRaw for calling syntax
78 #define FCGI_JSONValue FCGI_PrintRaw