[RoLUG] CR LF remover

Roccatello Eduard rolug@lists.linux.it
Mon, 3 Mar 2003 20:41:29 +0100


--Boundary-00=_p/6Y+A1P711eCRZ
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Ciao raga
sto riformattando il paper sui buffer overflow (per convertirlo in pdf) e h=
o=20
avuto la necessit=E0 di togliere tutti i "fine line" (CR e LF).
Per farlo ho scritto un piccolo programmino che voglio condividere con voi=
=20
dato che pu=F2 essere utile (per me lo =E8 :-)

Lo allego a questa mail (tanto sono pochi byte)

PS: l'interfaccia utente praticamente non esiste ed il programma non=20
mostrer=E0 nessun output (per=F2 funziona correttamente :-)
=2D-=20
Roccatello Eduard
RoLUG member @ http://rovigo.linux.it
Modding, overclock and hardware reviews @ http://www.pcimprover.it
Look to the headers for my GnuPG key



--Boundary-00=_p/6Y+A1P711eCRZ
Content-Type: text/x-csrc;
  charset="us-ascii";
  name="clrem.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="clrem.c"

/*	Carriage return and Line feed cleaner v0.1
 *	This program clean every CR or LF char in a text file passed as argument
 *
 *	USAGE:	programname textfile
 *
 *	It creates a new file named textfile.clr without any CR or LF chars
 *	This is useful to format bad text files...
 */

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{	FILE *in, *out;
	int ascii;
	if (argc < 2)
		exit(-1);
	in = fopen(argv[1], "r");
	out = fopen(strcat(argv[1], ".clr"), "w");
	while (!((ascii = fgetc(in)) == EOF))
	{	if (ascii == 10 || ascii == 13)
			fputc(32, out);
		else
			fputc(ascii, out);
	}
	fclose(in);
	fclose(out);
	return(0);
}

--Boundary-00=_p/6Y+A1P711eCRZ--