aboutsummaryrefslogtreecommitdiff
path: root/src/mysql.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-12-26 21:54:07 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-12-26 21:54:07 +0000
commitf60b650e9acd449b142c37e4fcc55390c62f4832 (patch)
tree3f3e026b1db43a9344fb65e6a83d7534b7434ff0 /src/mysql.c
parent06e6d0bcfcd33203091a817e4423fdd12e1bcd68 (diff)
downloadgamma-f60b650e9acd449b142c37e4fcc55390c62f4832.tar.gz
gamma-f60b650e9acd449b142c37e4fcc55390c62f4832.tar.bz2
* NEWS: Update.
* configure.ac: Version number 1.1 * COPYING: GPLv3. * Makefile.am: GPLv3. * examples/whoisd.scm: GPLv3. * m4/guile.m4: Require Guile v. 1.8 or later. * scripts/Makefile.am: GPLv3. * scripts/guile-doc-snarf.awk: GPLv3. * src/.cvsignore (gettext.inc, gettext.scm): Remove. * src/Makefile.am: Remove libguile-gettext. * src/app.h: GPLv3. * src/gsql_conn.c, src/gsql_lib.c, src/guile-sql.h, src/mysql.c, src/pgsql.c: GPLv3; Guile v.>=1.8. * src/gettext.sci, src/gettext.h, src/gettext.c: Remove. * src/gettext.scm: New file.
Diffstat (limited to 'src/mysql.c')
-rw-r--r--src/mysql.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/src/mysql.c b/src/mysql.c
index d788a92..ac7e0f7 100644
--- a/src/mysql.c
+++ b/src/mysql.c
@@ -1,19 +1,18 @@
1/* This file is part of guile-sql. 1/* This file is part of guile-sql.
2 Copyright (C) 2002, 2004, 2005 Sergey Poznyakoff 2 Copyright (C) 2002, 2004, 2005 Sergey Poznyakoff
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify it
5 it under the terms of the GNU General Public License as published by 5 under the terms of the GNU General Public License as published by the
6 the Free Software Foundation; either version 2 of the License, or 6 Free Software Foundation; either version 3 of the License, or (at your
7 (at your option) any later version. 7 option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License along
15 along with this program; if not, write to the Free Software Foundation, Inc., 15 with this program. If not, see <http://www.gnu.org/licenses/>. */
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
17 16
18#ifdef HAVE_CONFIG_H 17#ifdef HAVE_CONFIG_H
19# include <config.h> 18# include <config.h>
@@ -22,13 +21,13 @@
22#include <guile-sql.h> 21#include <guile-sql.h>
23#include <mysql/mysql.h> 22#include <mysql/mysql.h>
24 23
25SCM 24static SCM
26s_mysql_mark(struct sql_connect *conn) 25s_mysql_mark(struct sql_connect *conn)
27{ 26{
28 return SCM_BOOL_F; 27 return SCM_BOOL_F;
29} 28}
30 29
31scm_sizet 30static scm_sizet
32s_mysql_free(struct sql_connect *conn) 31s_mysql_free(struct sql_connect *conn)
33{ 32{
34 MYSQL *mysql = (MYSQL*) conn->data; 33 MYSQL *mysql = (MYSQL*) conn->data;
@@ -38,14 +37,15 @@ s_mysql_free(struct sql_connect *conn)
38 return sizeof(MYSQL); 37 return sizeof(MYSQL);
39} 38}
40 39
41SCM 40static SCM
42s_mysql_connect (char *hostname, int port, 41s_mysql_connect (const char *hostname, int port,
43 char *dbname, char *user, char *pass, const char *why) 42 const char *dbname, const char *user, const char *pass,
43 const char *why)
44{ 44{
45 MYSQL *mysql; 45 MYSQL *mysql;
46 SCM smob; 46 SCM smob;
47 struct sql_connect *conn; 47 struct sql_connect *conn;
48 char *socket_path = NULL; 48 const char *socket_path = NULL;
49 49
50 mysql = mysql_init(NULL); 50 mysql = mysql_init(NULL);
51 if (!mysql) 51 if (!mysql)
@@ -72,8 +72,8 @@ s_mysql_connect (char *hostname, int port,
72 return smob; 72 return smob;
73} 73}
74 74
75SCM 75static SCM
76s_mysql_query(struct sql_connect *conn, char *query) 76s_mysql_query(struct sql_connect *conn, const char *query)
77{ 77{
78 MYSQL *mysql = conn->data; 78 MYSQL *mysql = conn->data;
79 MYSQL_RES *result; 79 MYSQL_RES *result;
@@ -99,9 +99,8 @@ s_mysql_query(struct sql_connect *conn, char *query)
99 if (!row) 99 if (!row)
100 break; 100 break;
101 for (j = 0; j < nfields; j++) { 101 for (j = 0; j < nfields; j++) {
102 SCM new_elt; 102 SCM new_elt = scm_cons(scm_makfrom0str(row[j]),
103 SCM_NEWCELL(new_elt); 103 SCM_EOL);
104 SCM_SETCAR(new_elt, scm_makfrom0str(row[j]));
105 if (head == SCM_EOL) 104 if (head == SCM_EOL)
106 head = new_elt; 105 head = new_elt;
107 else 106 else
@@ -109,20 +108,13 @@ s_mysql_query(struct sql_connect *conn, char *query)
109 tail = new_elt; 108 tail = new_elt;
110 } 109 }
111 110
112 if (head != SCM_EOL) 111 new_row = scm_cons(head, SCM_EOL);
113 SCM_SETCDR(tail, SCM_EOL);
114
115 SCM_NEWCELL(new_row);
116 SCM_SETCAR(new_row, head);
117
118 if (row_head == SCM_EOL) 112 if (row_head == SCM_EOL)
119 row_head = new_row; 113 row_head = new_row;
120 else 114 else
121 SCM_SETCDR(row_tail, new_row); 115 SCM_SETCDR(row_tail, new_row);
122 row_tail = new_row; 116 row_tail = new_row;
123 } 117 }
124 if (row_head != SCM_EOL)
125 SCM_SETCDR(row_tail, SCM_EOL);
126 cell = row_head; 118 cell = row_head;
127 mysql_free_result(result); 119 mysql_free_result(result);
128 } else { /* should it have returned something? */ 120 } else { /* should it have returned something? */
@@ -137,7 +129,7 @@ s_mysql_query(struct sql_connect *conn, char *query)
137 return cell; 129 return cell;
138} 130}
139 131
140void 132static void
141s_mysql_close(struct sql_connect *conn) 133s_mysql_close(struct sql_connect *conn)
142{ 134{
143 if (conn->data) 135 if (conn->data)

Return to:

Send suggestions and report system problems to the System administrator.