home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / TELECOM / UUCPbb_2_1_src.lzh / UUCPBB21 / getsys.c < prev    next >
Text File  |  1994-09-25  |  2KB  |  69 lines

  1. /*  getsys.c   This routine gets the default remote system name.
  2.     Copyright (C) 1990, 1993  Rick Adams and Bob Billson
  3.  
  4.     This file is part of the OS-9 UUCP package, UUCPbb.
  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.     The author of UUCPbb, Bob Billson, can be contacted at:
  21.     bob@kc2wz.bubble.org  or  uunet!kc2wz!bob  or  by snail mail:
  22.     21 Bates Way, Westfield, NJ 07090
  23. */
  24.  
  25. #include "uucp.h"
  26.  
  27. EXTERN QQ unsigned myuid;
  28.  
  29.  
  30. int getsys (sysname)
  31. char *sysname;
  32. {
  33.      char line[SYSLINE];
  34.      FILE *file;
  35.      register char *p;
  36.      char *systems = SYSTEMS;
  37.  
  38.      /* we already have a system name */
  39.      if (*sysname != '\0')
  40.           return(0);
  41.  
  42.      /* get the first system in the Systems file as the default */
  43.      p = line;
  44.      asetuid (0);
  45.  
  46.      if ((file = fopen (systems, "r")) == NULL)
  47.        {
  48.           sprintf (p, "getsys() can't open '%s'", systems);
  49.           asetuid (myuid);
  50.           fatal (p);
  51.        }
  52.  
  53.      asetuid (myuid);
  54.  
  55.      /* ignore comment lines starting with '#', <space>, <tab> or CR */
  56.      while (mfgets (p, SYSLINE, file) != NULL)
  57.           if (ISCOMMENT (*p) == TRUE)
  58.                break;
  59.  
  60.      fclose (file);
  61.  
  62.      /* get first remote in Systems */
  63.      if ((p = strrchr (p, ' ')) != NULL)
  64.        {
  65.           *p = '\0';
  66.           strcpy (sysname, line);
  67.        }
  68. }
  69.