1    | /***************************************
2    |   $Revision: 1.22 $
3    | 
4    |   SQL module (sq) - MySQL implementation of SQL driver.
5    | 
6    |   Status: NOT REVUED, NOT TESTED
7    | 
8    |   ******************/ /******************
9    |   Copyright (c) 1999,2000,2001,2002               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   | #include "erroutines.h"
34   | 
35   | /* types for mysql_info */
36   | #define SQL_RECORDS 0
37   | #define SQL_MATCHES 0 // for UPDATE queries (checking for duplicates)
38   | #define SQL_DUPLICATES 1
39   | #define SQL_WARNINGS 2
40   | 
41   | 
42   | 
43   | #define SQ_connection_t MYSQL
44   | #define SQ_result_set_t MYSQL_RES
45   | 
46   | #define SQ_row_t MYSQL_ROW
47   | 
48   | #ifdef __cplusplus
49   | extern "C" {
50   | #endif
51   | 
52   | 
53   | 
54   | er_ret_t SQ_try_connection(SQ_connection_t **conn, const char *host, 
55   |                            unsigned int port, const char *db, 
56   | 		           const char *user, const char *password);
57   | SQ_connection_t *SQ_get_connection(const char *host, unsigned int port, const char *db, const char *user, const char *password);
58   | int SQ_execute_query(SQ_connection_t *sql_connection, 
59   | 		     const char *query, SQ_result_set_t **result_ptr);
60   | int SQ_execute_query_nostore(SQ_connection_t *sql_connection,
61   |                              const char *query, SQ_result_set_t **result_ptr);
62   | int SQ_get_column_count(SQ_result_set_t *result);
63   | char *SQ_get_column_label(SQ_result_set_t *result, unsigned int column);
64   | unsigned int SQ_get_column_max_length(SQ_result_set_t *result, unsigned int column);
65   | SQ_row_t *SQ_row_next(SQ_result_set_t *result);
66   | char *SQ_get_column_string(SQ_result_set_t *result, SQ_row_t *current_row, unsigned int column);
67   | char *SQ_get_column_string_nocopy(SQ_result_set_t *result, 
68   | 				  SQ_row_t *current_row, 
69   | 				  unsigned int column);
70   | char *SQ_get_column_strings(SQ_result_set_t *result, unsigned int column);
71   | int SQ_get_column_int(SQ_result_set_t *result, SQ_row_t *current_row, unsigned int column, long  *resultptr);
72   | char *SQ_result_to_string(SQ_result_set_t *result);
73   | void SQ_free_result(SQ_result_set_t *result);
74   | void SQ_close_connection(SQ_connection_t *sql_connection);
75   | 
76   | /* report number of rows */
77   | int SQ_num_rows(SQ_result_set_t *result);
78   | int SQ_get_table_size(SQ_connection_t *sql_connection, char *table);
79   | int SQ_get_affected_rows(SQ_connection_t *sql_connection);
80   | long SQ_get_insert_id(SQ_connection_t *sql_connection);
81   | 
82   | 
83   | char *SQ_info_to_string(SQ_connection_t *sql_connection);
84   | char *SQ_error(SQ_connection_t *sql_connection);
85   | int SQ_errno(SQ_connection_t *sql_connection);
86   | int SQ_get_info(SQ_connection_t *sql_connection, int info[3]);
87   | SQ_connection_t *SQ_duplicate_connection(SQ_connection_t *orig);
88   | int SQ_abort_query(SQ_connection_t *sql_connection);
89   | int SQ_ping(SQ_connection_t *sql_connection);
90   | char *SQ_escape_string(SQ_connection_t *sql_connection, char *str);
91   | 
92   | long sq_get_minmax_id(SQ_connection_t *sql_connection, char *id_name, char *table, int max);
93   | #define SQ_get_max_id(conn, id, table) sq_get_minmax_id(conn, id, table, 1)
94   | #define SQ_get_min_id(conn, id, table) sq_get_minmax_id(conn, id, table, 0)
95   | 
96   | 
97   | 
98   | #ifdef __cplusplus
99   | }
100  | #endif
101  | 
102  | 
103  | #endif /* READ_MYSQL_DRIVER */