Files | Functions | Variables

Xhttp_rpc

Files

Functions

Variables


Detailed Description

Overview of Operation

This module provides a web interface for RPC management interface. It is built on top of the xhttp API module.


Function Documentation

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.

Parameters:
ctx rpc_ctx_t structure to be initialized.
Returns:
0 on success, a negative number on error.

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.

Here is the call graph for this function:

static int print_value ( rpc_ctx_t ctx,
char  fmt,
va_list *  ap,
str id 
) [static]

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.

Parameters:
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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

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.

Returns:
0 - not supported, already replied, or no more memory; !=0 pointer to the special delayed ctx. Note1: one should use the returned ctx reply context to build a reply and when finished call rpc_delayed_ctx_close(). Note2: adding pieces to the reply in different processes is not supported.

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.

Parameters:
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().

Here is the caller graph for this function:

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.

Here is the call graph for this function:

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.

Here is the call graph for this function:

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.

Parameters:
ctx A pointer to the context structure of the xhttp_rpc request that generated the reply.
Returns:
1 if the reply was already sent, 0 on success, a negative number on error

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.

Here is the call graph for this function:


Variable Documentation

rpc_ctx_t ctx [static]

This is a global variable that records the context of the xhttp_rpc request being currently processed.

See also:
rpc_ctx

Definition at line 77 of file xhttp_rpc.c.