/* prototype filter program - line (actually record) oriented */
#include <stdio.h>
#include <algol68.h>
#include <cx.h>
#include <nboff.h>
#include <fdoff.h>
#define BUFSIZ 4096
char buffer[BUFSIZ];
FILE	*inf;
FILE	*ouf;
extern int $dsw;
FDB * fdbp;
main(argc,argv)
char **argv;
BEGIN
register int	howlong;	/* char length of this record */
	IF	((inf=fopen(argv[1],"ur"))==NULL)
	THEN	error("can't find %s\7\n",argv[1]);
	FI
	IF	((ouf=fopen(argv[2],"uw"))==NULL)
	THEN	error("can't make %s\7\n",argv[2]);
	FI
	fdbp = ouf -> io_fdb;
	fdbp -> f_fatt . f_ratt |= fd_cr;	/* force fd.cr */
	WHILE	(!feof(inf))
	DO	howlong = fget(buffer,BUFSIZ,inf);
		IF	(ferror(inf))
		THEN	error("read failure $$ferr=%oo\7\n",$$ferr);
		FI
		IF	(feof(inf))
		THEN	break;
		FI
		fput(buffer,howlong,ouf);
		IF	(ferror(ouf))
		THEN	error("write failed $$ferr=%oo\7\n",$$ferr);
		FI
	OD
	IF	(fclose(ouf))
	THEN	error("Can't close\n");
	FI
END
/* end: ufilter.c */
