gwenhywfar
4.8.0beta
|
This group contains the definition of a GWEN_DB database. More...
Macros | |
#define | GWEN_DB_DEFAULT_LOCK_TIMEOUT 1000 |
#define | GWEN_DB_LINE_MAXSIZE 1024 |
Typedefs | |
typedef struct GWEN_DB_NODE | GWEN_DB_NODE |
DB Flags | |
Please note that the setter functions also take the flags from the module Paths (e.g. GWEN_PATH_FLAGS_PATHMUSTEXIST) into account. So you most likely need to specify them, too. However, for your conveniance there is a default flag value which suffices in most cases (GWEN_DB_FLAGS_DEFAULT). | |
#define | GWEN_DB_FLAGS_ALLOW_EMPTY_STREAM 0x00008000 |
#define | GWEN_DB_FLAGS_OVERWRITE_VARS 0x00010000 |
#define | GWEN_DB_FLAGS_OVERWRITE_GROUPS 0x00020000 |
#define | GWEN_DB_FLAGS_QUOTE_VARNAMES 0x00040000 |
#define | GWEN_DB_FLAGS_QUOTE_VALUES 0x00080000 |
#define | GWEN_DB_FLAGS_WRITE_SUBGROUPS 0x00100000 |
#define | GWEN_DB_FLAGS_DETAILED_GROUPS 0x00200000 |
#define | GWEN_DB_FLAGS_INDEND 0x00400000 |
#define | GWEN_DB_FLAGS_ADD_GROUP_NEWLINES 0x00800000 |
#define | GWEN_DB_FLAGS_USE_COLON 0x01000000 |
#define | GWEN_DB_FLAGS_UNTIL_EMPTY_LINE 0x02000000 |
#define | GWEN_DB_FLAGS_OMIT_TYPES 0x04000000 |
#define | GWEN_DB_FLAGS_APPEND_FILE 0x08000000 |
#define | GWEN_DB_FLAGS_ESCAPE_CHARVALUES 0x10000000 |
#define | GWEN_DB_FLAGS_UNESCAPE_CHARVALUES 0x10000000 |
#define | GWEN_DB_FLAGS_LOCKFILE 0x20000000 |
#define | GWEN_DB_FLAGS_INSERT 0x40000000 |
#define | GWEN_DB_FLAGS_DOSMODE 0x80000000 |
#define | GWEN_DB_FLAGS_DEFAULT |
#define | GWEN_DB_FLAGS_COMPACT |
#define | GWEN_DB_FLAGS_HTTP |
Node Flags | |
#define | GWEN_DB_NODE_FLAGS_DIRTY 0x00000001 |
#define | GWEN_DB_NODE_FLAGS_VOLATILE 0x00000002 |
#define | GWEN_DB_NODE_FLAGS_INHERIT_HASH_MECHANISM 0x00000004 |
#define | GWEN_DB_NODE_FLAGS_SAFE 0x00000008 |
Constructing, Destructing, Copying | |
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_Group_new (const char *name) |
GWENHYWFAR_API void | GWEN_DB_Group_free (GWEN_DB_NODE *n) |
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_Group_dup (const GWEN_DB_NODE *n) |
Iterating Through Groups | |
typedef void *(* | GWEN_DB_NODES_CB )(GWEN_DB_NODE *node, void *user_data) |
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetFirstGroup (GWEN_DB_NODE *n) |
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetNextGroup (GWEN_DB_NODE *n) |
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_FindFirstGroup (GWEN_DB_NODE *n, const char *name) |
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_FindNextGroup (GWEN_DB_NODE *n, const char *name) |
GWENHYWFAR_API void * | GWEN_DB_Groups_Foreach (GWEN_DB_NODE *node, GWEN_DB_NODES_CB func, void *user_data) |
GWENHYWFAR_API unsigned int | GWEN_DB_Groups_Count (const GWEN_DB_NODE *node) |
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetParentGroup (GWEN_DB_NODE *n) |
Variable Getter and Setter | |
These getter functions check for the existence of the given variable and return the value specified by an index. Under the following circumstances the also given default value will be returned:
The setter functions either replace an existing variable, create a missing variable, add a value or return an error if the variable does not exist (see description of the flags). All setter functions make deep copies of the given values, so you may free the params after calling the setter function. All getter functions return a const pointer to the variable's retrieved value. All setter functions return Zero if ok and Nonzero on error. This module knows about the following types (see GWEN_DB_VALUETYPE):
| |
GWENHYWFAR_API const char * | GWEN_DB_GetCharValue (GWEN_DB_NODE *n, const char *path, int idx, const char *defVal) |
GWENHYWFAR_API int | GWEN_DB_SetCharValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val) |
GWENHYWFAR_API int | GWEN_DB_AddCharValue (GWEN_DB_NODE *n, const char *path, const char *val, int senseCase, int check) |
GWENHYWFAR_API int | GWEN_DB_RemoveCharValue (GWEN_DB_NODE *n, const char *path, const char *val, int senseCase) |
GWENHYWFAR_API int | GWEN_DB_GetIntValue (GWEN_DB_NODE *n, const char *path, int idx, int defVal) |
GWENHYWFAR_API int | GWEN_DB_SetIntValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, int val) |
GWENHYWFAR_API const void * | GWEN_DB_GetBinValue (GWEN_DB_NODE *n, const char *path, int idx, const void *defVal, unsigned int defValSize, unsigned int *returnValueSize) |
GWENHYWFAR_API int | GWEN_DB_SetBinValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, const void *val, unsigned int valSize) |
GWENHYWFAR_API void * | GWEN_DB_GetPtrValue (GWEN_DB_NODE *n, const char *path, int idx, void *defVal) |
GWENHYWFAR_API int | GWEN_DB_SetPtrValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, void *val) |
Reading and Writing From/To IO Layers | |
These functions read or write a DB from/to GWEN_IO_LAYER. This allows to use any source or target supported by GWEN_IO_LAYER for data storage (these are currently sockets, files and memory buffers). The flags determine how to read/write the data (e.g. if sub-groups are to be written etc). | |
GWENHYWFAR_API int | GWEN_DB_ReadFromFastBuffer (GWEN_DB_NODE *n, GWEN_FAST_BUFFER *fb, uint32_t dbflags) |
GWENHYWFAR_API int | GWEN_DB_ReadFromIo (GWEN_DB_NODE *n, GWEN_SYNCIO *sio, uint32_t dbflags) |
GWENHYWFAR_API int | GWEN_DB_ReadFile (GWEN_DB_NODE *n, const char *fname, uint32_t dbflags) |
GWENHYWFAR_API int | GWEN_DB_ReadFromString (GWEN_DB_NODE *n, const char *str, int len, uint32_t dbflags) |
GWENHYWFAR_API int | GWEN_DB_WriteToFastBuffer (GWEN_DB_NODE *node, GWEN_FAST_BUFFER *fb, uint32_t dbflags) |
GWENHYWFAR_API int | GWEN_DB_WriteToIo (GWEN_DB_NODE *node, GWEN_SYNCIO *sio, uint32_t dbflags) |
GWENHYWFAR_API int | GWEN_DB_WriteFile (GWEN_DB_NODE *n, const char *fname, uint32_t dbflags) |
GWENHYWFAR_API int | GWEN_DB_WriteToBuffer (GWEN_DB_NODE *n, GWEN_BUFFER *buf, uint32_t dbflags) |
GWENHYWFAR_API int | GWEN_DB_ReadFileAs (GWEN_DB_NODE *n, const char *fname, const char *type, GWEN_DB_NODE *params, uint32_t dbflags) |
GWENHYWFAR_API int | GWEN_DB_WriteFileAs (GWEN_DB_NODE *n, const char *fname, const char *type, GWEN_DB_NODE *params, uint32_t dbflags) |
Iterating Through Values and value handling | |
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetFirstValue (GWEN_DB_NODE *n) |
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetNextValue (GWEN_DB_NODE *n) |
GWENHYWFAR_API void * | GWEN_DB_Values_Foreach (GWEN_DB_NODE *node, GWEN_DB_NODES_CB func, void *user_data) |
GWENHYWFAR_API unsigned int | GWEN_DB_Values_Count (const GWEN_DB_NODE *node) |
GWENHYWFAR_API GWEN_DB_NODE_TYPE | GWEN_DB_GetValueType (GWEN_DB_NODE *n) |
GWENHYWFAR_API GWEN_DB_NODE_TYPE | GWEN_DB_GetValueTypeByPath (GWEN_DB_NODE *n, const char *p, unsigned int i) |
GWENHYWFAR_API const char * | GWEN_DB_GetCharValueFromNode (const GWEN_DB_NODE *n) |
GWENHYWFAR_API int | GWEN_DB_SetCharValueInNode (GWEN_DB_NODE *n, const char *s) |
GWENHYWFAR_API int | GWEN_DB_GetIntValueFromNode (const GWEN_DB_NODE *n) |
GWENHYWFAR_API const void * | GWEN_DB_GetBinValueFromNode (const GWEN_DB_NODE *n, unsigned int *size) |
GWENHYWFAR_API int | GWEN_DB_IsValue (const GWEN_DB_NODE *n) |
Debugging | |
These functions are for debugging purposes only. You should NOT consider them part of the API. | |
GWENHYWFAR_API void | GWEN_DB_Dump (GWEN_DB_NODE *n, int insert) |
This group contains the definition of a GWEN_DB database.
A GWEN_DB database consists of a tree of GWEN_DB_NODE entries. Such a GWEN_DB_NODE node can either be a group node, or a variable node, or a value node. Usually an application programmer will only get in touch with group nodes. The application programmer can iterate through the group nodes with GWEN_DB_GetGroup(), GWEN_DB_Groups_foreach(), and can retrieve variable values with GWEN_DB_GetIntValue(), GWEN_DB_GetCharValue() and so on.
The following graph shows the internal structure of a GWEN_DB:
As you can see the GWEN_DB consists of multiple units called NODE. Every node has a pointer to:
Such a node can be either of the following:
Each group has a name. Depending on the GWEN_DB_FLAGS given when reading a GWEN_DB from a file or creating it, it may very well be possible to have multiple groups with the same name as children of the same root node. Again: Child group nodes with the same name may very well exist. This also applies to variable nodes.
For the interested reader, we again explain the difference of the three kinds of nodes. Depending on either of these cases, you can
To retrieve or set the value of such a variable, the following "shortcut" functions for all three supported typed exist: GWEN_DB_GetIntValue(), GWEN_DB_GetCharValue(), GWEN_DB_GetBinValue(). These functions only accept a group and a "path" to the desired variable.
#define GWEN_DB_DEFAULT_LOCK_TIMEOUT 1000 |
Definition at line 218 of file db.h.
Referenced by GWEN_DB_WriteFile(), GWEN_DBIO_ExportToFile(), and GWEN_DBIO_ImportFromFile().
#define GWEN_DB_FLAGS_ADD_GROUP_NEWLINES 0x00800000 |
writes a newline to the stream after writing a group to improve the readability of the created file
Definition at line 137 of file db.h.
Referenced by GWEN_DB_WriteGroupToIoLayer().
#define GWEN_DB_FLAGS_ALLOW_EMPTY_STREAM 0x00008000 |
when reading a DB allow for empty streams (e.g. empty file)
Definition at line 119 of file db.h.
Referenced by GWEN_DB_ReadFromFastBuffer().
#define GWEN_DB_FLAGS_APPEND_FILE 0x08000000 |
appends data to an existing file instead of overwriting it
Definition at line 147 of file db.h.
Referenced by GWEN_DB_WriteFile(), and GWEN_DBIO_ExportToFile().
#define GWEN_DB_FLAGS_COMPACT |
same like GWEN_DB_FLAGS_DEFAULT except that the produced file (when writing to a stream) is more compact (but less readable)
#define GWEN_DB_FLAGS_DEFAULT |
These are the default flags which you use in most cases
Definition at line 168 of file db.h.
Referenced by GWEN_Args_Check(), GWEN_DB_AddCharValue(), GWEN_DB_RemoveCharValue(), GWEN_MsgEngine__ReadGroup(), GWEN_MsgEngine__TransformValue(), GWEN_MsgEngine_SetIntValue(), GWEN_MsgEngine_SetValue(), GWEN_PasswordStore_ReadFile(), GWEN_PasswordStore_WriteFile(), GWEN_PathManager_AddPath(), GWEN_PathManager_DefinePath(), GWEN_PathManager_InsertPath(), GWEN_PathManager_UndefinePath(), GWEN_SslCertDescr_toDb(), GWEN_Time_toDb(), GWEN_Url_fromCommandString(), GWEN_Url_fromString(), GWEN_Url_toDb(), and HtmlCtx_AddAttr().
#define GWEN_DB_FLAGS_DETAILED_GROUPS 0x00200000 |
adds some comments when writing to a stream
Definition at line 131 of file db.h.
Referenced by GWEN_DB_WriteGroupToIoLayer().
#define GWEN_DB_FLAGS_DOSMODE 0x80000000 |
When writing a DB use DOS line termination (e.g. CR/LF) instead if unix mode (LF only)
Definition at line 165 of file db.h.
Referenced by GWEN_DB_ReadFromIo(), and GWEN_DB_WriteToIo().
#define GWEN_DB_FLAGS_ESCAPE_CHARVALUES 0x10000000 |
Char values are escaped when writing them to a file.
Definition at line 149 of file db.h.
Referenced by GWEN_DB_WriteGroupToIoLayer().
#define GWEN_DB_FLAGS_HTTP |
These flags can be used to read a DB from a HTTP header. It uses a colon instead of the equation mark with variable definitions and stops when encountering an empty line.
#define GWEN_DB_FLAGS_INDEND 0x00400000 |
indents text according to the current path depth when writing to a stream to improve the readability of the created file
Definition at line 134 of file db.h.
Referenced by GWEN_DB_WriteGroupToIoLayer().
#define GWEN_DB_FLAGS_INSERT 0x40000000 |
When setting a value or getting a group insert newly created values/groups rather than appending them.
Definition at line 160 of file db.h.
Referenced by GWEN_DB_HandlePath(), GWEN_DB_SetBinValue(), GWEN_DB_SetCharValue(), GWEN_DB_SetIntValue(), GWEN_DB_SetPtrValue(), and GWEN_PathManager_InsertPath().
#define GWEN_DB_FLAGS_LOCKFILE 0x20000000 |
locks a file before reading from or writing to it This is used by GWEN_DB_ReadFile and GWEN_DB_WriteFile
Definition at line 155 of file db.h.
Referenced by GWEN_DB_WriteFile(), GWEN_DBIO_ExportToFile(), and GWEN_DBIO_ImportFromFile().
#define GWEN_DB_FLAGS_OMIT_TYPES 0x04000000 |
normally the type of a variable is written to the stream, too. This flag changes this behaviour
Definition at line 145 of file db.h.
Referenced by GWEN_DB_WriteGroupToIoLayer().
#define GWEN_DB_FLAGS_OVERWRITE_GROUPS 0x00020000 |
Overwrite existing groups when calling GWEN_DB_GetGroup()
Definition at line 123 of file db.h.
Referenced by GWEN_Crypt_KeyRsa_fromModExp(), GWEN_Crypt_KeyRsa_fromModPrivExp(), GWEN_Crypt_KeyRsa_toDb(), GWEN_Crypt_KeySym__toDb(), GWEN_Crypt_KeySym_toDb(), and GWEN_DB_GetGroup().
#define GWEN_DB_FLAGS_OVERWRITE_VARS 0x00010000 |
Overwrite existing values when assigning a new value to a variable
Definition at line 121 of file db.h.
Referenced by GWEN_Args_Check(), GWEN_Crypt_CryptAlgo_toDb(), GWEN_Crypt_HashAlgo_toDb(), GWEN_Crypt_Key_toDb(), GWEN_Crypt_KeyRsa__WriteMpi(), GWEN_Crypt_KeyRsa_fromModExp(), GWEN_Crypt_KeyRsa_fromModPrivExp(), GWEN_Crypt_KeyRsa_toDb(), GWEN_Crypt_KeySym__toDb(), GWEN_Crypt_KeySym_toDb(), GWEN_Crypt_PaddAlgo_toDb(), GWEN_Crypt_Token_Context_WriteDb(), GWEN_Date_toDb(), GWEN_DB_SetBinValue(), GWEN_DB_SetCharValue(), GWEN_DB_SetIntValue(), GWEN_DB_SetPtrValue(), GWEN_DlgInput_Fini(), GWEN_DlgMessage_Fini(), GWEN_DlgProgress_Fini(), GWEN_DlgShowBox_Fini(), GWEN_Gui_CGui_CheckCert(), GWEN_Gui_Internal_GetPassword(), GWEN_Gui_Internal_GetSyncIo(), GWEN_HttpSession_Init(), GWEN_HttpSession_SendPacket(), GWEN_MsgEngine__TransformValue(), GWEN_MsgEngine_ReadMessage(), GWEN_MsgEngine_SetIntValue(), GWEN_MsgEngine_SetMode(), GWEN_MsgEngine_SetProtocolVersion(), GWEN_MsgEngine_SetValue(), GWEN_PasswordStore__SetPassword(), GWEN_SslCertDescr_toDb(), GWEN_SyncIo_Http_ParseCommand(), GWEN_SyncIo_Http_ParseStatus(), GWEN_Time_toDb(), and GWEN_Url_toDb().
#define GWEN_DB_FLAGS_QUOTE_VALUES 0x00080000 |
quote values when writing them to a stream
Definition at line 127 of file db.h.
Referenced by GWEN_DB_WriteGroupToIoLayer().
#define GWEN_DB_FLAGS_QUOTE_VARNAMES 0x00040000 |
quote variable names when writing them to a stream
Definition at line 125 of file db.h.
Referenced by GWEN_DB_WriteGroupToIoLayer().
#define GWEN_DB_FLAGS_UNESCAPE_CHARVALUES 0x10000000 |
Char values are unescaped when reading them from a file (uses the same bit GWEN_DB_FLAGS_ESCAPE_CHARVALUES uses)
#define GWEN_DB_FLAGS_UNTIL_EMPTY_LINE 0x02000000 |
stops reading from a stream at empty lines
Definition at line 142 of file db.h.
Referenced by GWEN_DB_ReadFromFastBuffer().
#define GWEN_DB_FLAGS_USE_COLON 0x01000000 |
uses a colon (":") instead of an equation mark when reading/writing variable definitions
Definition at line 140 of file db.h.
Referenced by GWEN_DB_ReadFromFastBuffer(), and GWEN_DB_WriteGroupToIoLayer().
#define GWEN_DB_FLAGS_WRITE_SUBGROUPS 0x00100000 |
allows writing of subgroups when writing to a stream
Definition at line 129 of file db.h.
Referenced by GWEN_DB_WriteGroupToIoLayer().
#define GWEN_DB_LINE_MAXSIZE 1024 |
#define GWEN_DB_NODE_FLAGS_DIRTY 0x00000001 |
is set then this node has been altered
Definition at line 207 of file db.h.
Referenced by GWEN_DB_Node_Append(), GWEN_DB_Node_Insert(), GWEN_DB_Node_Unlink(), and GWEN_PathManager_PathChanged().
#define GWEN_DB_NODE_FLAGS_INHERIT_HASH_MECHANISM 0x00000004 |
#define GWEN_DB_NODE_FLAGS_SAFE 0x00000008 |
node has to be disposed of safely (i.e. it will be overridden before freeing it)
Definition at line 214 of file db.h.
Referenced by GWEN_DB_Node_free(), GWEN_PasswordStore__SetPassword(), GWEN_PasswordStore_ClearStoragePasswd(), GWEN_PasswordStore_free(), GWEN_PasswordStore_ReadFile(), GWEN_PasswordStore_SafeFreeDb(), and GWEN_PasswordStore_SetPassword().
#define GWEN_DB_NODE_FLAGS_VOLATILE 0x00000002 |
variable is volatile (will not be written)
Definition at line 209 of file db.h.
Referenced by GWEN_DB_WriteGroupToIoLayer().
typedef struct GWEN_DB_NODE GWEN_DB_NODE |
typedef void*(* GWEN_DB_NODES_CB)(GWEN_DB_NODE *node, void *user_data) |
Callback function type for GWEN_DB_Groups_Foreach(), GWEN_DB_Variables_Foreach(), and GWEN_DB_Values_Foreach().
node | The current node element |
user_data | The arbitrary data passed to the foreach function. |
enum GWEN_DB_NODE_TYPE |
This specifies the type of a value stored in the DB.
GWENHYWFAR_API int GWEN_DB_AddCharValue | ( | GWEN_DB_NODE * | n, |
const char * | path, | ||
const char * | val, | ||
int | senseCase, | ||
int | check | ||
) |
Adds the given char value to the given variable if it not already exists (depending on the arguments senseCase and check).
n | db node |
path | path and name of the variable |
val | The string value that is copied into the DB |
senseCase | if 0 then the case of the value is ignored while checking |
check | if 1 then the variable will be checked for this value |
Definition at line 960 of file db.c.
References DBG_DEBUG, DBG_VERBOUS, GWEN_DB_FLAGS_DEFAULT, GWEN_DB_GetFirstValue(), GWEN_DB_GetNode(), GWEN_DB_Node_Append(), GWEN_DB_NodeType_ValueChar, GWEN_DB_ValueChar_new(), GWEN_LOGDOMAIN, and GWEN_PATH_FLAGS_VARIABLE.
GWENHYWFAR_API int GWEN_DB_AddGroup | ( | GWEN_DB_NODE * | parent, |
GWEN_DB_NODE * | node | ||
) |
Adds the given group node as a new child of the given parent group node.
The group name has no influence on what will happen in this function. In other words, if the parent group already has a child group with the same name as 'node', then after this function two child group nodes with the same name will exist.
parent | Some group node that will be the parent of the added node |
node | Group node to add |
Definition at line 1358 of file db.c.
References DBG_ERROR, GWEN_DB_Node_Append(), GWEN_DB_NodeType_Group, and GWEN_LOGDOMAIN.
GWENHYWFAR_API int GWEN_DB_AddGroupChildren | ( | GWEN_DB_NODE * | n, |
GWEN_DB_NODE * | nn | ||
) |
This function adds all children of the second node as new children to the first given one.
n | db node |
nn | node whose children are to be added (makes deep copies) |
Definition at line 1398 of file db.c.
References DBG_ERROR, DBG_VERBOUS, GWEN_DB_Dump(), GWEN_DB_Node_Append(), GWEN_DB_Node_dup(), GWEN_DB_NodeType_Group, and GWEN_LOGDOMAIN.
Referenced by GWEN_Url_toDb().
GWENHYWFAR_API int GWEN_DB_ClearGroup | ( | GWEN_DB_NODE * | n, |
const char * | path | ||
) |
Frees all children of the given node thereby clearing it.
n | db node |
path | path to the group under the given node to clear (if 0 then clear the given node) |
Definition at line 871 of file db.c.
References DBG_VERBOUS, GWEN_DB_ClearNode(), GWEN_DB_GetNode(), GWEN_LOGDOMAIN, GWEN_PATH_FLAGS_NAMEMUSTEXIST, and GWEN_PATH_FLAGS_PATHMUSTEXIST.
Referenced by GWEN_Gui_Internal_SetPasswordStatus(), GWEN_SyncIo_Http_Read(), and GWEN_SyncIo_Http_SetWriteIdle().
GWENHYWFAR_API int GWEN_DB_DeleteGroup | ( | GWEN_DB_NODE * | n, |
const char * | path | ||
) |
Locates and removes the group of the given name.
n | db node |
path | path to the group to delete |
Definition at line 850 of file db.c.
References DBG_VERBOUS, GWEN_DB_GetNode(), GWEN_DB_Node_free(), GWEN_DB_Node_Unlink(), GWEN_LOGDOMAIN, GWEN_PATH_FLAGS_NAMEMUSTEXIST, and GWEN_PATH_FLAGS_PATHMUSTEXIST.
Referenced by GWEN_PathManager_RemovePaths().
GWENHYWFAR_API int GWEN_DB_DeleteVar | ( | GWEN_DB_NODE * | n, |
const char * | path | ||
) |
Deletes the given variable by removing it and its values from the DB.
n | root of the DB |
path | path to the variable to remove |
Definition at line 828 of file db.c.
References DBG_VERBOUS, GWEN_DB_GetNode(), GWEN_DB_Node_free(), GWEN_DB_Node_Unlink(), GWEN_LOGDOMAIN, GWEN_PATH_FLAGS_NAMEMUSTEXIST, GWEN_PATH_FLAGS_PATHMUSTEXIST, and GWEN_PATH_FLAGS_VARIABLE.
Referenced by GWEN_Crypt_Token_Context_WriteDb(), GWEN_MsgEngine_SetMode(), GWEN_PasswordStore__SetPassword(), and GWEN_StringList2_toDb().
GWENHYWFAR_API void GWEN_DB_Dump | ( | GWEN_DB_NODE * | n, |
int | insert | ||
) |
Dumps the content of the given DB to the given file (e.g. stderr).
n | node to dump |
insert | number of blanks to insert at every line |
Definition at line 1297 of file db.c.
References GWEN_DB_Dump(), GWEN_DB_NodeType_Group, GWEN_DB_NodeType_ValueBin, GWEN_DB_NodeType_ValueChar, GWEN_DB_NodeType_ValueInt, GWEN_DB_NodeType_ValuePtr, GWEN_DB_NodeType_Var, GWEN_Memory_dealloc(), GWEN_Memory_malloc(), and GWEN_Text_ToHex().
Referenced by GWEN_Crypt_KeyRsa_fromModExp(), GWEN_Crypt_KeyRsa_fromModPrivExp(), GWEN_DB_AddGroupChildren(), GWEN_DB_Dump(), GWEN_MsgEngine__WriteElement(), GWEN_MsgEngine__WriteGroup(), GWEN_MsgEngine_ReadMessage(), and GWEN_SyncIo_Tls_GetPeerCert().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_FindFirstGroup | ( | GWEN_DB_NODE * | n, |
const char * | name | ||
) |
Returns the first group node below the given one by name.
If there is no matching group node then NULL is returned. This can either mean that this node does not have any children or the only children are variables instead of groups or their is no group of the given name.
n | db node |
name | name to look for (joker and wildcards allowed) |
Definition at line 1692 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_Group, GWEN_LOGDOMAIN, GWEN_Text_ComparePattern(), and NULL.
Referenced by GWEN_MsgEngine__WriteGroup(), GWEN_PathManager_FindFile(), GWEN_PathManager_GetMatchingFilesRecursively(), GWEN_PathManager_GetPaths(), GWEN_PathManager_RemovePath(), and GWEN_PathManager_RemovePaths().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_FindFirstVar | ( | GWEN_DB_NODE * | n, |
const char * | name | ||
) |
Returns the first variable node below the given one by name.
If there is no matching variable node then NULL is returned. This can either mean that this node does not have any children or the only children are groups/values instead of variables or their is no variable of the given name.
n | db node |
name | name to look for (joker and wildcards allowed) |
Definition at line 1733 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_Group, GWEN_DB_NodeType_Var, GWEN_LOGDOMAIN, GWEN_Text_ComparePattern(), and NULL.
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_FindNextGroup | ( | GWEN_DB_NODE * | n, |
const char * | name | ||
) |
Returns the next group node following the given one, which has the same parent node, by name.
If there is no matching group node then NULL is returned. This can either mean that the parent node does not have any further children, or that the other children are variables instead of groups or that there is no group with the given name.
n | db node |
name | name to look for (joker and wildcards allowed) |
Definition at line 1712 of file db.c.
References DBG_ERROR, GWEN_DB_GetNextGroup(), GWEN_DB_NodeType_Group, GWEN_LOGDOMAIN, GWEN_Text_ComparePattern(), and NULL.
Referenced by GWEN_MsgEngine__WriteGroup(), GWEN_PathManager_FindFile(), GWEN_PathManager_GetMatchingFilesRecursively(), GWEN_PathManager_GetPaths(), GWEN_PathManager_RemovePath(), and GWEN_PathManager_RemovePaths().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_FindNextVar | ( | GWEN_DB_NODE * | n, |
const char * | name | ||
) |
Returns the next variable node following the given one, which has the same parent node, by name.
If there is no matching variable node then NULL is returned. This can either mean that this node does not have any children or the only children are groups/values instead of variables or their is no variable of the given name.
n | db node |
name | name to look for (joker and wildcards allowed) |
Definition at line 1755 of file db.c.
References DBG_ERROR, GWEN_DB_GetNextVar(), GWEN_DB_NodeType_Var, GWEN_LOGDOMAIN, GWEN_Text_ComparePattern(), and NULL.
GWENHYWFAR_API const void* GWEN_DB_GetBinValue | ( | GWEN_DB_NODE * | n, |
const char * | path, | ||
int | idx, | ||
const void * | defVal, | ||
unsigned int | defValSize, | ||
unsigned int * | returnValueSize | ||
) |
Returns the variable's retrieved value. The size of the binary data is written into the int pointer argument returnValueSize.
n | db node |
path | path and name of the variable |
idx | index number of the value to return |
defVal | default value to return in case there is no real value |
defValSize | size of the default value |
returnValueSize | pointer to a variable to receive the length of the data returned |
Definition at line 1120 of file db.c.
References DBG_VERBOUS, GWEN_DB_GetValue(), GWEN_DB_NodeType_ValueBin, and GWEN_LOGDOMAIN.
Referenced by GWEN_Crypt_CryptAlgo_fromDb(), GWEN_Crypt_HashAlgo_fromDb(), GWEN_Crypt_KeyRsa__ReadMpi(), GWEN_Crypt_KeySym__fromDb(), GWEN_Crypt_KeySym_fromDb(), GWEN_MsgEngine__TransformValue(), and GWEN_MsgEngine__WriteElement().
GWENHYWFAR_API const void* GWEN_DB_GetBinValueFromNode | ( | const GWEN_DB_NODE * | n, |
unsigned int * | size | ||
) |
Definition at line 570 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_ValueBin, GWEN_LOGDOMAIN, and NULL.
GWENHYWFAR_API const char* GWEN_DB_GetCharValue | ( | GWEN_DB_NODE * | n, |
const char * | path, | ||
int | idx, | ||
const char * | defVal | ||
) |
Returns the variable's retrieved value.
n | db node |
path | path and name of the variable |
idx | index number of the value to return |
defVal | default value to return in case there is no real value |
Definition at line 897 of file db.c.
References DBG_VERBOUS, GWEN_DB_GetValue(), GWEN_DB_NodeType_ValueChar, and GWEN_LOGDOMAIN.
Referenced by GWEN_Crypt_CryptAlgo_fromDb(), GWEN_Crypt_HashAlgo_fromDb(), GWEN_Crypt_Key_fromDb(), GWEN_Crypt_PaddAlgo_fromDb(), GWEN_Crypt_Token_Context_ReadDb(), GWEN_Date_fromDb(), GWEN_Gui_Internal_GetPassword(), GWEN_HttpSession__RecvPacket(), GWEN_HttpSession__RecvPacketToSio(), GWEN_MsgEngine__TransformValue(), GWEN_MsgEngine__WriteElement(), GWEN_MsgEngine_GetMode(), GWEN_MsgEngine_GetValue(), GWEN_MsgEngine_ReadMessage(), GWEN_PasswordStore__GetPassword(), GWEN_PathManager_FindFile(), GWEN_PathManager_GetMatchingFilesRecursively(), GWEN_PathManager_GetPaths(), GWEN_PathManager_RemovePath(), GWEN_PathManager_RemovePaths(), GWEN_SslCertDescr_ReadDb(), GWEN_StringList2_fromDb(), GWEN_SyncIo_Http_ParseHeader(), GWEN_SyncIo_Http_Read(), GWEN_SyncIo_Http_RecvBody(), GWEN_SyncIo_Http_RecvBodyToSio(), GWEN_SyncIo_Http_Write(), GWEN_SyncIo_Http_WriteCommand(), GWEN_SyncIo_Http_WriteStatus(), GWEN_Url_ReadDb(), HtmlGroup_Box_StartTag(), and HtmlGroup_TableRow_StartTag().
GWENHYWFAR_API const char* GWEN_DB_GetCharValueFromNode | ( | const GWEN_DB_NODE * | n | ) |
Returns the value data of the given value node. If the given node is not a char-value node then 0 is returned.
Definition at line 517 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_ValueChar, GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_SyncIo_Http_WriteHeader(), GWEN_Url_toCommandString(), and GWEN_Url_toString().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_GetFirstGroup | ( | GWEN_DB_NODE * | n | ) |
Returns the first group node below the given one.
If there is no group node then NULL is returned. This can either mean that this node does not have any children or the only children are variables instead of groups.
n | db node |
Definition at line 386 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_Group, GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_DB_Groups_Foreach(), and GWEN_PathManager_RemovePaths().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_GetFirstValue | ( | GWEN_DB_NODE * | n | ) |
Returns the first value below the given variable. If there is no value then NULL is returned.
n | db node |
Definition at line 460 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_ValueChar, GWEN_DB_NodeType_ValueLast, GWEN_DB_NodeType_Var, GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_DB_AddCharValue(), GWEN_DB_GetVariableType(), GWEN_DB_RemoveCharValue(), GWEN_DB_Values_Foreach(), GWEN_SyncIo_Http_WriteHeader(), GWEN_Url_toCommandString(), and GWEN_Url_toString().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_GetFirstVar | ( | GWEN_DB_NODE * | n | ) |
Returns the first variable below the given group. If there is no variable then NULL is returned.
n | db node |
Definition at line 423 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_Group, GWEN_DB_NodeType_Var, GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_DB_Variables_Foreach(), GWEN_SyncIo_Http_WriteHeader(), GWEN_Url_toCommandString(), and GWEN_Url_toString().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_GetGroup | ( | GWEN_DB_NODE * | n, |
uint32_t | flags, | ||
const char * | path | ||
) |
This function either creates a new group, returns an existing one or returns an error if there is no group but the caller wanted one (depending on the flags given).
n | db node |
flags | see GWEN_DB_FLAGS_OVERWRITE_VARS and others which can all be OR-combined to form the flags to use. |
path | path and name of the group to be created/located |
Definition at line 1260 of file db.c.
References DBG_VERBOUS, GWEN_DB_ClearNode(), GWEN_DB_FLAGS_OVERWRITE_GROUPS, GWEN_DB_GetNode(), GWEN_LOGDOMAIN, GWEN_PATH_FLAGS_VARIABLE, and NULL.
Referenced by GWEN_Crypt_KeyRsa_fromDb(), GWEN_Crypt_KeyRsa_fromModExp(), GWEN_Crypt_KeyRsa_fromModPrivExp(), GWEN_Crypt_KeyRsa_toDb(), GWEN_Crypt_KeySym__fromDb(), GWEN_Crypt_KeySym__toDb(), GWEN_Crypt_KeySym_fromDb(), GWEN_Crypt_KeySym_toDb(), GWEN_DB_ReadFromFastBuffer(), GWEN_MsgEngine__ReadGroup(), GWEN_MsgEngine_ReadMessage(), GWEN_PathManager_AddPath(), GWEN_PathManager_DefinePath(), GWEN_PathManager_FindFile(), GWEN_PathManager_GetMatchingFilesRecursively(), GWEN_PathManager_GetPaths(), GWEN_PathManager_InsertPath(), GWEN_PathManager_PathChanged(), GWEN_PathManager_RemovePath(), GWEN_PathManager_UndefinePath(), GWEN_SslCertDescr_ReadDb(), GWEN_SslCertDescr_toDb(), GWEN_Time_fromDb(), GWEN_Time_toDb(), GWEN_Url_ReadDb(), and GWEN_Url_toDb().
GWENHYWFAR_API int GWEN_DB_GetIntValue | ( | GWEN_DB_NODE * | n, |
const char * | path, | ||
int | idx, | ||
int | defVal | ||
) |
Returns the variable's retrieved value.
n | db node |
path | path and name of the variable |
idx | index number of the value to return |
defVal | default value to return in case there is no real value |
Definition at line 1048 of file db.c.
References DBG_ERROR, DBG_INFO, DBG_VERBOUS, GWEN_DB_GetValue(), GWEN_DB_NodeType_ValueChar, GWEN_DB_NodeType_ValueInt, and GWEN_LOGDOMAIN.
Referenced by GWEN_Args_Check(), GWEN_Crypt_CryptAlgo_fromDb(), GWEN_Crypt_Key_fromDb(), GWEN_Crypt_KeyRsa_fromDb(), GWEN_Crypt_PaddAlgo_fromDb(), GWEN_Crypt_Token_Context_ReadDb(), GWEN_DlgInput_Init(), GWEN_DlgMessage_Init(), GWEN_DlgProgress_Init(), GWEN_DlgShowBox_Init(), GWEN_Gui_CGui_CheckCert(), GWEN_MsgEngine__TransformValue(), GWEN_MsgEngine__WriteElement(), GWEN_MsgEngine_GetIntValue(), GWEN_MsgEngine_GetProtocolVersion(), GWEN_MsgEngine_ReadMessage(), GWEN_SslCertDescr_ReadDb(), GWEN_SyncIo_Http_ParseHeader(), GWEN_SyncIo_Http_RecvBody(), GWEN_SyncIo_Http_RecvBodyToSio(), GWEN_SyncIo_Http_WriteHeader(), GWEN_SyncIo_Http_WriteStatus(), GWEN_Time_fromDb(), GWEN_Url_ReadDb(), and HtmlGroup_Box_StartTag().
GWENHYWFAR_API int GWEN_DB_GetIntValueFromNode | ( | const GWEN_DB_NODE * | n | ) |
Definition at line 544 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_ValueChar, GWEN_DB_NodeType_ValueInt, and GWEN_LOGDOMAIN.
Referenced by GWEN_SyncIo_Http_WriteHeader().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_GetNextGroup | ( | GWEN_DB_NODE * | n | ) |
Returns the next group node following the given one, which has the same parent node.
This function works absolutely independently of the group nodes' names – the returned node may or may not have the same name as the specified node. The only guarantee is that the returned node will be a group node.
If there is no group node then NULL is returned. This can either mean that the parent node does not have any further children, or that the other children are variables instead of groups.
n | db node |
Definition at line 406 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_Group, GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_DB_FindNextGroup(), GWEN_DB_Groups_Foreach(), and GWEN_PathManager_RemovePaths().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_GetNextValue | ( | GWEN_DB_NODE * | n | ) |
Returns the next value node following the given one, which has the same parent node.
If there is no value node then NULL is returned. This can either mean that the parent node does not have any further children, or that the other children aren't values.
n | db node |
Definition at line 482 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_ValueChar, GWEN_DB_NodeType_ValueLast, GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_DB_Values_Foreach().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_GetNextVar | ( | GWEN_DB_NODE * | n | ) |
Returns the next variable node following the given one, which has the same parent node.
This function works absolutely independently of the variable nodes' names – the returned node may or may not have the same name as the specified node. The only guarantee is that the returned node will be a variable node.
If there is no variable node then NULL is returned. This can either mean that the parent node does not have any further children, or that the other children are groups instead of variables.
n | db node |
Definition at line 443 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_Var, GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_DB_FindNextVar(), GWEN_DB_Variables_Foreach(), GWEN_SyncIo_Http_WriteHeader(), GWEN_Url_toCommandString(), and GWEN_Url_toString().
GWENHYWFAR_API uint32_t GWEN_DB_GetNodeFlags | ( | const GWEN_DB_NODE * | n | ) |
Returns the node flags for the given db node. Please note that all modifications applied to a node will set the dirty flag in the node itself and all its parents. This allows to use this funcion here to check whether a DB has been modified.
n | db node |
Definition at line 1627 of file db.c.
Referenced by GWEN_PathManager_PathChanged().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_GetParentGroup | ( | GWEN_DB_NODE * | n | ) |
Returns the parent group of the given node.
Definition at line 1680 of file db.c.
References GWEN_DB_NodeType_Group.
GWENHYWFAR_API void* GWEN_DB_GetPtrValue | ( | GWEN_DB_NODE * | n, |
const char * | path, | ||
int | idx, | ||
void * | defVal | ||
) |
Returns the variable's retrieved value.
n | db node |
path | path and name of the variable |
idx | index number of the value to return |
defVal | default value to return in case there is no real value |
Definition at line 1187 of file db.c.
References DBG_VERBOUS, GWEN_DB_GetValue(), GWEN_DB_NodeType_ValuePtr, and GWEN_LOGDOMAIN.
GWENHYWFAR_API GWEN_DB_NODE_TYPE GWEN_DB_GetValueType | ( | GWEN_DB_NODE * | n | ) |
Returns the type of the given value.
n | db node |
Definition at line 503 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_Unknown, GWEN_DB_NodeType_ValueChar, GWEN_DB_NodeType_ValueLast, and GWEN_LOGDOMAIN.
Referenced by GWEN_DB_GetValueTypeByPath(), GWEN_DB_GetVariableType(), and GWEN_SyncIo_Http_WriteHeader().
GWENHYWFAR_API GWEN_DB_NODE_TYPE GWEN_DB_GetValueTypeByPath | ( | GWEN_DB_NODE * | n, |
const char * | p, | ||
unsigned int | i | ||
) |
Definition at line 1481 of file db.c.
References GWEN_DB_GetValue(), GWEN_DB_GetValueType(), and GWEN_DB_NodeType_Unknown.
Referenced by GWEN_MsgEngine__WriteElement().
GWENHYWFAR_API GWEN_DB_NODE_TYPE GWEN_DB_GetVariableType | ( | GWEN_DB_NODE * | n, |
const char * | p | ||
) |
Returns the type of the first value of the given variable
n | root node of the DB |
p | path of the variable to inspect |
Definition at line 1465 of file db.c.
References GWEN_DB_FindVar(), GWEN_DB_GetFirstValue(), GWEN_DB_GetValueType(), and GWEN_DB_NodeType_Unknown.
Referenced by GWEN_MsgEngine__TransformValue().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_Group_dup | ( | const GWEN_DB_NODE * | n | ) |
Creates a deep copy of the given node. This copy will then be owned by the caller and MUST be freed after using it by calling GWEN_DB_Group_free().
n | db node |
Definition at line 375 of file db.c.
References DBG_ERROR, GWEN_DB_Node_dup(), GWEN_DB_NodeType_Group, GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_Url_dup(), GWEN_Url_ReadDb(), and GWEN_Url_SetVars().
GWENHYWFAR_API void GWEN_DB_Group_free | ( | GWEN_DB_NODE * | n | ) |
Frees a DB group. I.e. this is the destructor. This is needed to avoid memory leaks.
n | db node |
Definition at line 369 of file db.c.
References GWEN_DB_Node_free().
Referenced by GWEN_Args_Check(), GWEN_Crypt_KeyRsa_dup(), GWEN_Crypt_KeyRsa_fromModExp(), GWEN_Crypt_KeyRsa_fromModPrivExp(), GWEN_Dialog_free(), GWEN_Gui_CGui_FreeData(), GWEN_Gui_CGui_SetCertDb(), GWEN_Gui_free(), GWEN_Gui_SetPasswordDb(), GWEN_MsgEngine_free(), GWEN_MsgEngine_ReadMessage(), GWEN_PasswordStore_ClearStoragePasswd(), GWEN_PasswordStore_free(), GWEN_PasswordStore_SafeFreeDb(), GWEN_PathManager_ModuleFini(), GWEN_PathManager_RemovePath(), GWEN_PathManager_RemovePaths(), GWEN_PathManager_UndefinePath(), GWEN_SyncIo_Http_FreeData(), GWEN_SyncIo_Tls_GetPeerCert(), GWEN_Url_free(), GWEN_Url_fromCommandString(), GWEN_Url_fromString(), GWEN_Url_ReadDb(), GWEN_Url_SetVars(), HtmlCtx_FreeData(), and HtmlCtx_StartTag().
GWENHYWFAR_API GWEN_DB_NODE* GWEN_DB_Group_new | ( | const char * | name | ) |
Creates a new (empty) group with the given name. I.e. this is the constructor. When finished using this group, you should free it using GWEN_DB_Group_free() in order to avoid memory leaks.
name | name of the group to create |
Definition at line 131 of file db.c.
References GWEN_DB_Node_new(), GWEN_DB_NodeType_Group, and GWEN_Memory_strdup().
Referenced by GWEN_Args_Check(), GWEN_Crypt_KeyRsa_dup(), GWEN_Crypt_KeyRsa_fromModExp(), GWEN_Crypt_KeyRsa_fromModPrivExp(), GWEN_DB_HandlePath(), GWEN_DB_Node_dup(), GWEN_Dialog_new(), GWEN_Gui_CGui_new(), GWEN_Gui_new(), GWEN_MsgEngine_new(), GWEN_MsgEngine_ReadMessage(), GWEN_PasswordStore_ReadFile(), GWEN_PasswordStore_SetPassword(), GWEN_PathManager_ModuleInit(), GWEN_SyncIo_Http_new(), GWEN_SyncIo_Tls_GetPeerCert(), GWEN_Url_fromCommandString(), GWEN_Url_fromString(), GWEN_Url_new(), HtmlCtx_StartTag(), and test10().
GWENHYWFAR_API const char* GWEN_DB_GroupName | ( | GWEN_DB_NODE * | n | ) |
Returns the name of the given group.
Definition at line 1286 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_Group, GWEN_LOGDOMAIN, and NULL.
GWENHYWFAR_API void GWEN_DB_GroupRename | ( | GWEN_DB_NODE * | n, |
const char * | newname | ||
) |
Renames the given group.
n | db node |
newname | new name for the group |
Definition at line 1493 of file db.c.
References GWEN_DB_NodeType_Group, GWEN_Memory_dealloc(), and GWEN_Memory_strdup().
GWENHYWFAR_API unsigned int GWEN_DB_Groups_Count | ( | const GWEN_DB_NODE * | node | ) |
Returns the number of group nodes that are direct children of the given node. In other words, this is the number of group nodes that will be reached in the GWEN_DB_Groups_foreach() function.
Definition at line 1559 of file db.c.
References GWEN_DB_count_cb(), and GWEN_DB_Groups_Foreach().
GWENHYWFAR_API void* GWEN_DB_Groups_Foreach | ( | GWEN_DB_NODE * | node, |
GWEN_DB_NODES_CB | func, | ||
void * | user_data | ||
) |
Iterates through all group nodes that are direct children of the given node, calling the callback function 'func' on each group node. Traversal will stop when 'func' returns a non-NULL value, and the routine will return with that value. Otherwise the routine will return NULL.
If no nodes that are groups are found as children, then this function will simply do nothing.
node | The group node whose children shall be iterated through. |
func | The function to be called with each group node. |
user_data | A pointer passed on to the function 'func'. |
Definition at line 1529 of file db.c.
References GWEN_DB_GetFirstGroup(), GWEN_DB_GetNextGroup(), and NULL.
Referenced by GWEN_DB_Groups_Count().
GWENHYWFAR_API int GWEN_DB_InsertGroup | ( | GWEN_DB_NODE * | parent, |
GWEN_DB_NODE * | node | ||
) |
Adds the given group node as the new first child of the given parent group node.
The group name has no influence on what will happen in this function. In other words, if the parent group already has a child group with the same name as 'node', then after this function two child group nodes with the same name will exist.
parent | Some group node that will be the parent of the added node |
node | Group node to add |
Definition at line 1378 of file db.c.
References DBG_ERROR, GWEN_DB_Node_Insert(), GWEN_DB_NodeType_Group, and GWEN_LOGDOMAIN.
GWENHYWFAR_API int GWEN_DB_IsGroup | ( | const GWEN_DB_NODE * | n | ) |
Predicate: Returns nonzero (TRUE) or zero (FALSE) if the given NODE is a Group or not. Usually these group nodes are the only nodes that the application gets in touch with.
n | db node |
Definition at line 1507 of file db.c.
References GWEN_DB_NodeType_Group.
GWENHYWFAR_API int GWEN_DB_IsValue | ( | const GWEN_DB_NODE * | n | ) |
Predicate: Returns nonzero (TRUE) or zero (FALSE) if the given NODE is a Value or not. Usually the Application does not get in touch with such Nodes but only with nodes that are Groups.
n | db node |
Definition at line 1521 of file db.c.
References GWEN_DB_NodeType_ValueChar, and GWEN_DB_NodeType_ValueLast.
GWENHYWFAR_API int GWEN_DB_IsVariable | ( | const GWEN_DB_NODE * | n | ) |
Predicate: Returns nonzero (TRUE) or zero (FALSE) if the given NODE is a Variable or not. Usually the Application does not get in touch with such Nodes but only with nodes that are Groups.
n | db node |
Definition at line 1514 of file db.c.
References GWEN_DB_NodeType_Var.
GWENHYWFAR_API void GWEN_DB_ModifyBranchFlagsDown | ( | GWEN_DB_NODE * | n, |
uint32_t | newflags, | ||
uint32_t | mask | ||
) |
Modifies the flags of the given node and all its children according to the parameters given.
n | db node |
newflags | new flags to set (see GWEN_DB_NODE_FLAGS_DIRTY) |
mask | only those flags which are set in this mask are modified according to newflags |
Definition at line 1659 of file db.c.
References GWEN_DB_ModifyBranchFlagsDown().
Referenced by GWEN_DB_ModifyBranchFlagsDown(), GWEN_PasswordStore__SetPassword(), GWEN_PasswordStore_ClearStoragePasswd(), GWEN_PasswordStore_free(), GWEN_PasswordStore_ReadFile(), GWEN_PasswordStore_SafeFreeDb(), and GWEN_PasswordStore_SetPassword().
GWENHYWFAR_API void GWEN_DB_ModifyBranchFlagsUp | ( | GWEN_DB_NODE * | n, |
uint32_t | newflags, | ||
uint32_t | mask | ||
) |
Modifies the flags of the given node and all its parents according to the parameters given.
n | db node |
newflags | new flags to set (see GWEN_DB_NODE_FLAGS_DIRTY) |
mask | only those flags which are set in this mask are modified according to newflags |
Definition at line 1642 of file db.c.
Referenced by GWEN_DB_Node_Append(), GWEN_DB_Node_Insert(), and GWEN_DB_Node_Unlink().
GWENHYWFAR_API int GWEN_DB_ReadFile | ( | GWEN_DB_NODE * | n, |
const char * | fname, | ||
uint32_t | dbflags | ||
) |
Definition at line 991 of file dbrw.c.
References DBG_INFO, GWEN_DB_ReadFromIo(), GWEN_LOGDOMAIN, GWEN_SyncIo_AddFlags(), GWEN_SyncIo_Connect(), GWEN_SyncIo_Disconnect(), GWEN_SyncIo_File_CreationMode_OpenExisting, GWEN_SYNCIO_FILE_FLAGS_READ, GWEN_SyncIo_File_new(), and GWEN_SyncIo_free().
GWENHYWFAR_API int GWEN_DB_ReadFileAs | ( | GWEN_DB_NODE * | n, |
const char * | fname, | ||
const char * | type, | ||
GWEN_DB_NODE * | params, | ||
uint32_t | dbflags | ||
) |
Imports a file into a DB using a GWEN_DBIO importer.
n | node to read into (becomes the root of the imported data) |
fname | name of the file to import |
type | GWEN_DBIO type |
params | parameters for the GWEN_DBIO importer (content depends on the importer, may even be NULL for some types) |
dbflags | flags to use while importing (see GWEN_DB_FLAGS_OVERWRITE_VARS and others) |
Definition at line 120 of file dbrw.c.
References DBG_ERROR, DBG_INFO, GWEN_DBIO_GetPlugin(), GWEN_DBIO_Import(), GWEN_ERROR_NOT_SUPPORTED, GWEN_LOGDOMAIN, GWEN_SyncIo_AddFlags(), GWEN_SyncIo_Connect(), GWEN_SyncIo_Disconnect(), GWEN_SyncIo_File_CreationMode_OpenExisting, GWEN_SYNCIO_FILE_FLAGS_READ, GWEN_SyncIo_File_new(), and GWEN_SyncIo_free().
GWENHYWFAR_API int GWEN_DB_ReadFromFastBuffer | ( | GWEN_DB_NODE * | n, |
GWEN_FAST_BUFFER * | fb, | ||
uint32_t | dbflags | ||
) |
Definition at line 767 of file dbrw.c.
References DBG_INFO, GWEN_Buffer_Dump(), GWEN_Buffer_free(), GWEN_Buffer_GetStart(), GWEN_Buffer_GetUsedBytes(), GWEN_Buffer_new(), GWEN_Buffer_Reset(), GWEN_DB__ReadValues(), GWEN_DB_FLAGS_ALLOW_EMPTY_STREAM, GWEN_DB_FLAGS_UNTIL_EMPTY_LINE, GWEN_DB_FLAGS_USE_COLON, GWEN_DB_GetGroup(), GWEN_DB_NodeType_Group, GWEN_DB_UnescapeToBufferTolerant(), GWEN_ERROR_BAD_DATA, GWEN_ERROR_EOF, GWEN_ERROR_GENERIC, GWEN_FastBuffer_ReadLineToBuffer(), GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_DB_ReadFromIo().
GWENHYWFAR_API int GWEN_DB_ReadFromIo | ( | GWEN_DB_NODE * | n, |
GWEN_SYNCIO * | sio, | ||
uint32_t | dbflags | ||
) |
Definition at line 967 of file dbrw.c.
References DBG_INFO, GWEN_DB_FLAGS_DOSMODE, GWEN_DB_ReadFromFastBuffer(), GWEN_FAST_BUFFER_FLAGS_DOSMODE, GWEN_FastBuffer_AddFlags(), GWEN_FastBuffer_free(), GWEN_FastBuffer_new(), and GWEN_LOGDOMAIN.
Referenced by GWEN_DB_ReadFile(), and GWEN_DB_ReadFromString().
GWENHYWFAR_API int GWEN_DB_ReadFromString | ( | GWEN_DB_NODE * | n, |
const char * | str, | ||
int | len, | ||
uint32_t | dbflags | ||
) |
Definition at line 1022 of file dbrw.c.
References DBG_INFO, GWEN_DB_ReadFromIo(), GWEN_LOGDOMAIN, GWEN_SyncIo_free(), and GWEN_SyncIo_Memory_fromBuffer().
Referenced by GWEN_PasswordStore_ReadFile().
GWENHYWFAR_API int GWEN_DB_RemoveCharValue | ( | GWEN_DB_NODE * | n, |
const char * | path, | ||
const char * | val, | ||
int | senseCase | ||
) |
Removes the given char value from the given variable if it exists (depending on the arguments senseCase and check).
n | db node |
path | path and name of the variable |
val | The string value to be removed |
senseCase | if 0 then the case of the value is ignored while checking |
Definition at line 1007 of file db.c.
References DBG_DEBUG, DBG_VERBOUS, GWEN_DB_FLAGS_DEFAULT, GWEN_DB_GetFirstValue(), GWEN_DB_GetNode(), GWEN_DB_Node_free(), GWEN_DB_Node_Unlink(), GWEN_DB_NodeType_ValueChar, GWEN_LOGDOMAIN, and GWEN_PATH_FLAGS_VARIABLE.
GWENHYWFAR_API int GWEN_DB_SetBinValue | ( | GWEN_DB_NODE * | n, |
uint32_t | flags, | ||
const char * | path, | ||
const void * | val, | ||
unsigned int | valSize | ||
) |
n | db node |
path | path and name of the variable |
flags | see GWEN_DB_FLAGS_OVERWRITE_VARS and others which can all be OR-combined to form the flags to use. |
val | The binary data that is copied into the DB. |
valSize | The number of bytes in the binary data value. |
Definition at line 1151 of file db.c.
References DBG_VERBOUS, GWEN_DB_ClearNode(), GWEN_DB_FLAGS_INSERT, GWEN_DB_FLAGS_OVERWRITE_VARS, GWEN_DB_GetNode(), GWEN_DB_Node_Append(), GWEN_DB_Node_Insert(), GWEN_DB_ValueBin_new(), GWEN_LOGDOMAIN, and GWEN_PATH_FLAGS_VARIABLE.
Referenced by GWEN_Crypt_CryptAlgo_toDb(), GWEN_Crypt_HashAlgo_toDb(), GWEN_Crypt_KeyRsa__WriteMpi(), GWEN_Crypt_KeyRsa_fromModExp(), GWEN_Crypt_KeyRsa_fromModPrivExp(), GWEN_Crypt_KeySym__toDb(), GWEN_Crypt_KeySym_toDb(), and GWEN_MsgEngine__ReadGroup().
GWENHYWFAR_API int GWEN_DB_SetCharValue | ( | GWEN_DB_NODE * | n, |
uint32_t | flags, | ||
const char * | path, | ||
const char * | val | ||
) |
n | db node |
flags | see GWEN_DB_FLAGS_OVERWRITE_VARS and others which can all be OR-combined to form the flags to use. |
path | path and name of the variable |
val | The string value that is copied into the DB |
Definition at line 922 of file db.c.
References DBG_VERBOUS, GWEN_DB_ClearNode(), GWEN_DB_FLAGS_INSERT, GWEN_DB_FLAGS_OVERWRITE_VARS, GWEN_DB_GetNode(), GWEN_DB_Node_Append(), GWEN_DB_Node_Insert(), GWEN_DB_ValueChar_new(), GWEN_LOGDOMAIN, and GWEN_PATH_FLAGS_VARIABLE.
Referenced by GWEN_Args_Check(), GWEN_Crypt_CryptAlgo_toDb(), GWEN_Crypt_HashAlgo_toDb(), GWEN_Crypt_Key_toDb(), GWEN_Crypt_KeyRsa_fromModExp(), GWEN_Crypt_KeyRsa_fromModPrivExp(), GWEN_Crypt_PaddAlgo_toDb(), GWEN_Crypt_Token_Context_WriteDb(), GWEN_Date_toDb(), GWEN_Gui_Internal_GetPassword(), GWEN_Gui_Internal_GetSyncIo(), GWEN_HttpSession_Init(), GWEN_HttpSession_SendPacket(), GWEN_MsgEngine__ReadGroup(), GWEN_MsgEngine_SetMode(), GWEN_MsgEngine_SetValue(), GWEN_PasswordStore__SetPassword(), GWEN_PathManager_AddPath(), GWEN_PathManager_InsertPath(), GWEN_SslCertDescr_toDb(), GWEN_StringList2_toDb(), GWEN_SyncIo_Http_ParseCommand(), GWEN_SyncIo_Http_ParseHeader(), GWEN_SyncIo_Http_ParseStatus(), GWEN_Url_fromCommandString(), GWEN_Url_fromString(), GWEN_Url_toDb(), and HtmlCtx_AddAttr().
GWENHYWFAR_API int GWEN_DB_SetCharValueInNode | ( | GWEN_DB_NODE * | n, |
const char * | s | ||
) |
Replaces the current value data of the given node by the new string.
Definition at line 528 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_ValueChar, GWEN_ERROR_INVALID, GWEN_LOGDOMAIN, GWEN_Memory_dealloc(), and GWEN_Memory_strdup().
GWENHYWFAR_API int GWEN_DB_SetIntValue | ( | GWEN_DB_NODE * | n, |
uint32_t | flags, | ||
const char * | path, | ||
int | val | ||
) |
n | db node |
flags | see GWEN_DB_FLAGS_OVERWRITE_VARS and others which can all be OR-combined to form the flags to use. |
path | path and name of the variable |
val | new value |
Definition at line 1086 of file db.c.
References DBG_VERBOUS, GWEN_DB_ClearNode(), GWEN_DB_FLAGS_INSERT, GWEN_DB_FLAGS_OVERWRITE_VARS, GWEN_DB_GetNode(), GWEN_DB_Node_Append(), GWEN_DB_Node_Insert(), GWEN_DB_ValueInt_new(), GWEN_LOGDOMAIN, and GWEN_PATH_FLAGS_VARIABLE.
Referenced by GWEN_Args_Check(), GWEN_Crypt_CryptAlgo_toDb(), GWEN_Crypt_Key_toDb(), GWEN_Crypt_KeyRsa_fromModExp(), GWEN_Crypt_KeyRsa_fromModPrivExp(), GWEN_Crypt_KeyRsa_toDb(), GWEN_Crypt_PaddAlgo_toDb(), GWEN_Crypt_Token_Context_WriteDb(), GWEN_DlgInput_Fini(), GWEN_DlgMessage_Fini(), GWEN_DlgProgress_Fini(), GWEN_DlgShowBox_Fini(), GWEN_Gui_CGui_CheckCert(), GWEN_HttpSession_Init(), GWEN_HttpSession_SendPacket(), GWEN_MsgEngine__ReadGroup(), GWEN_MsgEngine__TransformValue(), GWEN_MsgEngine_ReadMessage(), GWEN_MsgEngine_SetIntValue(), GWEN_MsgEngine_SetProtocolVersion(), GWEN_SslCertDescr_toDb(), GWEN_SyncIo_Http_ParseStatus(), GWEN_Time_toDb(), and GWEN_Url_toDb().
GWENHYWFAR_API void GWEN_DB_SetNodeFlags | ( | GWEN_DB_NODE * | n, |
uint32_t | flags | ||
) |
Modifies the node flags for the given db node
n | db node |
flags | flags to set (see GWEN_DB_NODE_FLAGS_DIRTY) |
GWENHYWFAR_API int GWEN_DB_SetPtrValue | ( | GWEN_DB_NODE * | n, |
uint32_t | flags, | ||
const char * | path, | ||
void * | val | ||
) |
n | db node |
path | path and name of the variable |
flags | see GWEN_DB_FLAGS_OVERWRITE_VARS and others which can all be OR-combined to form the flags to use. |
val | The pointer that is stored within the DB. |
Definition at line 1212 of file db.c.
References DBG_VERBOUS, GWEN_DB_ClearNode(), GWEN_DB_FLAGS_INSERT, GWEN_DB_FLAGS_OVERWRITE_VARS, GWEN_DB_GetNode(), GWEN_DB_Node_Append(), GWEN_DB_Node_Insert(), GWEN_DB_ValuePtr_new(), GWEN_LOGDOMAIN, and GWEN_PATH_FLAGS_VARIABLE.
GWENHYWFAR_API void GWEN_DB_UnlinkGroup | ( | GWEN_DB_NODE * | n | ) |
Unlinks a group (and thereby all its children) from its parent and brothers.
This function DOES NOT free the group, it just unlinks it. You can then use it with e.g. GWEN_DB_AddGroup or other functions to relink it at any other position of even in other DBs.
n | db node |
Definition at line 1427 of file db.c.
References DBG_ERROR, GWEN_DB_Node_Unlink(), GWEN_DB_NodeType_Group, and GWEN_LOGDOMAIN.
Referenced by GWEN_PathManager_RemovePath(), GWEN_PathManager_RemovePaths(), and GWEN_PathManager_UndefinePath().
GWENHYWFAR_API int GWEN_DB_ValueExists | ( | GWEN_DB_NODE * | n, |
const char * | path, | ||
unsigned int | idx | ||
) |
Checks whether the given variable and value exists.
n | root of the DB |
path | path to the variable to check for |
idx | index number of the variable's value to check for |
Definition at line 1457 of file db.c.
References GWEN_DB_GetValue().
Referenced by GWEN_MsgEngine__WriteElement().
GWENHYWFAR_API unsigned int GWEN_DB_Values_Count | ( | const GWEN_DB_NODE * | node | ) |
Returns the number of value nodes that are direct children of the given node. In other words, this is the number of value nodes that will be reached in the GWEN_DB_Values_foreach() function.
Definition at line 1619 of file db.c.
References GWEN_DB_count_cb(), and GWEN_DB_Values_Foreach().
GWENHYWFAR_API void* GWEN_DB_Values_Foreach | ( | GWEN_DB_NODE * | node, |
GWEN_DB_NODES_CB | func, | ||
void * | user_data | ||
) |
Iterates through all value nodes that are direct children of the given node, calling the callback function 'func' on each value node. Traversal will stop when 'func' returns a non-NULL value, and the routine will return with that value. Otherwise the routine will return NULL.
If no nodes that are values are found as children, then this function will simply do nothing.
node | The variable node whose children shall be iterated through. |
func | The function to be called with each group node. |
user_data | A pointer passed on to the function 'func'. |
Definition at line 1597 of file db.c.
References GWEN_DB_GetFirstValue(), GWEN_DB_GetNextValue(), and NULL.
Referenced by GWEN_DB_Values_Count().
GWENHYWFAR_API int GWEN_DB_VariableExists | ( | GWEN_DB_NODE * | n, |
const char * | path | ||
) |
Checks whether the given variable exists.
n | root of the DB |
path | path to the variable to check for |
Definition at line 1437 of file db.c.
References DBG_VERBOUS, GWEN_DB_GetNode(), GWEN_LOGDOMAIN, GWEN_PATH_FLAGS_NAMEMUSTEXIST, GWEN_PATH_FLAGS_PATHMUSTEXIST, and GWEN_PATH_FLAGS_VARIABLE.
Referenced by GWEN_MsgEngine__TransformValue().
GWENHYWFAR_API const char* GWEN_DB_VariableName | ( | GWEN_DB_NODE * | n | ) |
Returns the name of the variable specified by the given node.
n | db node specifying a variable (not a group !) |
Definition at line 1776 of file db.c.
References DBG_ERROR, GWEN_DB_NodeType_Var, GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_SyncIo_Http_WriteHeader(), GWEN_Url_toCommandString(), and GWEN_Url_toString().
GWENHYWFAR_API void GWEN_DB_VariableRename | ( | GWEN_DB_NODE * | n, |
const char * | newname | ||
) |
Definition at line 1787 of file db.c.
References GWEN_DB_NodeType_Var, GWEN_Memory_dealloc(), and GWEN_Memory_strdup().
GWENHYWFAR_API unsigned int GWEN_DB_Variables_Count | ( | const GWEN_DB_NODE * | node | ) |
Returns the number of variable nodes that are direct children of the given node. In other words, this is the number of variable nodes that will be reached in the GWEN_DB_Variables_Foreach() function.
Definition at line 1589 of file db.c.
References GWEN_DB_count_cb(), and GWEN_DB_Variables_Foreach().
GWENHYWFAR_API void* GWEN_DB_Variables_Foreach | ( | GWEN_DB_NODE * | node, |
GWEN_DB_NODES_CB | func, | ||
void * | user_data | ||
) |
Iterates through all variable nodes that are direct children of the given node, calling the callback function 'func' on each variable node. Traversal will stop when 'func' returns a non-NULL value, and the routine will return with that value. Otherwise the routine will return NULL.
If no nodes that are variables are found as children, then this function will simply do nothing.
node | The group node whose children shall be iterated through. |
func | The function to be called with each group node. |
user_data | A pointer passed on to the function 'func'. |
Definition at line 1567 of file db.c.
References GWEN_DB_GetFirstVar(), GWEN_DB_GetNextVar(), and NULL.
Referenced by GWEN_DB_Variables_Count().
GWENHYWFAR_API int GWEN_DB_WriteFile | ( | GWEN_DB_NODE * | n, |
const char * | fname, | ||
uint32_t | dbflags | ||
) |
Definition at line 528 of file dbrw.c.
References DBG_ERROR, DBG_INFO, DBG_WARN, GWEN_DB_DEFAULT_LOCK_TIMEOUT, GWEN_DB_FLAGS_APPEND_FILE, GWEN_DB_FLAGS_LOCKFILE, GWEN_DB_WriteToIo(), GWEN_FSLock_free(), GWEN_FSLock_Lock(), GWEN_FSLock_new(), GWEN_FSLock_ResultOk, GWEN_FSLock_TypeFile, GWEN_FSLock_Unlock(), GWEN_LOGDOMAIN, GWEN_SyncIo_AddFlags(), GWEN_SyncIo_Connect(), GWEN_SyncIo_Disconnect(), GWEN_SyncIo_File_CreationMode_CreateAlways, GWEN_SYNCIO_FILE_FLAGS_APPEND, GWEN_SYNCIO_FILE_FLAGS_READ, GWEN_SYNCIO_FILE_FLAGS_UREAD, GWEN_SYNCIO_FILE_FLAGS_UWRITE, GWEN_SYNCIO_FILE_FLAGS_WRITE, GWEN_SyncIo_File_new(), and GWEN_SyncIo_free().
GWENHYWFAR_API int GWEN_DB_WriteFileAs | ( | GWEN_DB_NODE * | n, |
const char * | fname, | ||
const char * | type, | ||
GWEN_DB_NODE * | params, | ||
uint32_t | dbflags | ||
) |
Exports a DB to a file using a GWEN_DBIO exporter.
n | node to write |
fname | name of the file to export to |
type | GWEN_DBIO type |
params | parameters for the GWEN_DBIO exporter (content depends on the exporter, may even be NULL for some types) |
dbflags | flags to use while exporting (see GWEN_DB_FLAGS_OVERWRITE_VARS and others) |
Definition at line 156 of file dbrw.c.
References DBG_ERROR, DBG_INFO, GWEN_DBIO_ExportToFile(), GWEN_DBIO_GetPlugin(), GWEN_ERROR_NOT_SUPPORTED, and GWEN_LOGDOMAIN.
GWENHYWFAR_API int GWEN_DB_WriteToBuffer | ( | GWEN_DB_NODE * | n, |
GWEN_BUFFER * | buf, | ||
uint32_t | dbflags | ||
) |
Definition at line 1047 of file dbrw.c.
References DBG_INFO, GWEN_DB_WriteToIo(), GWEN_LOGDOMAIN, GWEN_SyncIo_free(), and GWEN_SyncIo_Memory_new().
Referenced by GWEN_PasswordStore_WriteFile().
GWENHYWFAR_API int GWEN_DB_WriteToFastBuffer | ( | GWEN_DB_NODE * | node, |
GWEN_FAST_BUFFER * | fb, | ||
uint32_t | dbflags | ||
) |
Definition at line 492 of file dbrw.c.
References GWEN_DB_WriteGroupToIoLayer(), and GWEN_FASTBUFFER_FLUSH.
GWENHYWFAR_API int GWEN_DB_WriteToIo | ( | GWEN_DB_NODE * | node, |
GWEN_SYNCIO * | sio, | ||
uint32_t | dbflags | ||
) |
Definition at line 507 of file dbrw.c.
References GWEN_DB_FLAGS_DOSMODE, GWEN_DB_WriteGroupToIoLayer(), GWEN_FAST_BUFFER_FLAGS_DOSMODE, GWEN_FastBuffer_AddFlags(), GWEN_FASTBUFFER_FLUSH, GWEN_FastBuffer_free(), and GWEN_FastBuffer_new().
Referenced by GWEN_DB_WriteFile(), and GWEN_DB_WriteToBuffer().