summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-09-27 14:13:38 +0200
committerJelmer Vernooij <jelmer@samba.org>2009-09-27 14:13:38 +0200
commitc145888cece8e34af7ba11c786f1693f5ffc3791 (patch)
tree2efd62edc013a8255f4e06d924f1afffb9db5ca7
parent2dd7c9bc3441c00ba26329d4d1f4f32775a06a75 (diff)
downloadsamba-c145888cece8e34af7ba11c786f1693f5ffc3791.tar.gz
samba-c145888cece8e34af7ba11c786f1693f5ffc3791.tar.bz2
samba-c145888cece8e34af7ba11c786f1693f5ffc3791.zip
util/parmlist: Add some more comments.
-rw-r--r--lib/util/parmlist.c22
-rw-r--r--lib/util/parmlist.h18
2 files changed, 36 insertions, 4 deletions
diff --git a/lib/util/parmlist.c b/lib/util/parmlist.c
index 4ab660197d..ffcd19a4ab 100644
--- a/lib/util/parmlist.c
+++ b/lib/util/parmlist.c
@@ -41,7 +41,24 @@ int parmlist_get_int(struct parmlist *ctx, const char *name, int default_v)
return default_v;
}
-const char *parmlist_get_string(struct parmlist *ctx, const char *name, const char *default_v)
+bool parmlist_get_bool(struct parmlist *ctx, const char *name, bool default_v)
+{
+ struct parmlist_entry *p = parmlist_get(ctx, name);
+ bool ret;
+
+ if (p == NULL)
+ return default_v;
+
+ if (!set_boolean(p->value, &ret)) {
+ DEBUG(0,("lp_bool(%s): value is not boolean!\n", p->value));
+ return default_v;
+ }
+
+ return ret;
+}
+
+const char *parmlist_get_string(struct parmlist *ctx, const char *name,
+ const char *default_v)
{
struct parmlist_entry *p = parmlist_get(ctx, name);
@@ -51,7 +68,8 @@ const char *parmlist_get_string(struct parmlist *ctx, const char *name, const ch
return p->value;
}
-const char **parmlist_get_string_list(struct parmlist *ctx, const char *name, const char *separator)
+const char **parmlist_get_string_list(struct parmlist *ctx, const char *name,
+ const char *separator)
{
struct parmlist_entry *p = parmlist_get(ctx, name);
diff --git a/lib/util/parmlist.h b/lib/util/parmlist.h
index 0fa518d1c4..47d2f89d63 100644
--- a/lib/util/parmlist.h
+++ b/lib/util/parmlist.h
@@ -31,9 +31,23 @@ struct parmlist {
struct parmlist_entry *entries;
};
+/** Retrieve an integer from a parameter list. If not found, return default_v. */
int parmlist_get_int(struct parmlist *ctx, const char *name, int default_v);
-const char *parmlist_get_string(struct parmlist *ctx, const char *name, const char *default_v);
+
+/** Retrieve a string from a parameter list. If not found, return default_v. */
+const char *parmlist_get_string(struct parmlist *ctx, const char *name,
+ const char *default_v);
+
+/** Retrieve the struct for an entry in a parmlist. */
struct parmlist_entry *parmlist_get(struct parmlist *ctx, const char *name);
-const char **parmlist_get_string_list(struct parmlist *ctx, const char *name, const char *separator);
+
+/** Retrieve a string list from a parameter list.
+ * separator can contain characters to consider separators or can be
+ * NULL for the default set. */
+const char **parmlist_get_string_list(struct parmlist *ctx, const char *name,
+ const char *separator);
+
+/** Retrieve boolean from a parameter list. If not set, return default_v. */
+bool parmlist_get_bool(struct parmlist *ctx, const char *name, bool default_v);
#endif /* _PARMLIST_H */