diff --git a/b2/db.c b/b2/db.c index df793d9..4bf259f 100644 --- a/b2/db.c +++ b/b2/db.c @@ -11,6 +11,7 @@ #include +#include #include #include "util.h" @@ -154,3 +155,20 @@ void part_finalize(struct part *part, const struct field *field) param = next; } } + + +void part_dump(FILE *file, const struct part *part) +{ + const struct param *p; + + fprintf(file, "%s %s\n", part->domain, part->name); + if (part->param) { + fprintf(file, " "); + for (p = part->param; p; p = p->next) { + fprintf(file, " %s=", p->u.field->name); + dump(file, p->u.field->fmt, &p->value); + } + fprintf(file, "\n"); + } + if (part->stock); +} diff --git a/b2/db.h b/b2/db.h index 0adfbb1..4648442 100644 --- a/b2/db.h +++ b/b2/db.h @@ -13,6 +13,9 @@ #ifndef DB_H #define DB_H +#include + + struct exchange { const struct currency *dst; double factor; @@ -63,5 +66,6 @@ struct part *part_lookup(const char *domain, const char *name); struct part *part_add(const char *domain, const char *name); void part_alias(struct part *a, struct part *b); void part_finalize(struct part *part, const struct field *field); +void part_dump(FILE *file, const struct part *part); #endif /* !DB_H */ diff --git a/b2/lang.y b/b2/lang.y index 15a0404..5ed8f57 100644 --- a/b2/lang.y +++ b/b2/lang.y @@ -353,6 +353,7 @@ characteristics: | part characteristics { part_finalize($1, hierarchy); + part_dump(stderr, $1); } ;