summaryrefslogtreecommitdiff
path: root/src/login/account.h
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-01-24 01:26:39 +0300
committerAndrei Karas <akaras@inbox.ru>2018-02-09 18:34:44 +0300
commita4cbec10932f12f849a942dff29d282975aabd45 (patch)
treea5a7f26dcbc01d2386f406bc86a78af49441d5a1 /src/login/account.h
parent7040d6071e3cbb7eafd9b67108952a1342cac572 (diff)
downloadhercules-a4cbec10932f12f849a942dff29d282975aabd45.tar.gz
hercules-a4cbec10932f12f849a942dff29d282975aabd45.tar.bz2
hercules-a4cbec10932f12f849a942dff29d282975aabd45.tar.xz
hercules-a4cbec10932f12f849a942dff29d282975aabd45.zip
Add interface into account.c.
Diffstat (limited to 'src/login/account.h')
-rw-r--r--src/login/account.h70
1 files changed, 59 insertions, 11 deletions
diff --git a/src/login/account.h b/src/login/account.h
index 3d47e8c56..8199ce3ba 100644
--- a/src/login/account.h
+++ b/src/login/account.h
@@ -33,12 +33,6 @@ struct config_t; // common/conf.h
typedef struct AccountDB AccountDB;
typedef struct AccountDBIterator AccountDBIterator;
-
-#ifdef HERCULES_CORE
-// standard engines
-AccountDB* account_db_sql(void);
-#endif // HERCULES_CORE
-
struct mmo_account
{
int account_id;
@@ -59,7 +53,6 @@ struct mmo_account
char birthdate[10+1]; // assigned birth date (format: YYYY-MM-DD, default: 0000-00-00)
};
-
struct AccountDBIterator
{
/// Destroys this iterator, releasing all allocated memory (including itself).
@@ -161,11 +154,66 @@ struct AccountDB
AccountDBIterator* (*iterator)(AccountDB* self);
};
-#ifdef HERCULES_CORE
-struct Sql *account_db_sql_up(AccountDB* self);
+typedef struct AccountDB_SQL
+{
+ AccountDB vtable; // public interface
+
+ struct Sql *accounts; // SQL accounts storage
+
+ // Sql settings
+ char db_hostname[32];
+ uint16 db_port;
+ char db_username[32];
+ char db_password[100];
+ char db_database[32];
+ char codepage[32];
+ // other settings
+ bool case_sensitive;
+ char account_db[32];
+ char global_acc_reg_num_db[32];
+ char global_acc_reg_str_db[32];
+} AccountDB_SQL;
+
+/// internal structure
+typedef struct AccountDBIterator_SQL
+{
+ AccountDBIterator vtable; // public interface
+
+ AccountDB_SQL* db;
+ int last_account_id;
+} AccountDBIterator_SQL;
-void account_mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id);
-void account_mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id);
+/**
+ * Account.c Interface
+ **/
+struct account_interface {
+ struct Sql* (*db_sql_up) (AccountDB* self);
+ void (*mmo_send_accreg2) (AccountDB* self, int fd, int account_id, int char_id);
+ void (*mmo_save_accreg2) (AccountDB* self, int fd, int account_id, int char_id);
+ bool (*mmo_auth_fromsql) (AccountDB_SQL* db, struct mmo_account* acc, int account_id);
+ bool (*mmo_auth_tosql) (AccountDB_SQL* db, const struct mmo_account* acc, bool is_new);
+
+ AccountDB* (*db_sql) (void);
+ bool (*db_sql_init) (AccountDB* self);
+ void (*db_sql_destroy) (AccountDB* self);
+ bool (*db_sql_get_property) (AccountDB* self, const char* key, char* buf, size_t buflen);
+ bool (*db_sql_set_property) (AccountDB* self, struct config_t *config, bool imported);
+ bool (*db_sql_create) (AccountDB* self, struct mmo_account* acc);
+ bool (*db_sql_remove) (AccountDB* self, const int account_id);
+ bool (*db_sql_save) (AccountDB* self, const struct mmo_account* acc);
+ bool (*db_sql_load_num) (AccountDB* self, struct mmo_account* acc, const int account_id);
+ bool (*db_sql_load_str) (AccountDB* self, struct mmo_account* acc, const char* userid);
+ AccountDBIterator* (*db_sql_iterator) (AccountDB* self);
+ void (*db_sql_iter_destroy) (AccountDBIterator* self);
+ bool (*db_sql_iter_next) (AccountDBIterator* self, struct mmo_account* acc);
+
+ bool (*db_read_inter) (AccountDB_SQL *db, const char *filename, bool imported);
+};
+
+#ifdef HERCULES_CORE
+void account_defaults(void);
#endif // HERCULES_CORE
+HPShared struct account_interface *account;
+
#endif /* LOGIN_ACCOUNT_H */