home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / uucp / Uucp.framework / uuconf.subproj / iniglb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-09  |  5.3 KB  |  181 lines

  1. /* iniglb.c
  2.    Initialize the global information structure.
  3.  
  4.    Copyright (C) 1992, 1994, 1995 Ian Lance Taylor
  5.  
  6.    This file is part of the Taylor UUCP uuconf library.
  7.  
  8.    This library is free software; you can redistribute it and/or
  9.    modify it under the terms of the GNU Library General Public License
  10.    as published by the Free Software Foundation; either version 2 of
  11.    the License, or (at your option) any later version.
  12.  
  13.    This library is distributed in the hope that it will be useful, but
  14.    WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.    Library General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU Library General Public
  19.    License along with this library; if not, write to the Free Software
  20.    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  21.  
  22.    The author of the program may be contacted at ian@airs.com or
  23.    c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
  24.    */
  25.  
  26. #include "uucnfi.h"
  27.  
  28. #if USE_RCS_ID
  29. const char _uuconf_iniglb_rcsid[] = "$Id: iniglb.c,v 1.11 1995/06/28 14:38:23 ian Rel $";
  30. #endif
  31.  
  32. #include <errno.h>
  33.  
  34. /* Initialize the global information structure.  */
  35.  
  36. int
  37. _uuconf_iinit_global (pqglobal)
  38.      struct sglobal **pqglobal;
  39. {
  40.   pointer pblock;
  41.   register struct sprocess *qprocess;
  42.   char *azargs[3];
  43.   int iret;
  44.  
  45.   pblock = uuconf_malloc_block ();
  46.   if (pblock == NULL)
  47.     return UUCONF_MALLOC_FAILED;
  48.  
  49.   *pqglobal = (struct sglobal *) uuconf_malloc (pblock,
  50.                         sizeof (struct sglobal));
  51.   if (*pqglobal == NULL)
  52.     {
  53.       uuconf_free_block (pblock);
  54.       return UUCONF_MALLOC_FAILED;
  55.     }
  56.  
  57.   (*pqglobal)->qprocess = ((struct sprocess *)
  58.                uuconf_malloc (pblock,
  59.                       sizeof (struct sprocess)));
  60.   if ((*pqglobal)->qprocess == NULL)
  61.     {
  62.       uuconf_free_block (pblock);
  63.       *pqglobal = NULL;
  64.       return UUCONF_MALLOC_FAILED;
  65.     }
  66.  
  67.   (*pqglobal)->pblock = pblock;
  68.   (*pqglobal)->ierrno = 0;
  69.   (*pqglobal)->ilineno = 0;
  70.   (*pqglobal)->zfilename = NULL;
  71.  
  72.   qprocess = (*pqglobal)->qprocess;
  73.  
  74.   qprocess->zlocalname = NULL;
  75.   qprocess->zspooldir = SPOOLDIR;
  76.   qprocess->zpubdir = PUBDIR;
  77. #ifdef LOCKDIR
  78.   qprocess->zlockdir = LOCKDIR;
  79. #else
  80.   qprocess->zlockdir = SPOOLDIR;
  81. #endif
  82.   qprocess->zlogfile = LOGFILE;
  83.   qprocess->zstatsfile = STATFILE;
  84.   qprocess->zdebugfile = DEBUGFILE;
  85.   qprocess->zdebug = "";
  86.   qprocess->fstrip_login = TRUE;
  87.   qprocess->fstrip_proto = TRUE;
  88.   qprocess->cmaxuuxqts = 0;
  89.   qprocess->zrunuuxqt = NULL;
  90.   qprocess->fv2 = TRUE;
  91.   qprocess->fhdb = TRUE;
  92.   qprocess->pzdialcodefiles = NULL;
  93.   qprocess->pztimetables = NULL;
  94.   qprocess->zconfigfile = NULL;
  95.   qprocess->pzsysfiles = NULL;
  96.   qprocess->pzportfiles = NULL;
  97.   qprocess->pzdialfiles = NULL;
  98.   qprocess->pzpwdfiles = NULL;
  99.   qprocess->pzcallfiles = NULL;
  100.   qprocess->qunknown = NULL;
  101.   qprocess->fread_syslocs = FALSE;
  102.   qprocess->qsyslocs = NULL;
  103.   qprocess->qvalidate = NULL;
  104.   qprocess->fuses_myname = FALSE;
  105.   qprocess->zv2systems = NULL;
  106.   qprocess->zv2devices = NULL;
  107.   qprocess->zv2userfile = NULL;
  108.   qprocess->zv2cmds = NULL;
  109.   qprocess->pzhdb_systems = NULL;
  110.   qprocess->pzhdb_devices = NULL;
  111.   qprocess->pzhdb_dialers = NULL;
  112.   qprocess->fhdb_read_permissions = FALSE;
  113.   qprocess->qhdb_permissions = NULL;
  114.  
  115.   azargs[0] = NULL;
  116.   azargs[1] = (char *) "Evening";
  117.   azargs[2] = (char *) "Wk1705-0755,Sa,Su";
  118.   iret = _uuconf_itimetable ((pointer) *pqglobal, 3, azargs,
  119.                  (pointer) NULL, (pointer) NULL);
  120.   if (UUCONF_ERROR_VALUE (iret) == UUCONF_SUCCESS)
  121.     {
  122.       azargs[1] = (char *) "Night";
  123.       azargs[2] = (char *) "Wk2305-0755,Sa,Su2305-1655";
  124.       iret = _uuconf_itimetable ((pointer) *pqglobal, 3, azargs,
  125.                  (pointer) NULL, (pointer) NULL);
  126.     }
  127.   if (UUCONF_ERROR_VALUE (iret) == UUCONF_SUCCESS)
  128.     {
  129.       azargs[1] = (char *) "NonPeak";
  130.       azargs[2] = (char *) "Wk1805-0655,Sa,Su";
  131.       iret = _uuconf_itimetable ((pointer) *pqglobal, 3, azargs,
  132.                  (pointer) NULL, (pointer) NULL);
  133.     }
  134.   if (UUCONF_ERROR_VALUE (iret) != UUCONF_SUCCESS)
  135.     {
  136.       uuconf_free_block (pblock);
  137.       *pqglobal = NULL;
  138.  
  139.       /* Strip off any special bits, since there's no global
  140.      structure.  */
  141.       return UUCONF_ERROR_VALUE (iret);
  142.     }
  143.  
  144.   return UUCONF_SUCCESS;
  145. }
  146.  
  147. /* Add a timetable.  This is also called by the Taylor UUCP
  148.    initialization code, as well as by the Taylor UUCP sys file code
  149.    (although the latter is obsolete).  There's no point in putting
  150.    this in a separate file, since everything must call
  151.    _uuconf_init_global.  There is a race condition here if this is
  152.    called by two different threads on a sys file command, but the sys
  153.    file command is obsolete anyhow.  */
  154.  
  155. /*ARGSUSED*/
  156. int
  157. _uuconf_itimetable (pglobal, argc, argv, pvar, pinfo)
  158.      pointer pglobal;
  159.      int argc;
  160.      char **argv;
  161.      pointer pvar;
  162.      pointer pinfo;
  163. {
  164.   struct sglobal *qglobal = (struct sglobal *) pglobal;
  165.   int iret;
  166.  
  167.   iret = _uuconf_iadd_string (qglobal, argv[1], FALSE, FALSE,
  168.                   &qglobal->qprocess->pztimetables,
  169.                   qglobal->pblock);
  170.   if (iret != UUCONF_SUCCESS)
  171.     return iret | UUCONF_CMDTABRET_EXIT;
  172.  
  173.   iret = _uuconf_iadd_string (qglobal, argv[2], FALSE, FALSE,
  174.                   &qglobal->qprocess->pztimetables,
  175.                   qglobal->pblock);
  176.   if (iret != UUCONF_SUCCESS)
  177.     return iret | UUCONF_CMDTABRET_EXIT;
  178.  
  179.   return UUCONF_CMDTABRET_KEEP;
  180. }
  181.