diff options
Diffstat (limited to 'plugins/libparser')
-rw-r--r-- | plugins/libparser/parser.c | 24 | ||||
-rw-r--r-- | plugins/libparser/parser.h | 6 |
2 files changed, 27 insertions, 3 deletions
diff --git a/plugins/libparser/parser.c b/plugins/libparser/parser.c index c49eeb72..54e94d55 100644 --- a/plugins/libparser/parser.c +++ b/plugins/libparser/parser.c @@ -46,12 +46,11 @@ skipws (const char *p) { } const char * -gettoken (const char *p, char *tok) { +gettoken_ext (const char *p, char *tok, const char *specialchars) { const char *c; assert (p); assert (tok); int n = MAX_TOKEN-1; - char specialchars[] = "{}();"; if (!(p = skipws (p))) { return NULL; } @@ -86,6 +85,26 @@ gettoken (const char *p, char *tok) { } const char * +gettoken (const char *p, char *tok) { + char specialchars[] = "{}();"; + return gettoken_ext (p, tok, specialchars); +} + +const char * +gettoken_keyvalue (const char *p, char *key, char *val) { + char specialchars[] = "{}();="; + p = gettoken_ext (p, key, specialchars); + if (!p) { + return NULL; + } + p = gettoken_ext (p, val, specialchars); + if (!p || *val != '=') { + return NULL; + } + return gettoken_ext (p, val, specialchars); +} + +const char * gettoken_warn_eof (const char *p, char *tok) { p = gettoken (p, tok); if (!p) { @@ -104,4 +123,3 @@ gettoken_err_eof (const char *p, char *tok) { return p; } - diff --git a/plugins/libparser/parser.h b/plugins/libparser/parser.h index b0f95169..5c7e5d83 100644 --- a/plugins/libparser/parser.h +++ b/plugins/libparser/parser.h @@ -31,6 +31,12 @@ const char * gettoken (const char *p, char *tok); const char * +gettoken_ext (const char *p, char *tok, const char *specialchars); + +const char * +gettoken_keyvalue (const char *p, char *key, char *val); + +const char * gettoken_warn_eof (const char *p, char *tok); const char * |