This is pp0cat.c in view mode; [Download] [Up]
/* Copyright 1994 Steve Ludtke (steve@ion.rice.edu) */
/* pp0cat.c this program gets around the bug in the NeXT parallel port */
/* driver by re write()ing data as necessary */
/* Many thanks to Federico Heinz for telling me about this bug */
#include <stdio.h>
#include <sys/file.h>
main(int argc, char *argv[])
{
int r,w,i,std=0;
FILE *in;
int out;
char data[4096],*ptr;
if (argc==1) { argc++; std=1; }
/* if we have >1 arg */
for (i=1; i<argc; i++) {
if (std && i==1) in=stdin;
else {
in=fopen(argv[i],"r");
if (in==NULL) { printf("Cannot open %s\n",argv[i]); continue; }
}
/* write the file(s) */
out=open("/dev/pp0",O_WRONLY,0);
while ((r=fread(data,1,4096,in))>0) {
ptr=data;
w=0;
while (r>0) {
w=write(out,ptr,r);
if (w<r) sleep(5);
r-=w;
ptr+=w;
}
}
close(out);
if (!std) fclose(in);
}
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.