summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/HPM.c2
-rw-r--r--src/common/core.c4
-rw-r--r--src/common/db.c46
-rw-r--r--src/common/db.h88
-rw-r--r--src/common/timer.h1
5 files changed, 71 insertions, 70 deletions
diff --git a/src/common/HPM.c b/src/common/HPM.c
index ed6151c95..9283360dc 100644
--- a/src/common/HPM.c
+++ b/src/common/HPM.c
@@ -264,7 +264,7 @@ void hplugins_share_defaults(void) {
HPM->share(&SERVER_TYPE,"SERVER_TYPE");
HPM->share((void*)get_svn_revision,"get_svn_revision");
HPM->share((void*)get_git_hash,"get_git_hash");
- HPM->share(iDB, "iDB");
+ HPM->share(DB, "DB");
HPM->share(iMalloc, "iMalloc");
/* socket */
HPM->share(RFIFOSKIP,"RFIFOSKIP");
diff --git a/src/common/core.c b/src/common/core.c
index d6cfff662..c53d2243b 100644
--- a/src/common/core.c
+++ b/src/common/core.c
@@ -322,7 +322,7 @@ int main (int argc, char **argv) {
Sql_Init();
rathread_init();
mempool_init();
- iDB->init();
+ DB->init();
signals_init();
#ifdef _WIN32
@@ -356,7 +356,7 @@ int main (int argc, char **argv) {
#endif
iTimer->final();
socket_final();
- iDB->final();
+ DB->final();
mempool_final();
rathread_final();
#endif
diff --git a/src/common/db.c b/src/common/db.c
index b1fe22a4a..561371787 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -2349,7 +2349,7 @@ DBHasher db_default_hash(DBType type)
DBReleaser db_default_release(DBType type, DBOptions options)
{
DB_COUNTSTAT(db_default_release);
- options = iDB->fix_options(type, options);
+ options = DB->fix_options(type, options);
if (options&DB_OPT_RELEASE_DATA) { // Release data, what about the key?
if (options&(DB_OPT_DUP_KEY|DB_OPT_RELEASE_KEY))
return &db_release_both; // Release both key and data
@@ -2416,7 +2416,7 @@ DBMap* db_alloc(const char *file, const char *func, int line, DBType type, DBOpt
#endif /* DB_ENABLE_STATS */
db = ers_alloc(db_alloc_ers, struct DBMap_impl);
- options = iDB->fix_options(type, options);
+ options = DB->fix_options(type, options);
/* Interface of the database */
db->vtable.iterator = db_obj_iterator;
db->vtable.exists = db_obj_exists;
@@ -2447,9 +2447,9 @@ DBMap* db_alloc(const char *file, const char *func, int line, DBType type, DBOpt
/* Other */
snprintf(ers_name, 50, "db_alloc:nodes:%s:%s:%d",func,file,line);
db->nodes = ers_new(sizeof(struct dbn),ers_name,ERS_OPT_WAIT|ERS_OPT_FREE_NAME);
- db->cmp = iDB->default_cmp(type);
- db->hash = iDB->default_hash(type);
- db->release = iDB->default_release(type, options);
+ db->cmp = DB->default_cmp(type);
+ db->hash = DB->default_hash(type);
+ db->release = DB->default_release(type, options);
for (i = 0; i < HASH_SIZE; i++)
db->ht[i] = NULL;
db->cache = NULL;
@@ -2830,22 +2830,22 @@ void linkdb_final( struct linkdb_node** head )
*head = NULL;
}
void db_defaults(void) {
- iDB = &iDB_s;
- iDB->alloc = db_alloc;
- iDB->custom_release = db_custom_release;
- iDB->data2i = db_data2i;
- iDB->data2ptr = db_data2ptr;
- iDB->data2ui = db_data2ui;
- iDB->default_cmp = db_default_cmp;
- iDB->default_hash = db_default_hash;
- iDB->default_release = db_default_release;
- iDB->final = db_final;
- iDB->fix_options = db_fix_options;
- iDB->i2data = db_i2data;
- iDB->i2key = db_i2key;
- iDB->init = db_init;
- iDB->ptr2data = db_ptr2data;
- iDB->str2key = db_str2key;
- iDB->ui2data = db_ui2data;
- iDB->ui2key = db_ui2key;
+ DB = &DB_s;
+ DB->alloc = db_alloc;
+ DB->custom_release = db_custom_release;
+ DB->data2i = db_data2i;
+ DB->data2ptr = db_data2ptr;
+ DB->data2ui = db_data2ui;
+ DB->default_cmp = db_default_cmp;
+ DB->default_hash = db_default_hash;
+ DB->default_release = db_default_release;
+ DB->final = db_final;
+ DB->fix_options = db_fix_options;
+ DB->i2data = db_i2data;
+ DB->i2key = db_i2key;
+ DB->init = db_init;
+ DB->ptr2data = db_ptr2data;
+ DB->str2key = db_str2key;
+ DB->ui2data = db_ui2data;
+ DB->ui2key = db_ui2key;
}
diff --git a/src/common/db.h b/src/common/db.h
index 8ad033cce..5a555b2fa 100644
--- a/src/common/db.h
+++ b/src/common/db.h
@@ -599,73 +599,73 @@ struct DBMap {
// For easy access to the common functions.
#define db_exists(db,k) ( (db)->exists((db),(k)) )
-#define idb_exists(db,k) ( (db)->exists((db),iDB->i2key(k)) )
-#define uidb_exists(db,k) ( (db)->exists((db),iDB->ui2key(k)) )
-#define strdb_exists(db,k) ( (db)->exists((db),iDB->str2key(k)) )
+#define idb_exists(db,k) ( (db)->exists((db),DB->i2key(k)) )
+#define uidb_exists(db,k) ( (db)->exists((db),DB->ui2key(k)) )
+#define strdb_exists(db,k) ( (db)->exists((db),DB->str2key(k)) )
// Get pointer-type data from DBMaps of various key types
-#define db_get(db,k) ( iDB->data2ptr((db)->get((db),(k))) )
-#define idb_get(db,k) ( iDB->data2ptr((db)->get((db),iDB->i2key(k))) )
-#define uidb_get(db,k) ( iDB->data2ptr((db)->get((db),iDB->ui2key(k))) )
-#define strdb_get(db,k) ( iDB->data2ptr((db)->get((db),iDB->str2key(k))) )
+#define db_get(db,k) ( DB->data2ptr((db)->get((db),(k))) )
+#define idb_get(db,k) ( DB->data2ptr((db)->get((db),DB->i2key(k))) )
+#define uidb_get(db,k) ( DB->data2ptr((db)->get((db),DB->ui2key(k))) )
+#define strdb_get(db,k) ( DB->data2ptr((db)->get((db),DB->str2key(k))) )
// Get int-type data from DBMaps of various key types
-#define db_iget(db,k) ( iDB->data2i((db)->get((db),(k))) )
-#define idb_iget(db,k) ( iDB->data2i((db)->get((db),iDB->i2key(k))) )
-#define uidb_iget(db,k) ( iDB->data2i((db)->get((db),iDB->ui2key(k))) )
-#define strdb_iget(db,k) ( iDB->data2i((db)->get((db),iDB->str2key(k))) )
+#define db_iget(db,k) ( DB->data2i((db)->get((db),(k))) )
+#define idb_iget(db,k) ( DB->data2i((db)->get((db),DB->i2key(k))) )
+#define uidb_iget(db,k) ( DB->data2i((db)->get((db),DB->ui2key(k))) )
+#define strdb_iget(db,k) ( DB->data2i((db)->get((db),DB->str2key(k))) )
// Get uint-type data from DBMaps of various key types
-#define db_uiget(db,k) ( iDB->data2ui((db)->get((db),(k))) )
-#define idb_uiget(db,k) ( iDB->data2ui((db)->get((db),iDB->i2key(k))) )
-#define uidb_uiget(db,k) ( iDB->data2ui((db)->get((db),iDB->ui2key(k))) )
-#define strdb_uiget(db,k) ( iDB->data2ui((db)->get((db),iDB->str2key(k))) )
+#define db_uiget(db,k) ( DB->data2ui((db)->get((db),(k))) )
+#define idb_uiget(db,k) ( DB->data2ui((db)->get((db),DB->i2key(k))) )
+#define uidb_uiget(db,k) ( DB->data2ui((db)->get((db),DB->ui2key(k))) )
+#define strdb_uiget(db,k) ( DB->data2ui((db)->get((db),DB->str2key(k))) )
// Put pointer-type data into DBMaps of various key types
-#define db_put(db,k,d) ( (db)->put((db),(k),iDB->ptr2data(d),NULL) )
-#define idb_put(db,k,d) ( (db)->put((db),iDB->i2key(k),iDB->ptr2data(d),NULL) )
-#define uidb_put(db,k,d) ( (db)->put((db),iDB->ui2key(k),iDB->ptr2data(d),NULL) )
-#define strdb_put(db,k,d) ( (db)->put((db),iDB->str2key(k),iDB->ptr2data(d),NULL) )
+#define db_put(db,k,d) ( (db)->put((db),(k),DB->ptr2data(d),NULL) )
+#define idb_put(db,k,d) ( (db)->put((db),DB->i2key(k),DB->ptr2data(d),NULL) )
+#define uidb_put(db,k,d) ( (db)->put((db),DB->ui2key(k),DB->ptr2data(d),NULL) )
+#define strdb_put(db,k,d) ( (db)->put((db),DB->str2key(k),DB->ptr2data(d),NULL) )
// Put int-type data into DBMaps of various key types
-#define db_iput(db,k,d) ( (db)->put((db),(k),iDB->i2data(d),NULL) )
-#define idb_iput(db,k,d) ( (db)->put((db),iDB->i2key(k),iDB->i2data(d),NULL) )
-#define uidb_iput(db,k,d) ( (db)->put((db),iDB->ui2key(k),iDB->i2data(d),NULL) )
-#define strdb_iput(db,k,d) ( (db)->put((db),iDB->str2key(k),iDB->i2data(d),NULL) )
+#define db_iput(db,k,d) ( (db)->put((db),(k),DB->i2data(d),NULL) )
+#define idb_iput(db,k,d) ( (db)->put((db),DB->i2key(k),DB->i2data(d),NULL) )
+#define uidb_iput(db,k,d) ( (db)->put((db),DB->ui2key(k),DB->i2data(d),NULL) )
+#define strdb_iput(db,k,d) ( (db)->put((db),DB->str2key(k),DB->i2data(d),NULL) )
// Put uint-type data into DBMaps of various key types
-#define db_uiput(db,k,d) ( (db)->put((db),(k),iDB->ui2data(d),NULL) )
-#define idb_uiput(db,k,d) ( (db)->put((db),iDB->i2key(k),iDB->ui2data(d),NULL) )
-#define uidb_uiput(db,k,d) ( (db)->put((db),iDB->ui2key(k),iDB->ui2data(d),NULL) )
-#define strdb_uiput(db,k,d) ( (db)->put((db),iDB->str2key(k),iDB->ui2data(d),NULL) )
+#define db_uiput(db,k,d) ( (db)->put((db),(k),DB->ui2data(d),NULL) )
+#define idb_uiput(db,k,d) ( (db)->put((db),DB->i2key(k),DB->ui2data(d),NULL) )
+#define uidb_uiput(db,k,d) ( (db)->put((db),DB->ui2key(k),DB->ui2data(d),NULL) )
+#define strdb_uiput(db,k,d) ( (db)->put((db),DB->str2key(k),DB->ui2data(d),NULL) )
// Remove entry from DBMaps of various key types
#define db_remove(db,k) ( (db)->remove((db),(k),NULL) )
-#define idb_remove(db,k) ( (db)->remove((db),iDB->i2key(k),NULL) )
-#define uidb_remove(db,k) ( (db)->remove((db),iDB->ui2key(k),NULL) )
-#define strdb_remove(db,k) ( (db)->remove((db),iDB->str2key(k),NULL) )
+#define idb_remove(db,k) ( (db)->remove((db),DB->i2key(k),NULL) )
+#define uidb_remove(db,k) ( (db)->remove((db),DB->ui2key(k),NULL) )
+#define strdb_remove(db,k) ( (db)->remove((db),DB->str2key(k),NULL) )
//These are discarding the possible vargs you could send to the function, so those
//that require vargs must not use these defines.
-#define db_ensure(db,k,f) ( iDB->data2ptr((db)->ensure((db),(k),(f))) )
-#define idb_ensure(db,k,f) ( iDB->data2ptr((db)->ensure((db),iDB->i2key(k),(f))) )
-#define uidb_ensure(db,k,f) ( iDB->data2ptr((db)->ensure((db),iDB->ui2key(k),(f))) )
-#define strdb_ensure(db,k,f) ( iDB->data2ptr((db)->ensure((db),iDB->str2key(k),(f))) )
+#define db_ensure(db,k,f) ( DB->data2ptr((db)->ensure((db),(k),(f))) )
+#define idb_ensure(db,k,f) ( DB->data2ptr((db)->ensure((db),DB->i2key(k),(f))) )
+#define uidb_ensure(db,k,f) ( DB->data2ptr((db)->ensure((db),DB->ui2key(k),(f))) )
+#define strdb_ensure(db,k,f) ( DB->data2ptr((db)->ensure((db),DB->str2key(k),(f))) )
// Database creation and destruction macros
-#define idb_alloc(opt) iDB->alloc(__FILE__,__func__,__LINE__,DB_INT,(opt),sizeof(int))
-#define uidb_alloc(opt) iDB->alloc(__FILE__,__func__,__LINE__,DB_UINT,(opt),sizeof(unsigned int))
-#define strdb_alloc(opt,maxlen) iDB->alloc(__FILE__,__func__,__LINE__,DB_STRING,(opt),(maxlen))
-#define stridb_alloc(opt,maxlen) iDB->alloc(__FILE__,__func__,__LINE__,DB_ISTRING,(opt),(maxlen))
+#define idb_alloc(opt) DB->alloc(__FILE__,__func__,__LINE__,DB_INT,(opt),sizeof(int))
+#define uidb_alloc(opt) DB->alloc(__FILE__,__func__,__LINE__,DB_UINT,(opt),sizeof(unsigned int))
+#define strdb_alloc(opt,maxlen) DB->alloc(__FILE__,__func__,__LINE__,DB_STRING,(opt),(maxlen))
+#define stridb_alloc(opt,maxlen) DB->alloc(__FILE__,__func__,__LINE__,DB_ISTRING,(opt),(maxlen))
#define db_destroy(db) ( (db)->destroy((db),NULL) )
// Other macros
#define db_clear(db) ( (db)->clear(db,NULL) )
#define db_size(db) ( (db)->size(db) )
#define db_iterator(db) ( (db)->iterator(db) )
-#define dbi_first(dbi) ( iDB->data2ptr((dbi)->first(dbi,NULL)) )
-#define dbi_last(dbi) ( iDB->data2ptr((dbi)->last(dbi,NULL)) )
-#define dbi_next(dbi) ( iDB->data2ptr((dbi)->next(dbi,NULL)) )
-#define dbi_prev(dbi) ( iDB->data2ptr((dbi)->prev(dbi,NULL)) )
+#define dbi_first(dbi) ( DB->data2ptr((dbi)->first(dbi,NULL)) )
+#define dbi_last(dbi) ( DB->data2ptr((dbi)->last(dbi,NULL)) )
+#define dbi_next(dbi) ( DB->data2ptr((dbi)->next(dbi,NULL)) )
+#define dbi_prev(dbi) ( DB->data2ptr((dbi)->prev(dbi,NULL)) )
#define dbi_remove(dbi) ( (dbi)->remove(dbi,NULL) )
#define dbi_exists(dbi) ( (dbi)->exists(dbi) )
#define dbi_destroy(dbi) ( (dbi)->destroy(dbi) )
@@ -867,9 +867,9 @@ void (*init) (void);
* @see #db_init(void)
*/
void (*final) (void);
-} iDB_s;
+} DB_s;
-struct db_interface *iDB;
+struct db_interface *DB;
void db_defaults(void);
// Link DB System - From jAthena
diff --git a/src/common/timer.h b/src/common/timer.h
index d68b5ed0f..2cc243692 100644
--- a/src/common/timer.h
+++ b/src/common/timer.h
@@ -59,6 +59,7 @@ struct timer_interface {
unsigned long (*get_uptime) (void);
int (*do_timer) (unsigned int tick);
+
void (*init) (void);
void (*final) (void);
} iTimer_s;