aboutsummaryrefslogtreecommitdiff
path: root/lib/cpluff/libcpluff/win32
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cpluff/libcpluff/win32')
-rw-r--r--lib/cpluff/libcpluff/win32/cpluffdef.h216
-rw-r--r--lib/cpluff/libcpluff/win32/dirent.c231
-rw-r--r--lib/cpluff/libcpluff/win32/dirent.h57
-rw-r--r--lib/cpluff/libcpluff/win32/win32_utils.c73
-rw-r--r--lib/cpluff/libcpluff/win32/win32_utils.h30
5 files changed, 0 insertions, 607 deletions
diff --git a/lib/cpluff/libcpluff/win32/cpluffdef.h b/lib/cpluff/libcpluff/win32/cpluffdef.h
deleted file mode 100644
index 7e3d55f269..0000000000
--- a/lib/cpluff/libcpluff/win32/cpluffdef.h
+++ /dev/null
@@ -1,216 +0,0 @@
-/*-------------------------------------------------------------------------
- * 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)
-#if defined(_WINDLL)
-# define CP_IMPORT extern __declspec(dllimport)
-#else
-# define CP_IMPORT
-#endif
-# 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/lib/cpluff/libcpluff/win32/dirent.c b/lib/cpluff/libcpluff/win32/dirent.c
deleted file mode 100644
index ead41848f9..0000000000
--- a/lib/cpluff/libcpluff/win32/dirent.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
-
- 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 "win32_utils.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
-{
- HANDLE handle; /* -1 for failed rewind */
- struct dirent result; /* d_name null iff first time */
- wchar_t* name;
- WIN32_FIND_DATAW info;
-};
-
-DIR *opendir(const char *name)
-{
- DIR *dir = 0;
-
- if(name && name[0])
- {
- if ((dir = (DIR *)malloc(sizeof *dir)) != 0)
- {
- dir->handle = INVALID_HANDLE_VALUE;
- int len = strlen(name);
- size_t newLength = len + 2; //add an extra for null and another for a * at the end
- if (!(name[0] == '\\' && name[1] == '\\' && name[2] == '?' && name[3] == '\\'))
- newLength += 4;
- if (name[len - 1] != '\\')
- newLength += 1;
-
- char* newDir = (char*)malloc(newLength);
- strcpy_s(newDir, newLength, "\\\\?\\");
- strcat_s(newDir, newLength, name);
- if (name[len - 1] != '\\')
- strcat_s(newDir, newLength, "\\");
- strcat_s(newDir, newLength, "*");
- newDir[newLength - 1] = '\0';
-
- dir->name = to_utf16(newDir, newLength);
- free(newDir);
-
- dir->handle = FindFirstFileW(dir->name, &dir->info);
- if (dir->handle != INVALID_HANDLE_VALUE)
- {
- dir->result.d_name = 0;
- }
- else /* rollback */
- {
- free(dir->name);
- free(dir);
- dir = 0;
- }
- }
- else /* rollback */
- {
- free(dir->name);
- free(dir);
- dir = 0;
- errno = ENOMEM;
- }
- }
- else
- {
- errno = EINVAL;
- }
-
- return dir;
-}
-
-int closedir(DIR *dir)
-{
- int result = -1;
-
- if(dir && dir->handle != INVALID_HANDLE_VALUE)
- {
- 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 != INVALID_HANDLE_VALUE)
- {
- if (FindNextFileW(dir->handle, &dir->info))
- {
- result = &dir->result;
- result->d_name = to_utf8(dir->info.cFileName, 0);
- }
- }
- else
- {
- errno = EBADF;
- }
-
- return result;
-}
-
-// 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/lib/cpluff/libcpluff/win32/dirent.h b/lib/cpluff/libcpluff/win32/dirent.h
deleted file mode 100644
index c250bfdb28..0000000000
--- a/lib/cpluff/libcpluff/win32/dirent.h
+++ /dev/null
@@ -1,57 +0,0 @@
-
-#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;
-
-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
diff --git a/lib/cpluff/libcpluff/win32/win32_utils.c b/lib/cpluff/libcpluff/win32/win32_utils.c
deleted file mode 100644
index 52cf353c13..0000000000
--- a/lib/cpluff/libcpluff/win32/win32_utils.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*-------------------------------------------------------------------------
- * C-Pluff, a plug-in framework for C
- * Copyright 2016 Team Kodi
- *
- * 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.
- *-----------------------------------------------------------------------*/
-
-#include <stdlib.h>
-
-#include "win32_utils.h"
-
-wchar_t* to_utf16(const char* str, size_t length)
-{
- if (length == 0)
- length = strlen(str);
- int result = MultiByteToWideChar(CP_UTF8, 0, str, length, NULL, 0);
- if (result == 0)
- {
- return NULL;
- }
-
- int newLen = result + 1;
- wchar_t* dirPath = malloc(newLen * 2);
- result = MultiByteToWideChar(CP_UTF8, 0, str, length, dirPath, newLen);
-
- if (result == 0)
- {
- free(dirPath);
- return NULL;
- }
-
- dirPath[newLen - 1] = L'\0';
- return dirPath;
-}
-
-char* to_utf8(const wchar_t* str, size_t length)
-{
- if (length == 0)
- length = wcslen(str);
-
- int result = WideCharToMultiByte(CP_UTF8, 0, str, length, NULL, 0, NULL, NULL);
- if (result == 0)
- return NULL;
-
- int newLen = result + 1;
- char *newStr = malloc(newLen);
- result = WideCharToMultiByte(CP_UTF8, 0, str, length, newStr, result, NULL, NULL);
- if (result == 0)
- {
- free(newStr);
- return NULL;
- }
-
- newStr[newLen - 1] = '\0';
-
- return newStr;
-}
diff --git a/lib/cpluff/libcpluff/win32/win32_utils.h b/lib/cpluff/libcpluff/win32/win32_utils.h
deleted file mode 100644
index f4074f3745..0000000000
--- a/lib/cpluff/libcpluff/win32/win32_utils.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-------------------------------------------------------------------------
- * C-Pluff, a plug-in framework for C
- * Copyright 2016 Team Kodi
- *
- * 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.
- *-----------------------------------------------------------------------*/
-
-#if !defined(WIN32_LEAN_AND_MEAN)
- #define WIN32_LEAN_AND_MEAN
-#endif
-#include <windows.h>
-
-wchar_t* to_utf16(const char* str, size_t length);
-char* to_utf8(const wchar_t* str, size_t length);