| 1 | /*
|
|---|
| 2 | * Unix SMB/CIFS implementation.
|
|---|
| 3 | * Test for lp_load()
|
|---|
| 4 | * Copyright (C) Michael Adam 2008
|
|---|
| 5 | *
|
|---|
| 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.
|
|---|
| 10 | *
|
|---|
| 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.
|
|---|
| 15 | *
|
|---|
| 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/>.
|
|---|
| 18 | */
|
|---|
| 19 |
|
|---|
| 20 | #include "includes.h"
|
|---|
| 21 | #include "popt_common.h"
|
|---|
| 22 |
|
|---|
| 23 | int main(int argc, const char **argv)
|
|---|
| 24 | {
|
|---|
| 25 | const char *config_file = get_dyn_CONFIGFILE();
|
|---|
| 26 | int ret = 0;
|
|---|
| 27 | poptContext pc;
|
|---|
| 28 | char *count_str = NULL;
|
|---|
| 29 | int i, count = 1;
|
|---|
| 30 |
|
|---|
| 31 | struct poptOption long_options[] = {
|
|---|
| 32 | POPT_AUTOHELP
|
|---|
| 33 | {"count", 'c', POPT_ARG_STRING, &count_str, 1,
|
|---|
| 34 | "Load config <count> number of times"},
|
|---|
| 35 | POPT_COMMON_DEBUGLEVEL
|
|---|
| 36 | POPT_TABLEEND
|
|---|
| 37 | };
|
|---|
| 38 |
|
|---|
| 39 | TALLOC_CTX *frame = talloc_stackframe();
|
|---|
| 40 |
|
|---|
| 41 | smb_init_locale();
|
|---|
| 42 | lp_set_cmdline("log level", "0");
|
|---|
| 43 |
|
|---|
| 44 | pc = poptGetContext(NULL, argc, argv, long_options,
|
|---|
| 45 | POPT_CONTEXT_KEEP_FIRST);
|
|---|
| 46 | poptSetOtherOptionHelp(pc, "[OPTION...] <config-file>");
|
|---|
| 47 |
|
|---|
| 48 | while(poptGetNextOpt(pc) != -1);
|
|---|
| 49 |
|
|---|
| 50 | setup_logging(poptGetArg(pc), DEBUG_STDERR);
|
|---|
| 51 |
|
|---|
| 52 | if (poptPeekArg(pc)) {
|
|---|
| 53 | config_file = poptGetArg(pc);
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | poptFreeContext(pc);
|
|---|
| 57 |
|
|---|
| 58 | if (count_str != NULL) {
|
|---|
| 59 | count = atoi(count_str);
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | for (i=0; i < count; i++) {
|
|---|
| 63 | printf("call lp_load() #%d: ", i+1);
|
|---|
| 64 | if (!lp_load_with_registry_shares(config_file)) {
|
|---|
| 65 | printf("ERROR.\n");
|
|---|
| 66 | ret = 1;
|
|---|
| 67 | goto done;
|
|---|
| 68 | }
|
|---|
| 69 | printf("ok.\n");
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 | done:
|
|---|
| 74 | gfree_loadparm();
|
|---|
| 75 | TALLOC_FREE(frame);
|
|---|
| 76 | return ret;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|