git://git.exim.org
/
exim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
heimdal auth: fix the increase of big_buffer size. Bug 2501
[exim.git]
/
src
/
src
/
lookups
/
sqlite.c
diff --git
a/src/src/lookups/sqlite.c
b/src/src/lookups/sqlite.c
index e2330f920240c49ba5279268367c7a2ffd2c6401..6200d6c820503f184b68f76841d5bd2fd1d1315a 100644
(file)
--- a/
src/src/lookups/sqlite.c
+++ b/
src/src/lookups/sqlite.c
@@
-2,7
+2,7
@@
* Exim - an Internet mail transport agent *
*************************************************/
* Exim - an Internet mail transport agent *
*************************************************/
-/* Copyright (c) University of Cambridge 1995 - 201
5
*/
+/* Copyright (c) University of Cambridge 1995 - 201
8
*/
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
/* See the file NOTICE for conditions of use and distribution. */
#include "../exim.h"
@@
-23,11
+23,11
@@
sqlite_open(uschar *filename, uschar **errmsg)
sqlite3 *db = NULL;
int ret;
sqlite3 *db = NULL;
int ret;
-ret = sqlite3_open(
(char *)
filename, &db);
+ret = sqlite3_open(
CS
filename, &db);
if (ret != 0)
{
*errmsg = (void *)sqlite3_errmsg(db);
if (ret != 0)
{
*errmsg = (void *)sqlite3_errmsg(db);
- debug_printf("Error opening database: %s\n", *errmsg);
+ debug_printf
_indent
("Error opening database: %s\n", *errmsg);
}
sqlite3_busy_timeout(db, 1000 * sqlite_lock_timeout);
}
sqlite3_busy_timeout(db, 1000 * sqlite_lock_timeout);
@@
-41,40
+41,30
@@
return db;
/* See local README for interface description. */
/* See local README for interface description. */
-struct strbuf {
- uschar *string;
- int size;
- int len;
-};
-
-static int sqlite_callback(void *arg, int argc, char **argv, char **azColName)
+static int
+sqlite_callback(void *arg, int argc, char **argv, char **azColName)
{
{
-struct strbuf *res = arg;
-int i;
+gstring * res = *(gstring **)arg;
/* For second and subsequent results, insert \n */
/* For second and subsequent results, insert \n */
-if (res
->string != NULL
)
- res
->string = string_cat(res->string, &res->size, &res->len
, US"\n", 1);
+if (res)
+ res
= string_catn(res
, US"\n", 1);
if (argc > 1)
{
/* For multiple fields, include the field name too */
if (argc > 1)
{
/* For multiple fields, include the field name too */
- for (i = 0; i < argc; i++)
+ for (i
nt i
= 0; i < argc; i++)
{
uschar *value = US((argv[i] != NULL)? argv[i]:"<NULL>");
{
uschar *value = US((argv[i] != NULL)? argv[i]:"<NULL>");
- res->string = lf_quote(US azColName[i], value, Ustrlen(value), res->string,
- &res->size, &res->len);
+ res = lf_quote(US azColName[i], value, Ustrlen(value), res);
}
}
else
}
}
else
- {
- res->string = string_append(res->string, &res->size, &res->len, 1,
- (argv[0] != NULL)? argv[0]:"<NULL>");
- }
+ res = string_cat(res, argv[0] ? US argv[0] : US "<NULL>");
-
res->string[res->len] = 0
;
+
*(gstring **)arg = res
;
return 0;
}
return 0;
}
@@
-84,18
+74,18
@@
sqlite_find(void *handle, uschar *filename, const uschar *query, int length,
uschar **result, uschar **errmsg, uint *do_cache)
{
int ret;
uschar **result, uschar **errmsg, uint *do_cache)
{
int ret;
-
struct strbuf res = { NULL, 0, 0 }
;
+
gstring * res = NULL
;
-ret = sqlite3_exec(handle,
(char *)
query, sqlite_callback, &res, (char **)errmsg);
+ret = sqlite3_exec(handle,
CS
query, sqlite_callback, &res, (char **)errmsg);
if (ret != SQLITE_OK)
{
if (ret != SQLITE_OK)
{
- debug_printf("sqlite3_exec failed: %s\n", *errmsg);
+ debug_printf
_indent
("sqlite3_exec failed: %s\n", *errmsg);
return FAIL;
}
return FAIL;
}
-if (
res.string == NULL
) *do_cache = 0;
+if (
!res
) *do_cache = 0;
-*result =
res.string
;
+*result =
string_from_gstring(res)
;
return OK;
}
return OK;
}
@@
-141,7
+131,7
@@
if (opt != NULL) return NULL; /* No options recognized */
while ((c = *t++) != 0) if (c == '\'') count++;
if (count == 0) return s;
while ((c = *t++) != 0) if (c == '\'') count++;
if (count == 0) return s;
-t = quoted = store_get(Ustrlen(s) + count + 1);
+t = quoted = store_get(Ustrlen(s) + count + 1
, is_tainted(s)
);
while ((c = *s++) != 0)
{
while ((c = *s++) != 0)
{