1 | /*************************************** 2 | $Revision: 1.13 $ 3 | 4 | SQL module (sq) - MySQL implementation of SQL driver. 5 | 6 | Status: NOT REVUED, NOT TESTED 7 | 8 | ******************/ /****************** 9 | Copyright (c) 1999 RIPE NCC 10 | 11 | All Rights Reserved 12 | 13 | Permission to use, copy, modify, and distribute this software and its 14 | documentation for any purpose and without fee is hereby granted, 15 | provided that the above copyright notice appear in all copies and that 16 | both that copyright notice and this permission notice appear in 17 | supporting documentation, and that the name of the author not be 18 | used in advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 22 | ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL 23 | AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY 24 | DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN 25 | AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 26 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 27 | ***************************************/ 28 | #ifndef READ_MYSQL_DRIVER 29 | #define READ_MYSQL_DRIVER 30 | 31 | #include "mysql.h" 32 | #include "mysqld_error.h" 33 | 34 | /* types for mysql_info */ 35 | #define SQL_RECORDS 0 36 | #define SQL_MATCHES 0 // for UPDATE queries (checking for duplicates) 37 | #define SQL_DUPLICATES 1 38 | #define SQL_WARNINGS 2 39 | 40 | 41 | 42 | #define SQ_connection_t MYSQL 43 | #define SQ_result_set_t MYSQL_RES 44 | 45 | #define SQ_row_t MYSQL_ROW 46 | 47 | SQ_connection_t *sq_connection_init(void); 48 | SQ_connection_t *sq_connection_get(SQ_connection_t *sql_connection, const char *host, unsigned int port,const char *db, const char *user, const char *password); 49 | SQ_connection_t *SQ_get_connection(const char *host, unsigned int port, const char *db, const char *user, const char *password); 50 | SQ_connection_t *SQ_get_connection2(void); 51 | int SQ_execute_query(SQ_connection_t *sql_connection, 52 | const char *query, SQ_result_set_t **result_ptr); 53 | int SQ_get_column_count(SQ_result_set_t *result); 54 | char *SQ_get_column_label(SQ_result_set_t *result, unsigned int column); 55 | unsigned int SQ_get_column_max_length(SQ_result_set_t *result, unsigned int column); 56 | SQ_row_t *SQ_row_next(SQ_result_set_t *result); 57 | char *SQ_get_column_string(SQ_result_set_t *result, SQ_row_t *current_row, unsigned int column); 58 | char *SQ_get_column_string_nocopy(SQ_result_set_t *result, 59 | SQ_row_t *current_row, 60 | unsigned int column); 61 | char *SQ_get_column_strings(SQ_result_set_t *result, unsigned int column); 62 | int SQ_get_column_int(SQ_result_set_t *result, SQ_row_t *current_row, unsigned int column, long *resultptr); 63 | char *SQ_result_to_string(SQ_result_set_t *result); 64 | void SQ_free_result(SQ_result_set_t *result); 65 | SQ_connection_t *SQ_connect_to_server (char *host,char *user,char *passwd,char *db,uint port); 66 | void SQ_close_connection(SQ_connection_t *sql_connection); 67 | SQ_result_set_t *SQ_query_server(SQ_connection_t *sql_connection, char *query); 68 | 69 | /* report number of rows */ 70 | int SQ_num_rows(SQ_result_set_t *result); 71 | int SQ_get_table_size(SQ_connection_t *sql_connection, char *table); 72 | int SQ_get_affected_rows(SQ_connection_t *sql_connection); 73 | 74 | char *SQ_info_to_string(SQ_connection_t *sql_connection); 75 | char *SQ_error(SQ_connection_t *sql_connection); 76 | int SQ_errno(SQ_connection_t *sql_connection); 77 | int SQ_get_info(SQ_connection_t *sql_connection, int info[3]); 78 | 79 | #endif /* READ_MYSQL_DRIVER */