Index: trunk/src_plugins/debug/Plug.tmpasm =================================================================== --- trunk/src_plugins/debug/Plug.tmpasm (revision 1719) +++ trunk/src_plugins/debug/Plug.tmpasm (revision 1720) @@ -1,5 +1,5 @@ put /local/pcb/mod {debug} -put /local/pcb/mod/OBJS [@ $(PLUGDIR)/debug/debug.o @] +put /local/pcb/mod/OBJS [@ $(PLUGDIR)/debug/debug.o $(PLUGDIR)/debug/debug_conf.o @] switch /local/pcb/debug/controls case {buildin} include /local/pcb/tmpasm/buildin; end; Index: trunk/src_plugins/debug/debug.c =================================================================== --- trunk/src_plugins/debug/debug.c (revision 1719) +++ trunk/src_plugins/debug/debug.c (revision 1720) @@ -27,10 +27,35 @@ #include "config.h" #include "global.h" #include "data.h" +#include "debug_conf.h" #include "action_helper.h" #include "plugins.h" +static const char conf_syntax[] = + "djopt(dump, [verbose], [prefix]) - dump the current config tree to stdout\n"; + +static const char conf_help[] = "Perform various operations on the configuration tree."; + + +static int ActionConf(int argc, char **argv, Coord x, Coord y) +{ + char *cmd = argc > 0 ? argv[0] : 0; + if (NSTRCMP(cmd, "dump") == 0) { + int verbose; + const char *prefix = ""; + if (argc > 1) + verbose = atoi(argv[1]); + if (argc > 2) + prefix = argv[2]; + conf_dump(stdout, prefix, verbose); + } +} + + HID_Action debug_action_list[] = { + {"conf", 0, ActionConf, + conf_help, conf_syntax} + , }; static const char *debug_cookie = "debug plugin"; Index: trunk/src_plugins/debug/debug_conf.c =================================================================== --- trunk/src_plugins/debug/debug_conf.c (nonexistent) +++ trunk/src_plugins/debug/debug_conf.c (revision 1720) @@ -0,0 +1,60 @@ +#include "src/conf.h" + +static void conf_dump_(FILE *f, const char *prefix, int verbose, confitem_t *val, conf_native_type_t type, confprop_t *prop, int idx) +{ + switch(type) { + case CFN_STRING: fprintf(f, "%s", val->string[idx] == NULL ? "" : val->string[idx]); break; + case CFN_BOOLEAN: fprintf(f, "%d", val->boolean[idx]); break; + case CFN_INTEGER: fprintf(f, "%ld", val->integer[idx]); break; + case CFN_REAL: fprintf(f, "%f", val->real[idx]); break; + case CFN_COORD: pcb_fprintf(f, "%$mS", val->coord[idx]); break; + case CFN_UNIT: pcb_fprintf(f, "%s", val->unit[idx] == NULL ? "" : val->unit[idx]->suffix); break; + case CFN_COLOR: fprintf(f, "%s", val->color[idx] == NULL ? "" : val->color[idx]); break; + case CFN_LIST: + { + conf_listitem_t *n; + if (conflist_length(val->list) > 0) { + fprintf(f, "{"); + for(n = conflist_first(val->list); n != NULL; n = conflist_next(n)) { + fprintf(f, "{"); + conf_dump_(f, prefix, verbose, &n->val, n->type, &n->prop, 0); + fprintf(f, "};"); + } + fprintf(f, "}"); + } + else + fprintf(f, ""); + } + break; + } + if (verbose) { + fprintf(f, " <file_name, prop[idx].src->line); + } + fprintf(f, ">>"); + } +} + +void conf_dump(FILE *f, const char *prefix, int verbose) +{ + htsp_entry_t *e; + for (e = htsp_first(conf_fields); e; e = htsp_next(conf_fields, e)) { + conf_native_t *node = (conf_native_t *)e->value; + if (node->array_size > 1) { + int n; + for(n = 0; n < node->used; n++) { + fprintf(f, "%s I %s[%d] = ", prefix, e->key, n); + conf_dump_(f, prefix, verbose, &node->val, node->type, node->prop, n); + fprintf(f, "\n"); + } + if (node->used == 0) + fprintf(f, "%s I %s[] = \n", prefix, e->key); + } + else { + fprintf(f, "%s I %s = ", prefix, e->key); + conf_dump_(f, prefix, verbose, &node->val, node->type, node->prop, 0); + fprintf(f, "\n"); + } + } +} Index: trunk/src_plugins/debug/debug_conf.h =================================================================== --- trunk/src_plugins/debug/debug_conf.h (nonexistent) +++ trunk/src_plugins/debug/debug_conf.h (revision 1720) @@ -0,0 +1,3 @@ + +/* Print all configuration items to f, prefixing each line with prefix */ +void conf_dump(FILE *f, const char *prefix, int verbose);