Fix-merge early C API implementation

develop
Petr Mrázek 2010-05-02 01:20:31 +02:00
parent 29aa8f03c0
commit bae9939e50
11 changed files with 70 additions and 89 deletions

@ -1,6 +1,6 @@
/* /*
www.sourceforge.net/projects/dfhack www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any warranty. In no event will the authors be held liable for any

@ -50,7 +50,7 @@ class WineProcess::Private
DFWindow* my_window; DFWindow* my_window;
memory_info * my_descriptor; memory_info * my_descriptor;
Process * self; Process * self;
ProcessHandle my_handle; pid_t my_handle;
uint32_t my_pid; uint32_t my_pid;
string memFile; string memFile;
int memFileHandle; int memFileHandle;

@ -47,7 +47,7 @@ class NormalProcess::Private
~Private(){}; ~Private(){};
DFWindow* my_window; DFWindow* my_window;
memory_info * my_descriptor; memory_info * my_descriptor;
ProcessHandle my_handle; pid_t my_handle;
uint32_t my_pid; uint32_t my_pid;
string memFile; string memFile;
int memFileHandle; int memFileHandle;

@ -44,7 +44,7 @@ class NormalProcess::Private
~Private(){}; ~Private(){};
memory_info * my_descriptor; memory_info * my_descriptor;
DFWindow * my_window; DFWindow * my_window;
ProcessHandle my_handle; HANDLE my_handle;
HANDLE my_main_thread; HANDLE my_main_thread;
uint32_t my_pid; uint32_t my_pid;
string memFile; string memFile;

@ -25,23 +25,43 @@ distribution.
#ifndef DFCOMMONINTERNAL_H_INCLUDED #ifndef DFCOMMONINTERNAL_H_INCLUDED
#define DFCOMMONINTERNAL_H_INCLUDED #define DFCOMMONINTERNAL_H_INCLUDED
// this makes everything that includes this file export symbols whn using DFHACK_EXPORT (see Export.h) // this makes everything that includes this file export symbols when using DFHACK_EXPORT (see Export.h)
#define BUILD_DFHACK_LIB #ifndef BUILD_DFHACK_LIB
#define BUILD_DFHACK_LIB
#endif
// wizardry for the cmake-generated config.h
#define _QUOTEME(x) #x
#define QUOT(x) _QUOTEME(x)
#ifdef USE_CONFIG_H // set by cmake for Linux builds
#include "config.h"
#else
#define MEMXML_DATA_PATH .
#endif
// one file for globals
#include "DFGlobal.h" #include "DFGlobal.h"
// one file for telling the MSVC compiler where it can shove its pointless warnings
#include "Tranquility.h" #include "Tranquility.h"
// basic stl containers and IO stuff
#include <string> #include <string>
#include <vector> #include <vector>
#include <map> #include <map>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
// C99 integer types
#include "integers.h" #include "integers.h"
// C includes
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
// platform includes and defines
#ifdef LINUX_BUILD #ifdef LINUX_BUILD
#include <sys/types.h> #include <sys/types.h>
#include <sys/ptrace.h> #include <sys/ptrace.h>
@ -53,59 +73,26 @@ using namespace std;
#include <fcntl.h> #include <fcntl.h>
#include <sys/wait.h> #include <sys/wait.h>
#else #else
// WINDOWS
#define _WIN32_WINNT 0x0501 // needed for INPUT struct #define _WIN32_WINNT 0x0501 // needed for INPUT struct
#define WINVER 0x0501 // OpenThread(), PSAPI, Toolhelp32 #define WINVER 0x0501 // OpenThread(), PSAPI, Toolhelp32
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <windows.h> #include <windows.h>
//#include <winbase.h>
#include <winnt.h> #include <winnt.h>
#include <psapi.h> #include <psapi.h>
#include <tlhelp32.h> #include <tlhelp32.h>
#endif #endif
#ifdef LINUX_BUILD // dfhack dependencies
typedef pid_t ProcessHandle;
#else
typedef HANDLE ProcessHandle;
#endif
#ifndef BUILD_DFHACK_LIB
# define BUILD_DFHACK_LIB
#endif
/*
#include "DFTypes.h"
//#include "DFDataModel.h"
#include "DFProcess.h"
#include "DFWindow.h"
#include "DFProcessEnumerator.h"
#include "DFMemInfoManager.h"
#include "DFVector.h"
#include "DFMemInfo.h"
#include "DFError.h"
*/
#include <stdlib.h>
#include <tinyxml.h> #include <tinyxml.h>
#include <md5wrapper.h> #include <md5wrapper.h>
#include <iostream> /*
//#include "DFHackAPI.h"
#define _QUOTEME(x) #x
#define QUOT(x) _QUOTEME(x)
#ifdef USE_CONFIG_H
#include "config.h"
#else
#define MEMXML_DATA_PATH .
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400 #if defined(_MSC_VER) && _MSC_VER >= 1400
#define fill_char_buf(buf, str) strcpy_s((buf), sizeof(buf) / sizeof((buf)[0]), (str).c_str()) #define fill_char_buf(buf, str) strcpy_s((buf), sizeof(buf) / sizeof((buf)[0]), (str).c_str())
#else #else
#define fill_char_buf(buf, str) strncpy((buf), (str).c_str(), sizeof(buf) / sizeof((buf)[0])) #define fill_char_buf(buf, str) strncpy((buf), (str).c_str(), sizeof(buf) / sizeof((buf)[0]))
#endif #endif
*/
#endif // DFCOMMONINTERNAL_H_INCLUDED #endif // DFCOMMONINTERNAL_H_INCLUDED

