This program could be build in two ways :
pbufs,
netconn functions and friends are implemented with UNIX sockets. All data processing is done
with lwip functions for pbuf processing. The ported lwip stack is located at pseudo-lwip/.
The building process is handled by the makefile (make noos [-B]).| File | Description |
|---|---|
| generic-json-zero-copy.c, generic-json-zero-copy.h | Callback based json parser. |
| http_server.c http_server.h | Server main function. |
| http-utils.c http-utils.h | HTTP utilities used by the project |
| json_decode.c | Test program for json parser, might be broken. (Not used by the server) |
| low-level-api.c, low-level-api.h | Low level API used by the server for memory and register i/o. |
| macros.h | Macroses used by the HTTP server. |
| makefile | Makefile. |
| network-stack.h | Header made to allow smooth pseudo-lwip to lwip transition. |
| noOS.c | Linux port of the server. |
| post_methods.c, post_methods.h | Methods called by the server on POST requests. |
| pseudo-lwip/ | Pseudo-lwip (linux port). |
| wp.h | The web page |
JSON_ERRORS : should be defined if various errors should be printed by the parser.
Uses fprintf or an error macro if defined.JSONX_LWIP : if defined the parser is configured for ntbuf parsing.
Should be always defined for correct functioning of the parser. make jsonvoid handle_request(struct netconn *netconn)
some header parser utilities and the server_start(), server_stop() functions.MAX_URL_LEN : the maximum length of a URL specified to the server.
Example: 196.254.44.44/URL - the length of URL should be less then MAX_URL_LEN.NETCONN_PRINTF_BUF : the size of the buffer of netconn_printf. Should not be huge, because used many times to send small amounts of data.---[POST request to /api/2]---------------------\
|
+---------------------------+ |
| post request lookup table | |
| | |
| (method_index: 1)[] | |
/--|---<-(method_index: 2)[]<--|--------/
| | (method_index: 3)[] |
| | ..... |
| | |
| +---------------------------+
|
V
[API->take()] ----------(if error)----------> [return error to client]
| ^
| |
V |
method([request body]) |
{ send data to the user } -----------------------------/
|
|
|
V
[API->release()]
A POST request is done to /api/2, the second method is looked up in the request lookup table.
Then API->take() it is run, then the needed method is run passing it the POST body.
In the end API->release() is run. More in API->release() and API->take() could be found here
tools/f2h, it contains a gzipped web page.DEBUG : if defined, then print functions actually print something, otherwise they are defied as dummies.STRICT : if this macro is defined, then the program is compiled to use strict lwip.
Otherwise it is compiled as a port to Linux.| File |
|---|
| api.h |
| api_lib.c |
| netbuf.c |
| netbuf.h |
| pbuf.c |
| pbuf.h |