2 * Unix SMB/CIFS implementation.
3 * libsmbconf - Samba configuration library, init dispatcher
4 * Copyright (C) Michael Adam 2008
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "smbconf_private.h"
24 * smbconf initialization dispatcher
26 * this takes a configuration source in the form of
27 * backend:path and calles the appropriate backend
28 * init function with the path argument
31 * - "registry" or "reg"
34 WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
41 TALLOC_CTX *tmp_ctx = talloc_stackframe();
43 if (conf_ctx == NULL) {
44 werr = WERR_INVALID_PARAM;
48 if ((source == NULL) || (*source == '\0')) {
49 werr = WERR_INVALID_PARAM;
53 backend = talloc_strdup(tmp_ctx, source);
54 if (backend == NULL) {
59 sep = strchr(backend, ':');
63 if (strlen(path) == 0) {
68 if (strequal(backend, "registry") || strequal(backend, "reg")) {
69 werr = smbconf_init_reg(mem_ctx, conf_ctx, path);
70 } else if (strequal(backend, "file") || strequal(backend, "txt")) {
71 werr = smbconf_init_txt(mem_ctx, conf_ctx, path);
72 } else if (sep == NULL) {
74 * If no separator was given in the source, and the string is
75 * not a know backend, assume file backend and use the source
76 * string as a path argument.
78 werr = smbconf_init_txt(mem_ctx, conf_ctx, backend);
81 * Separator was specified but this is not a known backend.
84 DEBUG(1, ("smbconf_init: ERROR - unknown backend '%s' given\n",
86 werr = WERR_INVALID_PARAM;