]> git.sur5r.net Git - openldap/commitdiff
slashpath from HEAD
authorKurt Zeilenga <kurt@openldap.org>
Fri, 19 Mar 2004 18:16:47 +0000 (18:16 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 19 Mar 2004 18:16:47 +0000 (18:16 +0000)
include/lutil.h
libraries/liblutil/utils.c

index b5b5b8c5c76caf38f02728214628dac43d742c62..8c7894e16f516a5dc05bffac2205557a50616850 100644 (file)
@@ -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 ));
 
index e09940c7daa2dc427d087f67410cc683b4fb9f61..4813a063e23ded86e5785d5e02f445ccdb8184af 100644 (file)
 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;
 }