gwenhywfar  5.10.1
Macros | Functions
db.c File Reference
#include "db_p.h"
#include <gwenhywfar/misc.h>
#include <gwenhywfar/debug.h>
#include <gwenhywfar/path.h>
#include <gwenhywfar/text.h>
#include <gwenhywfar/dbio.h>
#include <gwenhywfar/fslock.h>
#include <gwenhywfar/fastbuffer.h>
#include <gwenhywfar/syncio_file.h>
#include <gwenhywfar/syncio_memory.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <sys/types.h>
#include "dbrw.c"
Include dependency graph for db.c:

Go to the source code of this file.

Macros

#define DISABLE_DEBUGLOG
 
#define GWEN_DB_NODE_FLAGS_GROUP   0x80000000
 
#define GWEN_DB_NODE_FLAGS_MASK_INTERNAL   0xf0000000
 

Functions

static int GWENHYWFAR_CB _replaceVarsCb (void *cbPtr, const char *name, int index, int maxLen, GWEN_BUFFER *dstBuf)
 
int GWENHYWFAR_CB _replaceVarsCb (void *cbPtr, const char *name, int index, GWEN_UNUSED int maxLen, GWEN_BUFFER *dstBuf)
 
static int _writeVarValueToBuffer (GWEN_DB_NODE *db, const char *name, int index, GWEN_BUFFER *dstBuf)
 
int GWEN_DB_AddCharValue (GWEN_DB_NODE *n, const char *path, const char *val, int senseCase, int check)
 
int GWEN_DB_AddGroup (GWEN_DB_NODE *n, GWEN_DB_NODE *nn)
 
int GWEN_DB_AddGroupChildren (GWEN_DB_NODE *n, GWEN_DB_NODE *nn)
 
int GWEN_DB_ClearGroup (GWEN_DB_NODE *n, const char *path)
 
void GWEN_DB_ClearNode (GWEN_DB_NODE *n)
 
void * GWEN_DB_count_cb (GWEN_UNUSED GWEN_DB_NODE *node, void *user_data)
 
int GWEN_DB_DeleteGroup (GWEN_DB_NODE *n, const char *path)
 
int GWEN_DB_DeleteVar (GWEN_DB_NODE *n, const char *path)
 
void GWEN_DB_Dump (GWEN_DB_NODE *n, int insert)
 
GWEN_DB_NODEGWEN_DB_FindFirstGroup (GWEN_DB_NODE *n, const char *name)
 
GWEN_DB_NODEGWEN_DB_FindFirstVar (GWEN_DB_NODE *n, const char *name)
 
GWEN_DB_NODEGWEN_DB_FindGroup (GWEN_DB_NODE *n, const char *name, int idx)
 
GWEN_DB_NODEGWEN_DB_FindNextGroup (GWEN_DB_NODE *n, const char *name)
 
GWEN_DB_NODEGWEN_DB_FindNextVar (GWEN_DB_NODE *n, const char *name)
 
GWEN_DB_NODEGWEN_DB_FindVar (GWEN_DB_NODE *n, const char *name, int idx)
 
const void * GWEN_DB_GetBinValue (GWEN_DB_NODE *n, const char *path, int idx, const void *defVal, unsigned int defValSize, unsigned int *returnValueSize)
 
const void * GWEN_DB_GetBinValueFromNode (const GWEN_DB_NODE *n, unsigned int *size)
 
