summaryrefslogtreecommitdiff
path: root/plugins/libparser
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2013-08-18 20:23:27 +0200
committerGravatar waker <wakeroid@gmail.com>2013-08-18 20:23:27 +0200
commitad99a354577d5e0b75958a80bfbdbc090842d45c (patch)
tree888ff44fcaa98a0f1338c91acfd30d9dee36887b /plugins/libparser
parentf6be3c3e63b1736faf54aaf889850543465e5cea (diff)
changed widget storage format to the more usable and extensible key-value pairs
Diffstat (limited to 'plugins/libparser')
-rw-r--r--plugins/libparser/parser.c24
-rw-r--r--plugins/libparser/parser.h6
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 *