summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-06-24 00:13:59 +0200
committerHaru <haru@dotalux.com>2018-07-01 21:09:24 +0200
commit8dd7aec896efc0220d6234bcfb190767c30dbb29 (patch)
tree0fd1b8d2b795c01b4a6fddc3827784d26d09cc61 /src
parentec1bc50b01aa4f34f151b3b3800011abdce31919 (diff)
downloadhercules-8dd7aec896efc0220d6234bcfb190767c30dbb29.tar.gz
hercules-8dd7aec896efc0220d6234bcfb190767c30dbb29.tar.bz2
hercules-8dd7aec896efc0220d6234bcfb190767c30dbb29.tar.xz
hercules-8dd7aec896efc0220d6234bcfb190767c30dbb29.zip
Change functions to static where possible (Part 1 - common)
This fixes issues with plugins defining symbols with the same names Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r--src/common/HPM.c95
-rw-r--r--src/common/conf.c44
-rw-r--r--src/common/console.c50
-rw-r--r--src/common/core.c26
-rw-r--r--src/common/db.c58
-rw-r--r--src/common/des.c6
-rw-r--r--src/common/ers.c2
-rw-r--r--src/common/grfio.c32
-rw-r--r--src/common/mapindex.c20
-rw-r--r--src/common/md5calc.c6
-rw-r--r--src/common/memmgr.c82
-rw-r--r--src/common/mutex.c22
-rw-r--r--src/common/nullpo.c8
-rw-r--r--src/common/random.c18
-rw-r--r--src/common/showmsg.c72
-rw-r--r--src/common/socket.c133
-rw-r--r--src/common/sql.c88
-rw-r--r--src/common/strlib.c101
-rw-r--r--src/common/sysinfo.c54
-rw-r--r--src/common/thread.c29
-rw-r--r--src/common/timer.c79
-rw-r--r--src/common/utils.c30
22 files changed, 562 insertions, 493 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c
index c84b447e8..300edf60a 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -48,25 +48,25 @@
# include <unistd.h>
#endif
-struct malloc_interface iMalloc_HPM;
-struct malloc_interface *HPMiMalloc;
-struct HPM_interface HPM_s;
+static struct malloc_interface iMalloc_HPM;
+static struct malloc_interface *HPMiMalloc;
+static struct HPM_interface HPM_s;
struct HPM_interface *HPM;
-struct HPMHooking_core_interface HPMHooking_core_s;
+static struct HPMHooking_core_interface HPMHooking_core_s;
/**
* (char*) data name -> (unsigned int) HPMDataCheck[] index
**/
-struct DBMap *datacheck_db;
-int datacheck_version;
-const struct s_HPMDataCheck *datacheck_data;
+static struct DBMap *datacheck_db;
+static int datacheck_version;
+static const struct s_HPMDataCheck *datacheck_data;
/**
* Executes an event on all loaded plugins.
*
* @param type The event type to trigger.
*/
-void hplugin_trigger_event(enum hp_event_types type)
+static void hplugin_trigger_event(enum hp_event_types type)
{
int i;
for (i = 0; i < VECTOR_LENGTH(HPM->plugins); i++) {
@@ -82,7 +82,7 @@ void hplugin_trigger_event(enum hp_event_types type)
* @param value The symbol value.
* @param name The symbol name.
*/
-void hplugin_export_symbol(void *value, const char *name)
+static void hplugin_export_symbol(void *value, const char *name)
{
struct hpm_symbol *symbol = NULL;
CREATE(symbol ,struct hpm_symbol, 1);
@@ -100,7 +100,7 @@ void hplugin_export_symbol(void *value, const char *name)
* @return The symbol value.
* @retval NULL if the symbol wasn't found.
*/
-void *hplugin_import_symbol(char *name, unsigned int pID)
+static void *hplugin_import_symbol(char *name, unsigned int pID)
{
int i;
nullpo_retr(NULL, name);
@@ -113,7 +113,8 @@ void *hplugin_import_symbol(char *name, unsigned int pID)
return NULL;
}
-bool hplugin_iscompatible(char* version) {
+static bool hplugin_iscompatible(char *version)
+{
unsigned int req_major = 0, req_minor = 0;
if( version == NULL )
@@ -131,7 +132,7 @@ bool hplugin_iscompatible(char* version) {
* @retval true if the plugin exists and is currently loaded.
* @retval false otherwise.
*/
-bool hplugin_exists(const char *filename)
+static bool hplugin_exists(const char *filename)
{
int i;
nullpo_retr(false, filename);
@@ -147,7 +148,7 @@ bool hplugin_exists(const char *filename)
*
* @return A (retained) pointer to the initialized data.
*/
-struct hplugin *hplugin_create(void)
+static struct hplugin *hplugin_create(void)
{
struct hplugin *plugin = NULL;
CREATE(plugin, struct hplugin, 1);
@@ -158,7 +159,7 @@ struct hplugin *hplugin_create(void)
return plugin;
}
-bool hplugins_addpacket(unsigned short cmd, unsigned short length, void (*receive) (int fd), unsigned int point, unsigned int pluginID)
+static bool hplugins_addpacket(unsigned short cmd, unsigned short length, void (*receive) (int fd), unsigned int point, unsigned int pluginID)
{
struct HPluginPacket *packet;
int i;
@@ -204,7 +205,7 @@ bool hplugins_addpacket(unsigned short cmd, unsigned short length, void (*receiv
* initialized through \c HPM->data_store_create() and ownership is passed
* to the caller.
*/
-bool hplugin_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize)
+static bool hplugin_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize)
{
struct hplugin_data_store *store;
nullpo_retr(false, storeptr);
@@ -248,7 +249,7 @@ bool hplugin_data_store_validate(enum HPluginDataTypes type, struct hplugin_data
* @param classid[in] The entry class identifier.
* @param autofree[in] Whether the entry should be automatically freed when removed.
*/
-void hplugins_addToHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store **storeptr, void *data, uint32 classid, bool autofree)
+static void hplugins_addToHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store **storeptr, void *data, uint32 classid, bool autofree)
{
struct hplugin_data_store *store;
struct hplugin_data_entry *entry;
@@ -293,7 +294,7 @@ void hplugins_addToHPData(enum HPluginDataTypes type, uint32 pluginID, struct hp
*
* @return The retrieved entry, or NULL.
*/
-void *hplugins_getFromHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store *store, uint32 classid)
+static void *hplugins_getFromHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store *store, uint32 classid)
{
int i;
@@ -320,7 +321,7 @@ void *hplugins_getFromHPData(enum HPluginDataTypes type, uint32 pluginID, struct
* @param store[in] The store.
* @param classid[in] The entry class identifier.
*/
-void hplugins_removeFromHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store *store, uint32 classid)
+static void hplugins_removeFromHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store *store, uint32 classid)
{
struct hplugin_data_entry *entry;
int i;
@@ -344,7 +345,7 @@ void hplugins_removeFromHPData(enum HPluginDataTypes type, uint32 pluginID, stru
}
/* TODO: add ability for tracking using pID for the upcoming runtime load/unload support. */
-bool HPM_AddHook(enum HPluginHookType type, const char *target, void *hook, unsigned int pID)
+static bool HPM_AddHook(enum HPluginHookType type, const char *target, void *hook, unsigned int pID)
{
if (!HPM->hooking->enabled) {
ShowError("HPM:AddHook Fail! '%s' tried to hook to '%s' but HPMHooking is disabled!\n",HPM->pid2name(pID),target);
@@ -360,13 +361,13 @@ bool HPM_AddHook(enum HPluginHookType type, const char *target, void *hook, unsi
return false;
}
-void HPM_HookStop(const char *func, unsigned int pID)
+static void HPM_HookStop(const char *func, unsigned int pID)
{
/* track? */
HPM->hooking->force_return = true;
}
-bool HPM_HookStopped(void)
+static bool HPM_HookStopped(void)
{
return HPM->hooking->force_return;
}
@@ -381,7 +382,7 @@ bool HPM_HookStopped(void)
* @param help the help string to be displayed by '--help', if any.
* @return the success status.
*/
-bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, CmdlineExecFunc func, const char *help)
+static bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, CmdlineExecFunc func, const char *help)
{
int i;
@@ -410,7 +411,7 @@ bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, CmdlineExecF
* @retval true if the listener was added successfully.
* @retval false in case of error.
*/
-bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *name, void (*parse_func) (const char *key, const char *val), int (*return_func) (const char *key), bool required)
+static bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *name, void (*parse_func) (const char *key, const char *val), int (*return_func) (const char *key), bool required)
{
struct HPConfListenStorage *conf;
int i;
@@ -450,7 +451,7 @@ bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *na
return true;
}
-struct hplugin *hplugin_load(const char* filename)
+static struct hplugin *hplugin_load(const char *filename)
{
struct hplugin *plugin;
struct hplugin_info *info;
@@ -598,7 +599,7 @@ struct hplugin *hplugin_load(const char* filename)
*
* @param plugin The plugin data.
*/
-void hplugin_unload(struct hplugin* plugin)
+static void hplugin_unload(struct hplugin *plugin)
{
int i;
nullpo_retv(plugin);
@@ -628,7 +629,7 @@ CMDLINEARG(loadplugin)
/**
* Reads the plugin configuration and loads the plugins as necessary.
*/
-void hplugins_config_read(void)
+static void hplugins_config_read(void)
{
struct config_t plugins_conf;
struct config_setting_t *plist = NULL;
@@ -707,7 +708,7 @@ void hplugins_config_read(void)
*
* @see CPCMD()
*/
-CPCMD(plugins)
+static CPCMD(plugins)
{
int i;
@@ -733,7 +734,7 @@ CPCMD(plugins)
* @retval 1 OK
* @retval 2 incomplete packet
*/
-unsigned char hplugins_parse_packets(int fd, int packet_id, enum HPluginPacketHookingPoints point)
+static unsigned char hplugins_parse_packets(int fd, int packet_id, enum HPluginPacketHookingPoints point)
{
struct HPluginPacket *packet = NULL;
int i;
@@ -765,7 +766,7 @@ unsigned char hplugins_parse_packets(int fd, int packet_id, enum HPluginPacketHo
* @retval "core" if the plugin ID belongs to the Hercules core.
* @retval "UnknownPlugin" if the plugin wasn't found.
*/
-char *hplugins_id2name(unsigned int pid)
+static char *hplugins_id2name(unsigned int pid)
{
int i;
@@ -791,7 +792,7 @@ char *hplugins_id2name(unsigned int pid)
* @param file The string/filename to retain
* @return A retained copy of the source string.
*/
-const char *HPM_file2ptr(const char *file)
+static const char *HPM_file2ptr(const char *file)
{
int i;
@@ -810,27 +811,27 @@ const char *HPM_file2ptr(const char *file)
return HPM->filenames.data[i].name;
}
-void* HPM_mmalloc(size_t size, const char *file, int line, const char *func)
+static void *HPM_mmalloc(size_t size, const char *file, int line, const char *func)
{
return iMalloc->malloc(size,HPM_file2ptr(file),line,func);
}
-void* HPM_calloc(size_t num, size_t size, const char *file, int line, const char *func)
+static void *HPM_calloc(size_t num, size_t size, const char *file, int line, const char *func)
{
return iMalloc->calloc(num,size,HPM_file2ptr(file),line,func);
}
-void* HPM_realloc(void *p, size_t size, const char *file, int line, const char *func)
+static void *HPM_realloc(void *p, size_t size, const char *file, int line, const char *func)
{
return iMalloc->realloc(p,size,HPM_file2ptr(file),line,func);
}
-void* HPM_reallocz(void *p, size_t size, const char *file, int line, const char *func)
+static void *HPM_reallocz(void *p, size_t size, const char *file, int line, const char *func)
{
return iMalloc->reallocz(p,size,HPM_file2ptr(file),line,func);
}
-char* HPM_astrdup(const char *p, const char *file, int line, const char *func)
+static char *HPM_astrdup(const char *p, const char *file, int line, const char *func)
{
return iMalloc->astrdup(p,HPM_file2ptr(file),line,func);
}
@@ -844,7 +845,7 @@ char* HPM_astrdup(const char *p, const char *file, int line, const char *func)
* @retval true if a registered plugin was found to handle the entry.
* @retval false if no registered plugins could be found.
*/
-bool hplugins_parse_conf_entry(const char *w1, const char *w2, enum HPluginConfType point)
+static bool hplugins_parse_conf_entry(const char *w1, const char *w2, enum HPluginConfType point)
{
int i;
ARR_FIND(0, VECTOR_LENGTH(HPM->config_listeners[point]), i, strcmpi(w1, VECTOR_INDEX(HPM->config_listeners[point], i).key) == 0);
@@ -863,7 +864,7 @@ bool hplugins_parse_conf_entry(const char *w1, const char *w2, enum HPluginConfT
* @retval true in case of data found
* @retval false in case of no data found
*/
-bool hplugins_get_battle_conf(const char *w1, int *value)
+static bool hplugins_get_battle_conf(const char *w1, int *value)
{
int i;
@@ -887,7 +888,7 @@ bool hplugins_get_battle_conf(const char *w1, int *value)
* @param imported Whether the current config is imported from another file.
* @retval false in case of error.
*/
-bool hplugins_parse_conf(const struct config_t *config, const char *filename, enum HPluginConfType point, bool imported)
+static bool hplugins_parse_conf(const struct config_t *config, const char *filename, enum HPluginConfType point, bool imported)
{
const struct config_setting_t *setting = NULL;
int i, val, type;
@@ -940,7 +941,7 @@ bool hplugins_parse_conf(const struct config_t *config, const char *filename, en
* @param imported whether the current config is imported from another file.
* @retval false in case of error.
*/
-bool hplugins_parse_battle_conf(const struct config_t *config, const char *filename, bool imported)
+static bool hplugins_parse_battle_conf(const struct config_t *config, const char *filename, bool imported)
{
const struct config_setting_t *setting = NULL;
int i, val, type;
@@ -985,7 +986,7 @@ bool hplugins_parse_battle_conf(const struct config_t *config, const char *filen
*
* @param storeptr[in,out] A pointer to the plugin data store.
*/
-void hplugin_data_store_destroy(struct hplugin_data_store **storeptr)
+static void hplugin_data_store_destroy(struct hplugin_data_store **storeptr)
{
struct hplugin_data_store *store;
nullpo_retv(storeptr);
@@ -1014,7 +1015,7 @@ void hplugin_data_store_destroy(struct hplugin_data_store **storeptr)
* @param storeptr[in,out] A pointer to the data store to initialize.
* @param type[in] The store type.
*/
-void hplugin_data_store_create(struct hplugin_data_store **storeptr, enum HPluginDataTypes type)
+static void hplugin_data_store_create(struct hplugin_data_store **storeptr, enum HPluginDataTypes type)
{
struct hplugin_data_store *store;
nullpo_retv(storeptr);
@@ -1031,7 +1032,7 @@ void hplugin_data_store_create(struct hplugin_data_store **storeptr, enum HPlugi
/**
* Called by HPM->DataCheck on a plugins incoming data, ensures data structs in use are matching!
**/
-bool HPM_DataCheck(struct s_HPMDataCheck *src, unsigned int size, int version, char *name)
+static bool HPM_DataCheck(struct s_HPMDataCheck *src, unsigned int size, int version, char *name)
{
unsigned int i, j;
@@ -1060,7 +1061,7 @@ bool HPM_DataCheck(struct s_HPMDataCheck *src, unsigned int size, int version, c
return true;
}
-void HPM_datacheck_init(const struct s_HPMDataCheck *src, unsigned int length, int version)
+static void HPM_datacheck_init(const struct s_HPMDataCheck *src, unsigned int length, int version)
{
unsigned int i;
@@ -1077,12 +1078,12 @@ void HPM_datacheck_init(const struct s_HPMDataCheck *src, unsigned int length, i
}
}
-void HPM_datacheck_final(void)
+static void HPM_datacheck_final(void)
{
db_destroy(datacheck_db);
}
-void hpm_init(void)
+static void hpm_init(void)
{
int i;
datacheck_db = NULL;
@@ -1126,7 +1127,7 @@ void hpm_init(void)
/**
* Releases the retained filenames cache.
*/
-void hpm_memdown(void)
+static void hpm_memdown(void)
{
/* this memory is handled outside of the server's memory manager and
* thus cleared after memory manager goes down */
@@ -1141,7 +1142,7 @@ void hpm_memdown(void)
}
}
-void hpm_final(void)
+static void hpm_final(void)
{
int i;
diff --git a/src/common/conf.c b/src/common/conf.c
index 841288959..0ad350057 100644
--- a/src/common/conf.c
+++ b/src/common/conf.c
@@ -29,7 +29,7 @@
#include <libconfig/libconfig.h>
/* interface source */
-struct libconfig_interface libconfig_s;
+static struct libconfig_interface libconfig_s;
struct libconfig_interface *libconfig;
/**
@@ -44,7 +44,7 @@ struct libconfig_interface *libconfig;
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_load_file(struct config_t *config, const char *config_filename)
+static int config_load_file(struct config_t *config, const char *config_filename)
{
libconfig->init(config);
if (!exists(config_filename)) {
@@ -63,7 +63,7 @@ int config_load_file(struct config_t *config, const char *config_filename)
//
// Functions to copy settings from libconfig/contrib
//
-void config_setting_copy_simple(struct config_setting_t *parent, const struct config_setting_t *src)
+static void config_setting_copy_simple(struct config_setting_t *parent, const struct config_setting_t *src)
{
if (config_setting_is_aggregate(src)) {
libconfig->setting_copy_aggregate(parent, src);
@@ -92,7 +92,7 @@ void config_setting_copy_simple(struct config_setting_t *parent, const struct co
}
}
-void config_setting_copy_elem(struct config_setting_t *parent, const struct config_setting_t *src)
+static void config_setting_copy_elem(struct config_setting_t *parent, const struct config_setting_t *src)
{
struct config_setting_t *set = NULL;
@@ -113,7 +113,7 @@ void config_setting_copy_elem(struct config_setting_t *parent, const struct conf
}
}
-void config_setting_copy_aggregate(struct config_setting_t *parent, const struct config_setting_t *src)
+static void config_setting_copy_aggregate(struct config_setting_t *parent, const struct config_setting_t *src)
{
struct config_setting_t *newAgg;
int i, n;
@@ -137,7 +137,7 @@ void config_setting_copy_aggregate(struct config_setting_t *parent, const struct
}
}
-int config_setting_copy(struct config_setting_t *parent, const struct config_setting_t *src)
+static int config_setting_copy(struct config_setting_t *parent, const struct config_setting_t *src)
{
if (!config_setting_is_group(parent) && !config_setting_is_list(parent))
return CONFIG_FALSE;
@@ -158,7 +158,7 @@ int config_setting_copy(struct config_setting_t *parent, const struct config_set
* @return The converted value.
* @retval false in case of failure.
*/
-bool config_setting_get_bool_real(const struct config_setting_t *setting)
+static bool config_setting_get_bool_real(const struct config_setting_t *setting)
{
if (setting == NULL || setting->type != CONFIG_TYPE_BOOL)
return false;
@@ -176,7 +176,7 @@ bool config_setting_get_bool_real(const struct config_setting_t *setting)
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_setting_lookup_bool_real(const struct config_setting_t *setting, const char *name, bool *value)
+static int config_setting_lookup_bool_real(const struct config_setting_t *setting, const char *name, bool *value)
{
struct config_setting_t *member = config_setting_get_member(setting, name);
@@ -199,7 +199,7 @@ int config_setting_lookup_bool_real(const struct config_setting_t *setting, cons
* @return The converted value.
* @retval 0 in case of failure.
*/
-uint32 config_setting_get_uint32(const struct config_setting_t *setting)
+static uint32 config_setting_get_uint32(const struct config_setting_t *setting)
{
if (setting == NULL || setting->type != CONFIG_TYPE_INT)
return 0;
@@ -220,7 +220,7 @@ uint32 config_setting_get_uint32(const struct config_setting_t *setting)
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_setting_lookup_uint32(const struct config_setting_t *setting, const char *name, uint32 *value)
+static int config_setting_lookup_uint32(const struct config_setting_t *setting, const char *name, uint32 *value)
{
struct config_setting_t *member = config_setting_get_member(setting, name);
@@ -243,7 +243,7 @@ int config_setting_lookup_uint32(const struct config_setting_t *setting, const c
* @return The converted value.
* @retval 0 in case of failure.
*/
-uint16 config_setting_get_uint16(const struct config_setting_t *setting)
+static uint16 config_setting_get_uint16(const struct config_setting_t *setting)
{
if (setting == NULL || setting->type != CONFIG_TYPE_INT)
return 0;
@@ -266,7 +266,7 @@ uint16 config_setting_get_uint16(const struct config_setting_t *setting)
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_setting_lookup_uint16(const struct config_setting_t *setting, const char *name, uint16 *value)
+static int config_setting_lookup_uint16(const struct config_setting_t *setting, const char *name, uint16 *value)
{
struct config_setting_t *member = config_setting_get_member(setting, name);
@@ -289,7 +289,7 @@ int config_setting_lookup_uint16(const struct config_setting_t *setting, const c
* @return The converted value.
* @retval 0 in case of failure.
*/
-int16 config_setting_get_int16(const struct config_setting_t *setting)
+static int16 config_setting_get_int16(const struct config_setting_t *setting)
{
if (setting == NULL || setting->type != CONFIG_TYPE_INT)
return 0;
@@ -312,7 +312,7 @@ int16 config_setting_get_int16(const struct config_setting_t *setting)
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_setting_lookup_int16(const struct config_setting_t *setting, const char *name, int16 *value)
+static int config_setting_lookup_int16(const struct config_setting_t *setting, const char *name, int16 *value)
{
struct config_setting_t *member = config_setting_get_member(setting, name);
@@ -338,7 +338,7 @@ int config_setting_lookup_int16(const struct config_setting_t *setting, const ch
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_setting_lookup_mutable_string(const struct config_setting_t *setting, const char *name, char *out, size_t out_size)
+static int config_setting_lookup_mutable_string(const struct config_setting_t *setting, const char *name, char *out, size_t out_size)
{
const char *str = NULL;
@@ -361,7 +361,7 @@ int config_setting_lookup_mutable_string(const struct config_setting_t *setting,
* @retval CONFIG_TRUE in case of success.
* @retval CONFIG_FALSE in case of failure.
*/
-int config_lookup_mutable_string(const struct config_t *config, const char *name, char *out, size_t out_size)
+static int config_lookup_mutable_string(const struct config_t *config, const char *name, char *out, size_t out_size)
{
const char *str = NULL;
@@ -378,7 +378,7 @@ int config_lookup_mutable_string(const struct config_t *config, const char *name
*
* @see config_setting_get_int64_real()
*/
-int64 config_setting_get_int64_real(const struct config_setting_t *setting)
+static int64 config_setting_get_int64_real(const struct config_setting_t *setting)
{
return (int64)config_setting_get_int64(setting);
}
@@ -388,7 +388,7 @@ int64 config_setting_get_int64_real(const struct config_setting_t *setting)
*
* @see config_setting_lookup_int64()
*/
-int config_setting_lookup_int64_real(const struct config_setting_t *setting, const char *name, int64 *value)
+static int config_setting_lookup_int64_real(const struct config_setting_t *setting, const char *name, int64 *value)
{
long long int lli = 0;
@@ -405,7 +405,7 @@ int config_setting_lookup_int64_real(const struct config_setting_t *setting, con
*
* @see config_setting_set_int64()
*/
-int config_setting_set_int64_real(struct config_setting_t *setting, int64 value)
+static int config_setting_set_int64_real(struct config_setting_t *setting, int64 value)
{
return config_setting_set_int64(setting, (long long int)value);
}
@@ -415,7 +415,7 @@ int config_setting_set_int64_real(struct config_setting_t *setting, int64 value)
*
* @see config_setting_get_int64_elem()
*/
-int64 config_setting_get_int64_elem_real(const struct config_setting_t *setting, int idx)
+static int64 config_setting_get_int64_elem_real(const struct config_setting_t *setting, int idx)
{
return (int64)config_setting_get_int64_elem(setting, idx);
}
@@ -425,7 +425,7 @@ int64 config_setting_get_int64_elem_real(const struct config_setting_t *setting,
*
* @see config_setting_set_int64_elem()
*/
-struct config_setting_t *config_setting_set_int64_elem_real(struct config_setting_t *setting, int idx, int64 value)
+static struct config_setting_t *config_setting_set_int64_elem_real(struct config_setting_t *setting, int idx, int64 value)
{
return config_setting_set_int64_elem(setting, idx, (long long int)value);
}
@@ -435,7 +435,7 @@ struct config_setting_t *config_setting_set_int64_elem_real(struct config_settin
*
* @see config_lookup_int64()
*/
-int config_lookup_int64_real(const struct config_t *config, const char *filepath, int64 *value)
+static int config_lookup_int64_real(const struct config_t *config, const char *filepath, int64 *value)
{
long long int lli = 0;
diff --git a/src/common/console.c b/src/common/console.c
index e7edd7e1e..55a9815f5 100644
--- a/src/common/console.c
+++ b/src/common/console.c
@@ -53,13 +53,13 @@
# endif
#endif
-struct console_interface console_s;
+static struct console_interface console_s;
struct console_interface *console;
#ifdef CONSOLE_INPUT
-struct console_input_interface console_input_s;
-struct spin_lock console_ptlock_s;
+static struct console_input_interface console_input_s;
+static struct spin_lock console_ptlock_s;
-struct {
+static struct {
char queue[CONSOLE_PARSE_SIZE][MAX_CONSOLE_INPUT];
unsigned short count;
} cinput;
@@ -68,7 +68,7 @@ struct {
/*======================================
* CORE : Display title
*--------------------------------------*/
-void display_title(void)
+static void display_title(void)
{
const char *vcstype = sysinfo->vcstype();
@@ -98,14 +98,14 @@ void display_title(void)
/**
* Shows a license notice as per GNU GPL recommendation.
*/
-void display_gplnotice(void)
+static void display_gplnotice(void)
{
ShowInfo("Hercules, Copyright (C) 2012-2018, Hercules Dev Team and others.\n");
ShowInfo("Licensed under the GNU General Public License, version 3 or later.\n");
}
#ifdef CONSOLE_INPUT
-int console_parse_key_pressed(void)
+static int console_parse_key_pressed(void)
{
#ifdef WIN32
return _kbhit();
@@ -131,7 +131,7 @@ int console_parse_key_pressed(void)
/**
* Stops server
**/
-CPCMD_C(exit, server)
+static CPCMD_C(exit, server)
{
if (core->shutdown_callback != NULL)
core->shutdown_callback();
@@ -142,7 +142,7 @@ CPCMD_C(exit, server)
/**
* Displays ERS-related statistics (Entry Reusage System)
**/
-CPCMD_C(ers_report, server)
+static CPCMD_C(ers_report, server)
{
ers_report();
}
@@ -150,7 +150,7 @@ CPCMD_C(ers_report, server)
/**
* Displays memory usage
**/
-CPCMD_C(mem_report, server)
+static CPCMD_C(mem_report, server)
{
#ifdef USE_MEMMGR
memmgr_report(line?atoi(line):0);
@@ -160,7 +160,7 @@ CPCMD_C(mem_report, server)
/**
* Displays command list
**/
-CPCMD(help)
+static CPCMD(help)
{
int i;
for (i = 0; i < VECTOR_LENGTH(console->input->command_list); i++) {
@@ -178,7 +178,7 @@ CPCMD(help)
* [Ind/Hercules]
* Displays current malloc usage
*/
-CPCMD_C(malloc_usage, server)
+static CPCMD_C(malloc_usage, server)
{
unsigned int val = (unsigned int)iMalloc->usage();
ShowInfo("malloc_usage: %.2f MB\n",(double)(val)/1024);
@@ -188,7 +188,7 @@ CPCMD_C(malloc_usage, server)
* Skips an sql update
* Usage: sql update skip UPDATE-FILE.sql
**/
-CPCMD_C(skip, update)
+static CPCMD_C(skip, update)
{
if( !line ) {
ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n");
@@ -200,7 +200,7 @@ CPCMD_C(skip, update)
/**
* Loads console commands list
**/
-void console_load_defaults(void)
+static void console_load_defaults(void)
{
/**
* Defines a main category.
@@ -313,7 +313,7 @@ void console_load_defaults(void)
* @param name The command name.
* @param func The command callback.
*/
-void console_parse_create(char *name, CParseFunc func)
+static void console_parse_create(char *name, CParseFunc func)
{
int i;
char *tok;
@@ -370,7 +370,7 @@ void console_parse_create(char *name, CParseFunc func)
* @param cmd The command entry.
* @param depth The current tree depth (for display purposes).
*/
-void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth)
+static void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth)
{
int i;
char msg[CP_CMD_LENGTH * 2];
@@ -394,7 +394,7 @@ void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth)
*
* @param line The input line.
*/
-void console_parse_sub(char *line)
+static void console_parse_sub(char *line)
{
struct CParseEntry *cmd;
char bline[200];
@@ -457,7 +457,7 @@ void console_parse_sub(char *line)
ShowError("Is only a category, type '"CL_WHITE"%s help"CL_RESET"' to list its subcommands\n",sublist);
}
-void console_parse(char *line)
+static void console_parse(char *line)
{
int c, i = 0, len = MAX_CONSOLE_INPUT - 1;/* we leave room for the \0 :P */
@@ -474,7 +474,7 @@ void console_parse(char *line)
line[i++] = '\0';
}
-void *cThread_main(void *x)
+static void *cThread_main(void *x)
{
while( console->input->ptstate ) {/* loopx */
if( console->input->key_pressed() ) {
@@ -501,7 +501,7 @@ void *cThread_main(void *x)
return NULL;
}
-int console_parse_timer(int tid, int64 tick, int id, intptr_t data)
+static int console_parse_timer(int tid, int64 tick, int id, intptr_t data)
{
int i;
EnterSpinLock(console->input->ptlock);
@@ -514,7 +514,7 @@ int console_parse_timer(int tid, int64 tick, int id, intptr_t data)
return 0;
}
-void console_parse_final(void)
+static void console_parse_final(void)
{
if( console->input->ptstate ) {
InterlockedDecrement(&console->input->ptstate);
@@ -528,7 +528,7 @@ void console_parse_final(void)
}
}
-void console_parse_init(void)
+static void console_parse_init(void)
{
cinput.count = 0;
@@ -548,13 +548,13 @@ void console_parse_init(void)
timer->add_interval(timer->gettick() + 1000, console->input->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */
}
-void console_setSQL(struct Sql *SQL_handle)
+static void console_setSQL(struct Sql *SQL_handle)
{
console->input->SQL = SQL_handle;
}
#endif /* CONSOLE_INPUT */
-void console_init(void)
+static void console_init(void)
{
#ifdef CONSOLE_INPUT
VECTOR_INIT(console->input->command_list);
@@ -564,7 +564,7 @@ void console_init(void)
#endif
}
-void console_final(void)
+static void console_final(void)
{
#ifdef CONSOLE_INPUT
console->input->parse_final();
diff --git a/src/common/core.c b/src/common/core.c
index 406bb7629..9fd33c4e0 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -80,7 +80,7 @@
// And don't complain to us if the XYZ plugin you installed wiped your hard disk, or worse.
// Note: This feature is deprecated, and should not be used.
-struct core_interface core_s;
+static struct core_interface core_s;
struct core_interface *core = &core_s;
#ifndef MINICORE // minimalist Core
@@ -97,7 +97,7 @@ struct core_interface *core = &core_s;
#ifndef POSIX
#define compat_signal(signo, func) signal((signo), (func))
#else
-sigfunc *compat_signal(int signo, sigfunc *func)
+static sigfunc *compat_signal(int signo, sigfunc *func)
{
struct sigaction sact, oact;
@@ -180,7 +180,7 @@ static void sig_proc(int sn)
}
}
-void signals_init (void)
+static void signals_init(void)
{
compat_signal(SIGTERM, sig_proc);
compat_signal(SIGINT, sig_proc);
@@ -203,7 +203,7 @@ void signals_init (void)
*
* @retval false if the check didn't pass and the program should be terminated.
*/
-bool usercheck(void)
+static bool usercheck(void)
{
#ifndef _WIN32
if (sysinfo->is_superuser()) {
@@ -247,7 +247,7 @@ bool usercheck(void)
return true;
}
-void core_defaults(void)
+static void core_defaults(void)
{
nullpo_defaults();
#ifndef MINICORE
@@ -278,7 +278,7 @@ void core_defaults(void)
/**
* Returns the source (core or plugin name) for the given command-line argument
*/
-const char *cmdline_arg_source(struct CmdlineArgData *arg)
+static const char *cmdline_arg_source(struct CmdlineArgData *arg)
{
#ifdef MINICORE
return "core";
@@ -299,7 +299,7 @@ const char *cmdline_arg_source(struct CmdlineArgData *arg)
* @param options options associated to the command-line argument. @see enum cmdline_options.
* @return the success status.
*/
-bool cmdline_arg_add(unsigned int pluginID, const char *name, char shortname, CmdlineExecFunc func, const char *help, unsigned int options)
+static bool cmdline_arg_add(unsigned int pluginID, const char *name, char shortname, CmdlineExecFunc func, const char *help, unsigned int options)
{
struct CmdlineArgData *data = NULL;
@@ -363,7 +363,7 @@ static CMDLINEARG(version)
* @param argc the program's argc.
* @return true if a value for the current argument is available on the command line.
*/
-bool cmdline_arg_next_value(const char *name, int current_arg, int argc)
+static bool cmdline_arg_next_value(const char *name, int current_arg, int argc)
{
if (current_arg >= argc-1) {
ShowError("Missing value for option '%s'.\n", name);
@@ -391,7 +391,7 @@ bool cmdline_arg_next_value(const char *name, int current_arg, int argc)
* line arguments or handler's failure cause the program to abort.
* @return the amount of command line handlers successfully executed.
*/
-int cmdline_exec(int argc, char **argv, unsigned int options)
+static int cmdline_exec(int argc, char **argv, unsigned int options)
{
int count = 0, i;
@@ -444,7 +444,7 @@ int cmdline_exec(int argc, char **argv, unsigned int options)
/**
* Defines the global command-line arguments.
*/
-void cmdline_init(void)
+static void cmdline_init(void)
{
#ifdef MINICORE
// Minicore has no HPM. This value isn't used, but the arg_add function requires it, so we're (re)defining it here
@@ -458,7 +458,7 @@ void cmdline_init(void)
cmdline_args_init_local();
}
-void cmdline_final(void)
+static void cmdline_final(void)
{
while (VECTOR_LENGTH(cmdline->args_data) > 0) {
struct CmdlineArgData *data = &VECTOR_POP(cmdline->args_data);
@@ -468,7 +468,7 @@ void cmdline_final(void)
VECTOR_CLEAR(cmdline->args_data);
}
-struct cmdline_interface cmdline_s;
+static struct cmdline_interface cmdline_s;
struct cmdline_interface *cmdline;
void cmdline_defaults(void)
@@ -488,7 +488,7 @@ void cmdline_defaults(void)
/*======================================
* CORE : MAINROUTINE
*--------------------------------------*/
-int main (int argc, char **argv)
+int main(int argc, char **argv)
{
int retval = EXIT_SUCCESS;
{// initialize program arguments
diff --git a/src/common/db.c b/src/common/db.c
index 1ad715f25..c28ad1f7c 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -100,7 +100,7 @@
#include <stdio.h>
#include <stdlib.h>
-struct db_interface DB_s;
+static struct db_interface DB_s;
struct db_interface *DB;
/*****************************************************************************
@@ -358,8 +358,8 @@ static struct db_stats {
#endif /* !defined(DB_ENABLE_STATS) */
/* [Ind/Hercules] */
-struct eri *db_iterator_ers;
-struct eri *db_alloc_ers;
+static struct eri *db_iterator_ers;
+static struct eri *db_alloc_ers;
/*****************************************************************************\
* (2) Section of private functions used by the database system. *
@@ -1250,7 +1250,7 @@ static void db_release_both(union DBKey key, struct DBData data, enum DBReleaseO
* @protected
* @see struct DBIterator#first()
*/
-struct DBData *dbit_obj_first(struct DBIterator *self, union DBKey *out_key)
+static struct DBData *dbit_obj_first(struct DBIterator *self, union DBKey *out_key)
{
struct DBIterator_impl *it = (struct DBIterator_impl *)self;
@@ -1272,7 +1272,7 @@ struct DBData *dbit_obj_first(struct DBIterator *self, union DBKey *out_key)
* @protected
* @see struct DBIterator#last()
*/
-struct DBData *dbit_obj_last(struct DBIterator *self, union DBKey *out_key)
+static struct DBData *dbit_obj_last(struct DBIterator *self, union DBKey *out_key)
{
struct DBIterator_impl *it = (struct DBIterator_impl *)self;
@@ -1294,7 +1294,7 @@ struct DBData *dbit_obj_last(struct DBIterator *self, union DBKey *out_key)
* @protected
* @see struct DBIterator#next()
*/
-struct DBData *dbit_obj_next(struct DBIterator *self, union DBKey *out_key)
+static struct DBData *dbit_obj_next(struct DBIterator *self, union DBKey *out_key)
{
struct DBIterator_impl *it = (struct DBIterator_impl *)self;
struct DBNode *node;
@@ -1370,7 +1370,7 @@ struct DBData *dbit_obj_next(struct DBIterator *self, union DBKey *out_key)
* @protected
* @see struct DBIterator#prev()
*/
-struct DBData *dbit_obj_prev(struct DBIterator *self, union DBKey *out_key)
+static struct DBData *dbit_obj_prev(struct DBIterator *self, union DBKey *out_key)
{
struct DBIterator_impl *it = (struct DBIterator_impl *)self;
struct DBNode *node;
@@ -1445,7 +1445,7 @@ struct DBData *dbit_obj_prev(struct DBIterator *self, union DBKey *out_key)
* @protected
* @see struct DBIterator#exists()
*/
-bool dbit_obj_exists(struct DBIterator *self)
+static bool dbit_obj_exists(struct DBIterator *self)
{
struct DBIterator_impl *it = (struct DBIterator_impl *)self;
@@ -1467,7 +1467,7 @@ bool dbit_obj_exists(struct DBIterator *self)
* @see struct DBMap#remove()
* @see struct DBIterator#remove()
*/
-int dbit_obj_remove(struct DBIterator *self, struct DBData *out_data)
+static int dbit_obj_remove(struct DBIterator *self, struct DBData *out_data)
{
struct DBIterator_impl *it = (struct DBIterator_impl *)self;
struct DBNode *node;
@@ -1494,7 +1494,7 @@ int dbit_obj_remove(struct DBIterator *self, struct DBData *out_data)
* @param self Iterator
* @protected
*/
-void dbit_obj_destroy(struct DBIterator *self)
+static void dbit_obj_destroy(struct DBIterator *self)
{
struct DBIterator_impl *it = (struct DBIterator_impl *)self;
@@ -2407,7 +2407,7 @@ static enum DBOptions db_obj_options(struct DBMap *self)
* @see #db_default_release()
* @see #db_alloc()
*/
-enum DBOptions db_fix_options(enum DBType type, enum DBOptions options)
+static enum DBOptions db_fix_options(enum DBType type, enum DBOptions options)
{
DB_COUNTSTAT(db_fix_options);
switch (type) {
@@ -2438,7 +2438,7 @@ enum DBOptions db_fix_options(enum DBType type, enum DBOptions options)
* @see #db_int64_cmp()
* @see #db_uint64_cmp()
*/
-DBComparator db_default_cmp(enum DBType type)
+static DBComparator db_default_cmp(enum DBType type)
{
DB_COUNTSTAT(db_default_cmp);
switch (type) {
@@ -2466,7 +2466,7 @@ DBComparator db_default_cmp(enum DBType type)
* @see #db_int64_hash()
* @see #db_uint64_hash()
*/
-DBHasher db_default_hash(enum DBType type)
+static DBHasher db_default_hash(enum DBType type)
{
DB_COUNTSTAT(db_default_hash);
switch (type) {
@@ -2499,7 +2499,7 @@ DBHasher db_default_hash(enum DBType type)
* @see #db_release_both()
* @see #db_custom_release()
*/
-DBReleaser db_default_release(enum DBType type, enum DBOptions options)
+static DBReleaser db_default_release(enum DBType type, enum DBOptions options)
{
DB_COUNTSTAT(db_default_release);
options = DB->fix_options(type, options);
@@ -2524,7 +2524,7 @@ DBReleaser db_default_release(enum DBType type, enum DBOptions options)
* @see #db_release_both()
* @see #db_default_release()
*/
-DBReleaser db_custom_release(enum DBReleaseOption which)
+static DBReleaser db_custom_release(enum DBReleaseOption which)
{
DB_COUNTSTAT(db_custom_release);
switch (which) {
@@ -2555,7 +2555,7 @@ DBReleaser db_custom_release(enum DBReleaseOption which)
* @see struct DBMap_impl
* @see #db_fix_options()
*/
-struct DBMap *db_alloc(const char *file, const char *func, int line, enum DBType type, enum DBOptions options, unsigned short maxlen)
+static struct DBMap *db_alloc(const char *file, const char *func, int line, enum DBType type, enum DBOptions options, unsigned short maxlen)
{
struct DBMap_impl *db;
unsigned int i;
@@ -2629,7 +2629,7 @@ struct DBMap *db_alloc(const char *file, const char *func, int line, enum DBType
* @return The key as a DBKey union
* @public
*/
-union DBKey db_i2key(int key)
+static union DBKey db_i2key(int key)
{
union DBKey ret;
@@ -2644,7 +2644,7 @@ union DBKey db_i2key(int key)
* @return The key as a DBKey union
* @public
*/
-union DBKey db_ui2key(unsigned int key)
+static union DBKey db_ui2key(unsigned int key)
{
union DBKey ret;
@@ -2659,7 +2659,7 @@ union DBKey db_ui2key(unsigned int key)
* @return The key as a DBKey union
* @public
*/
-union DBKey db_str2key(const char *key)
+static union DBKey db_str2key(const char *key)
{
union DBKey ret;
@@ -2674,7 +2674,7 @@ union DBKey db_str2key(const char *key)
* @return The key as a DBKey union
* @public
*/
-union DBKey db_i642key(int64 key)
+static union DBKey db_i642key(int64 key)
{
union DBKey ret;
@@ -2689,7 +2689,7 @@ union DBKey db_i642key(int64 key)
* @return The key as a DBKey union
* @public
*/
-union DBKey db_ui642key(uint64 key)
+static union DBKey db_ui642key(uint64 key)
{
union DBKey ret;
@@ -2704,7 +2704,7 @@ union DBKey db_ui642key(uint64 key)
* @return The data as a DBData struct
* @public
*/
-struct DBData db_i2data(int data)
+static struct DBData db_i2data(int data)
{
struct DBData ret;
@@ -2720,7 +2720,7 @@ struct DBData db_i2data(int data)
* @return The data as a DBData struct
* @public
*/
-struct DBData db_ui2data(unsigned int data)
+static struct DBData db_ui2data(unsigned int data)
{
struct DBData ret;
@@ -2736,7 +2736,7 @@ struct DBData db_ui2data(unsigned int data)
* @return The data as a DBData struct
* @public
*/
-struct DBData db_ptr2data(void *data)
+static struct DBData db_ptr2data(void *data)
{
struct DBData ret;
@@ -2753,7 +2753,7 @@ struct DBData db_ptr2data(void *data)
* @return Integer value of the data.
* @public
*/
-int db_data2i(struct DBData *data)
+static int db_data2i(struct DBData *data)
{
DB_COUNTSTAT(db_data2i);
if (data && DB_DATA_INT == data->type)
@@ -2768,7 +2768,7 @@ int db_data2i(struct DBData *data)
* @return Unsigned int value of the data.
* @public
*/
-unsigned int db_data2ui(struct DBData *data)
+static unsigned int db_data2ui(struct DBData *data)
{
DB_COUNTSTAT(db_data2ui);
if (data && DB_DATA_UINT == data->type)
@@ -2783,7 +2783,7 @@ unsigned int db_data2ui(struct DBData *data)
* @return Void* value of the data.
* @public
*/
-void *db_data2ptr(struct DBData *data)
+static void *db_data2ptr(struct DBData *data)
{
DB_COUNTSTAT(db_data2ptr);
if (data && DB_DATA_PTR == data->type)
@@ -2796,7 +2796,7 @@ void *db_data2ptr(struct DBData *data)
* @public
* @see #db_final(void)
*/
-void db_init(void)
+static void db_init(void)
{
db_iterator_ers = ers_new(sizeof(struct DBIterator_impl),"db.c::db_iterator_ers",ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK);
db_alloc_ers = ers_new(sizeof(struct DBMap_impl),"db.c::db_alloc_ers",ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK);
@@ -2810,7 +2810,7 @@ void db_init(void)
* @public
* @see #db_init(void)
*/
-void db_final(void)
+static void db_final(void)
{
#ifdef DB_ENABLE_STATS
DB_COUNTSTAT(db_final);
diff --git a/src/common/des.c b/src/common/des.c
index 2223f4744..fbd158265 100644
--- a/src/common/des.c
+++ b/src/common/des.c
@@ -29,7 +29,7 @@
* Implementation of the des interface.
*/
-struct des_interface des_s;
+static struct des_interface des_s;
struct des_interface *des;
/// Bitmask for accessing individual bits of a byte.
@@ -228,7 +228,7 @@ static void des_RoundFunction(struct des_bit64 *src)
}
/// @copydoc des_interface::decrypt_block()
-void des_decrypt_block(struct des_bit64 *block)
+static void des_decrypt_block(struct des_bit64 *block)
{
des_IP(block);
des_RoundFunction(block);
@@ -236,7 +236,7 @@ void des_decrypt_block(struct des_bit64 *block)
}
/// @copydoc des_interface::decrypt()
-void des_decrypt(unsigned char *data, size_t size)
+static void des_decrypt(unsigned char *data, size_t size)
{
struct des_bit64 *p = (struct des_bit64 *)data;
size_t i;
diff --git a/src/common/ers.c b/src/common/ers.c
index da793db99..e421c47c9 100644
--- a/src/common/ers.c
+++ b/src/common/ers.c
@@ -309,7 +309,7 @@ static void ers_obj_destroy(ERS *self)
aFree(instance);
}
-void ers_cache_size(ERS *self, unsigned int new_size)
+static void ers_cache_size(ERS *self, unsigned int new_size)
{
struct ers_instance_t *instance = (struct ers_instance_t *)self;
diff --git a/src/common/grfio.c b/src/common/grfio.c
index ba8a1d161..79154d191 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -68,19 +68,19 @@ enum grf_filelist_type {
//#define GRFIO_LOCAL
// stores info about every loaded file
-struct grf_filelist *filelist = NULL;
-int filelist_entrys = 0;
-int filelist_maxentry = 0;
+static struct grf_filelist *filelist = NULL;
+static int filelist_entrys = 0;
+static int filelist_maxentry = 0;
// stores grf file names
-char** gentry_table = NULL;
-int gentry_entrys = 0;
-int gentry_maxentry = 0;
+static char** gentry_table = NULL;
+static int gentry_entrys = 0;
+static int gentry_maxentry = 0;
// the path to the data directory
-char data_dir[1024] = "";
+static char data_dir[1024] = "";
-struct grfio_interface grfio_s;
+static struct grfio_interface grfio_s;
struct grfio_interface *grfio;
// little endian char array to uint conversion
@@ -273,19 +273,19 @@ static void grf_decode(unsigned char *buf, size_t len, char entry_type, int entr
/* Zlib Subroutines */
/// @copydoc grfio_interface::crc32()
-unsigned long grfio_crc32(const unsigned char *buf, unsigned int len)
+static unsigned long grfio_crc32(const unsigned char *buf, unsigned int len)
{
return crc32(crc32(0L, Z_NULL, 0), buf, len);
}
/// @copydoc grfio_interface::decode_zip
-int grfio_decode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
+static int grfio_decode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
{
return uncompress(dest, dest_len, source, source_len);
}
/// @copydoc grfio_interface::encode_zip
-int grfio_encode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
+static int grfio_encode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len)
{
if (*dest_len == 0) /* [Ind/Hercules] */
*dest_len = compressBound(source_len);
@@ -299,7 +299,7 @@ int grfio_encode_zip(void *dest, unsigned long *dest_len, const void *source, un
/* File List Subroutines */
/// File list hash table
-int filelist_hash[256];
+static int filelist_hash[256];
/**
* Initializes the table that holds the first elements of all hash chains
@@ -351,7 +351,7 @@ static struct grf_filelist *grfio_filelist_find(const char *fname)
}
/// @copydoc grfio_interface::find_file()
-const char *grfio_find_file(const char *fname)
+static const char *grfio_find_file(const char *fname)
{
struct grf_filelist *flist = grfio_filelist_find(fname);
if (flist == NULL)
@@ -458,7 +458,7 @@ static void grfio_localpath_create(char *buffer, size_t size, const char *filena
}
/// @copydoc grfio_interface::reads()
-void *grfio_reads(const char *fname, int *size)
+static void *grfio_reads(const char *fname, int *size)
{
struct grf_filelist *entry = grfio_filelist_find(fname);
if (entry == NULL || entry->gentry <= 0) {
@@ -885,7 +885,7 @@ static int grfio_add(const char *fname)
}
/// @copydoc grfio_interface::final()
-void grfio_final(void)
+static void grfio_final(void)
{
if (filelist != NULL) {
int i;
@@ -911,7 +911,7 @@ void grfio_final(void)
}
/// @copydoc grfio_interface::init()
-void grfio_init(const char *fname)
+static void grfio_init(const char *fname)
{
FILE *data_conf;
int grf_num = 0;
diff --git a/src/common/mapindex.c b/src/common/mapindex.c
index e79054f72..d5cda5c22 100644
--- a/src/common/mapindex.c
+++ b/src/common/mapindex.c
@@ -33,12 +33,12 @@
#include <stdlib.h>
/* mapindex.c interface source */
-struct mapindex_interface mapindex_s;
+static 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.
-const char* mapindex_getmapname(const char* string, char* output)
+static const char *mapindex_getmapname(const char *string, char *output)
{
static char buf[MAP_NAME_LENGTH];
char* dest = (output != NULL) ? output : buf;
@@ -62,7 +62,7 @@ const char* mapindex_getmapname(const char* string, char* output)
/// Retrieves the map name from 'string' (adding .gat extension if not already present).
/// Result gets placed either into 'buf' or in a static local buffer.
-const char* mapindex_getmapname_ext(const char* string, char* output)
+static const char *mapindex_getmapname_ext(const char *string, char *output)
{
static char buf[MAP_NAME_LENGTH_EXT];
char* dest = (output != NULL) ? output : buf;
@@ -94,7 +94,7 @@ const char* mapindex_getmapname_ext(const char* string, char* output)
/// Adds a map to the specified index
/// Returns 1 if successful, 0 otherwise
-int mapindex_addmap(int index, const char* name)
+static int mapindex_addmap(int index, const char *name)
{
char map_name[MAP_NAME_LENGTH];
@@ -136,7 +136,7 @@ int mapindex_addmap(int index, const char* name)
return index;
}
-unsigned short mapindex_name2id(const char* name)
+static unsigned short mapindex_name2id(const char *name)
{
int i;
char map_name[MAP_NAME_LENGTH];
@@ -150,7 +150,7 @@ unsigned short mapindex_name2id(const char* name)
return 0;
}
-const char *mapindex_id2name_sub(uint16 id, const char *file, int line, const char *func)
+static const char *mapindex_id2name_sub(uint16 id, const char *file, int line, const char *func)
{
if (id >= MAX_MAPINDEX || !mapindex_exists(id)) {
ShowDebug("mapindex_id2name: Requested name for non-existant map index [%d] in cache. %s:%s:%d\n", id,file,func,line);
@@ -159,7 +159,7 @@ const char *mapindex_id2name_sub(uint16 id, const char *file, int line, const ch
return mapindex->list[id].name;
}
-int mapindex_init(void)
+static int mapindex_init(void)
{
FILE *fp;
char line[1024];
@@ -198,7 +198,7 @@ int mapindex_init(void)
return total;
}
-bool mapindex_check_default(void)
+static bool mapindex_check_default(void)
{
if (!strdb_iget(mapindex->db, mapindex->default_map)) {
ShowError("mapindex_init: MAP_DEFAULT '%s' not found in cache! update mapindex.h MAP_DEFAULT var!!!\n", mapindex->default_map);
@@ -207,14 +207,14 @@ bool mapindex_check_default(void)
return true;
}
-void mapindex_removemap(int index)
+static void mapindex_removemap(int index)
{
Assert_retv(index < MAX_MAPINDEX);
strdb_remove(mapindex->db, mapindex->list[index].name);
mapindex->list[index].name[0] = '\0';
}
-void mapindex_final(void)
+static void mapindex_final(void)
{
db_destroy(mapindex->db);
}
diff --git a/src/common/md5calc.c b/src/common/md5calc.c
index 9784bd7b8..3f9ccdc41 100644
--- a/src/common/md5calc.c
+++ b/src/common/md5calc.c
@@ -34,7 +34,7 @@
* Implementation of the md5 interface.
*/
-struct md5_interface md5_s;
+static struct md5_interface md5_s;
struct md5_interface *md5;
/// Global variable
@@ -233,7 +233,7 @@ static void md5_buf2binary(const uint8 *buf, const int buf_size, uint8 *output)
}
/// @copydoc md5_interface::string()
-void md5_string(const char *string, char *output)
+static void md5_string(const char *string, char *output)
{
uint8 digest[16];
@@ -249,7 +249,7 @@ void md5_string(const char *string, char *output)
}
/// @copydoc md5_interface::salt();
-void md5_salt(int len, char *output)
+static void md5_salt(int len, char *output)
{
int i;
Assert_retv(len > 0);
diff --git a/src/common/memmgr.c b/src/common/memmgr.c
index 3c9cca6a6..3c645e7fa 100644
--- a/src/common/memmgr.c
+++ b/src/common/memmgr.c
@@ -31,7 +31,7 @@
#include <stdlib.h>
#include <string.h>
-struct malloc_interface iMalloc_s;
+static struct malloc_interface iMalloc_s;
struct malloc_interface *iMalloc;
////////////// Memory Libraries //////////////////
@@ -113,7 +113,7 @@ struct malloc_interface *iMalloc;
#error Unsupported OS
#endif
-void* aMalloc_(size_t size, const char *file, int line, const char *func)
+static void *aMalloc_(size_t size, const char *file, int line, const char *func)
{
void *ret = MALLOC(size, file, line, func);
// ShowMessage("%s:%d: in func %s: aMalloc %d\n",file,line,func,size);
@@ -124,7 +124,7 @@ void* aMalloc_(size_t size, const char *file, int line, const char *func)
return ret;
}
-void* aCalloc_(size_t num, size_t size, const char *file, int line, const char *func)
+static void *aCalloc_(size_t num, size_t size, const char *file, int line, const char *func)
{
void *ret = CALLOC(num, size, file, line, func);
// ShowMessage("%s:%d: in func %s: aCalloc %d %d\n",file,line,func,num,size);
@@ -134,7 +134,7 @@ void* aCalloc_(size_t num, size_t size, const char *file, int line, const char *
}
return ret;
}
-void* aRealloc_(void *p, size_t size, const char *file, int line, const char *func)
+static void *aRealloc_(void *p, size_t size, const char *file, int line, const char *func)
{
void *ret = REALLOC(p, size, file, line, func);
// ShowMessage("%s:%d: in func %s: aRealloc %p %d\n",file,line,func,p,size);
@@ -145,7 +145,7 @@ void* aRealloc_(void *p, size_t size, const char *file, int line, const char *fu
return ret;
}
-void* aReallocz_(void *p, size_t size, const char *file, int line, const char *func)
+static void *aReallocz_(void *p, size_t size, const char *file, int line, const char *func)
{
unsigned char *ret = NULL;
// ShowMessage("%s:%d: in func %s: aReallocz %p %ld\n",file,line,func,p,size);
@@ -168,7 +168,7 @@ void* aReallocz_(void *p, size_t size, const char *file, int line, const char *f
return ret;
}
-char* aStrdup_(const char *p, const char *file, int line, const char *func)
+static char *aStrdup_(const char *p, const char *file, int line, const char *func)
{
char *ret = STRDUP(p, file, line, func);
// ShowMessage("%s:%d: in func %s: aStrdup %p\n",file,line,func,p);
@@ -195,7 +195,7 @@ char* aStrdup_(const char *p, const char *file, int line, const char *func)
* @param func @see ALC_MARK.
* @return the copied string.
*/
-char *aStrndup_(const char *p, size_t size, const char *file, int line, const char *func)
+static char *aStrndup_(const char *p, size_t size, const char *file, int line, const char *func)
{
size_t len = strnlen(p, size);
char *ret = MALLOC(len + 1, file, line, func);
@@ -208,7 +208,7 @@ char *aStrndup_(const char *p, size_t size, const char *file, int line, const ch
return ret;
}
-void aFree_(void *p, const char *file, int line, const char *func)
+static void aFree_(void *p, const char *file, int line, const char *func)
{
// ShowMessage("%s:%d: in func %s: aFree %p\n",file,line,func,p);
if (p)
@@ -279,8 +279,8 @@ struct unit_head {
long checksum;
};
-static struct block* hash_unfill[BLOCK_DATA_COUNT1 + BLOCK_DATA_COUNT2 + 1];
-static struct block* block_first, *block_last, block_head;
+static struct block *hash_unfill[BLOCK_DATA_COUNT1 + BLOCK_DATA_COUNT2 + 1];
+static struct block *block_first, *block_last, block_head;
/* Data for areas that do not use the memory be turned */
struct unit_head_large {
@@ -292,8 +292,8 @@ struct unit_head_large {
static struct unit_head_large *unit_head_large_first = NULL;
-static struct block* block_malloc(unsigned short hash);
-static void block_free(struct block* p);
+static struct block *block_malloc(unsigned short hash);
+static void block_free(struct block *p);
static size_t memmgr_usage_bytes;
static size_t memmgr_usage_bytes_t;
@@ -301,7 +301,7 @@ static size_t memmgr_usage_bytes_t;
#define block2unit(p, n) ((struct unit_head*)(&(p)->data[ p->unit_size * (n) ]))
#define memmgr_assert(v) do { if(!(v)) { ShowError("Memory manager: assertion '" #v "' failed!\n"); } } while(0)
-static unsigned short size2hash( size_t size )
+static unsigned short size2hash(size_t size)
{
if( size <= BLOCK_DATA_SIZE1 ) {
return (unsigned short)(size + BLOCK_ALIGNMENT1 - 1) / BLOCK_ALIGNMENT1;
@@ -313,7 +313,7 @@ static unsigned short size2hash( size_t size )
}
}
-static size_t hash2size( unsigned short hash )
+static size_t hash2size(unsigned short hash)
{
if( hash <= BLOCK_DATA_COUNT1) {
return hash * BLOCK_ALIGNMENT1;
@@ -322,7 +322,8 @@ static size_t hash2size( unsigned short hash )
}
}
-void *mmalloc_(size_t size, const char *file, int line, const char *func) {
+static void *mmalloc_(size_t size, const char *file, int line, const char *func)
+{
struct block *block;
short size_hash = size2hash( size );
struct unit_head *head;
@@ -428,14 +429,16 @@ void *mmalloc_(size_t size, const char *file, int line, const char *func) {
return (char *)head + sizeof(struct unit_head) - sizeof(long);
}
-void *mcalloc_(size_t num, size_t size, const char *file, int line, const char *func) {
+static void *mcalloc_(size_t num, size_t size, const char *file, int line, const char *func)
+{
void *p = iMalloc->malloc(num * size,file,line,func);
if (p)
memset(p, 0, num * size);
return p;
}
-void *mrealloc_(void *memblock, size_t size, const char *file, int line, const char *func) {
+static void *mrealloc_(void *memblock, size_t size, const char *file, int line, const char *func)
+{
size_t old_size;
if(memblock == NULL) {
return iMalloc->malloc(size,file,line,func);
@@ -460,7 +463,8 @@ void *mrealloc_(void *memblock, size_t size, const char *file, int line, const c
}
/* a mrealloc_ clone with the difference it 'z'eroes the newly created memory */
-void *mreallocz_(void *memblock, size_t size, const char *file, int line, const char *func) {
+static void *mreallocz_(void *memblock, size_t size, const char *file, int line, const char *func)
+{
size_t old_size;
void *p = NULL;
@@ -490,7 +494,8 @@ void *mreallocz_(void *memblock, size_t size, const char *file, int line, const
}
-char *mstrdup_(const char *p, const char *file, int line, const char *func) {
+static char *mstrdup_(const char *p, const char *file, int line, const char *func)
+{
if(p == NULL) {
return NULL;
} else {
@@ -518,7 +523,7 @@ char *mstrdup_(const char *p, const char *file, int line, const char *func) {
* @return the copied string.
* @retval NULL if the source string is NULL or in case of error.
*/
-char *mstrndup_(const char *p, size_t size, const char *file, int line, const char *func)
+static char *mstrndup_(const char *p, size_t size, const char *file, int line, const char *func)
{
if (p == NULL) {
return NULL;
@@ -532,7 +537,8 @@ char *mstrndup_(const char *p, size_t size, const char *file, int line, const ch
}
-void mfree_(void *ptr, const char *file, int line, const char *func) {
+static void mfree_(void *ptr, const char *file, int line, const char *func)
+{
struct unit_head *head;
if (ptr == NULL)
@@ -604,7 +610,7 @@ void mfree_(void *ptr, const char *file, int line, const char *func) {
}
/* Allocating blocks */
-static struct block* block_malloc(unsigned short hash)
+static struct block *block_malloc(unsigned short hash)
{
struct block *p;
if(hash_unfill[0] != NULL) {
@@ -661,7 +667,7 @@ static struct block* block_malloc(unsigned short hash)
return p;
}
-static void block_free(struct block* p)
+static void block_free(struct block *p)
{
if( p->unfill_prev ) {
if( p->unfill_prev == &block_head) {
@@ -679,7 +685,7 @@ static void block_free(struct block* p)
hash_unfill[0] = p;
}
-size_t memmgr_usage (void)
+static size_t memmgr_usage(void)
{
return memmgr_usage_bytes / 1024;
}
@@ -688,7 +694,8 @@ size_t memmgr_usage (void)
static char memmer_logfile[128];
static FILE *log_fp;
-static void memmgr_log(char *buf, char *vcsinfo) {
+static void memmgr_log(char *buf, char *vcsinfo)
+{
if( !log_fp ) {
time_t raw;
struct tm* t;
@@ -711,7 +718,7 @@ static void memmgr_log(char *buf, char *vcsinfo) {
///
/// @param ptr Pointer to the memory
/// @return true if the memory is active
-bool memmgr_verify(void* ptr)
+static bool memmgr_verify(void *ptr)
{
struct block* block = block_first;
struct unit_head_large* large = unit_head_large_first;
@@ -752,7 +759,7 @@ bool memmgr_verify(void* ptr)
return false;
}
-static void memmgr_final (void)
+static void memmgr_final(void)
{
struct block *block = block_first;
struct unit_head_large *large = unit_head_large_first;
@@ -808,7 +815,8 @@ static void memmgr_final (void)
#endif /* LOG_MEMMGR */
}
/* [Ind/Hercules] */
-void memmgr_report (int extra) {
+void memmgr_report(int extra)
+{
struct block *block = block_first;
struct unit_head_large *large = unit_head_large_first;
unsigned int count = 0, size = 0;
@@ -918,7 +926,7 @@ static void memmgr_init_messages(void)
/// Tests the memory for errors and memory leaks.
-void malloc_memory_check(void)
+static void malloc_memory_check(void)
{
MEMORY_CHECK();
}
@@ -926,7 +934,8 @@ void malloc_memory_check(void)
/// Returns true if a pointer is valid.
/// The check is best-effort, false positives are possible.
-bool malloc_verify_ptr(void* ptr) {
+static bool malloc_verify_ptr(void *ptr)
+{
#ifdef USE_MEMMGR
return memmgr_verify(ptr) && MEMORY_VERIFY(ptr);
#else
@@ -935,7 +944,8 @@ bool malloc_verify_ptr(void* ptr) {
}
-size_t malloc_usage (void) {
+static size_t malloc_usage(void)
+{
#ifdef USE_MEMMGR
return memmgr_usage ();
#else
@@ -943,7 +953,8 @@ size_t malloc_usage (void) {
#endif
}
-void malloc_final (void) {
+static void malloc_final(void)
+{
#ifdef USE_MEMMGR
memmgr_final ();
#endif
@@ -959,14 +970,14 @@ void malloc_final (void) {
* chance to other modules to initialize, in case they want to silence any
* status messages, but at the same time require malloc.
*/
-void malloc_init_messages(void)
+static void malloc_init_messages(void)
{
#ifdef USE_MEMMGR
memmgr_init_messages();
#endif
}
-void malloc_init(void)
+static void malloc_init(void)
{
#ifdef USE_MEMMGR
memmgr_usage_bytes_t = 0;
@@ -986,7 +997,8 @@ void malloc_init(void)
#endif
}
-void malloc_defaults(void) {
+void malloc_defaults(void)
+{
iMalloc = &iMalloc_s;
iMalloc->init = malloc_init;
iMalloc->final = malloc_final;
diff --git a/src/common/mutex.c b/src/common/mutex.c
index fab1c45c0..dd63d2adc 100644
--- a/src/common/mutex.c
+++ b/src/common/mutex.c
@@ -39,7 +39,7 @@
* Implementation of the mutex interface.
*/
-struct mutex_interface mutex_s;
+static struct mutex_interface mutex_s;
struct mutex_interface *mutex;
struct mutex_data {
@@ -65,7 +65,7 @@ struct cond_data {
/* Mutex */
/// @copydoc mutex_interface::create()
-struct mutex_data *mutex_create(void)
+static struct mutex_data *mutex_create(void)
{
struct mutex_data *m = aMalloc(sizeof(struct mutex_data));
if (m == NULL) {
@@ -83,7 +83,7 @@ struct mutex_data *mutex_create(void)
}
/// @copydoc mutex_interface::destroy()
-void mutex_destroy(struct mutex_data *m)
+static void mutex_destroy(struct mutex_data *m)
{
nullpo_retv(m);
#ifdef WIN32
@@ -96,7 +96,7 @@ void mutex_destroy(struct mutex_data *m)
}
/// @copydoc mutex_interface::lock()
-void mutex_lock(struct mutex_data *m)
+static void mutex_lock(struct mutex_data *m)
{
nullpo_retv(m);
#ifdef WIN32
@@ -107,7 +107,7 @@ void mutex_lock(struct mutex_data *m)
}
/// @copydoc mutex_interface::trylock()
-bool mutex_trylock(struct mutex_data *m)
+static bool mutex_trylock(struct mutex_data *m)
{
nullpo_retr(false, m);
#ifdef WIN32
@@ -121,7 +121,7 @@ bool mutex_trylock(struct mutex_data *m)
}
/// @copydoc mutex_interface::unlock()
-void mutex_unlock(struct mutex_data *m)
+static void mutex_unlock(struct mutex_data *m)
{
nullpo_retv(m);
#ifdef WIN32
@@ -134,7 +134,7 @@ void mutex_unlock(struct mutex_data *m)
/* Conditional variable */
/// @copydoc mutex_interface::cond_create()
-struct cond_data *cond_create(void)
+static struct cond_data *cond_create(void)
{
struct cond_data *c = aMalloc(sizeof(struct cond_data));
if (c == NULL) {
@@ -155,7 +155,7 @@ struct cond_data *cond_create(void)
}
/// @copydoc mutex_interface::cond_destroy()
-void cond_destroy(struct cond_data *c)
+static void cond_destroy(struct cond_data *c)
{
nullpo_retv(c);
#ifdef WIN32
@@ -170,7 +170,7 @@ void cond_destroy(struct cond_data *c)
}
/// @copydoc mutex_interface::cond_wait()
-void cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks)
+static void cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks)
{
#ifdef WIN32
register DWORD ms;
@@ -224,7 +224,7 @@ void cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks)
}
/// @copydoc mutex_interface::cond_signal()
-void cond_signal(struct cond_data *c)
+static void cond_signal(struct cond_data *c)
{
#ifdef WIN32
# if 0
@@ -245,7 +245,7 @@ void cond_signal(struct cond_data *c)
}
/// @copydoc mutex_interface::cond_broadcast()
-void cond_broadcast(struct cond_data *c)
+static void cond_broadcast(struct cond_data *c)
{
#ifdef WIN32
# if 0
diff --git a/src/common/nullpo.c b/src/common/nullpo.c
index 1441ff853..e19f7f846 100644
--- a/src/common/nullpo.c
+++ b/src/common/nullpo.c
@@ -32,7 +32,7 @@
#include <execinfo.h>
#endif // HAVE_EXECINFO
-struct nullpo_interface nullpo_s;
+static struct nullpo_interface nullpo_s;
struct nullpo_interface *nullpo;
/**
@@ -44,7 +44,8 @@ struct nullpo_interface *nullpo;
* @param targetname Name of the checked symbol
* @param title Message title to display (i.e. failed assertion or nullpo info)
*/
-void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) {
+static void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title)
+{
#ifdef HAVE_EXECINFO
void *array[10];
int size;
@@ -72,7 +73,8 @@ void assert_report(const char *file, int line, const char *func, const char *tar
/**
*
**/
-void nullpo_defaults(void) {
+void nullpo_defaults(void)
+{
nullpo = &nullpo_s;
nullpo->assert_report = assert_report;
}
diff --git a/src/common/random.c b/src/common/random.c
index 6fbaba91c..9bbe4f86c 100644
--- a/src/common/random.c
+++ b/src/common/random.c
@@ -40,11 +40,11 @@
* Implementation of the random number generator interface.
*/
-struct rnd_interface rnd_s;
+static struct rnd_interface rnd_s;
struct rnd_interface *rnd;
/// @copydoc rnd_interface::init()
-void rnd_init(void)
+static void rnd_init(void)
{
unsigned long seed = (unsigned long)timer->gettick();
seed += (unsigned long)time(NULL);
@@ -66,30 +66,30 @@ void rnd_init(void)
}
/// @copydoc rnd_interface::final()
-void rnd_final(void)
+static void rnd_final(void)
{
}
/// @copydoc rnd_interface::seed()
-void rnd_seed(uint32 seed)
+static void rnd_seed(uint32 seed)
{
init_genrand(seed);
}
/// @copydoc rnd_interface::random()
-int32 rnd_random(void)
+static int32 rnd_random(void)
{
return (int32)genrand_int31();
}
/// @copydoc rnd_interface::roll()
-uint32 rnd_roll(uint32 dice_faces)
+static uint32 rnd_roll(uint32 dice_faces)
{
return (uint32)(rnd->uniform()*dice_faces);
}
/// @copydoc rnd_interface::value()
-int32 rnd_value(int32 min, int32 max)
+static int32 rnd_value(int32 min, int32 max)
{
if (min >= max)
return min;
@@ -97,13 +97,13 @@ int32 rnd_value(int32 min, int32 max)
}
/// @copydoc rnd_interface::uniform()
-double rnd_uniform(void)
+static double rnd_uniform(void)
{
return ((uint32)genrand_int32())*(1.0/4294967296.0);// divided by 2^32
}
/// @copydoc rnd_interface::uniform53()
-double rnd_uniform53(void)
+static double rnd_uniform53(void)
{
return genrand_res53();
}
diff --git a/src/common/showmsg.c b/src/common/showmsg.c
index 8bcd1b4c7..91f84e9d3 100644
--- a/src/common/showmsg.c
+++ b/src/common/showmsg.c
@@ -45,7 +45,7 @@
#define DEBUGLOGPATH "log"PATHSEP_STR"login-server.log"
#endif
-struct showmsg_interface showmsg_s;
+static struct showmsg_interface showmsg_s;
struct showmsg_interface *showmsg;
///////////////////////////////////////////////////////////////////////////////
@@ -186,7 +186,7 @@ Escape sequences for Select Character Set
#define is_console(handle) (FILE_TYPE_CHAR==GetFileType(handle))
///////////////////////////////////////////////////////////////////////////////
-int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
+static int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
{
/////////////////////////////////////////////////////////////////
/* XXX Two streams are being used. Disabled to avoid inconsistency [flaviojs]
@@ -467,8 +467,9 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
return 0;
}
-int FPRINTF(HANDLE handle, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
-int FPRINTF(HANDLE handle, const char *fmt, ...) {
+static int FPRINTF(HANDLE handle, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+static int FPRINTF(HANDLE handle, const char *fmt, ...)
+{
int ret;
va_list argptr;
va_start(argptr, fmt);
@@ -488,7 +489,7 @@ int FPRINTF(HANDLE handle, const char *fmt, ...) {
#define is_console(file) (0!=isatty(fileno(file)))
//vprintf_without_ansiformats
-int VFPRINTF(FILE *file, const char *fmt, va_list argptr)
+static int VFPRINTF(FILE *file, const char *fmt, va_list argptr)
{
char *p, *q;
NEWBUF(tempbuf); // temporary buffer
@@ -584,8 +585,9 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr)
FREEBUF(tempbuf);
return 0;
}
-int FPRINTF(FILE *file, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
-int FPRINTF(FILE *file, const char *fmt, ...) {
+static int FPRINTF(FILE *file, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+static int FPRINTF(FILE *file, const char *fmt, ...)
+{
int ret;
va_list argptr;
va_start(argptr, fmt);
@@ -601,7 +603,7 @@ int FPRINTF(FILE *file, const char *fmt, ...) {
#endif// not _WIN32
-int vShowMessage_(enum msg_type flag, const char *string, va_list ap)
+static int vShowMessage_(enum msg_type flag, const char *string, va_list ap)
{
va_list apcopy;
char prefix[100];
@@ -720,7 +722,7 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap)
return 0;
}
-int showmsg_vShowMessage(const char *string, va_list ap)
+static int showmsg_vShowMessage(const char *string, va_list ap)
{
int ret;
va_list apcopy;
@@ -730,14 +732,16 @@ int showmsg_vShowMessage(const char *string, va_list ap)
return ret;
}
-void showmsg_clearScreen(void)
+static void showmsg_clearScreen(void)
{
#ifndef _WIN32
ShowMessage(CL_CLS); // to prevent empty string passed messages
#endif
}
-int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3)));
-int ShowMessage_(enum msg_type flag, const char *string, ...) {
+
+static int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3)));
+static int ShowMessage_(enum msg_type flag, const char *string, ...)
+{
int ret;
va_list ap;
va_start(ap, string);
@@ -747,56 +751,56 @@ int ShowMessage_(enum msg_type flag, const char *string, ...) {
}
// direct printf replacement
-void showmsg_showMessage(const char *string, ...) __attribute__((format(printf, 1, 2)));
-void showmsg_showMessage(const char *string, ...)
+static void showmsg_showMessage(const char *string, ...) __attribute__((format(printf, 1, 2)));
+static void showmsg_showMessage(const char *string, ...)
{
va_list ap;
va_start(ap, string);
vShowMessage_(MSG_NONE, string, ap);
va_end(ap);
}
-void showmsg_showStatus(const char *string, ...) __attribute__((format(printf, 1, 2)));
-void showmsg_showStatus(const char *string, ...)
+static void showmsg_showStatus(const char *string, ...) __attribute__((format(printf, 1, 2)));
+static void showmsg_showStatus(const char *string, ...)
{
va_list ap;
va_start(ap, string);
vShowMessage_(MSG_STATUS, string, ap);
va_end(ap);
}
-void showmsg_showSQL(const char *string, ...) __attribute__((format(printf, 1, 2)));
-void showmsg_showSQL(const char *string, ...)
+static void showmsg_showSQL(const char *string, ...) __attribute__((format(printf, 1, 2)));
+static void showmsg_showSQL(const char *string, ...)
{
va_list ap;
va_start(ap, string);
vShowMessage_(MSG_SQL, string, ap);
va_end(ap);
}
-void showmsg_showInfo(const char *string, ...) __attribute__((format(printf, 1, 2)));
-void showmsg_showInfo(const char *string, ...)
+static void showmsg_showInfo(const char *string, ...) __attribute__((format(printf, 1, 2)));
+static void showmsg_showInfo(const char *string, ...)
{
va_list ap;
va_start(ap, string);
vShowMessage_(MSG_INFORMATION, string, ap);
va_end(ap);
}
-void showmsg_showNotice(const char *string, ...) __attribute__((format(printf, 1, 2)));
-void showmsg_showNotice(const char *string, ...)
+static void showmsg_showNotice(const char *string, ...) __attribute__((format(printf, 1, 2)));
+static void showmsg_showNotice(const char *string, ...)
{
va_list ap;
va_start(ap, string);
vShowMessage_(MSG_NOTICE, string, ap);
va_end(ap);
}
-void showmsg_showWarning(const char *string, ...) __attribute__((format(printf, 1, 2)));
-void showmsg_showWarning(const char *string, ...)
+static void showmsg_showWarning(const char *string, ...) __attribute__((format(printf, 1, 2)));
+static void showmsg_showWarning(const char *string, ...)
{
va_list ap;
va_start(ap, string);
vShowMessage_(MSG_WARNING, string, ap);
va_end(ap);
}
-void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3)));
-void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...)
+static void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3)));
+static void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...)
{
StringBuf buf;
va_list ap;
@@ -812,24 +816,24 @@ void showmsg_showConfigWarning(struct config_setting_t *config, const char *stri
va_end(ap);
StrBuf->Destroy(&buf);
}
-void showmsg_showDebug(const char *string, ...) __attribute__((format(printf, 1, 2)));
-void showmsg_showDebug(const char *string, ...)
+static void showmsg_showDebug(const char *string, ...) __attribute__((format(printf, 1, 2)));
+static void showmsg_showDebug(const char *string, ...)
{
va_list ap;
va_start(ap, string);
vShowMessage_(MSG_DEBUG, string, ap);
va_end(ap);
}
-void showmsg_showError(const char *string, ...) __attribute__((format(printf, 1, 2)));
-void showmsg_showError(const char *string, ...)
+static void showmsg_showError(const char *string, ...) __attribute__((format(printf, 1, 2)));
+static void showmsg_showError(const char *string, ...)
{
va_list ap;
va_start(ap, string);
vShowMessage_(MSG_ERROR, string, ap);
va_end(ap);
}
-void showmsg_showFatalError(const char *string, ...) __attribute__((format(printf, 1, 2)));
-void showmsg_showFatalError(const char *string, ...)
+static void showmsg_showFatalError(const char *string, ...) __attribute__((format(printf, 1, 2)));
+static void showmsg_showFatalError(const char *string, ...)
{
va_list ap;
va_start(ap, string);
@@ -837,11 +841,11 @@ void showmsg_showFatalError(const char *string, ...)
va_end(ap);
}
-void showmsg_init(void)
+static void showmsg_init(void)
{
}
-void showmsg_final(void)
+static void showmsg_final(void)
{
}
diff --git a/src/common/socket.c b/src/common/socket.c
index cec366765..6119a5341 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -75,19 +75,19 @@
/**
* Socket Interface Source
**/
-struct socket_interface sockt_s;
+static struct socket_interface sockt_s;
struct socket_interface *sockt;
-struct socket_data **session;
+static struct socket_data **session;
-const char *SOCKET_CONF_FILENAME = "conf/common/socket.conf";
+static const char *SOCKET_CONF_FILENAME = "conf/common/socket.conf";
#ifdef SEND_SHORTLIST
// Add a fd to the shortlist so that it'll be recognized as a fd that needs
// sending done on it.
-void send_shortlist_add_fd(int fd);
+static void send_shortlist_add_fd(int fd);
// Do pending network sends (and eof handling) from the shortlist.
-void send_shortlist_do_sends(void);
+static void send_shortlist_do_sends(void);
#endif // SEND_SHORTLIST
/////////////////////////////////////////////////////////////////////
@@ -123,7 +123,7 @@ static int sock_arr_len = 0;
///
/// @param s Socket
/// @return Fd or -1
-int sock2fd(SOCKET s)
+static int sock2fd(SOCKET s)
{
int fd;
@@ -144,7 +144,7 @@ int sock2fd(SOCKET s)
///
/// @param s Socket
/// @return New fd or -1
-int sock2newfd(SOCKET s)
+static int sock2newfd(SOCKET s)
{
int fd;
@@ -164,7 +164,7 @@ int sock2newfd(SOCKET s)
return fd;
}
-int sAccept(int fd, struct sockaddr* addr, int* addrlen)
+static int sAccept(int fd, struct sockaddr *addr, int *addrlen)
{
SOCKET s;
@@ -175,14 +175,14 @@ int sAccept(int fd, struct sockaddr* addr, int* addrlen)
return sock2newfd(s);
}
-int sClose(int fd)
+static int sClose(int fd)
{
int ret = closesocket(fd2sock(fd));
fd2sock(fd) = INVALID_SOCKET;
return ret;
}
-int sSocket(int af, int type, int protocol)
+static int sSocket(int af, int type, int protocol)
{
SOCKET s;
@@ -193,7 +193,7 @@ int sSocket(int af, int type, int protocol)
return sock2newfd(s);
}
-char* sErr(int code)
+static char *sErr(int code)
{
static char sbuf[512];
// strerror does not handle socket codes
@@ -259,7 +259,7 @@ char* sErr(int code)
#ifndef SOCKET_EPOLL
// Select based Event Dispatcher:
-fd_set readfds;
+static fd_set readfds;
#else // SOCKET_EPOLL
// Epoll based Event Dispatcher:
@@ -296,19 +296,19 @@ static time_t socket_data_last_tick = 0;
#define WFIFO_MAX (1*1024*1024)
#ifdef SEND_SHORTLIST
-int send_shortlist_array[FD_SETSIZE];// we only support FD_SETSIZE sockets, limit the array to that
-int send_shortlist_count = 0;// how many fd's are in the shortlist
-uint32 send_shortlist_set[(FD_SETSIZE+31)/32];// to know if specific fd's are already in the shortlist
+static int send_shortlist_array[FD_SETSIZE];// we only support FD_SETSIZE sockets, limit the array to that
+static int send_shortlist_count = 0;// how many fd's are in the shortlist
+static uint32 send_shortlist_set[(FD_SETSIZE+31)/32];// to know if specific fd's are already in the shortlist
#endif // SEND_SHORTLIST
static int create_session(int fd, RecvFunc func_recv, SendFunc func_send, ParseFunc func_parse);
#ifndef MINICORE
- int ip_rules = 1;
+ static int ip_rules = 1;
static int connect_check(uint32 ip);
#endif // MINICORE
-const char* error_msg(void)
+static const char *error_msg(void)
{
static char buf[512];
int code = sErrno;
@@ -319,13 +319,24 @@ const char* error_msg(void)
/*======================================
* CORE : Default processing functions
*--------------------------------------*/
-int null_recv(int fd) { return 0; }
-int null_send(int fd) { return 0; }
-int null_parse(int fd) { return 0; }
+static int null_recv(int fd)
+{
+ return 0;
+}
+
+static int null_send(int fd)
+{
+ return 0;
+}
+
+static int null_parse(int fd)
+{
+ return 0;
+}
-ParseFunc default_func_parse = null_parse;
+static ParseFunc default_func_parse = null_parse;
-void set_defaultparse(ParseFunc defaultparse)
+static void set_defaultparse(ParseFunc defaultparse)
{
default_func_parse = defaultparse;
}
@@ -333,7 +344,7 @@ void set_defaultparse(ParseFunc defaultparse)
/*======================================
* CORE : Socket options
*--------------------------------------*/
-void set_nonblocking(int fd, unsigned long yes)
+static void set_nonblocking(int fd, unsigned long yes)
{
// FIONBIO Use with a nonzero argp parameter to enable the nonblocking mode of socket s.
// The argp parameter is zero if nonblocking is to be disabled.
@@ -347,7 +358,7 @@ void set_nonblocking(int fd, unsigned long yes)
* @param fd The socket descriptor
* @param opt Optional, additional options to set (Can be NULL).
*/
-void setsocketopts(int fd, struct hSockOpt *opt)
+static void setsocketopts(int fd, struct hSockOpt *opt)
{
#if defined(WIN32)
BOOL yes = TRUE;
@@ -409,7 +420,7 @@ void setsocketopts(int fd, struct hSockOpt *opt)
/*======================================
* CORE : Socket Sub Function
*--------------------------------------*/
-void set_eof(int fd)
+static void set_eof(int fd)
{
if (sockt->session_is_active(fd)) {
#ifdef SEND_SHORTLIST
@@ -420,7 +431,7 @@ void set_eof(int fd)
}
}
-int recv_to_fifo(int fd)
+static int recv_to_fifo(int fd)
{
ssize_t len;
@@ -457,7 +468,7 @@ int recv_to_fifo(int fd)
return 0;
}
-int send_from_fifo(int fd)
+static int send_from_fifo(int fd)
{
ssize_t len;
@@ -504,13 +515,13 @@ int send_from_fifo(int fd)
}
/// Best effort - there's no warranty that the data will be sent.
-void flush_fifo(int fd)
+static void flush_fifo(int fd)
{
if(sockt->session[fd] != NULL)
sockt->session[fd]->func_send(fd);
}
-void flush_fifos(void)
+static void flush_fifos(void)
{
int i;
for(i = 1; i < sockt->fd_max; i++)
@@ -520,7 +531,7 @@ void flush_fifos(void)
/*======================================
* CORE : Connection functions
*--------------------------------------*/
-int connect_client(int listen_fd)
+static int connect_client(int listen_fd)
{
int fd;
struct sockaddr_in client_address;
@@ -579,7 +590,7 @@ int connect_client(int listen_fd)
return fd;
}
-int make_listen_bind(uint32 ip, uint16 port)
+static int make_listen_bind(uint32 ip, uint16 port)
{
struct sockaddr_in server_address = { 0 };
int fd;
@@ -648,7 +659,7 @@ int make_listen_bind(uint32 ip, uint16 port)
return fd;
}
-int make_connection(uint32 ip, uint16 port, struct hSockOpt *opt)
+static int make_connection(uint32 ip, uint16 port, struct hSockOpt *opt)
{
struct sockaddr_in remote_address = { 0 };
int fd;
@@ -749,7 +760,7 @@ static void delete_session(int fd)
}
}
-int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size)
+static int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size)
{
if (!sockt->session_is_valid(fd))
return 0;
@@ -766,7 +777,7 @@ int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size)
return 0;
}
-int realloc_writefifo(int fd, size_t addition)
+static int realloc_writefifo(int fd, size_t addition)
{
size_t newsize;
@@ -794,7 +805,7 @@ int realloc_writefifo(int fd, size_t addition)
}
/// advance the RFIFO cursor (marking 'len' bytes as processed)
-int rfifoskip(int fd, size_t len)
+static int rfifoskip(int fd, size_t len)
{
struct socket_data *s;
@@ -816,7 +827,7 @@ int rfifoskip(int fd, size_t len)
}
/// advance the WFIFO cursor (marking 'len' bytes for sending)
-int wfifoset(int fd, size_t len)
+static int wfifoset(int fd, size_t len)
{
size_t newreserve;
struct socket_data* s;
@@ -884,7 +895,7 @@ int wfifoset(int fd, size_t len)
return 0;
}
-int do_sockets(int next)
+static int do_sockets(int next)
{
#ifndef SOCKET_EPOLL
fd_set rfd;
@@ -1088,7 +1099,7 @@ static int access_debug = 0;
static int ddos_count = 10;
static int ddos_interval = 3*1000;
static int ddos_autoreset = 10*60*1000;
-struct DBMap *connect_history = NULL;
+static struct DBMap *connect_history = NULL;
static int connect_check_(uint32 ip);
@@ -1232,7 +1243,7 @@ static int connect_check_clear(int tid, int64 tick, int id, intptr_t data)
/// Parses the ip address and mask and puts it into acc.
/// Returns 1 is successful, 0 otherwise.
-int access_ipmask(const char *str, struct access_control *acc)
+static int access_ipmask(const char *str, struct access_control *acc)
{
uint32 ip;
uint32 mask;
@@ -1288,7 +1299,7 @@ int access_ipmask(const char *str, struct access_control *acc)
*
* @retval false in case of failure
*/
-bool access_list_add(struct config_setting_t *setting, const char *list_name, struct access_control_list *access_list)
+static bool access_list_add(struct config_setting_t *setting, const char *list_name, struct access_control_list *access_list)
{
const char *temp = NULL;
int i, setting_length;
@@ -1330,7 +1341,7 @@ bool access_list_add(struct config_setting_t *setting, const char *list_name, st
*
* @retval false in case of error.
*/
-bool socket_config_read_iprules(const char *filename, struct config_t *config, bool imported)
+static bool socket_config_read_iprules(const char *filename, struct config_t *config, bool imported)
{
#ifndef MINICORE
struct config_setting_t *setting = NULL;
@@ -1389,7 +1400,7 @@ bool socket_config_read_iprules(const char *filename, struct config_t *config, b
*
* @retval false in case of error.
*/
-bool socket_config_read_ddos(const char *filename, struct config_t *config, bool imported)
+static bool socket_config_read_ddos(const char *filename, struct config_t *config, bool imported)
{
#ifndef MINICORE
struct config_setting_t *setting = NULL;
@@ -1420,7 +1431,7 @@ bool socket_config_read_ddos(const char *filename, struct config_t *config, bool
*
* @retval false in case of error.
*/
-bool socket_config_read(const char *filename, bool imported)
+static bool socket_config_read(const char *filename, bool imported)
{
struct config_t config;
struct config_setting_t *setting = NULL;
@@ -1484,7 +1495,7 @@ bool socket_config_read(const char *filename, bool imported)
return retval;
}
-void socket_final(void)
+static void socket_final(void)
{
int i;
#ifndef MINICORE
@@ -1523,7 +1534,7 @@ void socket_final(void)
}
/// Closes a socket.
-void socket_close(int fd)
+static void socket_close(int fd)
{
if( fd <= 0 ||fd >= FD_SETSIZE )
return;// invalid
@@ -1547,7 +1558,7 @@ void socket_close(int fd)
/// Retrieve local ips in host byte order.
/// Uses loopback is no address is found.
-int socket_getips(uint32* ips, int max)
+static int socket_getips(uint32 *ips, int max)
{
int num = 0;
@@ -1628,7 +1639,7 @@ int socket_getips(uint32* ips, int max)
return num;
}
-void socket_init(void)
+static void socket_init(void)
{
uint64 rlim_cur = FD_SETSIZE;
@@ -1730,18 +1741,18 @@ void socket_init(void)
ShowInfo("Server supports up to '"CL_WHITE"%"PRIu64""CL_RESET"' concurrent connections.\n", rlim_cur);
}
-bool session_is_valid(int fd)
+static bool session_is_valid(int fd)
{
return ( fd > 0 && fd < FD_SETSIZE && sockt->session[fd] != NULL );
}
-bool session_is_active(int fd)
+static bool session_is_active(int fd)
{
return ( sockt->session_is_valid(fd) && !sockt->session[fd]->flag.eof );
}
// Resolves hostname into a numeric ip.
-uint32 host2ip(const char *hostname)
+static uint32 host2ip(const char *hostname)
{
struct hostent* h;
nullpo_ret(hostname);
@@ -1757,7 +1768,7 @@ uint32 host2ip(const char *hostname)
*
* @return A pointer to the output string.
*/
-const char *ip2str(uint32 ip, char *ip_str)
+static const char *ip2str(uint32 ip, char *ip_str)
{
struct in_addr addr;
addr.s_addr = htonl(ip);
@@ -1765,20 +1776,20 @@ const char *ip2str(uint32 ip, char *ip_str)
}
// Converts a dot-formatted ip string into a numeric ip.
-uint32 str2ip(const char* ip_str)
+static uint32 str2ip(const char *ip_str)
{
return ntohl(inet_addr(ip_str));
}
// Reorders bytes from network to little endian (Windows).
// Necessary for sending port numbers to the RO client until Gravity notices that they forgot ntohs() calls.
-uint16 ntows(uint16 netshort)
+static uint16 ntows(uint16 netshort)
{
return ((netshort & 0xFF) << 8) | ((netshort & 0xFF00) >> 8);
}
/* [Ind/Hercules] - socket_datasync */
-void socket_datasync(int fd, bool send)
+static void socket_datasync(int fd, bool send)
{
struct {
unsigned int length;/* short is not enough for some */
@@ -1845,7 +1856,7 @@ void socket_datasync(int fd, bool send)
#ifdef SEND_SHORTLIST
// Add a fd to the shortlist so that it'll be recognized as a fd that needs
// sending or eof handling.
-void send_shortlist_add_fd(int fd)
+static void send_shortlist_add_fd(int fd)
{
int i;
int bit;
@@ -1872,7 +1883,7 @@ void send_shortlist_add_fd(int fd)
}
// Do pending network sends and eof handling from the shortlist.
-void send_shortlist_do_sends(void)
+static void send_shortlist_do_sends(void)
{
int i;
@@ -1928,7 +1939,7 @@ void send_shortlist_do_sends(void)
* @retval 0 if it is a WAN IP.
* @return the appropriate LAN server address to send, if it is a LAN IP.
*/
-uint32 socket_lan_subnet_check(uint32 ip, struct s_subnet *info)
+static uint32 socket_lan_subnet_check(uint32 ip, struct s_subnet *info)
{
int i;
ARR_FIND(0, VECTOR_LENGTH(sockt->lan_subnets), i, SUBNET_MATCH(ip, VECTOR_INDEX(sockt->lan_subnets, i).ip, VECTOR_INDEX(sockt->lan_subnets, i).mask));
@@ -1952,7 +1963,7 @@ uint32 socket_lan_subnet_check(uint32 ip, struct s_subnet *info)
* @retval true if we allow server connections from the given IP.
* @retval false otherwise.
*/
-bool socket_allowed_ip_check(uint32 ip)
+static bool socket_allowed_ip_check(uint32 ip)
{
int i;
ARR_FIND(0, VECTOR_LENGTH(sockt->allowed_ips), i, SUBNET_MATCH(ip, VECTOR_INDEX(sockt->allowed_ips, i).ip, VECTOR_INDEX(sockt->allowed_ips, i).mask));
@@ -1968,7 +1979,7 @@ bool socket_allowed_ip_check(uint32 ip)
* @retval true if we trust the given IP.
* @retval false otherwise.
*/
-bool socket_trusted_ip_check(uint32 ip)
+static bool socket_trusted_ip_check(uint32 ip)
{
int i;
ARR_FIND(0, VECTOR_LENGTH(sockt->trusted_ips), i, SUBNET_MATCH(ip, VECTOR_INDEX(sockt->trusted_ips, i).ip, VECTOR_INDEX(sockt->trusted_ips, i).mask));
@@ -1988,7 +1999,7 @@ bool socket_trusted_ip_check(uint32 ip)
* @param[in] groupname Current group name, for output/logging reasons.
* @return The amount of entries read, zero in case of errors.
*/
-int socket_net_config_read_sub(struct config_setting_t *t, struct s_subnet_vector *list, const char *filename, const char *groupname)
+static int socket_net_config_read_sub(struct config_setting_t *t, struct s_subnet_vector *list, const char *filename, const char *groupname)
{
int i, len;
char ipbuf[64], maskbuf[64];
@@ -2022,7 +2033,7 @@ int socket_net_config_read_sub(struct config_setting_t *t, struct s_subnet_vecto
*
* @param filename The filename to read from.
*/
-void socket_net_config_read(const char *filename)
+static void socket_net_config_read(const char *filename)
{
struct config_t network_config;
int i;
diff --git a/src/common/sql.c b/src/common/sql.c
index 6e0e9ba33..0b5b7fa07 100644
--- a/src/common/sql.c
+++ b/src/common/sql.c
@@ -37,12 +37,12 @@
#include <stdio.h>
#include <stdlib.h> // strtoul
-void hercules_mysql_error_handler(unsigned int ecode);
+static void hercules_mysql_error_handler(unsigned int ecode);
-int mysql_reconnect_type = 2;
-int mysql_reconnect_count = 1;
+static int mysql_reconnect_type = 2;
+static int mysql_reconnect_count = 1;
-struct sql_interface sql_s;
+static struct sql_interface sql_s;
struct sql_interface *SQL;
/// Sql handle
@@ -81,7 +81,7 @@ struct SqlStmt {
///////////////////////////////////////////////////////////////////////////////
/// Allocates and initializes a new Sql handle.
-struct Sql *Sql_Malloc(void)
+static struct Sql *Sql_Malloc(void)
{
struct Sql *self;
@@ -101,7 +101,7 @@ struct Sql *Sql_Malloc(void)
static int Sql_P_Keepalive(struct Sql *self);
/// Establishes a connection.
-int Sql_Connect(struct Sql *self, const char *user, const char *passwd, const char *host, uint16 port, const char *db)
+static int Sql_Connect(struct Sql *self, const char *user, const char *passwd, const char *host, uint16 port, const char *db)
{
if( self == NULL )
return SQL_ERROR;
@@ -124,7 +124,7 @@ int Sql_Connect(struct Sql *self, const char *user, const char *passwd, const ch
}
/// Retrieves the timeout of the connection.
-int Sql_GetTimeout(struct Sql *self, uint32 *out_timeout)
+static int Sql_GetTimeout(struct Sql *self, uint32 *out_timeout)
{
if( self && out_timeout && SQL_SUCCESS == SQL->Query(self, "SHOW VARIABLES LIKE 'wait_timeout'") ) {
char* data;
@@ -141,7 +141,7 @@ int Sql_GetTimeout(struct Sql *self, uint32 *out_timeout)
}
/// Retrieves the name of the columns of a table into out_buf, with the separator after each name.
-int Sql_GetColumnNames(struct Sql *self, const char *table, char *out_buf, size_t buf_len, char sep)
+static int Sql_GetColumnNames(struct Sql *self, const char *table, char *out_buf, size_t buf_len, char sep)
{
char* data;
size_t len;
@@ -170,7 +170,7 @@ int Sql_GetColumnNames(struct Sql *self, const char *table, char *out_buf, size_
}
/// Changes the encoding of the connection.
-int Sql_SetEncoding(struct Sql *self, const char *encoding)
+static int Sql_SetEncoding(struct Sql *self, const char *encoding)
{
if( self && mysql_set_character_set(&self->handle, encoding) == 0 )
return SQL_SUCCESS;
@@ -178,7 +178,7 @@ int Sql_SetEncoding(struct Sql *self, const char *encoding)
}
/// Pings the connection.
-int Sql_Ping(struct Sql *self)
+static int Sql_Ping(struct Sql *self)
{
if( self && mysql_ping(&self->handle) == 0 )
return SQL_SUCCESS;
@@ -220,7 +220,7 @@ static int Sql_P_Keepalive(struct Sql *self)
}
/// Escapes a string.
-size_t Sql_EscapeString(struct Sql *self, char *out_to, const char *from)
+static size_t Sql_EscapeString(struct Sql *self, char *out_to, const char *from)
{
if (self != NULL)
return (size_t)mysql_real_escape_string(&self->handle, out_to, from, (unsigned long)strlen(from));
@@ -229,7 +229,7 @@ size_t Sql_EscapeString(struct Sql *self, char *out_to, const char *from)
}
/// Escapes a string.
-size_t Sql_EscapeStringLen(struct Sql *self, char *out_to, const char *from, size_t from_len)
+static size_t Sql_EscapeStringLen(struct Sql *self, char *out_to, const char *from, size_t from_len)
{
if (self != NULL)
return (size_t)mysql_real_escape_string(&self->handle, out_to, from, (unsigned long)from_len);
@@ -238,8 +238,8 @@ size_t Sql_EscapeStringLen(struct Sql *self, char *out_to, const char *from, siz
}
/// Executes a query.
-int Sql_Query(struct Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
-int Sql_Query(struct Sql *self, const char *query, ...)
+static int Sql_Query(struct Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
+static int Sql_Query(struct Sql *self, const char *query, ...)
{
int res;
va_list args;
@@ -252,7 +252,7 @@ int Sql_Query(struct Sql *self, const char *query, ...)
}
/// Executes a query.
-int Sql_QueryV(struct Sql *self, const char *query, va_list args)
+static int Sql_QueryV(struct Sql *self, const char *query, va_list args)
{
if( self == NULL )
return SQL_ERROR;
@@ -277,7 +277,7 @@ int Sql_QueryV(struct Sql *self, const char *query, va_list args)
}
/// Executes a query.
-int Sql_QueryStr(struct Sql *self, const char *query)
+static int Sql_QueryStr(struct Sql *self, const char *query)
{
if( self == NULL )
return SQL_ERROR;
@@ -302,7 +302,7 @@ int Sql_QueryStr(struct Sql *self, const char *query)
}
/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE query.
-uint64 Sql_LastInsertId(struct Sql *self)
+static uint64 Sql_LastInsertId(struct Sql *self)
{
if (self != NULL)
return (uint64)mysql_insert_id(&self->handle);
@@ -311,7 +311,7 @@ uint64 Sql_LastInsertId(struct Sql *self)
}
/// Returns the number of columns in each row of the result.
-uint32 Sql_NumColumns(struct Sql *self)
+static uint32 Sql_NumColumns(struct Sql *self)
{
if (self != NULL && self->result != NULL)
return (uint32)mysql_num_fields(self->result);
@@ -319,7 +319,7 @@ uint32 Sql_NumColumns(struct Sql *self)
}
/// Returns the number of rows in the result.
-uint64 Sql_NumRows(struct Sql *self)
+static uint64 Sql_NumRows(struct Sql *self)
{
if (self != NULL && self->result != NULL)
return (uint64)mysql_num_rows(self->result);
@@ -327,7 +327,7 @@ uint64 Sql_NumRows(struct Sql *self)
}
/// Fetches the next row.
-int Sql_NextRow(struct Sql *self)
+static int Sql_NextRow(struct Sql *self)
{
if (self != NULL && self->result != NULL) {
self->row = mysql_fetch_row(self->result);
@@ -343,7 +343,7 @@ int Sql_NextRow(struct Sql *self)
}
/// Gets the data of a column.
-int Sql_GetData(struct Sql *self, size_t col, char **out_buf, size_t *out_len)
+static int Sql_GetData(struct Sql *self, size_t col, char **out_buf, size_t *out_len)
{
if( self && self->row ) {
if( col < SQL->NumColumns(self) ) {
@@ -359,7 +359,7 @@ int Sql_GetData(struct Sql *self, size_t col, char **out_buf, size_t *out_len)
}
/// Frees the result of the query.
-void Sql_FreeResult(struct Sql *self)
+static void Sql_FreeResult(struct Sql *self)
{
if( self && self->result ) {
mysql_free_result(self->result);
@@ -370,7 +370,7 @@ void Sql_FreeResult(struct Sql *self)
}
/// Shows debug information (last query).
-void Sql_ShowDebug_(struct Sql *self, const char *debug_file, const unsigned long debug_line)
+static void Sql_ShowDebug_(struct Sql *self, const char *debug_file, const unsigned long debug_line)
{
if( self == NULL )
ShowDebug("at %s:%lu - self is NULL\n", debug_file, debug_line);
@@ -381,7 +381,7 @@ void Sql_ShowDebug_(struct Sql *self, const char *debug_file, const unsigned lon
}
/// Frees a Sql handle returned by Sql_Malloc.
-void Sql_Free(struct Sql *self)
+static void Sql_Free(struct Sql *self)
{
if( self )
{
@@ -417,7 +417,7 @@ static enum enum_field_types Sql_P_SizeToMysqlIntType(int sz)
/// Binds a parameter/result.
///
/// @private
-static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type, void* buffer, size_t buffer_len, unsigned long* out_length, int8* out_is_null)
+static int Sql_P_BindSqlDataType(MYSQL_BIND *bind, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, unsigned long *out_length, int8 *out_is_null)
{
nullpo_retr(SQL_ERROR, bind);
memset(bind, 0, sizeof(MYSQL_BIND));
@@ -531,7 +531,7 @@ static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type,
/// Prints debug information about a field (type and length).
///
/// @private
-static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_types type, int is_unsigned, unsigned long length, const char* length_postfix)
+static void Sql_P_ShowDebugMysqlFieldInfo(const char *prefix, enum enum_field_types type, int is_unsigned, unsigned long length, const char *length_postfix)
{
const char *sign = (is_unsigned ? "UNSIGNED " : "");
const char *type_string = NULL;
@@ -588,7 +588,7 @@ static void SqlStmt_P_ShowDebugTruncatedColumn(struct SqlStmt *self, size_t i)
}
/// Allocates and initializes a new SqlStmt handle.
-struct SqlStmt *SqlStmt_Malloc(struct Sql *sql)
+static struct SqlStmt *SqlStmt_Malloc(struct Sql *sql)
{
struct SqlStmt *self;
MYSQL_STMT* stmt;
@@ -616,8 +616,8 @@ struct SqlStmt *SqlStmt_Malloc(struct Sql *sql)
}
/// Prepares the statement.
-int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
-int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...)
+static int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3)));
+static int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...)
{
int res;
va_list args;
@@ -630,7 +630,7 @@ int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...)
}
/// Prepares the statement.
-int SqlStmt_PrepareV(struct SqlStmt *self, const char *query, va_list args)
+static int SqlStmt_PrepareV(struct SqlStmt *self, const char *query, va_list args)
{
if( self == NULL )
return SQL_ERROR;
@@ -650,7 +650,7 @@ int SqlStmt_PrepareV(struct SqlStmt *self, const char *query, va_list args)
}
/// Prepares the statement.
-int SqlStmt_PrepareStr(struct SqlStmt *self, const char *query)
+static int SqlStmt_PrepareStr(struct SqlStmt *self, const char *query)
{
if( self == NULL )
return SQL_ERROR;
@@ -670,7 +670,7 @@ int SqlStmt_PrepareStr(struct SqlStmt *self, const char *query)
}
/// Returns the number of parameters in the prepared statement.
-size_t SqlStmt_NumParams(struct SqlStmt *self)
+static size_t SqlStmt_NumParams(struct SqlStmt *self)
{
if( self )
return (size_t)mysql_stmt_param_count(self->stmt);
@@ -679,7 +679,7 @@ size_t SqlStmt_NumParams(struct SqlStmt *self)
}
/// Binds a parameter to a buffer.
-int SqlStmt_BindParam(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, const void *buffer, size_t buffer_len)
+static int SqlStmt_BindParam(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, const void *buffer, size_t buffer_len)
{
if( self == NULL )
return SQL_ERROR;
@@ -716,7 +716,7 @@ PRAGMA_GCC46(GCC diagnostic pop)
}
/// Executes the prepared statement.
-int SqlStmt_Execute(struct SqlStmt *self)
+static int SqlStmt_Execute(struct SqlStmt *self)
{
if( self == NULL )
return SQL_ERROR;
@@ -741,7 +741,7 @@ int SqlStmt_Execute(struct SqlStmt *self)
}
/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement.
-uint64 SqlStmt_LastInsertId(struct SqlStmt *self)
+static uint64 SqlStmt_LastInsertId(struct SqlStmt *self)
{
if( self )
return (uint64)mysql_stmt_insert_id(self->stmt);
@@ -750,7 +750,7 @@ uint64 SqlStmt_LastInsertId(struct SqlStmt *self)
}
/// Returns the number of columns in each row of the result.
-size_t SqlStmt_NumColumns(struct SqlStmt *self)
+static size_t SqlStmt_NumColumns(struct SqlStmt *self)
{
if( self )
return (size_t)mysql_stmt_field_count(self->stmt);
@@ -759,7 +759,7 @@ size_t SqlStmt_NumColumns(struct SqlStmt *self)
}
/// Binds the result of a column to a buffer.
-int SqlStmt_BindColumn(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null)
+static int SqlStmt_BindColumn(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null)
{
if (self == NULL)
return SQL_ERROR;
@@ -801,7 +801,7 @@ int SqlStmt_BindColumn(struct SqlStmt *self, size_t idx, enum SqlDataType buffer
}
/// Returns the number of rows in the result.
-uint64 SqlStmt_NumRows(struct SqlStmt *self)
+static uint64 SqlStmt_NumRows(struct SqlStmt *self)
{
if (self != NULL)
return (uint64)mysql_stmt_num_rows(self->stmt);
@@ -810,7 +810,7 @@ uint64 SqlStmt_NumRows(struct SqlStmt *self)
}
/// Fetches the next row.
-int SqlStmt_NextRow(struct SqlStmt *self)
+static int SqlStmt_NextRow(struct SqlStmt *self)
{
int err;
size_t i;
@@ -878,14 +878,14 @@ int SqlStmt_NextRow(struct SqlStmt *self)
}
/// Frees the result of the statement execution.
-void SqlStmt_FreeResult(struct SqlStmt *self)
+static void SqlStmt_FreeResult(struct SqlStmt *self)
{
if( self )
mysql_stmt_free_result(self->stmt);
}
/// Shows debug information (with statement).
-void SqlStmt_ShowDebug_(struct SqlStmt *self, const char *debug_file, const unsigned long debug_line)
+static void SqlStmt_ShowDebug_(struct SqlStmt *self, const char *debug_file, const unsigned long debug_line)
{
if( self == NULL )
ShowDebug("at %s:%lu - self is NULL\n", debug_file, debug_line);
@@ -896,7 +896,7 @@ void SqlStmt_ShowDebug_(struct SqlStmt *self, const char *debug_file, const unsi
}
/// Frees a SqlStmt returned by SqlStmt_Malloc.
-void SqlStmt_Free(struct SqlStmt *self)
+static void SqlStmt_Free(struct SqlStmt *self)
{
if( self )
{
@@ -915,7 +915,7 @@ void SqlStmt_Free(struct SqlStmt *self)
}
/* receives mysql error codes during runtime (not on first-time-connects) */
-void hercules_mysql_error_handler(unsigned int ecode)
+static void hercules_mysql_error_handler(unsigned int ecode)
{
switch( ecode ) {
case 2003:/* Can't connect to MySQL (this error only happens here when failing to reconnect) */
@@ -938,7 +938,7 @@ void hercules_mysql_error_handler(unsigned int ecode)
*
* @retval false in case of error.
*/
-bool Sql_inter_server_read(const char *filename, bool imported)
+static bool Sql_inter_server_read(const char *filename, bool imported)
{
struct config_t config;
const struct config_setting_t *setting = NULL;
diff --git a/src/common/strlib.c b/src/common/strlib.c
index f0357e4a0..c9448177b 100644
--- a/src/common/strlib.c
+++ b/src/common/strlib.c
@@ -32,16 +32,17 @@
#define J_MAX_MALLOC_SIZE 65535
-struct strlib_interface strlib_s;
-struct stringbuf_interface stringbuf_s;
-struct sv_interface sv_s;
+static struct strlib_interface strlib_s;
+static struct stringbuf_interface stringbuf_s;
+static 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) {
+static char *jstrescape(char *pt)
+{
//copy from here
char *ptr;
int i = 0, j = 0;
@@ -73,7 +74,7 @@ char* jstrescape (char* pt) {
}
// escapes a string into a provided buffer
-char* jstrescapecpy (char* pt, const char* spt)
+static char *jstrescapecpy(char *pt, const char *spt)
{
//copy from here
//WARNING: Target string pt should be able to hold strlen(spt)*2, as each time
@@ -108,7 +109,7 @@ char* jstrescapecpy (char* pt, const char* spt)
}
// escapes exactly 'size' bytes of a string into a provided buffer
-int jmemescapecpy (char* pt, const char* spt, int size)
+static int jmemescapecpy(char *pt, const char *spt, int size)
{
//copy from here
int i =0, j=0;
@@ -135,7 +136,7 @@ int jmemescapecpy (char* pt, const char* spt, int size)
}
// Function to suppress control characters in a string.
-int strlib_remove_control_chars(char *str)
+static int strlib_remove_control_chars(char *str)
{
int i;
int change = 0;
@@ -152,7 +153,7 @@ int strlib_remove_control_chars(char *str)
// Removes characters identified by ISSPACE from the start and end of the string
// NOTE: make sure the string is not const!!
-char *strlib_trim(char *str)
+static char *strlib_trim(char *str)
{
size_t start;
size_t end;
@@ -180,7 +181,7 @@ char *strlib_trim(char *str)
// Converts one or more consecutive occurrences of the delimiters into a single space
// and removes such occurrences from the beginning and end of string
// NOTE: make sure the string is not const!!
-char *strlib_normalize_name(char *str, const char *delims)
+static char *strlib_normalize_name(char *str, const char *delims)
{
char* in = str;
char* out = str;
@@ -218,7 +219,7 @@ char *strlib_normalize_name(char *str, const char *delims)
//stristr: Case insensitive version of strstr, code taken from
//http://www.daniweb.com/code/snippet313.html, Dave Sinkula
//
-const char *strlib_stristr(const char *haystack, const char *needle)
+static const char *strlib_stristr(const char *haystack, const char *needle)
{
if ( !*needle )
{
@@ -246,7 +247,7 @@ const char *strlib_stristr(const char *haystack, const char *needle)
return 0;
}
-char* strlib_strtok_r(char *s1, const char *s2, char **lasts)
+static char* strlib_strtok_r(char *s1, const char *s2, char **lasts)
{
#ifdef __WIN32
char *ret;
@@ -269,7 +270,7 @@ char* strlib_strtok_r(char *s1, const char *s2, char **lasts)
#endif
}
-size_t strlib_strnlen(const char *string, size_t maxlen)
+static size_t strlib_strnlen(const char *string, size_t maxlen)
{
// TODO: Verify whether this implementation is still necessary for NetBSD 5.x
// and possibly some Solaris versions.
@@ -287,7 +288,7 @@ size_t strlib_strnlen(const char *string, size_t maxlen)
//----------------------------------------------------
// E-mail check: return 0 (not correct) or 1 (valid).
//----------------------------------------------------
-int strlib_e_mail_check(char *email)
+static int strlib_e_mail_check(char *email)
{
char ch;
char* last_arobas;
@@ -324,7 +325,8 @@ int strlib_e_mail_check(char *email)
// Return numerical value of a switch configuration
// on/off, yes/no, true/false, number
//--------------------------------------------------
-int strlib_config_switch(const char *str) {
+static int strlib_config_switch(const char *str)
+{
size_t len = strlen(str);
if ((len == 2 && strcmpi(str, "on") == 0)
|| (len == 3 && strcmpi(str, "yes") == 0)
@@ -345,7 +347,7 @@ int strlib_config_switch(const char *str) {
/// strncpy that always null-terminates the string
/// @remark this function will read at most `n` - 1 bytes from `src` (from 0 to `n` - 2)
-char *strlib_safestrncpy(char *dst, const char *src, size_t n)
+static char *strlib_safestrncpy(char *dst, const char *src, size_t n)
{
if( n > 0 )
{
@@ -366,7 +368,7 @@ char *strlib_safestrncpy(char *dst, const char *src, size_t n)
}
/// doesn't crash on null pointer
-size_t strlib_safestrnlen(const char *string, size_t maxlen)
+static size_t strlib_safestrnlen(const char *string, size_t maxlen)
{
return ( string != NULL ) ? strnlen(string, maxlen) : 0;
}
@@ -380,8 +382,8 @@ size_t strlib_safestrnlen(const char *string, size_t maxlen)
/// @param fmt Format string
/// @param ... Format arguments
/// @return The size of the string or -1 if the buffer is too small
-int strlib_safesnprintf(char *buf, size_t sz, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
-int strlib_safesnprintf(char *buf, size_t sz, const char *fmt, ...)
+static int strlib_safesnprintf(char *buf, size_t sz, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+static int strlib_safesnprintf(char *buf, size_t sz, const char *fmt, ...)
{
va_list ap;
int ret;
@@ -398,7 +400,7 @@ int strlib_safesnprintf(char *buf, size_t sz, const char *fmt, ...)
/// Returns the line of the target position in the string.
/// Lines start at 1.
-int strlib_strline(const char *str, size_t pos)
+static int strlib_strline(const char *str, size_t pos)
{
const char* target;
int line;
@@ -424,7 +426,7 @@ int strlib_strline(const char *str, size_t pos)
/// @param output Output string
/// @param input Binary input buffer
/// @param count Number of bytes to convert
-bool strlib_bin2hex(char *output, const unsigned char *input, size_t count)
+static bool strlib_bin2hex(char *output, const unsigned char *input, size_t count)
{
char toHex[] = "0123456789abcdef";
size_t i;
@@ -444,7 +446,7 @@ bool strlib_bin2hex(char *output, const unsigned char *input, size_t count)
///
/// @param svstate Parse state
/// @return 1 if a field was parsed, 0 if already done, -1 on error.
-int sv_parse_next(struct s_svstate* svstate)
+static int sv_parse_next(struct s_svstate *svstate)
{
enum {
START_OF_FIELD,
@@ -615,7 +617,8 @@ int sv_parse_next(struct s_svstate* svstate)
/// @param npos Size of the pos array
/// @param opt Options that determine the parsing behavior
/// @return Number of fields found in the string or -1 if an error occurred
-int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, int npos, enum e_svopt opt) {
+static int sv_parse(const char *str, int len, int startoff, char delim, int *out_pos, int npos, enum e_svopt opt)
+{
struct s_svstate svstate;
int count;
@@ -665,7 +668,8 @@ int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, i
/// @param nfields Size of the field array
/// @param opt Options that determine the parsing behavior
/// @return Number of fields found in the string or -1 if an error occurred
-int sv_split(char* str, int len, int startoff, char delim, char** out_fields, int nfields, enum e_svopt opt) {
+static int sv_split(char *str, int len, int startoff, char delim, char **out_fields, int nfields, enum e_svopt opt)
+{
int pos[1024];
int i;
int done;
@@ -731,7 +735,8 @@ int sv_split(char* str, int len, int startoff, char delim, char** out_fields, in
/// @param len Length of the source string
/// @param escapes Extra characters to be escaped
/// @return Length of the escaped string
-size_t sv_escape_c(char* out_dest, const char* src, size_t len, const char* escapes) {
+static size_t sv_escape_c(char *out_dest, const char *src, size_t len, const char *escapes)
+{
size_t i;
size_t j;
@@ -799,7 +804,8 @@ size_t sv_escape_c(char* out_dest, const char* src, size_t len, const char* esca
/// @param src Source string
/// @param len Length of the source string
/// @return Length of the escaped string
-size_t sv_unescape_c(char* out_dest, const char* src, size_t len) {
+static size_t sv_unescape_c(char *out_dest, const char *src, size_t len)
+{
static unsigned char low2hex[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,// 0x0?
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,// 0x1?
@@ -880,7 +886,8 @@ size_t sv_unescape_c(char* out_dest, const char* src, size_t len) {
}
/// Skips a C escape sequence (starting with '\\').
-const char* skip_escaped_c(const char* p) {
+static const char *skip_escaped_c(const char *p)
+{
if( p && *p == '\\' ) {
++p;
switch( *p ) {
@@ -918,7 +925,8 @@ const char* skip_escaped_c(const char* p) {
/// @param maxcols Maximum number of columns of a valid row
/// @param parseproc User-supplied row processing function
/// @return true on success, false if file could not be opened
-bool sv_readdb(const char* directory, const char* filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char* fields[], int columns, int current)) {
+static bool sv_readdb(const char *directory, const char *filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char *fields[], int columns, int current))
+{
FILE* fp;
int lines = 0;
int entries = 0;
@@ -990,7 +998,8 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc
// @author MouseJstr (original)
/// Allocates a StringBuf
-StringBuf* StringBuf_Malloc(void) {
+static StringBuf *StringBuf_Malloc(void)
+{
StringBuf* self;
CREATE(self, StringBuf, 1);
StrBuf->Init(self);
@@ -998,14 +1007,16 @@ StringBuf* StringBuf_Malloc(void) {
}
/// Initializes a previously allocated StringBuf
-void StringBuf_Init(StringBuf* self) {
+static void StringBuf_Init(StringBuf *self)
+{
self->max_ = 1024;
self->ptr_ = self->buf_ = (char*)aMalloc(self->max_ + 1);
}
/// Appends the result of printf to the StringBuf
-int StringBuf_Printf(StringBuf *self, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
-int StringBuf_Printf(StringBuf *self, const char *fmt, ...) {
+static int StringBuf_Printf(StringBuf *self, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
+static int StringBuf_Printf(StringBuf *self, const char *fmt, ...)
+{
int len;
va_list ap;
@@ -1017,7 +1028,8 @@ int StringBuf_Printf(StringBuf *self, const char *fmt, ...) {
}
/// Appends the result of vprintf to the StringBuf
-int StringBuf_Vprintf(StringBuf* self, const char* fmt, va_list ap) {
+static int StringBuf_Vprintf(StringBuf *self, const char *fmt, va_list ap)
+{
for(;;) {
va_list apcopy;
int n, off;
@@ -1040,7 +1052,8 @@ int StringBuf_Vprintf(StringBuf* self, const char* fmt, va_list ap) {
}
/// Appends the contents of another StringBuf to the StringBuf
-int StringBuf_Append(StringBuf* self, const StringBuf* sbuf) {
+static int StringBuf_Append(StringBuf *self, const StringBuf *sbuf)
+{
size_t available = self->max_ - (self->ptr_ - self->buf_);
size_t needed = sbuf->ptr_ - sbuf->buf_;
@@ -1057,7 +1070,8 @@ int StringBuf_Append(StringBuf* self, const StringBuf* sbuf) {
}
// Appends str to the StringBuf
-int StringBuf_AppendStr(StringBuf* self, const char* str) {
+static int StringBuf_AppendStr(StringBuf *self, const char *str)
+{
size_t available = self->max_ - (self->ptr_ - self->buf_);
size_t needed = strlen(str);
@@ -1075,34 +1089,41 @@ int StringBuf_AppendStr(StringBuf* self, const char* str) {
}
// Returns the length of the data in the Stringbuf
-int StringBuf_Length(StringBuf* self) {
+static int StringBuf_Length(StringBuf *self)
+{
return (int)(self->ptr_ - self->buf_);
}
/// Returns the data in the StringBuf
-char* StringBuf_Value(StringBuf* self) {
+static char *StringBuf_Value(StringBuf *self)
+{
*self->ptr_ = '\0';
return self->buf_;
}
/// Clears the contents of the StringBuf
-void StringBuf_Clear(StringBuf* self) {
+static void StringBuf_Clear(StringBuf *self)
+{
self->ptr_ = self->buf_;
}
/// Destroys the StringBuf
-void StringBuf_Destroy(StringBuf* self) {
+static void StringBuf_Destroy(StringBuf *self)
+{
aFree(self->buf_);
self->ptr_ = self->buf_ = 0;
self->max_ = 0;
}
// Frees a StringBuf returned by StringBuf_Malloc
-void StringBuf_Free(StringBuf* self) {
+static void StringBuf_Free(StringBuf *self)
+{
StrBuf->Destroy(self);
aFree(self);
}
-void strlib_defaults(void) {
+
+void strlib_defaults(void)
+{
/* connect */
strlib = &strlib_s;
StrBuf = &stringbuf_s;
diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c
index 0056aee1e..b8cb2a90a 100644
--- a/src/common/sysinfo.c
+++ b/src/common/sysinfo.c
@@ -59,8 +59,8 @@ struct sysinfo_private {
};
/// sysinfo.c interface source
-struct sysinfo_interface sysinfo_s;
-struct sysinfo_private sysinfo_p;
+static struct sysinfo_interface sysinfo_s;
+static struct sysinfo_private sysinfo_p;
struct sysinfo_interface *sysinfo;
@@ -238,7 +238,7 @@ enum windows_ver_suite {
* @retval true if a revision was correctly detected.
* @retval false if no revision was detected. out is set to NULL in this case.
*/
-bool sysinfo_svn_get_revision(char **out)
+static bool sysinfo_svn_get_revision(char **out)
{
// Only include SVN support if detected it, or we're on MSVC
#if !defined(SYSINFO_VCSTYPE) || SYSINFO_VCSTYPE == VCSTYPE_SVN || SYSINFO_VCSTYPE == VCSTYPE_UNKNOWN
@@ -310,7 +310,7 @@ bool sysinfo_svn_get_revision(char **out)
* @retval true if a revision was correctly detected.
* @retval false if no revision was detected. out is set to NULL in this case.
*/
-bool sysinfo_git_get_revision(char **out)
+static bool sysinfo_git_get_revision(char **out)
{
// Only include Git support if we detected it, or we're on MSVC
#if !defined(SYSINFO_VCSTYPE) || SYSINFO_VCSTYPE == VCSTYPE_GIT || SYSINFO_VCSTYPE == VCSTYPE_UNKNOWN
@@ -359,7 +359,7 @@ typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);
*
* Once retrieved, the version string is stored into sysinfo->p->osversion.
*/
-void sysinfo_osversion_retrieve(void)
+static void sysinfo_osversion_retrieve(void)
{
OSVERSIONINFOEX osvi;
StringBuf buf;
@@ -611,7 +611,7 @@ typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
* System info is not stored anywhere after retrieval
* @see http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx
**/
-void sysinfo_systeminfo_retrieve(LPSYSTEM_INFO info)
+static void sysinfo_systeminfo_retrieve(LPSYSTEM_INFO info)
{
PGNSI pGNSI;
@@ -629,7 +629,7 @@ void sysinfo_systeminfo_retrieve(LPSYSTEM_INFO info)
* Returns number of bytes in a memory page
* Only needed when compiling with MSVC
**/
-long sysinfo_getpagesize(void)
+static long sysinfo_getpagesize(void)
{
SYSTEM_INFO si;
ZeroMemory(&si, sizeof(SYSTEM_INFO));
@@ -644,7 +644,7 @@ long sysinfo_getpagesize(void)
* Once retrieved, the name is stored into sysinfo->p->cpu and the
* number of cores in sysinfo->p->cpucores.
*/
-void sysinfo_cpu_retrieve(void)
+static void sysinfo_cpu_retrieve(void)
{
StringBuf buf;
SYSTEM_INFO si;
@@ -681,7 +681,7 @@ void sysinfo_cpu_retrieve(void)
*
* Once retrieved, the name is stored into sysinfo->p->arch.
*/
-void sysinfo_arch_retrieve(void)
+static void sysinfo_arch_retrieve(void)
{
SYSTEM_INFO si;
ZeroMemory(&si, sizeof(SYSTEM_INFO));
@@ -710,7 +710,7 @@ void sysinfo_arch_retrieve(void)
*
* Once retrieved, the value is stored in sysinfo->p->vcsrevision_src.
*/
-void sysinfo_vcsrevision_src_retrieve(void)
+static void sysinfo_vcsrevision_src_retrieve(void)
{
if (sysinfo->p->vcsrevision_src != NULL) {
aFree(sysinfo->p->vcsrevision_src);
@@ -735,7 +735,7 @@ void sysinfo_vcsrevision_src_retrieve(void)
*
* Once retrieved, the value is stored in sysinfo->p->vcstype_name.
*/
-void sysinfo_vcstype_name_retrieve(void)
+static void sysinfo_vcstype_name_retrieve(void)
{
if (sysinfo->p->vcstype_name != NULL) {
aFree(sysinfo->p->vcstype_name);
@@ -765,7 +765,7 @@ void sysinfo_vcstype_name_retrieve(void)
*
* Output example: "Linux", "Darwin", "Windows", etc.
*/
-const char *sysinfo_platform(void)
+static const char *sysinfo_platform(void)
{
return sysinfo->p->platform;
}
@@ -784,7 +784,7 @@ const char *sysinfo_platform(void)
* Output example: "Windows 2008 Small Business Server", "OS X 10.8 Mountain Lion",
* "Gentoo Base System Release 2.2", "Debian GNU/Linux 6.0.6 (squeeze)", etc.
*/
-const char *sysinfo_osversion(void)
+static const char *sysinfo_osversion(void)
{
return sysinfo->p->osversion;
}
@@ -804,7 +804,7 @@ const char *sysinfo_osversion(void)
* "Intel(R) Xeon(R) CPU E5-1650 0 @ 3.20GHz", "Intel Core i7",
* "x86 CPU, Family 6, Model 54, Stepping 1", etc.
*/
-const char *sysinfo_cpu(void)
+static const char *sysinfo_cpu(void)
{
return sysinfo->p->cpu;
}
@@ -818,7 +818,7 @@ const char *sysinfo_cpu(void)
*
* @return the number of CPU cores.
*/
-int sysinfo_cpucores(void)
+static int sysinfo_cpucores(void)
{
return sysinfo->p->cpucores;
}
@@ -836,7 +836,7 @@ int sysinfo_cpucores(void)
*
* Output example: "x86", "x86_64", "IA-64", "ARM", etc.
*/
-const char *sysinfo_arch(void)
+static const char *sysinfo_arch(void)
{
return sysinfo->p->arch;
}
@@ -847,7 +847,7 @@ const char *sysinfo_arch(void)
* @retval true if this is a 64 bit build.
* @retval false if this isn't a 64 bit build (i.e. it is a 32 bit build).
*/
-bool sysinfo_is64bit(void)
+static bool sysinfo_is64bit(void)
{
#ifdef _LP64
return true;
@@ -866,7 +866,7 @@ bool sysinfo_is64bit(void)
* Output example: "Microsoft Visual C++ 2012 (v170050727)",
* "Clang v5.0.0", "MinGW32 v3.20", "GCC v4.7.3", etc.
*/
-const char *sysinfo_compiler(void)
+static const char *sysinfo_compiler(void)
{
return sysinfo->p->compiler;
}
@@ -882,7 +882,7 @@ const char *sysinfo_compiler(void)
*
* Output example: "-ggdb -O2 -flto -pipe -ffast-math ..."
*/
-const char *sysinfo_cflags(void)
+static const char *sysinfo_cflags(void)
{
return sysinfo->p->cflags;
}
@@ -898,7 +898,7 @@ const char *sysinfo_cflags(void)
*
* @see VCSTYPE_NONE, VCSTYPE_GIT, VCSTYPE_SVN, VCSTYPE_UNKNOWN
*/
-int sysinfo_vcstypeid(void)
+static int sysinfo_vcstypeid(void)
{
return sysinfo->p->vcstype;
}
@@ -916,7 +916,7 @@ int sysinfo_vcstypeid(void)
*
* Output example: "Git", "SVN", "Exported"
*/
-const char *sysinfo_vcstype(void)
+static const char *sysinfo_vcstype(void)
{
return sysinfo->p->vcstype_name;
}
@@ -935,7 +935,7 @@ const char *sysinfo_vcstype(void)
*
* Output example: Git: "9128feccf3bddda94a7f8a170305565416815b40", SVN: "17546"
*/
-const char *sysinfo_vcsrevision_src(void)
+static const char *sysinfo_vcsrevision_src(void)
{
return sysinfo->p->vcsrevision_src;
}
@@ -952,7 +952,7 @@ const char *sysinfo_vcsrevision_src(void)
*
* Output example: Git: "9128feccf3bddda94a7f8a170305565416815b40", SVN: "17546"
*/
-const char *sysinfo_vcsrevision_scripts(void)
+static const char *sysinfo_vcsrevision_scripts(void)
{
return sysinfo->p->vcsrevision_scripts;
}
@@ -961,7 +961,7 @@ const char *sysinfo_vcsrevision_scripts(void)
* Reloads the run-time (scripts) VCS revision information. To be used during
* script reloads to refresh the cached version.
*/
-void sysinfo_vcsrevision_reload(void)
+static void sysinfo_vcsrevision_reload(void)
{
if (sysinfo->p->vcsrevision_scripts != NULL) {
aFree(sysinfo->p->vcsrevision_scripts);
@@ -984,7 +984,7 @@ void sysinfo_vcsrevision_reload(void)
* @retval false if the current process is running as regular user, or
* in any case under Windows.
*/
-bool sysinfo_is_superuser(void)
+static bool sysinfo_is_superuser(void)
{
#ifndef _WIN32
if (geteuid() == 0)
@@ -996,7 +996,7 @@ bool sysinfo_is_superuser(void)
/**
* Interface runtime initialization.
*/
-void sysinfo_init(void)
+static void sysinfo_init(void)
{
sysinfo->p->compiler = SYSINFO_COMPILER;
#ifdef WIN32
@@ -1023,7 +1023,7 @@ void sysinfo_init(void)
/**
* Interface shutdown cleanup.
*/
-void sysinfo_final(void)
+static void sysinfo_final(void)
{
#ifdef WIN32
// Only need to be free'd in win32, they're #defined elsewhere
diff --git a/src/common/thread.c b/src/common/thread.c
index 2dc7d2682..605153011 100644
--- a/src/common/thread.c
+++ b/src/common/thread.c
@@ -49,7 +49,7 @@
* @author Florian Wilkemeyer <fw@f-ws.de>
*/
-struct thread_interface thread_s;
+static struct thread_interface thread_s;
struct thread_interface *thread;
/// The maximum amount of threads.
@@ -70,7 +70,7 @@ struct thread_handle {
};
#ifdef HAS_TLS
-__thread int g_rathread_ID = -1;
+static __thread int g_rathread_ID = -1;
#endif
// Subystem Code
@@ -78,7 +78,7 @@ __thread int g_rathread_ID = -1;
static struct thread_handle l_threads[THREADS_MAX];
/// @copydoc thread_interface::init()
-void thread_init(void)
+static void thread_init(void)
{
register int i;
memset(&l_threads, 0x00, THREADS_MAX * sizeof(struct thread_handle));
@@ -97,7 +97,7 @@ void thread_init(void)
}
/// @copydoc thread_interface::final()
-void thread_final(void)
+static void thread_final(void)
{
register int i;
@@ -125,7 +125,7 @@ static void thread_terminated(struct thread_handle *handle)
}
#ifdef WIN32
-DWORD WINAPI thread_main_redirector(LPVOID p)
+static DWORD WINAPI thread_main_redirector(LPVOID p)
{
#else
static void *thread_main_redirector(void *p)
@@ -170,13 +170,13 @@ static void *thread_main_redirector(void *p)
// API Level
/// @copydoc thread_interface::create()
-struct thread_handle *thread_create(threadFunc entry_point, void *param)
+static struct thread_handle *thread_create(threadFunc entry_point, void *param)
{
return thread->create_opt(entry_point, param, (1<<23) /*8MB*/, THREADPRIO_NORMAL);
}
/// @copydoc thread_interface::create_opt()
-struct thread_handle *thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio)
+static struct thread_handle *thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio)
{
#ifndef WIN32
pthread_attr_t attr;
@@ -226,7 +226,7 @@ struct thread_handle *thread_create_opt(threadFunc entry_point, void *param, siz
}
/// @copydoc thread_interface::destroy()
-void thread_destroy(struct thread_handle *handle)
+static void thread_destroy(struct thread_handle *handle)
{
#ifdef WIN32
if (TerminateThread(handle->hThread, 0) != FALSE) {
@@ -244,7 +244,7 @@ void thread_destroy(struct thread_handle *handle)
#endif
}
-struct thread_handle *thread_self(void)
+static struct thread_handle *thread_self(void)
{
#ifdef HAS_TLS
struct thread_handle *handle = &l_threads[g_rathread_ID];
@@ -273,7 +273,7 @@ struct thread_handle *thread_self(void)
}
/// @copydoc thread_interface::get_tid()
-int thread_get_tid(void)
+static int thread_get_tid(void)
{
#if defined(HAS_TLS)
return g_rathread_ID;
@@ -285,7 +285,7 @@ int thread_get_tid(void)
}
/// @copydoc thread_interface::wait()
-bool thread_wait(struct thread_handle *handle, void **out_exit_code)
+static bool thread_wait(struct thread_handle *handle, void **out_exit_code)
{
// Hint:
// no thread data cleanup routine call here!
@@ -302,20 +302,21 @@ bool thread_wait(struct thread_handle *handle, void **out_exit_code)
}
/// @copydoc thread_interface::prio_set()
-void thread_prio_set(struct thread_handle *handle, enum thread_priority prio)
+static void thread_prio_set(struct thread_handle *handle, enum thread_priority prio)
{
handle->prio = THREADPRIO_NORMAL;
//@TODO
}
/// @copydoc thread_interface::prio_get()
-enum thread_priority thread_prio_get(struct thread_handle *handle)
+static enum thread_priority thread_prio_get(struct thread_handle *handle)
{
return handle->prio;
}
/// @copydoc thread_interface::yield()
-void thread_yield(void) {
+static void thread_yield(void)
+{
#ifdef WIN32
SwitchToThread();
#else
diff --git a/src/common/timer.c b/src/common/timer.c
index ad11bc18d..d5f9c83d1 100644
--- a/src/common/timer.c
+++ b/src/common/timer.c
@@ -40,7 +40,7 @@
#include <stdlib.h>
#include <string.h>
-struct timer_interface timer_s;
+static struct timer_interface timer_s;
struct timer_interface *timer;
// If the server can't handle processing thousands of monsters
@@ -54,7 +54,7 @@ static int timer_data_max = 0;
static int timer_data_num = 1;
// free timers (array)
-static int* free_timer_list = NULL;
+static int *free_timer_list = NULL;
static int free_timer_list_max = 0;
static int free_timer_list_pos = 0;
@@ -72,20 +72,21 @@ static BHEAP_VAR(int, timer_heap);
// server startup time
-time_t start_time;
+static time_t start_time;
/*----------------------------
* Timer debugging
*----------------------------*/
-struct timer_func_list {
+static struct timer_func_list {
struct timer_func_list* next;
TimerFunc func;
char* name;
} *tfl_root = NULL;
/// Sets the name of a timer function.
-int timer_add_func_list(TimerFunc func, char* name) {
+static int timer_add_func_list(TimerFunc func, char *name)
+{
struct timer_func_list* tfl;
nullpo_ret(func);
@@ -108,7 +109,7 @@ int timer_add_func_list(TimerFunc func, char* name) {
}
/// Returns the name of the timer function.
-char* search_timer_func_list(TimerFunc func)
+static char *search_timer_func_list(TimerFunc func)
{
struct timer_func_list* tfl;
@@ -124,9 +125,11 @@ char* search_timer_func_list(TimerFunc func)
*----------------------------*/
#if defined(ENABLE_RDTSC)
-static uint64 RDTSC_BEGINTICK = 0, RDTSC_CLOCK = 0;
+static uint64 RDTSC_BEGINTICK = 0;
+static uint64 RDTSC_CLOCK = 0;
-static __inline uint64 rdtsc_(void) {
+static __inline uint64 rdtsc_(void)
+{
register union {
uint64 qw;
uint32 dw[2];
@@ -137,7 +140,8 @@ static __inline uint64 rdtsc_(void) {
return t.qw;
}
-static void rdtsc_calibrate(void){
+static void rdtsc_calibrate(void)
+{
uint64 t1, t2;
int32 i;
@@ -164,7 +168,8 @@ static void rdtsc_calibrate(void){
* platform-abstracted tick retrieval
* @return server's current tick
*/
-static int64 sys_tick(void) {
+static int64 sys_tick(void)
+{
#if defined(WIN32)
// Windows: GetTickCount/GetTickCount64: Return the number of
// milliseconds that have elapsed since the system was started.
@@ -226,25 +231,28 @@ static int64 sys_tick(void) {
static int64 gettick_cache;
static int gettick_count = 1;
-int64 timer_gettick_nocache(void) {
+static int64 timer_gettick_nocache(void)
+{
gettick_count = TICK_CACHE;
gettick_cache = sys_tick();
return gettick_cache;
}
-int64 timer_gettick(void) {
+static int64 timer_gettick(void)
+{
return ( --gettick_count == 0 ) ? gettick_nocache() : gettick_cache;
}
//////////////////////////////
#else
//////////////////////////////
// tick doesn't get cached
-int64 timer_gettick_nocache(void)
+static int64 timer_gettick_nocache(void)
{
return sys_tick();
}
-int64 timer_gettick(void) {
+static int64 timer_gettick(void)
+{
return sys_tick();
}
//////////////////////////////////////////////////////////////////////////
@@ -256,7 +264,8 @@ int64 timer_gettick(void) {
*--------------------------------------*/
/// Adds a timer to the timer_heap
-static void push_timer_heap(int tid) {
+static void push_timer_heap(int tid)
+{
BHEAP_ENSURE(timer_heap, 1, 256);
BHEAP_PUSH(timer_heap, tid, DIFFTICK_MINTOPCMP, swap);
}
@@ -266,7 +275,8 @@ static void push_timer_heap(int tid) {
*--------------------------*/
/// Returns a free timer id.
-static int acquire_timer(void) {
+static int acquire_timer(void)
+{
int tid;
// select a free timer
@@ -299,7 +309,8 @@ static int acquire_timer(void) {
/// Starts a new timer that is deleted once it expires (single-use).
/// Returns the timer's id.
-int timer_add(int64 tick, TimerFunc func, int id, intptr_t data) {
+static int timer_add(int64 tick, TimerFunc func, int id, intptr_t data)
+{
int tid;
nullpo_retr(INVALID_TIMER, func);
@@ -328,7 +339,7 @@ int timer_add(int64 tick, TimerFunc func, int id, intptr_t data) {
/// Starts a new timer that automatically restarts itself (infinite loop until manually removed).
/// Returns the timer's id, or INVALID_TIMER if it fails.
-int timer_add_interval(int64 tick, TimerFunc func, int id, intptr_t data, int interval)
+static int timer_add_interval(int64 tick, TimerFunc func, int id, intptr_t data, int interval)
{
int tid;
@@ -364,7 +375,8 @@ int timer_add_interval(int64 tick, TimerFunc func, int id, intptr_t data, int in
}
/// Retrieves internal timer data
-const struct TimerData* timer_get(int tid) {
+static const struct TimerData *timer_get(int tid)
+{
Assert_retr(NULL, tid > 0);
return ( tid >= 0 && tid < timer_data_num ) ? &timer_data[tid] : NULL;
}
@@ -372,7 +384,7 @@ const struct TimerData* timer_get(int tid) {
/// Marks a timer specified by 'id' for immediate deletion once it expires.
/// Param 'func' is used for debug/verification purposes.
/// Returns 0 on success, < 0 on failure.
-int timer_do_delete(int tid, TimerFunc func)
+static int timer_do_delete(int tid, TimerFunc func)
{
nullpo_ret(func);
@@ -402,7 +414,8 @@ int timer_do_delete(int tid, TimerFunc func)
/// Adjusts a timer's expiration time.
/// Returns the new tick value, or -1 if it fails.
-int64 timer_addtick(int tid, int64 tick) {
+static int64 timer_addtick(int tid, int64 tick)
+{
if (tid < 1 || tid >= timer_data_num) {
ShowError("timer_addtick error : no such timer [%d]\n", tid);
Assert_retr(-1, 0);
@@ -419,7 +432,7 @@ int64 timer_addtick(int tid, int64 tick) {
* @return The new tick value.
* @retval -1 in case of failure.
*/
-int64 timer_settick(int tid, int64 tick)
+static int64 timer_settick(int tid, int64 tick)
{
int i;
@@ -461,7 +474,7 @@ int64 timer_settick(int tid, int64 tick)
* @param tick The current tick.
* @return The value of the smallest non-expired timer (or 1 second if there aren't any).
*/
-int do_timer(int64 tick)
+static int do_timer(int64 tick)
{
int64 diff = TIMER_MAX_INTERVAL; // return value
@@ -515,11 +528,12 @@ int do_timer(int64 tick)
return (int)cap_value(diff, TIMER_MIN_INTERVAL, TIMER_MAX_INTERVAL);
}
-unsigned long timer_get_uptime(void) {
+static unsigned long timer_get_uptime(void)
+{
return (unsigned long)difftime(time(NULL), start_time);
}
-void timer_init(void)
+static void timer_init(void)
{
#if defined(ENABLE_RDTSC)
rdtsc_calibrate();
@@ -528,7 +542,8 @@ void timer_init(void)
time(&start_time);
}
-void timer_final(void) {
+static void timer_final(void)
+{
struct timer_func_list *tfl;
struct timer_func_list *next;
@@ -542,12 +557,14 @@ void timer_final(void) {
BHEAP_CLEAR(timer_heap);
if (free_timer_list) aFree(free_timer_list);
}
+
/*=====================================
-* Default Functions : timer.h
-* Generated by HerculesInterfaceMaker
-* created by Susu
-*-------------------------------------*/
-void timer_defaults(void) {
+ * Default Functions : timer.h
+ * Generated by HerculesInterfaceMaker
+ * created by Susu
+ *-------------------------------------*/
+void timer_defaults(void)
+{
timer = &timer_s;
/* funcs */
diff --git a/src/common/utils.c b/src/common/utils.c
index 44f3087c3..d4c838b56 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -45,11 +45,11 @@
#include <stdlib.h>
#include <sys/stat.h> // cache purposes [Ind/Hercules]
-struct HCache_interface HCache_s;
+static 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)
+void WriteDump(FILE *fp, const void *buffer, size_t length)
{
size_t i;
char hex[48+1], ascii[16+1];
@@ -109,7 +109,7 @@ void ShowDump(const void *buffer, size_t length)
#ifdef WIN32
-static char* checkpath(char *path, const char *srcpath)
+static char *checkpath(char *path, const char *srcpath)
{
// just make sure the char*path is not const
char *p = path;
@@ -128,7 +128,7 @@ static char* checkpath(char *path, const char *srcpath)
return path;
}
-void findfile(const char *p, const char *pat, void (func)(const char*))
+void findfile(const char *p, const char *pat, void (func)(const char *))
{
WIN32_FIND_DATAA FindFileData;
HANDLE hFind;
@@ -171,7 +171,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*))
#define MAX_DIR_PATH 2048
-static char* checkpath(char *path, const char*srcpath)
+static char *checkpath(char *path, const char *srcpath)
{
// just make sure the char*path is not const
char *p=path;
@@ -190,7 +190,7 @@ static char* checkpath(char *path, const char*srcpath)
return path;
}
-void findfile(const char *p, const char *pat, void (func)(const char*))
+void findfile(const char *p, const char *pat, void (func)(const char *))
{
DIR* dir; ///< pointer to the scanned directory.
struct dirent* entry; ///< pointer to one directory entry.
@@ -238,7 +238,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*))
}
#endif
-bool exists(const char* filename)
+bool exists(const char *filename)
{
return !access(filename, F_OK);
}
@@ -309,14 +309,14 @@ int32 MakeLongLE(int32 val)
}
// Reads an uint16 in little-endian from the buffer
-uint16 GetUShort(const unsigned char* buf)
+uint16 GetUShort(const unsigned char *buf)
{
return ( ((uint16)(buf[0])) )
| ( ((uint16)(buf[1])) << 0x08 );
}
// Reads an uint32 in little-endian from the buffer
-uint32 GetULong(const unsigned char* buf)
+uint32 GetULong(const unsigned char *buf)
{
return ( ((uint32)(buf[0])) )
| ( ((uint32)(buf[1])) << 0x08 )
@@ -325,13 +325,13 @@ uint32 GetULong(const unsigned char* buf)
}
// Reads an int32 in little-endian from the buffer
-int32 GetLong(const unsigned char* buf)
+int32 GetLong(const unsigned char *buf)
{
return (int32)GetULong(buf);
}
// Reads a float (32 bits) from the buffer
-float GetFloat(const unsigned char* buf)
+float GetFloat(const unsigned char *buf)
{
uint32 val = GetULong(buf);
return *((float*)(void*)&val);
@@ -426,7 +426,7 @@ int apply_percentrate(int value, int rate, int maxrate)
//-----------------------------------------------------
// custom timestamp formatting (from eApp)
//-----------------------------------------------------
-const char* timestamp2string(char* str, size_t size, time_t timestamp, const char* format)
+const char *timestamp2string(char *str, size_t size, time_t timestamp, const char *format)
{
size_t len;
nullpo_retr(NULL, str);
@@ -436,7 +436,7 @@ const char* timestamp2string(char* str, size_t size, time_t timestamp, const cha
}
/* [Ind/Hercules] Caching */
-bool HCache_check(const char *file)
+static bool HCache_check(const char *file)
{
struct stat bufa, bufb;
FILE *first, *second;
@@ -487,7 +487,7 @@ bool HCache_check(const char *file)
return true;
}
-FILE *HCache_open(const char *file, const char *opt)
+static FILE *HCache_open(const char *file, const char *opt)
{
FILE *first;
char s_path[255];
@@ -520,7 +520,7 @@ FILE *HCache_open(const char *file, const char *opt)
return first;
}
-void HCache_init(void)
+static void HCache_init(void)
{
struct stat buf;
if (stat(SERVER_NAME, &buf) != 0) {