source: examples/tracedump/tracedump-libtrace.cc @ d907ff5

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since d907ff5 was d907ff5, checked in by Perry Lorier <perry@…>, 16 years ago

Import tracedump to libtrace

  • Property mode set to 100644
File size: 576 bytes
Line 
1#include <libtrace.h>
2#include <err.h>
3#include <time.h>
4#include "tracedump.h"
5#include <stdio.h>
6
7int main(int argc,char **argv)
8{
9        struct libtrace_t *trace = trace_create(argv[1]);
10        struct libtrace_packet_t packet;
11
12        if (!trace) {
13                errx(1,"Failed to open trace");
14        }
15
16        while(trace_read_packet(trace,&packet)!=-1) {
17                time_t sec = (time_t)trace_get_seconds(&packet);
18                char *link=(char *)trace_get_link(&packet);
19                printf("%s",ctime(&sec));
20                per_packet(trace_get_link_type(&packet),
21                                link,
22                                packet.size-(link-packet.buffer));
23        }
24
25        trace_destroy(trace);
26        return 0;
27}
Note: See TracBrowser for help on using the repository browser.