1: #ifndef lint
   2: static char sccsid[] = "@(#)mic.c	4.1 (Berkeley) 1/22/85";
   3: #endif
   4: 
   5: #include "../condevs.h"
   6: #ifdef MICOM
   7: 
   8: /*
   9:  *	micopn: establish connection through a micom.
  10:  *	Returns descriptor open to tty for reading and writing.
  11:  *	Negative values (-1...-7) denote errors in connmsg.
  12:  *	Be sure to disconnect tty when done, via HUPCL or stty 0.
  13:  */
  14: micopn(flds)
  15: register char *flds[];
  16: {
  17:     extern errno;
  18:     char *rindex(), *fdig(), dcname[20];
  19:     int dh, ok = 0, speed;
  20:     register struct condev *cd;
  21:     register FILE *dfp;
  22:     struct Devices dev;
  23: 
  24:     dfp = fopen(DEVFILE, "r");
  25:     ASSERT(dfp != NULL, "Can't open", DEVFILE, 0);
  26: 
  27:     signal(SIGALRM, alarmtr);
  28:     dh = -1;
  29:     for(cd = condevs; ((cd->CU_meth != NULL)&&(dh < 0)); cd++) {
  30:         if (snccmp(flds[F_LINE], cd->CU_meth) == SAME) {
  31:             fseek(dfp, (off_t)0, 0);
  32:             while(rddev(dfp, &dev) != FAIL) {
  33:                 if (strcmp(flds[F_CLASS], dev.D_class) != SAME)
  34:                     continue;
  35:                 if (snccmp(flds[F_LINE], dev.D_type) != SAME)
  36:                     continue;
  37:                 if (mlock(dev.D_line) == FAIL)
  38:                     continue;
  39: 
  40:                 sprintf(dcname, "/dev/%s", dev.D_line);
  41:                 getnextfd();
  42:                 alarm(10);
  43:                 if (setjmp(Sjbuf)) {
  44:                     delock(dev.D_line);
  45:                     logent(dev.D_line,"micom open TIMEOUT");
  46:                     dh = -1;
  47:                     break;
  48:                 }
  49:                 dh = open(dcname, 2);
  50:                 alarm(0);
  51:                 next_fd = -1;
  52:                 if (dh > 0) {
  53:                     break;
  54:                 }
  55:                 devSel[0] = '\0';
  56:                 delock(dev.D_line);
  57:             }
  58:         }
  59:     }
  60:     fclose(dfp);
  61:     if (dh < 0)
  62:         return CF_NODEV;
  63: 
  64:     speed = atoi(fdig(flds[F_CLASS]));
  65:     fixline(dh, speed);
  66:     sleep(1);
  67: 
  68:     /* negotiate with micom */
  69:     if (speed != 4800)  /* damn their eyes! */
  70:         write(dh, "\r", 1);
  71:     else
  72:         write(dh, " ", 1);
  73: 
  74:     DEBUG(4, "wanted %s ", "SELECTION");
  75:     ok = expect("SELECTION", dh);
  76:     DEBUG(4, "got %s\n", ok ? "?" : "that");
  77:     if (ok == 0) {
  78:         write(dh, flds[F_PHONE], strlen(flds[F_PHONE]));
  79:         sleep(1);
  80:         write(dh, "\r", 1);
  81:         DEBUG(4, "wanted %s ", "GO");
  82:         ok = expect("GO", dh);
  83:         DEBUG(4, "got %s\n", ok ? "?" : "that");
  84:     }
  85: 
  86:     if (ok != 0) {
  87:         if (dh > 2)
  88:             close(dh);
  89:         DEBUG(4, "micom failed\n", "");
  90:         delock(dev.D_line);
  91:         return(CF_DIAL);
  92:     }
  93:     else
  94:         DEBUG(4, "micom ok\n", "");
  95: 
  96:     CU_end = cd->CU_clos;
  97:     strcat(devSel, dev.D_line); /* for later unlock */
  98:     return dh;
  99: }
 100: 
 101: miccls(fd)
 102: register int fd;
 103: {
 104: 
 105:     if (fd > 0) {
 106:         close(fd);
 107:         delock(devSel);
 108:     }
 109: }
 110: #endif MICOM

Defined functions

miccls defined in line 101; never used
micopn defined in line 14; never used

Defined variables

sccsid defined in line 2; never used
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1430
Valid CSS Valid XHTML 1.0 Strict