@ -1,6 +1,6 @@
/* /*
www.sourceforge.net/projects/dfhack www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any warranty. In no event will the authors be held liable for any
@ -34,21 +34,21 @@ typedef void DFHackObject;
extern "C" { extern "C" {
#endif #endif
EXPORT DFHackObject* API_Alloc(const char* path_to_xml); DFHACK_EXPORT DFHackObject* API_Alloc(const char* path_to_xml);
EXPORT void API_Free(DFHackObject* api); DFHACK_EXPORT void API_Free(DFHackObject* api);
EXPORT int API_Attach(DFHackObject* api); DFHACK_EXPORT int API_Attach(DFHackObject* api);
EXPORT int API_Detach(DFHackObject* api); DFHACK_EXPORT int API_Detach(DFHackObject* api);
EXPORT int API_isAttached(DFHackObject* api); DFHACK_EXPORT int API_isAttached(DFHackObject* api);
EXPORT int API_Suspend(DFHackObject* api); DFHACK_EXPORT int API_Suspend(DFHackObject* api);
EXPORT int API_Resume(DFHackObject* api); DFHACK_EXPORT int API_Resume(DFHackObject* api);
EXPORT int API_isSuspended(DFHackObject* api); DFHACK_EXPORT int API_isSuspended(DFHackObject* api);
EXPORT int API_ForceResume(DFHackObject* api); DFHACK_EXPORT int API_ForceResume(DFHackObject* api);
EXPORT int API_AsyncSuspend(DFHackObject* api); DFHACK_EXPORT int API_AsyncSuspend(DFHackObject* api);
EXPORT void API_ReadRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* target); DFHACK_EXPORT void API_ReadRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* target);
EXPORT void API_WriteRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* source); DFHACK_EXPORT void API_WriteRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* source);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -23,23 +23,17 @@ distribution.
*/ */
#ifdef LINUX_BUILD #ifdef LINUX_BUILD
#ifndef DFHACK_EXPORT #ifndef DFHACK_EXPORT
#ifndef SWIGIMPORTED #define DFHACK_EXPORT __attribute__ ((visibility("default")))
#define DFHACK_EXPORT __attribute__ ((visibility("default"))) #endif
#else #else
#define DFHACK_EXPORT #ifdef BUILD_DFHACK_LIB
#ifndef DFHACK_EXPORT
#define DFHACK_EXPORT __declspec(dllexport)
#endif
#else
#ifndef DFHACK_EXPORT
#define DFHACK_EXPORT __declspec(dllimport)
#endif
#endif
#endif #endif
#endif
#else
#ifdef BUILD_DFHACK_LIB
#ifndef DFHACK_EXPORT
#define DFHACK_EXPORT __declspec(dllexport)
#endif
#else
#ifndef DFHACK_EXPORT
#define DFHACK_EXPORT __declspec(dllimport)
#endif
#endif
#endif
#define EXPORT __declspec(dllexport)

@ -1,6 +1,6 @@
/* /*
www.sourceforge.net/projects/dfhack www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any warranty. In no event will the authors be held liable for any
@ -33,13 +33,13 @@ distribution.
extern "C" { extern "C" {
#endif #endif
EXPORT int Position_getViewCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z); DFHACK_EXPORT int Position_getViewCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z);
EXPORT int Position_setViewCoords(DFHackObject* pos, const int32_t x, const int32_t y, const int32_t z); DFHACK_EXPORT int Position_setViewCoords(DFHackObject* pos, const int32_t x, const int32_t y, const int32_t z);
EXPORT int Position_getCursorCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z); DFHACK_EXPORT int Position_getCursorCoords(DFHackObject* pos, int32_t* x, int32_t* y, int32_t* z);
EXPORT int Position_setCursorCoords(DFHackObject* pos, const int32_t x, const int32_t y, const int32_t z); DFHACK_EXPORT int Position_setCursorCoords(DFHackObject* pos, const int32_t x, const int32_t y, const int32_t z);
EXPORT int Position_getWindowSize(DFHackObject* pos, int32_t* width, int32_t* height); DFHACK_EXPORT int Position_getWindowSize(DFHackObject* pos, int32_t* width, int32_t* height);
#ifdef __cplusplus #ifdef __cplusplus
} }

@ -191,7 +191,8 @@ bool Creatures::ReadCreature (const int32_t index, t_creature & furball)
d->d->readName(furball.artifact_name, temp + offs.artifact_name_offset); d->d->readName(furball.artifact_name, temp + offs.artifact_name_offset);
// custom profession // custom profession
fill_char_buf (furball.custom_profession, p->readSTLString (temp + offs.custom_profession_offset)); p->readSTLString(temp + offs.custom_profession_offset, furball.custom_profession, sizeof(furball.custom_profession));
//fill_char_buf (furball.custom_profession, p->readSTLString (temp + offs.custom_profession_offset));
// labors // labors
p->read (temp + offs.labors_offset, NUM_CREATURE_LABORS, furball.labors); p->read (temp + offs.labors_offset, NUM_CREATURE_LABORS, furball.labors);

@ -31,7 +31,7 @@ distribution.
using namespace std; using namespace std;
#include "Export.h" #include "Export.h"
#include "DFCommonInternal.h" //#include "DFCommonInternal.h"
#include "DFMemInfo.h" #include "DFMemInfo.h"
using namespace DFHack; using namespace DFHack;

@ -5,7 +5,6 @@ Author: Alex Legg
Based on code from and uses DFHack - www.sourceforge.net/projects/dfhack Based on code from and uses DFHack - www.sourceforge.net/projects/dfhack
*/ */
//#include <DFCommonInternal.h>
#include <sstream> #include <sstream>
#include <iostream> #include <iostream>
#include <string.h> #include <string.h>