From 74510b059e6852d1491a4cb6eaa9cc7c2ed61fbf Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 19 Apr 2012 11:00:45 -0400 Subject: loadparm: Add convenience function to return long integers --- lib/param/loadparm.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/param/loadparm.c') diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index 3ccf4668fc..d68d585617 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -1710,6 +1710,20 @@ static unsigned long lp_ulong(const char *s) return strtoul(s, NULL, 0); } +/** + * convenience routine to return unsigned long parameters. + */ +static long lp_long(const char *s) +{ + + if (!s) { + DEBUG(0,("lp_long(%s): is called with NULL!\n",s)); + return -1; + } + + return strtol(s, NULL, 0); +} + /** * convenience routine to return unsigned long parameters. */ @@ -1840,6 +1854,17 @@ unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx, return default_v; } +long lpcfg_parm_long(struct loadparm_context *lp_ctx, + struct loadparm_service *service, const char *type, + const char *option, long default_v) +{ + const char *value = lpcfg_get_parametric(lp_ctx, service, type, option); + + if (value) + return lp_long(value); + + return default_v; +} double lpcfg_parm_double(struct loadparm_context *lp_ctx, struct loadparm_service *service, const char *type, -- cgit