Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
apreq_param.h File Reference

Request parsing and parameter API. More...

#include "apreq.h"
#include "apr_buckets.h"
Include dependency graph for apreq_param.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  apreq_param_t
 

Typedefs

typedef struct apreq_param_t apreq_param_t
 

Functions

apreq_param_tapreq_param_make (apr_pool_t *p, const char *name, const apr_size_t nlen, const char *val, const apr_size_t vlen)
 
apr_status_t apreq_param_decode (apreq_param_t **param, apr_pool_t *pool, const char *word, apr_size_t nlen, apr_size_t vlen)
 
char * apreq_param_encode (apr_pool_t *pool, const apreq_param_t *param)
 
apr_status_t apreq_parse_query_string (apr_pool_t *pool, apr_table_t *t, const char *qs)
 
apr_array_header_tapreq_params_as_array (apr_pool_t *p, const apr_table_t *t, const char *key)
 
const char * apreq_params_as_string (apr_pool_t *p, const apr_table_t *t, const char *key, apreq_join_t mode)
 
const apr_table_tapreq_uploads (const apr_table_t *body, apr_pool_t *pool)
 
const apreq_param_tapreq_upload (const apr_table_t *body, const char *name)
 

Detailed Description

Request parsing and parameter API.

Typedef Documentation

typedef struct apreq_param_t apreq_param_t

Common data structure for params and file uploads

Function Documentation

apr_status_t apreq_param_decode ( apreq_param_t **  param,
apr_pool_t pool,
const char *  word,
apr_size_t  nlen,
apr_size_t  vlen 
)

Url-decodes a name=value pair into a param.

Parameters
parampoints to the decoded parameter on success
poolPool from which the param is allocated.
wordStart of the name=value pair.
nlenLength of urlencoded name.
vlenLength of urlencoded value.
Returns
APR_SUCCESS on success.
APREQ_ERROR_BADSEQ or APREQ_ERROR_BADCHAR on malformed input.
Remarks
Unless vlen == 0, this function assumes there is exactly one character ('=') which separates the pair.
char* apreq_param_encode ( apr_pool_t pool,
const apreq_param_t param 
)

Url-encodes the param into a name-value pair.

Parameters
poolPool which allocates the returned string.
paramParam to encode.
Returns
name-value pair representing the param.
apreq_param_t* apreq_param_make ( apr_pool_t p,
const char *  name,
const apr_size_t  nlen,
const char *  val,
const apr_size_t  vlen 
)

creates a param from name/value information

apr_array_header_t* apreq_params_as_array ( apr_pool_t p,
const apr_table_t t,
const char *  key 
)

Returns an array of parameters (apreq_param_t *) matching the given key. The key is case-insensitive.

Parameters
pAllocates the returned array.
tthe parameter table returned by apreq_args(), apreq_body() or apreq_params()
keyNull-terminated search key, case insensitive. key==NULL fetches all parameters.
Returns
an array of apreq_param_t* (pointers)
Remarks
Also parses the request if necessary.
const char* apreq_params_as_string ( apr_pool_t p,
const apr_table_t t,
const char *  key,
apreq_join_t  mode 
)

Returns a ", " -joined string containing all parameters for the requested key, an empty string if none are found. The key is case-insensitive.

Parameters
pAllocates the return string.
tthe parameter table returned by apreq_args(), apreq_body() or apreq_params()
keyNull-terminated parameter name, case insensitive. key==NULL fetches all values.
modeJoin type- see apreq_join().
Returns
the joined string or NULL on error
Remarks
Also parses the request if necessary.
apr_status_t apreq_parse_query_string ( apr_pool_t pool,
apr_table_t t,
const char *  qs 
)

Parse a url-encoded string into a param table.

Parameters
poolpool used to allocate the param data.
ttable to which the params are added.
qsQuery string to url-decode.
Returns
APR_SUCCESS if successful, error otherwise.
Remarks
This function uses [&;] as the set of tokens to delineate words, and will treat a word w/o '=' as a name-value pair with value-length = 0.
const apreq_param_t* apreq_upload ( const apr_table_t body,
const char *  name 
)

Returns the first param in req->body which has both param->v.name matching key (case insensitive) and param->upload != NULL.

Parameters
bodyparameter table returned by apreq_body() or apreq_params()
nameParameter name. key == NULL returns first upload.
Returns
Corresponding upload, NULL if none found.
Remarks
Will parse the request as necessary.
const apr_table_t* apreq_uploads ( const apr_table_t body,
apr_pool_t pool 
)

Returns a table of all params in req->body with non-NULL upload brigades.

Parameters
bodyparameter table returned by apreq_body() or apreq_params()
poolPool which allocates the table struct.
Returns
Upload table.
Remarks
Will parse the request if necessary.