gwenhywfar  4.8.0beta
Typedefs | Functions
Paths
Data Management And Parsing

These functions work on general paths. More...

Typedefs

typedef void *(* GWEN_PATHHANDLERPTR )(const char *entry, void *data, uint32_t flags)
typedef void *(* GWEN_PATHIDXHANDLERPTR )(const char *entry, void *data, int idx, uint32_t flags)

Functions

GWENHYWFAR_API int GWEN_Path_Convert (const char *path, GWEN_BUFFER *buffer, uint32_t flags)
GWENHYWFAR_API void * GWEN_Path_Handle (const char *path, void *data, uint32_t flags, GWEN_PATHHANDLERPTR elementFunction)
GWENHYWFAR_API void * GWEN_Path_HandleWithIdx (const char *path, void *data, uint32_t flags, GWEN_PATHIDXHANDLERPTR elementFunction)

Path Flags

The path flags only use the lower word of the integer. The high word may be used/interpreted by the called function.

#define GWEN_PATH_FLAGS_PATHMUSTEXIST   0x00000001
#define GWEN_PATH_FLAGS_PATHMUSTNOTEXIST   0x00000002
#define GWEN_PATH_FLAGS_PATHCREATE   0x00000004
#define GWEN_PATH_FLAGS_NAMEMUSTEXIST   0x00000008
#define GWEN_PATH_FLAGS_NAMEMUSTNOTEXIST   0x00000010
#define GWEN_PATH_FLAGS_CREATE_GROUP   0x00000020
#define GWEN_PATH_FLAGS_CREATE_VAR   0x00000040
#define GWEN_PATH_FLAGS_VARIABLE   0x00000080
#define GWEN_PATH_FLAGS_ESCAPE   0x00000100
#define GWEN_PATH_FLAGS_UNESCAPE   0x00000100
#define GWEN_PATH_FLAGS_TOLERANT_ESCAPE   0x00000200
#define GWEN_PATH_FLAGS_CONVERT_LAST   0x00000400
#define GWEN_PATH_FLAGS_CHECKROOT   0x00000800
#define GWEN_PATH_FLAGS_NO_IDX   0x00001000
#define GWEN_PATH_FLAGS_RFU1   0x00002000
#define GWEN_PATH_FLAGS_INTERNAL   0x0000c000
#define GWEN_PATH_FLAGS_LAST   0x00004000
#define GWEN_PATH_FLAGS_ROOT   0x00008000

Detailed Description

These functions work on general paths.

A path consists of a list of elements separated by a slash, like in /element1/element2/element3. An element can either be a group or an item. Groups can contain multiple items and groups, but an item can not contain anything. So there can at most be one item, and it must be the last element. An example of how to use these functions is given in the module Database. These functions can also be used with files and folders. In this case a group corresponds to a folder and items correspond to files.

Macro Definition Documentation

#define GWEN_PATH_FLAGS_CHECKROOT   0x00000800

Allows checking for root. If the path begins with a slash ('/') and this flags is set the slash will be included in the first path element passed to the element handler function. Additionally the flag GWEN_PATH_FLAGS_ROOT will be set. Otherwise there will be no check and special treatment of root entries.

Definition at line 142 of file path.h.

Referenced by GWEN_Directory_GetPath(), GWEN_Path_Handle(), and GWEN_Path_HandleWithIdx().

#define GWEN_PATH_FLAGS_CONVERT_LAST   0x00000400

Allow to also escape/unescape the last path element (otherwise it will not be escaped/unescaped).

Definition at line 133 of file path.h.

Referenced by GWEN_Path_Handle(), and GWEN_Path_HandleWithIdx().

#define GWEN_PATH_FLAGS_CREATE_GROUP   0x00000020

if this bit is set then the last element of the path is created in any case (this is for groups). This may lead to double entries of the last element.

Definition at line 96 of file path.h.

Referenced by GWEN_DB_HandlePath(), GWEN_MsgEngine__ReadGroup(), GWEN_MsgEngine_ReadMessage(), GWEN_PathManager_AddPath(), GWEN_PathManager_InsertPath(), and GWEN_XMLNode_HandlePath().

#define GWEN_PATH_FLAGS_CREATE_VAR   0x00000040

if this bit is set then the last element of the path is created in any case (this is for variables). This may lead to double entries of the last element.

Definition at line 103 of file path.h.

Referenced by GWEN_DB_HandlePath(), GWEN_SyncIo_Http_ParseHeader(), and GWEN_XMLNode_HandlePath().

#define GWEN_PATH_FLAGS_ESCAPE   0x00000100

all elements of the path are to be escaped. This is usefull when used with file names etc. It makes sure that the path elements presented to the path element handler function only consist of alphanumeric characters. All other characters are escaped using GWEN_Text_Escape.

Definition at line 121 of file path.h.

Referenced by GWEN_Path_Handle(), and GWEN_Path_HandleWithIdx().

#define GWEN_PATH_FLAGS_INTERNAL   0x0000c000

Definition at line 159 of file path.h.

Referenced by GWEN_Path_Handle(), and GWEN_Path_HandleWithIdx().

#define GWEN_PATH_FLAGS_LAST   0x00004000

this is flagged for the path function. If this is set then the element given is the last one, otherwise it is not.

Definition at line 166 of file path.h.

