Last change
on this file since 3637 was 1421, checked in by Bruno Cornec, 17 years ago |
tests reviewed
|
-
Property svn:eol-style
set to
native
|
File size:
1.1 KB
|
Rev | Line | |
---|
[1065] | 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 |
|
---|
[1421] | 19 | void (*mr_cleanup)(void) = NULL;
|
---|
| 20 |
|
---|
[1065] | 21 | int main(void) {
|
---|
| 22 | int ret = 0;
|
---|
| 23 | char *s = NULL;
|
---|
| 24 | int l = 0;
|
---|
| 25 | char *str = NULL;
|
---|
| 26 | size_t n = (size_t)0;
|
---|
| 27 | FILE *fd = NULL;
|
---|
| 28 |
|
---|
| 29 | /* Get logfile name and log level from conf file */
|
---|
| 30 | if ((ret = mr_conf_open("mondo.conf")) != 0) {
|
---|
| 31 | fprintf(stderr,"Unable to open conf file (%d)\n",ret);
|
---|
| 32 | exit(-1);
|
---|
| 33 | }
|
---|
| 34 | if ((s = mr_conf_sread("logfile")) == NULL) {
|
---|
| 35 | fprintf(stderr,"Unable to get string\n");
|
---|
| 36 | exit(-1);
|
---|
| 37 | }
|
---|
| 38 | fprintf(stdout, "Logfile : ***%s***\n",s);
|
---|
| 39 | l = mr_conf_iread("loglevel");
|
---|
| 40 | fprintf(stdout, "Loglevel : ***%d***\n",l);
|
---|
| 41 | mr_conf_close();
|
---|
| 42 |
|
---|
| 43 | /* test messages functions */
|
---|
| 44 | mr_msg_init(s,l);
|
---|
| 45 |
|
---|
| 46 | mr_msg(1, "Log sentence : %d %d %s %s\n", 12, l, s, "is a log file");
|
---|
| 47 |
|
---|
| 48 | if ((fd = fopen(s,"r")) != NULL) {
|
---|
| 49 | getline(&str, &n, fd);
|
---|
| 50 | fprintf(stdout, "%s", str);
|
---|
| 51 | mr_free(str);
|
---|
| 52 | fclose(fd);
|
---|
| 53 | } else {
|
---|
| 54 | fprintf(stderr,"Unable to open file %s\n", s);
|
---|
| 55 | exit(-1);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | mr_free(s);
|
---|
| 59 | mr_msg_close();
|
---|
| 60 | exit(0);
|
---|
| 61 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.