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
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
warranty. In no event will the authors be held liable for any

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

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

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

@ -25,23 +25,43 @@ distribution.
#ifndef DFCOMMONINTERNAL_H_INCLUDED
#define DFCOMMONINTERNAL_H_INCLUDED
// this makes everything that includes this file export symbols whn using DFHACK_EXPORT (see Export.h)
#define BUILD_DFHACK_LIB
// this makes everything that includes this file export symbols when using DFHACK_EXPORT (see Export.h)
#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"
// one file for telling the MSVC compiler where it can shove its pointless warnings
#include "Tranquility.h"
// basic stl containers and IO stuff
#include <string>
#include <vector>
#include <map>
#include <fstream>
#include <iostream>
using namespace std;
// C99 integer types
#include "integers.h"
// C includes
#include <assert.h>
#include <string.h>
#include <stdlib.h>
// platform includes and defines
#ifdef LINUX_BUILD
#include <sys/types.h>
#include <sys/ptrace.h>
@ -53,59 +73,26 @@ using namespace std;
#include <fcntl.h>
#include <sys/wait.h>
#else
// WINDOWS
#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
#include <windows.h>
//#include <winbase.h>
#include <winnt.h>
#include <psapi.h>
#include <tlhelp32.h>
#endif
#ifdef LINUX_BUILD
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>
// dfhack dependencies
#include <tinyxml.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
#define fill_char_buf(buf, str) strcpy_s((buf), sizeof(buf) / sizeof((buf)[0]), (str).c_str())
#else
#define fill_char_buf(buf, str) strncpy((buf), (str).c_str(), sizeof(buf) / sizeof((buf)[0]))
#endif
*/
#endif // DFCOMMONINTERNAL_H_INCLUDED

@ -1,6 +1,6 @@
/*
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
warranty. In no event will the authors be held liable for any
@ -34,21 +34,21 @@ typedef void DFHackObject;
extern "C" {
#endif
EXPORT DFHackObject* API_Alloc(const char* path_to_xml);
EXPORT void API_Free(DFHackObject* api);
DFHACK_EXPORT DFHackObject* API_Alloc(const char* path_to_xml);
DFHACK_EXPORT void API_Free(DFHackObject* api);
EXPORT int API_Attach(DFHackObject* api);
EXPORT int API_Detach(DFHackObject* api);
EXPORT int API_isAttached(DFHackObject* api);
DFHACK_EXPORT int API_Attach(DFHackObject* api);
DFHACK_EXPORT int API_Detach(DFHackObject* api);
DFHACK_EXPORT int API_isAttached(DFHackObject* api);
EXPORT int API_Suspend(DFHackObject* api);
EXPORT int API_Resume(DFHackObject* api);
EXPORT int API_isSuspended(DFHackObject* api);
EXPORT int API_ForceResume(DFHackObject* api);
EXPORT int API_AsyncSuspend(DFHackObject* api);
DFHACK_EXPORT int API_Suspend(DFHackObject* api);
DFHACK_EXPORT int API_Resume(DFHackObject* api);
DFHACK_EXPORT int API_isSuspended(DFHackObject* api);
DFHACK_EXPORT int API_ForceResume(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);
EXPORT void API_WriteRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* source);
DFHACK_EXPORT void API_ReadRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* target);
DFHACK_EXPORT void API_WriteRaw(DFHackObject* api, const uint32_t offset, const uint32_t size, uint8_t* source);
#ifdef __cplusplus
}

@ -23,23 +23,17 @@ distribution.
*/
#ifdef LINUX_BUILD
#ifndef DFHACK_EXPORT
#ifndef SWIGIMPORTED
#define DFHACK_EXPORT __attribute__ ((visibility("default")))
#else
#define DFHACK_EXPORT
#ifndef DFHACK_EXPORT
#define DFHACK_EXPORT __attribute__ ((visibility("default")))
#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
#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
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
warranty. In no event will the authors be held liable for any
@ -33,13 +33,13 @@ distribution.
extern "C" {
#endif
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_getViewCoords(DFHackObject* pos, int32_t* x, int32_t* y, 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);
EXPORT int Position_setCursorCoords(DFHackObject* pos, const int32_t x, const int32_t y, const int32_t z);
DFHACK_EXPORT int Position_getCursorCoords(DFHackObject* pos, int32_t* x, int32_t* y, 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
}

@ -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);
// 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
p->read (temp + offs.labors_offset, NUM_CREATURE_LABORS, furball.labors);

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

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