IMPORT CHANGES : From the version of 11, qDecoder only has CGI-related features and all containers(data-structures) and other APIs has moved to qLibc project.
All of the deliverable code in qDecoder has been dedicated to the public domain by the authors. Anyone is free to copy, modify, publish, use, compile, sell, or distribute the original qDecoder code, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.
All of the deliverable code in qDecoder has been written from scratch. No code has been taken from other projects or from the open internet. Every line of code can be traced back to its original author. So the qDecoder code base is clean and is not contaminated with licensed code from any other projects.
qDecoder has been developed and tested under below platforms..
Parsed elements are stored in Q_ENTRY linked-list structure.
[HTML sample] <form action="your_program.cgi"> <input type="text" name="color"> <input type="submit"> </form> [Your Code] qentry_t *req = qcgireq_parse(NULL, 0); qcgires_setcontenttype(req, "text/plain"); const char *color = req->getstr(req, "color", false); if (color != NULL) { printf("color = %s\n", color); } req->free(req);
The order of parsing sequence is (1)COOKIE (2)POST (3)GET. Thus if there is a same query name existing in different methods, COOKIE values will be stored first than POST, GET values will be added at the very last into a qentry linked-list.
Below is an example to parse only two given methods. Please note that when multiple methods are specified, it'll be parsed in the order of COOKIE, POST and GET.
qentry_t *req = qcgireq_parse(req, Q_CGI_COOKIE | Q_CGI_POST);
To change the order of parsing sequence, you can call qcgireq_parse() multiple times in the order that you want as below.
qentry_t *req; req = qcgireq_parse(req, Q_CGI_POST); req = qcgireq_parse(req, Q_CGI_GET); req = qcgireq_parse(req, Q_CGI_COOKIE);
In terms of multipart/form-data encoding(used for file uploading), qDecoder can handle that in two different ways internally.
You can switch to file mode by calling qCgiRequestSetOption().
Q_ENTRY *req = qcgireq_setoption(NULL, true, "/tmp", 86400); req = qcgireq_parse(req, 0); // ...your codes here... req->free(req);
Basically, when file is uploaded qDecoder store it's meta information like below.
[default mode example] binary = (...binary data...) binary.filename = hello.xls binary.length = 3292 binary.contenttype = application/vnd.ms-excel [file mode example] binary = tmp/q_wcktIq binary.length = 60014 binary.filename = hello.xls binary.contenttype = application/vnd.ms-excel binary.savepath = tmp/q_wcktIq
Please refer the examples included in the source package for more detailed samples.