Re: [squid-users] Need help to build my own external help

From: Mohamed Amine Kadimi <amine.kadimi_at_gmail.com>
Date: Mon, 16 Apr 2012 20:06:16 +0000

>> I reduced my program to that:
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <string.h>
>> #define MAX_INPUT 8192
>> int main(int argc, char **argv)
>> {
>>    char request [MAX_INPUT];
>>    while (fgets(request, MAX_INPUT , stdin) != NULL)
>>    {
>>        printf ("OK\n");
>>    }
>>    return 0;
>> }
>>
>> But, I still get the same problem,
>
> I jump in the middle of the conversation but,
> the return will constantly end the helper...
> It is supposed to loop "forever".
> I used to use this:
>
> #define INPUTSIZE 8192 char input[INPUTSIZE]; while (fgets(input, sizeof(input), stdin)) { if ((cp=strchr(input, '\n')) == NULL) { fprintf(stderr, "filter: input too big: %s\n", input); } else { *cp = '\0'; } ... fflush(stderr); fflush(stdout); }
>
> JD

Actually, it should loop forever because the return is outside the
while (fgets(...) != NULL) and fgets is supposed to not return NULL
unless some error occurs.

Also refer to the source code of ext_session_acl which has a return 0
at the end.

-- 
Mohamed Amine Kadimi
Tél     : +212 (0) 675 72 36 45
Received on Mon Apr 16 2012 - 20:06:24 MDT

This archive was generated by hypermail 2.2.0 : Tue Apr 17 2012 - 12:00:03 MDT