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