New functions gw_res_int and gw_res_bool.
[egate.git] / res+log / gw-res-int.c
1 /*
2  * Implementation of resource management.
3  *
4  * Europagate, 1994-1995.
5  *
6  * $Log: gw-res-int.c,v $
7  * Revision 1.1  1995/05/03 07:38:18  adam
8  * New functions gw_res_int and gw_res_bool.
9  *
10  */
11 #include <assert.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14 #include <string.h>
15
16 #include <gw-log.h>
17 #include <gw-res.h>
18
19 int gw_res_int (GwRes res, const char *name, int def_val)
20 {
21     const char *cp;
22     int val;
23
24     cp = gw_res_get (res, name, NULL);
25     if (!cp)
26         return def_val;
27     if (sscanf (cp, "%d", &val) == 1)
28         return val;
29     gw_log (GW_LOG_WARN, "res", "Missing integer for resource %s", name);
30     return def_val;
31 }
32