Merge branch 'master' of https://github.com/szmoore/MCTX3420.git
[matches/MCTX3420.git] / server / fastcgi.h
1 /**
2  * @file fastcgi.h
3  * @brief Headers for the fastcgi web interface
4  */
5  
6 #ifndef _FASTCGI_H
7 #define _FASTCGI_H
8  
9 /**
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
15  */
16 typedef enum StatusCodes {
17         STATUS_OK = 1,
18         STATUS_ERROR = -1,
19         STATUS_UNAUTHORIZED = -2
20 } StatusCodes;
21
22 typedef struct FCGIContext FCGIContext;
23 typedef void (*ModuleHandler) (FCGIContext *context, char *params);
24
25 extern void FCGI_BeginControl(FCGIContext *context, bool force);
26 extern void FCGI_EndControl(FCGIContext *context);
27 extern bool FCGI_HasControl(FCGIContext *context, const char *key);
28 extern char *FCGI_KeyPair(char *in, const char **key, const char **value);
29 extern void FCGI_BeginJSON(FCGIContext *context, StatusCodes status_code);
30 extern void FCGI_JSONPair(const char *key, const char *value);
31 extern void FCGI_JSONLong(const char *key, long value);
32 extern void FCGI_JSONDouble(const char *key, double value);
33 extern void FCGI_JSONBool(const char *key, bool value);
34 extern void FCGI_JSONKey(const char *key);
35 extern void FCGI_PrintRaw(const char *format, ...);
36 extern void FCGI_EndJSON();
37 extern void FCGI_RejectJSON(FCGIContext *context);
38 extern void FCGI_RejectJSONEx(FCGIContext *context, StatusCodes status, const char *description);
39 extern void * FCGI_RequestLoop (void *data);
40
41 /**
42  * Custom formatting function for the JSON value. To be used in 
43  * conjunction with FCGI_JSONKey. Care should be taken to ensure
44  * that valid JSON is produced.
45  * 
46  * @see FCGI_PrintRaw for calling syntax
47  */
48 #define FCGI_JSONValue FCGI_PrintRaw
49
50 #endif
51
52

UCC git Repository :: git.ucc.asn.au