source: examples/skeleton/trivial.c @ d025ff7

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

Lots more warnings squashed

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/* Trivial libtrace skeleton program
2 *
3 * This libtrace skeleton has the bare minimum required to write a useful
4 * libtrace program, including error handling.
5 *
6 * If you are going to base your program on anything, you should look at the
7 * complete.c and use that.
8 *
9 */
10#include "libtrace.h"
11#include <stdio.h>
12#include <assert.h>
13
14static void per_packet(libtrace_packet_t *packet)
15{
16        /* You really should consider using complete.c instead */
17
18        /* Your code goes here */
19}
20
21int main(int argc, char *argv[])
22{
23        libtrace_t *trace;
24        libtrace_packet_t *packet;
25
26        if (argc<2) {
27                fprintf(stderr,"usage: %s libtraceuri\n",argv[0]);
28                return 1;
29        }
30
31        trace = trace_create(argv[1]);
32
33        if (trace_is_err(trace)) {
34                trace_perror(trace,"Opening trace file");
35                return 1;
36        }
37
38        if (trace_start(trace)) {
39                trace_perror(trace,"Starting trace");
40                trace_destroy(trace);
41                return 1;
42        }
43
44        packet = trace_create_packet();
45
46        while (trace_read_packet(trace,packet)>0) {
47                per_packet(packet);
48        }
49
50        trace_destroy_packet(packet);
51
52        if (trace_is_err(trace)) {
53                trace_perror(trace,"Reading packets");
54                trace_destroy(trace);
55                return 1;
56        }
57
58        trace_destroy(trace);
59
60        return 0;
61}
Note: See TracBrowser for help on using the repository browser.