Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!news.larc.nasa.gov!amiga-request From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator) Newsgroups: comp.sources.amiga Subject: v91i109: filter - filter non-ASCII characters, Part01/01 Message-ID: Date: 18 May 91 02:00:30 GMT Reply-To: RWALLACE%vax1.tcd.ie@CUNYVM.CUNY.EDU Lines: 222 Approved: tadguy@uunet.UU.NET (Tad Guy) X-Mail-Submissions-To: amiga@uunet.uu.net X-Post-Discussions-To: comp.sys.amiga.misc 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 '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 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 X#include X#include X#include 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 \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`*S1R-'((F@`$-/)T\D@`G(`V XM$ADI20$(T(%>@`)`__PI0`$02.=`0"(\``$``4ZN_SI*@&8,(#P```/H+P!GI XM``$0($`I0`$,3-\"`B`"4X#4@1&R```@`E."4``$(FP30$ZN_F).N@"&" XM2JP`_&<<(BP!!&<$3J[_W"QX``1.KO]\(FP`_$ZN_H9@#B`L`1!G"")L`0Q.6 XMKO\N(!\N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^:2'@`/$AX`/I(;`"L2&P`F'``(@"1R$/L8 XM`(1.NOH&3^\`%%.`9P1P_V`"<`!,WTS,3EU.=2HJ(%5S97(@06)O``$3J[^SBX``H<``#``2H=G'$JL`/!G%B!L`/!.D$J`9@)@"D*L`/!P" XM%$ZZ_`Y,WT"`3G5AO$YU``````/L`````0````$```3.`````@````(````4/ XM````"@````````/R```#Z0```(I(YS`2)D@@+!$<(@!!^@`^)`AV&BQL$T!.= XMKO_0("P1'"!+2AAF_%.(D``>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_<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 . Mail comments to the moderator at . Post requests for sources, and general discussion to comp.sys.amiga.misc.