Added to the repository
Showing
2 changed files
with
143 additions
and
0 deletions
include/mailutils/sql.h
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2004 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 2 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General Public | ||
15 | License along with this library; if not, write to the Free Software | ||
16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
17 | |||
18 | #ifndef _MAILUTILS_SQL_H | ||
19 | #define _MAILUTILS_SQL_H | ||
20 | |||
21 | /* Loadable Modules Suppert */ | ||
22 | #define __s_cat2__(a,b) a ## b | ||
23 | #define __s_cat3__(a,b,c) a ## b ## c | ||
24 | #define RDL_EXPORT(module,name) __s_cat3__(module,_LTX_,name) | ||
25 | |||
26 | typedef int (*rdl_init_t) (void); | ||
27 | typedef void (*rdl_done_t) (void); | ||
28 | |||
29 | #ifdef _HAVE_LIBLTDL //FIXME: Remove leading _ when SQL + ltdl works | ||
30 | # define MU_DECL_SQL_DISPATCH_T(mod) \ | ||
31 | mu_sql_dispatch_t RDL_EXPORT(mod,dispatch_tab) | ||
32 | #else | ||
33 | # define MU_DECL_SQL_DISPATCH_T(mod) \ | ||
34 | mu_sql_dispatch_t __s_cat2__(mod,_dispatch_tab) | ||
35 | #endif | ||
36 | |||
37 | enum mu_sql_connection_state { | ||
38 | mu_sql_not_connected, | ||
39 | mu_sql_connected, | ||
40 | mu_sql_query_run, | ||
41 | mu_sql_result_available | ||
42 | }; | ||
43 | |||
44 | typedef struct mu_sql_connection *mu_sql_connection_t; | ||
45 | |||
46 | struct mu_sql_connection | ||
47 | { | ||
48 | int interface; | ||
49 | char *server; | ||
50 | int port; | ||
51 | char *login; | ||
52 | char *password; | ||
53 | char *dbname; | ||
54 | void *data; | ||
55 | enum mu_sql_connection_state state; | ||
56 | }; | ||
57 | |||
58 | typedef struct mu_sql_dispatch mu_sql_dispatch_t; | ||
59 | |||
60 | struct mu_sql_dispatch | ||
61 | { | ||
62 | char *name; | ||
63 | int port; | ||
64 | |||
65 | int (*init) (mu_sql_connection_t conn); | ||
66 | int (*destroy) (mu_sql_connection_t conn); | ||
67 | |||
68 | int (*connect) (mu_sql_connection_t conn); | ||
69 | int (*disconnect) (mu_sql_connection_t conn); | ||
70 | |||
71 | int (*query) (mu_sql_connection_t conn, char *query); | ||
72 | int (*store_result) (mu_sql_connection_t conn); | ||
73 | int (*release_result) (mu_sql_connection_t conn); | ||
74 | |||
75 | int (*num_tuples) (mu_sql_connection_t conn, size_t *np); | ||
76 | int (*num_columns) (mu_sql_connection_t conn, size_t *np); | ||
77 | |||
78 | int (*get_column) (mu_sql_connection_t conn, size_t nrow, size_t ncol, | ||
79 | char **pdata); | ||
80 | |||
81 | char *(*errstr) (mu_sql_connection_t conn); | ||
82 | }; | ||
83 | |||
84 | /* Public interfaces */ | ||
85 | int mu_sql_interface_index (char *name); | ||
86 | |||
87 | int mu_sql_connection_init (mu_sql_connection_t *conn, int interface, | ||
88 | char *server, int port, char *login, | ||
89 | char *password, char *dbname); | ||
90 | int mu_sql_connection_destroy (mu_sql_connection_t *conn); | ||
91 | |||
92 | int mu_sql_connect (mu_sql_connection_t conn); | ||
93 | int mu_sql_disconnect (mu_sql_connection_t conn); | ||
94 | |||
95 | int mu_sql_query (mu_sql_connection_t conn, char *query); | ||
96 | |||
97 | int mu_sql_store_result (mu_sql_connection_t conn); | ||
98 | int mu_sql_release_result (mu_sql_connection_t conn); | ||
99 | |||
100 | int mu_sql_num_tuples (mu_sql_connection_t conn, size_t *np); | ||
101 | int mu_sql_num_columns (mu_sql_connection_t conn, size_t *np); | ||
102 | |||
103 | int mu_sql_get_column (mu_sql_connection_t conn, size_t nrow, size_t ncol, | ||
104 | char **pdata); | ||
105 | |||
106 | char *mu_sql_strerror (mu_sql_connection_t conn); | ||
107 | |||
108 | #endif |
scripts/sqlmod.sh
0 → 100755
1 | #! /bin/sh | ||
2 | # This file is part of GNU Mailutils | ||
3 | # Copyright (C) 2004 Free Software Foundation, Inc. | ||
4 | # | ||
5 | # Written by Sergey Poznyakoff | ||
6 | # | ||
7 | # This file is free software; as a special exception the author gives | ||
8 | # unlimited permission to copy and/or distribute it, with or without | ||
9 | # modifications, as long as this notice is preserved. | ||
10 | # | ||
11 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
12 | # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the | ||
13 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
14 | |||
15 | cat - <<EOT | ||
16 | /* This file is generated automatically. Please do not edit */ | ||
17 | EOT | ||
18 | |||
19 | for module | ||
20 | do | ||
21 | echo "extern mu_sql_dispatch_t ${module}_dispatch_tab;" | ||
22 | done | ||
23 | |||
24 | cat - <<EOT | ||
25 | static mu_sql_dispatch_t *static_dispatch_tab[] = { | ||
26 | NULL, | ||
27 | EOT | ||
28 | |||
29 | for module | ||
30 | do | ||
31 | echo " &${module}_dispatch_tab," | ||
32 | done | ||
33 | |||
34 | echo "};" | ||
35 | echo '/* EOF */' |
-
Please register or sign in to post a comment