qDecoder Header file
Data Structures | |
struct | qentry_s |
struct | qentobj_s |
Defines | |
#define | _Q_PRGNAME "qdecoder" |
#define | _Q_VERSION "12.0.2" |
Typedefs | |
typedef struct qentry_s | qentry_t |
typedef struct qentobj_s | qentobj_t |
Enumerations | |
enum | Q_CGI_T { Q_CGI_ALL = 0, Q_CGI_COOKIE = 0x01, Q_CGI_POST = 0x02, Q_CGI_GET = 0x04 } |
Functions | |
qentry_t * | qcgireq_setoption (qentry_t *request, bool filemode, const char *basepath, int clearold) |
Set request parsing option for file uploading in case of multipart/form-data encoding. | |
qentry_t * | qcgireq_parse (qentry_t *request, Q_CGI_T method) |
Parse one or more request(COOKIE/POST/GET) queries. | |
char * | qcgireq_getquery (Q_CGI_T method) |
Get raw query string. | |
bool | qcgires_setcookie (qentry_t *request, const char *name, const char *value, int expire, const char *path, const char *domain, bool secure) |
Set cookie. | |
bool | qcgires_removecookie (qentry_t *request, const char *name, const char *path, const char *domain, bool secure) |
Remove cookie. | |
bool | qcgires_setcontenttype (qentry_t *request, const char *mimetype) |
Set responding content-type. | |
const char * | qcgires_getcontenttype (qentry_t *request) |
Get content-type. | |
bool | qcgires_redirect (qentry_t *request, const char *uri) |
Send redirection header. | |
int | qcgires_download (qentry_t *request, const char *filepath, const char *mimetype) |
Force to send(download) file to client in accordance with given mime type. | |
void | qcgires_error (qentry_t *request, char *format,...) |
Print out HTML error page and exit program. | |
qentry_t * | qcgisess_init (qentry_t *request, const char *dirpath) |
Initialize session. | |
bool | qcgisess_settimeout (qentry_t *session, time_t seconds) |
Set the auto-expiration seconds about user session. | |
const char * | qcgisess_getid (qentry_t *session) |
Get user session id. | |
time_t | qcgisess_getcreated (qentry_t *session) |
Get user session created time. | |
bool | qcgisess_save (qentry_t *session) |
Update session data. | |
bool | qcgisess_destroy (qentry_t *session) |
Destroy user session. | |
qentry_t * | qEntry (void) |
Create new qentry_t linked-list object. |
qentry_t* qcgireq_setoption | ( | qentry_t * | request, | |
bool | filemode, | |||
const char * | basepath, | |||
int | clearold | |||
) |
Set request parsing option for file uploading in case of multipart/form-data encoding.
request | qentry_t container pointer that options will be set. NULL can be used to create a new container. | |
filemode | false for parsing in memory, true for storing attached files into file-system directly. | |
basepath | the base path where the uploaded files are located. Set to NULL if filemode is false. | |
clearold | saved files older than this seconds will be removed automatically. Set to 0 to disable. |
qentry_t *req = qcgireq_setoption(NULL, true, "/tmp", 86400); req = qcgireq_parse(req, 0); req->free(req);
Parse one or more request(COOKIE/POST/GET) queries.
request | qentry_t container pointer that parsed key/value pairs will be stored. NULL can be used to create a new container. | |
method | Target mask consists of one or more of Q_CGI_COOKIE, Q_CGI_POST and Q_CGI_GET. Q_CGI_ALL or 0 can be used for parsing all of those types. |
qentry_t *req = qcgireq_parse(NULL, 0);
qentry_t *req = qcgireq_parse(req, Q_CGI_COOKIE | Q_CGI_POST);
char* qcgireq_getquery | ( | Q_CGI_T | method | ) |
Get raw query string.
method | One of Q_CGI_COOKIE, Q_CGI_POST or Q_CGI_GET. |
char *query = qcgireq_getquery(Q_CGI_GET); if(query != NULL) { printf("%s\n", query); free(query); }
bool qcgires_setcookie | ( | qentry_t * | request, | |
const char * | name, | |||
const char * | value, | |||
int | expire, | |||
const char * | path, | |||
const char * | domain, | |||
bool | secure | |||
) |
Set cookie.
request | a pointer of request structure | |
name | cookie name | |
value | cookie value | |
expire | expire related time in seconds (0 means end of session) | |
path | cookie path (NULL can current path) | |
domain | cookie domain (NULL means current domain) | |
secure | secure flag |
// Apply cookie in the current domain and directory for 1 day. qcgires_setcookie(req, "NAME", "qDecoder", 86400, NULL, NULL, false); // Apply cookie to the "/" directory of "*.qdecoder.org" until the // browser is closed. qcgires_setcookie(req, name, value, 0, "/", ".qdecoder.org", false); // As for the followings, cookies will be set up only when security // requirements are satisfied. qcgires_setcookie(req, name, value, 0, NULL, NULL, true);
bool qcgires_removecookie | ( | qentry_t * | request, | |
const char * | name, | |||
const char * | path, | |||
const char * | domain, | |||
bool | secure | |||
) |
Remove cookie.
request | a pointer of request structure | |
name | cookie name | |
path | cookie path | |
domain | cookie domain | |
secure | secure flag |
qcgires_setcookie(req, "NAME", "VALUE", 0, NULL, NULL, NULL); qcgires_removecookie(req, "NAME", NULL, NULL, NULL); qcgires_setcookie(req, "NAME", "VALUE", 0, "/", "www.qdecoder.org", NULL); qcgires_removecookie(req, "NAME", "/", "www.qdecoder.org", NULL);
bool qcgires_setcontenttype | ( | qentry_t * | request, | |
const char * | mimetype | |||
) |
Set responding content-type.
request | a pointer of request structure | |
mimetype | mimetype |
qcgires_setcontenttype(req, "text/html");
const char* qcgires_getcontenttype | ( | qentry_t * | request | ) |
Get content-type.
request | a pointer of request structure |
qcgires_setcontenttype(req, "text/html");
bool qcgires_redirect | ( | qentry_t * | request, | |
const char * | uri | |||
) |
Send redirection header.
request | a pointer of request structure | |
uri | new URI |
qcgires_redirect(req, "http://www.qdecoder.org/");
int qcgires_download | ( | qentry_t * | request, | |
const char * | filepath, | |||
const char * | mimetype | |||
) |
Force to send(download) file to client in accordance with given mime type.
request | a pointer of request structure | |
filepath | file to send | |
mimetype | mimetype. NULL can be used for "application/octet-stream". |
void qcgires_error | ( | qentry_t * | request, | |
char * | format, | |||
... | ||||
) |
Print out HTML error page and exit program.
request | a pointer of request structure | |
format | error message |
qcgires_error(req, "Error: can't find userid.");
Initialize session.
request | a pointer of request structure returned by qcgireq_parse() | |
dirpath | directory path where session data will be kept |
bool qcgisess_settimeout | ( | qentry_t * | session, | |
time_t | seconds | |||
) |
Set the auto-expiration seconds about user session.
session | a pointer of session structure | |
seconds | expiration seconds |
const char* qcgisess_getid | ( | qentry_t * | session | ) |
Get user session id.
session | a pointer of session structure |
time_t qcgisess_getcreated | ( | qentry_t * | session | ) |
Get user session created time.
session | a pointer of session structure |
bool qcgisess_save | ( | qentry_t * | session | ) |
Update session data.
session | a pointer of session structure |
bool qcgisess_destroy | ( | qentry_t * | session | ) |
Destroy user session.
session | a pointer of session structure |