--- In [email protected], "Brett McCoy" <[EMAIL PROTECTED]> wrote: > > . > On Fri, Apr 18, 2008 at 5:56 AM, Sathya Raghunathan < > [EMAIL PROTECTED]> wrote: > > > > > A process has a char buffer(4096 bytes) which contains a > > log statement which is a comma seperated string of the > > following information: > > loglevel, errorlevel, Module name, function name, > > description of the error etc. > > (Variable length string and can go upto 4096 characters) > > > > Now my requirement is to send this comma seperated > > string to a different process through a FIFO. > > > > My doubt is, > > 1) is it better to use write(fifofile,buffer,4096) or > > 2) should i use any other function like fputs or > > fwrite(fifofile,strlen(buffer))? > > Are you opening the pipe with popen? If so, you should use > fwrite since popen returns FILE * > > Showing your code would be helpful also. > > -- Brett
In order to avoid the length issue completely, I suggest the OP prefixes every line with a four-character string telling the length of the string to follow (whether including or excluding the terminating NUL character is a different story). Meaning that you have this at the beginning of your actual output process to the FIFO (shown as ANSI C source code): char LengthBuffer [5]; ... sprintf( LengthBuffer, "%.04s", MessageLength); fprintf( fifo, "%.4s%s", LengthBuffer, Message); BTW do you intend to use ASCII characters only for the log file? Or Unicode characters as well? If it's the latter, what encoding will you use? Regards, Nico
