Last change
on this file since 1125 was 1065, checked in by Bruno Cornec, 18 years ago |
More tests in
mr_msg function doesn't cascade to _mr_msg anymore, as it doesn't seem to work correctly with multiple varargs entries (I've not found how to do it correctly, so I give up for the moment)
lib code pass valgrind without issue.
|
-
Property svn:eol-style
set to
native
|
File size:
1.1 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 | int main(void) {
|
---|
20 | int ret = 0;
|
---|
21 | char *s = NULL;
|
---|
22 | int l = 0;
|
---|
23 | char *str = NULL;
|
---|
24 | size_t n = (size_t)0;
|
---|
25 | FILE *fd = NULL;
|
---|
26 |
|
---|
27 | /* Get logfile name and log level from conf file */
|
---|
28 | if ((ret = mr_conf_open("mondo.conf")) != 0) {
|
---|
29 | fprintf(stderr,"Unable to open conf file (%d)\n",ret);
|
---|
30 | exit(-1);
|
---|
31 | }
|
---|
32 | if ((s = mr_conf_sread("logfile")) == NULL) {
|
---|
33 | fprintf(stderr,"Unable to get string\n");
|
---|
34 | exit(-1);
|
---|
35 | }
|
---|
36 | fprintf(stdout, "Logfile : ***%s***\n",s);
|
---|
37 | l = mr_conf_iread("loglevel");
|
---|
38 | fprintf(stdout, "Loglevel : ***%d***\n",l);
|
---|
39 | mr_conf_close();
|
---|
40 |
|
---|
41 | /* test messages functions */
|
---|
42 | mr_msg_init(s,l);
|
---|
43 |
|
---|
44 | mr_msg(1, "Log sentence : %d %d %s %s\n", 12, l, s, "is a log file");
|
---|
45 |
|
---|
46 | if ((fd = fopen(s,"r")) != NULL) {
|
---|
47 | getline(&str, &n, fd);
|
---|
48 | fprintf(stdout, "%s", str);
|
---|
49 | mr_free(str);
|
---|
50 | fclose(fd);
|
---|
51 | } else {
|
---|
52 | fprintf(stderr,"Unable to open file %s\n", s);
|
---|
53 | exit(-1);
|
---|
54 | }
|
---|
55 |
|
---|
56 | mr_free(s);
|
---|
57 | mr_msg_close();
|
---|
58 | exit(0);
|
---|
59 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.