Referenced by GWEN_DB_HandlePath(), GWEN_Directory_HandlePathElement(), GWEN_Path_AppendPathElement(), GWEN_Path_Handle(), GWEN_Path_HandleWithIdx(), and GWEN_XMLNode_HandlePath().

#define GWEN_PATH_FLAGS_NAMEMUSTEXIST   0x00000008
#define GWEN_PATH_FLAGS_NAMEMUSTNOTEXIST   0x00000010

if this bit is set then the last element of the path MUST NOT exist.

Definition at line 89 of file path.h.

Referenced by GWEN_DB_HandlePath(), GWEN_Directory_HandlePathElement(), and GWEN_XMLNode_HandlePath().

#define GWEN_PATH_FLAGS_NO_IDX   0x00001000

This flag is only used with GWEN_Path_HandleWithIdx to disable index handling.

Definition at line 148 of file path.h.

Referenced by GWEN_Path_HandleWithIdx().

#define GWEN_PATH_FLAGS_PATHCREATE   0x00000004

if this bit is set then the whole path (at any depth!) will be created. This may lead to double entries at any part of the path. You need this in very rare cases, most likely you want GWEN_PATH_FLAGS_NAMEMUSTEXIST.

Definition at line 78 of file path.h.

Referenced by GWEN_DB_HandlePath(), and GWEN_XMLNode_HandlePath().

#define GWEN_PATH_FLAGS_PATHMUSTEXIST   0x00000001
#define GWEN_PATH_FLAGS_PATHMUSTNOTEXIST   0x00000002

if this is set then none of the elements of the path must exist.

Definition at line 70 of file path.h.

Referenced by GWEN_DB_HandlePath(), GWEN_Directory_HandlePathElement(), and GWEN_XMLNode_HandlePath().

#define GWEN_PATH_FLAGS_RFU1   0x00002000

Definition at line 153 of file path.h.

#define GWEN_PATH_FLAGS_ROOT   0x00008000

this is flagged for the path function. If this is set then the element given is within root (in this case the element passed to the element handler funcion will start with a slash), otherwise it is not.

Definition at line 174 of file path.h.

Referenced by GWEN_Path_Handle(), GWEN_Path_HandleWithIdx(), and GWEN_XMLNode_HandlePath().

#define GWEN_PATH_FLAGS_TOLERANT_ESCAPE   0x00000200

Definition at line 127 of file path.h.

Referenced by GWEN_Path_Handle(), and GWEN_Path_HandleWithIdx().

#define GWEN_PATH_FLAGS_UNESCAPE   0x00000100

use the same flag for both escape and unescape

Definition at line 124 of file path.h.

Referenced by GWEN_Path_Handle(), and GWEN_Path_HandleWithIdx().

#define GWEN_PATH_FLAGS_VARIABLE   0x00000080

Typedef Documentation

typedef void*(* GWEN_PATHHANDLERPTR)(const char *entry, void *data, uint32_t flags)

Definition at line 180 of file path.h.

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

Definition at line 184 of file path.h.

Function Documentation

GWENHYWFAR_API int GWEN_Path_Convert ( const char *  path,
GWEN_BUFFER buffer,
uint32_t  flags 
)

Converts the given path according to the given flags. You can use this function to escape, unescape or simply store all path elements within a buffer. The converted path will simply be appended to the given buffer (without any leading slash).

Definition at line 390 of file path.c.

References GWEN_Path_AppendPathElement(), and GWEN_Path_Handle().

GWENHYWFAR_API void* GWEN_Path_Handle ( const char *  path,
void *  data,
uint32_t  flags,
GWEN_PATHHANDLERPTR  elementFunction 
)

This function works on a path according to the given flags. For every element the given function is called. A path consists of multiple elements separated by a slash ("/"), e.g. "first/second/element". This function is used by the DB module but may also be used for any type of path handling (like creating all directories along a given path). This function simply calls the given function for any element as long as that function returns a non-zero value or the path ends. The type of the returned value completely depends on the function called.

Returns
0 on error, !=0 otherwise

Definition at line 39 of file path.c.

References DBG_DEBUG, DBG_ERROR, GWEN_Buffer_AppendByte(), GWEN_Buffer_free(), GWEN_Buffer_GetStart(), GWEN_Buffer_new(), GWEN_Buffer_Reset(), GWEN_Buffer_SetStep(), GWEN_LOGDOMAIN, GWEN_PATH_FLAGS_CHECKROOT, GWEN_PATH_FLAGS_CONVERT_LAST, GWEN_PATH_FLAGS_ESCAPE, GWEN_PATH_FLAGS_INTERNAL, GWEN_PATH_FLAGS_LAST, GWEN_PATH_FLAGS_ROOT, GWEN_PATH_FLAGS_TOLERANT_ESCAPE, GWEN_PATH_FLAGS_UNESCAPE, GWEN_PATH_FLAGS_VARIABLE, GWEN_Text_EscapeToBuffer(), GWEN_Text_EscapeToBufferTolerant(), GWEN_Text_UnescapeToBuffer(), and GWEN_Text_UnescapeToBufferTolerant().

Referenced by GWEN_Directory_GetPath(), and GWEN_Path_Convert().

GWENHYWFAR_API void* GWEN_Path_HandleWithIdx ( const char *  path,
void *  data,
uint32_t  flags,
GWEN_PATHIDXHANDLERPTR  elementFunction 
)