diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/HPMi.h | 4 | ||||
-rw-r--r-- | src/common/console.c | 3 | ||||
-rw-r--r-- | src/common/console.h | 8 | ||||
-rw-r--r-- | src/common/sql.c | 114 | ||||
-rw-r--r-- | src/common/sql.h | 78 |
5 files changed, 107 insertions, 100 deletions
diff --git a/src/common/HPMi.h b/src/common/HPMi.h index cf3e16277..72640b382 100644 --- a/src/common/HPMi.h +++ b/src/common/HPMi.h @@ -24,8 +24,8 @@ #include "common/console.h" #include "common/core.h" #include "common/showmsg.h" -#include "common/sql.h" +struct Sql; // common/sql.h struct script_state; struct AtCommandInfo; struct socket_data; @@ -242,7 +242,7 @@ struct HPMi_interface { /* pc group permission */ void (*addPCGPermission) (unsigned int pluginID, char *name, unsigned int *mask); - Sql *sql_handle; + struct Sql *sql_handle; }; #ifdef HERCULES_CORE #define HPM_SYMBOL(n, s) (HPM->share((s), (n)), true) diff --git a/src/common/console.c b/src/common/console.c index 10e1bee1a..0be33e5c3 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -523,7 +523,8 @@ void console_parse_init(void) { timer->add_func_list(console->input->parse_timer, "console_parse_timer"); 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(Sql *SQL_handle) { +void console_setSQL(struct Sql *SQL_handle) +{ console->input->SQL = SQL_handle; } #endif /* CONSOLE_INPUT */ diff --git a/src/common/console.h b/src/common/console.h index 43f48b865..57c750a7d 100644 --- a/src/common/console.h +++ b/src/common/console.h @@ -24,9 +24,11 @@ #include "common/db.h" #include "common/mutex.h" #include "common/spinlock.h" -#include "common/sql.h" #include "common/thread.h" +/* Forward Declarations */ +struct Sql; // common/sql.h + /** * Queue Max * why is there a limit, why not make it dynamic? - I'm playing it safe, I'd rather not play with memory management between threads @@ -78,7 +80,7 @@ struct console_input_interface { VECTOR_DECL(struct CParseEntry *) command_list; VECTOR_DECL(struct CParseEntry *) commands; /* */ - Sql *SQL; + struct Sql *SQL; /* */ void (*parse_init) (void); void (*parse_final) (void); @@ -90,7 +92,7 @@ struct console_input_interface { void (*load_defaults) (void); void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth); void (*addCommand) (char *name, CParseFunc func); - void (*setSQL) (Sql *SQL_handle); + void (*setSQL) (struct Sql *SQL_handle); #else // not CONSOLE_INPUT UNAVAILABLE_STRUCT; #endif diff --git a/src/common/sql.c b/src/common/sql.c index ed93169ea..1dcf5d374 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -79,11 +79,11 @@ struct SqlStmt { /////////////////////////////////////////////////////////////////////////////// /// Allocates and initializes a new Sql handle. -Sql* Sql_Malloc(void) +struct Sql *Sql_Malloc(void) { - Sql* self; + struct Sql *self; - CREATE(self, Sql, 1); + CREATE(self, struct Sql, 1); mysql_init(&self->handle); StrBuf->Init(&self->buf); self->lengths = NULL; @@ -93,10 +93,10 @@ Sql* Sql_Malloc(void) return self; } -static int Sql_P_Keepalive(Sql* self); +static int Sql_P_Keepalive(struct Sql *self); /// Establishes a connection. -int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* host, uint16 port, const char* db) +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; @@ -119,7 +119,7 @@ int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* hos } /// Retrieves the timeout of the connection. -int Sql_GetTimeout(Sql* self, uint32* out_timeout) +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; @@ -136,7 +136,7 @@ int Sql_GetTimeout(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(Sql* self, const char* table, char* out_buf, size_t buf_len, char sep) +int Sql_GetColumnNames(struct Sql *self, const char *table, char *out_buf, size_t buf_len, char sep) { char* data; size_t len; @@ -164,7 +164,7 @@ int Sql_GetColumnNames(Sql* self, const char* table, char* out_buf, size_t buf_l } /// Changes the encoding of the connection. -int Sql_SetEncoding(Sql* self, const char* encoding) +int Sql_SetEncoding(struct Sql *self, const char *encoding) { if( self && mysql_set_character_set(&self->handle, encoding) == 0 ) return SQL_SUCCESS; @@ -172,7 +172,7 @@ int Sql_SetEncoding(Sql* self, const char* encoding) } /// Pings the connection. -int Sql_Ping(Sql* self) +int Sql_Ping(struct Sql *self) { if( self && mysql_ping(&self->handle) == 0 ) return SQL_SUCCESS; @@ -184,7 +184,7 @@ int Sql_Ping(Sql* self) /// @private static int Sql_P_KeepaliveTimer(int tid, int64 tick, int id, intptr_t data) { - Sql* self = (Sql*)data; + struct Sql *self = (struct Sql *)data; ShowInfo("Pinging SQL server to keep connection alive...\n"); Sql_Ping(self); return 0; @@ -194,7 +194,7 @@ static int Sql_P_KeepaliveTimer(int tid, int64 tick, int id, intptr_t data) /// /// @return the keepalive timer id, or INVALID_TIMER /// @private -static int Sql_P_Keepalive(Sql* self) +static int Sql_P_Keepalive(struct Sql *self) { uint32 timeout, ping_interval; @@ -214,26 +214,27 @@ static int Sql_P_Keepalive(Sql* self) } /// Escapes a string. -size_t Sql_EscapeString(Sql* self, char *out_to, const char *from) +size_t Sql_EscapeString(struct Sql *self, char *out_to, const char *from) { - if( self ) + if (self != NULL) return (size_t)mysql_real_escape_string(&self->handle, out_to, from, (unsigned long)strlen(from)); else return (size_t)mysql_escape_string(out_to, from, (unsigned long)strlen(from)); } /// Escapes a string. -size_t Sql_EscapeStringLen(Sql* self, char *out_to, const char *from, size_t from_len) +size_t Sql_EscapeStringLen(struct Sql *self, char *out_to, const char *from, size_t from_len) { - if( self ) + if (self != NULL) return (size_t)mysql_real_escape_string(&self->handle, out_to, from, (unsigned long)from_len); else return (size_t)mysql_escape_string(out_to, from, (unsigned long)from_len); } /// Executes a query. -int Sql_Query(Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3))); -int Sql_Query(Sql *self, const char *query, ...) { +int Sql_Query(struct Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3))); +int Sql_Query(struct Sql *self, const char *query, ...) +{ int res; va_list args; @@ -245,7 +246,7 @@ int Sql_Query(Sql *self, const char *query, ...) { } /// Executes a query. -int Sql_QueryV(Sql* self, const char* query, va_list args) +int Sql_QueryV(struct Sql *self, const char *query, va_list args) { if( self == NULL ) return SQL_ERROR; @@ -270,7 +271,7 @@ int Sql_QueryV(Sql* self, const char* query, va_list args) } /// Executes a query. -int Sql_QueryStr(Sql* self, const char* query) +int Sql_QueryStr(struct Sql *self, const char *query) { if( self == NULL ) return SQL_ERROR; @@ -295,33 +296,34 @@ int Sql_QueryStr(Sql* self, const char* query) } /// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE query. -uint64 Sql_LastInsertId(Sql* self) +uint64 Sql_LastInsertId(struct Sql *self) { - if( self ) + if (self != NULL) return (uint64)mysql_insert_id(&self->handle); else return 0; } /// Returns the number of columns in each row of the result. -uint32 Sql_NumColumns(Sql* self) +uint32 Sql_NumColumns(struct Sql *self) { - if( self && self->result ) + if (self != NULL && self->result != NULL) return (uint32)mysql_num_fields(self->result); return 0; } /// Returns the number of rows in the result. -uint64 Sql_NumRows(Sql* self) +uint64 Sql_NumRows(struct Sql *self) { - if( self && self->result ) + if (self != NULL && self->result != NULL) return (uint64)mysql_num_rows(self->result); return 0; } /// Fetches the next row. -int Sql_NextRow(Sql* self) { - if( self && self->result ) { +int Sql_NextRow(struct Sql *self) +{ + if (self != NULL && self->result != NULL) { self->row = mysql_fetch_row(self->result); if( self->row ) { self->lengths = mysql_fetch_lengths(self->result); @@ -335,7 +337,7 @@ int Sql_NextRow(Sql* self) { } /// Gets the data of a column. -int Sql_GetData(Sql* self, size_t col, char** out_buf, size_t* out_len) +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) ) { @@ -351,7 +353,8 @@ int Sql_GetData(Sql* self, size_t col, char** out_buf, size_t* out_len) } /// Frees the result of the query. -void Sql_FreeResult(Sql* self) { +void Sql_FreeResult(struct Sql *self) +{ if( self && self->result ) { mysql_free_result(self->result); self->result = NULL; @@ -361,7 +364,7 @@ void Sql_FreeResult(Sql* self) { } /// Shows debug information (last query). -void Sql_ShowDebug_(Sql* self, const char* debug_file, const unsigned long debug_line) +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); @@ -372,7 +375,7 @@ void Sql_ShowDebug_(Sql* self, const char* debug_file, const unsigned long debug } /// Frees a Sql handle returned by Sql_Malloc. -void Sql_Free(Sql* self) { +void Sql_Free(struct Sql *self) { if( self ) { SQL->FreeResult(self); @@ -515,7 +518,7 @@ static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_ty /// Reports debug information about a truncated column. /// /// @private -static void SqlStmt_P_ShowDebugTruncatedColumn(SqlStmt* self, size_t i) +static void SqlStmt_P_ShowDebugTruncatedColumn(struct SqlStmt *self, size_t i) { MYSQL_RES* meta; MYSQL_FIELD* field; @@ -535,8 +538,9 @@ static void SqlStmt_P_ShowDebugTruncatedColumn(SqlStmt* self, size_t i) } /// Allocates and initializes a new SqlStmt handle. -SqlStmt* SqlStmt_Malloc(Sql* sql) { - SqlStmt* self; +struct SqlStmt *SqlStmt_Malloc(struct Sql *sql) +{ + struct SqlStmt *self; MYSQL_STMT* stmt; if( sql == NULL ) @@ -547,7 +551,7 @@ SqlStmt* SqlStmt_Malloc(Sql* sql) { ShowSQL("DB error - %s\n", mysql_error(&sql->handle)); return NULL; } - CREATE(self, SqlStmt, 1); + CREATE(self, struct SqlStmt, 1); StrBuf->Init(&self->buf); self->stmt = stmt; self->params = NULL; @@ -562,8 +566,9 @@ SqlStmt* SqlStmt_Malloc(Sql* sql) { } /// Prepares the statement. -int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3))); -int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) { +int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3))); +int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...) +{ int res; va_list args; @@ -575,7 +580,7 @@ int SqlStmt_Prepare(SqlStmt *self, const char *query, ...) { } /// Prepares the statement. -int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args) +int SqlStmt_PrepareV(struct SqlStmt *self, const char *query, va_list args) { if( self == NULL ) return SQL_ERROR; @@ -595,7 +600,7 @@ int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args) } /// Prepares the statement. -int SqlStmt_PrepareStr(SqlStmt* self, const char* query) +int SqlStmt_PrepareStr(struct SqlStmt *self, const char *query) { if( self == NULL ) return SQL_ERROR; @@ -615,7 +620,7 @@ int SqlStmt_PrepareStr(SqlStmt* self, const char* query) } /// Returns the number of parameters in the prepared statement. -size_t SqlStmt_NumParams(SqlStmt* self) +size_t SqlStmt_NumParams(struct SqlStmt *self) { if( self ) return (size_t)mysql_stmt_param_count(self->stmt); @@ -624,7 +629,7 @@ size_t SqlStmt_NumParams(SqlStmt* self) } /// Binds a parameter to a buffer. -int SqlStmt_BindParam(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, void* buffer, size_t buffer_len) +int SqlStmt_BindParam(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len) { if( self == NULL ) return SQL_ERROR; @@ -652,7 +657,7 @@ int SqlStmt_BindParam(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, v } /// Executes the prepared statement. -int SqlStmt_Execute(SqlStmt* self) +int SqlStmt_Execute(struct SqlStmt *self) { if( self == NULL ) return SQL_ERROR; @@ -677,7 +682,7 @@ int SqlStmt_Execute(SqlStmt* self) } /// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement. -uint64 SqlStmt_LastInsertId(SqlStmt* self) +uint64 SqlStmt_LastInsertId(struct SqlStmt *self) { if( self ) return (uint64)mysql_stmt_insert_id(self->stmt); @@ -686,7 +691,7 @@ uint64 SqlStmt_LastInsertId(SqlStmt* self) } /// Returns the number of columns in each row of the result. -size_t SqlStmt_NumColumns(SqlStmt* self) +size_t SqlStmt_NumColumns(struct SqlStmt *self) { if( self ) return (size_t)mysql_stmt_field_count(self->stmt); @@ -695,7 +700,8 @@ size_t SqlStmt_NumColumns(SqlStmt* self) } /// Binds the result of a column to a buffer. -int SqlStmt_BindColumn(SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null) { +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; @@ -736,16 +742,16 @@ int SqlStmt_BindColumn(SqlStmt *self, size_t idx, enum SqlDataType buffer_type, } /// Returns the number of rows in the result. -uint64 SqlStmt_NumRows(SqlStmt* self) +uint64 SqlStmt_NumRows(struct SqlStmt *self) { - if( self ) + if (self != NULL) return (uint64)mysql_stmt_num_rows(self->stmt); else return 0; } /// Fetches the next row. -int SqlStmt_NextRow(SqlStmt* self) +int SqlStmt_NextRow(struct SqlStmt *self) { int err; size_t i; @@ -828,14 +834,14 @@ int SqlStmt_NextRow(SqlStmt* self) } /// Frees the result of the statement execution. -void SqlStmt_FreeResult(SqlStmt* self) +void SqlStmt_FreeResult(struct SqlStmt *self) { if( self ) mysql_stmt_free_result(self->stmt); } /// Shows debug information (with statement). -void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned long debug_line) +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); @@ -846,7 +852,7 @@ void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned lo } /// Frees a SqlStmt returned by SqlStmt_Malloc. -void SqlStmt_Free(SqlStmt* self) +void SqlStmt_Free(struct SqlStmt *self) { if( self ) { @@ -919,7 +925,8 @@ void Sql_inter_server_read(const char* cfgName, bool first) { return; } -void Sql_HerculesUpdateCheck(Sql* self) { +void Sql_HerculesUpdateCheck(struct Sql *self) +{ char line[22];// "yyyy-mm-dd--hh-mm" (17) + ".sql" (4) + 1 FILE* ifp;/* index fp */ unsigned int performed = 0; @@ -980,7 +987,8 @@ void Sql_HerculesUpdateCheck(Sql* self) { StrBuf->Destroy(&buf); } -void Sql_HerculesUpdateSkip(Sql* self,const char *filename) { +void Sql_HerculesUpdateSkip(struct Sql *self, const char *filename) +{ char path[41];// "sql-files/upgrades/" (19) + "yyyy-mm-dd--hh-mm" (17) + ".sql" (4) + 1 char timestamp[11];// "1360186680" (10) + 1 FILE* ifp;/* index fp */ diff --git a/src/common/sql.h b/src/common/sql.h index e949a8280..3619895b1 100644 --- a/src/common/sql.h +++ b/src/common/sql.h @@ -71,90 +71,86 @@ enum SqlDataType { SQLDT_LASTID }; -struct Sql;// Sql handle (private access) -struct SqlStmt;// Sql statement (private access) - -typedef enum SqlDataType SqlDataType; -typedef struct Sql Sql; -typedef struct SqlStmt SqlStmt; +struct Sql; ///< Sql handle (private access) +struct SqlStmt; ///< Sql statement (private access) struct sql_interface { /// Establishes a connection. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*Connect) (Sql* self, const char* user, const char* passwd, const char* host, uint16 port, const char* db); + int (*Connect) (struct Sql *self, const char *user, const char *passwd, const char *host, uint16 port, const char *db); /// Retrieves the timeout of the connection. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*GetTimeout) (Sql* self, uint32* out_timeout); + int (*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. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*GetColumnNames) (Sql* self, const char* table, char* out_buf, size_t buf_len, char sep); + int (*GetColumnNames) (struct Sql *self, const char *table, char *out_buf, size_t buf_len, char sep); /// Changes the encoding of the connection. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*SetEncoding) (Sql* self, const char* encoding); + int (*SetEncoding) (struct Sql *self, const char *encoding); /// Pings the connection. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*Ping) (Sql* self); + int (*Ping) (struct Sql *self); /// Escapes a string. /// The output buffer must be at least strlen(from)*2+1 in size. /// /// @return The size of the escaped string - size_t (*EscapeString) (Sql* self, char* out_to, const char* from); + size_t (*EscapeString) (struct Sql *self, char *out_to, const char *from); /// Escapes a string. /// The output buffer must be at least from_len*2+1 in size. /// /// @return The size of the escaped string - size_t (*EscapeStringLen) (Sql* self, char* out_to, const char* from, size_t from_len); + size_t (*EscapeStringLen) (struct Sql *self, char *out_to, const char *from, size_t from_len); /// Executes a query. /// Any previous result is freed. /// The query is constructed as if it was sprintf. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*Query) (Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3))); + int (*Query) (struct Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3))); /// Executes a query. /// Any previous result is freed. /// The query is constructed as if it was svprintf. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*QueryV) (Sql* self, const char* query, va_list args); + int (*QueryV) (struct Sql *self, const char *query, va_list args); /// Executes a query. /// Any previous result is freed. /// The query is used directly. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*QueryStr) (Sql* self, const char* query); + int (*QueryStr) (struct Sql *self, const char *query); /// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE query. /// /// @return Value of the auto-increment column - uint64 (*LastInsertId) (Sql* self); + uint64 (*LastInsertId) (struct Sql *self); /// Returns the number of columns in each row of the result. /// /// @return Number of columns - uint32 (*NumColumns) (Sql* self); + uint32 (*NumColumns) (struct Sql *self); /// Returns the number of rows in the result. /// /// @return Number of rows - uint64 (*NumRows) (Sql* self); + uint64 (*NumRows) (struct Sql *self); /// Fetches the next row. /// The data of the previous row is no longer valid. /// /// @return SQL_SUCCESS, SQL_ERROR or SQL_NO_DATA - int (*NextRow) (Sql* self); + int (*NextRow) (struct Sql *self); /// Gets the data of a column. /// The data remains valid until the next row is fetched or the result is freed. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*GetData) (Sql* self, size_t col, char** out_buf, size_t* out_len); + int (*GetData) (struct Sql *self, size_t col, char **out_buf, size_t *out_len); /// Frees the result of the query. - void (*FreeResult) (Sql* self); + void (*FreeResult) (struct Sql *self); /// Shows debug information (last query). - void (*ShowDebug_) (Sql* self, const char* debug_file, const unsigned long debug_line); + void (*ShowDebug_) (struct Sql *self, const char *debug_file, const unsigned long debug_line); /// Frees a Sql handle returned by Sql_Malloc. - void (*Free) (Sql* self); + void (*Free) (struct Sql *self); /// Allocates and initializes a new Sql handle. struct Sql *(*Malloc) (void); @@ -180,56 +176,56 @@ struct sql_interface { /// Queries in Sql and SqlStmt are independent and don't affect each other. /// /// @return SqlStmt handle or NULL if an error occurred - struct SqlStmt* (*StmtMalloc)(Sql* sql); + struct SqlStmt* (*StmtMalloc)(struct Sql *sql); /// Prepares the statement. /// Any previous result is freed and all parameter bindings are removed. /// The query is constructed as if it was sprintf. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*StmtPrepare) (SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3))); + int (*StmtPrepare) (struct SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3))); /// Prepares the statement. /// Any previous result is freed and all parameter bindings are removed. /// The query is constructed as if it was svprintf. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*StmtPrepareV)(SqlStmt* self, const char* query, va_list args); + int (*StmtPrepareV)(struct SqlStmt *self, const char *query, va_list args); /// Prepares the statement. /// Any previous result is freed and all parameter bindings are removed. /// The query is used directly. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*StmtPrepareStr)(SqlStmt* self, const char* query); + int (*StmtPrepareStr)(struct SqlStmt *self, const char *query); /// Returns the number of parameters in the prepared statement. /// /// @return Number or parameters - size_t (*StmtNumParams)(SqlStmt* self); + size_t (*StmtNumParams)(struct SqlStmt *self); /// Binds a parameter to a buffer. /// The buffer data will be used when the statement is executed. /// All parameters should have bindings. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*StmtBindParam)(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len); + int (*StmtBindParam)(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len); /// Executes the prepared statement. /// Any previous result is freed and all column bindings are removed. /// /// @return SQL_SUCCESS or SQL_ERROR - int (*StmtExecute)(SqlStmt* self); + int (*StmtExecute)(struct SqlStmt *self); /// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement. /// /// @return Value of the auto-increment column - uint64 (*StmtLastInsertId)(SqlStmt* self); + uint64 (*StmtLastInsertId)(struct SqlStmt *self); /// Returns the number of columns in each row of the result. /// /// @return Number of columns - size_t (*StmtNumColumns)(SqlStmt* self); + size_t (*StmtNumColumns)(struct SqlStmt *self); /// Binds the result of a column to a buffer. /// The buffer will be filled with data when the next row is fetched. @@ -237,26 +233,26 @@ struct sql_interface { /// and the null-terminator (an extra byte). /// /// @return SQL_SUCCESS or SQL_ERROR - int (*StmtBindColumn)(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null); + int (*StmtBindColumn)(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null); /// Returns the number of rows in the result. /// /// @return Number of rows - uint64 (*StmtNumRows)(SqlStmt* self); + uint64 (*StmtNumRows)(struct SqlStmt *self); /// Fetches the next row. /// All column bindings will be filled with data. /// /// @return SQL_SUCCESS, SQL_ERROR or SQL_NO_DATA - int (*StmtNextRow)(SqlStmt* self); + int (*StmtNextRow)(struct SqlStmt *self); /// Frees the result of the statement execution. - void (*StmtFreeResult)(SqlStmt* self); + void (*StmtFreeResult)(struct SqlStmt *self); /// Frees a SqlStmt returned by SqlStmt_Malloc. - void (*StmtFree)(SqlStmt* self); + void (*StmtFree)(struct SqlStmt *self); - void (*StmtShowDebug_)(SqlStmt* self, const char* debug_file, const unsigned long debug_line); + void (*StmtShowDebug_)(struct SqlStmt *self, const char *debug_file, const unsigned long debug_line); }; @@ -265,8 +261,8 @@ void sql_defaults(void); void Sql_Init(void); -void Sql_HerculesUpdateCheck(Sql* self); -void Sql_HerculesUpdateSkip(Sql* self,const char *filename); +void Sql_HerculesUpdateCheck(struct Sql *self); +void Sql_HerculesUpdateSkip(struct Sql *self, const char *filename); #endif // HERCULES_CORE HPShared struct sql_interface *SQL; |