This is the main file of xhttp_rpc module which contains all the functions related to http processing, as well as the module interface.
This module provides a web interface for RPC management interface. It is built on top of the xhttp API module.
| static int init_xhttp_rpc_reply | ( | rpc_ctx_t * | ctx | ) | [static] |
This function initializes the data structure that contains all data related to the xhttp_rpc reply being created. The function must be called before any other function that adds data to the reply.
| ctx | rpc_ctx_t structure to be initialized. |
Definition at line 194 of file xhttp_rpc.c.
References xhttp_rpc_reply::body, xhttp_rpc_reply::buf, xhttp_rpc_reply::code, _str::len, xhttp_rpc_reply::reason, rpc_ctx::reply, rpc_fault(), and _str::s.

This function takes the parameters provided in ap parameter and creates HTML formatted parameters that will be put in the html document. The format of input parameters is described in formatting string fmt which follows the syntax of the management API. In the case of an error the function will generate an error reply in err_reply parameter instead.
| ctx | An error reply document will be generated here if the function encounters a problem while processing input parameters. | |
| fmt | Formatting string of the management API. | |
| ap | A pointer to the array of input parameters. |
Definition at line 281 of file xhttp_rpc.c.
References xhttp_rpc_reply::body, xhttp_rpc_reply::buf, _str::len, rpc_fault(), _str::s, and sint2str().
Referenced by rpc_add(), and rpc_struct_add().


| static int rpc_add | ( | rpc_ctx_t * | ctx, | |
| char * | fmt, | |||
| ... | ||||
| ) | [static] |
This function will be called when an RPC management function calls rpc->add to add a parameter to the xhttp_rpc reply being generated.
Definition at line 345 of file xhttp_rpc.c.
References print_value(), and rpc_fault().

| static void rpc_delayed_ctx_close | ( | struct rpc_delayed_ctx * | dctx | ) | [static] |
If no reply has been sent the reply will be built and sent automatically. See the notes from rpc_new_delayed_ctx()
Definition at line 612 of file xhttp_rpc.c.
| static struct rpc_delayed_ctx* rpc_delayed_ctx_new | ( | rpc_ctx_t * | ctx | ) | [static, read] |
Creates a new delayed reply context in shm and returns it.
Definition at line 602 of file xhttp_rpc.c.
| static void rpc_fault | ( | rpc_ctx_t * | ctx, | |
| int | code, | |||
| char * | fmt, | |||
| ... | ||||
| ) | [static] |
This function will be called whenever a management function indicates that an error ocurred while it was processing the request. The function takes the reply code and reason phrase as parameters, these will be put in the body of the reply.
| ctx | A pointer to the context structure of the request being processed. | |
| code | Reason code. | |
| fmt | Formatting string used to build the reason phrase. |
Definition at line 130 of file xhttp_rpc.c.
References xhttp_rpc_reply::body, xhttp_rpc_reply::code, _str::len, xhttp_rpc_reply::reason, rpc_ctx::reply, and _str::s.
Referenced by init_xhttp_rpc_reply(), print_value(), rpc_add(), rpc_printf(), rpc_scan(), and rpc_send().

| static int rpc_printf | ( | rpc_ctx_t * | ctx, | |
| char * | fmt, | |||
| ... | ||||
| ) | [static] |
This function will be called whenever an RPC management function calls rpc-printf to add a parameter to the xhttp_rpc reply being constructed.
Definition at line 475 of file xhttp_rpc.c.
References xhttp_rpc_reply::body, xhttp_rpc_reply::buf, _str::len, rpc_ctx::reply, rpc_fault(), and _str::s.

| static int rpc_scan | ( | rpc_ctx_t * | ctx, | |
| char * | fmt, | |||
| ... | ||||
| ) | [static] |
This is the function that will be called whenever a management function calls rpc->scan to get the value of parameter from the xhttp_rpc request. This function will extract the current parameter from the xhttp_rpc URL and attempts to convert it to the type requested by the management function that called it.
Definition at line 385 of file xhttp_rpc.c.
References _str::len, rpc_fault(), and _str::s.

| static int rpc_send | ( | rpc_ctx_t * | ctx | ) | [static] |
This is the function that will be called whenever a management function asks the management interface to send the reply to the client. The SIP/HTTP reply sent to the client will be always 200 OK, if an error ocurred on the server then it will be indicated in the html document in body.
| ctx | A pointer to the context structure of the xhttp_rpc request that generated the reply. |
Definition at line 226 of file xhttp_rpc.c.
References rpc_ctx::arg, xhttp_rpc_reply::body, xhttp_rpc_reply::buf, xhttp_rpc_reply::code, _str::len, rpc_ctx::msg, xhttp_rpc_reply::reason, rpc_ctx::reply, rpc_ctx::reply_sent, rpc_fault(), and _str::s.

This is a global variable that records the context of the xhttp_rpc request being currently processed.
Definition at line 77 of file xhttp_rpc.c.
1.7.1