summaryrefslogtreecommitdiff
path: root/src/common/sql.h
diff options
context:
space:
mode:
authorgreenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-11-25 21:20:43 +0000
committergreenboxal2 <greenboxal2@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-11-25 21:20:43 +0000
commitb11bf6e1604097711291265f927e79e8f2af5c54 (patch)
tree6eac67dfe94b2cef4e48f59c1bf448a321ce24cd /src/common/sql.h
parentd9c5c4784a0abc43fb9e01f365a0d8b3a15a0692 (diff)
downloadhercules-b11bf6e1604097711291265f927e79e8f2af5c54.tar.gz
hercules-b11bf6e1604097711291265f927e79e8f2af5c54.tar.bz2
hercules-b11bf6e1604097711291265f927e79e8f2af5c54.tar.xz
hercules-b11bf6e1604097711291265f927e79e8f2af5c54.zip
Applied AStyle code formating as discussed on tid:74602.
Removed /SAFESEH option from MSVC11 projects. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16968 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/sql.h')
-rw-r--r--src/common/sql.h139
1 files changed, 69 insertions, 70 deletions
diff --git a/src/common/sql.h b/src/common/sql.h
index 898e2c778..4534061e0 100644
--- a/src/common/sql.h
+++ b/src/common/sql.h
@@ -21,39 +21,38 @@
/// Data type identifier.
/// String, enum and blob data types need the buffer length specified.
-enum SqlDataType
-{
- SQLDT_NULL,
- // fixed size
- SQLDT_INT8,
- SQLDT_INT16,
- SQLDT_INT32,
- SQLDT_INT64,
- SQLDT_UINT8,
- SQLDT_UINT16,
- SQLDT_UINT32,
- SQLDT_UINT64,
- // platform dependent size
- SQLDT_CHAR,
- SQLDT_SHORT,
- SQLDT_INT,
- SQLDT_LONG,
- SQLDT_LONGLONG,
- SQLDT_UCHAR,
- SQLDT_USHORT,
- SQLDT_UINT,
- SQLDT_ULONG,
- SQLDT_ULONGLONG,
- // floating point
- SQLDT_FLOAT,
- SQLDT_DOUBLE,
- // other
- SQLDT_STRING,
- SQLDT_ENUM,
- // Note: An ENUM is a string with restricted values. When an invalid value
- // is inserted, it is saved as an empty string (numerical value 0).
- SQLDT_BLOB,
- SQLDT_LASTID
+enum SqlDataType {
+ SQLDT_NULL,
+ // fixed size
+ SQLDT_INT8,
+ SQLDT_INT16,
+ SQLDT_INT32,
+ SQLDT_INT64,
+ SQLDT_UINT8,
+ SQLDT_UINT16,
+ SQLDT_UINT32,
+ SQLDT_UINT64,
+ // platform dependent size
+ SQLDT_CHAR,
+ SQLDT_SHORT,
+ SQLDT_INT,
+ SQLDT_LONG,
+ SQLDT_LONGLONG,
+ SQLDT_UCHAR,
+ SQLDT_USHORT,
+ SQLDT_UINT,
+ SQLDT_ULONG,
+ SQLDT_ULONGLONG,
+ // floating point
+ SQLDT_FLOAT,
+ SQLDT_DOUBLE,
+ // other
+ SQLDT_STRING,
+ SQLDT_ENUM,
+ // Note: An ENUM is a string with restricted values. When an invalid value
+ // is inserted, it is saved as an empty string (numerical value 0).
+ SQLDT_BLOB,
+ SQLDT_LASTID
};
struct Sql;// Sql handle (private access)
@@ -65,14 +64,14 @@ typedef struct SqlStmt SqlStmt;
/// Allocates and initializes a new Sql handle.
-struct Sql* Sql_Malloc(void);
+struct Sql *Sql_Malloc(void);
/// Establishes a connection.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* host, uint16 port, const char* db);
+int Sql_Connect(Sql *self, const char *user, const char *passwd, const char *host, uint16 port, const char *db);
@@ -80,7 +79,7 @@ int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* hos
/// Retrieves the timeout of the connection.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int Sql_GetTimeout(Sql* self, uint32* out_timeout);
+int Sql_GetTimeout(Sql *self, uint32 *out_timeout);
@@ -88,7 +87,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.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int Sql_GetColumnNames(Sql* self, const char* table, char* out_buf, size_t buf_len, char sep);
+int Sql_GetColumnNames(Sql *self, const char *table, char *out_buf, size_t buf_len, char sep);
@@ -96,14 +95,14 @@ int Sql_GetColumnNames(Sql* self, const char* table, char* out_buf, size_t buf_l
/// Changes the encoding of the connection.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int Sql_SetEncoding(Sql* self, const char* encoding);
+int Sql_SetEncoding(Sql *self, const char *encoding);
/// Pings the connection.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int Sql_Ping(Sql* self);
+int Sql_Ping(Sql *self);
@@ -111,7 +110,7 @@ int Sql_Ping(Sql* self);
/// The output buffer must be at least strlen(from)*2+1 in size.
///
/// @return The size of the escaped string
-size_t Sql_EscapeString(Sql* self, char* out_to, const char* from);
+size_t Sql_EscapeString(Sql *self, char *out_to, const char *from);
@@ -119,7 +118,7 @@ size_t Sql_EscapeString(Sql* self, char* out_to, const char* from);
/// The output buffer must be at least from_len*2+1 in size.
///
/// @return The size of the escaped string
-size_t Sql_EscapeStringLen(Sql* self, char* out_to, const char* from, size_t from_len);
+size_t Sql_EscapeStringLen(Sql *self, char *out_to, const char *from, size_t from_len);
@@ -128,7 +127,7 @@ size_t Sql_EscapeStringLen(Sql* self, char* out_to, const char* from, size_t fro
/// The query is constructed as if it was sprintf.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int Sql_Query(Sql* self, const char* query, ...);
+int Sql_Query(Sql *self, const char *query, ...);
@@ -137,7 +136,7 @@ int Sql_Query(Sql* self, const char* query, ...);
/// The query is constructed as if it was svprintf.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int Sql_QueryV(Sql* self, const char* query, va_list args);
+int Sql_QueryV(Sql *self, const char *query, va_list args);
@@ -146,28 +145,28 @@ int Sql_QueryV(Sql* self, const char* query, va_list args);
/// The query is used directly.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int Sql_QueryStr(Sql* self, const char* query);
+int Sql_QueryStr(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 Sql_LastInsertId(Sql* self);
+uint64 Sql_LastInsertId(Sql *self);
/// Returns the number of columns in each row of the result.
///
/// @return Number of columns
-uint32 Sql_NumColumns(Sql* self);
+uint32 Sql_NumColumns(Sql *self);
/// Returns the number of rows in the result.
///
/// @return Number of rows
-uint64 Sql_NumRows(Sql* self);
+uint64 Sql_NumRows(Sql *self);
@@ -175,7 +174,7 @@ uint64 Sql_NumRows(Sql* self);
/// The data of the previous row is no longer valid.
///
/// @return SQL_SUCCESS, SQL_ERROR or SQL_NO_DATA
-int Sql_NextRow(Sql* self);
+int Sql_NextRow(Sql *self);
@@ -183,12 +182,12 @@ int Sql_NextRow(Sql* self);
/// The data remains valid until the next row is fetched or the result is freed.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int Sql_GetData(Sql* self, size_t col, char** out_buf, size_t* out_len);
+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(Sql *self);
@@ -198,22 +197,22 @@ void Sql_FreeResult(Sql* self);
#define Sql_ShowDebug(self) Sql_ShowDebug_(self, __FILE__, __LINE__)
#endif
/// Shows debug information (last query).
-void Sql_ShowDebug_(Sql* self, const char* debug_file, const unsigned long debug_line);
+void Sql_ShowDebug_(Sql *self, const char *debug_file, const unsigned long debug_line);
/// Frees a Sql handle returned by Sql_Malloc.
-void Sql_Free(Sql* self);
+void Sql_Free(Sql *self);
///////////////////////////////////////////////////////////////////////////////
// Prepared Statements
///////////////////////////////////////////////////////////////////////////////
-// Parameters are placed in the statement by embedding question mark ('?')
+// Parameters are placed in the statement by embedding question mark ('?')
// characters into the query at the appropriate positions.
// The markers are legal only in places where they represent data.
-// The markers cannot be inside quotes. Quotes will be added automatically
+// The markers cannot be inside quotes. Quotes will be added automatically
// when they are required.
//
// example queries with parameters:
@@ -227,7 +226,7 @@ void Sql_Free(Sql* self);
/// Queries in Sql and SqlStmt are independent and don't affect each other.
///
/// @return SqlStmt handle or NULL if an error occured
-struct SqlStmt* SqlStmt_Malloc(Sql* sql);
+struct SqlStmt *SqlStmt_Malloc(Sql *sql);
@@ -236,7 +235,7 @@ struct SqlStmt* SqlStmt_Malloc(Sql* sql);
/// The query is constructed as if it was sprintf.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_Prepare(SqlStmt* self, const char* query, ...);
+int SqlStmt_Prepare(SqlStmt *self, const char *query, ...);
@@ -245,7 +244,7 @@ int SqlStmt_Prepare(SqlStmt* self, const char* query, ...);
/// The query is constructed as if it was svprintf.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args);
+int SqlStmt_PrepareV(SqlStmt *self, const char *query, va_list args);
@@ -254,14 +253,14 @@ int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args);
/// The query is used directly.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_PrepareStr(SqlStmt* self, const char* query);
+int SqlStmt_PrepareStr(SqlStmt *self, const char *query);
/// Returns the number of parameters in the prepared statement.
///
/// @return Number or paramenters
-size_t SqlStmt_NumParams(SqlStmt* self);
+size_t SqlStmt_NumParams(SqlStmt *self);
@@ -270,7 +269,7 @@ size_t SqlStmt_NumParams(SqlStmt* self);
/// All parameters should have bindings.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_BindParam(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len);
+int SqlStmt_BindParam(SqlStmt *self, size_t idx, SqlDataType buffer_type, void *buffer, size_t buffer_len);
@@ -278,38 +277,38 @@ int SqlStmt_BindParam(SqlStmt* self, size_t idx, SqlDataType buffer_type, void*
/// Any previous result is freed and all column bindings are removed.
///
/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_Execute(SqlStmt* self);
+int SqlStmt_Execute(SqlStmt *self);
/// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement.
///
/// @return Value of the auto-increment column
-uint64 SqlStmt_LastInsertId(SqlStmt* self);
+uint64 SqlStmt_LastInsertId(SqlStmt *self);
/// Returns the number of columns in each row of the result.
///
/// @return Number of columns
-size_t SqlStmt_NumColumns(SqlStmt* self);
+size_t SqlStmt_NumColumns(SqlStmt *self);
/// Binds the result of a column to a buffer.
/// The buffer will be filled with data when the next row is fetched.
-/// For string/enum buffer types there has to be enough space for the data
+/// For string/enum buffer types there has to be enough space for the data
/// and the nul-terminator (an extra byte).
///
/// @return SQL_SUCCESS or SQL_ERROR
-int SqlStmt_BindColumn(SqlStmt* self, size_t idx, SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null);
+int SqlStmt_BindColumn(SqlStmt *self, size_t idx, 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 SqlStmt_NumRows(SqlStmt* self);
+uint64 SqlStmt_NumRows(SqlStmt *self);
@@ -317,12 +316,12 @@ uint64 SqlStmt_NumRows(SqlStmt* self);
/// All column bindings will be filled with data.
///
/// @return SQL_SUCCESS, SQL_ERROR or SQL_NO_DATA
-int SqlStmt_NextRow(SqlStmt* self);
+int SqlStmt_NextRow(SqlStmt *self);
/// Frees the result of the statement execution.
-void SqlStmt_FreeResult(SqlStmt* self);
+void SqlStmt_FreeResult(SqlStmt *self);
@@ -332,12 +331,12 @@ void SqlStmt_FreeResult(SqlStmt* self);
#define SqlStmt_ShowDebug(self) SqlStmt_ShowDebug_(self, __FILE__, __LINE__)
#endif
/// Shows debug information (with statement).
-void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned long debug_line);
+void SqlStmt_ShowDebug_(SqlStmt *self, const char *debug_file, const unsigned long debug_line);
/// Frees a SqlStmt returned by SqlStmt_Malloc.
-void SqlStmt_Free(SqlStmt* self);
+void SqlStmt_Free(SqlStmt *self);