From: Howard Chu Date: Fri, 7 Dec 2001 01:46:26 +0000 (+0000) Subject: From jon@symas.com - patches for consistent use of directory separators X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~735 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e6d6faf3c9a2089b621804501c39dcb14e402b23;p=openldap From jon@symas.com - patches for consistent use of directory separators in pathnames. --- diff --git a/clients/finger/main.c b/clients/finger/main.c index 96f8d3595c..ec2a07460e 100644 --- a/clients/finger/main.c +++ b/clients/finger/main.c @@ -122,7 +122,7 @@ main( int argc, char **argv ) } #endif - if ( (myname = strrchr( argv[0], '/' )) == NULL ) + if ( (myname = strrchr( argv[0], *LDAP_DIRSEP )) == NULL ) myname = strdup( argv[0] ); else myname = strdup( myname + 1 ); diff --git a/clients/mail500/main.c b/clients/mail500/main.c index 789fbe4353..cbe5bb8037 100644 --- a/clients/mail500/main.c +++ b/clients/mail500/main.c @@ -163,7 +163,7 @@ main ( int argc, char **argv ) int numto, ngroups, numerr, nargs; int i, j; - if ( (myname = strrchr( argv[0], '/' )) == NULL ) + if ( (myname = strrchr( argv[0], *LDAP_DIRSEP )) == NULL ) myname = strdup( argv[0] ); else myname = strdup( myname + 1 ); diff --git a/clients/maildap/main.c b/clients/maildap/main.c index 9a501d8408..36b58576b8 100644 --- a/clients/maildap/main.c +++ b/clients/maildap/main.c @@ -191,7 +191,7 @@ main ( int argc, char **argv ) int i, j; char *conffile = NULL; - if ( (myname = strrchr( argv[0], '/' )) == NULL ) + if ( (myname = strrchr( argv[0], *LDAP_DIRSEP )) == NULL ) myname = strdup( argv[0] ); else myname = strdup( myname + 1 ); diff --git a/clients/tools/ldapdelete.c b/clients/tools/ldapdelete.c index 57a1444b70..466a32c35a 100644 --- a/clients/tools/ldapdelete.c +++ b/clients/tools/ldapdelete.c @@ -590,7 +590,7 @@ main( int argc, char **argv ) } #else fprintf( stderr, "%s: not compiled with SASL support\n", - argv[0] ); + prog ); return( EXIT_FAILURE ); #endif } diff --git a/clients/tools/ldapmodify.c b/clients/tools/ldapmodify.c index 08319972f7..82390b7fdd 100644 --- a/clients/tools/ldapmodify.c +++ b/clients/tools/ldapmodify.c @@ -659,7 +659,7 @@ main( int argc, char **argv ) } #else fprintf( stderr, "%s: not compiled with SASL support\n", - argv[0] ); + prog ); return( EXIT_FAILURE ); #endif } diff --git a/clients/tools/ldapmodrdn.c b/clients/tools/ldapmodrdn.c index a6bf34b512..e3475e5553 100644 --- a/clients/tools/ldapmodrdn.c +++ b/clients/tools/ldapmodrdn.c @@ -482,7 +482,7 @@ main(int argc, char **argv) default: fprintf( stderr, "%s: unrecognized option -%c\n", prog, optopt ); - usage( argv[0] ); + usage( prog ); return( EXIT_FAILURE ); } } @@ -512,7 +512,7 @@ main(int argc, char **argv) } else if ( argc - optind != 0 ) { fprintf( stderr, "%s: invalid number of arguments (%d), " "only two allowed\n", prog, argc-optind ); - usage( argv[0] ); + usage( prog ); return( EXIT_FAILURE ); } @@ -627,7 +627,7 @@ main(int argc, char **argv) } #else fprintf( stderr, "%s: not compiled with SASL support\n", - argv[0] ); + prog ); return( EXIT_FAILURE ); #endif } diff --git a/clients/tools/ldappasswd.c b/clients/tools/ldappasswd.c index 8d254aabed..f161ac79ad 100644 --- a/clients/tools/ldappasswd.c +++ b/clients/tools/ldappasswd.c @@ -483,7 +483,7 @@ main( int argc, char *argv[] ) default: fprintf( stderr, "%s: unrecognized option -%c\n", prog, optopt ); - usage (argv[0]); + usage (prog); } } @@ -496,7 +496,7 @@ main( int argc, char *argv[] ) } if( argc - optind > 1 ) { - usage( argv[0] ); + usage( prog ); } else if ( argc - optind == 1 ) { user = strdup( argv[optind] ); } else { @@ -636,7 +636,7 @@ main( int argc, char *argv[] ) } #else fprintf( stderr, "%s: not compiled with SASL support\n", - argv[0] ); + prog ); return( EXIT_FAILURE ); #endif } diff --git a/clients/ud/edit.c b/clients/ud/edit.c index fa97178f60..9e20860383 100644 --- a/clients/ud/edit.c +++ b/clients/ud/edit.c @@ -143,7 +143,7 @@ load_editor( void ) #endif #ifdef HAVE_MKSTEMP - sprintf(entry_temp_file, "/tmp/udXXXXXX"); + strcpy(entry_temp_file, LDAP_TMPDIR LDAP_DIRSEP "udXXXXXX"); tmpfd = mkstemp(entry_temp_file); @@ -192,7 +192,7 @@ load_editor( void ) if (verbose) { char *p; - if (( p = strrchr( editor, '/' )) == NULL ) { + if (( p = strrchr( editor, *LDAP_DIRSEP )) == NULL ) { p = editor; } else { ++p; diff --git a/libraries/libldap/init.c b/libraries/libldap/init.c index 227617704c..05b931a4df 100644 --- a/libraries/libldap/init.c +++ b/libraries/libldap/init.c @@ -263,11 +263,11 @@ static void openldap_ldap_init_w_userconf(const char *file) /* we assume UNIX path syntax is used... */ /* try ~/file */ - sprintf(path, "%s/%s", home, file); + sprintf(path, "%s%s%s", home, LDAP_DIRSEP, file); openldap_ldap_init_w_conf(path, 1); /* try ~/.file */ - sprintf(path, "%s/.%s", home, file); + sprintf(path, "%s%s.%s", home, LDAP_DIRSEP, file); openldap_ldap_init_w_conf(path, 1); } diff --git a/libraries/libldif/fetch.c b/libraries/libldif/fetch.c index 1f62be80e0..3038676501 100644 --- a/libraries/libldif/fetch.c +++ b/libraries/libldif/fetch.c @@ -51,7 +51,8 @@ ldif_fetch_url( return -1; } - if( *p != *LDAP_DIRSEP ) { + /* we don't check for LDAP_DIRSEP since URLs should contain '/' */ + if( *p != '/' ) { /* skip over false root */ p++; } diff --git a/libraries/liblunicode/ucdata/ucdata.c b/libraries/liblunicode/ucdata/ucdata.c index 01a94a0294..24be72df64 100644 --- a/libraries/liblunicode/ucdata/ucdata.c +++ b/libraries/liblunicode/ucdata/ucdata.c @@ -27,6 +27,7 @@ /* $Id: ucdata.c,v 1.4 2001/01/02 18:46:20 mleisher Exp $" */ #include "portable.h" +#include "ldap_config.h" #include #include @@ -36,12 +37,6 @@ #include "ucdata.h" -#ifdef WIN32 -#define UC_DIRSEP '\\' -#else -#define UC_DIRSEP '/' -#endif - /************************************************************************** * * Miscellaneous types, data, and support functions. @@ -89,7 +84,7 @@ _ucopenfile(char *paths, char *filename, char *mode) pp = path; while (*dp && *dp != ':') *pp++ = *dp++; - *pp++ = UC_DIRSEP; + *pp++ = *LDAP_DIRSEP; fp = filename; while (*fp) diff --git a/libraries/liblunicode/ucdata/ucgendat.c b/libraries/liblunicode/ucdata/ucgendat.c index ff165f7308..faedd216f3 100644 --- a/libraries/liblunicode/ucdata/ucgendat.c +++ b/libraries/liblunicode/ucdata/ucgendat.c @@ -23,6 +23,7 @@ /* $Id: ucgendat.c,v 1.4 2001/01/02 18:46:20 mleisher Exp $" */ #include "portable.h" +#include "ldap_config.h" #include #include @@ -1181,7 +1182,7 @@ write_cdata(char *opath) /* * Open the ctype.dat file. */ - sprintf(path, "%s/ctype.dat", opath); + sprintf(path, "%s%sctype.dat", opath, LDAP_DIRSEP); if ((out = fopen(path, "wb")) == 0) return; @@ -1252,7 +1253,7 @@ write_cdata(char *opath) /* * Open the case.dat file. */ - sprintf(path, "%s/case.dat", opath); + sprintf(path, "%s%scase.dat", opath, LDAP_DIRSEP); if ((out = fopen(path, "wb")) == 0) return; @@ -1307,7 +1308,7 @@ write_cdata(char *opath) /* * Open the comp.dat file. */ - sprintf(path, "%s/comp.dat", opath); + sprintf(path, "%s%scomp.dat", opath, LDAP_DIRSEP); if ((out = fopen(path, "wb")) == 0) return; @@ -1345,7 +1346,7 @@ write_cdata(char *opath) /* * Open the decomp.dat file. */ - sprintf(path, "%s/decomp.dat", opath); + sprintf(path, "%s%sdecomp.dat", opath, LDAP_DIRSEP); if ((out = fopen(path, "wb")) == 0) return; @@ -1405,7 +1406,7 @@ write_cdata(char *opath) /* * Open the cmbcl.dat file. */ - sprintf(path, "%s/cmbcl.dat", opath); + sprintf(path, "%s%scmbcl.dat", opath, LDAP_DIRSEP); if ((out = fopen(path, "wb")) == 0) return; @@ -1443,7 +1444,7 @@ write_cdata(char *opath) /* * Open the num.dat file. */ - sprintf(path, "%s/num.dat", opath); + sprintf(path, "%s%snum.dat", opath, LDAP_DIRSEP); if ((out = fopen(path, "wb")) == 0) return; @@ -1496,7 +1497,7 @@ main(int argc, char *argv[]) FILE *in; char *prog, *opath; - if ((prog = strrchr(argv[0], '/')) != 0) + if ((prog = strrchr(argv[0], *LDAP_DIRSEP)) != 0) prog++; else prog = argv[0];