--- pfqueue-0.1.3.new/pfqueue.c.orig	2004-12-23 21:12:56.201678200 +0100
+++ pfqueue-0.1.3.new/pfqueue.c	2004-12-23 21:14:26.773909128 +0100
@@ -3,9 +3,12 @@
 #include <ncurses.h>
 #include <unistd.h>
 #include <sys/stat.h>
+#include <sys/types.h>
+#include <dirent.h>
 #include <stdlib.h>
 #include <string.h>
 
+
 #include "config.h"
 #include "ncgui.h"
 
@@ -82,7 +85,7 @@
 	int   tagged;
 };
 
-struct msg_t *queue;
+struct msg_t *queue[];
 
 char queue_path[BUF_SIZE];
 char config_path[BUF_SIZE];
@@ -101,7 +104,7 @@
 int msg_fileex(int n) {
 	char b[BUF_SIZE];
 	snprintf ( b, BUF_SIZE, "%s/%s/%c/%s",
-		queue_path, q_names[CURQ], queue[n].id[0], queue[n].id );
+		queue_path, q_names[CURQ], queue[n]->id[0], queue[n]->id );
 	return ( stat (b, &foostat )!=-1);
 }
 
@@ -141,59 +144,46 @@
 
 // Fills the list of messages
 void fill_list () {
-	FILE *p;
 	char b[BUF_SIZE];
+	DIR *dirp, *filep;
+	struct dirent *dp, *fp;
+	char const *entry;
+	
+	snprintf( b, BUF_SIZE, "%s/%s", queue_path, q_names[CURQ] );
 
-#ifndef HAS_FIND_PRINTF
-	char t[2048];
-	char *c;
-#endif
-
-#ifdef HAS_FIND_PRINTF
-#ifdef HAS_HEAD
-	snprintf ( b, BUF_SIZE, "find %s/%s -type f -printf '%%f\\n' | head -%d",
-		queue_path,
-		q_names[CURQ],
-		MSG_MAX );
-#else
-	snprintf ( b, BUF_SIZE, "find %s/%s -type f -printf '%%f\\n'",
-		queue_path,
-		q_names[CURQ]);
-#endif // HAS_HEAD
-#endif // HAS_FIND_PRINTF
-
-#ifndef HAS_FIND_PRINTF
-#ifdef HAS_HEAD
-	snprintf ( b, BUF_SIZE, "find %s/%s -type f | head -%d",
-		queue_path,
-		q_names[CURQ],
-		MSG_MAX );
-#else
-	snprintf ( b, BUF_SIZE, "find %s/%s -type f",
-		queue_path,
-		q_names[CURQ]);
-#endif // HAS_HEAD
-#endif // !HAS_FIND_PRINTF
+	dirp = opendir( b );
+	if (dirp == NULL)
+		return;
 
-	p = popen ( b, "r" );
+	filep = NULL;
 	NUMMSG = 0;
-
-#ifdef HAS_FIND_PRINTF
-	while ( NUMMSG<MSG_MAX && freadl ( p, queue[NUMMSG].id, sizeof(queue[NUMMSG].id) ) ) {
-		queue[NUMMSG].cached = 0;
-		NUMMSG++;
-	}
-#endif
-
-#ifndef HAS_FIND_PRINTF
-	while ( NUMMSG<MSG_MAX && freadl ( p, t, sizeof(t) ) ) {
-		queue[NUMMSG].cached = 0;
-		c = strrchr(t, '/' );
-		strncpy ( queue[NUMMSG].id, c+sizeof(char), 11 );
-		NUMMSG++;
+	while ( NUMMSG < MSG_MAX && ((dp = readdir (dirp)) != NULL) )  {
+		entry = dp->d_name;
+		
+		/* Skip "." ".." and "" (Returned by Slowlaris 2.4 on NFS *g*) */
+		if (dp->d_type == DT_DIR && (entry[entry[0] != '.' ? 0 : entry[1] != '.' ? 1 : 2] != '\0') ) {
+			snprintf( b, BUF_SIZE, "%s/%s/%s", queue_path, q_names[CURQ], entry );
+			filep = opendir( b );
+			if (filep == NULL)
+				continue;
+
+			while ( NUMMSG < MSG_MAX && ((fp = readdir (filep)) != NULL) )  {
+				entry = fp->d_name;
+				if (fp->d_type == DT_REG) {
+					queue[NUMMSG]->cached = 0;
+					strncpy(queue[NUMMSG]->id, entry, sizeof(queue[NUMMSG]->id));
+					NUMMSG++;
+				}
+			}
+		} else if (dp->d_type == DT_REG) {
+			queue[NUMMSG]->cached = 0;
+			strncpy(queue[NUMMSG]->id, entry, sizeof(queue[NUMMSG]->id));
+			NUMMSG++;
+		}
 	}
-#endif
-	pclose ( p );
+	closedir( dirp );
+	if (filep != NULL)
+		closedir ( filep );
 }
 
 // Extracts and header from the message
@@ -208,11 +198,11 @@
 		return;
 
 	snprintf ( b, BUF_SIZE, "postcat %s/%s/%c/%s 2> /dev/null", 
-		queue_path, q_names[CURQ], queue[m].id[0], queue[m].id );
+		queue_path, q_names[CURQ], queue[m]->id[0], queue[m]->id );
 	p = popen ( b, "r" );
 	if ( !p ) {
-		strcpy ( queue[m].from, "cant popen" );
-		strcpy ( queue[m].to,   "cant popen" );
+		strcpy ( queue[m]->from, "cant popen" );
+		strcpy ( queue[m]->to,   "cant popen" );
 		return;
 	}
 	
