Apache HTTPD
Macros | Typedefs | Functions | Variables
Hash Tables

Macros

#define APR_HASH_KEY_STRING   (-1)
 

Typedefs

typedef struct apr_hash_t apr_hash_t
 
typedef struct apr_hash_index_t apr_hash_index_t
 
typedef unsigned int(* apr_hashfunc_t) (const char *key, apr_ssize_t *klen)
 
typedef int() apr_hash_do_callback_fn_t(void *rec, const void *key, apr_ssize_t klen, const void *value)
 

Functions

 APR_DECLARE_NONSTD (unsigned int) apr_hashfunc_default(const char *key
 
 APR_DECLARE (apr_hash_t *) apr_hash_make(apr_pool_t *pool)
 
 APR_DECLARE (void) apr_hash_set(apr_hash_t *ht
 
 APR_DECLARE (void *) apr_hash_get(apr_hash_t *ht
 
 APR_DECLARE (apr_hash_index_t *) apr_hash_first(apr_pool_t *p
 
 APR_DECLARE (const void *) apr_hash_this_key(apr_hash_index_t *hi)
 
 APR_DECLARE (apr_ssize_t) apr_hash_this_key_len(apr_hash_index_t *hi)
 
 APR_DECLARE (unsigned int) apr_hash_count(apr_hash_t *ht)
 
 APR_DECLARE (int) apr_hash_do(apr_hash_do_callback_fn_t *comp
 
 APR_DECLARE (apr_pool_t *) apr_hash_pool_get(const apr_hash_t *thehash)
 

Variables

apr_ssize_tklen
 
apr_hashfunc_t hash_func
 
const apr_hash_th
 
const void * key
 
const void apr_ssize_t const void * val
 
apr_hash_tht
 
const apr_hash_toverlay
 
const apr_hash_t const apr_hash_tbase
 
const apr_hash_th1
 
const apr_hash_t const apr_hash_th2
 
const apr_hash_t const apr_hash_t void *(* merger )(apr_pool_t *p, const void *key, apr_ssize_t klen, const void *h1_val, const void *h2_val, const void *data)
 
const apr_hash_t const apr_hash_t void *(*) const void data )
 
void * rec
 

Detailed Description

Macro Definition Documentation

◆ APR_HASH_KEY_STRING

#define APR_HASH_KEY_STRING   (-1)

When passing a key to apr_hash_set or apr_hash_get, this value can be passed to indicate a string-valued key, and have apr_hash compute the length automatically.

Remarks
apr_hash will use strlen(key) for the length. The NUL terminator is not included in the hash value (why throw a constant in?). Since the hash table merely references the provided key (rather than copying it), apr_hash_this() will return the NUL-term'd key.

Definition at line 47 of file apr_hash.h.

Typedef Documentation

◆ apr_hash_do_callback_fn_t

typedef int() apr_hash_do_callback_fn_t(void *rec, const void *key, apr_ssize_t klen, const void *value)

Declaration prototype for the iterator callback function of apr_hash_do().

Parameters
recThe data passed as the first argument to apr_hash_[v]do()
keyThe key from this iteration of the hash table
klenThe key length from this iteration of the hash table
valueThe value from this iteration of the hash table
Remarks
Iteration continues while this callback function returns non-zero. To export the callback function for apr_hash_do() it must be declared in the _NONSTD convention.

Definition at line 253 of file apr_hash.h.

◆ apr_hash_index_t

Abstract type for scanning hash tables.

Definition at line 57 of file apr_hash.h.

◆ apr_hash_t

Abstract type for hash tables.

Definition at line 52 of file apr_hash.h.

◆ apr_hashfunc_t

typedef unsigned int(* apr_hashfunc_t) (const char *key, apr_ssize_t *klen)

Callback functions for calculating hash values.

Parameters
keyThe key.
klenThe length of the key, or APR_HASH_KEY_STRING to use the string length. If APR_HASH_KEY_STRING then returns the actual key length.

Definition at line 65 of file apr_hash.h.

Function Documentation

◆ APR_DECLARE() [1/9]

APR_DECLARE ( apr_hash_index_t )

Start iterating over the entries in a hash table.

Parameters
pThe pool to allocate the apr_hash_index_t iterator. If this pool is NULL, then an internal, non-thread-safe iterator is used.
htThe hash table
Returns
The iteration state
Remarks
There is no restriction on adding or deleting hash entries during an iteration (although the results may be unpredictable unless all you do is delete the current entry) and multiple iterations can be in progress at the same time.
Example:
{
void *val;
int sum = 0;
sum += *(int *)val;
}
return sum;
}
apr_size_t size
apr_uint32_t val
Definition apr_atomic.h:66
apr_hash_t * ht
Definition apr_hash.h:148
apr_pool_t * p
Definition md_event.c:32
return NULL
Definition mod_so.c:359

Continue iterating over the entries in a hash table.

Parameters
hiThe iteration state
Returns
a pointer to the updated iteration state. NULL if there are no more
entries.

◆ APR_DECLARE() [2/9]

APR_DECLARE ( apr_hash_t )

Create a hash table.

Parameters
poolThe pool to allocate the hash table out of
Returns
The hash table just created

Create a hash table with a custom hash function

Parameters
poolThe pool to allocate the hash table out of
hash_funcA custom hash function.
Returns
The hash table just created

Make a copy of a hash table

Parameters
poolThe pool from which to allocate the new hash table
hThe hash table to clone
Returns
The hash table just created
Remarks
Makes a shallow copy

Merge two hash tables into one new hash table. The values of the overlay hash override the values of the base if both have the same key. Both hash tables must use the same hash function.

Parameters
pThe pool to use for the new hash table
overlayThe table to add to the initial table
baseThe table that represents the initial values of the new table
Returns
A new hash table containing all of the data from the two passed in

Merge two hash tables into one new hash table. If the same key is present in both tables, call the supplied merge function to produce a merged value for the key in the new table. Both hash tables must use the same hash function.

Parameters
pThe pool to use for the new hash table
h1The first of the tables to merge
h2The second of the tables to merge
mergerA callback function to merge values, or NULL to make values from h1 override values from h2 (same semantics as apr_hash_overlay())
dataClient data to pass to the merger function
Returns
A new hash table containing all of the data from the two passed in

◆ APR_DECLARE() [3/9]

APR_DECLARE ( apr_pool_t ) const

Get a pointer to the pool which the hash table was created in

◆ APR_DECLARE() [4/9]

APR_DECLARE ( apr_ssize_t  )

Get the current entry's key length from the iteration state.

Parameters
hiThe iteration state
Returns
The key length

Definition at line 173 of file apr_hash.c.

◆ APR_DECLARE() [5/9]

APR_DECLARE ( const void *  )

Get the current entry's key from the iteration state.

Parameters
hiThe iteration state
Returns
The pointer to the key

Convert hex encoding to binary data, and return the results from a pool. If the colon character appears between pairs of hex digits, it will be ignored.

Parameters
pPool to allocate from
strThe original string
colonIf not zero, ignore colon characters between hex digits.
lenIf present, returns the length of the final buffer
Returns
A buffer allocated from the pool on success, or NULL if src was NULL, or a bad character was present.

Definition at line 1124 of file apr_escape.c.

◆ APR_DECLARE() [6/9]

APR_DECLARE ( int  )

Iterate over a hash table running the provided function once for every element in the hash table. The comp function will be invoked for every element in the hash table.

Parameters
compThe function to run
recThe data to pass as the first argument to the function
htThe hash table to iterate over
Returns
FALSE if one of the comp() iterations returned zero; TRUE if all iterations returned non-zero
See also
apr_hash_do_callback_fn_t

< File is read-only

< File is executable

< all protections

< File is read-only

< File is read-only

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< File is executable

< File is executable

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

< Stat the link not the file itself if it is a link

< Stat the link not the file itself if it is a link

< ->name in proper case

< ->name in proper case

< Access Time

< Create the file if not there

< Open the file for reading

< Open the file for writing

< Delete the file after close

< Open should fail if APR_FOPEN_CREATE and file exists.

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Read by user

<

Deprecated:
See also
APR_FPROT_UREAD

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< ->name in proper case

< Modification Time

< Access Time

< Creation or inode-changed time

< Type

< Size of the file

< Storage size consumed by the file

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< ->name in proper case

< ->name in proper case

< Type

< all protections

< ->name in proper case

< ->name in proper case

< File is read-only

< File is hidden

< File is read-only

< File is read-only

< File is hidden

< File is hidden

< Platform dependent flag to enable * non blocking file io

< Open the file for reading

< Open the file for writing

< Open the file for reading

< Open the file for writing

< Open the file for buffered I/O

< Create the file if not there

< Open should fail if APR_FOPEN_CREATE and file exists.

< Open the file and truncate to 0 length

< Open should fail if APR_FOPEN_CREATE and file exists.

< Create the file if not there

< Open the file and truncate to 0 length

< Append to the end of the file

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Delete the file after close

< Open the file for buffered I/O

< Open the file for writing

< Open the file for writing

< Open the file for reading

< Append to the end of the file

< an atomic unix apr_stat()

< Open the file for writing

< Create the file if not there

< Open the file and truncate to 0 length

< Open the file for writing

< Create the file if not there

< Append to the end of the file

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< File is read-only

< File is executable

< all protections

< File is read-only

< File is read-only

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< File is executable

< File is executable

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

< Access Time

< Stat the link not the file itself if it is a link

< Stat the link not the file itself if it is a link

< Stat the link not the file itself if it is a link

< Create the file if not there

< Open the file for reading

< Open the file for writing

< Open should fail if APR_FOPEN_CREATE and file exists.

< Delete the file after close

< Open the file for reading

< Open the file for writing

< Open the file for reading

< Open the file for writing

< Create the file if not there

< Open should fail if APR_FOPEN_CREATE and file exists.

< Open should fail if APR_FOPEN_CREATE and file exists.

< Create the file if not there

< Append to the end of the file

< Open the file and truncate to 0 length

< Platform dependent flag to enable * non blocking file io

< use OS's default permissions

<

Deprecated:
See also
APR_FPROT_OS_DEFAULT

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Open the file for buffered I/O

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Open the file for buffered I/O

< Open the file for writing

< Open the file for writing

< Open the file for reading

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

The problem with trying to output the entire iovec is that we cannot maintain the behaviour that a real writev would have. If we iterate over the iovec one at a time, we lose the atomic properties of writev(). The other option is to combine the entire iovec into one buffer that we could then send in one call to write(). This is not reasonable since we do not know how much data an iovec could contain.

The only reasonable option, that maintains the semantics of a real writev(), is to only write the first iovec. Callers of file_writev() must deal with partial writes as they normally would. If you want to ensure an entire iovec is written, use apr_file_writev_full().

< ->name in proper case

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Size of the file

< Size of the file

< dev and inode

< Number of links

< ->name in proper case

< Type

< Type

< ->name in proper case

< File is read-only

< File is hidden

< File is read-only

< File is read-only

< File is hidden

< File is hidden

< Open the file for reading

< use OS's default permissions

<

Deprecated:
See also
APR_FPROT_OS_DEFAULT

< Platform dependent flag to enable * non blocking file io

< Open the file for reading

< Open the file for writing

< Create the file if not there

< Open should fail if APR_FOPEN_CREATE and file exists.

< Open the file and truncate to 0 length

< Open the file and truncate to 0 length

< Open should fail if APR_FOPEN_CREATE and file exists.

< Create the file if not there

< Delete the file after close

< Open the file for reading

< Open the file for writing

< Platform dependent tag to open the file for use across multiple threads

< Append to the end of the file

< Open the file for buffered I/O

< Platform dependent flag to enable * sparse file support, see WARNING below

< Do not register a cleanup when the file is opened. The apr_os_file_t handle in apr_file_t will not be closed when the pool is destroyed.

< Append to the end of the file

< Open the file for buffered I/O

< Open the file for writing

< Open the file for writing

< Open the file for reading

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Exclusive lock. Only one process may hold an exclusive lock at any given time. This is analogous to a "write lock".

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Platform dependent tag to open the file for use across multiple threads

< Size of the file

< Platform dependent tag to open the file for use across multiple threads

< Size of the file

Definition at line 74 of file apr_atomic.c.

◆ APR_DECLARE() [7/9]

APR_DECLARE ( unsigned int  )

Get the number of key/value pairs in the hash table.

Parameters
htThe hash table
Returns
The number of key/value pairs in the hash table.

Definition at line 402 of file apr_hash.c.

◆ APR_DECLARE() [8/9]

APR_DECLARE ( void *  )

Look up the value associated with a key in a hash table.

Parameters
htThe hash table
keyPointer to the key
klenLength of the key. Can be APR_HASH_KEY_STRING to use the string length.
Returns
Returns NULL if the key is not present.

Get the current entry's value from the iteration state.

Parameters
hiThe iteration state
Returns
The pointer to the value

Definition at line 131 of file apr_atomic.c.

◆ APR_DECLARE() [9/9]

APR_DECLARE ( void  )

Associate a value with a key in a hash table.

Parameters
htThe hash table
keyPointer to the key
klenLength of the key. Can be APR_HASH_KEY_STRING to use the string length.
valValue to associate with the key
Remarks
If the value is NULL the hash entry is deleted. The key is stored as is, and so must have a lifetime at least as long as the hash table's pool.

Get the current entry's details from the iteration state.

Parameters
hiThe iteration state
keyReturn pointer for the pointer to the key.
klenReturn pointer for the key length.
valReturn pointer for the associated value.
Remarks
The return pointers should point to a variable that will be set to the corresponding data, or they may be NULL if the data isn't interesting.

Clear any key/value pairs in the hash table.

Parameters
htThe hash table

< File is read-only

< File is executable

< all protections

< File is read-only

< File is read-only

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< Write by user

<

Deprecated:
See also
APR_FPROT_UWRITE

< Write by group

<

Deprecated:
See also
APR_FPROT_GWRITE

< Write by others

<

Deprecated:
See also
APR_FPROT_WWRITE

< File is executable

< File is executable

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

< Execute by user

<

Deprecated:
See also
APR_FPROT_UEXECUTE

< Execute by group

<

Deprecated:
See also
APR_FPROT_GEXECUTE

< Execute by others

<

Deprecated:
See also
APR_FPROT_WEXECUTE

Definition at line 224 of file apr_pools.h.

◆ APR_DECLARE_NONSTD()

APR_DECLARE_NONSTD ( unsigned int  ) const

The default hash function.

Variable Documentation

◆ base

Definition at line 215 of file apr_hash.h.

◆ data

const apr_hash_t const apr_hash_t void *(*) const void data)

Definition at line 240 of file apr_hash.h.

◆ h

Definition at line 97 of file apr_hash.h.

◆ h1

Definition at line 232 of file apr_hash.h.

◆ h2

Definition at line 233 of file apr_hash.h.

◆ hash_func

apr_hashfunc_t hash_func

Definition at line 87 of file apr_hash.h.

◆ ht

void const apr_hash_t * ht

Definition at line 148 of file apr_hash.h.

◆ key

const void ** key

Definition at line 108 of file apr_hash.h.

◆ klen

const void apr_ssize_t * klen

Definition at line 71 of file apr_hash.h.

◆ merger

const apr_hash_t const apr_hash_t void *(* merger) (apr_pool_t *p, const void *key, apr_ssize_t klen, const void *h1_val, const void *h2_val, const void *data) ( apr_pool_t p,
const void *  key,
apr_ssize_t  klen,
const void *  h1_val,
const void *  h2_val,
const void *  data 
)

Definition at line 234 of file apr_hash.h.

◆ overlay

const apr_hash_t* overlay

Definition at line 214 of file apr_hash.h.

◆ rec

void* rec

Definition at line 270 of file apr_hash.h.

◆ val

const void apr_ssize_t void ** val

Definition at line 109 of file apr_hash.h.