From: Kurt Zeilenga Date: Fri, 19 Mar 2004 18:16:47 +0000 (+0000) Subject: slashpath from HEAD X-Git-Tag: OPENLDAP_REL_ENG_2_2_7~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f9eabe153b97050a878d83a041a9c6dd23133423;p=openldap slashpath from HEAD --- diff --git a/include/lutil.h b/include/lutil.h index b5b5b8c5c7..8c7894e16f 100644 --- a/include/lutil.h +++ b/include/lutil.h @@ -147,6 +147,14 @@ lutil_progname LDAP_P(( int argc, char *argv[] )); +#ifdef _WIN32 +LDAP_LUTIL_F( void ) +lutil_slashpath LDAP_P(( char* path )); +#define LUTIL_SLASHPATH(p) lutil_slashpath(p) +#else +#define LUTIL_SLASHPATH(p) +#endif + LDAP_LUTIL_F( char* ) lutil_strcopy LDAP_P(( char *dst, const char *src )); diff --git a/libraries/liblutil/utils.c b/libraries/liblutil/utils.c index e09940c7da..4813a063e2 100644 --- a/libraries/liblutil/utils.c +++ b/libraries/liblutil/utils.c @@ -34,6 +34,23 @@ int _trans_argv = 1; #endif +#ifdef _WIN32 +/* Some Windows versions accept both forward and backslashes in + * directory paths, but we always use backslashes when generating + * and parsing... + */ +void lutil_slashpath( char *path ) +{ + char *c, *p; + + p = path; + while (( c=strchr( p, '/' ))) { + *c++ = '\\'; + p = c; + } +} +#endif + char* lutil_progname( const char* name, int argc, char *argv[] ) { char *progname; @@ -49,9 +66,9 @@ char* lutil_progname( const char* name, int argc, char *argv[] ) _trans_argv = 0; } #endif + LUTIL_SLASHPATH( argv[0] ); progname = strrchr ( argv[0], *LDAP_DIRSEP ); progname = progname ? &progname[1] : argv[0]; - return progname; }