File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / usr / src / usr.bin / bsc / cmd / 3270 / emprint.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:26:11 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

/*	D.L.Buck and Associates, Inc. - May, 1984
 *
 *	COPYRIGHT NOTICE:
 *		Copyright c 1984 - An unpublished work by
 *		D.L.Buck and Associates, Inc.
 *
 *	PROPRIETARY RIGHTS NOTICE:
 *		All rights reserved. This document and program contains
 *		proprietary information of D.L.Buck and Associates,Inc.
 *		of San Jose, California, U.S.A., embodying confidential
 *		information,  ideas, and expressions,  no part of which
 *		may be reproduced, or transmitted in any form or by any
 *		means,	electronic,  mechanical,  or otherwise, without
 *		the written permission of D.L.Buck and Associates, Inc.
 * NAME
 *	emprint
 *
 * SYNOPSIS
 *	emprint()
 *
 * DESCRIPTION
 *	do print processing - called from emulate()
 *
 * ALGORITHM
 *	I. Initialize everything
 *	II. Open file or process
 *	III. Get print format
 *		A. logical 'and' write control character with print format
 *		   masks to determine line length --
 *		      40, 64, 80 words per line or variable length lines
 *	IV. Set characters printed counter to 0
 *	V. Print the screen image on the file or process
 *		A. For each character on the screen, if it isn't
 *		   an invisible character, an attribute, or a null:
 *			a. put it in the file or process
 *			b. if counter indicates end of line, output
 *			   a newline character and reset the counter
 *	VI. Close the file or process
 */
static char s_emprint[] = "@(#)emprint.c	1.7 REL";
#include <em.h>

extern char ptype;
extern char pr_dest[];

emprint(as_is)
int as_is;	/* 1= print as is; 0= insert newlines every 80 characters
		   if a newline hasn't been encountered before then */
{
	register FILE *prptr;	/* FILE to use for printing */
	FILE *fopen(),*popen();
	register int pfmt;	/* print format : variable length
					  40 chars
					  64 chars
					  80 chars	*/
	register char *bufptr;	/* buffer pointer */
	register int *xrefptr;	/* cross-ref pointer */
	int chrctr;		/* character count */
	register int i;

	updstat (status | PRTR_BUSY);
/* open file or process */
	if (ptype == 'p')
		prptr = popen(pr_dest,"w");
	else
		prptr = fopen(pr_dest,"a");
	if (prptr == (FILE *)0)	{
		wclear(cmd_scr);
		mvwaddstr(cmd_scr,0,0,"em3277: can't print to ");
		waddstr(cmd_scr,pr_dest);
		wrefresh(cmd_scr);
		updstat ( (status | PRTR_NW) & ~ PRTR_BUSY);
		return;
	}
/* determine print format */
	if ((wcc & WCCPRFMT) == WCCPRVAR)	{
		if (as_is)
			pfmt = 132;
		else
			pfmt = 80;
	}
	else if ((wcc & WCCPRFMT) == WCCPR40)
		pfmt = 40;
	else if ((wcc & WCCPRFMT) == WCCPR64)
		pfmt = 64;
	else if ((wcc & WCCPRFMT) == WCCPR80)
		pfmt = 80;
	
	chrctr = 0;

	for (bufptr = scrn_image, xrefptr = scrn_xref;
	     bufptr <= &scrn_image[MAXSCREENSIZE-1];
	     ++bufptr,++xrefptr) {
		if (!(invis_attr(fldattr[*xrefptr])) &&
		    *bufptr != (char)ATTRCODE && 
		    *bufptr != '\0')			
			fputc(*bufptr,prptr);
		else
			fputc(' ',prptr);

		if (++chrctr >= pfmt) {
			chrctr = 0;
			fputc('\n',prptr);
		}
	}

/* close file or process */
	updstat (status & ~PRTR_BUSY);
	if (ptype == 'p')
		pclose(prptr);
	else
		fclose(prptr);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.