summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/conf.h2
-rw-r--r--src/common/console.c5
-rw-r--r--src/common/console.h7
-rw-r--r--src/common/core.h30
-rw-r--r--src/common/db.h2
-rw-r--r--src/common/des.h4
-rw-r--r--src/common/ers.h2
-rw-r--r--src/common/grfio.h2
-rw-r--r--src/common/malloc.h6
-rw-r--r--src/common/mapindex.h2
-rw-r--r--src/common/md5calc.h2
-rw-r--r--src/common/mutex.h3
-rw-r--r--src/common/nullpo.h2
-rw-r--r--src/common/random.h2
-rw-r--r--src/common/showmsg.h16
-rw-r--r--src/common/socket.h2
-rw-r--r--src/common/spinlock.h5
-rw-r--r--src/common/sql.h12
-rw-r--r--src/common/strlib.h2
-rw-r--r--src/common/sysinfo.h2
-rw-r--r--src/common/thread.h5
-rw-r--r--src/common/timer.h2
-rw-r--r--src/common/utils.h10
23 files changed, 81 insertions, 46 deletions
diff --git a/src/common/conf.h b/src/common/conf.h
index 9ea5f5b72..bd97d5c1e 100644
--- a/src/common/conf.h
+++ b/src/common/conf.h
@@ -93,6 +93,8 @@ struct libconfig_interface {
struct libconfig_interface *libconfig;
+#ifdef HERCULES_CORE
void libconfig_defaults(void);
+#endif // HERCULES_CORE
#endif // COMMON_CONF_H
diff --git a/src/common/console.c b/src/common/console.c
index 6c5a5c886..0b1b9cf93 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -40,6 +40,11 @@
struct console_interface console_s;
#ifdef CONSOLE_INPUT
struct console_input_interface console_input_s;
+
+struct {
+ char queue[CONSOLE_PARSE_SIZE][MAX_CONSOLE_INPUT];
+ unsigned short count;
+} cinput;
#endif
/*======================================
diff --git a/src/common/console.h b/src/common/console.h
index 062d48bbe..3d3c8e9dd 100644
--- a/src/common/console.h
+++ b/src/common/console.h
@@ -44,11 +44,6 @@ struct CParseEntry {
unsigned short next_count;
};
-struct {
- char queue[CONSOLE_PARSE_SIZE][MAX_CONSOLE_INPUT];
- unsigned short count;
-} cinput;
-
#ifdef CONSOLE_INPUT
struct console_input_interface {
/* vars */
@@ -91,6 +86,8 @@ struct console_interface {
struct console_interface *console;
+#ifdef HERCULES_CORE
void console_defaults(void);
+#endif // HERCULES_CORE
#endif /* COMMON_CONSOLE_H */
diff --git a/src/common/core.h b/src/common/core.h
index a8337e1b9..025f636e9 100644
--- a/src/common/core.h
+++ b/src/common/core.h
@@ -13,15 +13,8 @@
# include <signal.h>
#endif
-extern int arg_c;
-extern char **arg_v;
-
#define HERC_UNKNOWN_VER '\x02'
-/// @see E_CORE_ST
-extern int runflag;
-extern char *SERVER_NAME;
-
enum server_types {
SERVER_TYPE_UNKNOWN = 0x0,
SERVER_TYPE_LOGIN = 0x1,
@@ -29,13 +22,6 @@ enum server_types {
SERVER_TYPE_MAP = 0x4,
};
-enum server_types SERVER_TYPE;
-
-extern int do_init(int,char**);
-extern void set_server_type(void);
-extern void do_abort(void);
-extern int do_final(void);
-
/// The main loop continues until runflag is CORE_ST_STOP
enum E_CORE_ST {
CORE_ST_STOP = 0,
@@ -43,8 +29,24 @@ 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 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
#endif /* COMMON_CORE_H */
diff --git a/src/common/db.h b/src/common/db.h
index 88265c3e8..cd61e1543 100644
--- a/src/common/db.h
+++ b/src/common/db.h
@@ -929,6 +929,7 @@ struct linkdb_node {
typedef void (*LinkDBFunc)(void* key, void* data, va_list args);
+#ifdef HERCULES_CORE
void linkdb_insert (struct linkdb_node** head, void *key, void* data); // Doesn't take into account duplicate keys
void linkdb_replace (struct linkdb_node** head, void *key, void* data); // Takes into account duplicate keys
void* linkdb_search (struct linkdb_node** head, void *key);
@@ -936,6 +937,7 @@ 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, ...);
+#endif // HERCULES_CORE
diff --git a/src/common/des.h b/src/common/des.h
index 2c7190f23..9e6aec4fd 100644
--- a/src/common/des.h
+++ b/src/common/des.h
@@ -8,9 +8,9 @@
/// One 64-bit block.
typedef struct BIT64 { uint8_t b[8]; } BIT64;
-
+#ifdef HERCULES_CORE
void des_decrypt_block(BIT64* block);
void des_decrypt(unsigned char* data, size_t size);
-
+#endif // HERCULES_CORE
#endif // COMMON_DES_H
diff --git a/src/common/ers.h b/src/common/ers.h
index 8c56118ae..85ddfed7a 100644
--- a/src/common/ers.h
+++ b/src/common/ers.h
@@ -148,6 +148,7 @@ typedef struct eri {
# define ers_destroy(obj) ((obj)->destroy(obj))
# define ers_chunk_size(obj,size) ((obj)->chunk_size((obj),(size)))
+#ifdef HERCULES_CORE
/**
* Get a new instance of the manager that handles the specified entry size.
* Size has to greater than 0.
@@ -173,6 +174,7 @@ void ers_report(void);
* Clears the remainder of the managers
**/
void ers_final(void);
+#endif // HERCULES_CORE
#endif /* DISABLE_ERS / not DISABLE_ERS */
#endif /* COMMON_ERS_H */
diff --git a/src/common/grfio.h b/src/common/grfio.h
index 15659c17c..adffe0990 100644
--- a/src/common/grfio.h
+++ b/src/common/grfio.h
@@ -4,6 +4,7 @@
#ifndef COMMON_GRFIO_H
#define COMMON_GRFIO_H
+#ifdef HERCULES_CORE
void grfio_init(const char* fname);
void grfio_final(void);
void* grfio_reads(const char* fname, int* size);
@@ -13,5 +14,6 @@ char* grfio_find_file(const char* fname);
unsigned long grfio_crc32(const unsigned char *buf, unsigned int len);
int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen);
int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen);
+#endif // HERCULES_CORE
#endif /* COMMON_GRFIO_H */
diff --git a/src/common/malloc.h b/src/common/malloc.h
index 53d2ebdd2..bc79ac65a 100644
--- a/src/common/malloc.h
+++ b/src/common/malloc.h
@@ -65,8 +65,12 @@
//void malloc_init (void);
//void malloc_final (void);
+#ifdef HERCULES_CORE
void malloc_defaults(void);
+void memmgr_report(int extra);
+#endif // HERCULES_CORE
+
struct malloc_interface {
void (*init) (void);
void (*final) (void);
@@ -85,7 +89,5 @@ struct malloc_interface {
void (*post_shutdown) (void);
};
-void memmgr_report (int extra);
-
struct malloc_interface *iMalloc;
#endif /* COMMON_MALLOC_H */
diff --git a/src/common/mapindex.h b/src/common/mapindex.h
index 8e552261a..87a275f57 100644
--- a/src/common/mapindex.h
+++ b/src/common/mapindex.h
@@ -96,6 +96,8 @@ struct mapindex_interface {
struct mapindex_interface *mapindex;
+#ifdef HERCULES_CORE
void mapindex_defaults(void);
+#endif // HERCULES_CORE
#endif /* COMMON_MAPINDEX_H */
diff --git a/src/common/md5calc.h b/src/common/md5calc.h
index 740e2edcc..f06a01f4d 100644
--- a/src/common/md5calc.h
+++ b/src/common/md5calc.h
@@ -1,8 +1,10 @@
#ifndef COMMON_MD5CALC_H
#define COMMON_MD5CALC_H
+#ifdef HERCULES_CORE
void MD5_String(const char * string, char * output);
void MD5_Binary(const char * string, unsigned char * output);
void MD5_Salt(unsigned int len, char * output);
+#endif // HERCULES_CORE
#endif /* COMMON_MD5CALC_H */
diff --git a/src/common/mutex.h b/src/common/mutex.h
index d298c05af..fa8170c98 100644
--- a/src/common/mutex.h
+++ b/src/common/mutex.h
@@ -9,6 +9,7 @@
typedef struct ramutex ramutex; // Mutex
typedef struct racond racond; // Condition Var
+#ifdef HERCULES_CORE
/**
* Creates a Mutex
*
@@ -88,6 +89,6 @@ void racond_signal(racond *c);
* All Waiters getting notified.
*/
void racond_broadcast(racond *c);
-
+#endif // HERCULES_CORE
#endif /* COMMON_MUTEX_H */
diff --git a/src/common/nullpo.h b/src/common/nullpo.h
index 581252cca..407f45403 100644
--- a/src/common/nullpo.h
+++ b/src/common/nullpo.h
@@ -123,6 +123,8 @@
if (Assert_chk(t)) break; else (void)0
+#ifdef HERCULES_CORE
void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title);
+#endif // HERCULES_CORE
#endif /* COMMON_NULLPO_H */
diff --git a/src/common/random.h b/src/common/random.h
index 15d7f8ab1..0ca375d28 100644
--- a/src/common/random.h
+++ b/src/common/random.h
@@ -6,6 +6,7 @@
#include "../common/cbasetypes.h"
+#ifdef HERCULES_CORE
void rnd_init(void);
void rnd_seed(uint32);
@@ -14,5 +15,6 @@ uint32 rnd_roll(uint32 dice_faces);// [0, dice_faces)
int32 rnd_value(int32 min, int32 max);// [min, max]
double rnd_uniform(void);// [0.0, 1.0)
double rnd_uniform53(void);// [0.0, 1.0)
+#endif // HERCULES_CORE
#endif /* COMMON_RANDOM_H */
diff --git a/src/common/showmsg.h b/src/common/showmsg.h
index f3fb50257..48e763c25 100644
--- a/src/common/showmsg.h
+++ b/src/common/showmsg.h
@@ -76,11 +76,6 @@
#define CL_SPACE " " // space equivalent of the print messages
-extern int stdout_with_ansisequence; //If the color ANSI sequences are to be used. [flaviojs]
-extern int msg_silent; //Specifies how silent the console is. [Skotlex]
-extern int console_msg_log; //Specifies what error messages to log. [Ind]
-extern char timestamp_format[20]; //For displaying Timestamps [Skotlex]
-
enum msg_type {
MSG_NONE,
MSG_STATUS,
@@ -93,8 +88,15 @@ enum msg_type {
MSG_FATALERROR
};
-extern void ClearScreen(void);
#ifdef HERCULES_CORE
+extern int stdout_with_ansisequence; //If the color ANSI sequences are to be used. [flaviojs]
+extern int msg_silent; //Specifies how silent the console is. [Skotlex]
+extern int console_msg_log; //Specifies what error messages to log. [Ind]
+extern char timestamp_format[20]; //For displaying Timestamps [Skotlex]
+
+extern void ClearScreen(void);
+extern int vShowMessage_(enum msg_type flag, const char *string, va_list ap);
+
extern void ShowMessage(const char *, ...) __attribute__((format(printf, 1, 2)));
extern void ShowStatus(const char *, ...) __attribute__((format(printf, 1, 2)));
extern void ShowSQL(const char *, ...) __attribute__((format(printf, 1, 2)));
@@ -117,6 +119,4 @@ extern void ClearScreen(void);
HPExport void (*ShowFatalError) (const char *, ...) __attribute__((format(printf, 1, 2)));
#endif
-extern int vShowMessage_(enum msg_type flag, const char *string, va_list ap);
-
#endif /* COMMON_SHOWMSG_H */
diff --git a/src/common/socket.h b/src/common/socket.h
index b9c562a29..6323a6862 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -171,7 +171,9 @@ struct socket_interface {
struct socket_interface *sockt;
+#ifdef HERCULES_CORE
void socket_defaults(void);
+#endif // HERCULES_CORE
/* the purpose of these macros is simply to not make calling them be an annoyance */
#ifndef H_SOCKET_C
diff --git a/src/common/spinlock.h b/src/common/spinlock.h
index 85a78ed33..413067b68 100644
--- a/src/common/spinlock.h
+++ b/src/common/spinlock.h
@@ -39,7 +39,7 @@ typedef struct SPIN_LOCK{
#endif
-
+#ifdef HERCULES_CORE
static forceinline void InitializeSpinLock(SPIN_LOCK *lck){
lck->lock = 0;
lck->nest = 0;
@@ -93,7 +93,6 @@ static forceinline void LeaveSpinLock(SPIN_LOCK *lck){
dropsynclock(&lck->sync_lock);
}
-
-
+#endif // HERCULES_CORE
#endif /* COMMON_SPINLOCK_H */
diff --git a/src/common/sql.h b/src/common/sql.h
index 9a79b3f33..c3598273e 100644
--- a/src/common/sql.h
+++ b/src/common/sql.h
@@ -271,17 +271,21 @@ struct sql_interface {
struct sql_interface *SQL;
+#ifdef HERCULES_CORE
void sql_defaults(void);
+void Sql_Init(void);
+
+void Sql_HerculesUpdateCheck(Sql* self);
+void Sql_HerculesUpdateSkip(Sql* self,const char *filename);
+#endif // HERCULES_CORE
+
#if defined(SQL_REMOVE_SHOWDEBUG)
#define Sql_ShowDebug(self) (void)0
#else
#define Sql_ShowDebug(self) (SQL->ShowDebug_((self), __FILE__, __LINE__))
#endif
-void Sql_HerculesUpdateCheck(Sql* self);
-void Sql_HerculesUpdateSkip(Sql* self,const char *filename);
-
#if defined(SQL_REMOVE_SHOWDEBUG)
#define SqlStmt_ShowDebug(self) (void)0
#else
@@ -289,6 +293,4 @@ void Sql_HerculesUpdateSkip(Sql* self,const char *filename);
#define SqlStmt_ShowDebug(self) (SQL->StmtShowDebug_((self), __FILE__, __LINE__))
#endif
-void Sql_Init(void);
-
#endif /* COMMON_SQL_H */
diff --git a/src/common/strlib.h b/src/common/strlib.h
index 0c596cb8f..c687d9e17 100644
--- a/src/common/strlib.h
+++ b/src/common/strlib.h
@@ -156,7 +156,9 @@ struct sv_interface {
struct sv_interface *sv;
+#ifdef HERCULES_CORE
void strlib_defaults(void);
+#endif // HERCULES_CORE
/* the purpose of these macros is simply to not make calling them be an annoyance */
#ifndef H_STRLIB_C
diff --git a/src/common/sysinfo.h b/src/common/sysinfo.h
index 600206a21..70f665071 100644
--- a/src/common/sysinfo.h
+++ b/src/common/sysinfo.h
@@ -46,6 +46,8 @@ struct sysinfo_interface {
struct sysinfo_interface *sysinfo;
+#ifdef HERCULES_CORE
void sysinfo_defaults(void);
+#endif // HERCULES_CORE
#endif /* COMMON_SYSINFO_H */
diff --git a/src/common/thread.h b/src/common/thread.h
index f00e7290d..f79eb77f9 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -16,6 +16,7 @@ typedef enum RATHREAD_PRIO {
} RATHREAD_PRIO;
+#ifdef HERCULES_CORE
/**
* Creates a new Thread
*
@@ -109,10 +110,8 @@ RATHREAD_PRIO rathread_prio_get(rAthread *handle);
*/
void rathread_yield(void);
-
-
void rathread_init(void);
void rathread_final(void);
-
+#endif // HERCULES_CORE
#endif /* COMMON_THREAD_H */
diff --git a/src/common/timer.h b/src/common/timer.h
index d0927adde..6e8a72389 100644
--- a/src/common/timer.h
+++ b/src/common/timer.h
@@ -65,6 +65,8 @@ struct timer_interface {
struct timer_interface *timer;
+#ifdef HERCULES_CORE
void timer_defaults(void);
+#endif // HERCULES_CORE
#endif /* COMMON_TIMER_H */
diff --git a/src/common/utils.h b/src/common/utils.h
index 421698d95..e6102f184 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -13,6 +13,10 @@
/* [HCache] 1-byte key to ensure our method is the latest, we can modify to ensure the method matches */
#define HCACHE_KEY 'k'
+//Caps values to min/max
+#define cap_value(a, min, max) (((a) >= (max)) ? (max) : ((a) <= (min)) ? (min) : (a))
+
+#ifdef HERCULES_CORE
// generate a hex dump of the first 'length' bytes of 'buffer'
void WriteDump(FILE* fp, const void* buffer, size_t length);
void ShowDump(const void* buffer, size_t length);
@@ -20,9 +24,6 @@ void ShowDump(const void* buffer, size_t length);
void findfile(const char *p, const char *pat, void (func)(const char*));
bool exists(const char* filename);
-//Caps values to min/max
-#define cap_value(a, min, max) (((a) >= (max)) ? (max) : ((a) <= (min)) ? (min) : (a))
-
/// calculates the value of A / B, in percent (rounded down)
unsigned int get_percentage(const unsigned int A, const unsigned int B);
@@ -49,6 +50,7 @@ extern float GetFloat(const unsigned char* buf);
size_t hread(void * ptr, size_t size, size_t count, FILE * stream);
size_t hwrite(const void * ptr, size_t size, size_t count, FILE * stream);
+#endif // HERCULES_CORE
/* [Ind/Hercules] Caching */
struct HCache_interface {
@@ -63,6 +65,8 @@ struct HCache_interface {
struct HCache_interface *HCache;
+#ifdef HERCULES_CORE
void HCache_defaults(void);
+#endif // HERCULES_CORE
#endif /* COMMON_UTILS_H */