aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cpluff/kazlib/hash.h4
-rw-r--r--lib/cpluff/kazlib/list.h4
-rw-r--r--lib/cpluff/libcpluff/cpluff.h2
-rw-r--r--lib/cpluff/libcpluff/internal.h8
-rw-r--r--lib/cpluff/libcpluff/pcontrol.c3
-rw-r--r--lib/cpluff/libcpluff/psymbol.c3
-rw-r--r--lib/cpluff/libcpluff/win32/cpluff.vcproj286
-rw-r--r--lib/cpluff/libcpluff/win32/cpluffdef.h (renamed from lib/cpluff/libcpluff/cpluffdef_win32.h)13
-rw-r--r--lib/cpluff/libcpluff/win32/dirent.c231
-rw-r--r--lib/cpluff/libcpluff/win32/dirent.h61
10 files changed, 612 insertions, 3 deletions
diff --git a/lib/cpluff/kazlib/hash.h b/lib/cpluff/kazlib/hash.h
index 1fbd2462c7..50297eed8e 100644
--- a/lib/cpluff/kazlib/hash.h
+++ b/lib/cpluff/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/lib/cpluff/kazlib/list.h b/lib/cpluff/kazlib/list.h
index c449acbb54..ccad262327 100644
--- a/lib/cpluff/kazlib/list.h
+++ b/lib/cpluff/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/lib/cpluff/libcpluff/cpluff.h b/lib/cpluff/libcpluff/cpluff.h
index da90130a1f..12d65a7956 100644
--- a/lib/cpluff/libcpluff/cpluff.h
+++ b/lib/cpluff/libcpluff/cpluff.h
@@ -39,7 +39,7 @@
*/
#ifdef _WIN32
-#include "cpluffdef_win32.h"
+#include "win32/cpluffdef.h"
#else
#include "cpluffdef.h"
#endif
diff --git a/lib/cpluff/libcpluff/internal.h b/lib/cpluff/libcpluff/internal.h
index 91989e8451..161ba6de07 100644
--- a/lib/cpluff/libcpluff/internal.h
+++ b/lib/cpluff/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/lib/cpluff/libcpluff/pcontrol.c b/lib/cpluff/libcpluff/pcontrol.c
index c7da6cfbab..38d0de4134 100644
--- a/lib/cpluff/libcpluff/pcontrol.c
+++ b/lib/cpluff/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/lib/cpluff/libcpluff/psymbol.c b/lib/cpluff/libcpluff/psymbol.c
index ccf9ea697a..632b087324 100644
--- a/lib/cpluff/libcpluff/psymbol.c
+++ b/lib/cpluff/libcpluff/psymbol.c
@@ -33,6 +33,9 @@
#include "defines.h"
#include "internal.h"
#include "util.h"
+#ifdef _WIN32
+#include <windows.h>
+#endif
/* ------------------------------------------------------------------------
diff --git a/lib/cpluff/libcpluff/win32/cpluff.vcproj b/lib/cpluff/libcpluff/win32/cpluff.vcproj
new file mode 100644
index 0000000000..b41e7e8e26
--- /dev/null
+++ b/lib/cpluff/libcpluff/win32/cpluff.vcproj
@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="cpluff"
+ ProjectGUID="{88968763-3D6B-48A8-B495-CC8C187FAC02}"
+ RootNamespace="cpluff"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="."
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CP_C_API=CP_EXPORT"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libexpat.lib"
+ OutputFile="..\..\..\..\system\cpluff.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)$(TargetName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="."
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CP_C_API=CP_EXPORT"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="libexpat.lib"
+ OutputFile="..\..\..\..\system\cpluff.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)$(TargetName).pdb"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)$(TargetName).lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\context.c"
+ >
+ </File>
+ <File
+ RelativePath="..\cpluff.c"
+ >
+ </File>
+ <File
+ RelativePath=".\dirent.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\kazlib\hash.c"
+ >
+ </File>
+ <File
+ RelativePath="..\..\kazlib\list.c"
+ >
+ </File>
+ <File
+ RelativePath="..\logging.c"
+ >
+ </File>
+ <File
+ RelativePath="..\pcontrol.c"
+ >
+ </File>
+ <File
+ RelativePath="..\pinfo.c"
+ >
+ </File>
+ <File
+ RelativePath="..\ploader.c"
+ >
+ </File>
+ <File
+ RelativePath="..\pscan.c"
+ >
+ </File>
+ <File
+ RelativePath="..\psymbol.c"
+ >
+ </File>
+ <File
+ RelativePath="..\serial.c"
+ >
+ </File>
+ <File
+ RelativePath="..\thread_windows.c"
+ >
+ </File>
+ <File
+ RelativePath="..\util.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\cpluff.h"
+ >
+ </File>
+ <File
+ RelativePath=".\cpluffdef.h"
+ >
+ </File>
+ <File
+ RelativePath="..\defines.h"
+ >
+ </File>
+ <File
+ RelativePath=".\dirent.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\kazlib\hash.h"
+ >
+ </File>
+ <File
+ RelativePath="..\internal.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\kazlib\list.h"
+ >
+ </File>
+ <File
+ RelativePath="..\thread.h"
+ >
+ </File>
+ <File
+ RelativePath="..\util.h"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/lib/cpluff/libcpluff/cpluffdef_win32.h b/lib/cpluff/libcpluff/win32/cpluffdef.h
index c529386702..6f7742b903 100644
--- a/lib/cpluff/libcpluff/cpluffdef_win32.h
+++ b/lib/cpluff/libcpluff/win32/cpluffdef.h
@@ -147,7 +147,6 @@
# define CP_IMPORT extern
# define CP_HIDDEN
#endif
-
/*@}*/
@@ -197,4 +196,16 @@
/*@}*/
+#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
new file mode 100644
index 0000000000..db72f39d37
--- /dev/null
+++ b/lib/cpluff/libcpluff/win32/dirent.c
@@ -0,0 +1,231 @@
+/*
+
+ 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;
+ }
+
+ // 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
new file mode 100644
index 0000000000..b41998c6eb
--- /dev/null
+++ b/lib/cpluff/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