On Wed, 19 Jan 2000, Petr Novotny wrote:
> maildecide is a program I have written in C which counts the bytes,
> rewinds stdin and invokes /var/qmail{2,3}/bin/forward. I didn't
> succeed with condredirect - it fails to pass the $HOST to the
> redirected address.
>
> maildecide.c looks like this:
> #include <stdio.h>
> #include <stdlib.h>
>
> void main(void)
> {
> int len=0;
> while (!feof(stdin))
> { fgetc(stdin); len++; }
> rewind(stdin);
ugh, byte-at-a-time reading for stdin, and then rewind it.
>
> if (len>=128000)
> system("/var/qmail3/bin/forward \"$DEFAULT@$HOST\"");
> else
> system("/var/qmail2/bin/forward \"$DEFAULT@$HOST\"");
> }
>
Here is a version which should run much faster; it doesn't read anyhting out of the
file.
#include <stdio.h>
#include <stdlib.h>
void main(void)
{
long len=0L;
fseek( stdin, 0L, SEEK_END);
len=ftell(stdin);
fseek( stdin, 0L, SEEK_SET);
if (len>=128000L)
system("/var/qmail3/bin/forward \"$DEFAULT@$HOST\"");
else
system("/var/qmail2/bin/forward \"$DEFAULT@$HOST\"");
}
-----
RjL
==================================================================
You know that. I know that. But when || Austin, Texas
you talk to a monkey you have to || Email: [EMAIL PROTECTED]
grunt and wave your arms -ck ||