1: #
   2: /*
   3:  */
   4: 
   5: /*
   6:  * LP-11 Line printer driver
   7:  */
   8: 
   9: #include "../param.h"
  10: #include "../conf.h"
  11: #include "../user.h"
  12: 
  13: #define LPADDR  0177514
  14: 
  15: #define IENABLE 0100
  16: #define DONE    0200
  17: 
  18: #define LPPRI   10
  19: #define LPLWAT  50
  20: #define LPHWAT  100
  21: #define EJLINE  60
  22: #define MAXCOL  80
  23: 
  24: struct {
  25:     int lpsr;
  26:     int lpbuf;
  27: };
  28: 
  29: struct  {
  30:     int cc;
  31:     int cf;
  32:     int cl;
  33:     int flag;
  34:     int mcc;
  35:     int ccc;
  36:     int mlc;
  37: } lp11;
  38: 
  39: #define CAP 01      /* Set to 0 for 96-char printer, else to 01 */
  40: #define EJECT   02
  41: #define OPEN    04
  42: #define IND 010     /* Set to 0 for no indent, else to 010 */
  43: 
  44: #define FORM    014
  45: 
  46: lpopen(dev, flag)
  47: {
  48: 
  49:     if(lp11.flag & OPEN || LPADDR->lpsr < 0) {
  50:         u.u_error = EIO;
  51:         return;
  52:     }
  53:     lp11.flag =| (IND|EJECT|OPEN);
  54:     LPADDR->lpsr =| IENABLE;
  55:     lpcanon(FORM);
  56: }
  57: 
  58: lpclose(dev, flag)
  59: {
  60:     lpcanon(FORM);
  61:     lp11.flag = 0;
  62: }
  63: 
  64: lpwrite()
  65: {
  66:     register int c;
  67: 
  68:     while ((c=cpass())>=0)
  69:         lpcanon(c);
  70: }
  71: 
  72: lpcanon(c)
  73: {
  74:     register c1, c2;
  75: 
  76:     c1 = c;
  77:     if(lp11.flag&CAP) {
  78:         if(c1>='a' && c1<='z')
  79:             c1 =+ 'A'-'a'; else
  80:         switch(c1) {
  81: 
  82:         case '{':
  83:             c2 = '(';
  84:             goto esc;
  85: 
  86:         case '}':
  87:             c2 = ')';
  88:             goto esc;
  89: 
  90:         case '`':
  91:             c2 = '\'';
  92:             goto esc;
  93: 
  94:         case '|':
  95:             c2 = '!';
  96:             goto esc;
  97: 
  98:         case '~':
  99:             c2 = '^';
 100: 
 101:         esc:
 102:             lpcanon(c2);
 103:             lp11.ccc--;
 104:             c1 = '-';
 105:         }
 106:     }
 107: 
 108:     switch(c1) {
 109: 
 110:     case '\t':
 111:         lp11.ccc = (lp11.ccc+8) & ~7;
 112:         return;
 113: 
 114:     case FORM:
 115:     case '\n':
 116:         if((lp11.flag&EJECT) == 0 ||
 117:            lp11.mcc!=0 || lp11.mlc!=0) {
 118:             lp11.mcc = 0;
 119:             lp11.mlc++;
 120:             if(lp11.mlc >= EJLINE && lp11.flag&EJECT)
 121:                 c1 = FORM;
 122:             lpoutput(c1);
 123:             if(c1 == FORM)
 124:                 lp11.mlc = 0;
 125:         }
 126: 
 127:     case '\r':
 128:         lp11.ccc = 0;
 129:         if(lp11.flag&IND)
 130:             lp11.ccc = 8;
 131:         return;
 132: 
 133:     case 010:
 134:         if(lp11.ccc > 0)
 135:             lp11.ccc--;
 136:         return;
 137: 
 138:     case ' ':
 139:         lp11.ccc++;
 140:         return;
 141: 
 142:     default:
 143:         if(lp11.ccc < lp11.mcc) {
 144:             lpoutput('\r');
 145:             lp11.mcc = 0;
 146:         }
 147:         if(lp11.ccc < MAXCOL) {
 148:             while(lp11.ccc > lp11.mcc) {
 149:                 lpoutput(' ');
 150:                 lp11.mcc++;
 151:             }
 152:             lpoutput(c1);
 153:             lp11.mcc++;
 154:         }
 155:         lp11.ccc++;
 156:     }
 157: }
 158: 
 159: lpstart()
 160: {
 161:     register int c;
 162: 
 163:     while (LPADDR->lpsr&DONE && (c = getc(&lp11)) >= 0)
 164:         LPADDR->lpbuf = c;
 165: }
 166: 
 167: lpint()
 168: {
 169:     register int c;
 170: 
 171:     lpstart();
 172:     if (lp11.cc == LPLWAT || lp11.cc == 0)
 173:         wakeup(&lp11);
 174: }
 175: 
 176: lpoutput(c)
 177: {
 178:     if (lp11.cc >= LPHWAT)
 179:         sleep(&lp11, LPPRI);
 180:     putc(c, &lp11);
 181:     spl4();
 182:     lpstart();
 183:     spl0();
 184: }

Defined functions

lpcanon defined in line 72; used 4 times
lpclose defined in line 58; never used
lpint defined in line 167; never used
lpopen defined in line 46; never used
lpoutput defined in line 176; used 4 times
lpstart defined in line 159; used 2 times
lpwrite defined in line 64; never used

Defined macros

CAP defined in line 39; used 1 times
  • in line 77
DONE defined in line 16; used 1 times
EJECT defined in line 40; used 3 times
EJLINE defined in line 21; used 1 times
FORM defined in line 44; used 4 times
IENABLE defined in line 15; used 1 times
  • in line 54
IND defined in line 42; used 2 times
LPADDR defined in line 13; used 4 times
LPHWAT defined in line 20; used 1 times
LPLWAT defined in line 19; used 1 times
LPPRI defined in line 18; used 1 times
MAXCOL defined in line 22; used 1 times
OPEN defined in line 41; used 2 times
Last modified: 1975-07-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 835
Valid CSS Valid XHTML 1.0 Strict