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

src/apreq_env.h File Reference

Logging and environment (module) declarations. More...

#include "apreq_params.h"
#include "apreq_cookie.h"
#include <stdarg.h>

Go to the source code of this file.

Data Structures

struct  apreq_env_t
 Vtable describing the necessary environment functions. More...

Defines

#define APREQ_LOG_EMERG   0
#define APREQ_LOG_ALERT   1
#define APREQ_LOG_CRIT   2
#define APREQ_LOG_ERR   3
#define APREQ_LOG_WARNING   4
#define APREQ_LOG_NOTICE   5
#define APREQ_LOG_INFO   6
#define APREQ_LOG_DEBUG   7
#define APREQ_LOG_LEVELMASK   7
#define APREQ_LOG_MARK   __FILE__ , __LINE__
#define APREQ_DEBUG   APREQ_LOG_MARK, APREQ_LOG_DEBUG,
#define APREQ_WARN   APREQ_LOG_MARK, APREQ_LOG_WARNING,
#define APREQ_ERROR   APREQ_LOG_MARK, APREQ_LOG_ERR,
#define apreq_env_content_type(env)   apreq_env_header_in(env, "Content-Type")
#define apreq_env_cookie(env)   apreq_env_header_in(env, "Cookie")
#define apreq_env_cookie2(env)   apreq_env_header_in(env, "Cookie2")
#define apreq_env_set_cookie(e, s)   apreq_env_header_out(e,"Set-Cookie",s)
#define apreq_env_set_cookie2(e, s)   apreq_env_header_out(e,"Set-Cookie2",s)
#define APREQ_ENV_MODULE(pre, name, mmn)
#define apreq_env_name   (apreq_env_module(NULL)->name)
#define apreq_env_magic_number   (apreq_env_module(NULL)->magic_number)

Typedefs

typedef apreq_env_t apreq_env_t
 Vtable describing the necessary environment functions.

Functions

void apreq_log (const char *file, int line, int level, apr_status_t status, void *env, const char *fmt,...)
apr_pool_tapreq_env_pool (void *env)
apreq_jar_tapreq_env_jar (void *env, apreq_jar_t *jar)
apreq_request_tapreq_env_request (void *env, apreq_request_t *req)
const char * apreq_env_query_string (void *env)
const char * apreq_env_header_in (void *env, const char *name)
apr_status_t apreq_env_header_out (void *env, const char *name, char *val)
apr_status_t apreq_env_read (void *env, apr_read_type_e block, apr_off_t bytes)
const char * apreq_env_temp_dir (void *env, const char *path)
apr_off_t apreq_env_max_body (void *env, apr_off_t bytes)
apr_ssize_t apreq_env_max_brigade (void *env, apr_ssize_t bytes)
const apreq_env_tapreq_env_module (const apreq_env_t *mod)


Detailed Description

Logging and environment (module) declarations.


Define Documentation

#define apreq_env_content_type env   )     apreq_env_header_in(env, "Content-Type")
 

Fetch the environment's "Content-Type" header.

Parameters:
env The current environment.
Returns:
The value of the Content-Type header, NULL if not found.

#define apreq_env_cookie env   )     apreq_env_header_in(env, "Cookie")
 

Fetch the environment's "Cookie" header.

Parameters:
env The current environment.
Returns:
The value of the "Cookie" header, NULL if not found.

#define apreq_env_cookie2 env   )     apreq_env_header_in(env, "Cookie2")
 

Fetch the environment's "Cookie2" header.

Parameters:
env The current environment.
Returns:
The value of the "Cookie2" header, NULL if not found.

#define apreq_env_magic_number   (apreq_env_module(NULL)->magic_number)
 

The current environment's magic (ie. version) number.

#define APREQ_ENV_MODULE pre,
name,
mmn   ) 
 

Value:

const apreq_env_t pre##_module = { \ name, mmn, pre##_log, pre##_pool, pre##_jar, pre##_request, \ pre##_query_string, pre##_header_in, pre##_header_out, pre##_read, \ pre##_temp_dir, pre##_max_body, pre##_max_brigade }
Convenience macro for defining an environment module by mapping a function prefix to an associated environment structure.
Parameters:
pre Prefix to define new environment. All attributes of the apreq_env_t struct are defined with this as their prefix. The generated struct is named by appending "_module" to the prefix.
name Name of this environment.
mmn Magic number (i.e. version number) of this environment.

#define apreq_env_name   (apreq_env_module(NULL)->name)
 

