|
|
1.1 root 1: /* D.L.Buck and Associates, Inc. - May, 1984
2: *
3: * COPYRIGHT NOTICE:
4: * Copyright c 1984 - An unpublished work by
5: * D.L.Buck and Associates, Inc.
6: *
7: * PROPRIETARY RIGHTS NOTICE:
8: * All rights reserved. This document and program contains
9: * proprietary information of D.L.Buck and Associates,Inc.
10: * of San Jose, California, U.S.A., embodying confidential
11: * information, ideas, and expressions, no part of which
12: * may be reproduced, or transmitted in any form or by any
13: * means, electronic, mechanical, or otherwise, without
14: * the written permission of D.L.Buck and Associates, Inc.
15: * NAME
16: * emprint
17: *
18: * SYNOPSIS
19: * emprint()
20: *
21: * DESCRIPTION
22: * do print processing - called from emulate()
23: *
24: * ALGORITHM
25: * I. Initialize everything
26: * II. Open file or process
27: * III. Get print format
28: * A. logical 'and' write control character with print format
29: * masks to determine line length --
30: * 40, 64, 80 words per line or variable length lines
31: * IV. Set characters printed counter to 0
32: * V. Print the screen image on the file or process
33: * A. For each character on the screen, if it isn't
34: * an invisible character, an attribute, or a null:
35: * a. put it in the file or process
36: * b. if counter indicates end of line, output
37: * a newline character and reset the counter
38: * VI. Close the file or process
39: */
40: static char s_emprint[] = "@(#)emprint.c 1.7 REL";
41: #include <em.h>
42:
43: extern char ptype;
44: extern char pr_dest[];
45:
46: emprint(as_is)
47: int as_is; /* 1= print as is; 0= insert newlines every 80 characters
48: if a newline hasn't been encountered before then */
49: {
50: register FILE *prptr; /* FILE to use for printing */
51: FILE *fopen(),*popen();
52: register int pfmt; /* print format : variable length
53: 40 chars
54: 64 chars
55: 80 chars */
56: register char *bufptr; /* buffer pointer */
57: register int *xrefptr; /* cross-ref pointer */
58: int chrctr; /* character count */
59: register int i;
60:
61: updstat (status | PRTR_BUSY);
62: /* open file or process */
63: if (ptype == 'p')
64: prptr = popen(pr_dest,"w");
65: else
66: prptr = fopen(pr_dest,"a");
67: if (prptr == (FILE *)0) {
68: wclear(cmd_scr);
69: mvwaddstr(cmd_scr,0,0,"em3277: can't print to ");
70: waddstr(cmd_scr,pr_dest);
71: wrefresh(cmd_scr);
72: updstat ( (status | PRTR_NW) & ~ PRTR_BUSY);
73: return;
74: }
75: /* determine print format */
76: if ((wcc & WCCPRFMT) == WCCPRVAR) {
77: if (as_is)
78: pfmt = 132;
79: else
80: pfmt = 80;
81: }
82: else if ((wcc & WCCPRFMT) == WCCPR40)
83: pfmt = 40;
84: else if ((wcc & WCCPRFMT) == WCCPR64)
85: pfmt = 64;
86: else if ((wcc & WCCPRFMT) == WCCPR80)
87: pfmt = 80;
88:
89: chrctr = 0;
90:
91: for (bufptr = scrn_image, xrefptr = scrn_xref;
92: bufptr <= &scrn_image[MAXSCREENSIZE-1];
93: ++bufptr,++xrefptr) {
94: if (!(invis_attr(fldattr[*xrefptr])) &&
95: *bufptr != (char)ATTRCODE &&
96: *bufptr != '\0')
97: fputc(*bufptr,prptr);
98: else
99: fputc(' ',prptr);
100:
101: if (++chrctr >= pfmt) {
102: chrctr = 0;
103: fputc('\n',prptr);
104: }
105: }
106:
107: /* close file or process */
108: updstat (status & ~PRTR_BUSY);
109: if (ptype == 'p')
110: pclose(prptr);
111: else
112: fclose(prptr);
113: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.