00001 /************************************************************************************************** 00002 Software License Agreement (BSD License) 00003 00004 Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt 00005 All rights reserved. 00006 00007 Redistribution and use in source and binary forms, with or without modification, are permitted 00008 provided that the following conditions are met: 00009 00010 *Redistributions of source code must retain the above copyright notice, this list of 00011 conditions and the following disclaimer. 00012 *Redistributions in binary form must reproduce the above copyright notice, this list of 00013 conditions and the following disclaimer in the documentation and/or other materials provided 00014 with the distribution. 00015 *Neither the name of the University of Aveiro nor the names of its contributors may be used to 00016 endorse or promote products derived from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 00019 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00020 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00021 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00023 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00024 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00025 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 ***************************************************************************************************/ 00033 #ifndef _LCM_EVENTLOG_H_ 00034 #define _LCM_EVENTLOG_H_ 00035 00036 #include <stdio.h> 00037 #include <inttypes.h> 00038 00039 #ifdef __cplusplus 00040 extern "C" { 00041 #endif 00042 00043 typedef struct _lcm_eventlog_t lcm_eventlog_t; 00044 struct _lcm_eventlog_t 00045 { 00046 FILE *f; 00047 int64_t eventcount; 00048 }; 00049 00050 typedef struct _lcm_eventlog_event_t lcm_eventlog_event_t; 00051 struct _lcm_eventlog_event_t { 00052 int64_t eventnum, timestamp; 00053 int32_t channellen, datalen; 00054 00055 char *channel; 00056 void *data; 00057 }; 00058 00059 // mode must be "r" 00060 lcm_eventlog_t *lcm_eventlog_create(const char *path, const char *mode); 00061 00062 // when you're done with the log, clean up after yourself! 00063 void lcm_eventlog_destroy(lcm_eventlog_t *l); 00064 00065 // read the next event. 00066 lcm_eventlog_event_t *lcm_eventlog_read_next_event(lcm_eventlog_t *l); 00067 00068 // free the structure returned by lcm_eventlog_read_next_event 00069 void lcm_eventlog_free_event(lcm_eventlog_event_t *le); 00070 00071 // seek (approximately) to particular timestamp 00072 int lcm_eventlog_seek_to_timestamp(lcm_eventlog_t *l, int64_t ts); 00073 00074 #ifdef __cplusplus 00075 } 00076 #endif 00077 00078 #endif 00079