Initial commit of newLISP.
[newlisp.git] / util / sql.c
blob6907d7881dbf0d45245780699d531f8cdea728c1
1 /*
2 sql.c - find offsets of important data fields in MySQL data structures
4 version 1.1, (c) Lutz Mueller 2004, released under the GNU GPL License
5 version 1.2 added 2 more include files for 4.0
7 compile using: gcc sql.c -o sql
9 then do: ./sql
10 to obtain a list of offsets in MySQL data structures
12 this program is only needed when designing new MySQL support functions
13 in newLISP and the MySQL data structures have to be accessed directly
15 the values produced by this program are used in the file mysql.lsp.
17 See also /usr/share/newlisp/mysql.lsp
22 #define LINUX
23 /* #define MACOSX */
25 #include <stdio.h>
26 #include <unistd.h>
27 #include <stdlib.h>
29 #ifdef MACOSX
30 #include "/usr/local/mysql/include/mysql.h"
31 #include "/usr/local/mysql/include/mysql_com.h"
32 #include "/usr/local/mysql/include/mysql_version.h"
33 #include "/usr/local/mysql/include/my_alloc.h"
34 #endif
36 #ifdef LINUX
37 #include "/usr/include/mysql/mysql.h"
38 #include "/usr/include/mysql/mysql_com.h"
39 #include "/usr/include/mysql/mysql_version.h"
40 #include "/usr/include/mysql/my_alloc.h"
41 #endif
43 MYSQL * mysql;
44 MYSQL_RES * mysql_res;
47 int main(int argc, char ** argv)
49 printf("sizeof(MYSQL) %d\n", sizeof(MYSQL));
50 printf("sizeof(MYSQL_RES) %d\n", sizeof(MYSQL_RES));
51 printf("sizeof(MYSQL_ROW) %d\n", sizeof(MYSQL_ROW));
52 printf("sizeof(MYSQL_FIELD) %d\n", sizeof(MYSQL_FIELD));
53 printf("sizeof(NET) %d\n", sizeof(NET));
54 printf("sizeof(my_ulonglong) %d\n", sizeof(my_ulonglong));
55 printf("sizeof(my_bool) %d\n\n", sizeof(my_bool));
57 mysql = 0;
58 mysql_res = 0;
60 printf("offset mysql->affected_rows: %d\n", &mysql->affected_rows);
61 printf("offset mysql->insert_id: %d\n", &mysql->insert_id);
62 printf("offset mysql->net.last_error: %d\n", &mysql->net.last_error);
64 printf("offset mysql_res->row_count: %d\n", &mysql_res->row_count);
65 printf("offset mysql_res->field_count: %d\n", &mysql_res->field_count);
66 printf("offset mysql_res->eof: %d\n", &mysql_res->eof);
69 return 0;
72 /* eof */