aqhome: remove flag AQH_PATH_FLAGS_ROOT
This commit is contained in:
@@ -65,7 +65,7 @@ int test1(GWEN_UNUSED GWEN_TEST_MODULE *mod)
|
||||
{
|
||||
static char path[]="/test1/test2[3]/test3[2]";
|
||||
static PATH_TEST_ENTRY expected[]={
|
||||
{"test1", 0, AQH_PATH_FLAGS_PARSEIDX | AQH_PATH_FLAGS_ROOT},
|
||||
{"test1", 0, AQH_PATH_FLAGS_PARSEIDX},
|
||||
{"test2", 3, AQH_PATH_FLAGS_PARSEIDX},
|
||||
{"test3", 2, AQH_PATH_FLAGS_PARSEIDX | AQH_PATH_FLAGS_LAST},
|
||||
{NULL, 0, 0}
|
||||
@@ -85,7 +85,7 @@ int test2(GWEN_UNUSED GWEN_TEST_MODULE *mod)
|
||||
{
|
||||
static char path[]="/test1/test2[3]/test3[2]";
|
||||
static PATH_TEST_ENTRY expected[]={
|
||||
{"test1", 0, AQH_PATH_FLAGS_ROOT},
|
||||
{"test1", 0, 0},
|
||||
{"test2[3]", 0, 0},
|
||||
{"test3[2]", 0, AQH_PATH_FLAGS_LAST},
|
||||
{NULL, 0, 0}
|
||||
@@ -105,7 +105,7 @@ int test3(GWEN_UNUSED GWEN_TEST_MODULE *mod)
|
||||
{
|
||||
static char path[]="/test1\\/test2[3]/test3[2]/test4[1]";
|
||||
static PATH_TEST_ENTRY expected[]={
|
||||
{"test1/test2", 3, AQH_PATH_FLAGS_PARSEIDX | AQH_PATH_FLAGS_ROOT},
|
||||
{"test1/test2", 3, AQH_PATH_FLAGS_PARSEIDX},
|
||||
{"test3", 2, AQH_PATH_FLAGS_PARSEIDX},
|
||||
{"test4", 1, AQH_PATH_FLAGS_PARSEIDX | AQH_PATH_FLAGS_LAST},
|
||||
{NULL, 0, 0}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
static void *_handleElement(const char *element, void *data, uint32_t flags, AQH_PATH_HANDLERFN fn);
|
||||
static void _getPathBetween(const char *path1, const char *path2, GWEN_BUFFER *diffBuf);
|
||||
|
||||
|
||||
|
||||
@@ -42,12 +43,8 @@ void *AQH_Path_Handle(const char *path, void *data, uint32_t flags, const char *
|
||||
GWEN_STRINGLIST *elementList;
|
||||
|
||||
/* clear internal flags */
|
||||
flags&=~(AQH_PATH_FLAGS_ROOT | AQH_PATH_FLAGS_LAST);
|
||||
flags&=~AQH_PATH_FLAGS_LAST;
|
||||
|
||||
if (*path=='/') {
|
||||
flags|=AQH_PATH_FLAGS_ROOT;
|
||||
path++;
|
||||
}
|
||||
elementList=GWEN_StringList_fromString2(path, delimiters, 0, GWEN_TEXT_FLAGS_CHECK_BACKSLASH | GWEN_TEXT_FLAGS_DEL_QUOTES);
|
||||
if (elementList) {
|
||||
GWEN_STRINGLISTENTRY *se;
|
||||
@@ -74,7 +71,6 @@ void *AQH_Path_Handle(const char *path, void *data, uint32_t flags, const char *
|
||||
}
|
||||
data=result;
|
||||
}
|
||||
flags&=~AQH_PATH_FLAGS_ROOT;
|
||||
se=GWEN_StringListEntry_Next(se);
|
||||
}
|
||||
GWEN_StringList_free(elementList);
|
||||
@@ -135,6 +131,83 @@ void *_handleElement(const char *element, void *data, uint32_t flags, AQH_PATH_H
|
||||
|
||||
|
||||
|
||||
int AQH_Path_GetPathBetween(const char *path1, const char *path2, GWEN_BUFFER *diffBuf)
|
||||
{
|
||||
if (!(path1 && *path1)) {
|
||||
if (path2 && *path2) {
|
||||
GWEN_Buffer_AppendString(diffBuf, path2);
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Both paths are NULL.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(path2 && *path2)) {
|
||||
GWEN_STRINGLIST *sl1;
|
||||
|
||||
sl1=GWEN_StringList_fromString2(path1, "/", 0, GWEN_TEXT_FLAGS_DEL_QUOTES | GWEN_TEXT_FLAGS_CHECK_BACKSLASH);
|
||||
if (sl1) {
|
||||
int cnt;
|
||||
int i;
|
||||
|
||||
cnt=GWEN_StringList_Count(sl1);
|
||||
for (i=0; i<cnt; i++) {
|
||||
if (i>0)
|
||||
GWEN_Buffer_AppendString(diffBuf, "/");
|
||||
GWEN_Buffer_AppendString(diffBuf, "..");
|
||||
}
|
||||
GWEN_StringList_free(sl1);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
_getPathBetween(path1, path2, diffBuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void _getPathBetween(const char *path1, const char *path2, GWEN_BUFFER *diffBuf)
|
||||
{
|
||||
GWEN_STRINGLIST *sl1;
|
||||
GWEN_STRINGLIST *sl2;
|
||||
GWEN_STRINGLISTENTRY *se;
|
||||
int count;
|
||||
int i;
|
||||
|
||||
sl2=GWEN_StringList_fromString2(path2, "/", 0, GWEN_TEXT_FLAGS_DEL_QUOTES | GWEN_TEXT_FLAGS_CHECK_BACKSLASH);
|
||||
sl1=GWEN_StringList_fromString2(path1, "/", 0, GWEN_TEXT_FLAGS_DEL_QUOTES | GWEN_TEXT_FLAGS_CHECK_BACKSLASH);
|
||||
|
||||
GWEN_StringList_RemoveCommonFirstEntries(sl1, sl2);
|
||||
|
||||
count=GWEN_StringList_Count(sl1);
|
||||
for (i=0; i<count; i++) {
|
||||
if (GWEN_Buffer_GetUsedBytes(diffBuf))
|
||||
GWEN_Buffer_AppendString(diffBuf, "/");
|
||||
GWEN_Buffer_AppendString(diffBuf, "..");
|
||||
}
|
||||
GWEN_StringList_free(sl1);
|
||||
|
||||
se=GWEN_StringList_FirstEntry(sl2);
|
||||
while(se) {
|
||||
const char *s;
|
||||
|
||||
s=GWEN_StringListEntry_Data(se);
|
||||
if (s && *s) {
|
||||
if (GWEN_Buffer_GetUsedBytes(diffBuf))
|
||||
GWEN_Buffer_AppendString(diffBuf, "/");
|
||||
GWEN_Buffer_AppendString(diffBuf, s);
|
||||
}
|
||||
|
||||
se=GWEN_StringListEntry_Next(se);
|
||||
}
|
||||
GWEN_StringList_free(sl2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "./path-t.c"
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#define AQH_PATH_FLAGS_VARIABLE 0x02000000
|
||||
#define AQH_PATH_FLAGS_PARSEIDX 0x04000000
|
||||
|
||||
#define AQH_PATH_FLAGS_ROOT 0x40000000
|
||||
#define AQH_PATH_FLAGS_LAST 0x80000000
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user