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 / finddev.c < prev    next >
Text File  |  1994-09-25  |  2KB  |  61 lines

  1. /*  finddev.c   This routine matches a device with one in the Devices file.
  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. /* Lines beginning with a #, <space>, <tab> or <cr> character are considered
  26.    comment lines and ignored. */
  27.  
  28. #include "uucp.h"
  29.  
  30. #define WORDSIZE  20
  31.  
  32.  
  33. int finddev (key1, key2, filename, line, length)
  34. char *key1, *key2, *filename, line[];
  35. int length;
  36. {
  37.      register char *p;
  38.      FILE *file;
  39.      char *words[WORDSIZE];
  40.      int result = FALSE;
  41.  
  42.      if ((file = fopen (filename, "r")) == NULL)
  43.        {
  44.           printf ("finddev(): can't open: %s\n", filename);    /* DEBUG */
  45.           return (result);
  46.        }
  47.  
  48.      p = line;
  49.      while (mfgets (p, length, file) != NULL)
  50.           if (ISCOMMENT (*p) == FALSE)
  51.                if ((getargs (words, p, WORDSIZE) == 5)
  52.                     && (strcmp (*words, key1) == 0)
  53.                     && (strcmp (*(words+3), key2) == 0))
  54.                  {
  55.                     result = TRUE;
  56.                     break;
  57.                  }
  58.      fclose (file);
  59.      return (result);
  60. }
  61.