6 * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
8 * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
21 #include <babeltrace/format.h>
33 void __attribute__((constructor
)) format_init(void);
34 void __attribute__((destructor
)) format_finalize(void);
37 * Format registry hash table contains the registered formats. Format
38 * registration is typically performed by a format plugin.
39 * TODO: support plugin unload (unregistration of formats).
41 GHashTable
*format_registry
;
43 struct format
*bt_lookup_format(bt_intern_str name
)
47 return g_hash_table_lookup(format_registry
,
48 (gconstpointer
) (unsigned long) name
);
51 static void show_format(gpointer key
, gpointer value
, gpointer user_data
)
53 struct walk_data
*data
= user_data
;
55 fprintf(data
->fp
, "%s%s", data
->iter
? ", " : "",
56 g_quark_to_string((GQuark
) (unsigned long) key
));
60 void bt_fprintf_format_list(FILE *fp
)
62 struct walk_data data
;
67 fprintf(fp
, "Formats available: ");
70 g_hash_table_foreach(format_registry
, show_format
, &data
);
72 fprintf(fp
, "<none>");
76 int bt_register_format(struct format
*format
)
81 if (bt_lookup_format(format
->name
))
84 g_hash_table_insert(format_registry
,
85 (gpointer
) (unsigned long) format
->name
,
90 void format_init(void)
94 format_registry
= g_hash_table_new(g_direct_hash
, g_direct_equal
);
95 assert(format_registry
);
99 void format_finalize(void)
101 g_hash_table_destroy(format_registry
);
This page took 0.032456 seconds and 4 git commands to generate.