source: MondoRescue/branches/stable/mondo/src/test/test-conf.c@ 1054

Last change on this file since 1054 was 1054, checked in by Bruno Cornec, 17 years ago
  • Backporting more trunk content into stable
  • Adding the test and lib directories
  • Preparing for l10n
  • Property svn:eol-style set to native
File size: 881 bytes
Line 
1/*
2 * Test file to test the configuration file handling
3 *
4 * $Id$
5 *
6 */
7
8#include <stdio.h>
9#include <stdlib.h>
10
11#include "mr_conf.h"
12#include "mr_mem.h"
13
14int g_main_pid = 0;
15int g_buffer_pid = 0;
16
17main() {
18 int ret = 0;
19 int i = 0;
20 double f = 0.0;
21 char *s = NULL;
22
23 if ((ret = mr_conf_open("mondo.conf")) != 0) {
24 fprintf(stderr,"Unable to open conf file (%d)\n",ret);
25 exit(-1);
26 }
27 if ((i = mr_conf_iread("testinteger")) == 0) {
28 fprintf(stderr,"Unable to get integer\n");
29 exit(-1);
30 }
31 fprintf(stdout, "Integer : ***%d***\n",i);
32 if ((f = mr_conf_fread("testfloat")) == 0.0) {
33 fprintf(stderr,"Unable to get float\n");
34 exit(-1);
35 }
36 fprintf(stdout, "Float : ***%f***\n",f);
37 if (! (s = mr_conf_sread("teststring"))) {
38 fprintf(stderr,"Unable to get string\n");
39 exit(-1);
40 }
41 fprintf(stdout, "String : ***%s***\n",s);
42 mr_free(s);
43 mr_conf_close();
44 exit(0);
45}
Note: See TracBrowser for help on using the repository browser.