The current environment's name.

#define apreq_env_set_cookie e,
 )     apreq_env_header_out(e,"Set-Cookie",s)
 

Add a "Set-Cookie" header to the outgoing response headers.

Parameters:
e The current environment.
s The cookie string.
Returns:
APR_SUCCESS on success, error code otherwise.

#define apreq_env_set_cookie2 e,
 )     apreq_env_header_out(e,"Set-Cookie2",s)
 

Add a "Set-Cookie2" header to the outgoing response headers.

Parameters:
e The current environment.
s The cookie string.
Returns:
APR_SUCCESS on success, error code otherwise.


Typedef Documentation

typedef struct apreq_env_t apreq_env_t
 

Vtable describing the necessary environment functions.

This must be fully defined for libapreq2 to operate properly in a given environment. Normally it is set once, with an apreq_env_module() call during process initialization, and should remain fixed thereafter.


Function Documentation

const char* apreq_env_header_in void *  env,
const char *  name
 

Fetch the header value (joined by ", " if there are multiple headers) for a given header name.

Parameters:
env The current environment.
name The header name.
Returns:
The value of the header, NULL if not found.

apr_status_t apreq_env_header_out void *  env,
const char *  name,
char *  val
 

Add a header field to the environment's outgoing response headers

Parameters:
env The current environment.
name The name of the outgoing header.
val Value of the outgoing header.
Returns:
APR_SUCCESS on success, error code otherwise.

apreq_jar_t* apreq_env_jar void *  env,
apreq_jar_t jar
 

Get/set the jar currently associated to the environment.

Parameters:
env The current environment.
jar New Jar to associate.
Returns:
The previous jar associated to the environment. jar == NULL gets the current jar, which will remain associated after the call.

apr_off_t apreq_env_max_body void *  env,
apr_off_t  bytes
 

Get/set the current max_body setting. This is the maximum amount of bytes that will be read into the environment's parser.

Parameters:
env The current environment.
bytes The new max_body setting.
Returns:
The previous max_body setting. Note: a call using bytes == -1 fetches the current max_body setting without modifying it.

apr_ssize_t apreq_env_max_brigade void *  env,
apr_ssize_t  bytes
 

Get/set the current max_brigade setting. This is the maximum amount of heap-allocated buckets libapreq2 will use for its brigades. If additional buckets are necessary, they will be created from a temporary file.

Parameters:
env The current environment.
bytes The new max_brigade setting.
Returns:
The previous max_brigade setting. Note: a call using bytes == -1 fetches the current max_brigade setting without modifying it.

const apreq_env_t* apreq_env_module const apreq_env_t mod  ) 
 

Get/set function for the active environment stucture. Usually this is called only once per process, to define the correct environment.

Parameters:
mod The new active environment.
Returns:
The previous active environment. Note: a call using mod == NULL fetches the current environment module without modifying it.

apr_pool_t* apreq_env_pool void *  env  ) 
 

Pool associated with the environment.

Parameters:
env The current environment
Returns:
The associated pool.

const char* apreq_env_query_string void *  env  ) 
 

Fetch the query string.

Parameters:
env The current environment.
Returns:
The query string.

apr_status_t apreq_env_read void *  env,
apr_read_type_e  block,
apr_off_t  bytes
 

Read data from the environment and into the current active parser.

Parameters:
env The current environment.
block Read type (APR_READ_BLOCK or APR_READ_NONBLOCK).
bytes Maximum number of bytes to read.
Returns:
APR_INCOMPLETE if there's more data to read, APR_SUCCESS if everything was read & parsed successfully, error code otherwise.

apreq_request_t* apreq_env_request void *  env,
apreq_request_t req
 

Get/set the request currently associated to the environment.

Parameters:
env The current environment.
req New request to associate.
Returns:
The previous request associated to the environment. req == NULL gets the current request, which will remain associated after the call.

const char* apreq_env_temp_dir void *  env,
const char *  path
 

Get/set the current temporary directory.

Parameters:
env The current environment.
path The full pathname of the new directory.
Returns:
The path of the previous temporary directory. Note: a call using path==NULL fetches the current directory without resetting it to NULL.

void apreq_log const char *  file,
int  line,
int  level,
apr_status_t  status,
void *  env,
const char *  fmt,
  ...
 

Analog of Apache's ap_log_rerror().

Parameters:
file Filename to list in the log message.
line Line number from the file.
level Log level.
status Status code.
env Current environment.
fmt Format string for the log message.