--- a/filter.c Sat Aug 11 14:09:03 2007 +0200
+++ b/filter.c Sat Aug 11 15:52:30 2007 +0200
@@ -4,6 +4,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
+#include <fcntl.h>
#include "dictre.h"
@@ -35,6 +36,7 @@
char *out;
int outsize;
int outrest;
+ int res;
out = 0;
outsize = SIZESTEP;
@@ -42,6 +44,14 @@
more_memory((void **) &out, outsize);
outrest = SIZESTEP;
+ /* We need unblocking write for select() */
+ res = fcntl(writeto, F_SETFL, O_NONBLOCK);
+ if (res == -1)
+ {
+ perror("Error setting nonblock to writeto");
+ exit(-1);
+ }
+
maxfd = writeto;
if (readfrom > maxfd)
maxfd = readfrom;
@@ -87,6 +97,19 @@
}
} while(1);
+ /*
+ {
+ int i;
+ printf("In : ");
+ for(i=0; i < deflen; ++i)
+ putchar(def[i]);
+ printf("\nOut: ");
+ for(i=0; i < outptr; ++i)
+ putchar(out[i]);
+ putchar('\n');
+ }
+ */
+
if (defptr < deflen)
{
fprintf(stderr, "Error in filter! not all written.\n");
@@ -122,7 +145,7 @@
dup(read_pipe[1]);
close(read_pipe[1]);
close(read_pipe[0]);
- execlp("bash", "bash", "-c", filter_par, 0);
+ execl(filter_par, filter_par, 0);
perror("execlp");
exit(-1);
break;
@@ -166,6 +189,8 @@
void filter_all(const char *filter_par)
{
int i;
+ static int dispndefs = 0;
+ static int filtereddefs = 0;
for(i=0; i < ndefs; ++i)
{
@@ -181,6 +206,14 @@
free(defs[i].d);
defs[i].d = newdef;
}
+ filtereddefs++; /* Not really all filtered. All but the 00-database* */
+ dispndefs++;
+ if (dispndefs >= 100)
+ {
+ dispndefs = 0;
+ printf("Filtered: %i/%i (%f)\n", filtereddefs, ndefs,
+ (float) filtereddefs / (float) ndefs);
+ }
}
}
}