From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mat Harris Subject: SOLVED: Re: writing logfile Date: Thu, 27 Feb 2003 10:32:38 +0000 Sender: linux-c-programming-owner@vger.kernel.org Message-ID: <20030227103238.A7438@genestate.com> References: <20030225105740.A31033@genestate.com> <20030225133810.C28473@neutrino.particles.org> <20030225124937.B31033@genestate.com> <15964.5048.368429.404765@cerise.nosuchdomain.co.uk> <20030226092502.A12697@genestate.com> <20030226100914.GO7826@lug-owl.de> <20030226101811.A13475@genestate.com> <15965.6467.762493.359428@cerise.nosuchdomain.co.uk> <20030227100415.A6471@genestate.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="wRRV7LY7NUeQGEoC" Return-path: Content-Disposition: inline In-Reply-To: <20030227100415.A6471@genestate.com>; from mat.harris@genestate.com on Thu, Feb 27, 2003 at 10:04:15 +0000 List-Id: To: linux-c-programming@vger.kernel.org --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable it's alright, i was closing the logfile inside the connection loop so it wa= s=20 printing to a null filehandle and got confused. On Thu, Feb 27, 2003 at 10:04:15 +0000, Mat Harris wrote: > ok, thanks guys for the help with my webserver, the loggin works fine and= now > I have remembered about extern void etc I have put the functions to compi= le > seperateley as suggested. >=20 > Just one more thing tho, the logmessage is getting printed to the client's > browser after any html content has been transferred and I can't see where= it > is happening. I have put a tarball of the whole thing at >=20 > http://www.genestate.com/~matthewh/debug/ >=20 > thanks again. >=20 > On Wed, Feb 26, 2003 at 07:45:07 +0000, Glynn Clements wrote: > >=20 > > Mat Harris wrote: > >=20 > > > ok and now i am getting something weird. when I try to log a successf= ul > > > request, and then make the request again, it ands to the previous pri= ntf > > > message and prints it again so it repeats all the previous messages a= gain > > > and again. Also, the garbage in the logfile is the beginning of my we= broot > > > "/home....". I do not know what is going on here. > >=20 > > Line 52 of webserver.c: > >=20 > > > strcat(logmsg, filename); > >=20 > > should be > >=20 > > strcpy(logmsg, filename); > >=20 > > Also: > >=20 > > > #include "log.h" /* logging functions */ > >=20 > > Don't use #include for actual code. Put it in a separate .c file and > > compile it separately. > >=20 > > > void write_log(int loghandle, char *string) > > > { > > > write(loghandle, string, sizeof(string)); > > > } > >=20 > > write(loghandle, string, strlen(string)); > >=20 > > Applying sizeof() to a "char *" will return the size of the pointer > > (typically 4 on a 32-bit system, 8 on a 64-bit system), not the length > > of the string to which it points. > >=20 > > --=20 > > Glynn Clements >=20 > --=20 > Mat Harris OpenGPG Public Key ID: C37D57D9 > mat.harris@genestate.com www.genestate.com=09 --=20 Mat Harris OpenGPG Public Key ID: C37D57D9 mat.harris@genestate.com www.genestate.com=09 --wRRV7LY7NUeQGEoC Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE+XelFEsYvZsN9V9kRAjafAJ9BAhBoBsHlf+hyBaxmg6euNUU4rACgpLPC dkKEKod7uHFbujN5Dg9dskk= =2yKh -----END PGP SIGNATURE----- --wRRV7LY7NUeQGEoC--