summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjolsa@redhat.com <jolsa@redhat.com>2011-10-31 16:33:47 +0100
committerJiri Olsa <Jiri Olsa jolsa@redhat.com>2012-01-11 19:55:00 +0100
commit08b50c19820909cc551e56c72ea173ebd09feabc (patch)
treeb3b78a11c52d7b62568ce2def4ca361f41b0aa7f
parentb258ebfcf8e7eaf513b61946242a1211d7559be1 (diff)
downloadlatrace-08b50c19820909cc551e56c72ea173ebd09feabc.tar.gz
latrace-08b50c19820909cc551e56c72ea173ebd09feabc.tar.xz
latrace-08b50c19820909cc551e56c72ea173ebd09feabc.zip
config: adding value list support
-rw-r--r--src/config-bison.y17
-rw-r--r--src/config.c15
-rw-r--r--src/config.h13
3 files changed, 39 insertions, 6 deletions
diff --git a/src/config-bison.y b/src/config-bison.y
index 247a270..c9512ac 100644
--- a/src/config-bison.y
+++ b/src/config-bison.y
@@ -272,13 +272,26 @@ OPTIONS_DEF OPT_ARGS_STRING_POINTER_LENGTH '=' BOOL
list_names_comma:
list_names_comma ',' NAME
{
- if (lt_config_ln_add(&ln_names, $3))
+ if (lt_config_ln_add(&ln_names, $3, 0, LT_CONFIG_LN_NAME))
ABORT("failed to add list name");
}
|
NAME
{
- if (lt_config_ln_add(&ln_names, $1))
+ if (lt_config_ln_add(&ln_names, $1, 0, LT_CONFIG_LN_NAME))
+ ABORT("failed to add list name");
+}
+
+list_values_comma:
+list_values_comma ',' VALUE
+{
+ if (lt_config_ln_add(&ln_names, NULL, $3, LT_CONFIG_LN_VALUE))
+ ABORT("failed to add list name");
+}
+|
+VALUE
+{
+ if (lt_config_ln_add(&ln_names, NULL, $1, LT_CONFIG_LN_VALUE))
ABORT("failed to add list name");
}
diff --git a/src/config.c b/src/config.c
index b04ec2c..7b6ecef 100644
--- a/src/config.c
+++ b/src/config.c
@@ -381,14 +381,25 @@ struct lt_config_opt *lt_config_opt_new(struct lt_config_app *cfg,
return opt;
}
-int lt_config_ln_add(struct lt_list_head *head, char *name)
+int lt_config_ln_add(struct lt_list_head *head,
+ char *name, long val, int type)
{
struct lt_config_ln *ln = malloc(sizeof(*ln));
if (!ln)
return -1;
- ln->name = strdup(name);
+ switch(type) {
+ case LT_CONFIG_LN_NAME:
+ ln->name = strdup(name);
+ break;
+ case LT_CONFIG_LN_VALUE:
+ ln->val = val;
+ break;
+ }
+
+ ln->type = type;
+
lt_init_list_head(&ln->list);
lt_list_add_tail(&ln->list, head);
return 0;
diff --git a/src/config.h b/src/config.h
index 1ac519e..379c7b8 100644
--- a/src/config.h
+++ b/src/config.h
@@ -257,9 +257,18 @@ struct lt_config_audit {
int init_ok;
};
+enum {
+ LT_CONFIG_LN_NAME,
+ LT_CONFIG_LN_VALUE,
+};
+
/* config - list name support */
struct lt_config_ln {
- char *name;
+ union {
+ char *name;
+ long val;
+ };
+ int type;
struct lt_list_head list;
};
@@ -416,7 +425,7 @@ struct lt_symbol* lt_symbol_get(struct lt_config_shared *cfg,
struct lt_config_opt *lt_config_opt_new(struct lt_config_app *cfg,
int idx, char *sval, long nval);
int lt_config_opt_process(struct lt_config_app *cfg, struct lt_list_head *list);
-int lt_config_ln_add(struct lt_list_head *head, char *name);
+int lt_config_ln_add(struct lt_list_head *head, char *name, long val, int type);
int lt_config_ln_fill_buf(struct lt_list_head *head, char *buf, int size);
char **lt_config_ln_fill_array(struct lt_list_head *head);