@@ -226,17 +216,17 @@
 		l2 = strlen(HEADER_TO);
 	}
 	
-	while ( (f1==0||f2==0) && freadl ( p, buf, sizeof(queue[m].from) ) ) {
+	while ( (f1==0||f2==0) && freadl ( p, buf, sizeof(queue[m]->from) ) ) {
 		if ( !f1 && ( (!use_envelope && !strncmp ( buf, HEADER_FROM, l1 ) ) ||
 		     ( use_envelope && !strncmp ( buf, ENVELOPE_FROM, l1 ) ) ) ) {
-			memcpy ( queue[m].from, buf+l1, sizeof(queue[m].from) );
-			if ( !strlen(queue[m].from) )
-				strcpy ( queue[m].from, ENVELOPE_NULL_SENDER );
+			memcpy ( queue[m]->from, buf+l1, sizeof(queue[m]->from) );
+			if ( !strlen(queue[m]->from) )
+				strcpy ( queue[m]->from, ENVELOPE_NULL_SENDER );
 			f1++;
 		}
 		if ( !f2 && ( (!use_envelope && !strncmp ( buf, HEADER_TO, l2 ) ) ||
 		     ( use_envelope && !strncmp ( buf, ENVELOPE_TO, l2 ) ) ) ) {
-			memcpy ( queue[m].to,   buf+l2, sizeof(queue[m].to) );
+			memcpy ( queue[m]->to,   buf+l2, sizeof(queue[m]->to) );
 			f2++;
 		}
 	}
@@ -249,7 +239,7 @@
 
 	FILE *p;
 	
-	if ( queue[n].cached )
+	if ( queue[n]->cached )
 		return;
 	
 	if ( !msg_fileex ( n ) )
@@ -263,23 +253,23 @@
 		char buf[BUF_SIZE];
 		snprintf ( buf, BUF_SIZE, "%s/defer/%c/%s", 
 			queue_path,
-			queue[n].id[0],
-			queue[n].id );
+			queue[n]->id[0],
+			queue[n]->id );
 		p = fopen ( buf, "r" );
 		
 		if ( !p )
-			strcpy ( queue[n].cause, "NONE" );
+			strcpy ( queue[n]->cause, "NONE" );
 		else {
 			if ( pf_version > PF_VERSION_20 )
-				flookfor ( p, queue[n].cause, sizeof(queue[n].cause), "reason=" );
+				flookfor ( p, queue[n]->cause, sizeof(queue[n]->cause), "reason=" );
 			else
-				freadl ( p, queue[n].cause, sizeof(queue[n].cause) );
+				freadl ( p, queue[n]->cause, sizeof(queue[n]->cause) );
 		}
 
 		if ( p )
 			fclose ( p );
 	}
-	queue[n].cached = 1;
+	queue[n]->cached = 1;
 }
 
 // Performs an action on the message
@@ -305,9 +295,9 @@
 	}
 
 	if ( strlen(config_path) )
-		snprintf ( b, BUF_SIZE, "postsuper -c %s -%c %s 2>/dev/null", config_path, o, queue[i].id );
+		snprintf ( b, BUF_SIZE, "postsuper -c %s -%c %s 2>/dev/null", config_path, o, queue[i]->id );
 	else
-		snprintf ( b, BUF_SIZE, "postsuper -%c %s 2>/dev/null", o, queue[i].id );
+		snprintf ( b, BUF_SIZE, "postsuper -%c %s 2>/dev/null", o, queue[i]->id );
 	system ( b );
 	free (b);
 }
@@ -316,7 +306,7 @@
 void msg_tagreset() {
 int i;
 	for ( i=0; i<NUMMSG; i++ )
-		queue[i].tagged = FALSE;
+		queue[i]->tagged = FALSE;
 	TAGGED = FALSE;
 	NUMTAG = 0;
 }
