Release 0.41.92
[vala-gnome.git] / vapi / mysql.vapi
blob745bbd42f3ff45068a8f8340c30dcf3b5d92a645
1 /* mysql.vala
2  *
3  * Copyright (C) 2008, 2010 Jukka-Pekka Iivonen
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
18  *
19  * Author:
20  *      Jukka-Pekka Iivonen <jp0409@jippii.fi>
21  */
23 [CCode (lower_case_cprefix = "mysql_", cheader_filename = "mysql/mysql.h")]
24 namespace Mysql {
25         [CCode (cname = "unsigned long", cprefix = "CLIENT_", has_type_id = false)]
26         public enum ClientFlag {
27                 LONG_PASSWORD,
28                 FOUND_ROWS,
29                 LONG_FLAG,
30                 CONNECT_WITH_DB,
31                 NO_SCHEMA,
32                 COMPRESS,
33                 ODBC,
34                 LOCAL_FILES,
35                 IGNORE_SPACE,
36                 PROTOCOL_41,
37                 INTERACTIVE,
38                 SSL,
39                 IGNORE_SIGPIPE,
40                 TRANSACTIONS,
41                 RESERVED,
42                 SECURE_CONNECTION,
43                 MULTI_STATEMENTS,
44                 MULTI_RESULTS,
45                 SSL_VERIFY_SERVER_CERT,
46                 REMEMBER_OPTIONS
47         }
49         [CCode (cname = "enum_mysql_set_option", cprefix = "MYSQL_OPTION_", has_type_id = false)]
50         public enum SetOption {
51                 MULTI_STATEMENTS_ON,
52                 MULTI_STATEMENTS_OFF
53         }
55         [CCode (cname = "mysql_option", cprefix = "MYSQL_", has_type_id = false)]
56         public enum Option {
57                 OPT_CONNECT_TIMEOUT,
58                 OPT_COMPRESS,
59                 OPT_NAMED_PIPE,
60                 INIT_COMMAND,
61                 READ_DEFAULT_FILE,
62                 READ_DEFAULT_GROUP,
63                 SET_CHARSET_DIR,
64                 SET_CHARSET_NAME,
65                 OPT_LOCAL_INFILE,
66                 OPT_PROTOCOL,
67                 SHARED_MEMORY_BASE_NAME,
68                 OPT_READ_TIMEOUT,
69                 OPT_WRITE_TIMEOUT,
70                 OPT_USE_RESULT,
71                 OPT_USE_REMOTE_CONNECTION,
72                 OPT_USE_EMBEDDED_CONNECTION,
73                 OPT_GUESS_CONNECTION,
74                 SET_CLIENT_IP,
75                 SECURE_AUTH,
76                 REPORT_DATA_TRUNCATION,
77                 OPT_RECONNECT,
78                 OPT_SSL_VERIFY_SERVER_CERT
79         }
81         [CCode (cname = "enum enum_field_types", cprefix = "MYSQL_TYPE_", has_type_id = false)]
82         public enum FieldType {
83                 DECIMAL,
84                 TINY,
85                 SHORT,
86                 LONG,
87                 FLOAT,
88                 DOUBLE,
89                 NULL,
90                 TIMESTAMP,
91                 LONGLONG,
92                 INT24,
93                 DATE,
94                 TIME,
95                 DATETIME,
96                 YEAR,
97                 NEWDATE,
98                 VARCHAR,
99                 BIT,
100                 NEWDECIMAL,
101                 ENUM,
102                 SET,
103                 TINY_BLOB,
104                 MEDIUM_BLOB,
105                 LONG_BLOB,
106                 BLOB,
107                 VAR_STRING,
108                 STRING,
109                 GEOMETRY
110         }
112         [CCode (cname = "guint", has_type_id = false)]
113         public enum FieldFlag {
114                 [CCode (cname = "NOT_NULL_FLAG")]
115                 NOT_NULL,
116                 [CCode (cname = "PRI_KEY_FLAG")]
117                 PRI_KEY,
118                 [CCode (cname = "UNIQUE_FLAG")]
119                 UNIQUE_KEY,
120                 [CCode (cname = "MULTIPLE_KEY_FLAG")]
121                 MULTIPLE_KEY,
122                 [CCode (cname = "BLOB_FLAG")]
123                 BLOB,
124                 [CCode (cname = "UNSIGNED_FLAG")]
125                 UNSIGNED,
126                 [CCode (cname = "ZEROFILL_FLAG")]
127                 ZEROFILL,
128                 [CCode (cname = "BINARY_FLAG")]
129                 BINARY,
130                 [CCode (cname = "ENUM_FLAG")]
131                 ENUM,
132                 [CCode (cname = "AUTO_INCREMENT_FLAG")]
133                 AUTO_INCREMENT,
134                 [CCode (cname = "TIMESTAMP_FLAG")]
135                 TIMESTAMP,
136                 [CCode (cname = "SET_FLAG")]
137                 SET,
138                 [CCode (cname = "NO_DEFAULT_VALUE_FLAG")]
139                 NO_DEFAULT_VALUE,
140                 [CCode (cname = "ON_UPDATE_NOW_FLAG")]
141                 ON_UPDATE_NOW,
142                 [CCode (cname = "NUM_FLAG")]
143                 NUM,
144                 [CCode (cname = "PART_KEY_FLAG")]
145                 PART_KEY,
146                 [CCode (cname = "GROUP_FLAG")]
147                 GROUP,
148                 [CCode (cname = "UNIQUE_FLAG")]
149                 UNIQUE,
150                 [CCode (cname = "BINCMP_FLAG")]
151                 BINCMP,
152                 [CCode (cname = "GET_FIXED_FIELDS_FLAG")]
153                 GET_FIXED_FIELDS,
154                 [CCode (cname = "FIELD_IN_PART_FUNC_FLAG")]
155                 FIELD_IN_PART_FUNC,
156                 [CCode (cname = "FIELD_IN_ADD_INDEX")]
157                 FIELD_IN_ADD_INDEX,
158                 [CCode (cname = "FIELD_IS_RENAMED")]
159                 FIELD_IS_RENAMED
160         }
162         [CCode (cname = "enum_cursor_type", cprefix = "CURSOR_TYPE_", has_type_id = false)]
163         public enum CursorType {
164                 NO_CURSOR,
165                 READ_ONLY,
166                 FOR_UPDATE,
167                 SCROLLABLE
168         }
170         [Compact]
171         [CCode (free_function = "mysql_close", cname = "MYSQL", cprefix = "mysql_")]
172         public class Database {
173                 [CCode (cname = "mysql_init")]
174                 public Database (Database? mysql = null);
176                 public ulong affected_rows ();
177                 public bool autocommit (bool mode);
178                 public bool change_user (string username, string passwd, string? dbname = null);
179                 public unowned string character_set_name ();
180                 public bool commit ();
181                 public int dump_debug_info ();
182                 public uint errno ();
183                 public unowned string error ();
184                 public unowned string get_host_info ();
185                 public uint get_proto_info ();
186                 public unowned string get_server_info ();
187                 public ulong get_server_version ();
188                 public unowned string get_ssl_cipher ();
189                 public unowned string info ();
190                 public ulong insert_id ();
191                 public int kill (ulong pid);
192                 public Result? list_dbs (string? wild = null);
193                 public Result? list_fields (string table, string? wild = null);
194                 public Result? list_processes ();
195                 public Result? list_tables (string? wild = null);
196                 public bool more_results ();
197                 public int next_result ();
198                 public int options (Option option, string arg);
199                 public int ping ();
200                 public int query (string stmt_str);
201                 public bool real_connect (string? host = null, string? username = null, string? passwd = null, string? dbname = null, uint port = 0, string? unix_socket = null, ClientFlag client_flag = 0);
202                 public ulong real_escape_string (string to, string from, ulong length);
203                 public int real_query (string query, ulong len);
204                 public int reload ();
205                 public bool rollback ();
206                 public int select_db (string dbname);
207                 public int set_character_set (string csname);
208                 public void set_local_infile_default ();
209                 public int set_server_option (SetOption option);
210                 public unowned string sqlstate ();
211                 public int shutdown (int shutdown_level);
212                 public bool ssl_set (string key, string cert, string ca, string capath, string cipher);
213                 public unowned string stat ();
214                 public Result? store_result ();
215                 public ulong thread_id ();
216                 public Result? use_result ();
217                 public uint warning_count ();
218         }
220         [Compact]
221         [CCode (free_function = "mysql_free_result", cname = "MYSQL_RES", cprefix = "mysql_")]
222         public class Result {
223                 public bool eof ();
224                 public Field* fetch_field ();
225                 public Field* fetch_field_direct (uint field_nbr);
227                 [CCode (cname = "mysql_fetch_fields", array_length = false)]
228                 public unowned Field[] _fetch_fields ();
229                 [CCode (cname = "_vala_mysql_fetch_fields")]
230                 public unowned Field[] fetch_fields () {
231                         unowned Field[] fields = this._fetch_fields ();
232                         fields.length = (int) this.num_fields ();
233                         return fields;
234                 }
236                 [CCode (cname = "mysql_fetch_lengths", array_length = false)]
237                 public unowned ulong[] _fetch_lengths ();
238                 [CCode (cname = "_vala_mysql_fetch_lengths")]
239                 public unowned ulong[] fetch_lengths () {
240                         unowned ulong[] lengths = this._fetch_lengths ();
241                         lengths.length = (int) this.num_fields ();
242                         return lengths;
243                 }
245                 [CCode (cname = "mysql_fetch_row", array_length = false)]
246                 public unowned string[]? _fetch_row ();
247                 [CCode (cname = "_vala_mysql_fetch_row")]
248                 public unowned string[]? fetch_row () {
249                         unowned string[]? row = this._fetch_row ();
250                         row.length = (int) this.num_fields ();
251                         return row;
252                 }
254                 public uint fetch_count ();
255                 public uint num_fields ();
256                 public uint num_rows ();
258                 public bool data_seek (ulong offset);
259         }
260         [CCode (cname = "MYSQL_FIELD", has_type_id = false)]
261         public struct Field {
262                 public unowned string name;
263                 public unowned string org_name;
264                 public unowned string table;
265                 public unowned string org_table;
266                 public unowned string db;
267                 public unowned string catalog;
268                 public unowned string def;
269                 public ulong length;
270                 public ulong max_length;
271                 public uint name_length;
272                 public uint org_name_length;
273                 public uint table_length;
274                 public uint org_table_length;
275                 public uint db_length;
276                 public uint catalog_length;
277                 public uint def_length;
278                 public uint flags;
279                 public uint decimals;
280                 public uint charsetnr;
281                 public FieldType type;
282                 public void *extension;
283         }
285         public unowned string get_client_info ();
286         public ulong get_client_version ();
287         public void debug (string msg);
288         public ulong hex_string (string to, string from, ulong length);
289         public void library_end ();
290         public int library_init ([CCode (array_length_pos = 0.1)] string[] argv, [CCode (array_length = false, array_null_terminated = true)] string[]? groups = null);
291         public void server_end ();
292         public int server_init ([CCode (array_length_pos = 0.1)] string[] argv, [CCode (array_length = false, array_null_terminated = true)] string[]? groups = null);
293         public void thread_end ();
294         public bool thread_init ();
295         public uint thread_safe ();