1: #include "parms.h"
   2: #include "structs.h"
   3: 
   4: #ifdef  RCSIDENT
   5: static char rcsid[] = "$Header: nfalias.c,v 1.7 85/01/18 15:24:36 notes Rel $";
   6: #endif	RCSIDENT
   7: 
   8: #include "net.h"
   9: /*
  10:  *	nfalias(local, remote, remotesys)
  11:  *	char *local, *remote, *remotesys;
  12:  *
  13:  *	nfalias looks in the alias file for the remote system and
  14:  *	tries to find a match for the local notesfile.
  15:  *	If a match is found, it is copied to *remote, otherwise
  16:  *	the original name is copied over.
  17:  *
  18:  *	The routine returns -1 if there is no file.
  19:  *	A zero is returned if no match is found.
  20:  *	A 1 is returned if a match is found.
  21:  *
  22:  *	Original Coding:	Ray Essick	April 25, 1982
  23:  */
  24: 
  25: nfalias (local, remote, remotesys)
  26: char   *local;
  27: char   *remote;
  28: char   *remotesys;
  29: {
  30: 
  31:     FILE * aliases;
  32:     char    linebuf[100];               /* hold lines from file */
  33:     char   *p,
  34:            *q;
  35:     int     c;
  36: 
  37:     strcpy (remote, local);             /* pessimism - ready to fail */
  38: 
  39:     sprintf (linebuf, "%s/%s/%s/%s", Mstdir, UTILITY, ALIASES, remotesys);
  40:     if ((aliases = fopen (linebuf, "r")) == NULL)
  41:     return (-1);                    /* no file, too bad */
  42: 
  43:     while (1)
  44:     {
  45:     p = linebuf;                    /* start line */
  46:     while ((c = getc (aliases)) != EOF && c != '\n')
  47:         *p++ = c;
  48:     if (c == EOF)
  49:     {
  50:         fclose (aliases);
  51:         return 0;                   /* no match */
  52:     }
  53:     *p = '\0';                  /* terminate string */
  54:     if (linebuf[0] == '#' || linebuf[0] == '\0')
  55:         continue;                   /* comment or empty line */
  56: 
  57:     q = linebuf;                    /* find colon */
  58:     while (*q != ':' && *q)
  59:         q++;                    /* try next */
  60:     if (*q != ':')                  /* properly formatted? */
  61:     {
  62:         fprintf (stderr, "Bad line in alias file for system %s: %s\n",
  63:             remotesys, linebuf);
  64:         continue;                   /* skip the line */
  65:     }
  66:     *q++ = '\0';                    /* break into two parts */
  67:     if (strcmp (linebuf, local) == 0)       /* match ? */
  68:     {
  69:         strcpy (remote, q);             /* copy the name over */
  70:         fclose (aliases);
  71:         return 1;                   /* success */
  72:     }
  73:     }
  74: /*	yes, we know that this statement is unreachable! */
  75:     return (-1);                    /* to satisfy lint */
  76: }

Defined functions

nfalias defined in line 25; used 2 times

Defined variables

rcsid defined in line 5; never used
Last modified: 1985-01-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2056
Valid CSS Valid XHTML 1.0 Strict