diff --git a/b2/db.c b/b2/db.c index 1d9c98f..f3a2486 100644 --- a/b2/db.c +++ b/b2/db.c @@ -168,6 +168,9 @@ void part_add_stock(struct part *part, struct stock *s) } +/* ----- Dumping ----------------------------------------------------------- */ + + static void dump_stock(FILE *file, const struct stock *s) { const struct price *p; @@ -199,6 +202,23 @@ void part_dump(FILE *file, const struct part *part) } +static gboolean dump_prm_traverse(gpointer key, gpointer value, gpointer data) +{ + struct part *p = key; + FILE *file = data; + + (void) value; + part_dump(file, p); + return FALSE; +} + + +void parts_dump(FILE *file) +{ + g_tree_foreach(tree, dump_prm_traverse, (void *) file); +} + + /* ----- Currencies -------------------------------------------------------- */ diff --git a/b2/db.h b/b2/db.h index 509d613..467dc01 100644 --- a/b2/db.h +++ b/b2/db.h @@ -98,6 +98,7 @@ void part_alias(struct part *a, struct part *b); void part_finalize(struct part *part, const struct action *act); void part_add_stock(struct part *part, struct stock *s); void part_dump(FILE *file, const struct part *part); +void parts_dump(FILE *file); const struct currency *currency_lookup(const char *name); double currency_convert(const struct currency *from, const struct currency *to,