Main Page   Modules   Data Structures   File List   Data Fields   Globals   Related Pages  

Common functions, structures and macros
[libapreq2]


Data Structures

struct  apreq_value_t

Defines

#define APREQ_DECLARE(d)   APR_DECLARE(d)
#define APREQ_DECLARE_NONSTD(d)   APR_DECLARE_NONSTD(d)
#define APREQ_URL_ENCTYPE   "application/x-www-form-urlencoded"
#define APREQ_MFD_ENCTYPE   "multipart/form-data"
#define APREQ_XML_ENCTYPE   "application/xml"
#define APREQ_NELTS   8
#define APREQ_READ_AHEAD   (64 * 1024)
#define APREQ_MAX_BRIGADE_LEN   (256 * 1024)
#define apreq_attr_to_type(T, A, P)   ( (T*) ((char*)(P)-offsetof(T,A)) )
#define apreq_char_to_value(ptr)   apreq_attr_to_type(apreq_value_t, data, ptr)
#define apreq_strtoval(ptr)   apreq_char_to_value(ptr)
#define apreq_strlen(ptr)   (apreq_strtoval(ptr)->size)

Typedefs

typedef apreq_value_t apreq_value_t
typedef apreq_value_tapreq_value_merge_t (apr_pool_t *p, const apr_array_header_t *a)
typedef apreq_value_tapreq_value_copy_t (apr_pool_t *p, const apreq_value_t *v)

Enumerations

enum  apreq_join_t { AS_IS, ENCODE, DECODE, QUOTE }
enum  apreq_match_t { FULL, PARTIAL }
enum  apreq_expires_t { HTTP, NSCOOKIE }

Functions

apreq_value_tapreq_make_value (apr_pool_t *p, const char *name, const apr_size_t nlen, const char *val, const apr_size_t vlen)
apreq_value_tapreq_copy_value (apr_pool_t *p, const apreq_value_t *val)
apreq_value_tapreq_merge_values (apr_pool_t *p, const apr_array_header_t *arr)
const char * apreq_enctype (void *env)
const char * apreq_join (apr_pool_t *p, const char *sep, const apr_array_header_t *arr, apreq_join_t mode)
char * apreq_memmem (char *hay, apr_size_t hlen, const char *ndl, apr_size_t nlen, const apreq_match_t type)
apr_ssize_t apreq_index (const char *hay, apr_size_t hlen, const char *ndl, apr_size_t nlen, const apreq_match_t type)
apr_size_t apreq_quote (char *dest, const char *src, const apr_size_t slen)
apr_size_t apreq_quote_once (char *dest, const char *src, const apr_size_t slen)
apr_size_t apreq_encode (char *dest, const char *src, const apr_size_t slen)
apr_ssize_t apreq_decode (char *d, const char *s, const apr_size_t slen)
char * apreq_escape (apr_pool_t *p, const char *src, const apr_size_t slen)
apr_ssize_t apreq_unescape (char *str)
char * apreq_expires (apr_pool_t *p, const char *time_str, const apreq_expires_t type)
apr_int64_t apreq_atoi64f (const char *s)
apr_int64_t apreq_atoi64t (const char *s)
apr_status_t apreq_brigade_fwrite (apr_file_t *f, apr_off_t *wlen, apr_bucket_brigade *bb)
apr_status_t apreq_file_mktemp (apr_file_t **fp, apr_pool_t *pool, const char *path)
apr_file_tapreq_brigade_spoolfile (apr_bucket_brigade *bb)
apr_bucket_brigadeapreq_brigade_copy (const apr_bucket_brigade *bb)
apr_status_t apreq_header_attribute (const char *hdr, const char *name, const apr_size_t nlen, const char **val, apr_size_t *vlen)

Define Documentation

#define apreq_char_to_value ptr       apreq_attr_to_type(apreq_value_t, data, ptr)
 

Converts (char *) to (apreq_value_t *). The char * is assumed to point at the data attribute of an apreq_value_t struct.

Parameters:
ptr  points at the data field of an apreq_value_t struct.

#define apreq_strlen ptr       (apreq_strtoval(ptr)->size)
 

Computes the length of the string, but unlike strlen(), it permits embedded null characters.

