[open]lipc
Open-source LIPC header file
Typedefs | Enumerations | Functions
HashArray

Hash-array data structure. More...

Typedefs

typedef void LIPCha
 

Enumerations

enum  LIPCHasharrayType {
  LIPC_HASHARRAY_INT = 0,
  LIPC_HASHARRAY_STRING = 1,
  LIPC_HASHARRAY_BLOB = 2
}
 

Functions

LIPChaLipcHasharrayNew (LIPC *lipc)
 
LIPCcode LipcHasharrayFree (LIPCha *ha, int destroy)
 
LIPCcode LipcHasharrayDestroy (LIPCha *ha)
 
int LipcHasharrayGetHashCount (LIPCha *ha)
 
LIPCcode LipcHasharrayAddHash (LIPCha *ha, size_t *index)
 
LIPCcode LipcHasharrayKeys (LIPCha *ha, int index, const char *keys[], size_t *count)
 
LIPCcode LipcHasharrayCheckKey (LIPCha *ha, int index, const char *key, LIPCHasharrayType *type, size_t *size)
 
LIPCcode LipcHasharrayGetInt (LIPCha *ha, int index, const char *key, int *value)
 
LIPCcode LipcHasharrayPutInt (LIPCha *ha, int index, const char *key, int value)
 
LIPCcode LipcHasharrayGetString (LIPCha *ha, int index, const char *key, char **value)
 
LIPCcode LipcHasharrayPutString (LIPCha *ha, int index, const char *key, const char *value)
 
LIPCcode LipcHasharrayGetBlob (LIPCha *ha, int index, const char *key, unsigned char *data[], size_t *size)
 
LIPCcode LipcHasharrayPutBlob (LIPCha *ha, int index, const char *key, const unsigned char *data, size_t size)
 
LIPCcode LipcHasharrayCopy (LIPCha *dest, const LIPCha *src)
 
LIPCcode LipcHasharrayCopyHash (LIPCha *dest, int dest_index, const LIPCha *src, int src_index)
 
LIPChaLipcHasharrayClone (const LIPCha *ha)
 
LIPCcode LipcHasharraySave (const LIPCha *ha, int fd)
 
LIPChaLipcHasharrayRestore (LIPC *lipc, int fd)
 
LIPCcode LipcHasharrayToString (const LIPCha *ha, char *str, size_t *size)
 

Detailed Description

Hash-array data structure.

Typedef Documentation

typedef void LIPCha

LIPC hash-array handler.

Enumeration Type Documentation

Possible data types, which can be stored in the value of the hash component in the hash-array data structure.

Function Documentation

LIPCha* LipcHasharrayNew ( LIPC lipc)

Initialize new hash-array data structure.

Parameters
lipcLIPC library handler.
Returns
The LIPC hash-array handler or NULL upon error.
LIPCcode LipcHasharrayFree ( LIPCha ha,
int  destroy 
)

Free resources associated with the hash-array handler.

Parameters
haThe LIPC hash-array handler.
destroyIf TRUE, the underlying shared memory segment will be marked to be destroyed.
Returns
The status code.
LIPCcode LipcHasharrayDestroy ( LIPCha ha)

Free resources associated with the hash-array handler.

This function is an equivalent of calling the LipcHasharrayFree() function with the destroy parameter set to TRUE.

Parameters
haThe LIPC hash-array handler.
Returns
The status code.
int LipcHasharrayGetHashCount ( LIPCha ha)

Get the number of elements in the array component of the hash-array data structure.

Parameters
haThe LIPC hash-array handler.
Returns
The array size or -1 upon error.
LIPCcode LipcHasharrayAddHash ( LIPCha ha,
size_t *  index 
)

Append new hash map to the hash-array structure.

Parameters
haThe LIPC hash-array handler.
indexThe address where the index of newly added hash map (hence, the size of the array) will be stored.
Returns
The status code.
LIPCcode LipcHasharrayKeys ( LIPCha ha,
int  index,
const char *  keys[],
size_t *  count 
)

Get keys stored in the hash map of the hash-array data structure.

In order to determine the number of keys at the given index, one should call this function with the count parameter initialized to 0. The number of available keys will be returned back in this parameter - in fact the count parameter is always modified, and the number of keys is returned in it (be careful when reusing this variable for iteration over keys array).

Parameters
haThe LIPC hash-array handler.
indexThe 0-based index in the array.
keysThe array which can store up to the count number of string pointers - keys.
countThe address where the number of keys to fetch is given.
Returns
The status code.
LIPCcode LipcHasharrayCheckKey ( LIPCha ha,
int  index,
const char *  key,
LIPCHasharrayType type,
size_t *  size 
)

Get the data type stored in the hash map of the hash-array data structure.

