r23532: added lp_parm_double()
authorAndrew Tridgell <tridge@samba.org>
Sun, 17 Jun 2007 20:02:56 +0000 (20:02 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:53:24 +0000 (14:53 -0500)
source/param/loadparm.c

index b98a75e441379b0e69df9be81691b0099ebef223..9bcf9aada7e3381958f27a151e4a06465f28c680 100644 (file)
@@ -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' */