From fdbc8e29c7c87e415d7e43589234526722698bd6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 17 Jun 2007 20:02:56 +0000 Subject: r23532: added lp_parm_double() (This used to be commit 524ba04b1f6996023886190eee8a226b08aafa35) --- source4/param/loadparm.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index b98a75e441..9bcf9aada7 100644 --- a/source4/param/loadparm.c +++ b/source4/param/loadparm.c @@ -1016,6 +1016,20 @@ static int lp_ulong(const char *s) return strtoul(s, NULL, 0); } +/******************************************************************* +convenience routine to return unsigned long parameters. +********************************************************************/ +static double lp_double(const char *s) +{ + + if (!s) { + DEBUG(0,("lp_double(%s): is called with NULL!\n",s)); + return (-1); + } + + return strtod(s, NULL); +} + /******************************************************************* convenience routine to return boolean parameters. ********************************************************************/ @@ -1112,6 +1126,17 @@ unsigned long lp_parm_ulong(int lookup_service, const char *type, const char *op return default_v; } + +double lp_parm_double(int lookup_service, const char *type, const char *option, double default_v) +{ + const char *value = lp_get_parametric(lookup_service, type, option); + + if (value) + return lp_double(value); + + return default_v; +} + /* Return parametric option from a given service. Type is a part of option before ':' */ /* Parametric option has following syntax: 'Type: option = value' */ -- cgit