6 * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
19 #include <babeltrace/format.h>
30 void __attribute__((constructor
)) format_init(void);
31 void __attribute__((destructor
)) format_finalize(void);
34 * Format registry hash table contains the registered formats. Format
35 * registration is typically performed by a format plugin.
36 * TODO: support plugin unload (unregistration of formats).
38 GHashTable
*format_registry
;
40 struct format
*bt_lookup_format(GQuark qname
)
44 return g_hash_table_lookup(format_registry
,
45 (gconstpointer
) (unsigned long) qname
);
48 static void show_format(gpointer key
, gpointer value
, gpointer user_data
)
50 struct walk_data
*data
= user_data
;
52 fprintf(data
->fp
, "%s%s", data
->iter
? ", " : "",
53 g_quark_to_string((GQuark
) (unsigned long) key
));
57 void bt_fprintf_format_list(FILE *fp
)
59 struct walk_data data
;
64 fprintf(fp
, "Formats available: ");
67 g_hash_table_foreach(format_registry
, show_format
, &data
);
69 fprintf(fp
, "<none>");
73 int bt_register_format(struct format
*format
)
78 if (bt_lookup_format(format
->name
))
81 g_hash_table_insert(format_registry
,
82 (gpointer
) (unsigned long) format
->name
,
87 void format_init(void)
91 format_registry
= g_hash_table_new(g_direct_hash
, g_direct_equal
);
92 assert(format_registry
);
96 void format_finalize(void)
98 g_hash_table_destroy(format_registry
);
This page took 0.029983 seconds and 4 git commands to generate.