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

  1. /* vsnams.c
  2.    Get all known system names from the V2 configuration files.
  3.  
  4.    Copyright (C) 1992, 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_vsnams_rcsid[] = "$Id: vsnams.c,v 1.8 1995/06/21 19:25:26 ian Rel $";
  30. #endif
  31.  
  32. #include <errno.h>
  33.  
  34. /* Get all the system names from the V2 L.sys file.  This code does
  35.    not support aliases, although some V2 versions do have an L-aliases
  36.    file.  */
  37.  
  38. /*ARGSUSED*/
  39. int
  40. uuconf_v2_system_names (pglobal, ppzsystems, falias)
  41.      pointer pglobal;
  42.      char ***ppzsystems;
  43.      int falias;
  44. {
  45.   struct sglobal *qglobal = (struct sglobal *) pglobal;
  46.   FILE *e;
  47.   int iret;
  48.   char *zline;
  49.   size_t cline;
  50.  
  51.   *ppzsystems = NULL;
  52.  
  53.   e = fopen (qglobal->qprocess->zv2systems, "r");
  54.   if (e == NULL)
  55.     {
  56.       if (FNO_SUCH_FILE ())
  57.     return _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
  58.                     ppzsystems, (pointer) NULL);
  59.       qglobal->ierrno = errno;
  60.       qglobal->zfilename = qglobal->qprocess->zv2systems;
  61.       return (UUCONF_FOPEN_FAILED
  62.           | UUCONF_ERROR_ERRNO
  63.           | UUCONF_ERROR_FILENAME);
  64.     }
  65.  
  66.   qglobal->ilineno = 0;
  67.   iret = UUCONF_SUCCESS;
  68.  
  69.   zline = NULL;
  70.   cline = 0;
  71.   while (_uuconf_getline (qglobal, &zline, &cline, e) > 0)
  72.     {
  73.       char *zname;
  74.  
  75.       ++qglobal->ilineno;
  76.  
  77.       /* Skip leading whitespace to get to the system name.  Then cut
  78.      the system name off at the first whitespace, comment, or
  79.      newline.  */
  80.       zname = zline + strspn (zline, " \t");
  81.       zname[strcspn (zname, " \t#\n")] = '\0';
  82.       if (*zname == '\0')
  83.     continue;
  84.  
  85.       iret = _uuconf_iadd_string (qglobal, zname, TRUE, TRUE, ppzsystems,
  86.                   (pointer) NULL);
  87.       if (iret != UUCONF_SUCCESS)
  88.     break;
  89.     }
  90.  
  91.   (void) fclose (e);
  92.   if (zline != NULL)
  93.     free ((pointer) zline);
  94.  
  95.   if (iret != UUCONF_SUCCESS)
  96.     {
  97.       qglobal->zfilename = qglobal->qprocess->zv2systems;
  98.       return iret | UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;
  99.     }
  100.  
  101.   if (*ppzsystems == NULL)
  102.     iret = _uuconf_iadd_string (qglobal, (char *) NULL, FALSE, FALSE,
  103.                 ppzsystems, (pointer) NULL);
  104.  
  105.   return iret;
  106. }
  107.