Commit | Line | Data |
---|---|---|
5400d18f PP |
1 | /* |
2 | * Copyright (C) - 2017 Philippe Proulx <pproulx@efficios.com> | |
3 | * | |
4 | * This library is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU Lesser General Public License as published by the | |
6 | * Free Software Foundation; version 2.1 of the License. | |
7 | * | |
8 | * This library is distributed in the hope that it will be useful, but WITHOUT | |
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License | |
11 | * for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU Lesser General Public License | |
14 | * along with this library; if not, write to the Free Software Foundation, | |
15 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
16 | */ | |
17 | ||
18 | #define _LGPL_SOURCE | |
19 | #include <stdio.h> | |
95983a02 | 20 | #include "signal-helper.h" |
5400d18f PP |
21 | |
22 | #define TRACEPOINT_DEFINE | |
23 | #include "tp.h" | |
24 | ||
25 | int main(int argc, char **argv) | |
26 | { | |
27 | int count; | |
28 | int i; | |
29 | int arg_i; | |
30 | ||
95983a02 JG |
31 | if (set_signal_handler()) { |
32 | return 1; | |
33 | } | |
34 | ||
5400d18f PP |
35 | if (argc <= 3) { |
36 | fprintf(stderr, "Usage: %s COUNT STRING [STRING]...\n", | |
37 | argv[0]); | |
38 | return 1; | |
39 | } | |
40 | ||
41 | if (argc >= 2) { | |
42 | count = atoi(argv[1]); | |
43 | } | |
44 | ||
45 | if (count < 0) { | |
46 | return 0; | |
47 | } | |
48 | ||
49 | for (i = 0, arg_i = 2; i < count; i++) { | |
50 | tracepoint(tp, the_string, i, arg_i, argv[arg_i]); | |
51 | ||
52 | arg_i++; | |
53 | if (arg_i == argc) { | |
54 | arg_i = 2; | |
55 | } | |
95983a02 JG |
56 | if (should_quit) { |
57 | break; | |
58 | } | |
5400d18f PP |
59 | } |
60 | ||
61 | return 0; | |
62 | } |