The program need to loop, reading lines and write back the new URL.. and
you MUST disable stdio buffering, or else your c-library will buffer the
printf, and it is never sent to Squid..
Further, URL's can be a lot longer than only 1024 characters...
#include <stdio.h>
#define SIZE 8192
main()
{
char buf[SIZE];
setbuf(stdout, NULL);
while(fgets(buf, SIZE, stdin)) {
printf("%s", buf);
}
}
Alberto Omella Herrero wrote:
>
> Hi there,
>
> I'm making my own redirector program for learning purposes and right
> now it's only function is to put in the stdout the same url that was
> requested. The program works fine with any webpage but (for some
> reason unknown to me) it can't bring the images contained inside when
> the requested page isn't in the cache. Yet if I make 3 or 4 refreshs
> of the url, the images are loaded at last. Sometimes, even in the
> first try, half of some of the images are loaded. This, of course,
> doesn't happen when the redirector is turned off.
>
> Anyone have any idea about what am I doing wrong? Here is the program
> writted in C:
>
> _________________________
> #include <stdio.h>
>
> #define SIZE 1024
> main()
> {
> char buf[SIZE];
> fgets(buf, SIZE, stdin);
> printf("%s", buf);
> }
> _________________________
>
> Thanks in advance.
>
> ___________________
> Alberto Omella Herrero
> omella@pla.net.py
Received on Fri Jun 08 2001 - 10:14:36 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 17:00:34 MST