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[] = "@(#)biz22.c	5.1 (Berkeley) 6/6/85";
   9: #endif not lint
  10: 
  11: #include "tip.h"
  12: 
  13: #define DISCONNECT_CMD  "\20\04"    /* disconnection string */
  14: 
  15: static  int sigALRM();
  16: static  int timeout = 0;
  17: static  jmp_buf timeoutbuf;
  18: 
  19: /*
  20:  * Dial up on a BIZCOMP Model 1022 with either
  21:  * 	tone dialing (mod = "V")
  22:  *	pulse dialing (mod = "W")
  23:  */
  24: static int
  25: biz_dialer(num, mod)
  26:     char *num, *mod;
  27: {
  28:     register int connected = 0;
  29:     char cbuf[40];
  30: 
  31:     if (boolean(value(VERBOSE)))
  32:         printf("\nstarting call...");
  33:     /*
  34: 	 * Disable auto-answer and configure for tone/pulse
  35: 	 *  dialing
  36: 	 */
  37:     if (cmd("\02K\r")) {
  38:         printf("can't initialize bizcomp...");
  39:         return (0);
  40:     }
  41:     strcpy(cbuf, "\02.\r");
  42:     cbuf[1] = *mod;
  43:     if (cmd(cbuf)) {
  44:         printf("can't set dialing mode...");
  45:         return (0);
  46:     }
  47:     strcpy(cbuf, "\02D");
  48:     strcat(cbuf, num);
  49:     strcat(cbuf, "\r");
  50:     write(FD, cbuf, strlen(cbuf));
  51:     if (!detect("7\r")) {
  52:         printf("can't get dial tone...");
  53:         return (0);
  54:     }
  55:     if (boolean(value(VERBOSE)))
  56:         printf("ringing...");
  57:     /*
  58: 	 * The reply from the BIZCOMP should be:
  59: 	 *	2 \r or 7 \r	failure
  60: 	 *	1 \r		success
  61: 	 */
  62:     connected = detect("1\r");
  63: #ifdef ACULOG
  64:     if (timeout) {
  65:         char line[80];
  66: 
  67:         sprintf(line, "%d second dial timeout",
  68:             number(value(DIALTIMEOUT)));
  69:         logent(value(HOST), num, "biz1022", line);
  70:     }
  71: #endif
  72:     if (timeout)
  73:         biz22_disconnect(); /* insurance */
  74:     return (connected);
  75: }
  76: 
  77: biz22w_dialer(num, acu)
  78:     char *num, *acu;
  79: {
  80: 
  81:     return (biz_dialer(num, "W"));
  82: }
  83: 
  84: biz22f_dialer(num, acu)
  85:     char *num, *acu;
  86: {
  87: 
  88:     return (biz_dialer(num, "V"));
  89: }
  90: 
  91: biz22_disconnect()
  92: {
  93:     int rw = 2;
  94: 
  95:     write(FD, DISCONNECT_CMD, 4);
  96:     sleep(2);
  97:     ioctl(FD, TIOCFLUSH, &rw);
  98: }
  99: 
 100: biz22_abort()
 101: {
 102: 
 103:     write(FD, "\02", 1);
 104: }
 105: 
 106: static int
 107: sigALRM()
 108: {
 109: 
 110:     timeout = 1;
 111:     longjmp(timeoutbuf, 1);
 112: }
 113: 
 114: static int
 115: cmd(s)
 116:     register char *s;
 117: {
 118:     char c;
 119:     int (*f)();
 120: 
 121:     write(FD, s, strlen(s));
 122:     f = signal(SIGALRM, sigALRM);
 123:     if (setjmp(timeoutbuf)) {
 124:         biz22_abort();
 125:         signal(SIGALRM, f);
 126:         return (1);
 127:     }
 128:     alarm(number(value(DIALTIMEOUT)));
 129:     read(FD, &c, 1);
 130:     alarm(0);
 131:     signal(SIGALRM, f);
 132:     c &= 0177;
 133:     return (c != '\r');
 134: }
 135: 
 136: static int
 137: detect(s)
 138:     register char *s;
 139: {
 140:     char c;
 141:     int (*f)();
 142: 
 143:     f = signal(SIGALRM, sigALRM);
 144:     timeout = 0;
 145:     while (*s) {
 146:         if (setjmp(timeoutbuf)) {
 147:             biz22_abort();
 148:             break;
 149:         }
 150:         alarm(number(value(DIALTIMEOUT)));
 151:         read(FD, &c, 1);
 152:         alarm(0);
 153:         c &= 0177;
 154:         if (c != *s++)
 155:             return (0);
 156:     }
 157:     signal(SIGALRM, f);
 158:     return (timeout == 0);
 159: }

Defined functions

biz22_abort defined in line 100; used 2 times
biz22_disconnect defined in line 91; used 1 times
  • in line 73
biz22f_dialer defined in line 84; never used
biz22w_dialer defined in line 77; never used
biz_dialer defined in line 24; used 2 times
cmd defined in line 114; used 2 times
detect defined in line 136; used 2 times
sigALRM defined in line 106; used 3 times

Defined variables

sccsid defined in line 8; never used
timeout defined in line 16; used 5 times

Defined macros

DISCONNECT_CMD defined in line 13; used 1 times
  • in line 95
Last modified: 1985-06-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3438
Valid CSS Valid XHTML 1.0 Strict