X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslurpd%2Freplog.c;h=53a82f64e4ec6bf15809b16b370ccf727820d59a;hb=4abbf9c610d4fbaeee0dbdceaad1e0f94ed8e8fe;hp=eb53bf10539b4f86e612840ce5f95a8499f23aa3;hpb=0c0f011dc0302348484d0278e2e8f2cbe53d1961;p=openldap diff --git a/servers/slurpd/replog.c b/servers/slurpd/replog.c index eb53bf1053..53a82f64e4 100644 --- a/servers/slurpd/replog.c +++ b/servers/slurpd/replog.c @@ -1,5 +1,18 @@ -/* - * Copyright (c) 1996 Regents of the University of Michigan. +/* $OpenLDAP$ */ +/* This work is part of OpenLDAP Software . + * + * Copyright 1998-2005 The OpenLDAP Foundation. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted only as authorized by the OpenLDAP + * Public License. + * + * A copy of this license is available in file LICENSE in the + * top-level directory of the distribution or, alternatively, at + * . + */ +/* Portions Copyright (c) 1996 Regents of the University of Michigan. * All rights reserved. * * Redistribution and use in source and binary forms are permitted @@ -9,52 +22,35 @@ * software without specific prior written permission. This software * is provided ``as is'' without express or implied warranty. */ +/* ACKNOWLEDGEMENTS: + * This work was originally developed by the University of Michigan + * (as part of U-MICH LDAP). + */ /* * replog.c - routines which read and write replication log files. */ -#define DISABLE_BRIDGE #include "portable.h" - -#include #include -#include + +#include +#include +#include +#include +#include #include -#include +#include + #include -#include + #include -#include -#include #include "slurp.h" #include "globals.h" -/* - * Externs - */ -extern FILE *lock_fopen LDAP_P(( char *, char *, FILE ** )); -extern char *ch_malloc LDAP_P(( unsigned long )); - -/* - * Forward declarations - */ -int file_nonempty LDAP_P(( char * )); - - -#ifdef DECL_SYS_ERRLIST -extern char *sys_errlist[]; -#endif - -/* - * Forward declarations - */ -static int duplicate_replog( char *, char * ); - - /* * Copy the replication log. Returns 0 on success, 1 if a temporary * error occurs, and -1 if a fatal error occurs. @@ -83,27 +79,27 @@ copy_replog( * with a fatal error. */ strcpy( buf, src ); - if (( p = strrchr( buf, '/' )) == NULL ) { + if (( p = strrchr( buf, LDAP_DIRSEP[0] )) == NULL ) { strcpy( buf, "." ); } else { *p = '\0'; } 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 ); - if (( p = strrchr( buf, '/' )) == NULL ) { + if (( p = strrchr( buf, LDAP_DIRSEP[0] )) == NULL ) { strcpy( buf, "." ); } else { *p = '\0'; } 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 ); } @@ -119,17 +115,17 @@ copy_replog( /* lock dst */ dfp = lock_fopen( dst, "a", &dlfp ); if ( dfp == NULL ) { - Debug( LDAP_DEBUG_ANY, - "Error: copy_replog: Can't lock replog \"%s\" for write: %s\n", - src, sys_errlist[ errno ], 0 ); - lock_fclose( rfp ); + Debug( LDAP_DEBUG_ANY, + "Error: copy_replog: Can't lock replog \"%s\" for write: %s\n", + dst, sys_errlist[ errno ], 0 ); + lock_fclose( rfp, lfp ); return( 1 ); } /* * Make our own private copy of the replication log. */ - while (( p = fgets( rbuf, sizeof( buf ), rfp )) != NULL ) { + while (( p = fgets( rbuf, sizeof( rbuf ), rfp )) != NULL ) { fputs( rbuf, dfp ); } /* Only truncate the source file if we're not in one-shot mode */ @@ -138,12 +134,12 @@ copy_replog( truncate( src, (off_t) 0 ); } - if ( lock_fclose( rfp, lfp ) == EOF ) { - Debug( LDAP_DEBUG_ANY, - "Error: copy_replog: Error closing \"%s\"\n", - src, 0, 0 ); - } if ( lock_fclose( dfp, dlfp ) == EOF ) { + Debug( LDAP_DEBUG_ANY, + "Error: copy_replog: Error closing \"%s\"\n", + dst, 0, 0 ); + } + if ( lock_fclose( rfp, lfp ) == EOF ) { Debug( LDAP_DEBUG_ANY, "Error: copy_replog: Error closing \"%s\"\n", src, 0, 0 );