root/source3/param/test_lp_load.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   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 
  22 extern bool AllowDebugChange;
  23 
  24 int main(int argc, const char **argv)
     /* [<][>][^][v][top][bottom][index][help] */
  25 {
  26         const char *config_file = get_dyn_CONFIGFILE();
  27         int ret = 0;
  28         poptContext pc;
  29         char *count_str = NULL;
  30         int i, count = 1;
  31 
  32         struct poptOption long_options[] = {
  33                 POPT_AUTOHELP
  34                 {"count", 'c', POPT_ARG_STRING, &count_str, 1,
  35                  "Load config <count> number of times"},
  36                 POPT_COMMON_DEBUGLEVEL
  37                 POPT_TABLEEND
  38         };
  39 
  40         TALLOC_CTX *frame = talloc_stackframe();
  41 
  42         load_case_tables();
  43         DEBUGLEVEL_CLASS[DBGC_ALL] = 0;
  44 
  45         pc = poptGetContext(NULL, argc, argv, long_options,
  46                             POPT_CONTEXT_KEEP_FIRST);
  47         poptSetOtherOptionHelp(pc, "[OPTION...] <config-file>");
  48 
  49         while(poptGetNextOpt(pc) != -1);
  50 
  51         setup_logging(poptGetArg(pc), True);
  52 
  53         if (poptPeekArg(pc)) {
  54                 config_file = poptGetArg(pc);
  55         }
  56 
  57         poptFreeContext(pc);
  58 
  59         if (count_str != NULL) {
  60                 count = atoi(count_str);
  61         }
  62 
  63         dbf = x_stderr;
  64         /* Don't let the debuglevel be changed by smb.conf. */
  65         AllowDebugChange = False;
  66 
  67         for (i=0; i < count; i++) {
  68                 printf("call lp_load() #%d: ", i+1);
  69                 if (!lp_load_with_registry_shares(config_file,
  70                                                   False, /* global only */
  71                                                   True,  /* save defaults */
  72                                                   False, /*add_ipc */
  73                                                   True)) /*init globals */
  74                 {
  75                         printf("ERROR.\n");
  76                         ret = 1;
  77                         goto done;
  78                 }
  79                 printf("ok.\n");
  80         }
  81 
  82 
  83 done:
  84         gfree_loadparm();
  85         TALLOC_FREE(frame);
  86         return ret;
  87 }
  88 

/* [<][>][^][v][top][bottom][index][help] */