summaryrefslogtreecommitdiffstats
path: root/conf
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-01-19 13:30:19 +0100
committerMartin Mares <mj@ucw.cz>2000-01-19 13:30:19 +0100
commit4b87e256eba51a8711c24fbae501ac7975b4ecd3 (patch)
treeadab4bad12941ac757d7b0a586ab42b7d09b9817 /conf
parentf5ad9f87a389c1167a8468d0190bcf6d3cc33cf6 (diff)
downloadbird-4b87e256eba51a8711c24fbae501ac7975b4ecd3.tar
bird-4b87e256eba51a8711c24fbae501ac7975b4ecd3.zip
Split off general commands to cmds.c.
Added `show symbols' command which dumps whole symbol table together with symbol types etc.
Diffstat (limited to 'conf')
-rw-r--r--conf/cf-lex.l40
-rw-r--r--conf/conf.h2
2 files changed, 42 insertions, 0 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l
index df0f3c1..a54cdd9 100644
--- a/conf/cf-lex.l
+++ b/conf/cf-lex.l
@@ -308,3 +308,43 @@ cf_pop_scope(void)
conf_this_scope = conf_this_scope->next;
ASSERT(conf_this_scope);
}
+
+struct symbol *
+cf_walk_symbols(struct config *cf, struct symbol *sym, int *pos)
+{
+ for(;;)
+ {
+ if (!sym)
+ {
+ if (*pos >= SYM_HASH_SIZE)
+ return NULL;
+ sym = cf->sym_hash[(*pos)++];
+ }
+ else
+ sym = sym->next;
+ if (sym && sym->scope->active)
+ return sym;
+ }
+}
+
+char *
+cf_symbol_class_name(struct symbol *sym)
+{
+ switch (sym->class)
+ {
+ case SYM_VOID:
+ return "undefined";
+ case SYM_PROTO:
+ return "protocol";
+ case SYM_NUMBER:
+ return "numeric constant";
+ case SYM_FUNCTION:
+ return "function";
+ case SYM_FILTER:
+ return "filter";
+ case SYM_TABLE:
+ return "routing table";
+ default:
+ return "unknown type";
+ }
+}
diff --git a/conf/conf.h b/conf/conf.h
index 178cdb6..5b80b0d 100644
--- a/conf/conf.h
+++ b/conf/conf.h
@@ -94,6 +94,8 @@ struct symbol *cf_default_name(char *template, int *counter);
void cf_define_symbol(struct symbol *symbol, int type, void *def);
void cf_push_scope(struct symbol *);
void cf_pop_scope(void);
+struct symbol *cf_walk_symbols(struct config *cf, struct symbol *sym, int *pos);
+char *cf_symbol_class_name(struct symbol *sym);
/* Parser */