home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / contrib / samba / samba-1.8 / samba-1 / samba-1.8.05 / testparm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-27  |  2.5 KB  |  97 lines

  1. /* 
  2.    Unix SMB/Netbios implementation.
  3.    Version 1.8.
  4.    Copyright (C) Karl Auer 1993, 1994
  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 2 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, write to the Free Software
  18.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. /*
  22.  * Testbed for loadparm.c/params.c
  23.  *
  24.  * This module simply loads a specified configuration file and
  25.  * if successful, dumps it's contents to stdout. Note that the
  26.  * operation is performed with DEBUGLEVEL at 3.
  27.  *
  28.  * Useful for a quick 'syntax check' of a configuration file.
  29.  *
  30.  */
  31.  
  32. #include "includes.h"
  33. #include "smb.h"
  34. #include "params.h"
  35. #include "loadparm.h"
  36.  
  37. /* these live in util.c */
  38. extern FILE *dbf;
  39. extern int DEBUGLEVEL;
  40.  
  41. int main(int argc, char *argv[])
  42. {
  43.    if (argc < 2)
  44.       printf("Please specify a services file\n");
  45.    else
  46.    {
  47.       dbf = fopen("test.log", "w");
  48.       if (dbf == NULL)
  49.          printf("Unable to open logfile.\n");
  50.       else
  51.       {
  52.          DEBUGLEVEL = 3;
  53.          if (!lp_load(argv[1]))
  54.             printf("Error loading services.\n");
  55.          else
  56.        {
  57.          printf("Loaded services file OK.\n");
  58.          {
  59.            int iHomeService;
  60.            int iPrinterService;
  61.            if ((iHomeService = lp_servicenumber(HOMES_NAME)) >= 0)
  62.          lp_add_home("tstuser",iHomeService,"/home/fred");
  63.            if ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) >= 0)
  64.          lp_add_printer("tstprinter",iPrinterService);
  65.          }
  66.          lp_dump();
  67.        }
  68.          fclose(dbf);
  69.      if (argc == 4)
  70.        {
  71.          struct from_host f;
  72.          int s;
  73.          f.name = argv[2];
  74.          f.addr = argv[3];
  75.  
  76.          /* this is totally ugly, a real `quick' hack */
  77.          for (s=0;s<1000;s++)
  78.            if (VALID_SNUM(s))
  79.          {         
  80.            if (allow_access(lp_hostsdeny(s),lp_hostsallow(s),&f))
  81.              {
  82.                printf("Allow connection from %s (%s) to %s\n",
  83.                  f.name,f.addr,lp_servicename(s));
  84.              }
  85.            else
  86.              {
  87.                printf("Deny connection from %s (%s) to %s\n",
  88.                  f.name,f.addr,lp_servicename(s));
  89.              }
  90.          }
  91.        }
  92.        }
  93.    }
  94.    return (0);
  95. }
  96.  
  97.