@@ -332,7 +322,7 @@
 
 	if ( TAGGED ) {
 		for ( i = 0; i<NUMMSG; i++ )
-			if ( queue[i].tagged )
+			if ( queue[i]->tagged )
 				msg_action_do ( i, act );
 		msg_tagreset();
 		CURROW = FIRSTROW;
@@ -437,21 +427,21 @@
 	}
 	
 	mvwaddstr ( mwnd, 0, 0, "Message:" );
-	mvwaddstr ( mwnd, 0, 9, queue[CURMSG].id );
+	mvwaddstr ( mwnd, 0, 9, queue[CURMSG]->id );
 	wclrtoeol ( mwnd );
 
 	mvwaddstr ( mwnd, 1, 0, "From.:" );
-	mvwaddstr ( mwnd, 1, 7, queue[CURMSG].from );
+	mvwaddstr ( mwnd, 1, 7, queue[CURMSG]->from );
 	wclrtoeol ( mwnd );
 	mvwaddstr ( mwnd, 2, 0, "To...:" );
-	mvwaddstr ( mwnd, 2, 7, queue[CURMSG].to );
+	mvwaddstr ( mwnd, 2, 7, queue[CURMSG]->to );
 	wclrtoeol ( mwnd );
 
 	if ( CURQ == Q_DEFERRED ) {
 		mvwaddstr ( mwnd, 3, 0, "Cause:" );
 		mvwaddstr ( mwnd, 4, 0, " " );
 		wclrtoeol ( mwnd );
-		mvwaddstr ( mwnd, 3, 7, queue[CURMSG].cause );
+		mvwaddstr ( mwnd, 3, 7, queue[CURMSG]->cause );
 		wclrtoeol ( mwnd );
 	}
 }
@@ -465,14 +455,14 @@
 	while ( j <= MAXROW ) {
 		if ( i<NUMMSG ) {
 			msg_fetch ( i );
-			if ( queue[i].tagged )
+			if ( queue[i]->tagged )
 				wattron ( lwnd, A_BOLD );
 			if ( i == CURMSG )
 				wattron ( lwnd, A_REVERSE );
 			mvwaddstr ( lwnd, j, 0, bline );
-			mvwaddstr ( lwnd, j, 1, queue[i].id );
-			mvwaddstr ( lwnd, j, COL1,   queue[i].from );
-			mvwaddstr ( lwnd, j, COL2,   queue[i].to );
+			mvwaddstr ( lwnd, j, 1, queue[i]->id );
+			mvwaddstr ( lwnd, j, COL1,   queue[i]->from );
+			mvwaddstr ( lwnd, j, COL2,   queue[i]->to );
 			wattroff ( lwnd, A_BOLD | A_REVERSE );
 		} else {
 			mvwaddstr ( lwnd, j, 1, " " );
@@ -584,11 +574,11 @@
 			queue_change ( Q_ACTIVE );
 			break;
 		case 't':
-			if ( queue[CURMSG].tagged )
+			if ( queue[CURMSG]->tagged )
 				NUMTAG--;
 			else
 				NUMTAG++;
-			queue[CURMSG].tagged = !queue[CURMSG].tagged;
+			queue[CURMSG]->tagged = !queue[CURMSG]->tagged;
 			queue_show();
 			break;
 		case 'u':
@@ -682,8 +672,8 @@
 	mwndb = lwnd = mwnd = 0;
 	bline = 0;
 
-	queue = (struct msg_t*)malloc(sizeof(struct msg_t)*MSG_MAX);
-	if ( !queue ) {
+	*queue = (struct msg_t*) malloc(sizeof(struct msg_t) * MSG_MAX);
+	if ( *queue == NULL ) {
 		printf ( "Sorry, cannot malloc for %d elements!\n", MSG_MAX );
 		exit (-2);
 	}
--- pfqueue-0.1.3.new/configure.in.orig	2004-12-23 21:13:19.580124136 +0100
+++ pfqueue-0.1.3.new/configure.in	2004-12-23 19:41:14.000000000 +0100
@@ -24,24 +24,6 @@
 AC_HEADER_STDC
 AC_CHECK_HEADERS(ncurses.h)
 
-dnl Checks for head
-AC_CHECK_PROG(HAS_HEAD,head,yes,no)
-if test "$HAS_HEAD" = "yes"
-then
-AC_DEFINE(HAS_HEAD,1,[Has head program])
-fi
-
-dnl Checks for find
-AC_CHECK_PROG(HAS_FIND,find,yes,no)
-if test "$HAS_FIND" = "yes"
-then
-find /etc -type f -printf %f 2>/dev/null >/dev/null
-	if test "$?" = "0"
-	then
-	AC_DEFINE(HAS_FIND_PRINTF,1,[Find has -printf option])
-	fi
-fi
-
 jm_CHECK_TYPE_STRUCT_UTIMBUF
 AC_HEADER_MAJOR
 