Parameters:
ptr  points at the data field of an apreq_value_t struct.


Typedef Documentation

typedef struct apreq_value_t apreq_value_t
 

libapreq-2's pre-extensible string type


Enumeration Type Documentation

enum apreq_expires_t
 

Expiration date format

Enumeration values:
HTTP  Use date formatting consistent with RFC 2616
NSCOOKIE  Use format consistent with Netscape's Cookie Spec

enum apreq_join_t
 

Join type

Enumeration values:
AS_IS  Join the strings without modification
ENCODE  Url-encode the strings before joining them
DECODE  Url-decode the strings before joining them
QUOTE  Quote the strings, backslashing existing quote marks.

enum apreq_match_t
 

Match type

Enumeration values:
FULL  Full match only.
PARTIAL  Partial matches are ok.


Function Documentation

apr_int64_t apreq_atoi64f const char *    s
 

Converts file sizes (KMG) to bytes

Parameters:
s  file size matching m/^\d+[KMG]b?$/i
Returns:
64-bit integer representation of s.

apr_int64_t apreq_atoi64t const char *    s
 

Converts time strings (YMDhms) to seconds

Parameters:
s  time string matching m/^\+?\d+[YMDhms]$/
Returns:
64-bit integer representation of s as seconds.

apr_bucket_brigade* apreq_brigade_copy const apr_bucket_brigade   bb
 

Duplicate a brigade.

Parameters:
bb  Original brigade.
Returns:
New brigade containing a bucket-by-bucket copy of the original.

apr_status_t apreq_brigade_fwrite apr_file_t   f,
apr_off_t   wlen,
apr_bucket_brigade   bb
 

Writes brigade to a file.

Parameters:
f  File that gets the brigade.
wlen  On a successful return, wlen holds the length of the brigade, which is the amount of data written to the file.
bb  Bucket brigade.
Remarks:
In the future, this function may do something intelligent with file buckets.

apr_file_t* apreq_brigade_spoolfile apr_bucket_brigade   bb
 

Gets the spoolfile associated to a brigade, if any.

Parameters:
bb  Brigade, usually associated to a file upload (apreq_param_t).
Returns:
If the last bucket in the brigade is a file bucket, this function will return its associated file. Otherwise, this function returns NULL.

apreq_value_t* apreq_copy_value apr_pool_t   p,
const apreq_value_t   val
 

Makes a pool-allocated copy of the value.

Parameters:
p  Pool.
val  Original value to copy.

apr_ssize_t apreq_decode char *    dest,
const char *    src,
const apr_size_t    slen
 

Url-decodes a string.

Parameters:
dest  Location of url-encoded result string. Caller must ensure dest is large enough to hold the encoded string and trailing null character.
src  Original string.
slen  Length of original string.
Returns:
Length of url-decoded string in dest, or < 0 on decoding (bad data) error.

apr_size_t apreq_encode char *    dest,
const char *    src,
const apr_size_t    slen
 

Url-encodes a string.

Parameters:
dest  Location of url-encoded result string. Caller must ensure it is large enough to hold the encoded string and trailing '\0'.
src  Original string.
slen  Length of original string.
Returns:
length of url-encoded string in dest.

const char* apreq_enctype void   env
 

Fetches the enctype from the environment.

Parameters:
env  Environment.

char* apreq_escape apr_pool_t   p,
const char *    src,
const apr_size_t    slen
 

Returns an url-encoded copy of a string.

Parameters:
p  Pool used to allocate the return value.
src  Original string.
slen  Length of original string.
Remarks:
Use this function insead of apreq_encode if its caller might otherwise overflow dest.

char* apreq_expires apr_pool_t   p,
const char *    time_str,
const apreq_expires_t    type
 

Returns an RFC-822 formatted time string. Similar to ap_gm_timestr_822.

Parameters:
req  The current apreq_request_t object.
time_str  YMDhms time units (from now) until expiry. Understands "now".
type  HTTP for RFC822 dates, NSCOOKIE for cookie dates.
Returns:
Date string, (time_str is offset from "now") formatted either as an NSCOOKIE or HTTP date
Deprecated:
Use apr_rfc822_date instead. NSCOOKIE strings are formatted with a '-' (instead of a ' ') character at offsets 7 and 11.

