changeset 387:0137b5490cca noffle

[svn] * src/outgoing.c: Don't assume "." and ".." are the first files returned from readdir(). Thanks to Andreas Happe for spotting this.
author bears
date Thu, 22 May 2003 09:26:25 +0100
parents 278a03a392b1
children 8e14809bf172
files src/outgoing.c
diffstat 1 files changed, 16 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/outgoing.c	Thu May 22 09:23:33 2003 +0100
+++ b/src/outgoing.c	Thu May 22 09:26:25 2003 +0100
@@ -1,7 +1,7 @@
 /*
   outgoing.c
 
-  $Id: outgoing.c 425 2003-01-30 15:49:23Z bears $
+  $Id: outgoing.c 529 2003-05-22 08:26:25Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -91,8 +91,6 @@
         return FALSE;
     }
     Utl_cpyStr( outgoing.serv, serv );
-    Out_next( NULL, NULL ); /* "."  */
-    Out_next( NULL, NULL ); /* ".." */
     return Out_next( msgId, artTxt );
 }
 
@@ -104,12 +102,17 @@
     Str file, line;
 
     ASSERT( outgoing.dir );
-    if ( ! ( d = readdir( outgoing.dir ) ) )
-    {
-        closedir( outgoing.dir );
-        outgoing.dir = NULL;
-        return FALSE;
-    }
+    
+    do {
+	if ( ! ( d = readdir( outgoing.dir ) ) )
+	{
+	    closedir( outgoing.dir );
+	    outgoing.dir = NULL;
+	    return FALSE;
+	}
+    } while ( strcmp( d->d_name, "." ) == 0 ||
+	      strcmp( d->d_name, ".." ) == 0 );
+    
     if ( msgId != NULL )
     	Utl_cpyStr( msgId, d->d_name );
     if ( artTxt == NULL )
@@ -153,15 +156,16 @@
         return FALSE;
     }
 
-    readdir( d );	/* '.' */
-    readdir( d );	/* '..' */
-
     res = FALSE;
     while ( ! res && ( entry = readdir( d ) ) != NULL )
     {
 	Str file;
 	struct stat s;
 
+	if ( strcmp( entry->d_name, "." ) == 0 ||
+	     strcmp( entry->d_name, ".." ) == 0 )
+	    continue;
+	
 	fileOutgoing( file, entry->d_name, msgId );
 	if ( stat( file, &s ) == 0 )
 	{