X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fregistry.c;h=a08b59364548104a93ad1503aac1543fd06b4394;hp=a6fd74b2bc5d3432ba0dae10eb0784753607e411;hb=f57447bdfc29e7390c32661341ef50ae1d9ab208;hpb=0860ab483ea602b4ac8f60a7634b54c3923da1e6 diff --git a/formats/registry.c b/formats/registry.c index a6fd74b2..a08b5936 100644 --- a/formats/registry.c +++ b/formats/registry.c @@ -3,7 +3,9 @@ * * Format Registry * - * Copyright 2010 - Mathieu Desnoyers + * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation + * + * Author: Mathieu Desnoyers * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,6 +23,11 @@ #include #include +struct walk_data { + FILE *fp; + int iter; +}; + static int init_done; void __attribute__((constructor)) format_init(void); void __attribute__((destructor)) format_finalize(void); @@ -42,19 +49,27 @@ struct format *bt_lookup_format(GQuark qname) static void show_format(gpointer key, gpointer value, gpointer user_data) { - FILE *fp = user_data; + struct walk_data *data = user_data; - fprintf(fp, "format: %s\n", + fprintf(data->fp, "%s%s", data->iter ? ", " : "", g_quark_to_string((GQuark) (unsigned long) key)); + data->iter++; } void bt_fprintf_format_list(FILE *fp) { - fprintf(fp, "Formats available:\n"); + struct walk_data data; + + data.fp = fp; + data.iter = 0; + + fprintf(fp, "Formats available: "); if (!init_done) return; - g_hash_table_foreach(format_registry, show_format, fp); - fprintf(fp, "End of formats available.\n"); + g_hash_table_foreach(format_registry, show_format, &data); + if (data.iter == 0) + fprintf(fp, ""); + fprintf(fp, ".\n"); } int bt_register_format(struct format *format)