PingAccess Agent SDK for C
Macros | Functions
paa-util.h File Reference
#include "apr.h"
#include "apr_pools.h"
#include "apr_tables.h"

Go to the source code of this file.

Macros

#define PAA_UTIL_GLOBAL
 
#define APR_PAA_ERROR_START   (APR_OS_START_USERERR + 4000)
 
#define APR_PAA_MODULE_START   (APR_PAA_ERROR_START + 0)
 
#define APR_PAA_CACHE_START   (APR_PAA_ERROR_START + 50)
 
#define APR_PAA_HTTP_START   (APR_PAA_ERROR_START + 100)
 

Functions

apr_status_t paa_util_parse_header_value (const char *header_value, apr_pool_t *pool, apr_array_header_t **output)
 
apr_status_t paa_util_parse_header_space_values (const char *header_value, apr_pool_t *pool, apr_array_header_t **output)
 
apr_status_t paa_util_parse_header_map (const char *header_value, apr_pool_t *pool, apr_table_t **output)
 
apr_status_t paa_util_parse_header (const char *header, size_t len, apr_pool_t *pool, char **name, char **value)
 
char * paa_util_trim_whitespace (char *input)
 
void paa_util_secure_erase (void *buffer, size_t buflen)
 
const char * paa_util_apr_table_getm (apr_pool_t *p, const apr_table_t *t, const char *key, char delim)
 
int paa_util_getpid ()
 

Detailed Description

Header for SDK util functions.

Also, for the convenience of SDK consumers, common HTTP methods and header names are exposed.

Macro Definition Documentation

#define APR_PAA_CACHE_START   (APR_PAA_ERROR_START + 50)

Start of error codes for the paa_cache interface

#define APR_PAA_ERROR_START   (APR_OS_START_USERERR + 4000)

Extensions to APR's error codes for the PAA SDK

#define APR_PAA_HTTP_START   (APR_PAA_ERROR_START + 100)

Start of error codes for the paa_http_client interface

#define APR_PAA_MODULE_START   (APR_PAA_ERROR_START + 0)

Start of error codes for the functions in paa.h

#define PAA_UTIL_GLOBAL

Macros for exporting/importing global constants appropriately when building with MSVC

Function Documentation

const char* paa_util_apr_table_getm ( apr_pool_t *  p,
const apr_table_t *  t,
const char *  key,
char  delim 
)

Combines multiple values with the same key from the specified table into a single string separated by the delimiter

Note: This is a local version of apr_table_getm to allow use with versions of APR that do not contain this function.

Parameters
pthe pool in which to allocate data if necessary
tthe table
keythe key for the values
delimthe delimiter for the values
int paa_util_getpid ( )

Get the current process id in a cross-platform way

Returns
the process id
apr_status_t paa_util_parse_header ( const char *  header,
size_t  len,
apr_pool_t *  pool,
char **  name,
char **  value 
)

Parses a header into its key and value.

Parameters
headerthe header (need not be null-terminated)
lenthe length of the string
poolthe pool in which to allocate the strings
namethe header name, allocated in the specified pool
valuethe header value, allocated in the specified pool
Returns
APR_SUCCESS if the header was successfully parsed
APR_EINVAL if the header could not be parsed
apr_status_t paa_util_parse_header_map ( const char *  header_value,
apr_pool_t *  pool,
apr_table_t **  output 
)

Parse the header value into a map, where entries are separated by semicolons (;) and key-value pairs are separated by equal signs (=).

This function assumes the specified header value doesn't contain any subvalues.

Since the output is an apr_table_t, the keys of the key-value pairs are expected to be case-insensitive. Further, the resulting table will contain a single entry for each unique key. If there are multiple pairs with the same key, the last pair in the header_value will be in the table.

Parameters
header_valuethe header value to parse
poolthe pool in which to allocate the strings
outputthe table of strings
Returns
APR_SUCCESS if the header value could be parsed
APR_EINVAL if the header value could not be parsed
other return value indicates an unspecified, unexpected error
apr_status_t paa_util_parse_header_space_values ( const char *  header_value,
apr_pool_t *  pool,
apr_array_header_t **  output 
)

Parses a header value into distinct subvalues that are separated by spaces.

This function assumes the specified header value doesn't contain any subvalues.

Parameters
header_valuethe header value to parse
poolthe pool in which to allocate the strings
outputthe table of strings
Returns
APR_SUCCESS if the header value could be parsed
APR_EINVAL if the header value could not be parsed
apr_status_t paa_util_parse_header_value ( const char *  header_value,
apr_pool_t *  pool,
apr_array_header_t **  output 
)

Parse a header value into distinct subvalues that are separated by commas, according to the HTTP spec.

Parameters
header_valuethe header value to parse
poolthe pool in which to allocate the strings
outputan array of strings
Returns
APR_SUCCESS if the header value could be parsed
APR_EINVAL if the header value could not be parsed
void paa_util_secure_erase ( void *  buffer,
size_t  buflen 
)

Securely erase memory and avoid compiler optimizations

Parameters
bufferthe buffer to erase
buflenthe buffer length
char* paa_util_trim_whitespace ( char *  input)

Trims the whitespace for a string. This function assumes that the input has been allocated in a pool and therefore, the output can be returned and assigned to the input without a memory leak.

Parameters
inputthe input string
Returns
the input string without leading or trailing whitespace (as defined by isspace)