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
 
14
 
15
 #include "ttail.h"
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
 /**@brief Parse cli arguments and return a ttail_t
28
 /**@brief Parse cli arguments and return a ttail_t
18
  *@param int argc
29
  *@param int argc
19
  *@param char** argv
30
  *@param char** argv

+ 3
- 12
src/ttail_init.c View File

27
 
27
 
28
 	while(1)
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
 		if(c == -1)
33
 		if(c == -1)
43
 			break;
34
 			break;
44
 		
35
 		

+ 10
- 3
tests/ttail_search_check.c View File

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

Loading…
Cancel
Save