Last change
on this file since 3745 was 2421, checked in by Bruno Cornec, 15 years ago |
- Remove some compiler warnings on main
- Adds function mr_chomp and mr_strip_char and use them in mr_date and call_program_and_get_last_line_of_output
- Fix call_program_and_get_last_line_of_output to return the right result using a temp file instead of popen
- Fix an issue in mr_getline_int in case of eof (returns now an empty string)
- Sequencing of Init of bkpinfo reviewed
|
-
Property svn:eol-style
set to
native
|
File size:
1.2 KB
|
Line | |
---|
1 | /*
|
---|
2 | * Test file to test the messages functions
|
---|
3 | *
|
---|
4 | * $Id$
|
---|
5 | *
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef _GNU_SOURCE
|
---|
9 | #define _GNU_SOURCE
|
---|
10 | #endif
|
---|
11 |
|
---|
12 | #include <stdio.h>
|
---|
13 | #include <stdlib.h>
|
---|
14 |
|
---|
15 | #include "mr_msg.h"
|
---|
16 | #include "mr_conf.h"
|
---|
17 | #include "mr_mem.h"
|
---|
18 |
|
---|
19 | void (*mr_cleanup)(void) = NULL;
|
---|
20 |
|
---|
21 | int main(void) {
|
---|
22 | int ret = 0;
|
---|
23 | char *s = NULL;
|
---|
24 | int l = 0;
|
---|
25 | char *str = NULL;
|
---|
26 | FILE *fd = NULL;
|
---|
27 |
|
---|
28 | /* Get logfile name and log level from conf file */
|
---|
29 | if ((ret = mr_conf_open("mondo.conf")) != 0) {
|
---|
30 | fprintf(stderr,"Unable to open conf file (%d)\n",ret);
|
---|
31 | exit(-1);
|
---|
32 | }
|
---|
33 | if ((s = mr_conf_sread("loglevel")) == NULL) {
|
---|
34 | fprintf(stderr,"Unable to get string\n");
|
---|
35 | exit(-1);
|
---|
36 | }
|
---|
37 | l = atoi(s);
|
---|
38 | mr_free(s);
|
---|
39 | fprintf(stdout, "Loglevel : ***%d***\n",l);
|
---|
40 |
|
---|
41 | if ((s = mr_conf_sread("logfile")) == NULL) {
|
---|
42 | fprintf(stderr,"Unable to get string\n");
|
---|
43 | exit(-1);
|
---|
44 | }
|
---|
45 | fprintf(stdout, "Logfile : ***%s***\n",s);
|
---|
46 | mr_conf_close();
|
---|
47 |
|
---|
48 | /* test messages functions */
|
---|
49 | mr_msg_init(s,l);
|
---|
50 |
|
---|
51 | mr_msg(1, "Log sentence : %d %d %s %s\n", 12, l, s, "is a log file");
|
---|
52 |
|
---|
53 | if ((fd = fopen(s,"r")) != NULL) {
|
---|
54 | mr_getline(str, fd);
|
---|
55 | fprintf(stdout, "%s", str);
|
---|
56 | mr_free(str);
|
---|
57 | fclose(fd);
|
---|
58 | } else {
|
---|
59 | fprintf(stderr,"Unable to open file %s\n", s);
|
---|
60 | exit(-1);
|
---|
61 | }
|
---|
62 |
|
---|
63 | mr_free(s);
|
---|
64 | mr_msg_close();
|
---|
65 | exit(0);
|
---|
66 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.