smbd: Remove references to get_Protocol()
[Samba.git] / source3 / param / test_lp_load.c
blob9f3d55168055b913f7bea4f41dcad2ff588751f7
1 /*
2 * Unix SMB/CIFS implementation.
3 * Test for lp_load()
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/>.
20 #include "includes.h"
21 #include "lib/cmdline/cmdline.h"
23 int main(int argc, const char **argv)
25 const char *config_file = NULL;
26 int ret = 0;
27 poptContext pc;
28 char *count_str = NULL;
29 int i, count = 1;
30 int opt;
31 bool ok;
33 struct poptOption long_options[] = {
34 POPT_AUTOHELP
36 .longName = "count",
37 .shortName = 'c',
38 .argInfo = POPT_ARG_STRING,
39 .arg = &count_str,
40 .val = 1,
41 .descrip = "Load config <count> number of times"
43 POPT_COMMON_DEBUG_ONLY
44 POPT_COMMON_VERSION
45 POPT_TABLEEND
48 TALLOC_CTX *frame = talloc_stackframe();
50 smb_init_locale();
52 ok = samba_cmdline_init(frame,
53 SAMBA_CMDLINE_CONFIG_NONE,
54 false /* require_smbconf */);
55 if (!ok) {
56 DBG_ERR("Failed to init cmdline parser!\n");
57 TALLOC_FREE(frame);
58 exit(ENOMEM);
60 lp_set_cmdline("log level", "0");
62 pc = samba_popt_get_context(getprogname(),
63 argc,
64 argv,
65 long_options,
66 0);
67 if (pc == NULL) {
68 DBG_ERR("Failed to setup popt context!\n");
69 TALLOC_FREE(frame);
70 exit(1);
72 poptSetOtherOptionHelp(pc, "[OPTION...] <config-file>");
74 while ((opt = poptGetNextOpt(pc)) != -1) {
75 switch (opt) {
76 case POPT_ERROR_BADOPT:
77 fprintf(stderr, "\nInvalid option %s: %s\n\n",
78 poptBadOption(pc, 0), poptStrerror(opt));
79 poptPrintUsage(pc, stderr, 0);
80 exit(1);
84 if (poptPeekArg(pc)) {
85 config_file = talloc_strdup(frame, poptGetArg(pc));
86 if (config_file == NULL) {
87 DBG_ERR("out of memory\n");
88 TALLOC_FREE(frame);
89 exit(1);
91 } else {
92 config_file = get_dyn_CONFIGFILE();
95 poptFreeContext(pc);
97 if (count_str != NULL) {
98 count = atoi(count_str);
101 for (i=0; i < count; i++) {
102 printf("call lp_load() #%d: ", i+1);
103 if (!lp_load_with_registry_shares(config_file)) {
104 printf("ERROR.\n");
105 ret = 1;
106 goto done;
108 printf("ok.\n");
112 done:
113 gfree_loadparm();
114 TALLOC_FREE(frame);
115 return ret;