|
VLC
2.1.0-git
|

Go to the source code of this file.
Data Structures | |
| struct | sql_value_t |
| struct | sql_t |
Macros | |
| #define | VLC_SQL_ROW 1 |
| Return values for the function. | |
| #define | VLC_SQL_DONE 2 |
| #define | sql_Create(a, b, c, d, e, f) sql_Create( VLC_OBJECT(a), b, c, d, e, f ) |
| #define | sql_Destroy(a) sql_Destroy( VLC_OBJECT( a ) ) |
Typedefs | |
| typedef struct sql_t | sql_t |
| typedef struct sql_sys_t | sql_sys_t |
| typedef struct sql_stmt_t | sql_stmt_t |
| typedef int(* | sql_query_callback_t )(void *, int, char **, char **) |
Enumerations | |
| enum | sql_type_e { SQL_NULL, SQL_INT, SQL_DOUBLE, SQL_TEXT, SQL_BLOB } |
Functions | |
| sql_t * | sql_Create (vlc_object_t *p_this, const char *psz_name, const char *psz_host, int i_port, const char *psz_user, const char *psz_pass) |
| Create a new SQL object. | |
| void | sql_Destroy (vlc_object_t *obj) |
| Destructor for p_sql object. | |
| static int | sql_QueryCallback (sql_t *p_sql, const char *psz_query, sql_query_callback_t pf_callback, void *p_opaque) |
| Perform a query using a callback function. | |
| static int | sql_Query (sql_t *p_sql, const char *psz_query, char ***pppsz_result, int *pi_rows, int *pi_cols) |
| Perform a query directly. | |
| static int | sql_GetTables (sql_t *p_sql, char ***pppsz_tables) |
| Get database table name list. | |
| static void | sql_Free (sql_t *p_sql, char **ppsz_result) |
| Free the result of a query. | |
| static char * | sql_Printf (sql_t *p_sql, const char *psz_fmt,...) |
| printf-like function that can escape forbidden/reserved characters. | |
| static char * | sql_VPrintf (sql_t *p_sql, const char *psz_fmt, va_list arg) |
| vprintf replacement for SQL queries, escaping forbidden characters | |
| static int | sql_BeginTransaction (sql_t *p_sql) |
| Begin a SQL transaction. | |
| static int | sql_CommitTransaction (sql_t *p_sql) |
| Commit a SQL transaction. | |
| static void | sql_RollbackTransaction (sql_t *p_sql) |
| Rollback a SQL transaction. | |
| static sql_stmt_t * | sql_Prepare (sql_t *p_sql, const char *p_fmt, int i_length) |
| Prepare an sql statement. | |
| static int | sql_BindGeneric (sql_t *p_sql, sql_stmt_t *p_stmt, int i_pos, int type, const sql_value_t *p_value) |
| Bind arguments to a sql_stmt_t object. | |
| static int | sql_BindNull (sql_t *p_sql, sql_stmt_t *p_stmt, int i_pos) |
| Bind a NULL value to a position. | |
| static int | sql_BindInteger (sql_t *p_sql, sql_stmt_t *p_stmt, int i_pos, int i_int) |
| Bind an integer to the statement object at some position. | |
| static int | sql_BindDouble (sql_t *p_sql, sql_stmt_t *p_stmt, int i_pos, double d_dbl) |
| Bind a double to the statement object at some position. | |
| static int | sql_BindText (sql_t *p_sql, sql_stmt_t *p_stmt, int i_pos, char *p_fmt, int i_length) |
| Bind Text to the statement. | |
| static int | sql_BindBlob (sql_t *p_sql, sql_stmt_t *p_stmt, int i_pos, void *p_ptr, int i_length) |
| Bind a binary object to the statement. | |
| static int | sql_Run (sql_t *p_sql, sql_stmt_t *p_stmt) |
| Run the SQL statement. | |
| static int | sql_Reset (sql_t *p_sql, sql_stmt_t *p_stmt) |
| Reset the SQL statement. | |
| static int | sql_Finalize (sql_t *p_sql, sql_stmt_t *p_stmt) |
| Destroy the sql statement object. | |
| static int | sql_GetColumnType (sql_t *p_sql, sql_stmt_t *p_stmt, int i_col, int *type) |
| Get the datatype of the result of the column. | |
| static int | sql_GetColumn (sql_t *p_sql, sql_stmt_t *p_stmt, int i_col, int type, sql_value_t *p_res) |
| Get the column data. | |
| static int | sql_GetColumnInteger (sql_t *p_sql, sql_stmt_t *p_stmt, int i_col, int *pi_res) |
| Get an integer from the results of a statement. | |
| static int | sql_GetColumnDouble (sql_t *p_sql, sql_stmt_t *p_stmt, int i_col, double *pd_res) |
| Get a double from the results of a statement. | |
| static int | sql_GetColumnText (sql_t *p_sql, sql_stmt_t *p_stmt, int i_col, char **pp_res) |
| Get some text from the results of a statement. | |
| static int | sql_GetColumnBlob (sql_t *p_sql, sql_stmt_t *p_stmt, int i_col, void **pp_res) |
| Get a blob from the results of a statement. | |
| static int | sql_GetColumnSize (sql_t *p_sql, sql_stmt_t *p_stmt, int i_col) |
| Get the size of the column in bytes. | |
| #define sql_Create | ( | a, | |
| b, | |||
| c, | |||
| d, | |||
| e, | |||
| f | |||
| ) | sql_Create( VLC_OBJECT(a), b, c, d, e, f ) |
| #define sql_Destroy | ( | a | ) | sql_Destroy( VLC_OBJECT( a ) ) |
| #define VLC_SQL_DONE 2 |
| #define VLC_SQL_ROW 1 |
Return values for the function.
| typedef int( * sql_query_callback_t)(void *, int, char **, char **) |
| typedef struct sql_stmt_t sql_stmt_t |
| enum sql_type_e |
|
inlinestatic |
Begin a SQL transaction.
| p_sql | The SQL object |
References sql_t::pf_begin.
|
inlinestatic |
Bind a binary object to the statement.
| p_sql | The SQL object |
| p_stmt | Statement Object |
| i_pos | Position at which the parameter should be bound |
| p_ptr | Value to be bound |
| i_length | Size of the blob to read |
References sql_value_t::length, sql_value_t::ptr, sql_BindGeneric(), SQL_INT, and sql_value_t::value.
|
inlinestatic |
Bind a double to the statement object at some position.
| p_sql | The SQL object |
| p_stmt | Statement Object |
| i_pos | Position at which the parameter should be bound |
| d_dbl | Value to be bound |
References sql_value_t::dbl, sql_value_t::length, sql_BindGeneric(), SQL_INT, and sql_value_t::value.
|
inlinestatic |
Bind arguments to a sql_stmt_t object.
| p_sql | The SQL object |
| p_stmt | Statement Object |
| type | Data type of the value |
| p_value | Value to be bound |
| i_pos | Position at which the parameter should be bound |
References sql_t::pf_bind.
Referenced by sql_BindBlob(), sql_BindDouble(), sql_BindInteger(), sql_BindNull(), and sql_BindText().
|
inlinestatic |
Bind an integer to the statement object at some position.
| p_sql | The SQL object |
| p_stmt | Statement Object |
| i_pos | Position at which the parameter should be bound |
| i_int | Value to be bound |
References sql_value_t::i, sql_value_t::length, sql_BindGeneric(), SQL_INT, and sql_value_t::value.
|
inlinestatic |
Bind a NULL value to a position.
| p_sql | The SQL object |
| p_stmt | Statement Object |
| i_pos | Position at which the parameter should be bound |
References sql_BindGeneric(), and SQL_NULL.
|
inlinestatic |
Bind Text to the statement.
| p_sql | The SQL object |
| p_stmt | Statement Object |
| i_pos | Position at which the parameter should be bound |
| p_fmt | Value to be bound |
| i_length | Length of text. If -ve text up to the first null char will be selected. |
References sql_value_t::length, sql_value_t::psz, sql_BindGeneric(), SQL_TEXT, and sql_value_t::value.
|
inlinestatic |
Commit a SQL transaction.
| p_sql | The SQL object |
References sql_t::pf_commit.
| sql_t* sql_Create | ( | vlc_object_t * | p_this, |
| const char * | psz_name, | ||
| const char * | psz_host, | ||
| int | i_port, | ||
| const char * | psz_user, | ||
| const char * | psz_pass | ||
| ) |
Create a new SQL object.
| p_this | Parent object to attach the SQL object to. |
| psz_host | URL to the database |
| i_port | Port on which the database is running |
| psz_user | Username to access the database |
| psz_pass | Password for the database |
| void sql_Destroy | ( | vlc_object_t * | obj | ) |
Destructor for p_sql object.
| obj | This p_sql object |
|
inlinestatic |
Destroy the sql statement object.
This will free memory.
| p_sql | The SQL object |
| p_stmt | The statement object |
References sql_t::pf_finalize.
|
inlinestatic |
Free the result of a query.
| p_sql | This SQL object. |
| ppsz_result | The result of sql_Query or sql_GetTables. See above. |
References sql_t::pf_free.
|
inlinestatic |
Get the column data.
| p_sql | The SQL object |
| p_stmt | The statement object |
| i_col | The column number |
| type | Datatype of result |
| p_res | The structure which contains the value of the result |
References sql_t::pf_getcolumn.
|
inlinestatic |
Get a blob from the results of a statement.
| p_sql | The SQL object |
| p_stmt | The statement object |
| i_col | The column number |
| pp_res | Pointer of the location for result to be stored |
< No error
References sql_t::pf_getcolumn, sql_value_t::ptr, SQL_BLOB, sql_value_t::value, and VLC_SUCCESS.
|
inlinestatic |
Get a double from the results of a statement.
| p_sql | The SQL object |
| p_stmt | The statement object |
| i_col | The column number |
| d_res | Pointer of the location for result to be stored |
< No error
References sql_value_t::dbl, sql_t::pf_getcolumn, SQL_DOUBLE, sql_value_t::value, and VLC_SUCCESS.
|
inlinestatic |
Get an integer from the results of a statement.
| p_sql | The SQL object |
| p_stmt | The statement object |
| i_col | The column number |
| i_res | Pointer of the location for result to be stored |
< No error
References sql_value_t::i, sql_t::pf_getcolumn, SQL_INT, sql_value_t::value, and VLC_SUCCESS.
|
inlinestatic |
Get the size of the column in bytes.
| p_sql | The SQL object |
| p_stmt | The sql statement object |
| i_col | The column |
References sql_t::pf_getcolumnsize.
|
inlinestatic |
Get some text from the results of a statement.
| p_sql | The SQL object |
| p_stmt | The statement object |
| i_col | The column number |
| pp_res | Pointer of the location for result to be stored |
< No error
References sql_t::pf_getcolumn, sql_value_t::psz, SQL_TEXT, sql_value_t::value, and VLC_SUCCESS.
|
inlinestatic |
Get the datatype of the result of the column.
| p_sql | The SQL object |
| p_stmt | The sql statement object |
| i_col | The column |
| type | pointer to datatype of the given column |
References sql_t::pf_gettype.
|
inlinestatic |
Get database table name list.
| p_sql | This SQL object. |
| pppsz_tables | Pointer to an array of strings. Dynamically allocated. Similar to pppsz_result of sql_Query but with only one row. |
References sql_t::pf_get_tables.
|
inlinestatic |
Prepare an sql statement.
| p_sql | The SQL object |
| p_fmt | SQL query string |
| i_length | length of the string. If negative, length will be considered up to the first \0 character equivalent to strlen(p_fmt). Otherwise the first i_length bytes will be used |
References sql_t::pf_prepare.
|
inlinestatic |
printf-like function that can escape forbidden/reserved characters.
| p_sql | This SQL object. |
| psz_fmt | Format of the string (with q, Q and z enabled). |
| ... | Printf arguments |
References sql_t::pf_vmprintf.
|
inlinestatic |
Perform a query directly.
| p_sql | This SQL object. |
| psz_query | The SQL query string. |
| pppsz_result | A pointer to a array of strings: result of the query. Dynamically allocated. |
| pi_rows | Pointer to an integer that will receive the number of result rows written. |
| pi_cols | Pointer to an integer that will receive the number of result columns written. |
References sql_t::pf_query.
|
inlinestatic |
Perform a query using a callback function.
| p_sql | This SQL object. |
| psz_query | The SQL query string. |
| pf_callback | A callback function that will be called for each row of the result: 1st argument is be p_opaque, 2nd argument is the number of columns, 3rd is the result columns (array of strings), 4th is the columns names (array of strings). |
| p_opaque | Any pointer to an object you may need in the callback. |
References sql_t::pf_query_callback.
|
inlinestatic |
Reset the SQL statement.
Resetting the statement will unbind all the values that were bound on this statement
| p_sql | The SQL object |
| p_stmt | The sql statement object |
References sql_t::pf_reset.
|
inlinestatic |
Rollback a SQL transaction.
| p_sql | The SQL object |
References sql_t::pf_rollback.
|
inlinestatic |
Run the SQL statement.
If the statement fetches data, then only one row of the data is fetched at a time. Run this function again to fetch the next row.
| p_sql | The SQL object |
| p_stmt | The statement |
References sql_t::pf_run.
|
inlinestatic |
vprintf replacement for SQL queries, escaping forbidden characters
| p_sql | This SQL object |
| psz_fmt | Format of the string |
| arg | Variable list of arguments |
References sql_t::pf_vmprintf.
1.8.1.2