From d95ea2c006224202fafafcd04051f4eb3fb16068 Mon Sep 17 00:00:00 2001 From: doomchild Date: Fri, 30 Apr 2010 15:24:49 -0500 Subject: [PATCH] first commit --- dfhack/DFHackAPI_C.cpp | 83 ++++++++++++++++++++++++++++++++++++ dfhack/include/DFHackAPI_C.h | 52 ++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 dfhack/DFHackAPI_C.cpp create mode 100644 dfhack/include/DFHackAPI_C.h diff --git a/dfhack/DFHackAPI_C.cpp b/dfhack/DFHackAPI_C.cpp new file mode 100644 index 000000000..2c07e4d2e --- /dev/null +++ b/dfhack/DFHackAPI_C.cpp @@ -0,0 +1,83 @@ +/* +www.sourceforge.net/projects/dfhack +Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#include "Tranquility.h" +#include "Export.h" +#include +#include +#include +#include "integers.h" +#include "DFTileTypes.h" +#include "DFTypes.h" +#include "DFWindow.h" +#include "DFHackAPI.h" + +using namespace std; +using namespace DFHack; + +#include "DFHackAPI_C.h" + +#ifdef __cplusplus +extern "C" { +#endif + +DFHackObject* API_Alloc(const char* path_to_xml) +{ + DFHack::API* api = new DFHack::API(std::string(path_to_xml)); + return (DFHackObject*)api; +} + +/* + +void API_Free(DFHackObject* api) +{ + if(api != NULL) + { + delete api; + api = NULL; + } +} + +bool API_Attach(DFHackObject* api) +{ + if(api != NULL) + return ((DFHack::API*)api)->Attach(); +} + +bool API_Detach(DFHackObject* api) +{ + if(api != NULL) + return ((DFHack::API*)api)->Detach(); +} + +bool API_isAttached(DFHackObject* api) +{ + if(api != NULL) + return ((DFHack::API*)api)->isAttached(); +} +*/ + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/dfhack/include/DFHackAPI_C.h b/dfhack/include/DFHackAPI_C.h new file mode 100644 index 000000000..f02d91d28 --- /dev/null +++ b/dfhack/include/DFHackAPI_C.h @@ -0,0 +1,52 @@ +/* +www.sourceforge.net/projects/dfhack +Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any +damages arising from the use of this software. + +Permission is granted to anyone to use this software for any +purpose, including commercial applications, and to alter it and +redistribute it freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must +not claim that you wrote the original software. If you use this +software in a product, an acknowledgment in the product documentation +would be appreciated but is not required. + +2. Altered source versions must be plainly marked as such, and +must not be misrepresented as being the original software. + +3. This notice may not be removed or altered from any source +distribution. +*/ + +#ifndef DFHACK_C_API +#define DFHACK_C_API + +typedef void DFHackObject; + +#ifdef __cplusplus +extern "C" { +#endif + +__declspec(dllexport) DFHackObject* API_Alloc(const char* path_to_xml); +/* +static void API_Free(DFHackObject* api); + +static bool API_Attach(DFHackObject* api); +static bool API_Detach(DFHackObject* api); +static bool API_isAttached(DFHackObject* api); + +static bool API_Suspend(DFHackObject* api); +static bool API_Resume(DFHackObject* api); +static bool API_isSuspended(DFHackObject* api); +static bool API_ForceResume(DFHackObject* api); +*/ + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file