# 2.11BSD#431 - /usr/src/usr.bin/uucp/versys.c

##### Functions

    uualias           X
    versys            X

##### Variables

    PhoneNumber       X

       1: #if !defined(lint) && defined(DOSCCS)
       2: static char sccsid[] = "@(#)versys.c	5.5.1 (2.11BSD) 1997/10/2";
       3: #endif
       4:
       5: #include "uucp.h"
       6: #include <stdio.h>
       7: #include <ctype.h>
       8:
       9: /*LINTLIBRARY*/
      10:
      11: char PhoneNumber[MAXPH];
      12:
      13: /*
      14:  *	verify system names n1 and n2
      15:  *	return codes:  SUCCESS  |  FAIL
      16:  *
      17:  *	NOTE:
      18:  *		the old calling sequence was versys(name) but is
      19:  *	now versys(&name) so that we can perform aliasing!!!!
      20:  *	See accompanying changes in uucp.c and uux.c
      21:  *		-- Ray Essick, April 27, 1984
      22:  */
      23: versys(nameptr)
      24: register char **nameptr;
      25: {
      26:     register FILE *fp;
      27:     char line[BUFSIZ];
      28:     char *name;
      29:
      30:     DEBUG (11, "Before Alias: %s\n", *nameptr);
      31:     uualias (nameptr);          /* alias expansion */
      32:     DEBUG (11, "After Alias: %s\n", *nameptr);
      33:     name = *nameptr;            /* dereference */
      34:
      35:     if (strncmp(name, Myname, MAXBASENAME) == 0)
      36:         return SUCCESS;
      37:
      38:     fp = fopen(SYSFILE, "r");
      39:     ASSERT(fp != NULL, CANTOPEN, SYSFILE, 0);
      40:     PhoneNumber[0] = '\0';
      41:     while (cfgets(line, sizeof(line), fp) != NULL) {
      42:         char *targs[100];
      43:
      44:         getargs(line, targs, 100);
      45:         if (strncmp(name, targs[0], MAXBASENAME) == SAME) {
      46:             fclose(fp);
      47:             strncpy(PhoneNumber, targs[F_PHONE], MAXPH);
      48:             return SUCCESS;
      49:         }
      50:     }
      51:     fclose(fp);
      52:     return FAIL;
      53: }
      54:
      55: /*
      56:  *	Works (sort of) like rhost(3) on 4.1[abc] Bsd systems.
      57:  *
      58:  *	Looks for the host in the L.aliases file and returns the
      59:  *	"standard" name by modifying the pointer. The returned
      60:  *	value is saved with malloc(3) so it isn't zapped by
      61:  *	subsequent calls.
      62:  *
      63:  *	Returns:
      64:  *		FAIL		No L.aliases file
      65:  *		SUCCESS		Anything else
      66:  */
      67:
      68: uualias(hostptr)
      69: char  **hostptr;              /* we change it */
      70: {
      71:     FILE *Aliases;            /* list of aliases */
      72:     char buf[BUFSIZ];
      73:     int atend;
      74:     char *p, *q;
      75:     char *koshername;        /* "official" name */
      76:
      77:     if ((Aliases = fopen(ALIASFILE, "r")) == NULL) {
      78:         DEBUG(11, "No %s file\n", ALIASFILE);
      79:         return FAIL;              /* no alias file */
      80:     }
      81:
      82:     DEBUG (11, "Alias expansion for %s\n", *hostptr);
      83:     while (cfgets(buf, sizeof (buf), Aliases)) {
      84:         p = &buf[0];
      85:         atend = 0;
      86:         DEBUG(11, "Alias line: %s\n", buf);
      87:
      88:         while (!atend) {
      89:             while (isspace(*p) && *p != '\n')
      90:                 p++;              /* skip white space */
      91:             q = p;
      92:             while (!isspace(*q) && *q != '\n')
      93:                 q++;              /* find end */
      94:             if (*q == '\n')
      95:                 atend++;          /* last entry */
      96:             *q = '\0';
      97:             DEBUG(11, "Compare against: %s\n", p);
      98:             if (strcmp(*hostptr, p) == 0)/* match? */ {
      99:                 koshername = (char *)malloc((unsigned)strlen(buf) + 1);
     100:                 strcpy(koshername, buf); /* save it */
     101:                 fclose(Aliases);
     102:                 DEBUG(4, "Alias: %s to ", *hostptr);
     103:                 DEBUG(4, "%s\n", koshername);
     104:                 *hostptr = koshername;    /* correct one */
     105:                 return SUCCESS;       /* all is well */
     106:             }
     107:             p = q + 1;            /* try next entry */
     108:         }
     109:
     110:     }
     111:     fclose(Aliases);
     112:     DEBUG(11, "Alias doesn't match %s, remains unchanged\n", *hostptr);
     113:     return SUCCESS;               /* unchanged host */
     114: }

#### Defined functions

uualias defined in line 68; used 1 times

- in line 31

versys defined in line 23; used 6 times

- in /usr/src/usr.bin/uucp/cico.c line 295
- in /usr/src/usr.bin/uucp/uucp.c line 128, 161
- in /usr/src/usr.bin/uucp/uulog.c line 35
- in /usr/src/usr.bin/uucp/uupoll.c line 54
- in /usr/src/usr.bin/uucp/uux.c line 179

#### Defined variables

PhoneNumber defined in line 11; used 2 times

- in line 40, 47

sccsid defined in line 2; never used

Last modified: 1997-10-03 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 655 |