/usr/include/ClearSilver/util/dict.h is in clearsilver-dev 0.10.5-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | /*
*
* Thread-safe Dictionary Using String Identifiers
* Copyright 1998-2000 Scott Shambarger (scott@shambarger.net)
*
* This software is open source. Permission to use, copy, modify, and
* distribute this software for any purpose and without fee is hereby granted,
* provided that the above copyright notice appear in all copies. No
* warranty of any kind is expressed or implied. Use at your own risk.
*
*/
#ifndef __DICT_H_
#define __DICT_H_
__BEGIN_DECLS
typedef struct _dictCtx *dictCtx;
typedef BOOL (*dictCleanupFunc)(char *id, void *value, void *rock);
typedef void (*dictFreeValueFunc)(void *value, void *rock);
NEOERR *dictCreate(dictCtx *dict, BOOL threaded, UINT32 root, UINT32 maxLevel,
UINT32 flushLimit, BOOL useCase,
dictFreeValueFunc freeValue, void *freeRock);
/*
* Function: dictCreate - create new dictionary.
* Description: Returns a dictionary. If <threaded> is true, list is
* multi-thread safe. <root>, <maxLevel>, and <flushLimit>
* act as for skipNewList() (see skiplist.h)
* Input: threaded - true if list should be thread-safe.
* root - performance parameter (see above).
* maxLevel - performance parameter (see above).
* flushLimit - max deleted items to keep cached before
* forcing a flush.
* useCase - true to be case sensitive in identifiers
* freeValue - callback when freeing a value
* freeRock - context for freeValue callback
* Output: None.
* Return: New dictionary, NULL on error.
* MT-Level: Safe.
*/
void dictDestroy(dictCtx dict);
/*
* Function: dictDestroy - destroy dictionary.
* Description: Release all resources used by <dict>.
* Input: dict - dictionary to destroy
* Output: None.
* Return: None.
* MT-Level: Safe for unique <dict>.
*/
BOOL dictRemove(dictCtx dict, const char *id);
/*
* Function: dictRemove - remove item from dictionary.
* Description: Removes item identified by <id> from <dict>.
* Input: dict - dictionary to search in.
* id - identifier of item to remove.
* Output: None.
* Return: true if item found, false if not.
* MT-Level: Safe if <dict> thread-safe.
*/
void *dictSearch(dictCtx dict, const char *id, void **plock);
/*
* Function: dictSearch - search for value in dictionary.
* Description: Searches for <id> in <dict>, and returns value if
* found, or NULL if not. If <plock> is non-NULL, then
* the lock returned in <plock> will be associated with
* the returned value. Until this lock is passed to
* dictReleaseLock(), the value will not be passed to the
* dictCleanupFunc callback (see dictCleanup()).
* Input: dict - dictionary to search in.
* id - identifier of item to find.
* plock - place for value lock (or NULL).
* Output: plock - set to value lock.
* Return: Value associated with <id>, or NULL if <id> not found.
* MT-Level: Safe if <dict> thread-safe.
*/
void *dictNext(dictCtx dict, char **id, void **plock);
/*
* Function: dictNext - search for next value in dictionary.
* Description: Can be used to iterate through values in the dictionary.
* The order is the order of the hash of the ids, which
* isn't usefully externally. Will return the value if
* found, or NULL if not. If <plock> is non-NULL, then
* the lock returned in <plock> will be associated with
* the returned value. Until this lock is passed to
* dictReleaseLock(), the value will not be passed to the
* dictCleanupFunc callback (see dictCleanup()).
* Input: dict - dictionary to iterate over.
* id - pointer to identifier of last item found, or
* pointer to NULL to retrieve first.
* plock - place for value lock (or NULL).
* Output: plock - set to value lock.
* id - pointer to id of found value
* Return: Value associated with <id>, or NULL if <id> not found.
* MT-Level: Safe if <dict> thread-safe.
*/
void dictReleaseLock(dictCtx dict, void *lock);
/*
* Function: dictReleaseLock - release lock on value.
* Description: Releases the lock on the value associated with <lock>. Once
* the lock is released, the dictCleanupFunc callback can
* be called for the value (see dictCleanup()).
* Input: dict - dictionary containing value to release.
* lock - lock to release.
* Output: None.
* Return: None.
* MT-Level: Safe if <dict> thread-safe.
*/
NEOERR *dictSetValue(dictCtx dict, const char *id, void *value);
/*
* Function: dictSetValue - set/reset an items value.
* Description: Updates the <id>/<value> pair into <dict>.
* If <id> is not in <dict>, it is created.
* Input: dict - dictionary to add pair to.
* id - identifier to insert/update
* value - value to store (may NOT be NULL)
* Output: None.
* Return: true if inserted/updated, false if error
* MT-Level: Safe if <dict> thread-safe.
*/
typedef NEOERR *(*dictNewValueCB)(const char *id, void *rock, void **new_val);
typedef NEOERR *(*dictUpdateValueCB)(const char *id, void *value, void *rock);
NEOERR *dictModifyValue(dictCtx dict, const char *id, dictNewValueCB new_cb,
dictUpdateValueCB update, void *rock);
/*
* Function: dictModifyValue - create/modify an item.
* Description: Finds <id>'s value and calls <update>. If <id> is
* not in <dict>, calls <new> to obtain a new value.
* Input: dict - dictionary to add pair to.
* id - identifier of value
* new - function to call to create new value (may be NULL)
* update - function to call to modify value (if NULL, the old
* value is freed, and <new> is used)
* rock - context to pass to <new> or <update>.
* Output: None.
* Return: true if inserted/updated, false if error
* MT-Level: Safe if <dict> thread-safe.
*/
void dictCleanup(dictCtx dict, dictCleanupFunc cleanup, void *rock);
/*
* Function: dictCleanup - cleanup dictionary
* Description: Calls <cleanup> for every item in <dict>. If <cleanup>
* returns true, then item is removed from <dict>.
* Input: dict - dictionary to cleanup
* cleanup - cleanup callback
* rock - to pass to <cleanup>
* Output: None.
* Return: None.
* MT-Level: Safe if <dict> thread-safe.
*/
__END_DECLS
#endif /* __DICT_H_ */
|