s3:net_idmap_dump deal with idmap config * : backend config style
[Samba/gebeck_regimport.git] / lib / ldb / common / ldb_options.c
blobf07f3935624e4970c9bafabb8340041d6a480ded
1 /*
2 ldb database library
4 Copyright (C) Andrew Tridgell 2010
6 ** NOTE! The following LGPL license applies to the ldb
7 ** library. This does NOT imply that all of Samba is released
8 ** under the LGPL
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 3 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, see <http://www.gnu.org/licenses/>.
25 * Name: ldb
27 * Component: ldb options[] handling
29 * Author: Andrew Tridgell
32 #include "ldb_private.h"
35 find an option within an options array
37 accepts the following forms:
39 NAME
40 NAME:value
41 NAME=value
43 returns a pointer into an element of the options[] array, or NULL is
44 not found.
46 For the NAME form, returns a pointer to an empty string (thus
47 allowing for boolean options).
49 const char *ldb_options_find(struct ldb_context *ldb, const char *options[],
50 const char *option_name)
52 size_t len = strlen(option_name);
53 int i;
55 if (options == NULL) {
56 return NULL;
59 for (i=0; options[i]; i++) {
60 if (strncmp(option_name, options[i], len) != 0) {
61 continue;
63 if (options[i][len] == ':' || options[i][len] == '=') {
64 return &options[i][len+1];
66 if (options[i][len] == 0) {
67 return &options[i][len];
71 return NULL;