Browse Source

Move options declaration + warn fixes

Yann Weber 7 years ago
parent
commit
b0b9e0a77e
3 changed files with 24 additions and 15 deletions
  1. 11
    0
      src/include/ttail_init.h
  2. 3
    12
      src/ttail_init.c
  3. 10
    3
      tests/ttail_search_check.c

+ 11
- 0
src/include/ttail_init.h View File

@@ -14,6 +14,17 @@
14 14
 
15 15
 #include "ttail.h"
16 16
 
17
+#define TTAIL_LONG_OPT {\
18
+	{"verbose", no_argument, 0, 'v'},\
19
+	{"re-prefix", required_argument, 0, 'p'},\
20
+	{"date-format", required_argument, 0, 'f'},\
21
+	{"date-min", required_argument, 0, 'd'},\
22
+	{"date-max", required_argument, 0, 'm'},\
23
+	{"logfile", required_argument, 0, 'l'},\
24
+	{0,	0,	0,	0 }\
25
+}
26
+#define TTAIL_SHORT_OPT "p:f:d:l:m:"
27
+
17 28
 /**@brief Parse cli arguments and return a ttail_t
18 29
  *@param int argc
19 30
  *@param char** argv

+ 3
- 12
src/ttail_init.c View File

@@ -27,18 +27,9 @@ ttail_t *ttail_init(int argc, char **argv)
27 27
 
28 28
 	while(1)
29 29
 	{
30
-		static struct option long_options[] =
31
-		{
32
-			{"verbose", no_argument, 0, 'v'},
33
-			{"re-prefix", required_argument, 0, 'p'},
34
-			{"date-format", required_argument, 0, 'f'},
35
-			{"date-min", required_argument, 0, 'd'},
36
-			{"date-max", required_argument, 0, 'm'},
37
-			{"logfile", required_argument, 0, 'l'},
38
-			{0,	0,	0,	0 }
39
-		};
40
-		opt_i = 0;
41
-		c = getopt_long(argc, argv, "p:f:d:l:m:", long_options, &opt_i);
30
+		static struct option long_options[] = TTAIL_LONG_OPT;
31
+
32
+		c = getopt_long(argc, argv, TTAIL_SHORT_OPT, long_options, &opt_i);
42 33
 		if(c == -1)
43 34
 			break;
44 35
 		

+ 10
- 3
tests/ttail_search_check.c View File

@@ -41,8 +41,8 @@ void setup_closest(void)
41 41
 
42 42
 void setup_closest_fileinit(void)
43 43
 {
44
-	setup_closest();
45 44
 	size_t i;
45
+	setup_closest();
46 46
 	for(i=0; i<5; i++)
47 47
 	{
48 48
 		ttail_add_logfile(ttail, samples[i]);
@@ -146,13 +146,20 @@ START_TEST (test_file_line_start)
146 146
 }
147 147
 END_TEST
148 148
 
149
+/*
150
+	TODO : complete the test + debug
151
+*/
149 152
 START_TEST (test_file_minmax1)
150 153
 {
151 154
 	int r;
155
+	/*
152 156
 	struct tm tm[2];
153
-	printf("%d\n", ttail->logfile_sz);
157
+	*/
158
+	printf("%ld\n", ttail->logfile_sz);
154 159
 	ttail->flag |= TTAIL_FLAG_FORMAT;
155
-	//ttail->fmt = "%b%n%d %H:%M";
160
+	/*
161
+	ttail->fmt = "%b%n%d %H:%M";
162
+	*/
156 163
 	r = _ttail_search_closest_files_init(ttail);
157 164
 	ck_assert_int_eq(r, 0);
158 165
 	/*

Loading…
Cancel
Save