|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 1360 (0x550)
Types: TextFile
Notes: UNIX file
Names: »print.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦f4b8d8c84⟧ UNIX Filesystem
└─⟦this⟧ »cmd/lpr/print.c«
#include <stdio.h>
#define LINESIZ 132
static col, /* current print position */
endcol; /* leftmost unused position */
static char line0[LINESIZ],
line1[LINESIZ];
print( file)
char *file;
{
register FILE *f;
register c;
extern printing;
f = fopen( file, "r");
if (f == NULL)
return (1);
lputc( '\f');
while ((c=getline( f)) && printing>0) {
putline( line1);
putline( line0);
lputc( c);
}
fclose( f);
return (0);
}
getline( f)
register FILE *f;
{
register c;
col = 0;
endcol = 0;
while ((c=getc( f)) != EOF)
switch (c) {
case '\n':
case '\f':
line0[col] = '\0';
line1[col] = '\0';
return (c);
case '\b':
if (col)
--col;
break;
case '\r':
col = 0;
break;
case '\t':
do {
store( ' ');
} while (col & 7);
break;
default:
store( c);
}
return (0);
}
store( c)
{
if (col < LINESIZ-1)
if (col >= endcol) {
line0[col] = c;
line1[col] = ' ';
++endcol;
}
else
line1[col] = c;
++col;
}
putline( linep)
register char *linep;
{
register c,
xcol;
extern FILE *lp;
col = 0;
xcol = 0;
for (; ; )
switch (c = *linep++) {
case '\0':
if (col)
lputc( '\r');
return;
default:
while (col < xcol) {
++col;
putc( ' ', lp);
}
putc( c, lp);
++col;
case ' ':
++xcol;
}
}
lputc( c)
{
putc( c, lp);
}