1: /*
   2:  * Copyright (c) 1983 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifndef lint
   8: static char sccsid[] = "@(#)remote.c	5.3 (Berkeley) 4/30/86";
   9: #endif not lint
  10: 
  11: # include "tip.h"
  12: 
  13: /*
  14:  * Attributes to be gleened from remote host description
  15:  *   data base.
  16:  */
  17: static char **caps[] = {
  18:     &AT, &DV, &CM, &CU, &EL, &IE, &OE, &PN, &PR, &DI,
  19:     &ES, &EX, &FO, &RC, &RE, &PA
  20: };
  21: 
  22: static char *capstrings[] = {
  23:     "at", "dv", "cm", "cu", "el", "ie", "oe", "pn", "pr",
  24:     "di", "es", "ex", "fo", "rc", "re", "pa", 0
  25: };
  26: 
  27: char *rgetstr();
  28: 
  29: static
  30: getremcap(host)
  31:     register char *host;
  32: {
  33:     int stat;
  34:     char tbuf[BUFSIZ];
  35:     static char buf[BUFSIZ/2];
  36:     char *bp = buf;
  37:     register char **p, ***q;
  38: 
  39:     if ((stat = rgetent(tbuf, host)) <= 0) {
  40:         if (DV ||
  41:             host[0] == '/' && access(DV = host, R_OK | W_OK) == 0) {
  42:             CU = DV;
  43:             HO = host;
  44:             HW = 1;
  45:             DU = 0;
  46:             if (!BR)
  47:                 BR = DEFBR;
  48:             FS = DEFFS;
  49:             return;
  50:         }
  51:         fprintf(stderr, stat == 0 ?
  52:             "tip: unknown host %s\n" :
  53:             "tip: can't open host description file\n", host);
  54:         exit(3);
  55:     }
  56: 
  57:     for (p = capstrings, q = caps; *p != NULL; p++, q++)
  58:         if (**q == NULL)
  59:             **q = rgetstr(*p, &bp);
  60:     if (!BR && (BR = rgetnum("br")) < 0)
  61:         BR = DEFBR;
  62:     if ((FS = rgetnum("fs")) < 0)
  63:         FS = DEFFS;
  64:     if (DU < 0)
  65:         DU = 0;
  66:     else
  67:         DU = rgetflag("du");
  68:     if (DV == NOSTR) {
  69:         fprintf(stderr, "%s: missing device spec\n", host);
  70:         exit(3);
  71:     }
  72:     if (DU && CU == NOSTR)
  73:         CU = DV;
  74:     if (DU && PN == NOSTR) {
  75:         fprintf(stderr, "%s: missing phone number\n", host);
  76:         exit(3);
  77:     }
  78: 
  79:     HD = rgetflag("hd");
  80: 
  81:     /*
  82: 	 * This effectively eliminates the "hw" attribute
  83: 	 *   from the description file
  84: 	 */
  85:     if (!HW)
  86:         HW = (CU == NOSTR) || (DU && equal(DV, CU));
  87:     HO = host;
  88:     /*
  89: 	 * see if uppercase mode should be turned on initially
  90: 	 */
  91:     if (rgetflag("ra"))
  92:         boolean(value(RAISE)) = 1;
  93:     if (rgetflag("ec"))
  94:         boolean(value(ECHOCHECK)) = 1;
  95:     if (rgetflag("be"))
  96:         boolean(value(BEAUTIFY)) = 1;
  97:     if (rgetflag("nb"))
  98:         boolean(value(BEAUTIFY)) = 0;
  99:     if (rgetflag("sc"))
 100:         boolean(value(SCRIPT)) = 1;
 101:     if (rgetflag("tb"))
 102:         boolean(value(TABEXPAND)) = 1;
 103:     if (rgetflag("vb"))
 104:         boolean(value(VERBOSE)) = 1;
 105:     if (rgetflag("nv"))
 106:         boolean(value(VERBOSE)) = 0;
 107:     if (rgetflag("ta"))
 108:         boolean(value(TAND)) = 1;
 109:     if (rgetflag("nt"))
 110:         boolean(value(TAND)) = 0;
 111:     if (rgetflag("rw"))
 112:         boolean(value(RAWFTP)) = 1;
 113:     if (rgetflag("hd"))
 114:         boolean(value(HALFDUPLEX)) = 1;
 115:     if (RE == NOSTR)
 116:         RE = (char *)"tip.record";
 117:     if (EX == NOSTR)
 118:         EX = (char *)"\t\n\b\f";
 119:     if (ES != NOSTR)
 120:         vstring("es", ES);
 121:     if (FO != NOSTR)
 122:         vstring("fo", FO);
 123:     if (PR != NOSTR)
 124:         vstring("pr", PR);
 125:     if (RC != NOSTR)
 126:         vstring("rc", RC);
 127:     if ((DL = rgetnum("dl")) < 0)
 128:         DL = 0;
 129:     if ((CL = rgetnum("cl")) < 0)
 130:         CL = 0;
 131:     if ((ET = rgetnum("et")) < 0)
 132:         ET = 10;
 133: }
 134: 
 135: char *
 136: getremote(host)
 137:     char *host;
 138: {
 139:     register char *cp;
 140:     static char *next;
 141:     static int lookedup = 0;
 142: 
 143:     if (!lookedup) {
 144:         if (host == NOSTR && (host = getenv("HOST")) == NOSTR) {
 145:             fprintf(stderr, "tip: no host specified\n");
 146:             exit(3);
 147:         }
 148:         getremcap(host);
 149:         next = DV;
 150:         lookedup++;
 151:     }
 152:     /*
 153: 	 * We return a new device each time we're called (to allow
 154: 	 *   a rotary action to be simulated)
 155: 	 */
 156:     if (next == NOSTR)
 157:         return (NOSTR);
 158:     if ((cp = index(next, ',')) == NULL) {
 159:         DV = next;
 160:         next = NOSTR;
 161:     } else {
 162:         *cp++ = '\0';
 163:         DV = next;
 164:         next = cp;
 165:     }
 166:     return (DV);
 167: }

Defined functions

getremcap defined in line 29; used 1 times
getremote defined in line 135; used 2 times

Defined variables

caps defined in line 17; used 1 times
  • in line 57
capstrings defined in line 22; used 1 times
  • in line 57
sccsid defined in line 8; never used
Last modified: 1986-04-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1142
Valid CSS Valid XHTML 1.0 Strict