diff options
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/gamma-expat.c | 10 | ||||
-rw-r--r-- | src/gsql_conn.c | 30 | ||||
-rw-r--r-- | src/guile-sql.h | 2 | ||||
-rw-r--r-- | src/mysql.c | 19 | ||||
-rw-r--r-- | src/pgsql.c | 27 | ||||
-rw-r--r-- | src/syslog-port.c | 124 |
7 files changed, 60 insertions, 154 deletions
diff --git a/configure.ac b/configure.ac index 15aeb87..0695551 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -36,3 +36,3 @@ AM_PROG_LIBTOOL | |||
36 | 36 | ||
37 | GINT_INIT(gint,[1.8]) | 37 | GINT_INIT(gint,[2.2.0]) |
38 | 38 | ||
diff --git a/src/gamma-expat.c b/src/gamma-expat.c index a81d30e..cd3efaa 100644 --- a/src/gamma-expat.c +++ b/src/gamma-expat.c | |||
@@ -34,3 +34,3 @@ gamma_xml_parser_create(XML_Parser parser) | |||
34 | 34 | ||
35 | gp = scm_malloc(sizeof (*gp)); | 35 | gp = scm_gc_malloc(sizeof (*gp), "xml_parser"); |
36 | gp->parser = parser; | 36 | gp->parser = parser; |
@@ -42,3 +42,3 @@ gamma_xml_parser_create(XML_Parser parser) | |||
42 | 42 | ||
43 | static scm_sizet | 43 | static size_t |
44 | gamma_xml_parser_free(SCM smob) | 44 | gamma_xml_parser_free(SCM smob) |
@@ -86,3 +86,3 @@ gamma_xml_parser_print(SCM smob, SCM port, scm_print_state *pstate) | |||
86 | static void | 86 | static void |
87 | gamma_xml_parser_init() | 87 | gamma_xml_parser_init(void) |
88 | { | 88 | { |
@@ -98,3 +98,3 @@ gamma_xml_parser_init() | |||
98 | static struct gamma_expat_user_data * | 98 | static struct gamma_expat_user_data * |
99 | make_user_data () | 99 | make_user_data(void) |
100 | { | 100 | { |
@@ -155,3 +155,3 @@ SCM_DEFINE_PUBLIC(scm_xml_primitive_make_parser, "xml-primitive-make-parser", | |||
155 | if (!parser) | 155 | if (!parser) |
156 | scm_memory_error(FUNC_NAME); | 156 | scm_report_out_of_memory(); |
157 | XML_SetUserData(parser, make_user_data()); | 157 | XML_SetUserData(parser, make_user_data()); |
diff --git a/src/gsql_conn.c b/src/gsql_conn.c index 4d53a03..64cec27 100644 --- a/src/gsql_conn.c +++ b/src/gsql_conn.c | |||
@@ -33,14 +33,14 @@ static long sql_connect_tag = -1; | |||
33 | static SCM | 33 | static SCM |
34 | sql_connect_mark (SCM connect_smob) | 34 | sql_connect_mark(SCM connect_smob) |
35 | { | 35 | { |
36 | struct sql_connect *conn = (struct sql_connect *)SCM_CDR(connect_smob); | 36 | struct sql_connect *conn = (struct sql_connect *)SCM_CDR(connect_smob); |
37 | return sql_iftab[conn->iface].mark(conn); | 37 | if (sql_iftab[conn->iface].mark) |
38 | return sql_iftab[conn->iface].mark(conn); | ||
38 | } | 39 | } |
39 | 40 | ||
40 | static scm_sizet | 41 | static size_t |
41 | sql_connect_free (SCM connect_smob) | 42 | sql_connect_free(SCM connect_smob) |
42 | { | 43 | { |
43 | scm_sizet size = sizeof(struct sql_connect); | ||
44 | struct sql_connect *conn = (struct sql_connect *)SCM_CDR(connect_smob); | 44 | struct sql_connect *conn = (struct sql_connect *)SCM_CDR(connect_smob); |
45 | size += sql_iftab[conn->iface].free(conn); | 45 | sql_iftab[conn->iface].free(conn); |
46 | if (conn->hostname) | 46 | if (conn->hostname) |
@@ -52,3 +52,3 @@ sql_connect_free (SCM connect_smob) | |||
52 | scm_gc_free(conn, sizeof *conn, "SQL connection"); | 52 | scm_gc_free(conn, sizeof *conn, "SQL connection"); |
53 | return size; | 53 | return 0; |
54 | } | 54 | } |
@@ -90,3 +90,3 @@ sql_find_iface(const char *name) | |||
90 | SCM | 90 | SCM |
91 | sql_connect_create (char *name) | 91 | sql_connect_create(char *name) |
92 | { | 92 | { |
@@ -99,6 +99,6 @@ sql_connect_create (char *name) | |||
99 | 99 | ||
100 | conn = scm_gc_malloc (sizeof (*conn), "sql_connect"); | 100 | conn = scm_gc_malloc(sizeof (*conn), "sql_connect"); |
101 | memset(conn, 0, sizeof *conn); | 101 | memset(conn, 0, sizeof *conn); |
102 | conn->iface = iface; | 102 | conn->iface = iface; |
103 | SCM_RETURN_NEWSMOB (sql_connect_tag, conn); | 103 | SCM_RETURN_NEWSMOB(sql_connect_tag, conn); |
104 | } | 104 | } |
@@ -106,5 +106,5 @@ sql_connect_create (char *name) | |||
106 | static int | 106 | static int |
107 | scm_is_sql_connect (SCM scm) | 107 | scm_is_sql_connect(SCM scm) |
108 | { | 108 | { |
109 | return SCM_NIMP (scm) && SCM_CAR (scm) == (SCM) sql_connect_tag; | 109 | return SCM_NIMP(scm) && SCM_CAR (scm) == (SCM) sql_connect_tag; |
110 | } | 110 | } |
@@ -136,3 +136,3 @@ gamma_cvt_iface(SCM inval, void *outval, const char *func_name) | |||
136 | 136 | ||
137 | SCM_DEFINE_PUBLIC (sql_open_connection, "sql-open-connection", 1, 0, 0, | 137 | SCM_DEFINE_PUBLIC(sql_open_connection, "sql-open-connection", 1, 0, 0, |
138 | (SCM param), | 138 | (SCM param), |
@@ -187,3 +187,3 @@ SCM_DEFINE_PUBLIC (sql_open_connection, "sql-open-connection", 1, 0, 0, | |||
187 | 187 | ||
188 | SCM_DEFINE_PUBLIC (sql_close_connection, "sql-close-connection", 1, 0, 0, | 188 | SCM_DEFINE_PUBLIC(sql_close_connection, "sql-close-connection", 1, 0, 0, |
189 | (SCM conn), | 189 | (SCM conn), |
@@ -200,3 +200,3 @@ SCM_DEFINE_PUBLIC (sql_close_connection, "sql-close-connection", 1, 0, 0, | |||
200 | 200 | ||
201 | SCM_DEFINE_PUBLIC (sql_query, "sql-query", 2, 0, 0, | 201 | SCM_DEFINE_PUBLIC(sql_query, "sql-query", 2, 0, 0, |
202 | (SCM conn, SCM query), | 202 | (SCM conn, SCM query), |
diff --git a/src/guile-sql.h b/src/guile-sql.h index 926aa74..f656fd4 100644 --- a/src/guile-sql.h +++ b/src/guile-sql.h | |||
@@ -41,3 +41,3 @@ struct sql_iface { | |||
41 | SCM (*mark) (struct sql_connect *); | 41 | SCM (*mark) (struct sql_connect *); |
42 | scm_sizet (*free) (struct sql_connect *); | 42 | size_t (*free) (struct sql_connect *); |
43 | SCM (*connect) (SCM parmlist, const char *func_name); | 43 | SCM (*connect) (SCM parmlist, const char *func_name); |
diff --git a/src/mysql.c b/src/mysql.c index 1310212..dcc1847 100644 --- a/src/mysql.c +++ b/src/mysql.c | |||
@@ -23,9 +23,3 @@ | |||
23 | 23 | ||
24 | static SCM | 24 | static size_t |
25 | s_mysql_mark(struct sql_connect *conn) | ||
26 | { | ||
27 | return SCM_BOOL_F; | ||
28 | } | ||
29 | |||
30 | static scm_sizet | ||
31 | s_mysql_free(struct sql_connect *conn) | 25 | s_mysql_free(struct sql_connect *conn) |
@@ -33,6 +27,5 @@ s_mysql_free(struct sql_connect *conn) | |||
33 | MYSQL *mysql = (MYSQL*) conn->data; | 27 | MYSQL *mysql = (MYSQL*) conn->data; |
34 | if (!mysql) | 28 | if (mysql) |
35 | return 0; | 29 | mysql_close(mysql); |
36 | mysql_close(mysql); | 30 | return 0; |
37 | return sizeof(MYSQL); | ||
38 | } | 31 | } |
@@ -40,3 +33,3 @@ s_mysql_free(struct sql_connect *conn) | |||
40 | static SCM | 33 | static SCM |
41 | s_mysql_connect (SCM parmlist, const char *func_name) | 34 | s_mysql_connect(SCM parmlist, const char *func_name) |
42 | { | 35 | { |
@@ -227,3 +220,3 @@ struct sql_iface mysql_iface = { | |||
227 | "mysql", | 220 | "mysql", |
228 | s_mysql_mark, | 221 | NULL, /* mark */ |
229 | s_mysql_free, | 222 | s_mysql_free, |
diff --git a/src/pgsql.c b/src/pgsql.c index c5cf51e..1421c40 100644 --- a/src/pgsql.c +++ b/src/pgsql.c | |||
@@ -23,9 +23,3 @@ | |||
23 | 23 | ||
24 | static SCM | 24 | static size_t |
25 | s_pgsql_mark(struct sql_connect *conn) | ||
26 | { | ||
27 | return SCM_BOOL_F; | ||
28 | } | ||
29 | |||
30 | static scm_sizet | ||
31 | s_pgsql_free(struct sql_connect *conn) | 25 | s_pgsql_free(struct sql_connect *conn) |
@@ -33,6 +27,5 @@ s_pgsql_free(struct sql_connect *conn) | |||
33 | PGconn *pgconn = (PGconn*) conn->data; | 27 | PGconn *pgconn = (PGconn*) conn->data; |
34 | if (!pgconn) | 28 | if (pgconn) |
35 | return 0; | 29 | PQfinish(pgconn); |
36 | PQfinish(pgconn); | 30 | return 0; |
37 | return sizeof(pgconn); | ||
38 | } | 31 | } |
@@ -40,3 +33,3 @@ s_pgsql_free(struct sql_connect *conn) | |||
40 | static SCM | 33 | static SCM |
41 | s_pgsql_connect (SCM parmlist, const char *func_name) | 34 | s_pgsql_connect(SCM parmlist, const char *func_name) |
42 | { | 35 | { |
@@ -170,6 +163,6 @@ s_pgsql_close(struct sql_connect *conn) | |||
170 | PGconn *pgconn = (PGconn*) conn->data; | 163 | PGconn *pgconn = (PGconn*) conn->data; |
171 | if (!pgconn) | 164 | if (pgconn) { |
172 | return; | 165 | PQfinish(pgconn); |
173 | PQfinish(pgconn); | 166 | conn->data = NULL; |
174 | conn->data = NULL; | 167 | } |
175 | } | 168 | } |
@@ -178,3 +171,3 @@ struct sql_iface pgsql_iface = { | |||
178 | "pgsql", | 171 | "pgsql", |
179 | s_pgsql_mark, | 172 | NULL, /* mark */ |
180 | s_pgsql_free, | 173 | s_pgsql_free, |
diff --git a/src/syslog-port.c b/src/syslog-port.c index 4b27ef9..4388c10 100644 --- a/src/syslog-port.c +++ b/src/syslog-port.c | |||
@@ -30,3 +30,3 @@ typedef off_t scm_t_off; | |||
30 | #define GAMMA_SYSLOG_PORT_BUFSIZE 1024 | 30 | #define GAMMA_SYSLOG_PORT_BUFSIZE 1024 |
31 | static scm_t_bits scm_tc16_syslog_port; | 31 | static scm_t_port_type *scm_syslog_port_type; |
32 | struct _gamma_syslog_port { | 32 | struct _gamma_syslog_port { |
@@ -39,21 +39,8 @@ _make_syslog_port(int prio) | |||
39 | struct _gamma_syslog_port *dp; | 39 | struct _gamma_syslog_port *dp; |
40 | SCM port; | ||
41 | scm_port *pt; | ||
42 | 40 | ||
43 | dp = scm_gc_malloc (sizeof (struct _gamma_syslog_port), "syslog-port"); | 41 | dp = scm_gc_typed_calloc (struct _gamma_syslog_port); |
44 | dp->prio = prio; | 42 | dp->prio = prio; |
45 | 43 | return scm_c_make_port(scm_syslog_port_type, | |
46 | port = scm_new_port_table_entry(scm_tc16_syslog_port); | 44 | SCM_OPN | SCM_WRTNG | SCM_BUFLINE, |
47 | pt = SCM_PTAB_ENTRY(port); | 45 | (scm_t_bits) dp); |
48 | pt->rw_random = 0; | ||
49 | pt->write_buf = scm_gc_malloc(GAMMA_SYSLOG_PORT_BUFSIZE, | ||
50 | "syslog port buffer"); | ||
51 | pt->write_pos = pt->write_buf; | ||
52 | pt->write_buf_size = GAMMA_SYSLOG_PORT_BUFSIZE; | ||
53 | pt->write_end = pt->write_buf + pt->write_buf_size; | ||
54 | SCM_SET_CELL_TYPE(port, | ||
55 | (scm_tc16_syslog_port | | ||
56 | SCM_OPN | SCM_WRTNG | SCM_BUFLINE)); | ||
57 | SCM_SETSTREAM(port, dp); | ||
58 | return port; | ||
59 | } | 46 | } |
@@ -62,38 +49,3 @@ _make_syslog_port(int prio) | |||
62 | 49 | ||
63 | static SCM | ||
64 | _syslog_port_mark(SCM port) | ||
65 | { | ||
66 | return SCM_BOOL_F; | ||
67 | } | ||
68 | |||
69 | static void | 50 | static void |
70 | _syslog_port_flush(SCM port) | ||
71 | { | ||
72 | struct _gamma_syslog_port *dp = SYSLOG_PORT(port); | ||
73 | scm_port *pt = SCM_PTAB_ENTRY(port); | ||
74 | size_t size = pt->write_pos - pt->write_buf; | ||
75 | unsigned char *nl = memchr(pt->write_buf, '\n', size); | ||
76 | int wrsize; | ||
77 | |||
78 | if (!nl) | ||
79 |