Tom Lane wrote:
> Andreas Pflug <pgadmin@pse-consulting.de> writes:
>
> Agreed (although actually I was thinking of preserving
> write_syslogger_file as the externally visible name and renaming the
> existing function to a static "write_syslogger_file_binary" or some such
> --- fewer files to touch that way). Do you have time to write and check
> this today? I could write it but am not in a good position to test it.
The attached code snippet works. I hesitated to use palloc(count*2) to
avoid problems in low mem conditions; might be paranoid.
Regards,
Andreas
void
write_syslogger_file(const char *buffer, int count)
{
char convbuf[1024+1], *p=convbuf;
int i;
for (i=0 ; *buffer != 0 && i < 1024 && count > 0 ; i++, count--)
{
if (*buffer == '\n')
{
i++;
*p++ = '\r';
}
*p++ = *buffer++;
}
write_syslogger_file_binary(convbuf, i);
}