apr_status_t apreq_file_mktemp apr_file_t **    fp,
apr_pool_t   pool,
const char *    path
 

Makes a temporary file.

Parameters:
fp  Points to the temporary apr_file_t on success.
pool  Pool to associate with the temp file. When the pool is destroyed, the temp file will be closed and deleted.
path  The base directory which will contain the temp file. If param == NULL, the directory will be selected via tempnam(). See the tempnam manpage for details.
Returns:
APR_SUCCESS on success; error code otherwise.

apr_status_t apreq_header_attribute const char *    hdr,
const char *    name,
const apr_size_t    nlen,
const char **    val,
apr_size_t   vlen
 

Search a header string for the value of a particular named attribute.

Parameters:
hdr  Header string to scan.
name  Name of attribute to search for.
nlen  Length of name.
val  Location of (first) matching value.
vlen  Length of matching value.
Returns:
APR_SUCCESS if found, otherwise APR_NOTFOUND.

apr_ssize_t apreq_index const char *    hay,
apr_size_t    hlen,
const char *    ndl,
apr_size_t    nlen,
const apreq_match_t    type
 

Returns offset of match string's location, or -1 if no match is found.

Parameters:
hay  Location of bytes to scan.
hlen  Number of bytes available for scanning.
ndl  Search string
nlen  Length of search string.
type  Match type.
Returns:
Offset of match string, or -1 if mo match is found.

const char* apreq_join apr_pool_t   p,
const char *    sep,
const apr_array_header_t   arr,
apreq_join_t    mode
 

Join an array of values.

Parameters:
p  Pool to allocate return value.
sep  String that is inserted between the joined values.
arr  Array of values.
Remarks:
Return string can be upgraded to an apreq_value_t with apreq_stroval.

apreq_value_t* apreq_make_value apr_pool_t   p,
const char *    name,
const apr_size_t    nlen,
const char *    val,
const apr_size_t    vlen
 

Construcs an apreq_value_t from the name/value info supplied by the arguments.

Parameters:
p  Pool for allocating the name and value.
name  Name of value.
nlen  Length of name.
val  Value data.
vlen  Length of val.
Returns:
apreq_value_t allocated from pool, with v->data holding a copy of val, v->status = 0, and v->name pointing to a nul-terminated copy of name.

char* apreq_memmem char *    hay,
apr_size_t    hlen,
const char *    ndl,
apr_size_t    nlen,
const apreq_match_t    type
 

Return a pointer to the match string, or NULL if no match is found.

Parameters:
hay  Location of bytes to scan.
hlen  Number of bytes available for scanning.
ndl  Search string
nlen  Length of search string.
type  Match type.

apreq_value_t* apreq_merge_values apr_pool_t   p,
const apr_array_header_t   arr
 

Merges an array of values into one.

Parameters:
p  Pool from which the new value is generated.
arr  Array of apr_value_t *.

apr_size_t apreq_quote char *    dest,
const char *    src,
const apr_size_t    slen
 

Places a quoted copy of src into dest. Embedded quotes are escaped with a backslash ('\').

Parameters:
dest  Location of quoted copy. Must be large enough to hold the copy and trailing null byte.
src  Original string.
slen  Length of original string.
dest  Destination string.
Returns:
length of quoted copy in dest.

apr_size_t apreq_quote_once char *    dest,
const char *    src,
const apr_size_t    slen
 

Same as apreq_quote() except when src begins and ends in quote marks. In that case it assumes src is quoted correctly, and just copies src to dest.

Parameters:
dest  Location of quoted copy. Must be large enough to hold the copy and trailing null byte.
src  Original string.
slen  Length of original string.
dest  Destination string.
Returns:
length of quoted copy in dest.

apr_ssize_t apreq_unescape char *    str
 

An in-situ url-decoder.

Parameters:
str  The string to decode
Returns:
Length of decoded string, or < 0 on error.
Remarks:
Equivalent to apreq_decode(str,str,strlen(str)).


Generated on Sat Jun 12 10:16:30 2004 for libapreq2 by doxygen1.2.15