diff options
author | Haru <haru@dotalux.com> | 2016-02-19 21:37:39 +0100 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-03-20 18:32:07 +0100 |
commit | f4fced20c769ccee7f808531221dda481f7bbcca (patch) | |
tree | 4bbdd3509a3d6f682e89279f8df2abb1e259a198 /src/common/sql.h | |
parent | 8c9e9668cef87ab9595bde6608de424072cc752d (diff) | |
download | hercules-f4fced20c769ccee7f808531221dda481f7bbcca.tar.gz hercules-f4fced20c769ccee7f808531221dda481f7bbcca.tar.bz2 hercules-f4fced20c769ccee7f808531221dda481f7bbcca.tar.xz hercules-f4fced20c769ccee7f808531221dda481f7bbcca.zip |
Removed unnecessary typedefs from sql.h
- Sql -> struct Sql
- SqlStmt -> struct SqlStmt
- SqlDataType -> enum SqlDataType
This is expected to improve compile time, by removing #include cycles (and forward declaring instead)
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/sql.h')
-rw-r--r-- | src/common/sql.h | 78 |
1 files changed, 37 insertions, 41 deletions
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; |