]> git.sur5r.net Git - openldap/blobdiff - servers/slurpd/replog.c
Relocate regex.h test to near top and die if it fails.
[openldap] / servers / slurpd / replog.c
index c3a855cffecbc626a00d2c67b443c74213c40e73..0e8f2f4c2ef5888b6937439aa083441962b181e1 100644 (file)
  * replog.c - routines which read and write replication log files.
  */
 
-
-#include <errno.h>
-#include <stdio.h>
-#include <syslog.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/param.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-
 #include "portable.h"
-#include "slurp.h"
-#include "globals.h"
 
-/*
- * Externs
- */
-#ifdef NEEDPROTOS
-extern FILE *lock_fopen( char *, char *, FILE ** );
-extern char *ch_malloc( unsigned long );
-#else /* NEEDPROTOS */
-extern FILE *lock_fopen();
-extern char *ch_malloc();
-#endif /* NEEDPROTOS */
+#include <stdio.h>
 
-/*
- * Forward declarations
- */
-#ifdef NEEDPROTOS
-int file_nonempty( char * );
-#else /* NEEDPROTOS */
-int file_nonempty();
-#endif /* NEEDPROTOS */
+#include <ac/errno.h>
+#include <ac/string.h>
+#include <ac/syslog.h>
+#include <ac/time.h>
+#include <ac/unistd.h>
 
+#include <sys/stat.h>
 
-#ifndef SYSERRLIST_IN_STDIO
-extern char *sys_errlist[];
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
 #endif
 
-/*
- * Forward declarations
- */
-static int duplicate_replog( char *, char * );
-
-
+#include <fcntl.h>
 
+#include "slurp.h"
+#include "globals.h"
 
 /*
  * Copy the replication log.  Returns 0 on success, 1 if a temporary
@@ -99,8 +71,8 @@ copy_replog(
     }
     if ( access( buf, W_OK ) < 0 ) {
        Debug( LDAP_DEBUG_ANY,
-               "Error: copy_replog (%d): Directory %s is not writable\n",
-               getpid(), buf, 0 );
+               "Error: copy_replog (%ld): Directory %s is not writable\n",
+               (long) getpid(), buf, 0 );
        return( -1 );
     }
     strcpy( buf, dst );
@@ -111,8 +83,8 @@ copy_replog(
     }
     if ( access( buf, W_OK ) < 0 ) {
        Debug( LDAP_DEBUG_ANY,
-               "Error: copy_replog (%d): Directory %s is not writable\n",
-               getpid(), buf, 0 );
+               "Error: copy_replog (%ld): Directory %s is not writable\n",
+               (long) getpid(), buf, 0 );
        return( -1 );
     }
 
@@ -131,7 +103,7 @@ copy_replog(
        Debug( LDAP_DEBUG_ANY,
                "Error: copy_replog: Can't lock replog \"%s\" for write: %s\n",
                src, sys_errlist[ errno ], 0 );
-       lock_fclose( rfp );
+       lock_fclose( rfp, lfp );
        return( 1 );
     }
 
@@ -147,12 +119,12 @@ copy_replog(
        truncate( src, (off_t) 0 );
     }
 
-    if ( lock_fclose( rfp, lfp ) == EOF ) {
+    if ( lock_fclose( dfp, dlfp ) == EOF ) {
        Debug( LDAP_DEBUG_ANY,
                "Error: copy_replog: Error closing \"%s\"\n",
                src, 0, 0 );
     }
-    if ( lock_fclose( dfp, dlfp ) == EOF ) {
+    if ( lock_fclose( rfp, lfp ) == EOF ) {
        Debug( LDAP_DEBUG_ANY,
                "Error: copy_replog: Error closing \"%s\"\n",
                src, 0, 0 );