1: #ifndef lint
   2: static char sccsid[] = "@(#)df12.c	4.1 (Berkeley) 4/3/85";
   3: #endif
   4: 
   5: #include "../condevs.h"
   6: 
   7: #ifdef DF112
   8: /*
   9:  *	df12popn(telno, flds, dev) connect to df12 modem (pulse call)
  10:  *	df12topn(telno, flds, dev) connect to df12 modem (tone call)
  11:  *	char *flds[], *dev[];
  12:  *
  13:  *	return codes:
  14:  *		>0  -  file number  -  ok
  15:  *		CF_DIAL,CF_NODEV  -  failed
  16:  */
  17: 
  18: df12popn (telno, flds, dev)
  19: char   *telno,
  20:        *flds[];
  21: struct Devices *dev;
  22: {
  23:     return df12opn (telno, flds, dev, 0);
  24: }
  25: 
  26: df12topn (telno, flds, dev)
  27: char   *telno,
  28:        *flds[];
  29: struct Devices *dev;
  30: {
  31:     return df12opn (telno, flds, dev, 1);
  32: }
  33: 
  34: /* ARGSUSED */
  35: df12opn (telno, flds, dev, toneflag)
  36: char   *telno;
  37: char   *flds[];
  38: struct Devices *dev;
  39: int     toneflag;
  40: {
  41:     int     phindex, dh = -1;
  42:     extern  errno;
  43:     char    dcname[20], newphone[64];
  44: 
  45:     sprintf (dcname, "/dev/%s", dev -> D_line);
  46:     DEBUG (4, "dc - %s\n", dcname);
  47:     if (setjmp (Sjbuf))
  48:     {
  49:     logent (dcname, "TIMEOUT");
  50:     if (dh >= 0)
  51:         close (dh);
  52:     return CF_DIAL;
  53:     }
  54:     signal (SIGALRM, alarmtr);
  55:     getnextfd ();
  56:     alarm (10);
  57:     dh = open (dcname, 2);/* read/write */
  58:     alarm (0);
  59: 
  60:  /* modem is open */
  61: 
  62:  /* First, adjust our phone number string.  These modems don't
  63:   * like any characters but digits and "=" signs (for delay)
  64:   */
  65:     for (phindex = 0; *telno; telno++)
  66:     {
  67:     if (*telno == '=' || (*telno >= '0' && *telno <= '9'))
  68:         newphone[phindex++] = *telno;
  69:     if (phindex == 64)
  70:     {
  71:         logent (dcname, "Phone number too long");
  72:         close (dh);
  73:         return CF_DIAL;
  74:     }
  75:     }
  76:     newphone[phindex] = '\0';
  77:     next_fd = -1;
  78:     if (dh >= 0)
  79:     {
  80:     fixline (dh, dev -> D_speed);
  81:     if (dochat (dev, flds, dh))
  82:     {
  83:         logent (dcname, "CHAT FAILED");
  84:         close (dh);
  85:         return CF_DIAL;
  86:     }
  87:     slowrite (dh, "\02");
  88:     if (expect ("Ready\r\n", dh) != 0)
  89:     {
  90:         DEBUG (4, "Didn't get 'Ready' response.\n", NULL);
  91:         logent (dcname, "Modem not responding");
  92:         close (dh);
  93:         return CF_DIAL;
  94:     }
  95:     DEBUG (4, "Got 'Ready' response\n", NULL);
  96:     DEBUG (7, "Writing control select flag %c\n", toneflag ? 'T' : 'P');
  97:     slowrite (dh, toneflag ? "T" : "P");
  98:     DEBUG (4, "Writing telephone number %s\n", newphone);
  99:     slowrite (dh, newphone);
 100:     DEBUG (7, "Telephone number written\n", NULL);
 101:     slowrite (dh, "#");
 102:     DEBUG (7, "Writing # sign\n", NULL);
 103: 
 104:     if (expect ("Attached\r\n", dh) != 0)
 105:     {
 106:         logent (dcname, "No carrier");
 107:         strcpy (devSel, dev -> D_line);
 108:         df12cls (dh);
 109:         return CF_DIAL;
 110:     }
 111: 
 112:     }
 113:     if (dh < 0)
 114:     {
 115:     logent (dcname, "CAN'T OPEN");
 116:     return CF_NODEV;
 117:     }
 118:     else
 119:     {
 120:     DEBUG (4, "df12 ok\n", CNULL);
 121:     return dh;
 122:     }
 123: }
 124: 
 125: df12cls (fd)
 126: int     fd;
 127: {
 128:     char    dcname[20];
 129:     struct sgttyb   hup,
 130:                     sav;
 131: 
 132:     if (fd > 0)
 133:     {
 134:     sprintf (dcname, "/dev/%s", devSel);
 135:     DEBUG (4, "Hanging up fd = %d\n", fd);
 136:     /*
 137:      * code to drop DTR -- change to 0 baud then back to default.
 138:      */
 139:     gtty (fd, &hup);
 140:     gtty (fd, &sav);
 141:     hup.sg_ispeed = B0;
 142:     hup.sg_ospeed = B0;
 143:     stty (fd, &hup);
 144:     sleep (2);
 145:     stty (fd, &sav);
 146:     /*
 147:      * now raise DTR -- close the device & open it again.
 148:      */
 149:     sleep (2);
 150:     close (fd);
 151:     sleep (2);
 152:     delock (devSel);
 153:     }
 154: }
 155: 
 156: #endif DF112

Defined functions

df12cls defined in line 125; used 1 times
df12opn defined in line 35; used 2 times
df12popn defined in line 18; never used
df12topn defined in line 26; never used

Defined variables

sccsid defined in line 2; never used
Last modified: 1986-01-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1128
Valid CSS Valid XHTML 1.0 Strict