Gitweb:
https://git.exim.org/exim.git/commitdiff/d447dbd160a0fb503ed1e763f3f23d28744b6ddd
Commit: d447dbd160a0fb503ed1e763f3f23d28744b6ddd
Parent: c685a2e3d970d25b36a00e4110f975b588b0bbab
Author: Jeremy Harris <jgh146exb@???>
AuthorDate: Sun Mar 29 19:07:48 2020 +0100
Committer: Jeremy Harris <jgh146exb@???>
CommitDate: Sun Mar 29 19:07:48 2020 +0100
constify
---
src/src/drtables.c | 3 +-
src/src/functions.h | 6 +-
src/src/lookupapi.h | 6 +-
src/src/lookups/cdb.c | 202 +++++++++++++++++++---------------------
src/src/lookups/dbmdb.c | 24 ++---
src/src/lookups/dnsdb.c | 6 +-
src/src/lookups/dsearch.c | 10 +-
src/src/lookups/ibase.c | 49 +++++-----
src/src/lookups/json.c | 8 +-
src/src/lookups/ldap.c | 18 ++--
src/src/lookups/lf_check_file.c | 4 +-
src/src/lookups/lf_functions.h | 2 +-
src/src/lookups/lmdb.c | 4 +-
src/src/lookups/lsearch.c | 40 ++++----
src/src/lookups/mysql.c | 6 +-
src/src/lookups/nis.c | 10 +-
src/src/lookups/nisplus.c | 6 +-
src/src/lookups/oracle.c | 6 +-
src/src/lookups/passwd.c | 6 +-
src/src/lookups/pgsql.c | 6 +-
src/src/lookups/redis.c | 10 +-
src/src/lookups/spf.c | 6 +-
src/src/lookups/sqlite.c | 9 +-
src/src/lookups/testdb.c | 6 +-
src/src/lookups/whoson.c | 6 +-
src/src/search.c | 11 ++-
26 files changed, 226 insertions(+), 244 deletions(-)
diff --git a/src/src/drtables.c b/src/src/drtables.c
index f1053bb..7fa8ca4 100644
--- a/src/src/drtables.c
+++ b/src/src/drtables.c
@@ -546,8 +546,7 @@ if (lookup_list[pos])
/* need to insert it, so move all the other items up
(last slot is still empty, of course) */
- memmove(&lookup_list[pos+1],
- &lookup_list[pos],
+ memmove(&lookup_list[pos+1], &lookup_list[pos],
sizeof(lookup_info *) * (lookup_list_count-pos-1));
}
lookup_list[pos] = info;
diff --git a/src/src/functions.h b/src/src/functions.h
index f789c5e..90e6e67 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -438,12 +438,12 @@ extern void route_init(void);
extern void route_show_supported(FILE *);
extern void route_tidyup(void);
-extern uschar *search_find(void *, uschar *, uschar *, int, const uschar *, int,
- int, int *);
+extern uschar *search_find(void *, const uschar *, uschar *, int,
+ const uschar *, int, int, int *);
extern int search_findtype(const uschar *, int);
extern int search_findtype_partial(const uschar *, int *, const uschar **, int *,
int *);
-extern void *search_open(uschar *, int, int, uid_t *, gid_t *);
+extern void *search_open(const uschar *, int, int, uid_t *, gid_t *);
extern void search_tidyup(void);
extern void set_process_info(const char *, ...) PRINTF_FUNCTION(1,2);
extern void sha1_end(hctx *, const uschar *, int, uschar *);
diff --git a/src/src/lookupapi.h b/src/src/lookupapi.h
index 9055f52..07e7af9 100644
--- a/src/src/lookupapi.h
+++ b/src/src/lookupapi.h
@@ -18,18 +18,18 @@ typedef struct lookup_info {
uschar *name; /* e.g. "lsearch" */
int type; /* query/singlekey/abs-file */
void *(*open)( /* open function */
- uschar *, /* file name for those that have one */
+ const uschar *, /* file name for those that have one */
uschar **); /* for error message */
BOOL (*check)( /* file checking function */
void *, /* handle */
- uschar *, /* file name */
+ const uschar *, /* file name */
int, /* modemask for file checking */
uid_t *, /* owners for file checking */
gid_t *, /* owngroups for file checking */
uschar **); /* for error messages */
int (*find)( /* find function */
void *, /* handle */
- uschar *, /* file name or NULL */
+ const uschar *, /* file name or NULL */
const uschar *, /* key or query */
int, /* length of key or query */
uschar **, /* for returning answer */
diff --git a/src/src/lookups/cdb.c b/src/src/lookups/cdb.c
index 5cae153..c9a5de1 100644
--- a/src/src/lookups/cdb.c
+++ b/src/src/lookups/cdb.c
@@ -136,108 +136,109 @@ cdb_bread(int fd,
static uint32
cdb_unpack(uschar *buf)
{
- uint32 num;
- num = buf[3]; num <<= 8;
- num += buf[2]; num <<= 8;
- num += buf[1]; num <<= 8;
- num += buf[0];
- return num;
+uint32 num;
+num = buf[3]; num <<= 8;
+num += buf[2]; num <<= 8;
+num += buf[1]; num <<= 8;
+num += buf[0];
+return num;
}
static void cdb_close(void *handle);
static void *
-cdb_open(uschar *filename,
- uschar **errmsg)
+cdb_open(const uschar * filename, uschar ** errmsg)
{
- int fileno;
- struct cdb_state *cdbp;
- struct stat statbuf;
- void * mapbuf;
-
- fileno = Uopen(filename, O_RDONLY, 0);
- if (fileno == -1) {
- int save_errno = errno;
- *errmsg = string_open_failed(errno, "%s for cdb lookup", filename);
- errno = save_errno;
- return NULL;
+int fileno;
+struct cdb_state *cdbp;
+struct stat statbuf;
+void * mapbuf;
+
+if ((fileno = Uopen(filename, O_RDONLY, 0)) < 0)
+ {
+ int save_errno = errno;
+ *errmsg = string_open_failed(errno, "%s for cdb lookup", filename);
+ errno = save_errno;
+ return NULL;
}
- if (fstat(fileno, &statbuf) == 0) {
- /* If this is a valid file, then it *must* be at least
- * CDB_HASH_TABLE bytes long */
- if (statbuf.st_size < CDB_HASH_TABLE) {
- int save_errno = errno;
- *errmsg = string_open_failed(errno,
- "%s too short for cdb lookup",
- filename);
- errno = save_errno;
- return NULL;
- }
- } else {
- int save_errno = errno;
- *errmsg = string_open_failed(errno,
- "fstat(%s) failed - cannot do cdb lookup",
- filename);
- errno = save_errno;
- return NULL;
+if (fstat(fileno, &statbuf) != 0)
+ {
+ int save_errno = errno;
+ *errmsg = string_open_failed(errno,
+ "fstat(%s) failed - cannot do cdb lookup",
+ filename);
+ errno = save_errno;
+ return NULL;
+ }
+
+/* If this is a valid file, then it *must* be at least
+CDB_HASH_TABLE bytes long */
+
+if (statbuf.st_size < CDB_HASH_TABLE)
+ {
+ int save_errno = errno;
+ *errmsg = string_open_failed(errno,
+ "%s too short for cdb lookup",
+ filename);
+ errno = save_errno;
+ return NULL;
}
- /* Having got a file open we need the structure to put things in */
- cdbp = store_get(sizeof(struct cdb_state), FALSE);
- /* store_get() does not return if memory was not available... */
- /* preload the structure.... */
- cdbp->fileno = fileno;
- cdbp->filelen = statbuf.st_size;
- cdbp->cdb_map = NULL;
- cdbp->cdb_offsets = NULL;
+/* Having got a file open we need the structure to put things in */
+cdbp = store_get(sizeof(struct cdb_state), FALSE);
+/* store_get() does not return if memory was not available... */
+/* preload the structure.... */
+cdbp->fileno = fileno;
+cdbp->filelen = statbuf.st_size;
+cdbp->cdb_map = NULL;
+cdbp->cdb_offsets = NULL;
- /* if we are allowed to we use mmap here.... */
+/* if we are allowed to we use mmap here.... */
#ifdef HAVE_MMAP
- mapbuf = mmap(NULL,
- statbuf.st_size,
- PROT_READ,
- MAP_SHARED,
- fileno,
- 0);
- if (mapbuf != MAP_FAILED) {
- /* We have an mmap-ed section. Now we can just use it */
- cdbp->cdb_map = mapbuf;
- /* The offsets can be set to the same value since they should
- * effectively be cached as well
- */
- cdbp->cdb_offsets = mapbuf;
-
- /* Now return the state struct */
- return(cdbp);
- } else
- /* If we got here the map failed. Basically we can ignore
- * this since we fall back to slower methods....
- * However lets debug log it...
- */
- DEBUG(D_lookup) debug_printf_indent("cdb mmap failed - %d\n", errno);
+if ((mapbuf = mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED, fileno, 0))
+ != MAP_FAILED)
+ {
+ /* We have an mmap-ed section. Now we can just use it */
+ cdbp->cdb_map = mapbuf;
+ /* The offsets can be set to the same value since they should
+ * effectively be cached as well
+ */
+ cdbp->cdb_offsets = mapbuf;
+
+ /* Now return the state struct */
+ return(cdbp);
+ }
+
+/* If we got here the map failed. Basically we can ignore this since we fall
+back to slower methods.... However lets debug log it... */
+
+DEBUG(D_lookup) debug_printf_indent("cdb mmap failed - %d\n", errno);
#endif /* HAVE_MMAP */
- /* In this case we have either not got MMAP allowed, or it failed */
-
- /* get a buffer to stash the basic offsets in - this should speed
- * things up a lot - especially on multiple lookups */
- cdbp->cdb_offsets = store_get(CDB_HASH_TABLE, FALSE);
-
- /* now fill the buffer up... */
- if (cdb_bread(fileno, cdbp->cdb_offsets, CDB_HASH_TABLE) == -1) {
- /* read of hash table failed, oh dear, oh.....
- * time to give up I think....
- * call the close routine (deallocs the memory), and return NULL */
- *errmsg = string_open_failed(errno,
- "cannot read header from %s for cdb lookup",
- filename);
- cdb_close(cdbp);
- return NULL;
+/* In this case we have either not got MMAP allowed, or it failed */
+
+/* get a buffer to stash the basic offsets in - this should speed
+things up a lot - especially on multiple lookups */
+
+cdbp->cdb_offsets = store_get(CDB_HASH_TABLE, FALSE);
+
+/* now fill the buffer up... */
+
+if (cdb_bread(fileno, cdbp->cdb_offsets, CDB_HASH_TABLE) == -1)
+ {
+ /* read of hash table failed, oh dear, oh..... time to give up I think....
+ call the close routine (deallocs the memory), and return NULL */
+
+ *errmsg = string_open_failed(errno,
+ "cannot read header from %s for cdb lookup",
+ filename);
+ cdb_close(cdbp);
+ return NULL;
}
- /* Everything else done - return the cache structure */
- return cdbp;
+/* Everything else done - return the cache structure */
+return cdbp;
}
@@ -247,22 +248,12 @@ cdb_open(uschar *filename,
*************************************************/
static BOOL
-cdb_check(void *handle,
- uschar *filename,
- int modemask,
- uid_t *owners,
- gid_t *owngroups,
- uschar **errmsg)
+cdb_check(void * handle, const uschar * filename, int modemask,
+ uid_t * owners, gid_t * owngroups, uschar ** errmsg)
{
- struct cdb_state * cdbp = handle;
- return lf_check_file(cdbp->fileno,
- filename,
- S_IFREG,
- modemask,
- owners,
- owngroups,
- "cdb",
- errmsg) == 0;
+struct cdb_state * cdbp = handle;
+return lf_check_file(cdbp->fileno, filename, S_IFREG, modemask,
+ owners, owngroups, "cdb", errmsg) == 0;
}
@@ -272,13 +263,8 @@ cdb_check(void *handle,
*************************************************/
static int
-cdb_find(void *handle,
- uschar *filename,
- const uschar *keystring,
- int key_len,
- uschar **result,
- uschar **errmsg,
- uint *do_cache)
+cdb_find(void * handle, const uschar * filename, const uschar * keystring,
+ int key_len, uschar ** result, uschar ** errmsg, uint * do_cache)
{
struct cdb_state * cdbp = handle;
uint32 item_key_len,
diff --git a/src/src/lookups/dbmdb.c b/src/src/lookups/dbmdb.c
index 5e97009..f3bd6d2 100644
--- a/src/src/lookups/dbmdb.c
+++ b/src/src/lookups/dbmdb.c
@@ -16,7 +16,7 @@
/* See local README for interface description */
static void *
-dbmdb_open(uschar *filename, uschar **errmsg)
+dbmdb_open(const uschar * filename, uschar ** errmsg)
{
uschar * dirname = string_copy(filename);
uschar * s;
@@ -24,7 +24,7 @@ EXIM_DB *yield = NULL;
if ((s = Ustrrchr(dirname, '/'))) *s = '\0';
EXIM_DBOPEN(filename, dirname, O_RDONLY, 0, &yield);
-if (yield == NULL)
+if (!yield)
{
int save_errno = errno;
*errmsg = string_open_failed(errno, "%s as a %s file", filename, EXIM_DBTYPE);
@@ -47,7 +47,7 @@ the same. Otherwise, for safety, we have to check for x.db or x.dir and x.pag.
*/
static BOOL
-dbmdb_check(void *handle, uschar *filename, int modemask, uid_t *owners,
+dbmdb_check(void *handle, const uschar *filename, int modemask, uid_t *owners,
gid_t *owngroups, uschar **errmsg)
{
int rc;
@@ -90,8 +90,8 @@ return rc == 0;
the keylength in order to include the terminating zero. */
static int
-dbmdb_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+dbmdb_find(void * handle, const uschar * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
EXIM_DB *d = (EXIM_DB *)handle;
EXIM_DATUM key, data;
@@ -122,9 +122,9 @@ return FAIL;
/* See local README for interface description */
-int
-static dbmnz_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+static int
+dbmnz_find(void * handle, const uschar * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
return dbmdb_find(handle, filename, keystring, length-1, result, errmsg,
do_cache);
@@ -143,8 +143,8 @@ return dbmdb_find(handle, filename, keystring, length-1, result, errmsg,
*/
static int
-dbmjz_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+dbmjz_find(void * handle, const uschar * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
uschar *key_item, *key_buffer, *key_p;
const uschar *key_elems = keystring;
@@ -203,8 +203,8 @@ DEBUG(D_lookup) debug_printf_indent("NUL-joined key length: %d\n", key_item_len)
/* beware that dbmdb_find() adds 1 to length to get back terminating NUL, so
because we've calculated the real length, we need to subtract one more here */
-return dbmdb_find(handle, filename,
- key_buffer, key_item_len - 1,
+
+return dbmdb_find(handle, filename, key_buffer, key_item_len - 1,
result, errmsg, do_cache);
}
diff --git a/src/src/lookups/dnsdb.c b/src/src/lookups/dnsdb.c
index 94809e5..cc711c5 100644
--- a/src/src/lookups/dnsdb.c
+++ b/src/src/lookups/dnsdb.c
@@ -77,7 +77,7 @@ static int type_values[] = {
/* See local README for interface description. */
static void *
-dnsdb_open(uschar *filename, uschar **errmsg)
+dnsdb_open(const uschar * filename, uschar **errmsg)
{
filename = filename; /* Keep picky compilers happy */
errmsg = errmsg; /* Ditto */
@@ -130,8 +130,8 @@ which may start with '<' in order to set a specific separator. The default
separator, as always, is colon. */
static int
-dnsdb_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+dnsdb_find(void * handle, const uschar * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
int rc;
int sep = 0;
diff --git a/src/src/lookups/dsearch.c b/src/src/lookups/dsearch.c
index 3a0df30..dba8422 100644
--- a/src/src/lookups/dsearch.c
+++ b/src/src/lookups/dsearch.c
@@ -25,7 +25,7 @@ it open, because the "search" can be done by a call to lstat() rather than
actually scanning through the list of files. */
static void *
-dsearch_open(uschar *dirname, uschar **errmsg)
+dsearch_open(const uschar * dirname, uschar ** errmsg)
{
DIR * dp = exim_opendir(dirname);
if (!dp)
@@ -48,8 +48,8 @@ return (void *)(-1);
integer as this gives warnings on 64-bit systems. */
static BOOL
-dsearch_check(void *handle, uschar *filename, int modemask, uid_t *owners,
- gid_t *owngroups, uschar **errmsg)
+dsearch_check(void * handle, const uschar * filename, int modemask,
+ uid_t * owners, gid_t * owngroups, uschar ** errmsg)
{
handle = handle;
return lf_check_file(-1, filename, S_IFDIR, modemask, owners, owngroups,
@@ -66,8 +66,8 @@ scanning the directory, as it is hopefully faster to let the OS do the scanning
for us. */
static int
-dsearch_find(void *handle, uschar *dirname, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+dsearch_find(void * handle, const uschar * dirname, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
struct stat statbuf;
int save_errno;
diff --git a/src/src/lookups/ibase.c b/src/src/lookups/ibase.c
index f08f503..2ccb7b4 100644
--- a/src/src/lookups/ibase.c
+++ b/src/src/lookups/ibase.c
@@ -31,9 +31,9 @@ static ibase_connection *ibase_connections = NULL;
/* See local README for interface description. */
-static void *ibase_open(uschar * filename, uschar ** errmsg)
+static void *ibase_open(const uschar * filename, uschar ** errmsg)
{
- return (void *) (1); /* Just return something non-null */
+return (void *) (1); /* Just return something non-null */
}
@@ -450,33 +450,32 @@ arguments are not used. Loop through a list of servers while the query is
deferred with a retryable error. */
static int
-ibase_find(void *handle, uschar * filename, uschar * query, int length,
+ibase_find(void * handle, const uschar * filename, uschar * query, int length,
uschar ** result, uschar ** errmsg, uint *do_cache)
{
- int sep = 0;
- uschar *server;
- uschar *list = ibase_servers;
- uschar buffer[512];
-
- /* Keep picky compilers happy */
- do_cache = do_cache;
-
- DEBUG(D_lookup) debug_printf_indent("Interbase query: %s\n", query);
-
- while ((server =
- string_nextinlist(&list, &sep, buffer,
- sizeof(buffer))) != NULL) {
- BOOL defer_break = FALSE;
- int rc = perform_ibase_search(query, server, result, errmsg,
- &defer_break);
- if (rc != DEFER || defer_break)
- return rc;
- }
+int sep = 0;
+uschar *server;
+uschar *list = ibase_servers;
+uschar buffer[512];
- if (ibase_servers == NULL)
- *errmsg = US "no Interbase servers defined (ibase_servers option)";
+/* Keep picky compilers happy */
+do_cache = do_cache;
- return DEFER;
+DEBUG(D_lookup) debug_printf_indent("Interbase query: %s\n", query);
+
+while ((server = string_nextinlist(&list, &sep, buffer,
+ sizeof(buffer))))
+ {
+ BOOL defer_break = FALSE;
+ int rc = perform_ibase_search(query, server, result, errmsg, &defer_break);
+ if (rc != DEFER || defer_break)
+ return rc;
+ }
+
+if (!ibase_servers)
+ *errmsg = US "no Interbase servers defined (ibase_servers option)";
+
+return DEFER;
}
diff --git a/src/src/lookups/json.c b/src/src/lookups/json.c
index 15b8617..f476db3 100644
--- a/src/src/lookups/json.c
+++ b/src/src/lookups/json.c
@@ -40,7 +40,7 @@ json_free(void * p)
/* See local README for interface description */
static void *
-json_open(uschar *filename, uschar **errmsg)
+json_open(const uschar * filename, uschar ** errmsg)
{
FILE * f;
@@ -63,7 +63,7 @@ return f;
*************************************************/
static BOOL
-json_check(void *handle, uschar *filename, int modemask, uid_t *owners,
+json_check(void *handle, const uschar *filename, int modemask, uid_t *owners,
gid_t *owngroups, uschar **errmsg)
{
return lf_check_file(fileno((FILE *)handle), filename, S_IFREG, modemask,
@@ -79,8 +79,8 @@ return lf_check_file(fileno((FILE *)handle), filename, S_IFREG, modemask,
/* See local README for interface description */
static int
-json_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+json_find(void * handle, const uschar * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
FILE * f = handle;
json_t * j, * j0;
diff --git a/src/src/lookups/ldap.c b/src/src/lookups/ldap.c
index 8972d10..b9a52d2 100644
--- a/src/src/lookups/ldap.c
+++ b/src/src/lookups/ldap.c
@@ -1283,8 +1283,8 @@ are handled by a common function, with a flag to differentiate between them.
The handle and filename arguments are not used. */
static int
-eldap_find(void *handle, uschar *filename, const uschar *ldap_url, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+eldap_find(void * handle, const uschar * filename, const uschar * ldap_url,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
/* Keep picky compilers happy */
do_cache = do_cache;
@@ -1292,8 +1292,8 @@ return(control_ldap_search(ldap_url, SEARCH_LDAP_SINGLE, result, errmsg));
}
static int
-eldapm_find(void *handle, uschar *filename, const uschar *ldap_url, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+eldapm_find(void * handle, const uschar * filename, const uschar * ldap_url,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
/* Keep picky compilers happy */
do_cache = do_cache;
@@ -1301,8 +1301,8 @@ return(control_ldap_search(ldap_url, SEARCH_LDAP_MULTIPLE, result, errmsg));
}
static int
-eldapdn_find(void *handle, uschar *filename, const uschar *ldap_url, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+eldapdn_find(void * handle, const uschar * filename, const uschar * ldap_url,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
/* Keep picky compilers happy */
do_cache = do_cache;
@@ -1310,8 +1310,8 @@ return(control_ldap_search(ldap_url, SEARCH_LDAP_DN, result, errmsg));
}
int
-eldapauth_find(void *handle, uschar *filename, const uschar *ldap_url, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+eldapauth_find(void * handle, const uschar * filename, const uschar * ldap_url,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
/* Keep picky compilers happy */
do_cache = do_cache;
@@ -1327,7 +1327,7 @@ return(control_ldap_search(ldap_url, SEARCH_LDAP_AUTH, result, errmsg));
/* See local README for interface description. */
static void *
-eldap_open(uschar *filename, uschar **errmsg)
+eldap_open(const uschar * filename, uschar ** errmsg)
{
return (void *)(1); /* Just return something non-null */
}
diff --git a/src/src/lookups/lf_check_file.c b/src/src/lookups/lf_check_file.c
index 8b11408..eb08a4d 100644
--- a/src/src/lookups/lf_check_file.c
+++ b/src/src/lookups/lf_check_file.c
@@ -38,8 +38,8 @@ Side effect: sets errno to ERRNO_BADUGID, ERRNO_NOTREGULAR or ERRNO_BADMODE for
*/
int
-lf_check_file(int fd, uschar *filename, int s_type, int modemask, uid_t *owners,
- gid_t *owngroups, const char *type, uschar **errmsg)
+lf_check_file(int fd, const uschar * filename, int s_type, int modemask,
+ uid_t * owners, gid_t * owngroups, const char * type, uschar ** errmsg)
{
struct stat statbuf;
diff --git a/src/src/lookups/lf_functions.h b/src/src/lookups/lf_functions.h
index 8fa6027..4d9ae95 100644
--- a/src/src/lookups/lf_functions.h
+++ b/src/src/lookups/lf_functions.h
@@ -7,7 +7,7 @@
/* Header for the functions that are shared by the lookups */
-extern int lf_check_file(int, uschar *, int, int, uid_t *, gid_t *,
+extern int lf_check_file(int, const uschar *, int, int, uid_t *, gid_t *,
const char *, uschar **);
extern gstring *lf_quote(uschar *, uschar *, int, gstring *);
extern int lf_sqlperform(const uschar *, const uschar *, const uschar *,
diff --git a/src/src/lookups/lmdb.c b/src/src/lookups/lmdb.c
index 2976cfa..712261a 100644
--- a/src/src/lookups/lmdb.c
+++ b/src/src/lookups/lmdb.c
@@ -23,7 +23,7 @@ MDB_dbi db_dbi;
*************************************************/
static void *
-lmdb_open(uschar * filename, uschar ** errmsg)
+lmdb_open(const uschar * filename, uschar ** errmsg)
{
MDB_env * db_env = NULL;
Lmdbstrct * lmdb_p;
@@ -74,7 +74,7 @@ bad:
*************************************************/
static int
-lmdb_find(void * handle, uschar * filename,
+lmdb_find(void * handle, const uschar * filename,
const uschar * keystring, int length, uschar ** result, uschar ** errmsg,
uint * do_cache)
{
diff --git a/src/src/lookups/lsearch.c b/src/src/lookups/lsearch.c
index 76b76b8..92a76e7 100644
--- a/src/src/lookups/lsearch.c
+++ b/src/src/lookups/lsearch.c
@@ -26,7 +26,7 @@ enum {
/* See local README for interface description */
static void *
-lsearch_open(uschar *filename, uschar **errmsg)
+lsearch_open(const uschar * filename, uschar ** errmsg)
{
FILE *f = Ufopen(filename, "rb");
if (f == NULL)
@@ -46,7 +46,7 @@ return f;
*************************************************/
static BOOL
-lsearch_check(void *handle, uschar *filename, int modemask, uid_t *owners,
+lsearch_check(void *handle, const uschar *filename, int modemask, uid_t *owners,
gid_t *owngroups, uschar **errmsg)
{
return lf_check_file(fileno((FILE *)handle), filename, S_IFREG, modemask,
@@ -71,8 +71,9 @@ fit into the fixed sized buffer. Most of the time this will never be exercised,
but people do occasionally do weird things. */
static int
-internal_lsearch_find(void *handle, uschar *filename, const uschar *keystring,
- int length, uschar **result, uschar **errmsg, int type)
+internal_lsearch_find(void * handle, const uschar * filename,
+ const uschar * keystring, int length, uschar ** result, uschar ** errmsg,
+ int type)
{
FILE *f = (FILE *)handle;
BOOL last_was_eol = TRUE;
@@ -318,8 +319,8 @@ return FAIL;
/* See local README for interface description */
static int
-lsearch_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+lsearch_find(void * handle, const uschar * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
do_cache = do_cache; /* Keep picky compilers happy */
return internal_lsearch_find(handle, filename, keystring, length, result,
@@ -335,8 +336,8 @@ return internal_lsearch_find(handle, filename, keystring, length, result,
/* See local README for interface description */
static int
-wildlsearch_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+wildlsearch_find(void * handle, const uschar * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
do_cache = do_cache; /* Keep picky compilers happy */
return internal_lsearch_find(handle, filename, keystring, length, result,
@@ -352,8 +353,8 @@ return internal_lsearch_find(handle, filename, keystring, length, result,
/* See local README for interface description */
static int
-nwildlsearch_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+nwildlsearch_find(void * handle, const uschar * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
do_cache = do_cache; /* Keep picky compilers happy */
return internal_lsearch_find(handle, filename, keystring, length, result,
@@ -370,23 +371,20 @@ return internal_lsearch_find(handle, filename, keystring, length, result,
/* See local README for interface description */
static int
-iplsearch_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+iplsearch_find(void * handle, uschar const * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
do_cache = do_cache; /* Keep picky compilers happy */
+
if ((length == 1 && keystring[0] == '*') ||
string_is_ip_address(keystring, NULL) != 0)
- {
return internal_lsearch_find(handle, filename, keystring, length, result,
errmsg, LSEARCH_IP);
- }
-else
- {
- *errmsg = string_sprintf("\"%s\" is not a valid iplsearch key (an IP "
- "address, with optional CIDR mask, is wanted): "
- "in a host list, use net-iplsearch as the search type", keystring);
- return DEFER;
- }
+
+*errmsg = string_sprintf("\"%s\" is not a valid iplsearch key (an IP "
+"address, with optional CIDR mask, is wanted): "
+"in a host list, use net-iplsearch as the search type", keystring);
+return DEFER;
}
diff --git a/src/src/lookups/mysql.c b/src/src/lookups/mysql.c
index 460ee29..745c650 100644
--- a/src/src/lookups/mysql.c
+++ b/src/src/lookups/mysql.c
@@ -81,7 +81,7 @@ static mysql_connection *mysql_connections = NULL;
/* See local README for interface description. */
static void *
-mysql_open(uschar *filename, uschar **errmsg)
+mysql_open(const uschar * filename, uschar ** errmsg)
{
return (void *)(1); /* Just return something non-null */
}
@@ -389,8 +389,8 @@ query is deferred with a retryable error is now in a separate function that is
shared with other SQL lookups. */
static int
-mysql_find(void *handle, uschar *filename, const uschar *query, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+mysql_find(void * handle, const uschar * filename, const uschar * query,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
return lf_sqlperform(US"MySQL", US"mysql_servers", mysql_servers, query,
result, errmsg, do_cache, perform_mysql_search);
diff --git a/src/src/lookups/nis.c b/src/src/lookups/nis.c
index 6f5307f..10ecf74 100644
--- a/src/src/lookups/nis.c
+++ b/src/src/lookups/nis.c
@@ -19,7 +19,7 @@
the "nis" and "nis0" lookup types. */
static void *
-nis_open(uschar *filename, uschar **errmsg)
+nis_open(const uschar * filename, uschar ** errmsg)
{
char *nis_domain;
if (yp_get_default_domain(&nis_domain) != 0)
@@ -41,8 +41,8 @@ for nis0 because they are so short it isn't worth trying to use any common
code. */
static int
-nis_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+nis_find(void * handle, const uschar * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
int rc;
uschar *nis_data;
@@ -67,8 +67,8 @@ return (rc == YPERR_KEY || rc == YPERR_MAP)? FAIL : DEFER;
/* See local README for interface description. */
static int
-nis0_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+nis0_find(void * handle, const uschar * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
int rc;
uschar *nis_data;
diff --git a/src/src/lookups/nisplus.c b/src/src/lookups/nisplus.c
index 98f3df3..370f6a6 100644
--- a/src/src/lookups/nisplus.c
+++ b/src/src/lookups/nisplus.c
@@ -18,7 +18,7 @@
/* See local README for interface description. */
static void *
-nisplus_open(uschar *filename, uschar **errmsg)
+nisplus_open(const uschar * filename, uschar ** errmsg)
{
return (void *)(1); /* Just return something non-null */
}
@@ -42,8 +42,8 @@ yield is the concatenation of all the fields, preceded by their names and an
equals sign. */
static int
-nisplus_find(void *handle, uschar *filename, const uschar *query, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+nisplus_find(void * handle, const uschar * filename, const uschar * query,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
int error_error = FAIL;
const uschar * field_name = NULL;
diff --git a/src/src/lookups/oracle.c b/src/src/lookups/oracle.c
index 4e8cba5..e22ff89 100644
--- a/src/src/lookups/oracle.c
+++ b/src/src/lookups/oracle.c
@@ -196,7 +196,7 @@ return col;
/* See local README for interface description. */
static void *
-oracle_open(uschar *filename, uschar **errmsg)
+oracle_open(const uschar * filename, uschar ** errmsg)
{
return (void *)(1); /* Just return something non-null */
}
@@ -503,8 +503,8 @@ arguments are not used. Loop through a list of servers while the query is
deferred with a retryable error. */
static int
-oracle_find(void *handle, uschar *filename, uschar *query, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+oracle_find(void * handle, const uschar * filename, uschar * query, int length,
+ uschar ** result, uschar ** errmsg, uint * do_cache)
{
int sep = 0;
uschar *server;
diff --git a/src/src/lookups/passwd.c b/src/src/lookups/passwd.c
index 315677f..58222f6 100644
--- a/src/src/lookups/passwd.c
+++ b/src/src/lookups/passwd.c
@@ -16,7 +16,7 @@
/* See local README for interface description */
static void *
-passwd_open(uschar *filename, uschar **errmsg)
+passwd_open(const uschar * filename, uschar ** errmsg)
{
filename = filename; /* Keep picky compilers happy */
errmsg = errmsg;
@@ -33,8 +33,8 @@ return (void *)(-1); /* Just return something non-null */
/* See local README for interface description */
static int
-passwd_find(void *handle, uschar *filename, const uschar *keystring, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+passwd_find(void * handle, const uschar * filename, const uschar * keystring,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
struct passwd *pw;
diff --git a/src/src/lookups/pgsql.c b/src/src/lookups/pgsql.c
index b5f6093..cf287b1 100644
--- a/src/src/lookups/pgsql.c
+++ b/src/src/lookups/pgsql.c
@@ -33,7 +33,7 @@ static pgsql_connection *pgsql_connections = NULL;
/* See local README for interface description. */
static void *
-pgsql_open(uschar *filename, uschar **errmsg)
+pgsql_open(const uschar * filename, uschar ** errmsg)
{
return (void *)(1); /* Just return something non-null */
}
@@ -381,8 +381,8 @@ query is deferred with a retryable error is now in a separate function that is
shared with other SQL lookups. */
static int
-pgsql_find(void *handle, uschar *filename, const uschar *query, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+pgsql_find(void * handle, const uschar * filename, const uschar * query,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
return lf_sqlperform(US"PostgreSQL", US"pgsql_servers", pgsql_servers, query,
result, errmsg, do_cache, perform_pgsql_search);
diff --git a/src/src/lookups/redis.c b/src/src/lookups/redis.c
index 53bd8d5..b5c2eda 100644
--- a/src/src/lookups/redis.c
+++ b/src/src/lookups/redis.c
@@ -28,7 +28,7 @@ static redis_connection *redis_connections = NULL;
static void *
-redis_open(uschar *filename, uschar **errmsg)
+redis_open(const uschar * filename, uschar ** errmsg)
{
return (void *)(1);
}
@@ -374,10 +374,10 @@ else
*/
static int
-redis_find(void *handle __attribute__((unused)),
- uschar *filename __attribute__((unused)),
- const uschar *command, int length, uschar **result, uschar **errmsg,
- uint *do_cache)
+redis_find(void * handle __attribute__((unused)),
+ const uschar * filename __attribute__((unused)),
+ const uschar * command, int length, uschar ** result, uschar ** errmsg,
+ uint * do_cache)
{
return lf_sqlperform(US"Redis", US"redis_servers", redis_servers, command,
result, errmsg, do_cache, perform_redis_search);
diff --git a/src/src/lookups/spf.c b/src/src/lookups/spf.c
index c84b6bb..243c271 100644
--- a/src/src/lookups/spf.c
+++ b/src/src/lookups/spf.c
@@ -35,7 +35,7 @@ extern SPF_dns_server_t * SPF_dns_exim_new(int);
static void *
-spf_open(uschar *filename, uschar **errmsg)
+spf_open(const uschar * filename, uschar ** errmsg)
{
SPF_dns_server_t * dc;
SPF_server_t *spf_server = NULL;
@@ -64,8 +64,8 @@ if (spf_server) SPF_server_free(spf_server);
}
static int
-spf_find(void *handle, uschar *filename, const uschar *keystring, int key_len,
- uschar **result, uschar **errmsg, uint *do_cache)
+spf_find(void * handle, const uschar * filename, const uschar * keystring,
+ int key_len, uschar ** result, uschar ** errmsg, uint * do_cache)
{
SPF_server_t *spf_server = handle;
SPF_request_t *spf_request;
diff --git a/src/src/lookups/sqlite.c b/src/src/lookups/sqlite.c
index 6200d6c..cf68b12 100644
--- a/src/src/lookups/sqlite.c
+++ b/src/src/lookups/sqlite.c
@@ -18,13 +18,12 @@
/* See local README for interface description. */
static void *
-sqlite_open(uschar *filename, uschar **errmsg)
+sqlite_open(const uschar * filename, uschar ** errmsg)
{
sqlite3 *db = NULL;
int ret;
-ret = sqlite3_open(CS filename, &db);
-if (ret != 0)
+if ((ret = sqlite3_open(CCS filename, &db)) != 0)
{
*errmsg = (void *)sqlite3_errmsg(db);
debug_printf_indent("Error opening database: %s\n", *errmsg);
@@ -70,8 +69,8 @@ return 0;
static int
-sqlite_find(void *handle, uschar *filename, const uschar *query, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+sqlite_find(void * handle, const uschar * filename, const uschar * query,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
int ret;
gstring * res = NULL;
diff --git a/src/src/lookups/testdb.c b/src/src/lookups/testdb.c
index 3f19e80..a4f0af7 100644
--- a/src/src/lookups/testdb.c
+++ b/src/src/lookups/testdb.c
@@ -21,7 +21,7 @@ the find function. */
/* See local README for interface description. */
static void *
-testdb_open(uschar *filename, uschar **errmsg)
+testdb_open(const uschar * filename, uschar ** errmsg)
{
filename = filename; /* Keep picky compilers happy */
errmsg = errmsg;
@@ -37,8 +37,8 @@ return (void *)(1); /* Just return something non-null */
/* See local README for interface description. */
static int
-testdb_find(void *handle, uschar *filename, const uschar *query, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+testdb_find(void * handle, const uschar * filename, const uschar * query,
+ int length, uschar ** result, uschar ** errmsg, uint * do_cache)
{
handle = handle; /* Keep picky compilers happy */
filename = filename;
diff --git a/src/src/lookups/whoson.c b/src/src/lookups/whoson.c
index 8f065e6..20d0133 100644
--- a/src/src/lookups/whoson.c
+++ b/src/src/lookups/whoson.c
@@ -20,7 +20,7 @@
/* See local README for interface description. */
static void *
-whoson_open(uschar *filename, uschar **errmsg)
+whoson_open(const uschar * filename, uschar ** errmsg)
{
filename = filename; /* Keep picky compilers happy */
errmsg = errmsg;
@@ -35,8 +35,8 @@ return (void *)(1); /* Just return something non-null */
/* See local README for interface description. */
static int
-whoson_find(void *handle, uschar *filename, uschar *query, int length,
- uschar **result, uschar **errmsg, uint *do_cache)
+whoson_find(void * handle, const uschar * filename, uschar * query, int length,
+ uschar ** result, uschar ** errmsg, uint * do_cache)
{
uschar buffer[80];
handle = handle; /* Keep picky compilers happy */
diff --git a/src/src/search.c b/src/src/search.c
index dc90f53..d67bdc5 100644
--- a/src/src/search.c
+++ b/src/src/search.c
@@ -325,8 +325,8 @@ Returns: an identifying handle for the open database;
*/
void *
-search_open(uschar *filename, int search_type, int modemask, uid_t *owners,
- gid_t *owngroups)
+search_open(const uschar * filename, int search_type, int modemask,
+ uid_t * owners, gid_t * owngroups)
{
void *handle;
tree_node *t;
@@ -462,7 +462,7 @@ Returns: a pointer to a dynamic string containing the answer,
*/
static uschar *
-internal_search_find(void *handle, uschar *filename, uschar *keystring)
+internal_search_find(void * handle, const uschar * filename, uschar * keystring)
{
tree_node * t = (tree_node *)handle;
search_cache * c = (search_cache *)(t->data.ptr);
@@ -605,8 +605,9 @@ Returns: a pointer to a dynamic string containing the answer,
*/
uschar *
-search_find(void *handle, uschar *filename, uschar *keystring, int partial,
- const uschar *affix, int affixlen, int starflags, int *expand_setup)
+search_find(void * handle, const uschar * filename, uschar * keystring,
+ int partial, const uschar * affix, int affixlen, int starflags,
+ int * expand_setup)
{
tree_node *t = (tree_node *)handle;
BOOL set_null_wild = FALSE;