cb912a37d153e02650ccc9c90513680c6bf7f67b
[babeltrace.git] / formats / bt-dummy / bt-dummy.c
1 /*
2 * BabelTrace - Dummy Output
3 *
4 * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
5 *
6 * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 *
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:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 */
18
19 #include <babeltrace/ctf-text/types.h>
20 #include <babeltrace/format.h>
21 #include <babeltrace/babeltrace-internal.h>
22 #include <inttypes.h>
23 #include <sys/mman.h>
24 #include <errno.h>
25 #include <sys/types.h>
26 #include <sys/stat.h>
27 #include <fcntl.h>
28 #include <dirent.h>
29 #include <glib.h>
30 #include <unistd.h>
31 #include <stdlib.h>
32
33 static
34 int bt_dummy_write_event(struct stream_pos *ppos, struct ctf_stream_definition *stream)
35 {
36 return 0;
37 }
38
39 static
40 struct trace_descriptor *bt_dummy_open_trace(const char *path, int flags,
41 void (*packet_seek)(struct stream_pos *pos, size_t index,
42 int whence), FILE *metadata_fp)
43 {
44 struct ctf_text_stream_pos *pos;
45
46 pos = g_new0(struct ctf_text_stream_pos, 1);
47 pos->parent.rw_table = NULL;
48 pos->parent.event_cb = bt_dummy_write_event;
49 return &pos->trace_descriptor;
50 }
51
52 static
53 int bt_dummy_close_trace(struct trace_descriptor *td)
54 {
55 struct ctf_text_stream_pos *pos =
56 container_of(td, struct ctf_text_stream_pos,
57 trace_descriptor);
58 free(pos);
59 return 0;
60 }
61
62 static
63 struct format bt_dummy_format = {
64 .open_trace = bt_dummy_open_trace,
65 .close_trace = bt_dummy_close_trace,
66 };
67
68 static
69 void __attribute__((constructor)) bt_dummy_init(void)
70 {
71 int ret;
72
73 bt_dummy_format.name = g_quark_from_static_string("dummy");
74 ret = bt_register_format(&bt_dummy_format);
75 assert(!ret);
76 }
77
78 static
79 void __attribute__((destructor)) bt_dummy_exit(void)
80 {
81 bt_unregister_format(&bt_dummy_format);
82 }
This page took 0.042832 seconds and 3 git commands to generate.