aqhome: remove flag AQH_PATH_FLAGS_ROOT
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user