diff options
author | Haru <haru@dotalux.com> | 2015-06-15 20:52:44 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2015-08-15 00:51:42 +0200 |
commit | 51b7adcf4e5b2a347081ec9a6903102c4909a404 (patch) | |
tree | 39a080440b4bd78b786c8f9372f7883b55fd3ba9 /src/common | |
parent | f8edb93a6a26cd81eeaad0eac23e33da7740c8b4 (diff) | |
download | hercules-51b7adcf4e5b2a347081ec9a6903102c4909a404.tar.gz hercules-51b7adcf4e5b2a347081ec9a6903102c4909a404.tar.bz2 hercules-51b7adcf4e5b2a347081ec9a6903102c4909a404.tar.xz hercules-51b7adcf4e5b2a347081ec9a6903102c4909a404.zip |
HPM compatibility improvements
Improved compatibility, portability and standards conformance.
- Since it is not possible to portably and reliably re-use the core's
symbols in plugins, symbols are no longer exported unless explicitly
required, in the UNIX builds. This mimics the Windows behavior and
adds HPM compatibility to OSes such as FreeBSD. Credits to Andrei Karas
for making this possible.
- For convenience, it is no longer necessary to call GET_SYMBOL, since
the plugin will automatically import all the available symbols when
it's loaded, depending on the included headers.
- Plugins are now supposed to include the "common/hercules.h" header
before including anything else. Incluing common/HPMi.h,
common/cbasetypes.h or conf/core.h is no longer necessary, as those
are guaranteed to be automatically included by hercules.h.
- HPM API version bumped to 1.1.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common')
33 files changed, 141 insertions, 123 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c index d82faee1f..85f3d9e95 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -34,6 +34,7 @@ struct malloc_interface iMalloc_HPM; struct malloc_interface *HPMiMalloc; struct HPM_interface HPM_s; +struct HPM_interface *HPM; /** * (char*) data name -> (unsigned int) HPMDataCheck[] index @@ -95,28 +96,6 @@ struct hplugin *hplugin_create(void) { HPM->plugins[HPM->plugin_count - 1]->filename = NULL; return HPM->plugins[HPM->plugin_count - 1]; } -#define HPM_POP(x) { #x , x } -bool hplugin_populate(struct hplugin *plugin, const char *filename) { - struct { - const char* name; - void *Ref; - } ToLink[] = { - HPM_POP(showmsg), - }; - int i, length = ARRAYLENGTH(ToLink); - - for(i = 0; i < length; i++) { - void **Link; - if (!( Link = plugin_import(plugin->dll, ToLink[i].name,void **))) { - ShowFatalError("HPM:plugin_load: failed to retrieve '%s' for '"CL_WHITE"%s"CL_RESET"'!\n", ToLink[i].name, filename); - exit(EXIT_FAILURE); - } - *Link = ToLink[i].Ref; - } - - return true; -} -#undef HPM_POP struct hplugin *hplugin_load(const char* filename) { struct hplugin *plugin; struct hplugin_info *info; @@ -127,6 +106,7 @@ struct hplugin *hplugin_load(const char* filename) { int *HPMDataCheckVer; unsigned int *HPMDataCheckLen; struct s_HPMDataCheck *HPMDataCheck; + const char *(*HPMLoadEvent)(int server_type); if( HPM->exists(filename) ) { ShowWarning("HPM:plugin_load: attempting to load duplicate '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename); @@ -204,8 +184,17 @@ struct hplugin *hplugin_load(const char* filename) { exit(EXIT_FAILURE); } - if( !HPM->populate(plugin,filename) ) - return NULL; + if (!(HPMLoadEvent = plugin_import(plugin->dll, "HPM_shared_symbols", const char *(*)(int)))) { + ShowFatalError("HPM:plugin_load: failed to retrieve 'HPM_shared_symbols' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h!\n", filename); + exit(EXIT_FAILURE); + } + { + const char *failure = HPMLoadEvent(SERVER_TYPE); + if (failure) { + ShowFatalError("HPM:plugin_load: failed to import symbol '%s' into '"CL_WHITE"%s"CL_RESET"'.\n", failure, filename); + exit(EXIT_FAILURE); + } + } if( !( HPMDataCheckLen = plugin_import(plugin->dll, "HPMDataCheckLen", unsigned int *) ) ) { ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMDataCheckLen' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h!\n", filename); @@ -925,7 +914,6 @@ void hpm_defaults(void) { HPM->share = hplugin_export_symbol; HPM->symbol_defaults = hplugins_share_defaults; HPM->config_read = hplugins_config_read; - HPM->populate = hplugin_populate; HPM->symbol_defaults_sub = NULL; HPM->pid2name = hplugins_id2name; HPM->parse_packets = hplugins_parse_packets; diff --git a/src/common/HPM.h b/src/common/HPM.h index 1358f19dc..2d38a2bfa 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -8,8 +8,8 @@ #error You should never include HPM.h from a plugin. #endif +#include "common/hercules.h" #include "common/HPMi.h" -#include "common/cbasetypes.h" #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN @@ -131,7 +131,6 @@ struct HPM_interface { void (*share) (void *, char *); void (*symbol_defaults) (void); void (*config_read) (void); - bool (*populate) (struct hplugin *plugin,const char *filename); void (*symbol_defaults_sub) (void);//TODO drop char *(*pid2name) (unsigned int pid); unsigned char (*parse_packets) (int fd, enum HPluginPacketHookingPoints point); @@ -150,7 +149,7 @@ struct HPM_interface { CMDLINEARG(loadplugin); -struct HPM_interface *HPM; +extern struct HPM_interface *HPM; void hpm_defaults(void); diff --git a/src/common/HPMi.h b/src/common/HPMi.h index 2054657be..244a9e0ab 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -4,7 +4,7 @@ #ifndef COMMON_HPMI_H #define COMMON_HPMI_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/console.h" #include "common/core.h" #include "common/showmsg.h" @@ -15,13 +15,7 @@ struct AtCommandInfo; struct socket_data; struct map_session_data; -#ifdef WIN32 - #define HPExport __declspec(dllexport) -#else - #define HPExport -#endif - -#define HPM_VERSION "1.0" +#define HPM_VERSION "1.1" #define HPM_ADDCONF_LENGTH 40 struct hplugin_info { @@ -37,11 +31,6 @@ struct s_HPMDataCheck { int type; }; -HPExport void *(*import_symbol) (char *name, unsigned int pID); -HPExport Sql *mysql_handle; - -#define GET_SYMBOL(n) import_symbol((n),HPMi->pid) - #define SERVER_TYPE_ALL (SERVER_TYPE_LOGIN|SERVER_TYPE_CHAR|SERVER_TYPE_MAP) enum hp_event_types { @@ -226,6 +215,10 @@ struct HPMi_interface { #ifndef HERCULES_CORE HPExport struct HPMi_interface HPMi_s; HPExport struct HPMi_interface *HPMi; -#endif +HPExport void *(*import_symbol) (char *name, unsigned int pID); +HPExport Sql *mysql_handle; +#define HPM_SYMBOL(n, s) ((s) = import_symbol((n),HPMi->pid)) +#endif // !HERCULES_CORE + #endif /* COMMON_HPMI_H */ diff --git a/src/common/Makefile.in b/src/common/Makefile.in index f6f993165..208d3b111 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -32,9 +32,9 @@ COMMON_MINI_OBJ = $(addprefix obj_all/, $(COMMON_SHARED_OBJ) \ miniconsole.o minicore.o minimalloc.o minisocket.o) COMMON_C += console.c core.c malloc.c socket.c COMMON_H = atomic.h cbasetypes.h conf.h console.h core.h db.h des.h ers.h \ - grfio.h HPM.h HPMi.h malloc.h mapindex.h md5calc.h mmo.h mutex.h \ - nullpo.h random.h showmsg.h socket.h spinlock.h sql.h strlib.h \ - sysinfo.h thread.h timer.h utils.h winapi.h + grfio.h hercules.h HPM.h HPMi.h malloc.h mapindex.h md5calc.h \ + mmo.h mutex.h nullpo.h random.h showmsg.h socket.h spinlock.h \ + sql.h strlib.h sysinfo.h thread.h timer.h utils.h winapi.h COMMON_SQL_OBJ = obj_sql/sql.o COMMON_SQL_H = sql.h diff --git a/src/common/conf.c b/src/common/conf.c index cb0194c3a..d9367dc9e 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -12,7 +12,7 @@ /* interface source */ struct libconfig_interface libconfig_s; - +struct libconfig_interface *libconfig; int conf_read_file(config_t *config, const char *config_filename) { libconfig->init(config); diff --git a/src/common/conf.h b/src/common/conf.h index 49257835d..ac97a5427 100644 --- a/src/common/conf.h +++ b/src/common/conf.h @@ -5,7 +5,7 @@ #ifndef COMMON_CONF_H #define COMMON_CONF_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <libconfig/libconfig.h> @@ -91,10 +91,10 @@ struct libconfig_interface { int (*setting_copy) (config_setting_t *parent, const config_setting_t *src); }; -struct libconfig_interface *libconfig; - #ifdef HERCULES_CORE void libconfig_defaults(void); #endif // HERCULES_CORE +HPShared struct libconfig_interface *libconfig; + #endif // COMMON_CONF_H diff --git a/src/common/console.c b/src/common/console.c index 3b49204f6..5091d1a6c 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -37,6 +37,7 @@ #endif struct console_interface console_s; +struct console_interface *console; #ifdef CONSOLE_INPUT struct console_input_interface console_input_s; diff --git a/src/common/console.h b/src/common/console.h index 643edc3d9..ffb4a165b 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -4,9 +4,7 @@ #ifndef COMMON_CONSOLE_H #define COMMON_CONSOLE_H -#include "config/core.h" // MAX_CONSOLE_INPUT - -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/mutex.h" #include "common/spinlock.h" #include "common/sql.h" @@ -84,10 +82,10 @@ struct console_interface { struct console_input_interface *input; }; -struct console_interface *console; - #ifdef HERCULES_CORE void console_defaults(void); #endif // HERCULES_CORE +HPShared struct console_interface *console; + #endif /* COMMON_CONSOLE_H */ diff --git a/src/common/core.c b/src/common/core.c index e46c9589b..2f89d004e 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -361,6 +361,7 @@ void cmdline_final(void) } struct cmdline_interface cmdline_s; +struct cmdline_interface *cmdline; void cmdline_defaults(void) { diff --git a/src/common/core.h b/src/common/core.h index c2a8d9e58..b0f0449a3 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -5,7 +5,7 @@ #ifndef COMMON_CORE_H #define COMMON_CORE_H -#include "common/cbasetypes.h" +#include "common/hercules.h" /* so that developers with --enable-debug can raise signals from any section of the code they'd like */ #ifdef DEBUG @@ -28,27 +28,6 @@ enum E_CORE_ST { CORE_ST_LAST }; -#ifdef HERCULES_CORE -extern int arg_c; -extern char **arg_v; - -/// @see E_CORE_ST -extern int runflag; -extern char *SERVER_NAME; - -enum server_types SERVER_TYPE; - -extern void cmdline_args_init_local(void); -extern int do_init(int,char**); -extern void set_server_type(void); -extern void do_abort(void); -extern int do_final(void); - -/// Called when a terminate signal is received. (Ctrl+C pressed) -/// If NULL, runflag is set to CORE_ST_STOP instead. -extern void (*shutdown_callback)(void); -#endif // HERCULES_CORE - /// Options for command line argument handlers. enum cmdline_options { CMDLINE_OPT_NORMAL = 0x0, ///< No special options. @@ -78,10 +57,28 @@ struct cmdline_interface { const char *(*arg_source) (struct CmdlineArgData *arg); }; -struct cmdline_interface *cmdline; - #define CMDLINEARG(x) bool cmdline_arg_ ## x (const char *name, const char *params) + #ifdef HERCULES_CORE +extern int arg_c; +extern char **arg_v; + +/// @see E_CORE_ST +extern int runflag; +extern char *SERVER_NAME; + +enum server_types SERVER_TYPE; + +extern void cmdline_args_init_local(void); +extern int do_init(int,char**); +extern void set_server_type(void); +extern void do_abort(void); +extern int do_final(void); + +/// Called when a terminate signal is received. (Ctrl+C pressed) +/// If NULL, runflag is set to CORE_ST_STOP instead. +extern void (*shutdown_callback)(void); + /// Special plugin ID assigned to the Hercules core #define HPM_PID_CORE ((unsigned int)-1) @@ -91,4 +88,6 @@ struct cmdline_interface *cmdline; void cmdline_defaults(void); #endif // HERCULES_CORE +HPShared struct cmdline_interface *cmdline; + #endif /* COMMON_CORE_H */ diff --git a/src/common/db.c b/src/common/db.c index 5063425e6..4df5c08db 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -82,6 +82,7 @@ #include <stdlib.h> struct db_interface DB_s; +struct db_interface *DB; /*****************************************************************************\ * (1) Private typedefs, enums, structures, defines and global variables of * diff --git a/src/common/db.h b/src/common/db.h index f75cbd8dc..9b9cba8f8 100644 --- a/src/common/db.h +++ b/src/common/db.h @@ -42,7 +42,7 @@ #ifndef COMMON_DB_H #define COMMON_DB_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <stdarg.h> @@ -916,9 +916,6 @@ void (*init) (void); void (*final) (void); }; -struct db_interface *DB; - -void db_defaults(void); // Link DB System - From jAthena struct linkdb_node { struct linkdb_node *next; @@ -937,8 +934,11 @@ void* linkdb_erase (struct linkdb_node** head, void *key); void linkdb_final (struct linkdb_node** head); void linkdb_vforeach(struct linkdb_node** head, LinkDBFunc func, va_list ap); void linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...); + +void db_defaults(void); #endif // HERCULES_CORE +HPShared struct db_interface *DB; /// Finds an entry in an array. diff --git a/src/common/hercules.h b/src/common/hercules.h new file mode 100644 index 000000000..678577690 --- /dev/null +++ b/src/common/hercules.h @@ -0,0 +1,23 @@ +// Copyright (c) Hercules Dev Team, licensed under GNU GPL. +// See the LICENSE file +// Base author: Haru <haru@dotalux.com> + +#ifndef COMMON_HERCULES_H +#define COMMON_HERCULES_H + +#include "config/core.h" +#include "common/cbasetypes.h" + +#ifdef WIN32 + #define HPExport __declspec(dllexport) +#else + #define HPExport __attribute__((visibility("default"))) +#endif + +#define HPShared extern + +#ifndef HERCULES_CORE +#include "common/HPMi.h" +#endif // HERCULES_CORE + +#endif // COMMON_HERCULES_H diff --git a/src/common/malloc.c b/src/common/malloc.c index ec0467495..d5a979e77 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -16,6 +16,7 @@ #include <string.h> struct malloc_interface iMalloc_s; +struct malloc_interface *iMalloc; ////////////// Memory Libraries ////////////////// diff --git a/src/common/malloc.h b/src/common/malloc.h index 20260de84..b194c7cf3 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -4,7 +4,7 @@ #ifndef COMMON_MALLOC_H #define COMMON_MALLOC_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #define ALC_MARK __FILE__, __LINE__, __func__ @@ -59,12 +59,6 @@ //////////////////////////////////////////////// -#ifdef HERCULES_CORE -void malloc_defaults(void); - -void memmgr_report(int extra); -#endif // HERCULES_CORE - struct malloc_interface { void (*init) (void); void (*final) (void); @@ -84,5 +78,12 @@ struct malloc_interface { void (*init_messages) (void); }; -struct malloc_interface *iMalloc; +#ifdef HERCULES_CORE +void malloc_defaults(void); + +void memmgr_report(int extra); +#endif // HERCULES_CORE + +HPShared struct malloc_interface *iMalloc; + #endif /* COMMON_MALLOC_H */ diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 3d3ef52f1..aa31d8090 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -17,6 +17,7 @@ /* mapindex.c interface source */ struct mapindex_interface mapindex_s; +struct mapindex_interface *mapindex; /// Retrieves the map name from 'string' (removing .gat extension if present). /// Result gets placed either into 'buf' or in a static local buffer. diff --git a/src/common/mapindex.h b/src/common/mapindex.h index 74eea0aef..ff19630a1 100644 --- a/src/common/mapindex.h +++ b/src/common/mapindex.h @@ -5,7 +5,7 @@ #ifndef COMMON_MAPINDEX_H #define COMMON_MAPINDEX_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" @@ -95,10 +95,10 @@ struct mapindex_interface { bool (*check_default) (void); }; -struct mapindex_interface *mapindex; - #ifdef HERCULES_CORE void mapindex_defaults(void); #endif // HERCULES_CORE +HPShared struct mapindex_interface *mapindex; + #endif /* COMMON_MAPINDEX_H */ diff --git a/src/common/nullpo.c b/src/common/nullpo.c index 0db714ae1..829ba4aab 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -17,6 +17,7 @@ #endif // HAVE_EXECINFO struct nullpo_interface nullpo_s; +struct nullpo_interface *nullpo; /** * Reports failed assertions or NULL pointers diff --git a/src/common/nullpo.h b/src/common/nullpo.h index a59c2ac2b..52e9fba39 100644 --- a/src/common/nullpo.h +++ b/src/common/nullpo.h @@ -5,7 +5,7 @@ #ifndef COMMON_NULLPO_H #define COMMON_NULLPO_H -#include "common/cbasetypes.h" +#include "common/hercules.h" // enabled by default on debug builds #if defined(DEBUG) && !defined(NULLPO_CHECK) @@ -127,10 +127,10 @@ struct nullpo_interface { void (*assert_report) (const char *file, int line, const char *func, const char *targetname, const char *title); }; -struct nullpo_interface *nullpo; - #ifdef HERCULES_CORE void nullpo_defaults(void); #endif // HERCULES_CORE +HPShared struct nullpo_interface *nullpo; + #endif /* COMMON_NULLPO_H */ diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 68af31917..27fb0b635 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -31,6 +31,7 @@ #endif struct showmsg_interface showmsg_s; +struct showmsg_interface *showmsg; /////////////////////////////////////////////////////////////////////////////// /// static/dynamic buffer for the messages diff --git a/src/common/showmsg.h b/src/common/showmsg.h index 6b119a1ce..728691ba3 100644 --- a/src/common/showmsg.h +++ b/src/common/showmsg.h @@ -5,7 +5,7 @@ #ifndef COMMON_SHOWMSG_H #define COMMON_SHOWMSG_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <libconfig/libconfig.h> @@ -105,10 +105,8 @@ struct showmsg_interface { void (*showConfigWarning) (config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); }; -struct showmsg_interface *showmsg; - /* the purpose of these macros is simply to not make calling them be an annoyance */ -#define ClearScreen() (showMsg->clearScreen()) +#define ClearScreen() (showmsg->clearScreen()) #define vShowMessage(fmt, list) (showmsg->showMessageV((fmt), (list))) #define ShowMessage(fmt, ...) (showmsg->showMessage((fmt), ##__VA_ARGS__)) #define ShowStatus(fmt, ...) (showmsg->showStatus((fmt), ##__VA_ARGS__)) @@ -123,6 +121,8 @@ struct showmsg_interface *showmsg; #ifdef HERCULES_CORE void showmsg_defaults(void); -#endif +#endif // HERCULES_CORE + +HPShared struct showmsg_interface *showmsg; #endif /* COMMON_SHOWMSG_H */ diff --git a/src/common/socket.c b/src/common/socket.c index 098fdf236..c4cc4a329 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -55,6 +55,9 @@ * Socket Interface Source **/ struct socket_interface sockt_s; +struct socket_interface *sockt; + +struct socket_data **session; #ifdef SEND_SHORTLIST // Add a fd to the shortlist so that it'll be recognized as a fd that needs diff --git a/src/common/socket.h b/src/common/socket.h index 18bf25178..a995bffc8 100644 --- a/src/common/socket.h +++ b/src/common/socket.h @@ -5,7 +5,7 @@ #ifndef COMMON_SOCKET_H #define COMMON_SOCKET_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include "common/conf.h" #ifdef WIN32 @@ -193,10 +193,10 @@ struct socket_interface { void (*net_config_read) (const char *filename); }; -struct socket_interface *sockt; - #ifdef HERCULES_CORE void socket_defaults(void); #endif // HERCULES_CORE +HPShared struct socket_interface *sockt; + #endif /* COMMON_SOCKET_H */ diff --git a/src/common/sql.c b/src/common/sql.c index a93092533..0ca51e272 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -24,6 +24,7 @@ int mysql_reconnect_type; unsigned int mysql_reconnect_count; struct sql_interface sql_s; +struct sql_interface *SQL; /// Sql handle struct Sql { diff --git a/src/common/sql.h b/src/common/sql.h index d76b4f9d4..7fb4aabe8 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -5,7 +5,7 @@ #ifndef COMMON_SQL_H #define COMMON_SQL_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <stdarg.h>// va_list @@ -269,8 +269,6 @@ struct sql_interface { }; -struct sql_interface *SQL; - #ifdef HERCULES_CORE void sql_defaults(void); @@ -280,6 +278,8 @@ void Sql_HerculesUpdateCheck(Sql* self); void Sql_HerculesUpdateSkip(Sql* self,const char *filename); #endif // HERCULES_CORE +HPShared struct sql_interface *SQL; + #if defined(SQL_REMOVE_SHOWDEBUG) #define Sql_ShowDebug(self) (void)0 #else diff --git a/src/common/strlib.c b/src/common/strlib.c index abef22d48..024b73e59 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -20,6 +20,10 @@ struct strlib_interface strlib_s; struct stringbuf_interface stringbuf_s; struct sv_interface sv_s; +struct strlib_interface *strlib; +struct stringbuf_interface *StrBuf; +struct sv_interface *sv; + // escapes a string in-place (' -> \' , \ -> \\ , % -> _) char* jstrescape (char* pt) { //copy from here diff --git a/src/common/strlib.h b/src/common/strlib.h index cd7b90b08..cd9e105fb 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -5,7 +5,7 @@ #ifndef COMMON_STRLIB_H #define COMMON_STRLIB_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <stdarg.h> #include <string.h> @@ -112,8 +112,6 @@ struct strlib_interface { bool (*bin2hex_) (char* output, unsigned char* input, size_t count); }; -struct strlib_interface *strlib; - struct stringbuf_interface { StringBuf* (*Malloc) (void); void (*Init) (StringBuf* self); @@ -128,8 +126,6 @@ struct stringbuf_interface { void (*Free) (StringBuf* self); }; -struct stringbuf_interface *StrBuf; - struct sv_interface { /// Parses a single field in a delim-separated string. /// The delimiter after the field is skipped. @@ -172,10 +168,12 @@ struct sv_interface { bool (*readdb) (const char* directory, const char* filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char* fields[], int columns, int current)); }; -struct sv_interface *sv; - #ifdef HERCULES_CORE void strlib_defaults(void); #endif // HERCULES_CORE +HPShared struct strlib_interface *strlib; +HPShared struct stringbuf_interface *StrBuf; +HPShared struct sv_interface *sv; + #endif /* COMMON_STRLIB_H */ diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index 105f300ad..d218e6e99 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -40,6 +40,8 @@ struct sysinfo_private { struct sysinfo_interface sysinfo_s; struct sysinfo_private sysinfo_p; +struct sysinfo_interface *sysinfo; + #define VCSTYPE_UNKNOWN 0 #define VCSTYPE_GIT 1 #define VCSTYPE_SVN 2 diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h index 3c0d01ca1..7d47398a3 100644 --- a/src/common/sysinfo.h +++ b/src/common/sysinfo.h @@ -11,7 +11,7 @@ * cached at compile time) */ -#include "common/cbasetypes.h" +#include "common/hercules.h" struct sysinfo_private; @@ -44,10 +44,10 @@ struct sysinfo_interface { void (*final) (void); }; -struct sysinfo_interface *sysinfo; - #ifdef HERCULES_CORE void sysinfo_defaults(void); #endif // HERCULES_CORE +HPShared struct sysinfo_interface *sysinfo; + #endif /* COMMON_SYSINFO_H */ diff --git a/src/common/timer.c b/src/common/timer.c index 06309642e..793706511 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -24,6 +24,7 @@ #include <string.h> struct timer_interface timer_s; +struct timer_interface *timer; // If the server can't handle processing thousands of monsters // or many connected clients, please increase TIMER_MIN_INTERVAL. diff --git a/src/common/timer.h b/src/common/timer.h index 46a036ec7..c00a4362b 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -5,7 +5,7 @@ #ifndef COMMON_TIMER_H #define COMMON_TIMER_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #define DIFF_TICK(a,b) ((a)-(b)) #define DIFF_TICK32(a,b) ((int32)((a)-(b))) @@ -63,10 +63,10 @@ struct timer_interface { void (*final) (void); }; -struct timer_interface *timer; - #ifdef HERCULES_CORE void timer_defaults(void); #endif // HERCULES_CORE +HPShared struct timer_interface *timer; + #endif /* COMMON_TIMER_H */ diff --git a/src/common/utils.c b/src/common/utils.c index 07e2e9fdf..3606c6755 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -29,6 +29,7 @@ #include <sys/stat.h> // cache purposes [Ind/Hercules] struct HCache_interface HCache_s; +struct HCache_interface *HCache; /// Dumps given buffer into file pointed to by a handle. void WriteDump(FILE* fp, const void* buffer, size_t length) diff --git a/src/common/utils.h b/src/common/utils.h index e2b0dacc9..6296f6235 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -5,7 +5,7 @@ #ifndef COMMON_UTILS_H #define COMMON_UTILS_H -#include "common/cbasetypes.h" +#include "common/hercules.h" #include <stdio.h> // FILE* @@ -68,10 +68,10 @@ struct HCache_interface { bool enabled; }; -struct HCache_interface *HCache; - #ifdef HERCULES_CORE void HCache_defaults(void); #endif // HERCULES_CORE +HPShared struct HCache_interface *HCache; + #endif /* COMMON_UTILS_H */ |