DataMuseum.dk

Presents historical artifacts from the history of:

Christian Rovsing CR7, CR8 & CR16 CP/M

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Christian Rovsing CR7, CR8 & CR16 CP/M

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦bccef03e7⟧ TextFile

    Length: 2560 (0xa00)
    Types: TextFile
    Names: »LPR.C«

Derivation

└─⟦23f778bf6⟧ Bits:30005378 BDS C v1.46 & Pascal/MT+ v5.5 (Callan format)
    └─ ⟦this⟧ »LPR.C« 
└─⟦4ada80662⟧ Bits:30005446 Pascal/MT+ v5.5 & XREF & BDS C v1.46
    └─ ⟦this⟧ »LPR.C« 

TextFile

/*
	Line printer formatter 

	Written by Leor Zolman
		   May 28, 1980

	First prints all files named on the command line, and then
	asks for names of more files to print until a null line is typed.
	Control-Q aborts current printing and goes to next file.

	Paper should be positioned ready to print on the first page; each
	file is always printed in an even number of pages so that new files
	always start on the same phase of fan-fold paper.

	Tabs are expanded into spaces.
*/

#include "bdscio.h"

#define FF 0x0c		/* formfeed character, or zero if not supported */
#define PGLEN 66	/* lines per lineprinter page */

int colno, linesleft;

main(argc,argv)
char **argv;
æ
	int i, pgno, fd;
	char dateÆ30Å, linebufÆ135Å;	/* date and line buffers */
	char fnbufÆ30Å, *fname;		/* filename buffer & ptr */
	char ibufÆBUFSIZÅ;		/* buffered input buffer */
	char *gets();

	pgno = colno = 0;
	linesleft = PGLEN; 
	printf("What is today's date? ");
	  gets(date);

	while (1)
	æ
		if (argc-1)
		 æ
			fname = *++argv;
			argc--;
		 å
		else
		 æ
			printf("ØnEnter file to print, or CR if done: ");
			if (!*(fname = gets(fnbuf))) break;
		 å

		if ((fd = fopen(fname,ibuf)) == ERROR)
		 æ
			printf("Can't open %sØn",fname);
			continue;
		 å
		else printf("ØnPrinting %-13s",fname);

		for (pgno = 1; ; pgno++)
		 æ
			putchar('*');
			sprintf(linebuf,"ØnØn%28s%-13s%5s%-3d%20sØnØnØn",
				"file: ",fname,"page ",pgno,date);
			linepr(linebuf);

		loop:	if (!fgets(linebuf,ibuf)) break;
			if (kbhit() && getchar() == 0x11) break;
			if (linepr(linebuf)) continue;
			if (linesleft > 2) goto loop;
			formfeed();
		 å
		formfeed();
		if (pgno % 2) formfeed();
		fabort(fd);
	å
å

/*
	Print a line of text out on the list device, and
	return true if a formfeed was encountered in the
	text.
*/

linepr(string)
char *string;
æ
	char c, ffflag;
	ffflag = 0;
	while (c = *string++)
	  switch (c) æ
	    case FF:
		ffflag = 1;
		break;
	    case 'Øn':	
		putlpr('Ør');
		putlpr('Øn');
		colno = 0;
		linesleft--;
		break;

	    case 'Øt':
		do æ
		  putlpr(' ');
		  colno++;
		å while (colno % 8);
		break;

	    default:					
		putlpr(c);
		colno++;
	å
	if (ffflag) formfeed();
	return ffflag;
å

putlpr(c)
char c;
æ
	bios(5,c);
å

formfeed()
æ
	if (FF) putlpr(FF);
	else while (linesleft--) putlpr('Øn');
	linesleft = PGLEN;
å
«eof»