const char * GWEN_DB_GetCharValue (GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
 
const char * GWEN_DB_GetCharValueFromNode (const GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_GetFirstGroup (GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_GetFirstValue (GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_GetFirstVar (GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_GetGroup (GWEN_DB_NODE *n, uint32_t flags, const char *path)
 
int GWEN_DB_GetIntValue (GWEN_DB_NODE *n, const char *path, int idx, int defVal)
 
int GWEN_DB_GetIntValueFromNode (const GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_GetNextGroup (GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_GetNextValue (GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_GetNextVar (GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_GetNode (GWEN_DB_NODE *n, const char *path, uint32_t flags)
 
uint32_t GWEN_DB_GetNodeFlags (const GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_GetParentGroup (GWEN_DB_NODE *n)
 
void * GWEN_DB_GetPtrValue (GWEN_DB_NODE *n, const char *path, int idx, void *defVal)
 
GWEN_DB_NODEGWEN_DB_GetValue (GWEN_DB_NODE *n, const char *path, int idx)
 
GWEN_DB_NODE_TYPE GWEN_DB_GetValueType (GWEN_DB_NODE *n)
 
GWEN_DB_NODE_TYPE GWEN_DB_GetValueTypeByPath (GWEN_DB_NODE *n, const char *path, unsigned int i)
 
GWEN_DB_NODE_TYPE GWEN_DB_GetVariableType (GWEN_DB_NODE *n, const char *p)
 
GWEN_DB_NODEGWEN_DB_Group_dup (const GWEN_DB_NODE *n)
 
void GWEN_DB_Group_free (GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_Group_new (const char *name)
 
const char * GWEN_DB_GroupName (GWEN_DB_NODE *n)
 
void GWEN_DB_GroupRename (GWEN_DB_NODE *n, const char *newname)
 
unsigned int GWEN_DB_Groups_Count (const GWEN_DB_NODE *node)
 
void * GWEN_DB_Groups_Foreach (GWEN_DB_NODE *node, GWEN_DB_NODES_CB func, void *user_data)
 
void * GWEN_DB_HandlePath (const char *entry, void *data, int idx, uint32_t flags)
 
int GWEN_DB_InsertGroup (GWEN_DB_NODE *n, GWEN_DB_NODE *nn)
 
int GWEN_DB_IsGroup (const GWEN_DB_NODE *n)
 
int GWEN_DB_IsValue (const GWEN_DB_NODE *n)
 
int GWEN_DB_IsVariable (const GWEN_DB_NODE *n)
 
void GWEN_DB_ModifyBranchFlagsDown (GWEN_DB_NODE *n, uint32_t newflags, uint32_t mask)
 
void GWEN_DB_ModifyBranchFlagsUp (GWEN_DB_NODE *n, uint32_t newflags, uint32_t mask)
 
void GWEN_DB_Node_Append (GWEN_DB_NODE *parent, GWEN_DB_NODE *n)
 
void GWEN_DB_Node_Append_UnDirty (GWEN_DB_NODE *parent, GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_Node_dup (const GWEN_DB_NODE *n)
 
void GWEN_DB_Node_free (GWEN_DB_NODE *n)
 
void GWEN_DB_Node_Insert (GWEN_DB_NODE *parent, GWEN_DB_NODE *n)
 
void GWEN_DB_Node_InsertUnDirty (GWEN_DB_NODE *parent, GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_Node_new (GWEN_DB_NODE_TYPE t)
 
void GWEN_DB_Node_Unlink (GWEN_DB_NODE *n)
 
void GWEN_DB_Node_Unlink_UnDirty (GWEN_DB_NODE *n)
 
int GWEN_DB_RemoveCharValue (GWEN_DB_NODE *n, const char *path, const char *val, int senseCase)
 
int GWEN_DB_ReplaceVars (GWEN_DB_NODE *db, const char *s, GWEN_BUFFER *dbuf)
 
int GWEN_DB_SetBinValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, const void *val, unsigned int valSize)
 
int GWEN_DB_SetCharValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
 
int GWEN_DB_SetCharValueFromInt (GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
 
int GWEN_DB_SetCharValueInNode (GWEN_DB_NODE *n, const char *s)
 
int GWEN_DB_SetIntValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
 
void GWEN_DB_SetNodeFlags (GWEN_DB_NODE *n, uint32_t flags)
 
int GWEN_DB_SetPtrValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, void *val)
 
void GWEN_DB_UnlinkGroup (GWEN_DB_NODE *n)
 
GWEN_DB_NODEGWEN_DB_ValueBin_new (const void *data, unsigned int datasize)
 
GWEN_DB_NODEGWEN_DB_ValueChar_new (const char *data)
 
GWEN_DB_NODEGWEN_DB_ValueChar_newFromInt (int v)
 
int GWEN_DB_ValueExists (GWEN_DB_NODE *n, const char *path, unsigned int i)
 
GWEN_DB_NODEGWEN_DB_ValueInt_new (int data)
 
GWEN_DB_NODEGWEN_DB_ValuePtr_new (void *data)
 
unsigned int GWEN_DB_Values_Count (const GWEN_DB_NODE *node)
 
void * GWEN_DB_Values_Foreach (GWEN_DB_NODE *node, GWEN_DB_NODES_CB func, void *user_data)
 
GWEN_DB_NODEGWEN_DB_Var_new (const char *name)
 
int GWEN_DB_VariableExists (GWEN_DB_NODE *n, const char *path)
 
const char * GWEN_DB_VariableName (GWEN_DB_NODE *n)
 
void GWEN_DB_VariableRename (GWEN_DB_NODE *n, const char *newname)
 
unsigned int GWEN_DB_Variables_Count (const GWEN_DB_NODE *node)
 
void * GWEN_DB_Variables_Foreach (GWEN_DB_NODE *node, GWEN_DB_NODES_CB func, void *user_data)
 
int GWEN_DB_WriteVarValueToBuffer (GWEN_DB_NODE *db, const char *name, int index, GWEN_BUFFER *dstBuf)
 

Macro Definition Documentation

◆ DISABLE_DEBUGLOG

#define DISABLE_DEBUGLOG

Definition at line 30 of file db.c.

◆ GWEN_DB_NODE_FLAGS_GROUP

#define GWEN_DB_NODE_FLAGS_GROUP   0x80000000

Definition at line 62 of file db.c.

◆ GWEN_DB_NODE_FLAGS_MASK_INTERNAL

#define GWEN_DB_NODE_FLAGS_MASK_INTERNAL   0xf0000000

Definition at line 61 of file db.c.

Function Documentation

◆ _replaceVarsCb() [1/2]

static int GWENHYWFAR_CB _replaceVarsCb ( void *  cbPtr,
const char *  name,
int  index,
int  maxLen,
GWEN_BUFFER dstBuf 
)
static

Referenced by GWEN_DB_ReplaceVars().

Here is the caller graph for this function:

◆ _replaceVarsCb() [2/2]

int GWENHYWFAR_CB _replaceVarsCb ( void *  cbPtr,
const char *  name,
int  index,
GWEN_UNUSED int  maxLen,
GWEN_BUFFER dstBuf 
)

Definition at line 1965 of file db.c.

References DBG_INFO, GWEN_DB_WriteVarValueToBuffer(), and GWEN_LOGDOMAIN.

Here is the call graph for this function:

◆ _writeVarValueToBuffer()

int _writeVarValueToBuffer ( GWEN_DB_NODE db,
const char *  name,
int  index,
GWEN_BUFFER dstBuf 
)
static

◆ GWEN_DB_ClearNode()

void GWEN_DB_ClearNode ( GWEN_DB_NODE n)

Definition at line 852 of file db.c.

Referenced by GWEN_DB_ClearGroup(), GWEN_DB_GetGroup(), GWEN_DB_SetBinValue(), GWEN_DB_SetCharValue(), GWEN_DB_SetCharValueFromInt(), GWEN_DB_SetIntValue(), and GWEN_DB_SetPtrValue().

Here is the caller graph for this function:

◆ GWEN_DB_count_cb()

void* GWEN_DB_count_cb ( GWEN_UNUSED GWEN_DB_NODE node,
void *  user_data 
)

Definition at line 1688 of file db.c.

References NULL.

Referenced by GWEN_DB_Groups_Count(), GWEN_DB_Values_Count(), and GWEN_DB_Variables_Count().

Here is the caller graph for this function:

◆ GWEN_DB_FindGroup()

GWEN_DB_NODE* GWEN_DB_FindGroup ( GWEN_DB_NODE n,
const char *  name,
int  idx 
)

Definition at line 650 of file db.c.

References DBG_ERROR, GWEN_DB_NodeType_Group, GWEN_LOGDOMAIN, and NULL.

Referenced by GWEN_DB_HandlePath().

Here is the caller graph for this function:

◆ GWEN_DB_FindVar()

GWEN_DB_NODE* GWEN_DB_FindVar ( GWEN_DB_NODE n,
const char *  name,
int  idx 
)

Definition at line 684 of file db.c.

References DBG_ERROR, GWEN_DB_NodeType_Group, GWEN_DB_NodeType_Var, GWEN_LOGDOMAIN, and NULL.

Referenced by GWEN_DB_GetVariableType(), and GWEN_DB_HandlePath().

Here is the caller graph for this function:

◆ GWEN_DB_GetNode()

GWEN_DB_NODE* GWEN_DB_GetNode ( GWEN_DB_NODE n,
const char *  path,
uint32_t  flags 
)

◆ GWEN_DB_GetValue()

GWEN_DB_NODE* GWEN_DB_GetValue ( GWEN_DB_NODE n,
const char *  path,
int  idx 
)

◆ GWEN_DB_HandlePath()

void* GWEN_DB_HandlePath ( const char *  entry,
void *  data,
int  idx,
uint32_t  flags 
)

◆ GWEN_DB_Node_Append()

void GWEN_DB_Node_Append ( GWEN_DB_NODE parent,
GWEN_DB_NODE n 
)

◆ GWEN_DB_Node_Append_UnDirty()

void GWEN_DB_Node_Append_UnDirty ( GWEN_DB_NODE parent,
GWEN_DB_NODE n 
)

Definition at line 205 of file db.c.

References NULL.

Referenced by GWEN_DB_Node_Append(), and GWEN_DB_Node_dup().

Here is the caller graph for this function:

◆ GWEN_DB_Node_dup()

GWEN_DB_NODE* GWEN_DB_Node_dup ( const GWEN_DB_NODE n)

◆ GWEN_DB_Node_free()

void GWEN_DB_Node_free ( GWEN_DB_NODE n)

◆ GWEN_DB_Node_Insert()

void GWEN_DB_Node_Insert ( GWEN_DB_NODE parent,
GWEN_DB_NODE n 
)

Definition at line 246 of file db.c.

References GWEN_DB_ModifyBranchFlagsUp(), GWEN_DB_NODE_FLAGS_DIRTY, and GWEN_DB_Node_InsertUnDirty().

Referenced by GWEN_DB_HandlePath(), GWEN_DB_InsertGroup(), GWEN_DB_SetBinValue(), GWEN_DB_SetCharValue(), GWEN_DB_SetCharValueFromInt(), GWEN_DB_SetIntValue(), and GWEN_DB_SetPtrValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_DB_Node_InsertUnDirty()

void GWEN_DB_Node_InsertUnDirty ( GWEN_DB_NODE parent,
GWEN_DB_NODE n 
)

Definition at line 231 of file db.c.

References NULL.

Referenced by GWEN_DB_Node_Insert().

Here is the caller graph for this function:

◆ GWEN_DB_Node_new()

GWEN_DB_NODE* GWEN_DB_Node_new ( GWEN_DB_NODE_TYPE  t)

◆ GWEN_DB_Node_Unlink()

void GWEN_DB_Node_Unlink ( GWEN_DB_NODE n)

Definition at line 274 of file db.c.

References GWEN_DB_ModifyBranchFlagsUp(), GWEN_DB_NODE_FLAGS_DIRTY, and GWEN_DB_Node_Unlink_UnDirty().

Referenced by GWEN_DB_DeleteGroup(), GWEN_DB_DeleteVar(), GWEN_DB_RemoveCharValue(), and GWEN_DB_UnlinkGroup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_DB_Node_Unlink_UnDirty()

void GWEN_DB_Node_Unlink_UnDirty ( GWEN_DB_NODE n)

Definition at line 257 of file db.c.

References DBG_WARN, GWEN_LOGDOMAIN, and NULL.

Referenced by GWEN_DB_Node_Unlink().

Here is the caller graph for this function:

◆ GWEN_DB_ValueBin_new()

GWEN_DB_NODE* GWEN_DB_ValueBin_new ( const void *  data,
unsigned int  datasize 
)

Definition at line 101 of file db.c.

References GWEN_DB_Node_new(), GWEN_DB_NodeType_ValueBin, and GWEN_Memory_malloc().

Referenced by GWEN_DB__ReadValues(), GWEN_DB_Node_dup(), and GWEN_DB_SetBinValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_DB_ValueChar_new()

GWEN_DB_NODE* GWEN_DB_ValueChar_new ( const char *  data)

Definition at line 130 of file db.c.

References GWEN_DB_Node_new(), GWEN_DB_NodeType_ValueChar, and GWEN_Memory_strdup().

Referenced by GWEN_DB__ReadValues(), GWEN_DB_AddCharValue(), GWEN_DB_Node_dup(), and GWEN_DB_SetCharValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_DB_ValueChar_newFromInt()

GWEN_DB_NODE* GWEN_DB_ValueChar_newFromInt ( int  v)

Definition at line 144 of file db.c.

References GWEN_DB_Node_new(), GWEN_DB_NodeType_ValueChar, and GWEN_Memory_strdup().

Referenced by GWEN_DB_SetCharValueFromInt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_DB_ValueInt_new()

GWEN_DB_NODE* GWEN_DB_ValueInt_new ( int  data)

Definition at line 119 of file db.c.

References GWEN_DB_Node_new(), and GWEN_DB_NodeType_ValueInt.

Referenced by GWEN_DB__ReadValues(), GWEN_DB_Node_dup(), and GWEN_DB_SetIntValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_DB_ValuePtr_new()

GWEN_DB_NODE* GWEN_DB_ValuePtr_new ( void *  data)

Definition at line 162 of file db.c.

References GWEN_DB_Node_new(), and GWEN_DB_NodeType_ValuePtr.

Referenced by GWEN_DB_Node_dup(), and GWEN_DB_SetPtrValue().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GWEN_DB_Var_new()

GWEN_DB_NODE* GWEN_DB_Var_new ( const char *  name)

Definition at line 189 of file db.c.

References GWEN_DB_Node_new(), GWEN_DB_NodeType_Var, and GWEN_Memory_strdup().

Referenced by GWEN_DB_HandlePath(), and GWEN_DB_Node_dup().

Here is the call graph for this function:
Here is the caller graph for this function: