loadparm: introduce lp_parm_ulonglong() and lpcfg_parm_ulonglong()
authorUri Simchoni <uri@samba.org>
Mon, 18 Jan 2016 04:56:43 +0000 (06:56 +0200)
committerMichael Adam <obnox@samba.org>
Tue, 26 Jan 2016 14:58:11 +0000 (15:58 +0100)
Signed-off-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
lib/param/loadparm.c
lib/param/param.h
source3/include/proto.h
source3/param/loadparm.c

index 9b36c7e368449f99d97e384bd1102cbbf8b606b7..9a3451f4e352a8f5527f5f35ee39b739e0f9dfb0 100644 (file)
@@ -328,6 +328,20 @@ unsigned long lp_ulong(const char *s)
        return strtoul(s, NULL, 0);
 }
 
+/**
+ * convenience routine to return unsigned long long parameters.
+ */
+unsigned long long lp_ulonglong(const char *s)
+{
+
+       if (!s || !*s) {
+               DEBUG(0, ("lp_ulonglong(%s): is called with NULL!\n", s));
+               return -1;
+       }
+
+       return strtoull(s, NULL, 0);
+}
+
 /**
  * convenience routine to return unsigned long parameters.
  */
@@ -473,6 +487,25 @@ unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
        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'
+ */
+unsigned long long lpcfg_parm_ulonglong(struct loadparm_context *lp_ctx,
+                                       struct loadparm_service *service,
+                                       const char *type, const char *option,
+                                       unsigned long long default_v)
+{
+       const char *value = lpcfg_get_parametric(lp_ctx, service, type, option);
+
+       if (value) {
+               return lp_ulonglong(value);
+       }
+
+       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)
index 500f52d56a7546f8a001716ada4604295d11a0e1..fb28218e3b8c2fa004f1dcbb53a2a4f40b037468 100644 (file)
@@ -98,6 +98,10 @@ int lpcfg_parm_bytes(struct loadparm_context *lp_ctx,
 unsigned long lpcfg_parm_ulong(struct loadparm_context *lp_ctx,
                            struct loadparm_service *service, const char *type,
                            const char *option, unsigned long default_v);
+unsigned long long lpcfg_parm_ulonglong(struct loadparm_context *lp_ctx,
+                                       struct loadparm_service *service,
+                                       const char *type, const char *option,
+                                       unsigned long long default_v);
 long lpcfg_parm_long(struct loadparm_context *lp_ctx,
                     struct loadparm_service *service, const char *type,
                     const char *option, long default_v);
index ce9e277187c40991d7a55ea0eae9c59e91f2ec81..e18aaf4811583db4b17109856d76473a07579685 100644 (file)
@@ -966,6 +966,9 @@ const char *lp_parm_const_string_service(struct loadparm_service *service, const
 const char **lp_parm_string_list(int snum, const char *type, const char *option, const char **def);
 int lp_parm_int(int snum, const char *type, const char *option, int def);
 unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsigned long def);
+unsigned long long lp_parm_ulonglong(int snum, const char *type,
+                                    const char *option,
+                                    unsigned long long def);
 bool lp_parm_bool(int snum, const char *type, const char *option, bool def);
 struct enum_list;
 int lp_parm_enum(int snum, const char *type, const char *option,
index f8ecab716b44252a550e397c5a2d9afd9fdb4620..31d9e2ddb3a86f6ec72aa94d064bd09b14569b4b 100644 (file)
@@ -1245,6 +1245,22 @@ unsigned long lp_parm_ulong(int snum, const char *type, const char *option, unsi
 /* Return parametric option from a given service. Type is a part of option before ':' */
 /* Parametric option has following syntax: 'Type: option = value' */
 
+unsigned long long lp_parm_ulonglong(int snum, const char *type,
+                                    const char *option, unsigned long long def)
+{
+       struct parmlist_entry *data = get_parametrics(snum, type, option);
+
+       if (data && data->value && *data->value) {
+               return lp_ulonglong(data->value);
+       }
+
+       return def;
+}
+
+/* Return parametric option from a given service. Type is a part of option
+ * before ':' */
+/* Parametric option has following syntax: 'Type: option = value' */
+
 bool lp_parm_bool(int snum, const char *type, const char *option, bool def)
 {
        struct parmlist_entry *data = get_parametrics(snum, type, option);