[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patches to port libtool's libltdl to native Win32
From: |
Bob Friesenhahn |
Subject: |
Patches to port libtool's libltdl to native Win32 |
Date: |
Tue, 9 Jul 2002 11:01:48 -0500 (CDT) |
The attached patch against libtool CVS allows libltdl to compile using
only the Win32 API. This is useful in the MinGW compilation
environment.
I mailed my signed paperwork to the FSF on June 27th, so hopefully I
am cleared by now for libtool submissions.
Bob
Index: ChangeLog
===================================================================
RCS file: /cvsroot/libtool/libtool/ChangeLog,v
retrieving revision 1.1125
diff -u -r1.1125 ChangeLog
--- ChangeLog 26 Jun 2002 07:15:36 -0000 1.1125
+++ ChangeLog 9 Jul 2002 15:52:25 -0000
@@ -1,4 +1,8 @@
-2002-06-26 Bob Friesenhahn <address@hidden>
+2002-06-26 Bob Friesenhahn <address@hidden>
+
+ * ltdl.m4 & libltdl/ltdl.c: Port fully to native Win32 API.
+
+2002-06-26 Bob Friesenhahn <address@hidden>
* libtool.m4 (AC_LIBTOOL_SYS_DYNAMIC_LINKER) [mingw]: Remove
extraneous '=' character which appears in gcc 3.1
Index: ltdl.m4
===================================================================
RCS file: /cvsroot/libtool/libtool/ltdl.m4,v
retrieving revision 1.42
diff -u -r1.42 ltdl.m4
--- ltdl.m4 23 Jun 2002 22:43:39 -0000 1.42
+++ ltdl.m4 9 Jul 2002 15:52:26 -0000
@@ -102,6 +102,7 @@
AC_CHECK_FUNCS([strrchr rindex], [break])
AC_CHECK_FUNCS([memcpy bcopy], [break])
AC_CHECK_FUNCS([memmove strcmp])
+AC_CHECK_FUNCS([closedir opendir readdir])
])# AC_LIB_LTDL
Index: libltdl/ltdl.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.c,v
retrieving revision 1.167
diff -u -r1.167 ltdl.c
--- libltdl/ltdl.c 23 Jun 2002 21:35:58 -0000 1.167
+++ libltdl/ltdl.c 9 Jul 2002 15:52:26 -0000
@@ -65,20 +65,52 @@
# include <errno.h>
#endif
-#if HAVE_DIRENT_H
+
+#ifndef __WINDOWS__
+# ifdef __WIN32__
+# define __WINDOWS__
+# endif
+#endif
+
+
+#undef LT_USE_POSIX_DIRENT
+#ifdef HAVE_CLOSEDIR
+# ifdef HAVE_OPENDIR
+# ifdef HAVE_READDIR
+# ifdef HAVE_DIRENT_H
+# define LT_USE_POSIX_DIRENT
+# endif /* HAVE_DIRENT_H */
+# endif /* HAVE_READDIR */
+# endif /* HAVE_OPENDIR */
+#endif /* HAVE_CLOSEDIR */
+
+
+#undef LT_USE_WINDOWS_DIRENT_EMULATION
+#ifndef LT_USE_POSIX_DIRENT
+# ifdef __WINDOWS__
+# define LT_USE_WINDOWS_DIRENT_EMULATION
+# endif /* __WINDOWS__ */
+#endif /* LT_USE_POSIX_DIRENT */
+
+
+#ifdef LT_USE_POSIX_DIRENT
# include <dirent.h>
# define LT_D_NAMLEN(dirent) (strlen((dirent)->d_name))
#else
-# define dirent direct
-# define LT_D_NAMLEN(dirent) ((dirent)->d_namlen)
-# if HAVE_SYS_NDIR_H
-# include <sys/ndir.h>
-# endif
-# if HAVE_SYS_DIR_H
-# include <sys/dir.h>
-# endif
-# if HAVE_NDIR_H
-# include <ndir.h>
+# ifdef LT_USE_WINDOWS_DIRENT_EMULATION
+# define LT_D_NAMLEN(dirent) (strlen((dirent)->d_name))
+# else
+# define dirent direct
+# define LT_D_NAMLEN(dirent) ((dirent)->d_namlen)
+# if HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# if HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# if HAVE_NDIR_H
+# include <ndir.h>
+# endif
# endif
#endif
@@ -118,7 +150,28 @@
# define LT_READTEXT_MODE "r"
#endif
+#ifdef LT_USE_WINDOWS_DIRENT_EMULATION
+#include <windows.h>
+
+#define dirent lt_dirent
+#define DIR lt_DIR
+
+struct dirent
+{
+ char d_name[2048];
+ int d_namlen;
+};
+
+typedef struct _DIR
+{
+ HANDLE hSearch;
+ WIN32_FIND_DATA Win32FindData;
+ BOOL firsttime;
+ struct dirent file_info;
+} DIR;
+
+#endif /* LT_USE_WINDOWS_DIRENT_EMULATION */
/* --- MANIFEST CONSTANTS --- */
@@ -371,6 +424,76 @@
#endif /* !HAVE_MEMMOVE */
+#ifdef LT_USE_WINDOWS_DIRENT_EMULATION
+
+static void closedir LT_PARAMS((DIR *entry));
+
+static void
+closedir(entry)
+ DIR *entry;
+{
+ assert(entry != (DIR *) NULL);
+ FindClose(entry->hSearch);
+ lt_dlfree((lt_ptr)entry);
+}
+
+
+static DIR * opendir LT_PARAMS((const char *path));
+
+static DIR*
+opendir (path)
+ const char *path;
+{
+ char file_specification[LT_FILENAME_MAX];
+ DIR *entry;
+
+ assert(path != (char *) NULL);
+ (void) strncpy(file_specification,path,LT_FILENAME_MAX-1);
+ (void) strcat(file_specification,"\\");
+ entry = LT_DLMALLOC (DIR,sizeof(DIR));
+ if (entry != (DIR *) 0)
+ {
+ entry->firsttime = TRUE;
+ entry->hSearch = FindFirstFile(file_specification,&entry->Win32FindData);
+ }
+ if (entry->hSearch == INVALID_HANDLE_VALUE)
+ {
+ (void) strcat(file_specification,"\\*.*");
+ entry->hSearch = FindFirstFile(file_specification,&entry->Win32FindData);
+ if (entry->hSearch == INVALID_HANDLE_VALUE)
+ {
+ LT_DLFREE (entry);
+ return (DIR *) 0;
+ }
+ }
+ return(entry);
+}
+
+
+static struct dirent *readdir LT_PARAMS((DIR *entry));
+
+static struct dirent *readdir(entry)
+ DIR *entry;
+{
+ int
+ status;
+
+ if (entry == (DIR *) 0)
+ return((struct dirent *) 0);
+ if (!entry->firsttime)
+ {
+ status = FindNextFile(entry->hSearch,&entry->Win32FindData);
+ if (status == 0)
+ return((struct dirent *) 0);
+ }
+ entry->firsttime = FALSE;
+ (void) strncpy(entry->file_info.d_name,entry->Win32FindData.cFileName,
+ LT_FILENAME_MAX-1);
+ entry->file_info.d_namlen = strlen(entry->file_info.d_name);
+ return(&entry->file_info);
+}
+
+#endif /* LT_USE_WINDOWS_DIRENT_EMULATION */
/* According to Alexandre Oliva <address@hidden>,
``realloc is not entirely portable''
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Patches to port libtool's libltdl to native Win32,
Bob Friesenhahn <=