| 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 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 24 | * SOFTWARE. |
| 25 | */ |
| 26 | |
| 27 | #include <babeltrace/ctf-text/types.h> |
| 28 | #include <babeltrace/format.h> |
| 29 | #include <babeltrace/babeltrace-internal.h> |
| 30 | #include <inttypes.h> |
| 31 | #include <sys/mman.h> |
| 32 | #include <errno.h> |
| 33 | #include <sys/types.h> |
| 34 | #include <sys/stat.h> |
| 35 | #include <fcntl.h> |
| 36 | #include <dirent.h> |
| 37 | #include <glib.h> |
| 38 | #include <unistd.h> |
| 39 | #include <stdlib.h> |
| 40 | |
| 41 | static |
| 42 | int bt_dummy_write_event(struct bt_stream_pos *ppos, struct ctf_stream_definition *stream) |
| 43 | { |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | static |
| 48 | struct bt_trace_descriptor *bt_dummy_open_trace(const char *path, int flags, |
| 49 | void (*packet_seek)(struct bt_stream_pos *pos, size_t index, |
| 50 | int whence), FILE *metadata_fp) |
| 51 | { |
| 52 | struct ctf_text_stream_pos *pos; |
| 53 | |
| 54 | pos = g_new0(struct ctf_text_stream_pos, 1); |
| 55 | pos->parent.rw_table = NULL; |
| 56 | pos->parent.event_cb = bt_dummy_write_event; |
| 57 | pos->parent.trace = &pos->trace_descriptor; |
| 58 | return &pos->trace_descriptor; |
| 59 | } |
| 60 | |
| 61 | static |
| 62 | int bt_dummy_close_trace(struct bt_trace_descriptor *td) |
| 63 | { |
| 64 | struct ctf_text_stream_pos *pos = |
| 65 | container_of(td, struct ctf_text_stream_pos, |
| 66 | trace_descriptor); |
| 67 | free(pos); |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | static |
| 72 | struct bt_format bt_dummy_format = { |
| 73 | .open_trace = bt_dummy_open_trace, |
| 74 | .close_trace = bt_dummy_close_trace, |
| 75 | }; |
| 76 | |
| 77 | static |
| 78 | void __attribute__((constructor)) bt_dummy_init(void) |
| 79 | { |
| 80 | int ret; |
| 81 | |
| 82 | bt_dummy_format.name = g_quark_from_static_string("dummy"); |
| 83 | ret = bt_register_format(&bt_dummy_format); |
| 84 | assert(!ret); |
| 85 | } |
| 86 | |
| 87 | static |
| 88 | void __attribute__((destructor)) bt_dummy_exit(void) |
| 89 | { |
| 90 | bt_unregister_format(&bt_dummy_format); |
| 91 | } |