path.h File Reference
`#include <gwenhywfar/gwenhywfarapi.h>`
`#include <gwenhywfar/types.h>`
`#include <gwenhywfar/buffer.h>`

Go to the source code of this file.

## Path Flags

The path flags only use the lower word of the integer. The high word may be used/interpreted by the called function.
GWENHYWFAR_API int | GWEN_Path_Convert (const char *path, GWEN_BUFFER *buffer, uint32_t flags)
#define | GWEN_PATH_FLAGS_CHECKROOT 0x00000800
#define | GWEN_PATH_FLAGS_CONVERT_LAST 0x00000400
#define | GWEN_PATH_FLAGS_CREATE_GROUP 0x00000020
#define | GWEN_PATH_FLAGS_CREATE_VAR 0x00000040
#define | GWEN_PATH_FLAGS_ESCAPE 0x00000100
#define | GWEN_PATH_FLAGS_INTERNAL 0x0000c000
#define | GWEN_PATH_FLAGS_LAST 0x00004000
#define | GWEN_PATH_FLAGS_NAMEMUSTEXIST 0x00000008
#define | GWEN_PATH_FLAGS_NAMEMUSTNOTEXIST 0x00000010
#define | GWEN_PATH_FLAGS_NO_IDX 0x00001000
#define | GWEN_PATH_FLAGS_PATHCREATE 0x00000004
#define | GWEN_PATH_FLAGS_PATHMUSTEXIST 0x00000001
#define | GWEN_PATH_FLAGS_PATHMUSTNOTEXIST 0x00000002
#define | GWEN_PATH_FLAGS_RFU1 0x00002000
#define | GWEN_PATH_FLAGS_ROOT 0x00008000
#define | GWEN_PATH_FLAGS_TOLERANT_ESCAPE 0x00000200
#define | GWEN_PATH_FLAGS_UNESCAPE 0x00000100
#define | GWEN_PATH_FLAGS_VARIABLE 0x00000080
GWENHYWFAR_API int | GWEN_Path_GetPathBetween (const char *path1, const char *path2, GWEN_BUFFER *diffBuf)
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)
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)

## Macro Definition Documentation

## GWEN_PATH_FLAGS_CHECKROOT

#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.

## GWEN_PATH_FLAGS_CONVERT_LAST

#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.

## GWEN_PATH_FLAGS_CREATE_GROUP

#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.

## GWEN_PATH_FLAGS_CREATE_VAR

#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.

## GWEN_PATH_FLAGS_ESCAPE

#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.

## GWEN_PATH_FLAGS_INTERNAL

#define GWEN_PATH_FLAGS_INTERNAL 0x0000c000

Definition at line 159 of file path.h.

## GWEN_PATH_FLAGS_LAST

#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.

## GWEN_PATH_FLAGS_NAMEMUSTEXIST

#define GWEN_PATH_FLAGS_NAMEMUSTEXIST 0x00000008

if this bit is set then the last element of the path MUST exist. This implies GWEN_PATH_FLAGS_PATHMUSTEXIST

Definition at line 84 of file path.h.

## GWEN_PATH_FLAGS_NAMEMUSTNOTEXIST

#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.

## GWEN_PATH_FLAGS_NO_IDX

#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.

## GWEN_PATH_FLAGS_PATHCREATE

#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.

## GWEN_PATH_FLAGS_PATHMUSTEXIST

#define GWEN_PATH_FLAGS_PATHMUSTEXIST 0x00000001

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

Definition at line 66 of file path.h.

## GWEN_PATH_FLAGS_PATHMUSTNOTEXIST

#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.

## GWEN_PATH_FLAGS_RFU1

#define GWEN_PATH_FLAGS_RFU1 0x00002000

Definition at line 153 of file path.h.

## GWEN_PATH_FLAGS_ROOT

#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.

## GWEN_PATH_FLAGS_TOLERANT_ESCAPE

#define GWEN_PATH_FLAGS_TOLERANT_ESCAPE 0x00000200

Definition at line 127 of file path.h.

## GWEN_PATH_FLAGS_UNESCAPE

#define GWEN_PATH_FLAGS_UNESCAPE 0x00000100

use the same flag for both escape and unescape

Definition at line 124 of file path.h.

## GWEN_PATH_FLAGS_VARIABLE

#define GWEN_PATH_FLAGS_VARIABLE 0x00000080

a variable is wanted (if this bit is 0 then a group is wanted). This flag is used internally, too. When the path handler function is called by GWEN_Path_Handle then this flag is modified to reflect the type of the current path element.

Definition at line 111 of file path.h.

## Typedef Documentation

## GWEN_PATHHANDLERPTR

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

Definition at line 180 of file path.h.

## GWEN_PATHIDXHANDLERPTR

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

Definition at line 184 of file path.h.

## Function Documentation

## GWEN_Path_Convert()

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).

References GWENHYWFAR_API.

## GWEN_Path_GetPathBetween()

GWENHYWFAR_API int GWEN_Path_GetPathBetween | ( | const char * | path1,
|  | const char * | path2,
|  | GWEN_BUFFER * | diffBuf )

## 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

References GWENHYWFAR_API.

## GWEN_Path_HandleWithIdx()

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

References GWENHYWFAR_API.