From e34e380795cac32a6a1d4ed126560c90a68301b3 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 3 May 1995 07:38:16 +0000 Subject: [PATCH] New functions gw_res_int and gw_res_bool. --- res+log/Makefile | 7 +++++-- res+log/gw-res-bool.c | 30 ++++++++++++++++++++++++++++++ res+log/gw-res-int.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 res+log/gw-res-bool.c create mode 100644 res+log/gw-res-int.c diff --git a/res+log/Makefile b/res+log/Makefile index cac7d65..4c03f80 100644 --- a/res+log/Makefile +++ b/res+log/Makefile @@ -2,7 +2,10 @@ # Europagate, 1994-1995. # # $Log: Makefile,v $ -# Revision 1.6 1995/04/17 09:36:03 adam +# Revision 1.7 1995/05/03 07:38:16 adam +# New functions gw_res_int and gw_res_bool. +# +# Revision 1.6 1995/04/17 09:36:03 adam # Minor changes. # # Revision 1.5 1995/03/27 12:51:10 adam @@ -24,7 +27,7 @@ CPP=$(CC) -E TPROG1=gw-log-test TPROG2=gw-res-test LIB=../lib/libres+log.a -PO=gw-log.o gw-res.o +PO=gw-log.o gw-res.o gw-res-bool.o gw-res-int.o DEFS=$(INCLUDE) all: $(TPROG1) $(TPROG2) diff --git a/res+log/gw-res-bool.c b/res+log/gw-res-bool.c new file mode 100644 index 0000000..532985c --- /dev/null +++ b/res+log/gw-res-bool.c @@ -0,0 +1,30 @@ +/* + * Implementation of resource management. + * + * Europagate, 1994-1995. + * + * $Log: gw-res-bool.c,v $ + * Revision 1.1 1995/05/03 07:38:18 adam + * New functions gw_res_int and gw_res_bool. + * + */ +#include +#include +#include +#include + +#include +#include + +int gw_res_bool (GwRes res, const char *name, int def_val) +{ + const char *cp; + + cp = gw_res_get (res, name, NULL); + if (!cp) + return def_val; + if (strchr ("1TYty", *cp)) + return 1; + return 0; +} + diff --git a/res+log/gw-res-int.c b/res+log/gw-res-int.c new file mode 100644 index 0000000..7c91819 --- /dev/null +++ b/res+log/gw-res-int.c @@ -0,0 +1,32 @@ +/* + * Implementation of resource management. + * + * Europagate, 1994-1995. + * + * $Log: gw-res-int.c,v $ + * Revision 1.1 1995/05/03 07:38:18 adam + * New functions gw_res_int and gw_res_bool. + * + */ +#include +#include +#include +#include + +#include +#include + +int gw_res_int (GwRes res, const char *name, int def_val) +{ + const char *cp; + int val; + + cp = gw_res_get (res, name, NULL); + if (!cp) + return def_val; + if (sscanf (cp, "%d", &val) == 1) + return val; + gw_log (GW_LOG_WARN, "res", "Missing integer for resource %s", name); + return def_val; +} + -- 1.7.10.4