format.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef _BABELTRACE_FORMAT_H
  2. #define _BABELTRACE_FORMAT_H
  3. /*
  4. * BabelTrace
  5. *
  6. * Trace Format Header
  7. *
  8. * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
  9. *
  10. * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  11. *
  12. * Permission is hereby granted, free of charge, to any person obtaining a copy
  13. * of this software and associated documentation files (the "Software"), to deal
  14. * in the Software without restriction, including without limitation the rights
  15. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  16. * copies of the Software, and to permit persons to whom the Software is
  17. * furnished to do so, subject to the following conditions:
  18. *
  19. * The above copyright notice and this permission notice shall be included in
  20. * all copies or substantial portions of the Software.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  25. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  27. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  28. * SOFTWARE.
  29. */
  30. #include <babeltrace/list.h>
  31. #include <babeltrace/clock-types.h>
  32. #include <stdint.h>
  33. #include <stdio.h>
  34. #ifdef __cplusplus
  35. extern "C" {
  36. #endif
  37. typedef int bt_intern_str;
  38. /* forward declaration */
  39. struct bt_stream_pos;
  40. struct bt_context;
  41. struct bt_trace_handle;
  42. struct bt_trace_descriptor;
  43. struct bt_mmap_stream {
  44. int fd;
  45. struct bt_list_head list;
  46. void *priv;
  47. };
  48. struct bt_mmap_stream_list {
  49. struct bt_list_head head;
  50. };
  51. struct bt_format {
  52. bt_intern_str name;
  53. struct bt_trace_descriptor *(*open_trace)(const char *path, int flags,
  54. void (*packet_seek)(struct bt_stream_pos *pos,
  55. size_t index, int whence),
  56. FILE *metadata_fp);
  57. struct bt_trace_descriptor *(*open_mmap_trace)(
  58. struct bt_mmap_stream_list *mmap_list,
  59. void (*packet_seek)(struct bt_stream_pos *pos,
  60. size_t index, int whence),
  61. FILE *metadata_fp);
  62. int (*close_trace)(struct bt_trace_descriptor *descriptor);
  63. void (*set_context)(struct bt_trace_descriptor *descriptor,
  64. struct bt_context *ctx);
  65. void (*set_handle)(struct bt_trace_descriptor *descriptor,
  66. struct bt_trace_handle *handle);
  67. uint64_t (*timestamp_begin)(struct bt_trace_descriptor *descriptor,
  68. struct bt_trace_handle *handle, enum bt_clock_type type);
  69. uint64_t (*timestamp_end)(struct bt_trace_descriptor *descriptor,
  70. struct bt_trace_handle *handle, enum bt_clock_type type);
  71. int (*convert_index_timestamp)(struct bt_trace_descriptor *descriptor);
  72. };
  73. extern struct bt_format *bt_lookup_format(bt_intern_str qname);
  74. extern void bt_fprintf_format_list(FILE *fp);
  75. extern int bt_register_format(struct bt_format *format);
  76. extern void bt_unregister_format(struct bt_format *format);
  77. #ifdef __cplusplus
  78. }
  79. #endif
  80. #endif /* _BABELTRACE_FORMAT_H */