On Wed, May 23, 2007, Mahesh Govindappa wrote:
> i wrote a simple program just for checking purpose.
>
> #include <stdio.h>
> #include <string.h>
>
> int main()
> {
> char buf[8192];
> fgets(buf, 256, stdin);
> FILE *fp;
> fp=fopen("/etc/test.txt", "w");
> fprintf(fp,"%s", buf);
> fclose(fp);
> printf("OK\n");
> }
>
> made it executable and run it and specified
Its not enough; it needs to be in a loop.
Something like:
int main()
{
/* Be explicit about the buffering semantics for stdin/stdout as Squid requires it to be line buffered */
setlinebuf(stdin);
setlinebuf(stdout);
fp = fopen("/etc/test.txt, "w");
if (!fp)
perror("Couldn't open /etc/test.txt for writing\n");
/* This isn't needed, but it makes debugging easier as you'll immediately see the lines as they're authenticated */
if (fp)
setlinebuf(fp);
while (! feof(stdin)) {
if (fgets(buf, 256, stdin) == NULL)
break;
printf("OK\n");
if (fp)
fprintf(fp, "%s", buf);
}
close(fp);
}
Might do it.
Adrian
Received on Thu May 24 2007 - 23:06:06 MDT
This archive was generated by hypermail pre-2.1.9 : Fri Jun 01 2007 - 12:00:09 MDT