Hi,
I am currently trying to add a Kdenlive[1] package to the Craft[2]
system for building KDE applications on Windows, and for this I would
need to build MLT using, among others, MSVC.
I already started working on it; the current state of my patch is
attached to this message. But since this turns out to be quite a piece
of work, I'd like to know what you think about this, whether there have
been previous attempts, and which would be your general recommandations
for achieving this.
Thanks!
Best,
Élie
[1]: https://kdenlive.org/
[2]: https://community.kde.org/Craft
diff -Nru mlt-6.4.1-orig/cmake/modules/FindPThreadsWin32.cmake
mlt-6.4.1/cmake/modules/FindPThreadsWin32.cmake
--- mlt-6.4.1-orig/cmake/modules/FindPThreadsWin32.cmake 1970-01-01
01:00:00.000000000 +0100
+++ mlt-6.4.1/cmake/modules/FindPThreadsWin32.cmake 2018-01-16
21:14:40.640185900 +0100
@@ -0,0 +1,15 @@
+# - Find the native PThreadsWin32 includes and library
+#
+# This module defines
+# PTHREADS_WIN32_INCLUDE_DIR, where to find pthread.h, etc.
+# PTHREADS_WIN32_LIBRARIES, the libraries to link against to use
PThreadsWin32.
+# PTHREADS_WIN32_FOUND, If false, do not try to use PThreadsWin32.
+#=============================================================================
+#
+find_path(PTHREADS_WIN32_INCLUDE_DIR pthread.h)
+find_library(PTHREADS_WIN32_LIBRARIES NAMES pthreads)
+# handle the QUIETLY and REQUIRED arguments and set PTHREADS_WIN32_FOUND to
TRUE if
+# all listed variables are TRUE
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(PThreadsWin32 DEFAULT_MSG
PTHREADS_WIN32_LIBRARIES PTHREADS_WIN32_INCLUDE_DIR)
+mark_as_advanced(PTHREADS_WIN32_INCLUDE_DIR PTHREADS_WIN32_LIBRARIES)
diff -Nru mlt-6.4.1-orig/CMakeLists.txt mlt-6.4.1/CMakeLists.txt
--- mlt-6.4.1-orig/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100
+++ mlt-6.4.1/CMakeLists.txt 2018-01-16 21:15:50.696235200 +0100
@@ -0,0 +1,33 @@
+project(mlt)
+cmake_minimum_required(VERSION 3.0)
+
+set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
+
+add_subdirectory(src/framework)
+add_subdirectory(src/mlt++)
+add_subdirectory(src/melt)
+#add_subdirectory(src/modules)
+#add_subdirectory(src/swig)
+#add_subdirectory(profiles)
+
+# Install
+
+#install:
+# install -d "$(DESTDIR)$(prefix)/bin"
+# install -d "$(DESTDIR)$(prefix)/include"
+# install -d "$(DESTDIR)$(libdir)"
+# install -d "$(DESTDIR)$(moduledir)"
+#ifeq ($(extra_versioning), true)
+# ln -s "$(moduledir)" "$(DESTDIR)$(unversionedmoduledir)"
+#endif
+# install -d "$(DESTDIR)$(libdir)/pkgconfig"
+# install -d "$(DESTDIR)$(mltdatadir)"
+#ifeq ($(extra_versioning), true)
+# ln -s "$(mltdatadir)" "$(DESTDIR)$(unversionedmltdatadir)"
+#endif
+# install -c -m 644 *.pc "$(DESTDIR)$(libdir)/pkgconfig"
+# list='$(SUBDIRS)'; \
+# for subdir in $$list; do \
+# $(MAKE) DESTDIR=$(DESTDIR) -C $$subdir $@ || exit 1; \
+# done
+# cp -R presets "$(DESTDIR)$(mltdatadir)"
diff -Nru mlt-6.4.1-orig/src/framework/CMakeLists.txt
mlt-6.4.1/src/framework/CMakeLists.txt
--- mlt-6.4.1-orig/src/framework/CMakeLists.txt 1970-01-01 01:00:00.000000000
+0100
+++ mlt-6.4.1/src/framework/CMakeLists.txt 2018-01-16 22:43:01.392537400
+0100
@@ -0,0 +1,100 @@
+cmake_minimum_required(VERSION 3.0)
+
+find_package(Threads REQUIRED)
+if(CMAKE_USE_PTHREADS_INIT)
+ set(PTHREADS_WIN32_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
+ set(PTHREADS_WIN32_INCLUDE_DIR .)
+else(CMAKE_USE_PTHREADS_INIT)
+ find_package(PThreadsWin32 REQUIRED)
+endif(CMAKE_USE_PTHREADS_INIT)
+
+option(BUILD_STATIC "build a static libmlt" OFF)
+
+include_directories(${PTHREADS_WIN32_INCLUDE_DIR})
+
+set(SRC
+ mlt_frame.c
+ mlt_version.c
+ mlt_geometry.c
+ mlt_deque.c
+ mlt_property.c
+ mlt_properties.c
+ mlt_events.c
+ mlt_parser.c
+ mlt_service.c
+ mlt_producer.c
+ mlt_multitrack.c
+ mlt_playlist.c
+ mlt_consumer.c
+ mlt_filter.c
+ mlt_transition.c
+ mlt_field.c
+ mlt_tractor.c
+ mlt_factory.c
+ mlt_repository.c
+ mlt_pool.c
+ mlt_tokeniser.c
+ mlt_profile.c
+ mlt_log.c
+ mlt_cache.c
+ mlt_animation.c
+ mlt_slices.c
+ )
+
+set(INCS
+ mlt_consumer.h
+ mlt_version.h
+ mlt_factory.h
+ mlt_filter.h
+ mlt.h
+ mlt_multitrack.h
+ mlt_pool.h
+ mlt_properties.h
+ mlt_events.h
+ mlt_parser.h
+ mlt_repository.h
+ mlt_tractor.h
+ mlt_types.h
+ mlt_deque.h
+ mlt_field.h
+ mlt_frame.h
+ mlt_geometry.h
+ mlt_playlist.h
+ mlt_producer.h
+ mlt_property.h
+ mlt_service.h
+ mlt_transition.h
+ mlt_tokeniser.h
+ mlt_profile.h
+ mlt_log.h
+ mlt_cache.h
+ mlt_animation.h
+ mlt_slices.h
+ )
+
+IF(MINGW)
+ #LDFLAGS += -liconv
+ set(SRC ${SRC} ../win32/win32.c)
+ENDIF(MINGW)
+
+if(WIN32)
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../win32)
+ set(aspell_SRCS
+ ../win32/dirent.c
+ ../win32/gettimeofday.c
+ ${SRC}
+ )
+endif(WIN32)
+
+if(BUILD_STATIC)
+ set(_SHARED STATIC)
+ add_definitions(-DREDLAND_STATIC)
+else(BUILD_STATIC)
+ set(_SHARED SHARED)
+endif(BUILD_STATIC)
+
+add_library(libmlt ${_SHARED} ${SRC})
+
+target_link_libraries(libmlt ${PTHREADS_WIN32_LIBRARIES})
+
+#LDFLAGS += $(LIBDL) -lpthread -lm
diff -Nru mlt-6.4.1-orig/src/framework/mlt_cache.c
mlt-6.4.1/src/framework/mlt_cache.c
--- mlt-6.4.1-orig/src/framework/mlt_cache.c 2018-01-13 18:00:27.117720100
+0100
+++ mlt-6.4.1/src/framework/mlt_cache.c 2018-01-16 21:27:09.017051600 +0100
@@ -27,6 +27,7 @@
#include "mlt_frame.h"
#include <stdlib.h>
+#define HAVE_STRUCT_TIMESPEC // prevents error with timespec
#include <pthread.h>
/** the maximum number of data objects to cache per line */
diff -Nru mlt-6.4.1-orig/src/framework/mlt_consumer.c
mlt-6.4.1/src/framework/mlt_consumer.c
--- mlt-6.4.1-orig/src/framework/mlt_consumer.c 2018-01-13 18:00:27.128248500
+0100
+++ mlt-6.4.1/src/framework/mlt_consumer.c 2018-01-16 22:39:34.765741300
+0100
@@ -30,7 +30,11 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#ifdef _WIN32
+#include "../win32/gettimeofday.h"
+#else
#include <sys/time.h>
+#endif /* ifdef _WIN32 */
/** Define this if you want an automatic deinterlace (if necessary) when the
* consumer's producer is not running at normal speed.
diff -Nru mlt-6.4.1-orig/src/framework/mlt_consumer.h
mlt-6.4.1/src/framework/mlt_consumer.h
--- mlt-6.4.1-orig/src/framework/mlt_consumer.h 2018-01-13 18:00:27.134265200
+0100
+++ mlt-6.4.1/src/framework/mlt_consumer.h 2018-01-16 21:27:14.169524500
+0100
@@ -25,6 +25,7 @@
#include "mlt_service.h"
#include "mlt_events.h"
+#define HAVE_STRUCT_TIMESPEC // prevents error with timespec
#include <pthread.h>
/** \brief Consumer abstract service class
diff -Nru mlt-6.4.1-orig/src/framework/mlt_events.c
mlt-6.4.1/src/framework/mlt_events.c
--- mlt-6.4.1-orig/src/framework/mlt_events.c 2018-01-13 18:00:27.149833700
+0100
+++ mlt-6.4.1/src/framework/mlt_events.c 2018-01-16 21:27:18.529100400
+0100
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
+#define HAVE_STRUCT_TIMESPEC // prevents error with timespec
#include <pthread.h>
#include "mlt_properties.h"
diff -Nru mlt-6.4.1-orig/src/framework/mlt_log.h
mlt-6.4.1/src/framework/mlt_log.h
--- mlt-6.4.1-orig/src/framework/mlt_log.h 2018-01-13 18:00:27.219493400
+0100
+++ mlt-6.4.1/src/framework/mlt_log.h 2018-01-16 21:32:32.665352100 +0100
@@ -77,13 +77,13 @@
void mlt_log( void *service, int level, const char *fmt, ... );
#endif
-#define mlt_log_panic(service, format, args...) mlt_log((service),
MLT_LOG_PANIC, (format), ## args)
-#define mlt_log_fatal(service, format, args...) mlt_log((service),
MLT_LOG_FATAL, (format), ## args)
-#define mlt_log_error(service, format, args...) mlt_log((service),
MLT_LOG_ERROR, (format), ## args)
-#define mlt_log_warning(service, format, args...) mlt_log((service),
MLT_LOG_WARNING, (format), ## args)
-#define mlt_log_info(service, format, args...) mlt_log((service),
MLT_LOG_INFO, (format), ## args)
-#define mlt_log_verbose(service, format, args...) mlt_log((service),
MLT_LOG_VERBOSE, (format), ## args)
-#define mlt_log_debug(service, format, args...) mlt_log((service),
MLT_LOG_DEBUG, (format), ## args)
+#define mlt_log_panic(service, format, ...) mlt_log((service), MLT_LOG_PANIC,
(format), ## __VA_ARGS__)
+#define mlt_log_fatal(service, format, ...) mlt_log((service), MLT_LOG_FATAL,
(format), ## __VA_ARGS__)
+#define mlt_log_error(service, format, ...) mlt_log((service), MLT_LOG_ERROR,
(format), ## __VA_ARGS__)
+#define mlt_log_warning(service, format, ...) mlt_log((service),
MLT_LOG_WARNING, (format), ## __VA_ARGS__)
+#define mlt_log_info(service, format, ...) mlt_log((service), MLT_LOG_INFO,
(format), ## __VA_ARGS__)
+#define mlt_log_verbose(service, format, ...) mlt_log((service),
MLT_LOG_VERBOSE, (format), ## __VA_ARGS__)
+#define mlt_log_debug(service, format, ...) mlt_log((service), MLT_LOG_DEBUG,
(format), ## __VA_ARGS__)
void mlt_vlog( void *service, int level, const char *fmt, va_list );
int mlt_log_get_level( void );
diff -Nru mlt-6.4.1-orig/src/framework/mlt_pool.c
mlt-6.4.1/src/framework/mlt_pool.c
--- mlt-6.4.1-orig/src/framework/mlt_pool.c 2018-01-13 18:00:27.256112300
+0100
+++ mlt-6.4.1/src/framework/mlt_pool.c 2018-01-16 23:11:39.871916400 +0100
@@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
+#define HAVE_STRUCT_TIMESPEC // prevents error with timespec
#include <pthread.h>
// Not nice - memalign is defined here apparently?
@@ -68,7 +69,11 @@
* optimized libraries (sse/altivec).
*/
+#if defined(_MSC_VER)
+typedef __declspec(align(16)) struct mlt_release_s
+#else
typedef struct __attribute__ ((aligned (16))) mlt_release_s
+#endif
{
mlt_pool pool;
int references;
diff -Nru mlt-6.4.1-orig/src/framework/mlt_properties.c
mlt-6.4.1/src/framework/mlt_properties.c
--- mlt-6.4.1-orig/src/framework/mlt_properties.c 2018-01-13
18:00:27.287967900 +0100
+++ mlt-6.4.1/src/framework/mlt_properties.c 2018-01-16 22:30:26.634701700
+0100
@@ -36,9 +36,10 @@
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
+#define HAVE_STRUCT_TIMESPEC // prevents error with timespec
#include <pthread.h>
#include <sys/types.h>
-#include <dirent.h>
+#include "../win32/dirent.h"
#include <sys/stat.h>
#include <errno.h>
#include <locale.h>
diff -Nru mlt-6.4.1-orig/src/framework/mlt_property.c
mlt-6.4.1/src/framework/mlt_property.c
--- mlt-6.4.1-orig/src/framework/mlt_property.c 2018-01-13 18:00:27.297992500
+0100
+++ mlt-6.4.1/src/framework/mlt_property.c 2018-01-16 21:27:35.266242700
+0100
@@ -32,6 +32,7 @@
#include <stdlib.h>
#include <string.h>
#include <locale.h>
+#define HAVE_STRUCT_TIMESPEC // prevents error with timespec
#include <pthread.h>
#include <float.h>
#include <math.h>
diff -Nru mlt-6.4.1-orig/src/framework/mlt_repository.c
mlt-6.4.1/src/framework/mlt_repository.c
--- mlt-6.4.1-orig/src/framework/mlt_repository.c 2018-01-13
18:00:27.308993700 +0100
+++ mlt-6.4.1/src/framework/mlt_repository.c 2018-01-16 22:52:30.576260300
+0100
@@ -28,7 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <dlfcn.h>
+#include "../win32/dlfcn.h"
#include <string.h>
#include <limits.h>
#include <dirent.h>
diff -Nru mlt-6.4.1-orig/src/framework/mlt_service.c
mlt-6.4.1/src/framework/mlt_service.c
--- mlt-6.4.1-orig/src/framework/mlt_service.c 2018-01-13 18:00:27.320053200
+0100
+++ mlt-6.4.1/src/framework/mlt_service.c 2018-01-16 21:27:40.898134900
+0100
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#define HAVE_STRUCT_TIMESPEC // prevents error with timespec
#include <pthread.h>
diff -Nru mlt-6.4.1-orig/src/framework/mlt_slices.c
mlt-6.4.1/src/framework/mlt_slices.c
--- mlt-6.4.1-orig/src/framework/mlt_slices.c 2018-01-13 18:00:27.330049200
+0100
+++ mlt-6.4.1/src/framework/mlt_slices.c 2018-01-16 21:27:46.449055300
+0100
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <unistd.h>
+#define HAVE_STRUCT_TIMESPEC // prevents error with timespec
#include <pthread.h>
#ifdef _WIN32
#include <windows.h>
diff -Nru mlt-6.4.1-orig/src/framework/mlt_types.h
mlt-6.4.1/src/framework/mlt_types.h
--- mlt-6.4.1-orig/src/framework/mlt_types.h 2018-01-13 18:00:27.370155500
+0100
+++ mlt-6.4.1/src/framework/mlt_types.h 2018-01-16 21:28:10.457220000 +0100
@@ -191,6 +191,7 @@
#endif
#ifdef _WIN32
+#define HAVE_STRUCT_TIMESPEC // prevents error with timespec
#include <pthread.h>
/* Win32 compatibility function declarations */
extern int usleep(unsigned int useconds);
diff -Nru mlt-6.4.1-orig/src/melt/CMakeLists.txt
mlt-6.4.1/src/melt/CMakeLists.txt
--- mlt-6.4.1-orig/src/melt/CMakeLists.txt 1970-01-01 01:00:00.000000000
+0100
+++ mlt-6.4.1/src/melt/CMakeLists.txt 2018-01-16 09:07:37.639790300 +0100
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.0)
+
+set(SRC
+ melt.c
+ io.c
+)
+
+add_executable(melt
+ ${SRC}
+)
+
+target_link_libraries(melt libmlt)
+
+IF(MINGW)
+#CFLAGS += $(shell pkg-config --cflags sdl)
+#LDFLAGS += $(shell pkg-config --libs sdl)
+ENDIF(MINGW)
+
diff -Nru mlt-6.4.1-orig/src/mlt++/CMakeLists.txt
mlt-6.4.1/src/mlt++/CMakeLists.txt
--- mlt-6.4.1-orig/src/mlt++/CMakeLists.txt 1970-01-01 01:00:00.000000000
+0100
+++ mlt-6.4.1/src/mlt++/CMakeLists.txt 2018-01-16 08:58:41.710621000 +0100
@@ -0,0 +1,33 @@
+cmake_minimum_required(VERSION 3.0)
+
+set(SRC
+ MltAnimation.cpp
+ MltConsumer.cpp
+ MltDeque.cpp
+ MltEvent.cpp
+ MltFactory.cpp
+ MltField.cpp
+ MltFilter.cpp
+ MltFilteredConsumer.cpp
+ MltFilteredProducer.cpp
+ MltFrame.cpp
+ MltGeometry.cpp
+ MltMultitrack.cpp
+ MltParser.cpp
+ MltPlaylist.cpp
+ MltProducer.cpp
+ MltProfile.cpp
+ MltProperties.cpp
+ MltPushConsumer.cpp
+ MltRepository.cpp
+ MltService.cpp
+ MltTokeniser.cpp
+ MltTractor.cpp
+ MltTransition.cpp
+ )
+
+add_library(libmlt++
+ ${SRC}
+)
+
+
diff -Nru mlt-6.4.1-orig/src/win32/dirent.c mlt-6.4.1/src/win32/dirent.c
--- mlt-6.4.1-orig/src/win32/dirent.c 1970-01-01 01:00:00.000000000 +0100
+++ mlt-6.4.1/src/win32/dirent.c 2018-01-16 21:51:44.251103900 +0100
@@ -0,0 +1,220 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apa...@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * Portions of this software are based upon public domain software
+ * originally written at the National Center for Supercomputing Applications,
+ * University of Illinois, Urbana-Champaign.
+ */
+#include <windows.h>
+#include <malloc.h>
+#include <string.h>
+#include "dirent.h"
+/**********************************************************************
+ * Implement dirent-style opendir/readdir/closedir on Window 95/NT
+ *
+ * Functions defined are opendir(), readdir() and closedir() with the
+ * same prototypes as the normal dirent.h implementation.
+ *
+ * Does not implement telldir(), seekdir(), rewinddir() or scandir().
+ * The dirent struct is compatible with Unix, except that d_ino is
+ * always 1 and d_off is made up as we go along.
+ *
+ * The DIR typedef is not compatible with Unix.
+ **********************************************************************/
+#ifdef _WIN32_WCE
+// Wrap ASCII functions to UNICODE
+static BOOL
+convert_find_data (LPWIN32_FIND_DATAW fdw, LPWIN32_FIND_DATAA fda)
+{
+ char *filename;
+ int len;
+ fda->dwFileAttributes = fdw->dwFileAttributes;
+ fda->ftCreationTime = fdw->ftCreationTime;
+ fda->ftLastAccessTime = fdw->ftLastAccessTime;
+ fda->ftLastWriteTime = fdw->ftLastWriteTime;
+ fda->nFileSizeHigh = fdw->nFileSizeHigh;
+ fda->nFileSizeLow = fdw->nFileSizeLow;
+ filename = strWtoA (fdw->cFileName);
+ if (!filename)
+ return FALSE;
+ len = sizeof (fda->cFileName);
+ strncpy (fda->cFileName, filename, len);
+ fda->cFileName[len - 1] = '\0';
+ return TRUE;
+}
+static LPWSTR strAtoW( LPCSTR str )
+{
+ LPWSTR ret = NULL;
+ if (str)
+ {
+ DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
+ if ((ret = ( WCHAR* )malloc( len * sizeof(WCHAR) )))
+ MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
+ }
+ return ret;
+}
+static LPSTR strWtoA( LPCWSTR str )
+{
+ LPSTR ret = NULL;
+ if (str)
+ {
+ DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL,
NULL );
+ if ((ret = ( char* )malloc( len )))
+ WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
+ }
+ return ret;
+}
+HANDLE
+FindFirstFileA (LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData)
+{
+ wchar_t *pathname;
+ WIN32_FIND_DATAW find_file_data;
+ HANDLE result;
+ int err;
+ pathname = strAtoW (lpFileName);
+ if (!pathname)
+ return INVALID_HANDLE_VALUE;
+ result = FindFirstFileW (pathname, &find_file_data);
+ if (result != INVALID_HANDLE_VALUE)
+ {
+ BOOL res = convert_find_data (&find_file_data, lpFindFileData);
+ if (! res)
+ {
+ err = GetLastError ();
+ FindClose (result);
+ SetLastError (err);
+ result = INVALID_HANDLE_VALUE;
+ }
+ }
+ err = GetLastError ();
+ free (pathname);
+ SetLastError (err);
+ return result;
+}
+BOOL
+FindNextFileA (HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData)
+{
+ WIN32_FIND_DATAW find_file_data;
+ BOOL result;
+ int err;
+ result = FindNextFileW (hFindFile, &find_file_data);
+ if (result)
+ result = convert_find_data (&find_file_data, lpFindFileData);
+ return result;
+}
+#endif
+DIR * aspell_opendir(const char *dir)
+{
+ DIR *dp;
+ char *filespec;
+ HANDLE handle;
+ int index;
+ filespec = (char * )malloc(strlen(dir) + 2 + 1);
+ strcpy(filespec, dir);
+ index = strlen(filespec) - 1;
+ if (index >= 0 && (filespec[index] == '/' || filespec[index] == '\\'))
+ filespec[index] = '\0';
+ strcat(filespec, "\\*");
+ dp = (DIR *)malloc(sizeof(DIR));
+ dp->offset = 0;
+ dp->finished = 0;
+ dp->dir = strdup(dir);
+ handle = FindFirstFileA(filespec, &(dp->fileinfo));
+ if (handle == INVALID_HANDLE_VALUE)
+ {
+ if (GetLastError() == ERROR_NO_MORE_FILES)
+ dp->finished = 1;
+ else
+ return NULL;
+ }
+ dp->handle = handle;
+ free(filespec);
+ return dp;
+}
+struct dirent * aspell_readdir(DIR *dp)
+{
+ int saved_err = GetLastError();
+ if (!dp || dp->finished)
+ return NULL;
+ if (dp->offset != 0)
+ {
+ if (FindNextFileA(dp->handle, &(dp->fileinfo)) == 0)
+ {
+ if (GetLastError() == ERROR_NO_MORE_FILES)
+ {
+ SetLastError(saved_err);
+ dp->finished = 1;
+ }
+ return NULL;
+ }
+ }
+ dp->offset++;
+
+ strncpy(dp->dent.d_name, dp->fileinfo.cFileName, _MAX_FNAME);
+ dp->dent.d_ino = 1;
+ dp->dent.d_reclen = strlen(dp->dent.d_name);
+ dp->dent.d_off = dp->offset;
+
+ return &(dp->dent);
+}
+int aspell_closedir(DIR *dp)
+{
+ if (!dp)
+ return 0;
+ FindClose(dp->handle);
+ if (dp->dir)
+ free(dp->dir);
+ if (dp)
+ free(dp);
+ return 0;
+}
diff -Nru mlt-6.4.1-orig/src/win32/dirent.h mlt-6.4.1/src/win32/dirent.h
--- mlt-6.4.1-orig/src/win32/dirent.h 1970-01-01 01:00:00.000000000 +0100
+++ mlt-6.4.1/src/win32/dirent.h 2018-01-16 21:53:54.901096600 +0100
@@ -0,0 +1,115 @@
+/* This file is part of the KDE project
+ Copyright (C) 2000 Werner Almesberger
+ libc/sys/linux/sys/dirent.h - Directory entry as returned by readdir
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+ You should have received a copy of the GNU Library General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+#ifndef ASPELL_DIRENT_H
+#define ASPELL_DIRENT_H
+// include everywhere
+#include <sys/types.h>
+#include <io.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+#ifdef _WIN32_WCE
+#include <altcecrt.h>
+#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define HAVE_NO_D_NAMLEN /* no struct dirent->d_namlen */
+#define HAVE_DD_LOCK /* have locking mechanism */
+#define MAXNAMLEN 255 /* sizeof(struct dirent.d_name)-1 */
+#define __dirfd(dir) (dir)->dd_fd
+// this one should come from unistd.h originally, but it is easier to put it
here:
+#define F_OK 0
+#define ASPELL_HAVE_DIRENT_D_TYPE
+#ifdef _WIN32_WCE
+/* Avoid nameclashes for wince */
+# define FindFirstFileA _aspell_wince_FindFirstFileA
+ HANDLE FindFirstFileA(LPCSTR,LPWIN32_FIND_DATAA);
+# define FindNextFileA _aspell_wince_FindNextFileA
+ BOOL FindNextFileA(HANDLE,LPWIN32_FIND_DATAA);
+# define convert_find_data _aspell_wince_convert_find_data
+static BOOL
+convert_find_data (LPWIN32_FIND_DATAW fdw, LPWIN32_FIND_DATAA fda);
+#define strAtoW _aspell_wince_strAtoW
+static LPWSTR strAtoW( LPCSTR str );
+#define strWtoA _aspell_wince_strWtoA
+static LPSTR strWtoA( LPCWSTR str );
+#endif // _WIN32_WCE
+#ifdef ASPELL_STATIC
+# define aspell_closedir _aspell_wince_closedir
+# define aspell_readdir _aspell_wince_readdir
+# define DIR _aspell_wince_DIR
+# define dirent _aspell_wince_dirent
+# define aspell_scandir _aspell_wince_scandir
+# define aspell_opendir _aspell_wince_opendir
+#endif //ASPELL_STATIC
+enum
+ {
+ DT_UNKNOWN = 0,
+ DT_FIFO = 1,
+ DT_CHR = 2,
+ DT_DIR = 4,
+ DT_BLK = 6,
+ DT_REG = 8,
+ DT_LNK = 10,
+ DT_SOCK = 12,
+ DT_WHT = 14
+ };
+/* struct dirent - same as Unix */
+struct dirent {
+ long d_ino; /* inode (always 1 in WIN32) */
+ off_t d_off; /* offset to this dirent */
+ unsigned short d_reclen; /* length of d_name */
+ unsigned char d_type;
+ char d_name[_MAX_FNAME+1]; /* filename (null terminated) */
+};
+/* typedef DIR - not the same as Unix */
+typedef struct
+ {
+ HANDLE handle; /* FindFirst/FindNext handle */
+ short offset; /* offset into directory */
+ short finished; /* 1 if there are not more files */
+ WIN32_FIND_DATAA fileinfo; /* from FindFirst/FindNext */
+ char *dir; /* the dir we are reading */
+ struct dirent dent; /* the dirent to return */
+ }
+DIR;
+/* --- redundant --- */
+//DIR *opendir(const char *);
+//struct dirent *readdir(DIR *);
+//void rewinddir(DIR *);
+//int closedir(DIR *);
+/* internal prototype */
+void _seekdir(DIR *dir,off_t offset);
+//#ifndef _POSIX_SOURCE
+//long telldir (DIR *);
+//void seekdir (DIR *, off_t loc);
+int aspell_scandir (const char *__dir,
+ struct dirent ***__namelist,
+ int (*select) (const struct dirent *),
+ int (*compar) (const struct dirent **, const struct dirent **));
+DIR * aspell_opendir(const char *);
+int aspell_closedir(DIR *);
+struct dirent* aspell_readdir(DIR *);
+// Implement readdir_r(). For now do not provide dummy function to avoid
setting HAVE_READDIR_R.
+// Code like DirectoryListThread::run() in kio/kio/kurlcompletion.cpp uses
readdir() when !HAVE_READDIR_R.
+// struct dirent* readdir_r(DIR *dirp, struct dirent *entry, struct dirent
**result);
+int alphasort (const struct dirent **__a, const struct dirent **__b);
+#ifdef __cplusplus
+}
+#endif
+#endif // ASPELL_DIRENT_H
diff -Nru mlt-6.4.1-orig/src/win32/dlfcn.h mlt-6.4.1/src/win32/dlfcn.h
--- mlt-6.4.1-orig/src/win32/dlfcn.h 1970-01-01 01:00:00.000000000 +0100
+++ mlt-6.4.1/src/win32/dlfcn.h 2018-01-16 22:52:07.896430300 +0100
@@ -0,0 +1,59 @@
+/*
+ * dlfcn-win32
+ * Copyright (c) 2007 Ramiro Polla
+ *
+ * dlfcn-win32 is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * dlfcn-win32 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with dlfcn-win32; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+ */
+
+#ifndef DLFCN_H
+#define DLFCN_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(DLFCN_WIN32_EXPORTS)
+# define DLFCN_EXPORT __declspec(dllexport)
+#else
+# define DLFCN_EXPORT
+#endif
+
+/* POSIX says these are implementation-defined.
+ * To simplify use with Windows API, we treat them the same way.
+ */
+
+#define RTLD_LAZY 0
+#define RTLD_NOW 0
+
+#define RTLD_GLOBAL (1 << 1)
+#define RTLD_LOCAL (1 << 2)
+
+/* These two were added in The Open Group Base Specifications Issue 6.
+ * Note: All other RTLD_* flags in any dlfcn.h are not standard compliant.
+ */
+
+#define RTLD_DEFAULT 0
+#define RTLD_NEXT 0
+
+DLFCN_EXPORT void *dlopen ( const char *file, int mode );
+DLFCN_EXPORT int dlclose(void *handle);
+DLFCN_EXPORT void *dlsym(void *handle, const char *name);
+DLFCN_EXPORT char *dlerror(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* DLFCN_H */
diff -Nru mlt-6.4.1-orig/src/win32/gettimeofday.c
mlt-6.4.1/src/win32/gettimeofday.c
--- mlt-6.4.1-orig/src/win32/gettimeofday.c 1970-01-01 01:00:00.000000000
+0100
+++ mlt-6.4.1/src/win32/gettimeofday.c 2018-01-16 22:48:31.983251500 +0100
@@ -0,0 +1,47 @@
+/**
+ * \file mlt_consumer.c
+ * \brief abstraction for all consumer services
+ * \see mlt_consumer_s
+ *
+ * Copyright (C) 2003-2015 Meltytech, LLC
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+ */
+
+#include <windows.h>
+#include "gettimeofday.h"
+
+int gettimeofday(struct timeval* p, void* tz) {
+ ULARGE_INTEGER ul; // As specified on MSDN.
+ FILETIME ft;
+
+ // Returns a 64-bit value representing the number of
+ // 100-nanosecond intervals since January 1, 1601 (UTC).
+ GetSystemTimeAsFileTime(&ft);
+
+ // Fill ULARGE_INTEGER low and high parts.
+ ul.LowPart = ft.dwLowDateTime;
+ ul.HighPart = ft.dwHighDateTime;
+ // Convert to microseconds.
+ ul.QuadPart /= 10ULL;
+ // Remove Windows to UNIX Epoch delta.
+ ul.QuadPart -= 11644473600000000ULL;
+ // Modulo to retrieve the microseconds.
+ p->tv_usec = (long) (ul.QuadPart % 1000000LL);
+ // Divide to retrieve the seconds.
+ p->tv_sec = (long) (ul.QuadPart / 1000000LL);
+
+ return 0;
+}
diff -Nru mlt-6.4.1-orig/src/win32/gettimeofday.h
mlt-6.4.1/src/win32/gettimeofday.h
--- mlt-6.4.1-orig/src/win32/gettimeofday.h 1970-01-01 01:00:00.000000000
+0100
+++ mlt-6.4.1/src/win32/gettimeofday.h 2018-01-16 22:50:53.176798000 +0100
@@ -0,0 +1,36 @@
+/**
+ * \file mlt_consumer.c
+ * \brief abstraction for all consumer services
+ * \see mlt_consumer_s
+ *
+ * Copyright (C) 2003-2015 Meltytech, LLC
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+ */
+
+#ifndef _GETTIMEOFDAY_
+#define _GETTIMEOFDAY_
+
+#include <time.h>
+
+// I though this was provided by time.h, even on Windows
+typedef struct timeval {
+ long tv_sec;
+ long tv_usec;
+} timeval;
+
+int gettimeofday(struct timeval* p, void* tz);
+
+#endif // _GETTIMEOFDAY_
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel