On Sat, 21 Aug 2004, Hegedus Ervin wrote:
hello,
i'm looking the external acl scheme - i trying to make a simple external helper, but i stuck in it...
here is the part of code:
while (1) { syslog(LOG_WARNING, "waiting datas..."); fgets(input, sizeof(input), stdin);
This is better done
while(fgets(input, sizeof(input), stdin) != NULL) { if ((cp = strchr(input, '\n')) != NULL) {
*cp = '\0';
}
syslog (LOG_WARNING, "getting info: %s", input); p1 = NULL; p2 = NULL; if ((cp = strtok(input, " \t")) != NULL) { p1 = cp; p2 = strtok(NULL, " \t"); } syslog(LOG_WARNING, "get: %s %s\n", p1, p2); printf("OK\n"); syslog(LOG_WARNING, "sending OK..."); }
(to see, how works my program, i send their messages through syslog)
You could also write to stderr.. the output ends up in cache.log.
2004/08/21 20:46:16| aclMatchAcl: checking 'acl srcip external SRC_IP' 2004/08/21 20:46:16| externalAclLookup: lookup in 'SRC_IP' for 'airween 192.168.0.2'
and then nothing to happen....
Most likely you have forgot to disable buffering of stdout. If this is done printf and friends does not immediately print out the data but waits for more data to be printed by your application (which won't happen).
setbuf(stdout, NULL);
in the startup of your program should help.
Regards Henrik
