--- libaitcfg/src/Attic/tools.c 2009/11/11 13:52:30 1.2.4.1 +++ libaitcfg/src/Attic/tools.c 2009/11/11 14:46:36 1.2.4.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: tools.c,v 1.2.4.1 2009/11/11 13:52:30 misho Exp $ +* $Id: tools.c,v 1.2.4.2 2009/11/11 14:46:36 misho Exp $ * *************************************************************************/ #include "global.h" @@ -62,4 +62,32 @@ inline int trim(u_char *psLine) ret += rtrim(psLine); return ret; +} + +// unquot() Unquoted string +inline int unquot(u_char *psLine) +{ + char *pos, *str = NULL; + int flg; + + if (!psLine) + return 0; + + switch (*psLine) { + case '`': + case '"': + case '\'': + str = strdup((char*) psLine + 1); + for (pos = str, flg = 0; *pos; flg = ('\\' == *pos), pos++) { + if (!flg && *pos == *psLine) { + *pos = 0; + strlcpy((char*) psLine, str, strlen((char*) psLine) + 1); + break; + } + } + free(str); + return 1; + } + + return 0; }