Parameters
haThe LIPC hash-array handler.
indexThe 0-based index in the array.
keyThe key name to check.
typeThe address where the data type will be stored.
sizeThe address where the size of the value will be stored.
Returns
The status code.
LIPCcode LipcHasharrayGetInt ( LIPCha ha,
int  index,
const char *  key,
int *  value 
)

Get the integer value form the hash map of the hash-array data structure.

Parameters
haThe LIPC hash-array handler.
indexThe 0-based index in the array.
keyThe key name to get.
valueThe address where the integer value will be stored.
Returns
The status code.
LIPCcode LipcHasharrayPutInt ( LIPCha ha,
int  index,
const char *  key,
int  value 
)

Put the integer value into the hash map of the hash-array data structure.

Parameters
haThe LIPC hash-array handler.
indexThe 0-based index in the array.
keyThe key name to set.
valueThe value to set.
Returns
The status code.
LIPCcode LipcHasharrayGetString ( LIPCha ha,
int  index,
const char *  key,
char **  value 
)

Get the string value form the hash map of the hash-array data structure.

Parameters
haThe LIPC hash-array handler.
indexThe 0-based index in the array.
keyThe key name to get.
valueThe address where the pointer to the string will be stored.
Returns
The status code.
LIPCcode LipcHasharrayPutString ( LIPCha ha,
int  index,
const char *  key,
const char *  value 
)

Put the string value into the hash map of the hash-array data structure.

Parameters
haThe LIPC hash-array handler.
indexThe 0-based index in the array.
keyThe key name to set.
valueThe value to set.
Returns
The status code.
LIPCcode LipcHasharrayGetBlob ( LIPCha ha,
int  index,
const char *  key,
unsigned char *  data[],
size_t *  size 
)

Get the blob data from the hash map of the hash-array data structure.

Parameters
haThe LIPC hash-array handler.
indexThe 0-based index in the array.
keyThe key name to get.
dataThe address where the pointer to the data will be stored.
sizeThe address where the size of the data will be stored.
Returns
The status code.
LIPCcode LipcHasharrayPutBlob ( LIPCha ha,
int  index,
const char *  key,
const unsigned char *  data,
size_t  size 
)

Put the blob data into the hash map of the hash-array data structure.

Parameters
haThe LIPC hash-array handler.
indexThe 0-based index in the array.
keyThe key name to set.
dataThe data to set.
sizeThe size of the data.
Returns
The status code.
LIPCcode LipcHasharrayCopy ( LIPCha dest,
const LIPCha src 
)

Copy a hash-array data structure.

The destination hash-array structure handler has to be initialized with the LipcHasharrayNew() function.

Parameters
destThe destination hash-array handler.
srcThe source hash-array handler.
Returns
The status code.
LIPCcode LipcHasharrayCopyHash ( LIPCha dest,
int  dest_index,
const LIPCha src,
int  src_index 
)

Copy a single hash map of the hash-array data structure.

The destination hash-array structure handler has to be initialized with the LipcHasharrayNew() function.

Parameters
destThe destination hash-array handler.
dest_indexThe index in the destination hash-array structure, where the copied hash map will be placed.
srcThe source hash-array handler.
src_indexThe index within the source hash-array structure, from where the hash map is copied.
Returns
The status code.
LIPCha* LipcHasharrayClone ( const LIPCha ha)

Clone a hash-array data structure.

This function is (almost) an equivalent of calling the LipcHasharrayCopy() function using a newly initialized hash-array handler. However, using this function ensures, that the internal hash-array key and few other internal fields are copied too. The exact meaning of these fields is unknown.

Parameters
haThe hash-array handler to the structure which should be cloned.
Returns
On success the LIPC hash-array handler to the new data structure is returned. Upon error this function returns NULL.
LIPCcode LipcHasharraySave ( const LIPCha ha,
int  fd 
)

Save hash-array memory into the given file descriptor.

Parameters
haThe hash-array handler.
fdOpened file descriptor with the write permission.
Returns
The status code.
LIPCha* LipcHasharrayRestore ( LIPC lipc,
int  fd 
)

Restore hash-array form the memory read from the given file descriptor.

Parameters
lipcLIPC library handler.
fdOpened file descriptor with the read permission.
Returns
On success the LIPC hash-array handler to the restored data structure is returned. Upon error this function returns NULL.
LIPCcode LipcHasharrayToString ( const LIPCha ha,
char *  str,
size_t *  size 
)

Get string representation of the given hash-array.

In order to determine the number of bytes required to store the string representation of the given hash-array data structure, one should call this function with the size parameter initialized to 0. The number of required bytes will be returned back in this parameter - in fact the size parameter is always modified, and the number of required bytes is returned in it (be careful when reusing this variable).

Parameters
haThe hash-array handler.
strThe pointer to the address, where the hash-array string representation will be stored.
sizeThe pointer to the address, where the size of the str buffer is passed. On return, the number of actually used bytes will be stored at this address.
Returns
The status code.