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[] = "@(#)dn11.c	5.1 (Berkeley) 4/30/85";
   9: #endif not lint
  10: 
  11: /*
  12:  * Routines for dialing up on DN-11
  13:  */
  14: #include "tip.h"
  15: 
  16: int dn_abort(), alarmtr();
  17: static jmp_buf jmpbuf;
  18: static int child = -1, dn;
  19: 
  20: dn_dialer(num, acu)
  21:     char *num, *acu;
  22: {
  23:     extern errno;
  24:     char *p, *q, phone[40];
  25:     int lt, nw, connected = 1;
  26:     register int timelim;
  27: 
  28:     if (boolean(value(VERBOSE)))
  29:         printf("\nstarting call...");
  30:     if ((dn = open(acu, 1)) < 0) {
  31:         if (errno == EBUSY)
  32:             printf("line busy...");
  33:         else
  34:             printf("acu open error...");
  35:         return (0);
  36:     }
  37:     if (setjmp(jmpbuf)) {
  38:         kill(child, SIGKILL);
  39:         close(dn);
  40:         return (0);
  41:     }
  42:     signal(SIGALRM, alarmtr);
  43:     timelim = 5 * strlen(num);
  44:     alarm(timelim < 30 ? 30 : timelim);
  45:     if ((child = fork()) == 0) {
  46:         /*
  47: 		 * ignore this stuff for aborts
  48: 		 */
  49:         signal(SIGALRM, SIG_IGN);
  50:         signal(SIGINT, SIG_IGN);
  51:         signal(SIGQUIT, SIG_IGN);
  52:         sleep(2);
  53:         nw = write(dn, num, lt = strlen(num));
  54:         exit(nw != lt);
  55:     }
  56:     /*
  57: 	 * open line - will return on carrier
  58: 	 */
  59:     if ((FD = open(DV, 2)) < 0) {
  60:         if (errno == EIO)
  61:             printf("lost carrier...");
  62:         else
  63:             printf("dialup line open failed...");
  64:         alarm(0);
  65:         kill(child, SIGKILL);
  66:         close(dn);
  67:         return (0);
  68:     }
  69:     alarm(0);
  70:     ioctl(dn, TIOCHPCL, 0);
  71:     signal(SIGALRM, SIG_DFL);
  72:     while ((nw = wait(&lt)) != child && nw != -1)
  73:         ;
  74:     fflush(stdout);
  75:     close(dn);
  76:     if (lt != 0) {
  77:         close(FD);
  78:         return (0);
  79:     }
  80:     return (1);
  81: }
  82: 
  83: alarmtr()
  84: {
  85: 
  86:     alarm(0);
  87:     longjmp(jmpbuf, 1);
  88: }
  89: 
  90: /*
  91:  * Insurance, for some reason we don't seem to be
  92:  *  hanging up...
  93:  */
  94: dn_disconnect()
  95: {
  96: 
  97:     sleep(2);
  98:     if (FD > 0)
  99:         ioctl(FD, TIOCCDTR, 0);
 100:     close(FD);
 101: }
 102: 
 103: dn_abort()
 104: {
 105: 
 106:     sleep(2);
 107:     if (child > 0)
 108:         kill(child, SIGKILL);
 109:     if (dn > 0)
 110:         close(dn);
 111:     if (FD > 0)
 112:         ioctl(FD, TIOCCDTR, 0);
 113:     close(FD);
 114: }

Defined functions

alarmtr defined in line 83; used 2 times
dn_abort defined in line 103; used 1 times
  • in line 16
dn_dialer defined in line 20; never used
dn_disconnect defined in line 94; never used

Defined variables

child defined in line 18; used 6 times
sccsid defined in line 8; never used
Last modified: 1985-04-30
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 935
Valid CSS Valid XHTML 1.0 Strict