aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorh.udo <hudokkow@gmail.com>2018-02-20 22:28:46 +0000
committerh.udo <hudokkow@gmail.com>2018-02-20 22:28:46 +0000
commit34ce080ebea899dc64783acc2b2a103645194cf2 (patch)
tree55805f841fcd89f18c6dc372061ff85309021a61 /lib
parent9447e594586a6645a186614742303f98e4851227 (diff)
[c-pluff] Add patches folder for reference and keep track of changes
Diffstat (limited to 'lib')
-rw-r--r--lib/cpluff/patches/0001-all-Change-plugin-to-addon-tags.patch61
-rw-r--r--lib/cpluff/patches/0002-osx-Fix-include.patch25
-rw-r--r--lib/cpluff/patches/0003-win32-Fix-compile.-Missing-cpluff.dll-will-crash-Kod.patch644
-rw-r--r--lib/cpluff/patches/0004-all-Fix-log-level-inconsistencies.patch46
-rw-r--r--lib/cpluff/patches/0005-all-Fix-unsigned-signed-warnings.patch84
-rw-r--r--lib/cpluff/patches/0006-all-Fix-scoping-error.patch33
-rw-r--r--lib/cpluff/patches/0007-all-Comment-log-line-to-reduce-log-spew.patch25
-rw-r--r--lib/cpluff/patches/0008-configure-Handle-libdl-only-being-needed-on-Linux-fo.patch27
-rw-r--r--lib/cpluff/patches/0009-configure-Add-silent-rules-to-shut-it-up-a-little.patch24
-rw-r--r--lib/cpluff/patches/0010-configure-Fix-build-with-xcode5.patch34
-rw-r--r--lib/cpluff/patches/0011-docs-We-don-t-need-them.patch25
-rw-r--r--lib/cpluff/patches/0012-Kill-implicit-function-declaration-warning.patch28
12 files changed, 1056 insertions, 0 deletions
diff --git a/lib/cpluff/patches/0001-all-Change-plugin-to-addon-tags.patch b/lib/cpluff/patches/0001-all-Change-plugin-to-addon-tags.patch
new file mode 100644
index 0000000000..b45630e66f
--- /dev/null
+++ b/lib/cpluff/patches/0001-all-Change-plugin-to-addon-tags.patch
@@ -0,0 +1,61 @@
+From ae1cfb84339c8247ac1705fa7f5e8556c6157314 Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Thu, 20 Oct 2016 13:59:00 +0100
+Subject: [PATCH 01/12] [all] Change plugin to addon tags
+
+---
+ libcpluff/ploader.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/libcpluff/ploader.c b/libcpluff/ploader.c
+index cea541f..c4e251b 100644
+--- a/libcpluff/ploader.c
++++ b/libcpluff/ploader.c
+@@ -61,7 +61,7 @@
+ #define CP_CFG_ELEMENT_VALUE_INITSIZE 64
+
+ /// Plugin descriptor name
+-#define CP_PLUGIN_DESCRIPTOR "plugin.xml"
++#define CP_PLUGIN_DESCRIPTOR "addon.xml"
+
+
+ /* ------------------------------------------------------------------------
+@@ -524,7 +524,7 @@ static void CP_XMLCALL start_element_handler(
+ static const XML_Char * const opt_bwcompatibility_atts[] = { "abi", "api", NULL };
+ static const XML_Char * const req_cpluff_atts[] = { "version", NULL };
+ static const XML_Char * const opt_cpluff_atts[] = { NULL };
+- static const XML_Char * const req_import_atts[] = { "plugin", NULL };
++ static const XML_Char * const req_import_atts[] = { "addon", NULL };
+ static const XML_Char * const opt_import_atts[] = { "version", "optional", NULL };
+ static const XML_Char * const req_runtime_atts[] = { "library", NULL };
+ static const XML_Char * const opt_runtime_atts[] = { "funcs", NULL };
+@@ -539,7 +539,7 @@ static void CP_XMLCALL start_element_handler(
+ switch (plcontext->state) {
+
+ case PARSER_BEGIN:
+- if (!strcmp(name, "plugin")) {
++ if (!strcmp(name, "addon")) {
+ plcontext->state = PARSER_PLUGIN;
+ if (!check_attributes(plcontext, name, atts,
+ req_plugin_atts, opt_plugin_atts)) {
+@@ -749,7 +749,7 @@ static void CP_XMLCALL start_element_handler(
+ import->plugin_id = NULL;
+ import->version = NULL;
+ for (i = 0; atts[i] != NULL; i += 2) {
+- if (!strcmp(atts[i], "plugin")) {
++ if (!strcmp(atts[i], "addon")) {
+ import->plugin_id
+ = parser_strdup(plcontext, atts[i+1]);
+ } else if (!strcmp(atts[i], "version")) {
+@@ -832,7 +832,7 @@ static void CP_XMLCALL end_element_handler(
+ switch (plcontext->state) {
+
+ case PARSER_PLUGIN:
+- if (!strcmp(name, "plugin")) {
++ if (!strcmp(name, "addon")) {
+
+ // Readjust memory allocated for extension points, if necessary
+ if (plcontext->ext_points_size != plcontext->plugin->num_ext_points) {
+--
+2.14.1
+
diff --git a/lib/cpluff/patches/0002-osx-Fix-include.patch b/lib/cpluff/patches/0002-osx-Fix-include.patch
new file mode 100644
index 0000000000..291aa8b08b
--- /dev/null
+++ b/lib/cpluff/patches/0002-osx-Fix-include.patch
@@ -0,0 +1,25 @@
+From 838c4364ee95eae2ef565406b89a8e62bbe969f1 Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Thu, 20 Oct 2016 14:03:00 +0100
+Subject: [PATCH 02/12] [osx] Fix include
+
+---
+ libcpluff/cpluff.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libcpluff/cpluff.h b/libcpluff/cpluff.h
+index 6b238bc..a798ee4 100644
+--- a/libcpluff/cpluff.h
++++ b/libcpluff/cpluff.h
+@@ -38,7 +38,7 @@
+ * Preprocessor defines.
+ */
+
+-#include <cpluffdef.h>
++#include "cpluffdef.h"
+
+ #ifdef __cplusplus
+ extern "C" {
+--
+2.14.1
+
diff --git a/lib/cpluff/patches/0003-win32-Fix-compile.-Missing-cpluff.dll-will-crash-Kod.patch b/lib/cpluff/patches/0003-win32-Fix-compile.-Missing-cpluff.dll-will-crash-Kod.patch
new file mode 100644
index 0000000000..88fc300f72
--- /dev/null
+++ b/lib/cpluff/patches/0003-win32-Fix-compile.-Missing-cpluff.dll-will-crash-Kod.patch
@@ -0,0 +1,644 @@
+From e3c3cf0fa229c3568f6c06cd4b507b60cc1629be Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Thu, 20 Oct 2016 14:14:50 +0100
+Subject: [PATCH 03/12] [win32] Fix compile. Missing cpluff.dll will crash Kodi
+
+---
+ kazlib/hash.h | 4 +
+ kazlib/list.h | 4 +
+ libcpluff/cpluff.h | 6 +-
+ libcpluff/internal.h | 8 +-
+ libcpluff/pcontrol.c | 3 +
+ libcpluff/psymbol.c | 3 +
+ libcpluff/win32/cpluffdef.h | 212 ++++++++++++++++++++++++++++++++++++++++
+ libcpluff/win32/dirent.c | 233 ++++++++++++++++++++++++++++++++++++++++++++
+ libcpluff/win32/dirent.h | 61 ++++++++++++
+ 9 files changed, 532 insertions(+), 2 deletions(-)
+ create mode 100644 libcpluff/win32/cpluffdef.h
+ create mode 100644 libcpluff/win32/dirent.c
+ create mode 100644 libcpluff/win32/dirent.h
+
+diff --git a/kazlib/hash.h b/kazlib/hash.h
+index 1fbd246..50297ee 100644
+--- a/kazlib/hash.h
++++ b/kazlib/hash.h
+@@ -27,7 +27,11 @@
+ #ifndef HASH_H
+ #define HASH_H
+
++#ifdef _WIN32
++#include "../libcpluff/win32/cpluffdef.h"
++#else
+ #include "../libcpluff/cpluffdef.h"
++#endif
+
+ #include <limits.h>
+ #ifdef KAZLIB_SIDEEFFECT_DEBUG
+diff --git a/kazlib/list.h b/kazlib/list.h
+index c449acb..ccad262 100644
+--- a/kazlib/list.h
++++ b/kazlib/list.h
+@@ -27,7 +27,11 @@
+ #ifndef LIST_H
+ #define LIST_H
+
++#ifdef _WIN32
++#include "../libcpluff/win32/cpluffdef.h"
++#else
+ #include "../libcpluff/cpluffdef.h"
++#endif
+
+ #include <limits.h>
+
+diff --git a/libcpluff/cpluff.h b/libcpluff/cpluff.h
+index a798ee4..d497af3 100644
+--- a/libcpluff/cpluff.h
++++ b/libcpluff/cpluff.h
+@@ -37,8 +37,12 @@
+ * @defgroup cDefines Defines
+ * Preprocessor defines.
+ */
+-
++
++#ifdef _WIN32
++#include "win32/cpluffdef.h"
++#else
+ #include "cpluffdef.h"
++#endif
+
+ #ifdef __cplusplus
+ extern "C" {
+diff --git a/libcpluff/internal.h b/libcpluff/internal.h
+index 91989e8..161ba6d 100644
+--- a/libcpluff/internal.h
++++ b/libcpluff/internal.h
+@@ -83,7 +83,13 @@ extern "C" {
+ * Macros
+ * ----------------------------------------------------------------------*/
+
+-#if defined(DLOPEN_POSIX)
++#if defined(_WIN32)
++#define DLHANDLE void *
++#define DLOPEN(name) LoadLibraryA(name)
++#define DLSYM(handle, symbol) GetProcAddress(handle, symbol)
++#define DLCLOSE(handle) CloseHandle(handle)
++#define DLERROR() "WIN32 - TODO"
++#elif defined(DLOPEN_POSIX)
+ #define DLHANDLE void *
+ #define DLOPEN(name) dlopen((name), RTLD_LAZY | RTLD_GLOBAL)
+ #define DLSYM(handle, symbol) dlsym((handle), (symbol))
+diff --git a/libcpluff/pcontrol.c b/libcpluff/pcontrol.c
+index 78a425e..130a3a2 100644
+--- a/libcpluff/pcontrol.c
++++ b/libcpluff/pcontrol.c
+@@ -40,6 +40,9 @@
+ #include "defines.h"
+ #include "util.h"
+ #include "internal.h"
++#ifdef _WIN32
++#include <windows.h>
++#endif
+
+
+ /* ------------------------------------------------------------------------
+diff --git a/libcpluff/psymbol.c b/libcpluff/psymbol.c
+index 93c9f12..988d903 100644
+--- a/libcpluff/psymbol.c
++++ b/libcpluff/psymbol.c
+@@ -37,6 +37,9 @@
+ #include "defines.h"
+ #include "internal.h"
+ #include "util.h"
++#ifdef _WIN32
++#include <windows.h>
++#endif
+
+
+ /* ------------------------------------------------------------------------
+diff --git a/libcpluff/win32/cpluffdef.h b/libcpluff/win32/cpluffdef.h
+new file mode 100644
+index 0000000..891e95a
+--- /dev/null
++++ b/libcpluff/win32/cpluffdef.h
+@@ -0,0 +1,212 @@
++/*-------------------------------------------------------------------------
++ * C-Pluff, a plug-in framework for C
++ * Copyright 2007 Johannes Lehtinen
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice shall be included
++ * in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
++ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
++ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
++ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
++ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
++ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
++ *-----------------------------------------------------------------------*/
++
++/** @file
++ * Common defines shared by C-Pluff C and C++ APIs.
++ * This file is automatically included by the top level C and C++
++ * API header files. There should be no need to include it explicitly.
++ */
++
++#ifndef CPLUFFDEF_H_
++#define CPLUFFDEF_H_
++
++
++/* ------------------------------------------------------------------------
++ * Version information
++ * ----------------------------------------------------------------------*/
++
++/**
++ * @defgroup versionInfo Version information
++ * @ingroup cDefines cxxDefines
++ *
++ * C-Pluff version information. Notice that this version information
++ * is static version information included in header files. The
++ * macros introduced here can be used for compile time checks.
++ */
++/*@{*/
++
++/**
++ * The C-Pluff release version string. This string identifies a specific
++ * version of the C-Pluff distribution. Compile time software compatibility
++ * checks should use #CP_VERSION_MAJOR and #CP_VERSION_MINOR instead.
++ */
++#define CP_VERSION "0.1.4"
++
++/**
++ * The major version number component of the release version. This is an
++ * integer.
++ */
++#define CP_VERSION_MAJOR 0
++
++/**
++ * The minor version number component of the release version. This is an
++ * integer.
++ */
++#define CP_VERSION_MINOR 1
++
++/*@}*/
++
++
++/* ------------------------------------------------------------------------
++ * Symbol visibility
++ * ----------------------------------------------------------------------*/
++
++/**
++ * @defgroup symbolVisibility Symbol visibility
++ * @ingroup cDefines cxxDefines
++ *
++ * Macros for controlling inter-module symbol visibility and linkage. These
++ * macros have platform specific values. #CP_EXPORT, #CP_IMPORT and #CP_HIDDEN
++ * can be reused by plug-in implementations for better portability. The
++ * complexity is mostly due to Windows DLL exports and imports.
++ *
++ * @anchor symbolVisibilityExample
++ * Each module should usually define its own macro to declare API symbols with
++ * #CP_EXPORT and #CP_IMPORT as necessary. For example, a mobule could define
++ * a macro @c MY_API in the API header file as follows.
++ *
++ * @code
++ * #ifndef MY_API
++ * # define MY_API CP_IMPORT
++ * #endif
++ * @endcode
++ *
++ * By default the API symbols would then be marked for import which is correct
++ * when client modules are including the API header file. When compiling the
++ * module itself the option @c -DMY_API=CP_EXPORT would be passed to the compiler to
++ * override the API header file and to mark the API symbols for export.
++ * The overriding definition could also be included in module source files or
++ * in an internal header file before including the API header file.
++ */
++/*@{*/
++
++/**
++ * @def CP_EXPORT
++ *
++ * Declares a symbol to be exported for inter-module usage. When compiling the
++ * module which defines the symbol this macro should be placed
++ * at the start of the symbol declaration to ensure that the symbol is exported
++ * to other modules. However, when compiling other modules the declaration of
++ * the symbol should start with #CP_IMPORT.
++ * See @ref symbolVisibilityExample "the example" of how to do this.
++ */
++
++/**
++ * @def CP_IMPORT
++ *
++ * Declares a symbol to be imported from another module. When compiling a
++ * module which uses the symbol this macro should be placed at the start of
++ * the symbol declaration to ensure that the symbol is imported from the
++ * defining module. However, when compiling the defining module the declaration
++ * of the symbol should start with #CP_EXPORT.
++ * See @ref symbolVisibilityExample "the example" of how to do this.
++ */
++
++/**
++ * @def CP_HIDDEN
++ *
++ * Declares a symbol hidden from other modules. This macro should be
++ * placed at the start of the symbol declaration to hide the symbol from other
++ * modules (if supported by the platform). This macro is not intended to be
++ * used with symbols declared as "static" which are already internal to the
++ * object file. Some platforms do not support hiding of symbols and therefore
++ * unique prefixes should be used for global symbols internal to the module
++ * even when they are declared using this macro.
++ */
++
++#if defined(_WIN32)
++# define CP_EXPORT __declspec(dllexport)
++# define CP_IMPORT extern __declspec(dllimport)
++# define CP_HIDDEN
++#elif defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
++# define CP_EXPORT
++# define CP_IMPORT extern
++# define CP_HIDDEN __attribute__ ((visibility ("hidden")))
++#else
++# define CP_EXPORT
++# define CP_IMPORT extern
++# define CP_HIDDEN
++#endif
++
++/*@}*/
++
++
++/* ------------------------------------------------------------------------
++ * GCC attributes
++ * ----------------------------------------------------------------------*/
++
++/**
++ * @defgroup cDefinesGCCAttributes GCC attributes
++ * @ingroup cDefines cxxDefines
++ *
++ * These macros conditionally define GCC attributes for declarations.
++ * They are used in C-Pluff API declarations to enable better optimization
++ * and error checking when using GCC. In non-GCC platforms they have
++ * empty values.
++ */
++/*@{*/
++
++/**
++ * @def CP_GCC_PURE
++ *
++ * Declares a function as pure function having no side effects.
++ * This attribute is supported in GCC since version 2.96.
++ * Such functions can be subject to common subexpression elimination
++ * and loop optimization.
++ */
++
++/**
++ * @def CP_GCC_NONNULL
++ *
++ * Specifies that some pointer arguments to a function should have
++ * non-NULL values. Takes a variable length list of argument indexes as
++ * arguments. This attribute is supported in GCC since version 3.3.
++ * It can be used for enhanced error checking and some optimizations.
++ */
++
++#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
++#define CP_GCC_PURE __attribute__((pure))
++#else
++#define CP_GCC_PURE
++#endif
++#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
++#define CP_GCC_NONNULL(...) __attribute__((nonnull (__VA_ARGS__)))
++#else
++#define CP_GCC_NONNULL(...)
++#endif
++
++/*@}*/
++
++#ifdef _WIN32
++#ifndef __func__
++# define __func__ __FUNCTION__
++#endif
++#ifndef snprintf
++#define snprintf _snprintf
++#endif
++#define CP_HOST "win32"
++#define CP_SHREXT ".dll"
++#define CP_FNAMESEP_CHAR '\\' // If we switch back to special:// paths then this can be '/' instead
++#define CP_THREADS
++#endif
++#endif /*CPLUFFDEF_H_*/
+diff --git a/libcpluff/win32/dirent.c b/libcpluff/win32/dirent.c
+new file mode 100644
+index 0000000..3254b22
+--- /dev/null
++++ b/libcpluff/win32/dirent.c
+@@ -0,0 +1,233 @@
++/*
++
++ Implementation of POSIX directory browsing functions and types for Win32.
++
++ Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)
++ History: Created March 1997. Updated June 2003.
++ Rights: See end of file.
++
++*/
++
++#include "dirent.h"
++#include <errno.h>
++#include <io.h> /* _findfirst and _findnext set errno iff they return -1 */
++#include <stdlib.h>
++#include <string.h>
++
++#ifdef __cplusplus
++extern "C"
++{
++#endif
++
++struct DIR
++{
++ long handle; /* -1 for failed rewind */
++ struct _finddata_t info;
++ struct dirent result; /* d_name null iff first time */
++ char *name; /* null-terminated char string */
++};
++
++DIR *opendir(const char *name)
++{
++ DIR *dir = 0;
++
++ if(name && name[0])
++ {
++ size_t base_length = strlen(name);
++ const char *all = /* search pattern must end with suitable wildcard */
++ strchr("/\\", name[base_length - 1]) ? "*" : "/*";
++
++ if((dir = (DIR *) malloc(sizeof *dir)) != 0 &&
++ (dir->name = (char *) malloc(base_length + strlen(all) + 1)) != 0)
++ {
++ strcat(strcpy(dir->name, name), all);
++
++ if((dir->handle = (long) _findfirst(dir->name, &dir->info)) != -1)
++ {
++ dir->result.d_name = 0;
++ }
++ else /* rollback */
++ {
++ free(dir->name);
++ free(dir);
++ dir = 0;
++ }
++ }
++ else /* rollback */
++ {
++ free(dir);
++ dir = 0;
++ errno = ENOMEM;
++ }
++ }
++ else
++ {
++ errno = EINVAL;
++ }
++
++ return dir;
++}
++
++int closedir(DIR *dir)
++{
++ int result = -1;
++
++ if(dir)
++ {
++ if(dir->handle != -1)
++ {
++ result = _findclose(dir->handle);
++ }
++
++ free(dir->name);
++ free(dir);
++ }
++
++ if(result == -1) /* map all errors to EBADF */
++ {
++ errno = EBADF;
++ }
++
++ return result;
++}
++
++struct dirent *readdir(DIR *dir)
++{
++ struct dirent *result = 0;
++
++ if(dir && dir->handle != -1)
++ {
++ if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1)
++ {
++ result = &dir->result;
++ result->d_name = dir->info.name;
++ }
++ }
++ else
++ {
++ errno = EBADF;
++ }
++
++ return result;
++}
++
++void rewinddir(DIR *dir)
++{
++ if(dir && dir->handle != -1)
++ {
++ _findclose(dir->handle);
++ dir->handle = (long) _findfirst(dir->name, &dir->info);
++ dir->result.d_name = 0;
++ }
++ else
++ {
++ errno = EBADF;
++ }
++}
++
++// helper for scandir below
++static void scandir_free_dir_entries(struct dirent*** namelist, int entries) {
++ int i;
++ if (!*namelist) return;
++ for (i = 0; i < entries; ++i) {
++ free((*namelist)[i]);
++ }
++ free(*namelist);
++ *namelist = 0;
++}
++
++// returns the number of directory entries select or -1 if an error occurs
++int scandir(
++ const char* dir,
++ struct dirent*** namelist,
++ int(*filter)(const struct dirent*),
++ int(*compar)(const void*, const void*)
++) {
++ int entries = 0;
++ int max_entries = 1024; // assume 2*512 = 1024 entries (used for allocation)
++ DIR* d;
++
++ *namelist = 0;
++
++ // open directory
++ d = opendir(dir);
++ if (!d) return -1;
++
++ // iterate
++ while (1) {
++ struct dirent* ent = readdir(d);
++ if (!ent) break;
++
++ // add if no filter or filter returns non-zero
++ if (filter && (0 == filter(ent))) continue;
++
++ // resize our buffer if there is not enough room
++ if (!*namelist || entries >= max_entries) {
++ struct dirent** new_entries;
++
++ max_entries *= 2;
++ new_entries = (struct dirent **)realloc(*namelist, max_entries);
++ if (!new_entries) {
++ scandir_free_dir_entries(namelist, entries);
++ closedir(d);
++ errno = ENOMEM;
++ return -1;
++ }
++
++ *namelist = new_entries;
++ }
++
++ // allocate new entry
++ (*namelist)[entries] = (struct dirent *)malloc(sizeof(struct dirent) + strlen(ent->d_name) + 1);
++ if (!(*namelist)[entries]) {
++ scandir_free_dir_entries(namelist, entries);
++ closedir(d);
++ errno = ENOMEM;
++ return -1;
++ }
++
++ // copy entry info
++ *(*namelist)[entries] = *ent;
++
++ // and then we tack the string onto the end
++ {
++ char* dest = (char*)((*namelist)[entries]) + sizeof(struct dirent);
++ strcpy(dest, ent->d_name);
++ (*namelist)[entries]->d_name = dest;
++ }
++
++ ++entries;
++ }
++
++ closedir(d);
++
++ // sort
++ if (*namelist && compar) qsort(*namelist, entries, sizeof((*namelist)[0]), compar);
++
++ return entries;
++}
++
++int alphasort(const void* lhs, const void* rhs) {
++ const struct dirent* lhs_ent = *(struct dirent**)lhs;
++ const struct dirent* rhs_ent = *(struct dirent**)rhs;
++ return _strcmpi(lhs_ent->d_name, rhs_ent->d_name);
++}
++
++#ifdef __cplusplus
++}
++#endif
++
++/*
++
++ Copyright Kevlin Henney, 1997, 2003. All rights reserved.
++
++ Permission to use, copy, modify, and distribute this software and its
++ documentation for any purpose is hereby granted without fee, provided
++ that this copyright and permissions notice appear in all copies and
++ derivatives.
++
++ This software is supplied "as is" without express or implied warranty.
++
++ But that said, if there are any problems please get in touch.
++
++*/
+diff --git a/libcpluff/win32/dirent.h b/libcpluff/win32/dirent.h
+new file mode 100644
+index 0000000..b41998c
+--- /dev/null
++++ b/libcpluff/win32/dirent.h
+@@ -0,0 +1,61 @@
++
++#ifndef DIRENT_INCLUDED
++#define DIRENT_INCLUDED
++
++/*
++
++ Declaration of POSIX directory browsing functions and types for Win32.
++
++ Author: Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)
++ History: Created March 1997. Updated June 2003.
++ Rights: See end of file.
++
++*/
++
++#ifdef __cplusplus
++extern "C"
++{
++#endif
++
++typedef struct DIR DIR;
++
++#ifndef WIN32
++static int errno;
++#endif
++
++struct dirent
++{
++ char *d_name;
++};
++
++DIR *opendir(const char *);
++int closedir(DIR *);
++struct dirent *readdir(DIR *);
++void rewinddir(DIR *);
++int scandir(
++ const char* dir,
++ struct dirent*** namelist,
++ int(*filter)(const struct dirent*),
++ int(*compar)(const void*, const void*) );
++int alphasort(const void* lhs, const void* rhs);
++
++/*
++
++ Copyright Kevlin Henney, 1997, 2003. All rights reserved.
++
++ Permission to use, copy, modify, and distribute this software and its
++ documentation for any purpose is hereby granted without fee, provided
++ that this copyright and permissions notice appear in all copies and
++ derivatives.
++
++ This software is supplied "as is" without express or implied warranty.
++
++ But that said, if there are any problems please get in touch.
++
++*/
++
++#ifdef __cplusplus
++}
++#endif
++
++#endif
+--
+2.14.1
+
diff --git a/lib/cpluff/patches/0004-all-Fix-log-level-inconsistencies.patch b/lib/cpluff/patches/0004-all-Fix-log-level-inconsistencies.patch
new file mode 100644
index 0000000000..7e780242f5
--- /dev/null
+++ b/lib/cpluff/patches/0004-all-Fix-log-level-inconsistencies.patch
@@ -0,0 +1,46 @@
+From ece6f7080c4613b2781f47e32479fb57dddd7494 Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Thu, 20 Oct 2016 14:19:44 +0100
+Subject: [PATCH 04/12] [all] Fix log level inconsistencies
+
+---
+ libcpluff/ploader.c | 2 +-
+ libcpluff/pscan.c | 4 ++--
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/libcpluff/ploader.c b/libcpluff/ploader.c
+index c4e251b..5c01add 100644
+--- a/libcpluff/ploader.c
++++ b/libcpluff/ploader.c
+@@ -1081,7 +1081,7 @@ static void check_cleanup_descriptor_parsing(cp_status_t status, cp_context_t *c
+ N_("Plug-in descriptor in %s is invalid."), path);
+ break;
+ case CP_ERR_IO:
+- cpi_errorf(context,
++ cpi_debugf(context,
+ N_("An I/O error occurred while loading a plug-in descriptor from %s."), path);
+ break;
+ case CP_ERR_RESOURCE:
+diff --git a/libcpluff/pscan.c b/libcpluff/pscan.c
+index 50dcff8..921c8e3 100644
+--- a/libcpluff/pscan.c
++++ b/libcpluff/pscan.c
+@@ -272,13 +272,13 @@ CP_C_API cp_status_t cp_scan_plugins(cp_context_t *context, int flags) {
+ // Report error
+ switch (status) {
+ case CP_OK:
+- cpi_debug(context, N_("Plug-in scan has completed successfully."));
++ cpi_info(context, N_("Plug-in scan has completed successfully."));
+ break;
+ case CP_ERR_RESOURCE:
+ cpi_error(context, N_("Could not scan plug-ins due to insufficient system resources."));
+ break;
+ default:
+- cpi_error(context, N_("Could not scan plug-ins."));
++ cpi_warn(context, N_("Not all directories were successfully scanned."));
+ break;
+ }
+ cpi_unlock_context(context);
+--
+2.14.1
+
diff --git a/lib/cpluff/patches/0005-all-Fix-unsigned-signed-warnings.patch b/lib/cpluff/patches/0005-all-Fix-unsigned-signed-warnings.patch
new file mode 100644
index 0000000000..1657962de2
--- /dev/null
+++ b/lib/cpluff/patches/0005-all-Fix-unsigned-signed-warnings.patch
@@ -0,0 +1,84 @@
+From 6956744aa9e38f961eef0b6bffbc59690d153b64 Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Thu, 20 Oct 2016 14:24:32 +0100
+Subject: [PATCH 05/12] [all] Fix unsigned/signed warnings
+
+---
+ libcpluff/pcontrol.c | 10 +++++-----
+ libcpluff/pinfo.c | 4 ++--
+ 2 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/libcpluff/pcontrol.c b/libcpluff/pcontrol.c
+index 130a3a2..2f47591 100644
+--- a/libcpluff/pcontrol.c
++++ b/libcpluff/pcontrol.c
+@@ -67,7 +67,7 @@ static void assert_processed_zero(cp_context_t *context) {
+ #endif
+
+ static void unregister_extensions(cp_context_t *context, cp_plugin_info_t *plugin) {
+- int i;
++ unsigned int i;
+
+ for (i = 0; i < plugin->num_ext_points; i++) {
+ cp_ext_point_t *ep = plugin->ext_points + i;
+@@ -109,7 +109,7 @@ CP_C_API cp_status_t cp_install_plugin(cp_context_t *context, cp_plugin_info_t *
+ cp_plugin_t *rp = NULL;
+ cp_status_t status = CP_OK;
+ cpi_plugin_event_t event;
+- int i;
++ unsigned int i;
+
+ CHECK_NOT_NULL(context);
+ CHECK_NOT_NULL(plugin);
+@@ -421,7 +421,7 @@ static int resolve_plugin_prel_rec(cp_context_t *context, cp_plugin_t *plugin) {
+ cp_status_t status = CP_OK;
+ int error_reported = 0;
+ lnode_t *node = NULL;
+- int i;
++ unsigned int i;
+
+ // Check if already resolved
+ if (plugin->state >= CP_PLUGIN_RESOLVED) {
+@@ -1092,7 +1092,7 @@ static void free_extension_content(cp_extension_t *extension) {
+ }
+
+ static void free_cfg_element_content(cp_cfg_element_t *ce) {
+- int i;
++ unsigned int i;
+
+ assert(ce != NULL);
+ free(ce->name);
+@@ -1108,7 +1108,7 @@ static void free_cfg_element_content(cp_cfg_element_t *ce) {
+ }
+
+ CP_HIDDEN void cpi_free_plugin(cp_plugin_info_t *plugin) {
+- int i;
++ unsigned int i;
+
+ assert(plugin != NULL);
+ free(plugin->name);
+diff --git a/libcpluff/pinfo.c b/libcpluff/pinfo.c
+index 6492712..29c629b 100644
+--- a/libcpluff/pinfo.c
++++ b/libcpluff/pinfo.c
+@@ -667,7 +667,7 @@ static cp_cfg_element_t * lookup_cfg_element(cp_cfg_element_t *base, const char
+ if (end - start == 2 && !strncmp(path + start, "..", 2)) {
+ base = base->parent;
+ } else {
+- int i;
++ unsigned int i;
+ int found = 0;
+
+ for (i = 0; !found && i < base->num_children; i++) {
+@@ -711,7 +711,7 @@ CP_C_API char * cp_lookup_cfg_value(cp_cfg_element_t *base, const char *path) {
+ if (attr == NULL) {
+ return e->value;
+ } else {
+- int i;
++ unsigned int i;
+
+ for (i = 0; i < e->num_atts; i++) {
+ if (!strcmp(attr, e->atts[2*i])) {
+--
+2.14.1
+
diff --git a/lib/cpluff/patches/0006-all-Fix-scoping-error.patch b/lib/cpluff/patches/0006-all-Fix-scoping-error.patch
new file mode 100644
index 0000000000..5e8e09a23b
--- /dev/null
+++ b/lib/cpluff/patches/0006-all-Fix-scoping-error.patch
@@ -0,0 +1,33 @@
+From f4a0c37a69c62965f93a697ea3b8565bbabf5b9b Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Thu, 20 Oct 2016 14:26:29 +0100
+Subject: [PATCH 06/12] [all] Fix scoping error
+
+---
+ libcpluff/util.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/libcpluff/util.c b/libcpluff/util.c
+index a5f437b..e5ff7cf 100644
+--- a/libcpluff/util.c
++++ b/libcpluff/util.c
+@@ -157,6 +157,7 @@ static int vercmp_num_value(const char *v, const char *vn) {
+ CP_HIDDEN int cpi_vercmp(const char *v1, const char *v2) {
+ const char *v1n;
+ const char *v2n;
++ int diff;
+
+ // Check for NULL versions
+ if (v1 == NULL && v2 != NULL) {
+@@ -186,7 +187,7 @@ CP_HIDDEN int cpi_vercmp(const char *v1, const char *v2) {
+ if (v2 < v2n) {
+ c2 = *v2++;
+ }
+- int diff = vercmp_char_value(c1) - vercmp_char_value(c2);
++ diff = vercmp_char_value(c1) - vercmp_char_value(c2);
+ if (diff != 0) {
+ return diff;
+ }
+--
+2.14.1
+
diff --git a/lib/cpluff/patches/0007-all-Comment-log-line-to-reduce-log-spew.patch b/lib/cpluff/patches/0007-all-Comment-log-line-to-reduce-log-spew.patch
new file mode 100644
index 0000000000..8fab2edd1f
--- /dev/null
+++ b/lib/cpluff/patches/0007-all-Comment-log-line-to-reduce-log-spew.patch
@@ -0,0 +1,25 @@
+From e06c8af2d8141b675f2719edf48af84e1445e1b5 Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Thu, 20 Oct 2016 15:01:11 +0100
+Subject: [PATCH 07/12] [all] Comment log line to reduce log spew
+
+---
+ libcpluff/pinfo.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libcpluff/pinfo.c b/libcpluff/pinfo.c
+index 29c629b..6262c74 100644
+--- a/libcpluff/pinfo.c
++++ b/libcpluff/pinfo.c
+@@ -198,7 +198,7 @@ CP_C_API cp_plugin_info_t * cp_get_plugin_info(cp_context_t *context, const char
+ // Lookup plug-in information
+ if (id != NULL) {
+ if ((node = hash_lookup(context->env->plugins, id)) == NULL) {
+- cpi_warnf(context, N_("Could not return information about unknown plug-in %s."), id);
++ // cpi_warnf(context, N_("Could not return information about unknown plug-in %s."), id);
+ status = CP_ERR_UNKNOWN;
+ break;
+ }
+--
+2.14.1
+
diff --git a/lib/cpluff/patches/0008-configure-Handle-libdl-only-being-needed-on-Linux-fo.patch b/lib/cpluff/patches/0008-configure-Handle-libdl-only-being-needed-on-Linux-fo.patch
new file mode 100644
index 0000000000..9baf70b6f2
--- /dev/null
+++ b/lib/cpluff/patches/0008-configure-Handle-libdl-only-being-needed-on-Linux-fo.patch
@@ -0,0 +1,27 @@
+From 40e6a7d6aa122b99b65ad0f034ee2d90214779a9 Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Thu, 20 Oct 2016 15:05:58 +0100
+Subject: [PATCH 08/12] [configure] Handle libdl only being needed on Linux for
+ dlopen
+
+---
+ configure.ac | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 0700af9..c391dfb 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -179,7 +179,8 @@ dlmechanism=none
+ if test "$with_dlopen" != no && test "$with_libltdl" != yes; then
+ AC_CHECK_HEADER([dlfcn.h],
+ AC_CHECK_LIB([dl], [dlopen],
+- [LIBS_DL="-ldl $LIBS_DL"; dlmechanism=dlopen]))
++ [LIBS_DL="-ldl $LIBS_DL"; dlmechanism=dlopen],
++ AC_CHECK_LIB([c], [dlopen], [dlmechanism=dlopen])))
+ fi
+ if test "$dlmechanism" = none && test "$with_libltdl" != no && test "$with_dlopen" != yes; then
+ AC_CHECK_HEADER([ltdl.h],
+--
+2.14.1
+
diff --git a/lib/cpluff/patches/0009-configure-Add-silent-rules-to-shut-it-up-a-little.patch b/lib/cpluff/patches/0009-configure-Add-silent-rules-to-shut-it-up-a-little.patch
new file mode 100644
index 0000000000..fa7765aa87
--- /dev/null
+++ b/lib/cpluff/patches/0009-configure-Add-silent-rules-to-shut-it-up-a-little.patch
@@ -0,0 +1,24 @@
+From 2a63458669637b8646e97e47b1384926760cb632 Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Thu, 20 Oct 2016 15:08:49 +0100
+Subject: [PATCH 09/12] [configure] Add silent rules to shut it up a little
+
+---
+ configure.ac | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/configure.ac b/configure.ac
+index c391dfb..3ada0ae 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -45,6 +45,7 @@ AC_SUBST([CP_CXX_LIB_VERSION])
+ # Automake initialization
+ # -----------------------
+ AM_INIT_AUTOMAKE([foreign subdir-objects])
++m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
+ AM_GNU_GETTEXT([external])
+ AM_GNU_GETTEXT_VERSION([0.16.1])
+
+--
+2.14.1
+
diff --git a/lib/cpluff/patches/0010-configure-Fix-build-with-xcode5.patch b/lib/cpluff/patches/0010-configure-Fix-build-with-xcode5.patch
new file mode 100644
index 0000000000..1ab98d10c4
--- /dev/null
+++ b/lib/cpluff/patches/0010-configure-Fix-build-with-xcode5.patch
@@ -0,0 +1,34 @@
+From 763a3322e981e0493106b87ae1c86c0054f0da2d Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Thu, 20 Oct 2016 15:22:30 +0100
+Subject: [PATCH 10/12] [configure] Fix build with xcode5
+
+---
+ configure.ac | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 3ada0ae..d9a1771 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -119,7 +119,7 @@ if test "$enable_threads" != no; then
+ [AC_LINK_IFELSE(
+ [AC_LANG_SOURCE([#include <pthread.h>
+
+-int main(int argc, char *argv[]) {
++int main(int argc, char **argv) {
+ pthread_mutex_t mutex;
+
+ pthread_mutex_init(&mutex, NULL);
+@@ -138,7 +138,7 @@ int main(int argc, char *argv[]) {
+ [AC_LINK_IFELSE(
+ [AC_LANG_SOURCE([#include <windows.h>
+
+-int main(int argc, char *argv[]) {
++int main(int argc, char **argv) {
+ CreateMutex(NULL, FALSE, NULL);
+ return 0;
+ }
+--
+2.14.1
+
diff --git a/lib/cpluff/patches/0011-docs-We-don-t-need-them.patch b/lib/cpluff/patches/0011-docs-We-don-t-need-them.patch
new file mode 100644
index 0000000000..35d6a87b4b
--- /dev/null
+++ b/lib/cpluff/patches/0011-docs-We-don-t-need-them.patch
@@ -0,0 +1,25 @@
+From c2e5e32cc956ab3bb58199f6d1606f3532b86519 Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Mon, 29 Jan 2018 20:45:51 +0000
+Subject: [PATCH 11/12] [docs] We don't need them
+
+---
+ Makefile.am | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 695448a..dcba780 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -6,7 +6,7 @@
+
+ ACLOCAL_AMFLAGS = -I m4
+
+-SUBDIRS = libcpluff loader console po test docsrc doc
++SUBDIRS = libcpluff loader console po test
+ DIST_SUBDIRS = $(SUBDIRS) examples
+
+ EXTRA_DIST = COPYRIGHT.txt INSTALL.txt ChangeLog.txt Roadmap.txt autogen.sh plugin.xsd
+--
+2.14.1
+
diff --git a/lib/cpluff/patches/0012-Kill-implicit-function-declaration-warning.patch b/lib/cpluff/patches/0012-Kill-implicit-function-declaration-warning.patch
new file mode 100644
index 0000000000..6a878f8d2e
--- /dev/null
+++ b/lib/cpluff/patches/0012-Kill-implicit-function-declaration-warning.patch
@@ -0,0 +1,28 @@
+From c16649382e3b89264aada598b07a3980aa7e42e4 Mon Sep 17 00:00:00 2001
+From: "h.udo" <hudokkow@gmail.com>
+Date: Fri, 2 Feb 2018 20:48:30 +0000
+Subject: [PATCH 12/12] Kill implicit-function-declaration warning
+
+---
+ console/cmdinput_basic.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/console/cmdinput_basic.c b/console/cmdinput_basic.c
+index 033c35d..71977fe 100644
+--- a/console/cmdinput_basic.c
++++ b/console/cmdinput_basic.c
+@@ -25,10 +25,10 @@
+
+ #include <stdio.h>
+ #include <string.h>
++#include "console.h"
+ #if defined(HAVE_ISATTY_FILENO)
+ #include <unistd.h>
+ #endif
+-#include "console.h"
+
+ #define CMDLINE_SIZE 256
+
+--
+2.14.1
+