/usr/include/lcm/eventlog.h is in liblcm-dev 1.3.1+repack1-1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | #ifndef _LCM_EVENTLOG_H_
#define _LCM_EVENTLOG_H_
#include <stdio.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef LCM_API_FUNCTION
#ifdef WIN32
#define LCM_API_FUNCTION __declspec(dllexport)
#else
#define LCM_API_FUNCTION
#endif // WIN32
#endif // LCM_API_FUNCTION
/**
* @defgroup LcmC_lcm_eventlog_t lcm_eventlog_t
* @ingroup LcmC
* @brief Read and write %LCM log files
*
* @code
* #include <lcm/lcm.h>
* @endcode
*
* Linking: <tt> `pkg-config --libs lcm` </tt>
*
* @{
*/
typedef struct _lcm_eventlog_t lcm_eventlog_t;
struct _lcm_eventlog_t
{
/**
* The underlying file handle. Made available for debugging.
*/
FILE *f;
/**
* Internal counter, keeps track of how many events have been written.
*/
int64_t eventcount;
};
/**
* Represents a single event (message) in a log file.
*/
typedef struct _lcm_eventlog_event_t lcm_eventlog_event_t;
struct _lcm_eventlog_event_t {
/**
* A monotonically increasing number assigned to the message to identify it
* in the log file.
*/
int64_t eventnum;
/**
* Time that the message was received, in microseconds since the UNIX
* epoch
*/
int64_t timestamp;
/**
* Length of @c channel, in bytes
*/
int32_t channellen;
/**
* Length of @c data, in bytes
*/
int32_t datalen;
/**
* Channel that the message was received on
*/
char *channel;
/**
* Raw byte buffer containing the message payload.
*/
void *data;
};
/**
* Open a log file for reading or writing.
*
* @param path Log file to open
* @param mode "r" (read mode), "w" (write mode), or "a" (append mode)
*
* @return a newly allocated lcm_eventlog_t, or NULL on failure.
*/
LCM_API_FUNCTION
lcm_eventlog_t *lcm_eventlog_create(const char *path, const char *mode);
/**
* Read the next event in the log file. Valid in read mode only. Free the
* returned structure with lcm_eventlog_free_event() after use.
*
* @param eventlog The log file object
*
* @return the next event in the log file. Returns NULL when the end of the
* file has been reached or when invalid data is read.
*/
LCM_API_FUNCTION
lcm_eventlog_event_t *lcm_eventlog_read_next_event(lcm_eventlog_t *eventlog);
/**
* Free a structure returned by lcm_eventlog_read_next_event().
*
* @param event A structure returned by lcm_eventlog_read_next_event()
*/
LCM_API_FUNCTION
void lcm_eventlog_free_event(lcm_eventlog_event_t *event);
/**
* Seek (approximately) to a particular timestamp.
*
* @param eventlog The log file object
* @param ts Timestamp of the target event in the log file.
*
* @return 0 on success, -1 on failure
*/
LCM_API_FUNCTION
int lcm_eventlog_seek_to_timestamp(lcm_eventlog_t *eventlog, int64_t ts);
/**
* Write an event into a log file. Valid in write mode only.
*
* @param eventlog The log file object
* @param event The event to write to the file. On return, the eventnum field
* will be filled in for you.
*
* @return 0 on success, -1 on failure.
*/
LCM_API_FUNCTION
int lcm_eventlog_write_event(lcm_eventlog_t *eventlog,
lcm_eventlog_event_t *event);
/**
* Close a log file and release allocated resources.
*
* @param eventlog The log file object
*/
LCM_API_FUNCTION
void lcm_eventlog_destroy(lcm_eventlog_t *eventlog);
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif
|