BSD 4_3_Reno release
[unix-history] / usr / src / usr.sbin / lpr / vfilters / vcat / vcat.c
CommitLineData
fa32567f
DF
1/*
2 * Copyright (c) 1983 Regents of the University of California.
9b0a4950
KB
3 * All rights reserved.
4 *
1c15e888
C
5 * Redistribution and use in source and binary forms are permitted provided
6 * that: (1) source distributions retain this entire copyright notice and
7 * comment, and (2) distributions including binaries display the following
8 * acknowledgement: ``This product includes software developed by the
9 * University of California, Berkeley and its contributors'' in the
10 * documentation or other materials provided with the distribution and in
11 * all advertising materials mentioning features or use of this software.
12 * Neither the name of the University nor the names of its contributors may
13 * be used to endorse or promote products derived from this software without
14 * specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
16 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
fa32567f
DF
18 */
19
c936af6c 20#ifndef lint
9b0a4950
KB
21char copyright[] =
22"@(#) Copyright (c) 1983 Regents of the University of California.\n\
23 All rights reserved.\n";
24#endif /* not lint */
25
26#ifndef lint
1c15e888 27static char sccsid[] = "@(#)vcat.c 5.5 (Berkeley) 6/1/90";
9b0a4950 28#endif /* not lint */
c936af6c 29
5647b8c0
BJ
30/*
31 * Cat Simulator for Versatec and Varian
32 */
33
5647b8c0 34#include <stdio.h>
5647b8c0
BJ
35#include <sys/vcmd.h>
36#include <vfont.h>
37
dfc1084e
RC
38int prtmode[] = {VPRINT};
39int pltmode[] = {VPLOT};
5647b8c0
BJ
40
41#define DISPATCHSIZE 256 /* must be a power of two */
42#define CHARMASK (DISPATCHSIZE-1)
43#define NFONTS 25
44#define SPECIALFONT 3
45#define DSIZ ((sizeof *dispatch)*DISPATCHSIZE)
46#define MAXF 4
47
48#define LOCAL_RAILMAG ".railmag"
49#define GLOBAL_RAILMAG "/usr/lib/vfont/railmag"
50
51#define CONVERT(n) (n*(200./432.))
52#define RECONVERT(n) (n*(432./200.))
53
5647b8c0 54#define NLINES 110
5647b8c0 55
46e69590
RC
56char buffer[NLINES * 880]; /* Big enough for versatec */
57char *buf0p = &buffer[0]; /* Zero origin in circular buffer */
5647b8c0
BJ
58
59char *calloc();
60char *nalloc();
61char *allpanic();
62
63struct header header;
64struct dispatch *dispatch;
65
66struct fontdes {
67 int fnum;
68 int psize;
69 struct dispatch *disp;
70 char *bits;
71} fontdes[NFONTS] = {
72 -1,
73 -1
74};
75
76struct point_sizes {
77 int stupid_code;
78 int real_code;
79} point_sizes[] = {
80 010, 6,
81 0, 7,
82 01, 8,
83 07, 9,
84 02, 10,
85 03, 11,
86 04, 12,
87 05, 14,
88 0211, 16,
89 06, 18,
90 0212, 20,
91 0213, 22,
92 0214, 24,
93 0215, 28,
94 0216, 36,
95 0, 0
96};
97
5647b8c0
BJ
98int lines;
99
99b206fb
RC
100int vc = 1; /* varian/versatec output file descriptor */
101int varian; /* 0 for versatec, 1 for varian. */
102int BYTES_PER_LINE = 880; /* number of bytes per raster line. */
103int PAGE_LINES = 2400; /* number of raster lines per page. */
104int BUFFER_SIZE = NLINES * 880; /* buffer size. */
5647b8c0
BJ
105int cfnum = -1;
106int cpsize = 10;
107int cfont = 1;
108char *bits;
109int nfontnum = -1;
110int fontwanted = 1;
111int npsize = 10;
112int last_ssize = 02;
113int xpos, ypos;
114int esc, lead, back, verd, mcase, railmag;
115double row, col;
116char *fontname[MAXF];
117char fnbuf[120];
118char *scanline;
119int linecount;
120
121char asctab[128] = {
122 '\0', /*blank*/
123 'h', /*h*/
124 't', /*t*/
125 'n', /*n*/
126 'm', /*m*/
127 'l', /*l*/
128 'i', /*i*/
129 'z', /*z*/
130 's', /*s*/
131 'd', /*d*/
132 'b', /*b*/
133 'x', /*x*/
134 'f', /*f*/
135 'j', /*j*/
136 'u', /*u*/
137 'k', /*k*/
138 '\0', /*blank*/
139 'p', /*p*/
140 '\06', /*_ 3/4 em dash*/
141 ';', /*;*/
142 '\0', /*blank*/
143 'a', /*a*/
144 '\05', /*rule*/
145 'c', /*c*/
146 '`', /*` open*/
147 'e', /*e*/
148 '\'', /*' close*/
149 'o', /*o*/
150 '\021', /*1/4*/
151 'r', /*r*/
152 '\022', /*1/2*/
153 'v', /*v*/
154 '-', /*- hyphen*/
155 'w', /*w*/
156 'q', /*q*/
157 '/', /*/*/
158 '.', /*.*/
159 'g', /*g*/
160 '\023', /*3/4*/
161 ',', /*,*/
162 '&', /*&*/
163 'y', /*y*/
164 '\0', /*blank*/
165 '%', /*%*/
166 '\0', /*blank*/
167 'Q', /*Q*/
168 'T', /*T*/
169 'O', /*O*/
170 'H', /*H*/
171 'N', /*N*/
172 'M', /*M*/
173 'L', /*L*/
174 'R', /*R*/
175 'G', /*G*/
176 'I', /*I*/
177 'P', /*P*/
178 'C', /*C*/
179 'V', /*V*/
180 'E', /*E*/
181 'Z', /*Z*/
182 'D', /*D*/
183 'B', /*B*/
184 'S', /*S*/
185 'Y', /*Y*/
186 '\0', /*blank*/
187 'F', /*F*/
188 'X', /*X*/
189 'A', /*A*/
190 'W', /*W*/
191 'J', /*J*/
192 'U', /*U*/
193 'K', /*K*/
194 '0', /*0*/
195 '1', /*1*/
196 '2', /*2*/
197 '3', /*3*/
198 '4', /*4*/
199 '5', /*5*/
200 '6', /*6*/
201 '7', /*7*/
202 '8', /*8*/
203 '9', /*9*/
204 '*', /***/
205 '\04', /*minus*/
206 '\01', /*fi*/
207 '\02', /*fl*/
208 '\03', /*ff*/
209 '\020', /* cent sign */
210 '\012', /*ffl*/
211 '\011', /*ffi*/
212 '(', /*(*/
213 ')', /*)*/
214 '[', /*[*/
215 ']', /*]*/
216 '\013', /* degree */
217 '\014', /* dagger */
218 '=', /*=*/
219 '\017', /* registered */
220 ':', /*:*/
221 '+', /*+*/
222 '\0', /*blank*/
223 '!', /*!*/
224 '\07', /* bullet */
225 '?', /*?*/
226 '\015', /*foot mark*/
227 '|', /*|*/
228 '\0', /*blank*/
229 '\016', /* copyright */
230 '\010', /* square */
231 '$', /*$*/
232 '\0',
233 '\0',
234 '"', /*"*/
235 '#', /*#*/
236 '<', /*<*/
237 '>', /*>*/
238 '@', /*@*/
239 '\\', /*\\*/
240 '^', /*^*/
241 '{', /*{*/
242 '}', /*}*/
243 '~' /*~*/
244};
245
246char spectab[128] = {
247 '\0', /*blank*/
248 'w', /*psi*/
249 'h', /*theta*/
250 'm', /*nu*/
251 'l', /*mu*/
252 'k', /*lambda*/
253 'i', /*iota*/
254 'f', /*zeta*/
255 'r', /*sigma*/
256 'd', /*delta*/
257 'b', /*beta*/
258 'n', /*xi*/
259 'g', /*eta*/
260 'u', /*phi*/
261 't', /*upsilon*/
262 'j', /*kappa*/
263 '\0', /*blank*/
264 'p', /*pi*/
265 '@', /*at-sign*/
266 '7', /*down arrow*/
267 '\0', /*blank*/
268 'a', /*alpha*/
269 '|', /*or*/
270 'v', /*chi*/
271 '"', /*"*/
272 'e', /*epsilon*/
273 '=', /*=*/
274 'o', /*omicron*/
275 '4', /*left arrow*/
276 'q', /*rho*/
277 '6', /*up arrow*/
278 's', /*tau*/
279 '_', /*underrule*/
280 '\\', /*\*/
281 'W', /*Psi*/
282 '\07', /*bell system sign*/
283 '\001', /*infinity*/
284 'c', /*gamma*/
285 '\002', /*improper superset*/
286 '\003', /*proportional to*/
287 '\004', /*right hand*/
288 'x', /*omega*/
289 '\0', /*blank*/
290 '(', /*gradient*/
291 '\0', /*blank*/
292 'U', /*Phi*/
293 'H', /*Theta*/
294 'X', /*Omega*/
295 '\005', /*cup (union)*/
296 '\006', /*root en*/
297 '\014', /*terminal sigma*/
298 'K', /*Lambda*/
299 '-', /*minus*/
300 'C', /*Gamma*/
301 '\015', /*integral sign*/
302 'P', /*Pi*/
303 '\032', /*subset of*/
304 '\033', /*superset of*/
305 '2', /*approximates*/
306 'y', /*partial derivative*/
307 'D', /*Delta*/
308 '\013', /*square root*/
309 'R', /*Sigma*/
310 '1', /*approx =*/
311 '\0', /*blank*/
312 '>', /*>*/
313 'N', /*Xi*/
314 '<', /*<*/
315 '\016', /*slash (longer)*/
316 '\034', /*cap (intersection)*/
317 'T', /*Upsilon*/
318 '\035', /*not*/
319 '\023', /*right ceiling (rt of ")*/
320 '\024', /*left top (of big curly)*/
321 '\017', /*bold vertical*/
322 '\030', /*left center of big curly bracket*/
323 '\025', /*left bottom*/
324 '\026', /*right top*/
325 '\031', /*right center of big curly bracket*/
326 '\027', /*right bot*/
327 '\021', /*right floor (rb of ")*/
328 '\020', /*left floor (left bot of big sq bract)*/
329 '\022', /*left ceiling (lt of ")*/
330 '*', /*multiply*/
331 '/', /*divide*/
332 '\010', /*plus-minus*/
333 '\011', /*<=*/
334 '\012', /*>=*/
335 '0', /*identically equal*/
336 '3', /*not equal*/
337 '{', /*{*/
338 '}', /*}*/
339 '\'', /*' acute accent*/
340 '\`', /*` grave accent*/
341 '^', /*^*/
342 '#', /*sharp*/
343 '\036', /*left hand*/
344 '\037', /*member of*/
345 '~', /*~*/
346 'z', /*empty set*/
347 '\0', /*blank*/
348 'Y', /*dbl dagger*/
349 'Z', /*box rule*/
350 '9', /*asterisk*/
351 '[', /*improper subset*/
352 ']', /*circle*/
353 '\0', /*blank*/
354 '+', /*eqn plus*/
355 '5', /*right arrow*/
356 '8' /*section mark*/
357};
358
5647b8c0
BJ
359main(argc, argv)
360 int argc;
361 char *argv[];
362{
5af70e5e
RC
363 char *namearg = NULL;
364 char *hostarg = NULL;
365 char *acctfile = NULL;
366
5647b8c0
BJ
367 while (--argc) {
368 if (*(*++argv) == '-')
369 switch (argv[0][1]) {
46e69590
RC
370 case 'x':
371 BYTES_PER_LINE = atoi(&argv[0][2]) / 8;
372 BUFFER_SIZE = NLINES * BYTES_PER_LINE;
373 varian = BYTES_PER_LINE == 264;
374 break;
375
376 case 'y':
377 PAGE_LINES = atoi(&argv[0][2]);
378 break;
5647b8c0
BJ
379
380 case 'n':
381 if (argc > 1) {
382 argc--;
383 namearg = *++argv;
384 }
385 break;
386
387 case 'h':
388 if (argc > 1) {
389 argc--;
390 hostarg = *++argv;
391 }
392 break;
5647b8c0
BJ
393 }
394 else
395 acctfile = *argv;
396 }
397 ioctl(vc, VSETSTATE, pltmode);
398 readrm();
399 ofile();
400 ioctl(vc, VSETSTATE, prtmode);
401 if (varian)
402 write(vc, "\f", 2);
403 else
404 write(vc, "\n\n\n\n\n", 6);
405 account(namearg, hostarg, acctfile);
406 exit(0);
407}
408
409readrm()
410{
411 register int i;
412 register char *cp;
413 register int rmfd;
414 char c;
415
416 if ((rmfd = open(LOCAL_RAILMAG, 0)) < 0)
417 if ((rmfd = open(GLOBAL_RAILMAG, 0)) < 0) {
418 fprintf(stderr, "vcat: No railmag file\n");
419 exit(2);
420 }
421 cp = fnbuf;
5af70e5e 422 for (i = 0; i < MAXF; i++) {
5647b8c0
BJ
423 fontname[i] = cp;
424 while (read(rmfd, &c, 1) == 1 && c != '\n')
425 *cp++ = c;
426 *cp++ = '\0';
427 }
428 close(rmfd);
429}
430
431ofile()
432{
433 register int c;
434 double scol;
435 static int initialized;
436
437 lines = 0;
438 while ((c = getchar()) != EOF) {
439 if (!c)
440 continue;
441 if (c & 0200) {
442 esc += (~c) & 0177;
443 continue;
444 }
445 if (esc) {
446 if (back)
447 esc = -esc;
448 col += esc;
449 ypos = CONVERT(col);
450 esc = 0;
451 }
452 if ((c & 0377) < 0100) /* Purely for efficiency */
453 goto normal_char;
454 switch (c) {
455
456 case 0100:
457 if (initialized)
458 goto out;
459 initialized = 1;
460 row = 25;
461 xpos = CONVERT(row);
462 for (c = 0; c < BUFFER_SIZE; c++)
463 buffer[c] = 0;
464 col = 0;
465 esc = 0;
466 lead = 0;
467 ypos = 0;
468 linecount = 0;
469 verd = 0;
470 back = 0;
471 mcase = 0;
472 railmag = 0;
473 if (loadfont(railmag, cpsize) < 0)
474 fprintf(stderr, "vcat: Can't load inital font\n");
475 break;
476
477 case 0101: /* lower rail */
478 crail(railmag &= ~01);
479 break;
480
481 case 0102: /* upper rail */
482 crail(railmag |= 01);
483 break;
484
485 case 0103: /* upper mag */
486 crail(railmag |= 02);
487 break;
488
489 case 0104: /* lower mag */
490 crail(railmag &= ~02);
491 break;
492
493 case 0105: /* lower case */
494 mcase = 0;
495 break;
496
497 case 0106: /* upper case */
498 mcase = 0100;
499 break;
500
501 case 0107: /* escape forward */
502 back = 0;
503 break;
504
505 case 0110: /* escape backwards */
506 back = 1;
507 break;
508
509 case 0111: /* stop */
510 break;
511
512 case 0112: /* lead forward */
513 verd = 0;
514 break;
515
516 case 0113: /* undefined */
517 break;
518
519 case 0114: /* lead backward */
520 verd = 1;
521 break;
522
523 case 0115: /* undefined */
524 case 0116:
525 case 0117:
526 break;
527
528 default:
529 if ((c & 0340) == 0140) /* leading */ {
530 lead = (~c) & 037;
531 if (verd)
532 lead = -lead;
533 row += lead*3; /* Lead is 3 units */
534 c = CONVERT(row);
535 while (c >= NLINES) {
536 slop_lines(15);
537 c = CONVERT(row);
538 }
539 xpos = c;
540 continue;
541 }
542 if ((c & 0360) == 0120) /* size change */ {
543 loadfont(railmag, findsize(c & 017));
544 continue;
545 }
546 if (c & 0300)
547 continue;
548
549normal_char:
550 c = (c & 077) | mcase;
551 outc(c);
552 }
553 }
554out:
555 slop_lines(NLINES);
556}
557
558findsize(code)
559 register int code;
560{
561 register struct point_sizes *psp;
562
563 psp = point_sizes;
564 while (psp->real_code != 0) {
565 if ((psp->stupid_code & 017) == code)
566 break;
567 psp++;
568 }
569 code = 0;
570 if (!(last_ssize & 0200) && (psp->stupid_code & 0200))
571 code = -55;
572 else if ((last_ssize & 0200) && !(psp->stupid_code & 0200))
573 code = 55;
574 if (back)
575 code = -code;
576 esc += code;
577 last_ssize = psp->stupid_code;
dfc1084e 578 return(psp->real_code);
5647b8c0
BJ
579}
580
581account(who, from, acctfile)
582 char *who, *from, *acctfile;
583{
584 register FILE *a;
585
586 if (who == NULL || acctfile == NULL)
587 return;
588 if (access(acctfile, 02) || (a = fopen(acctfile, "a")) == NULL)
589 return;
590 /*
dfc1084e 591 * Varian accounting is done by 8.5 inch pages;
5647b8c0
BJ
592 * Versatec accounting is by the (12 inch) foot.
593 */
984a125c 594 fprintf(a, "t%6.2f\t", (double)lines / (double)PAGE_LINES);
5647b8c0
BJ
595 if (from != NULL)
596 fprintf(a, "%s:", from);
597 fprintf(a, "%s\n", who);
598 fclose(a);
599}
600
601crail(nrail)
602 register int nrail;
603{
604 register int psize;
605
606 psize = cpsize;
607 if (fontwanted && psize != npsize)
608 psize = npsize;
609 loadfont(nrail, psize);
610}
611
612
613loadfont(fnum, size)
614 register int fnum;
615 register int size;
616{
617 register int i;
618 char cbuf[80];
619
620 fontwanted = 0;
621 if (fnum == cfnum && size == cpsize)
622 return(0);
623 for (i = 0; i < NFONTS; i++)
624 if (fontdes[i].fnum == fnum && fontdes[i].psize == size) {
625 cfnum = fontdes[i].fnum;
626 cpsize = fontdes[i].psize;
627 dispatch = &fontdes[i].disp[0];
628 bits = fontdes[i].bits;
629 cfont = i;
dfc1084e 630 return(0);
5647b8c0
BJ
631 }
632 if (fnum < 0 || fnum >= MAXF) {
633 fprintf(stderr, "vcat: Internal error: illegal font\n");
634 return(-1);
635 }
636 nfontnum = fnum;
637 npsize = size;
638 fontwanted++;
dfc1084e 639 return(0);
5647b8c0
BJ
640}
641
642
643getfont()
644{
645 register int fnum, size, font;
646 int d;
647 char cbuf[BUFSIZ];
648
649 if (!fontwanted)
650 return(0);
651 fnum = nfontnum;
652 size = npsize;
653 sprintf(cbuf, "%s.%d", fontname[fnum], size);
654 font = open(cbuf, 0);
655 if (font == -1) {
5af70e5e 656 fprintf(stderr, "vcat: ");
5647b8c0
BJ
657 perror(cbuf);
658 fontwanted = 0;
dfc1084e 659 return(-1);
5647b8c0
BJ
660 }
661 if (read(font, &header, sizeof header)!=sizeof header || header.magic!=0436)
662 fprintf(stderr, "vcat: %s: Bad font file", cbuf);
663 else {
664 cfont = relfont();
665 if (((bits=nalloc(header.size+DSIZ+1,1))== NULL)
666 && ((bits=allpanic(header.size+DSIZ+1))== NULL)) {
667 fprintf(stderr, "vcat: %s: ran out of memory\n", cbuf);
668 exit(2);
669 } else {
670 /*
671 * have allocated one chunk of mem for font, dispatch.
672 * get the dispatch addr, align to word boundary.
673 */
674 d = (int) bits+header.size;
675 d += 1;
676 d &= ~1;
677 if (read(font, d, DSIZ)!=DSIZ
678 || read(font, bits, header.size)!=header.size)
679 fprintf(stderr, "vcat: bad font header");
680 else {
681 close(font);
682 cfnum = fontdes[cfont].fnum = fnum;
683 cpsize = fontdes[cfont].psize = size;
684 fontdes[cfont].bits = bits;
685 fontdes[cfont].disp = (struct dispatch *) d;
686 dispatch = &fontdes[cfont].disp[0];
687 fontwanted = 0;
dfc1084e 688 return(0);
5647b8c0
BJ
689 }
690 }
691 }
692 close(font);
693 fontwanted = 0;
694 return(-1);
695}
696
dfc1084e 697int lastloaded = -1;
5647b8c0
BJ
698
699relfont()
700{
701 register int newfont;
702
703 newfont = lastloaded;
704 /*
705 * optimization for special font. since we think that usually
706 * there is only one character at a time from any special math
707 * font, make it the candidate for removal.
708 */
709 if (fontdes[cfont].fnum != SPECIALFONT || fontdes[cfont].bits==0)
710 if (++newfont>=NFONTS)
711 newfont = 0;
712 lastloaded = newfont;
713 if ((int)fontdes[newfont].bits != -1 && fontdes[newfont].bits != 0)
714 nfree(fontdes[newfont].bits);
715 fontdes[newfont].bits = 0;
dfc1084e 716 return(newfont);
5647b8c0
BJ
717}
718
719char *
720allpanic(nbytes)
721 int nbytes;
722{
723 register int i;
724
725 for (i = 0; i <= NFONTS; i++)
726 if (fontdes[i].bits != (char *)-1 && fontdes[i].bits != (char *)0)
727 nfree(fontdes[i].bits);
728 lastloaded = cfont;
729 for (i = 0; i <= NFONTS; i++) {
730 fontdes[i].fnum = fontdes[i].psize = -1;
731 fontdes[i].bits = 0;
732 cfnum = cpsize = -1;
733 }
734 return(nalloc(nbytes,1));
735}
736
737int M[] = { 0xffffffff, 0xfefefefe, 0xfcfcfcfc, 0xf8f8f8f8,
738 0xf0f0f0f0, 0xe0e0e0e0, 0xc0c0c0c0, 0x80808080, 0x0 };
739int N[] = { 0x00000000, 0x01010101, 0x03030303, 0x07070707,
740 0x0f0f0f0f, 0x1f1f1f1f, 0x3f3f3f3f, 0x7f7f7f7f, 0xffffffff };
741int strim[] = { 0xffffffff, 0xffffff00, 0xffff0000, 0xff000000, 0 };
742
743outc(code)
744 int code;
745{
746 char c; /* character to print */
747 register struct dispatch *d; /* ptr to character font record */
748 register char *addr; /* addr of font data */
749 int llen; /* length of each font line */
750 int nlines; /* number of font lines */
751 register char *scanp; /* ptr to output buffer */
752 int scanp_inc; /* increment to start of next buffer */
753 int offset; /* bit offset to start of font data */
754 int i; /* loop counter */
755 register int count; /* font data ptr */
756 register unsigned fontdata; /* font data temporary */
757 register int off8; /* offset + 8 */
758
759 if (fontwanted)
760 getfont();
761 if (railmag == SPECIALFONT) {
762 if ((c = spectab[code]) < 0)
763 return(0);
764 } else if ((c = asctab[code]) < 0)
765 return(0);
766 d = dispatch+c;
767 if (d->nbytes) {
768 addr = bits+d->addr;
769 llen = (d->left+d->right+7)/8;
770 nlines = d->up+d->down;
771 if (xpos+d->down >= NLINES)
772 slop_lines(xpos+d->down-NLINES+1);
773 scanp = ((xpos-d->up-1)*BYTES_PER_LINE+(ypos-d->left)/8)+buf0p;
774 if (scanp < &buffer[0])
775 scanp += BUFFER_SIZE;
776 scanp_inc = BYTES_PER_LINE-llen;
777 offset = -((ypos-d->left)&07);
778 off8 = offset+8;
779 for (i = 0; i < nlines; i++) {
780 if (scanp >= &buffer[BUFFER_SIZE])
781 scanp -= BUFFER_SIZE;
782 count = llen;
783 if (scanp + count <= &buffer[BUFFER_SIZE])
784 do {
785 fontdata = *(unsigned *)addr;
786 addr += 4;
787 if (count < 4)
788 fontdata &= ~strim[count];
789 *(unsigned *)scanp |= (fontdata << offset) &~ M[off8];
790 scanp++;
791 *(unsigned *)scanp |= (fontdata << off8) &~ N[off8];
792 scanp += 3;
793 count -= 4;
794 } while (count > 0);
795 scanp += scanp_inc+count;
796 addr += count;
797 }
dfc1084e 798 return(1);
5647b8c0 799 }
dfc1084e 800 return(0);
5647b8c0
BJ
801}
802
803slop_lines(nlines)
804 int nlines;
805{
806 register int i, rlines;
807
808 lines += nlines;
809 rlines = (&buffer[BUFFER_SIZE] - buf0p) / BYTES_PER_LINE;
810 if (rlines < nlines) {
811 if (write(vc, buf0p, BYTES_PER_LINE * rlines) < 0)
812 exit(1);
a9d46e9c 813 bzero(buf0p, rlines * BYTES_PER_LINE);
5647b8c0
BJ
814 buf0p = buffer;
815 nlines -= rlines;
816 xpos -= rlines;
817 row -= RECONVERT(rlines);
818 }
819 if (write(vc, buf0p, BYTES_PER_LINE * nlines) < 0)
820 exit(1);
a9d46e9c 821 bzero(buf0p, BYTES_PER_LINE * nlines);
5647b8c0
BJ
822 buf0p += BYTES_PER_LINE * nlines;
823 if (buf0p >= &buffer[BUFFER_SIZE])
824 buf0p -= BUFFER_SIZE;
825 xpos -= nlines;
826 row -= RECONVERT(nlines);
827 /* ioctl(vc, VSETSTATE, pltmode); WHY? */
828}
829
5647b8c0
BJ
830char *
831nalloc(i, j)
832 int i, j;
833{
834 register char *cp;
835
836 cp = calloc(i, j);
837 return(cp);
838}
839
840nfree(cp)
841 char *cp;
842{
843 free(cp);
844}