Browse Source

File splitting

Yann Weber 7 years ago
parent
commit
2a80bded28
8 changed files with 72 additions and 54 deletions
  1. 1
    1
      configure.ac
  2. 2
    2
      src/Makefile.am
  3. 0
    49
      src/include/ttail.h
  4. 65
    0
      src/include/ttail_init.h
  5. 1
    0
      src/main.c
  6. 1
    1
      src/ttail_init.c
  7. 1
    0
      tests/ttail_argparse_check.c
  8. 1
    1
      tests/ttail_init_check.c

+ 1
- 1
configure.ac View File

@@ -15,7 +15,7 @@ esac],[debug=false])
15 15
 AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])
16 16
 
17 17
 AC_CONFIG_HEADERS([src/include/config.h])
18
-AC_CONFIG_SRCDIR([src/ttail.c])
18
+AC_CONFIG_SRCDIR([src/main.c])
19 19
 AC_CONFIG_MACRO_DIR([m4])
20 20
 
21 21
 # Checks for programs.

+ 2
- 2
src/Makefile.am View File

@@ -1,5 +1,5 @@
1 1
 bin_PROGRAMS = ttail
2 2
 noinst_LIBRARIES=libttail.a
3 3
 
4
-libttail_a_SOURCES = ttail.c
5
-ttail_SOURCES = main.c ttail.c
4
+libttail_a_SOURCES = ttail_init.c
5
+ttail_SOURCES = main.c ttail_init.c

+ 0
- 49
src/include/ttail.h View File

@@ -41,53 +41,4 @@ struct _ttail_s
41 41
 };
42 42
 typedef struct _ttail_s ttail_t;
43 43
 
44
-
45
-/**@brief Parse cli arguments and return a ttail_t
46
- *@param int argc
47
- *@param char** argv
48
- *@return NULL on error
49
- */
50
-ttail_t *ttail_init(int argc, char **argv);
51
-
52
-/**@brief Checks that init lead to a valid runtime
53
- *@param ttail_t* t
54
- *@return 0 if no error -1 if fatal error
55
- */
56
-int ttail_init_check(ttail_t*);
57
-
58
-/**@brief Add a logfile
59
- *@param ttail_t*
60
- *@param const char * filename
61
- *@return 0 if no errors 1 if unable to open file -1 if fatal error
62
- */
63
-int ttail_add_logfile(ttail_t*, const char*);
64
-
65
-/**@brief Set a date prefix regex
66
- *@param ttail_t*
67
- *@param const char * regex
68
- *@return 0 if no errors 1 if allready set -1 if compilation fails
69
- */
70
-int ttail_set_prefix(ttail_t*, const char*);
71
-
72
-/**@brief Set dates min/max
73
- *
74
- *After the call dates are free and set to NULL except if error
75
- *@param ttail_t ttail instance
76
- *@param char*[2] dates {min,max} both can be NULL
77
- *@return -1 if error 0 else
78
- */
79
-int ttail_set_dates(ttail_t*, char*[2]);
80
-
81
-/**@brief Attempt to guess a dateformat
82
- *@param ttail_t* ttail if manage to guess set the ttail_t.fmt
83
- *@param const char* date as a dtring
84
- *@param struct tm* if non NULL will be set to detected date
85
- *@return -1 if no guess -2 if fmt already set else id in TTAIL_DEFAULT_FORMATS
86
- */
87
-int ttail_format_guess(ttail_t*, const char*, struct tm*);
88
-
89
-
90
-void ttail_free(ttail_t*);
91
-
92
-
93 44
 #endif

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

@@ -0,0 +1,65 @@
1
+#ifndef _ttail_init_h__
2
+#define _ttail_init_h__
3
+
4
+#include <ctype.h>
5
+#include <errno.h>
6
+#include <getopt.h>
7
+#include <regex.h>
8
+#include <stdio.h>
9
+#include <stdlib.h>
10
+#include <string.h>
11
+#include <sys/types.h>
12
+#include <time.h>
13
+#include <unistd.h>
14
+
15
+#include "ttail.h"
16
+
17
+/**@brief Parse cli arguments and return a ttail_t
18
+ *@param int argc
19
+ *@param char** argv
20
+ *@return NULL on error
21
+ */
22
+ttail_t *ttail_init(int argc, char **argv);
23
+
24
+/**@brief Checks that init lead to a valid runtime
25
+ *@param ttail_t* t
26
+ *@return 0 if no error -1 if fatal error
27
+ */
28
+int ttail_init_check(ttail_t*);
29
+
30
+/**@brief Add a logfile
31
+ *@param ttail_t*
32
+ *@param const char * filename
33
+ *@return 0 if no errors 1 if unable to open file -1 if fatal error
34
+ */
35
+int ttail_add_logfile(ttail_t*, const char*);
36
+
37
+/**@brief Set a date prefix regex
38
+ *@param ttail_t*
39
+ *@param const char * regex
40
+ *@return 0 if no errors 1 if allready set -1 if compilation fails
41
+ */
42
+int ttail_set_prefix(ttail_t*, const char*);
43
+
44
+/**@brief Set dates min/max
45
+ *
46
+ *After the call dates are free and set to NULL except if error
47
+ *@param ttail_t ttail instance
48
+ *@param char*[2] dates {min,max} both can be NULL
49
+ *@return -1 if error 0 else
50
+ */
51
+int ttail_set_dates(ttail_t*, char*[2]);
52
+
53
+/**@brief Attempt to guess a dateformat
54
+ *@param ttail_t* ttail if manage to guess set the ttail_t.fmt
55
+ *@param const char* date as a dtring
56
+ *@param struct tm* if non NULL will be set to detected date
57
+ *@return -1 if no guess -2 if fmt already set else id in TTAIL_DEFAULT_FORMATS
58
+ */
59
+int ttail_format_guess(ttail_t*, const char*, struct tm*);
60
+
61
+
62
+void ttail_free(ttail_t*);
63
+
64
+
65
+#endif

+ 1
- 0
src/main.c View File

@@ -1,4 +1,5 @@
1 1
 #include "include/ttail.h"
2
+#include "include/ttail_init.h"
2 3
 
3 4
 int main(int argc, char **argv)
4 5
 {

src/ttail.c → src/ttail_init.c View File

@@ -1,4 +1,4 @@
1
-#include "ttail.h"
1
+#include "ttail_init.h"
2 2
 
3 3
 ttail_t *ttail_init(int argc, char **argv)
4 4
 {

+ 1
- 0
tests/ttail_argparse_check.c View File

@@ -5,6 +5,7 @@
5 5
 
6 6
 
7 7
 #include "ttail.h"
8
+#include "ttail_init.h"
8 9
 
9 10
 ttail_t *ttail;
10 11
 #define __Fname_sz 5

+ 1
- 1
tests/ttail_init_check.c View File

@@ -3,8 +3,8 @@
3 3
 #include <stdio.h>
4 4
 #include <unistd.h>
5 5
 
6
-
7 6
 #include "ttail.h"
7
+#include "ttail_init.h"
8 8
 
9 9
 ttail_t *ttail;
10 10
 #define __Fname_sz 5

Loading…
Cancel
Save