source: examples/skeleton/trivial.c @ 34ee7eb

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

Make it more obvious in "trivial.c" that you should use "complete.c"
Complete.c now supports --libtrace-help to be more in line with the rest of the
libtrace tools.

  • 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
13void per_packet(libtrace_packet_t *packet)
14{
15        /* You really should consider using complete.c instead */
16
17        /* Your code goes here */
18}
19
20int main(int argc, char *argv[])
21{
22        libtrace_t *trace;
23        libtrace_packet_t *packet;
24
25        if (argc<2) {
26                fprintf(stderr,"usage: %s libtraceuri\n",argv[0]);
27                return 1;
28        }
29
30        trace = trace_create(argv[1]);
31
32        if (trace_is_err(trace)) {
33                trace_perror(trace,"Opening trace file");
34                return 1;
35        }
36
37        if (trace_start(trace)) {
38                trace_perror(trace,"Starting trace");
39                trace_destroy(trace);
40                return 1;
41        }
42
43        packet = trace_create_packet();
44
45        while (trace_read_packet(trace,packet)>0) {
46                per_packet(packet);
47        }
48
49        trace_destroy_packet(packet);
50
51        if (trace_is_err(trace)) {
52                trace_perror(trace,"Reading packets");
53                trace_destroy(trace);
54                return 1;
55        }
56
57        trace_destroy(trace);
58
59        return 0;
60}
Note: See TracBrowser for help on using the repository browser.