4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file was
f724640,
checked in by Shane Alcock <salcock@…>, 10 years ago
|
- Fix warnings in the skeleton code
|
-
Property mode set to
100644
|
File size:
1.2 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 | |
---|
14 | static void per_packet(libtrace_packet_t *packet) |
---|
15 | { |
---|
16 | /* You really should consider using complete.c instead */ |
---|
17 | assert(packet); |
---|
18 | |
---|
19 | /* Your code goes here */ |
---|
20 | |
---|
21 | } |
---|
22 | |
---|
23 | int main(int argc, char *argv[]) |
---|
24 | { |
---|
25 | libtrace_t *trace; |
---|
26 | libtrace_packet_t *packet; |
---|
27 | |
---|
28 | if (argc<2) { |
---|
29 | fprintf(stderr,"usage: %s libtraceuri\n",argv[0]); |
---|
30 | return 1; |
---|
31 | } |
---|
32 | |
---|
33 | trace = trace_create(argv[1]); |
---|
34 | |
---|
35 | if (trace_is_err(trace)) { |
---|
36 | trace_perror(trace,"Opening trace file"); |
---|
37 | return 1; |
---|
38 | } |
---|
39 | |
---|
40 | if (trace_start(trace)) { |
---|
41 | trace_perror(trace,"Starting trace"); |
---|
42 | trace_destroy(trace); |
---|
43 | return 1; |
---|
44 | } |
---|
45 | |
---|
46 | packet = trace_create_packet(); |
---|
47 | |
---|
48 | while (trace_read_packet(trace,packet)>0) { |
---|
49 | per_packet(packet); |
---|
50 | } |
---|
51 | |
---|
52 | trace_destroy_packet(packet); |
---|
53 | |
---|
54 | if (trace_is_err(trace)) { |
---|
55 | trace_perror(trace,"Reading packets"); |
---|
56 | trace_destroy(trace); |
---|
57 | return 1; |
---|
58 | } |
---|
59 | |
---|
60 | trace_destroy(trace); |
---|
61 | |
---|
62 | return 0; |
---|
63 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.