changeset 238:70a34f697a50 src

lower impact solution for the win32 build * reuse dlfcn stuff from libdvdnav/msvc/contrib * use -no-undefined on windows only, since it is wrong on Linux
author mroi
date Fri, 13 Feb 2004 19:15:30 +0000
parents 0935fd314458
children eaa775ba1306
files dvdread/Makefile.am dvdread/dlfcn.c dvdread/dlfcn.h dvdread/dvd_input.c
diffstat 4 files changed, 6 insertions(+), 127 deletions(-) [+]
line wrap: on
line diff
--- a/dvdread/Makefile.am	Wed Feb 11 15:05:20 2004 +0000
+++ b/dvdread/Makefile.am	Fri Feb 13 19:15:30 2004 +0000
@@ -14,4 +14,4 @@
 include_HEADERS = dvd_reader.h nav_read.h ifo_read.h \
 	nav_print.h ifo_print.h ifo_types.h nav_types.h
 
-noinst_HEADERS = bswap.h dvd_input.h dvdread_internal.h dvd_udf.h md5.h dlfcn.c dlfcn.h
+noinst_HEADERS = bswap.h dvd_input.h dvdread_internal.h dvd_udf.h md5.h
--- a/dvdread/dlfcn.c	Wed Feb 11 15:05:20 2004 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,96 +0,0 @@
-/*
- * $Id$
- * $Name$
- * 
- * Adopted from Apache DSO code.
- * Portions copyright Apache Software Foundation
- *
- * Structures and types used to implement dlopen, dlsym, etc.
- * on Windows 95/NT.
- */
-#include <windows.h>
-#include <string.h>
-#include <stdio.h>
-
-#include "dlfcn.h"
-
-void *dlopen(const char *module_name, int mode)
-{
-    UINT em;
-    HINSTANCE dsoh;
-    char path[MAX_PATH], *p;
-    /* Load the module...
-     * per PR2555, the LoadLibraryEx function is very picky about slashes.
-     * Debugging on NT 4 SP 6a reveals First Chance Exception within NTDLL.
-     * LoadLibrary in the MS PSDK also reveals that it -explicitly- states
-     * that backslashes must be used.
-     *
-     * Transpose '\' for '/' in the filename.
-     */
-    (void)strncpy(path, module_name, MAX_PATH);
-    p = path;
-    while (p = strchr(p, '/'))
-        *p = '\\';
-    
-    /* First assume the dso/dll's required by -this- dso are sitting in the 
-     * same path or can be found in the usual places.  Failing that, let's
-     * let that dso look in the apache root.
-     */
-    em = SetErrorMode(SEM_FAILCRITICALERRORS);
-    dsoh = LoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
-    if (!dsoh) 
-    {
-        SetLastError(0); // clear the last error
-        dsoh = LoadLibraryEx(path, NULL, 0);
-    }
-    SetErrorMode(em);
-    SetLastError(0); // clear the last error
-    return (void *)dsoh;
-}
-
-char *dlerror(void)
-{
-    int len, nErrorCode;
-    static char errstr[120];
-    /* This is -not- threadsafe code, but it's about the best we can do.
-     * mostly a potential problem for isapi modules, since LoadModule
-     * errors are handled within a single config thread.
-     */
-    
-    if((nErrorCode = GetLastError()) == 0)
-      return((char *)0);
-
-    SetLastError(0); // clear the last error
-    len = snprintf(errstr, sizeof(errstr), "(%d) ", nErrorCode);
-
-    len += FormatMessage( 
-            FORMAT_MESSAGE_FROM_SYSTEM,
-            NULL,
-            nErrorCode,
-            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */
-            (LPTSTR) errstr + len,
-            sizeof(errstr) - len,
-            NULL 
-        );
-        /* FormatMessage may have appended a newline (\r\n). So remove it 
-         * and use ": " instead like the Unix errors. The error may also
-         * end with a . before the return - if so, trash it.
-         */
-    if (len > 1 && errstr[len-2] == '\r' && errstr[len-1] == '\n') {
-        if (len > 2 && errstr[len-3] == '.')
-            len--;
-        errstr[len-2] = ':';
-        errstr[len-1] = ' ';
-    }
-    return errstr;
-}
-
-int dlclose(void *handle)
-{
-  return  FreeLibrary(handle);
-}
-
-void *dlsym(void *handle, const char *name)
-{
-  return GetProcAddress(handle, name);
-}
--- a/dvdread/dlfcn.h	Wed Feb 11 15:05:20 2004 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-#ifndef __DLFCN_H__
-# define __DLFCN_H__
-/*
- * $Id$
- * $Name$
- * 
- *
- */
-extern void *dlopen  (const char *file, int mode);
-extern int   dlclose (void *handle);
-extern void *dlsym   (void * handle, const char * name);
-extern char *dlerror (void);
-
-/* These don't mean anything on windows */
-#define RTLD_NEXT      ((void *) -1l)
-#define RTLD_DEFAULT   ((void *) 0)
-#define RTLD_LAZY					-1
-#define RTLD_NOW					-1
-#define RTLD_BINDING_MASK -1
-#define RTLD_NOLOAD				-1
-#define RTLD_GLOBAL				-1
-
-#endif /* __DLFCN_H__ */
--- a/dvdread/dvd_input.c	Wed Feb 11 15:05:20 2004 +0000
+++ b/dvdread/dvd_input.c	Fri Feb 13 19:15:30 2004 +0000
@@ -24,13 +24,6 @@
 #include <fcntl.h>
 #include <unistd.h>
 
-#ifdef HAVE_DLFCN_H
-#include <dlfcn.h>
-#else
-/* Only needed on MINGW at the moment */
-#include "dlfcn.c"
-#endif
-
 #include "dvd_reader.h"
 #include "dvd_input.h"
 
@@ -55,7 +48,12 @@
 #else
 
 /* dlopening libdvdcss */
+#ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
+#else
+/* Only needed on MINGW at the moment */
+#include "../../msvc/contrib/dlfcn.c"
+#endif
 
 typedef struct dvdcss_s *dvdcss_handle;
 static dvdcss_handle (*DVDcss_open)  (const char *);