|
|
1.1 ! root 1: #include "pen.h" ! 2: #define PLOTTER "/dev/hp7580" ! 3: ! 4: struct sgttyb vvec; ! 5: struct ttydevb dvec; ! 6: extern int tty_ld; ! 7: ! 8: openpl(s) ! 9: char *s; ! 10: { ! 11: int n, dp; ! 12: ! 13: dp = open(PLOTTER, 2); ! 14: if (dp < 0) { ! 15: fprintf(stderr, "cannot open plotter %s\n", PLOTTER); ! 16: exit(1); ! 17: } ! 18: if(ioctl(dp, FIOLOOKLD, 0) != tty_ld){ ! 19: if(ioctl(dp, FIOPUSHLD, &tty_ld) < 0){ ! 20: perror("tty_ld"); ! 21: exit(1); ! 22: } ! 23: } ! 24: if(ioctl(dp, TIOCEXCL, 0)){ ! 25: perror("plotter in use"); ! 26: exit(1); ! 27: } ! 28: vvec.sg_ispeed = vvec.sg_ospeed = B9600; ! 29: vvec.sg_flags = CBREAK|CRMOD|TANDEM; ! 30: vvec.sg_erase = 0; ! 31: vvec.sg_kill = 0; ! 32: ioctl(dp, TIOCGDEV, &dvec); ! 33: if(ioctl(dp, TIOCSETP, &vvec) < 0){ ! 34: perror("ioctl"); ! 35: exit(1); ! 36: } ! 37: dvec.ispeed = dvec.ospeed = vvec.sg_ispeed; ! 38: dvec.flags |= EVENP|ODDP; ! 39: if(ioctl(dp, TIOCSDEV, &dvec) < 0){ ! 40: perror("ioctl1"); ! 41: exit(1); ! 42: } ! 43: ioctl(dp, TIOCEXCL, 0); ! 44: if((pltin = fdopen(dp, "r")) == NULL) { ! 45: fprintf(stderr, "cannot fdopen, pltin"); ! 46: exit(1); ! 47: } ! 48: if((pltout = fdopen(dp, "w")) == NULL) { ! 49: fprintf(stderr, "cannot fdopen, pltout"); ! 50: exit(1); ! 51: } ! 52: /* system("stty >/dev/hp7580"); ! 53: */ ! 54: fprintf(pltout, "\033.I;;17:"); ! 55: fprintf(pltout, "\033.N;19:"); ! 56: fprintf(pltout, "\033.M10;;;10:"); ! 57: fprintf(pltout, " IN SP 1 SR .67,1.0\n"); ! 58: fprintf(pltout,"OP;\n"); ! 59: fflush(pltout); ! 60: e0->p1x = e1->p1x = (float) readInt(pltin); ! 61: e0->p1y = e1->p1y = (float) readInt(pltin); ! 62: e0->p2x = e1->p2x = (float) readInt(pltin); ! 63: e0->p2y = e1->p2y = (float) readInt(pltin); ! 64: DX = e0->p2x - e0->p1x; ! 65: e0->xmax = e1->xmax = DX; ! 66: DY = e0->p2y - e0->p1y; ! 67: e0->ymax = e1->ymax = DY; ! 68: e0->scale = e1->scale = 1.; ! 69: e0->pen = e1->pen = 1; ! 70: e0->charsz = e1->charsz = 1.; ! 71: e0->brush = e1->brush = 1; ! 72: e0->pentype = e1->pentype = 0; ! 73: e0->xmin = e1->xmin = 0; ! 74: e0->ymin = e1->ymin = 0; ! 75: e0->pslant = e1->pslant = 0; ! 76: e0->pgap = e1->pgap = 2.; ! 77: if(*s == 'N'){ ! 78: noscale = 0; ! 79: fprintf(pltout,"SC %8.2f,%8.2f %8.2f,%8.2f\n", ! 80: e1->xmin,e1->xmax,e1->ymin,e1->ymax); ! 81: } ! 82: ckerr(1); ! 83: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.