[comp.sources.amiga] v91i109: filter - filter non-ASCII characters, Part01/01

amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator) (05/18/91)

Submitted-by: RWALLACE%vax1.tcd.ie@CUNYVM.CUNY.EDU
Posting-number: Volume 91, Issue 109
Archive-name: utilities/filter/part01

[ includes uuencoded executable  ...tad ]

	Filter copies all valid ASCII characters from the source file to the
	object file. Non-ASCII characters are excluded. Carriage returns
	(ASCII 13) are also excluded since a linefeed (ASCII 10) is the standard
	end of line marker under AmigaDOS.

#!/bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 1)."
# Contents:  filter.c filter.uu
# Wrapped by tadguy@ab20 on Fri May 17 22:00:29 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'filter.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'filter.c'\"
else
echo shar: Extracting \"'filter.c'\" \(1891 characters\)
sed "s/^X//" >'filter.c' <<'END_OF_FILE'
X/*	Filter by Russell Wallace 1988. This program is in the public domain.
X	Both source and executable code may be freely used and distributed.
X
X	Usage: Filter <sourcefile> <destfile>
X	Filter copies all valid ASCII characters from the source file to the
X	object file. Non-ASCII characters are excluded. Carriage returns
X	(ASCII 13) are also excluded since a linefeed (ASCII 10) is the standard
X	end of line marker under AmigaDOS.
X
X	This version was compiled with Aztec C 3.4. If you are compiling with
X	Lattice, use the short integer option.
X
X	If you give copies of this program to anyone, please distribute source
X	code with the executable program. */
X
X#include	<string.h>
X#include <dos.h>
X#include	<proto/dos.h>
X#include <exec/types.h>
X
X#define BUFSIZE 2048L		/* length of I/O buffers */
X
Xchar inbuffer[BUFSIZE],outbuffer[BUFSIZE];
Xstruct FileHandle *in,*out,*output;
Xint inpoint;
Xint maxin;
Xint outpoint;
X
Xvoid fileerrmess (char *s)
X{
X	Write (output,"ERROR: Couldn't open file ",26L);
X	Write (output,s,(long)strlen (s));
X	Write (output,"\n",1L);
X}
X
Xmain (int argc,char **argv)
X{
X	char c;
X	inpoint=maxin=BUFSIZE-1;
X	outpoint=-1;
X	output=Output ();
X	if (argc!=3)
X	{
X		Write (output,"Usage: Filter <sourcefile> <destfile>\n",38L);
X		exit (30);
X	}
X	if ((in=Open (argv[1],MODE_OLDFILE))==0)	/* Try to open input file */
X	{
X		fileerrmess (argv[1]);
X		exit (29);
X	}
X	if ((out=Open (argv[2],MODE_NEWFILE))==0)	/* Try to open output file */
X	{
X		fileerrmess (argv[2]);
X		Close (in);
X		exit (28);
X	}
X	for (;;)
X	{
X		if (++inpoint>=maxin)
X		{
X			maxin=Read (in,inbuffer,BUFSIZE);
X			inpoint=0;
X		}
X		if (maxin==0)
X		{
X			Write (out,outbuffer,(long)(outpoint+1));
X			break;
X		}
X		c=inbuffer[inpoint];
X		if ((c>31 && c<127) || c==10 || c==9)
X		{
X			if (++outpoint>=BUFSIZE)
X			{
X				Write (out,outbuffer,(long)outpoint);
X				outpoint=0;
X			}
X			outbuffer[outpoint]=c;
X		}
X	}
X	Close (in);
X	Close (out);
X}
END_OF_FILE
if test 1891 -ne `wc -c <'filter.c'`; then
    echo shar: \"'filter.c'\" unpacked with wrong size!
fi
# end of 'filter.c'
fi
if test -f 'filter.uu' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'filter.uu'\"
else
echo shar: Extracting \"'filter.uu'\" \(4499 characters\)
sed "s/^X//" >'filter.uu' <<'END_OF_FILE'
Xbegin 644 filter
XM```#\P`````````#``````````(```(X````B@``!-$```/I```".$CG?OXD)
XM2"0`2?D`````+'@`!$?Y````P'(`(#P```2A8`(FP5'(__PI3P$`*4X`^$*L\
XM`/QP`"(\```P`$ZN_LY#^@&4<`!.KOW8*4`30&8&<&1@``$F)FX!%"EK`)@`M
XM]$JK`*QG``"2(`^0KP`X!H````"`*4``Q"!K`*S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L92````H`57-A9V4Z($9I@
XM;'1E<B`\<V]U<F-E9FEL93X@/&1E<W1F:6QE/@H``$Y5__A(YS$2+@`F2"`\Z
XM```'_RE`$20I0!$@</\I0!$H+&P30$ZN_\0I0!$<<@.^@6<8(@!!^O^B)`AVB
XM)DZN_]!(>``>3KH!2%A/(BL`!"0\```#[2QL$T!.KO_B*4`1%&8.(&L`!&$`B
XM_P9P'4ZZ`2`B*P`()#P```/N+&P30$ZN_^(I0!$89AP@:P`(80#^X"`L$10BB
XM`"QL$T!.KO_<<!Q.N@#L4JP1("`L$2"PK!$D;20@+!$4(@!![`$4)`@F/```S
XM"``L;!-`3J[_UBE`$21P`"E`$2!*K!$D9B0@+!$8(BP1*%*!+T$`&"(`0>P)0
XM%"0()B\`&"QL$T!.KO_08&X@;!$@0^P!%"`($#$(`!]``!1R'[`!8P9R?[`!C
XM90YR"K`!9PAR";`!9@#_>E*L$2@B+!$H#($```@`;1XD+!$8(@)![`D4)`@FQ
XM+!$H+&P30$ZN_]!P`"E`$2@@;!$H0^P)%"`($Z\`%`@`8`#_."`L$10B`"QL&
XM$T!.KO_<("P1&"(`3J[_W$S?2(Q.74YU3OD```8`<&$```/L`````0``````3
XM``(B`````````_(```/J````,````"@````F````````````````````````$
XM````````````````````2```````````````````````````````````````(
XM````````````````````````````````````````````````````@`#__P``^
XM``X`#@````````@*`````/__````!``$``````````````!P__\````$``0`J
XM```````()@````#__P````0`!`````````@P`````````^P````#````````>
XF`+@```"D````?`````,````"````E````"8````$`````````_(#3
X``
Xend
Xsize 3188
END_OF_FILE
if test 4499 -ne `wc -c <'filter.uu'`; then
    echo shar: \"'filter.uu'\" unpacked with wrong size!
fi
# end of 'filter.uu'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have the archive.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
Mail comments to the moderator at <amiga-request@uunet.uu.net>.
Post requests for sources, and general discussion to comp.sys.amiga.misc.