summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy Harris <jgh146exb@wizmail.org>2019-08-19 11:51:43 +0100
committerJeremy Harris <jgh146exb@wizmail.org>2019-08-19 11:51:43 +0100
commit59a93276e38d2d8ae297a9581a5388a475c209c1 (patch)
treeb9829ccd868f61ce9f344009bc5497b0fac82629 /src
parent9c6881f8f7cd820300c035a24d2d34567afc2040 (diff)
inlining
Diffstat (limited to 'src')
-rw-r--r--src/src/dcc.c19
-rw-r--r--src/src/functions.h48
-rw-r--r--src/src/queue.c35
-rw-r--r--src/src/receive.c2
-rw-r--r--src/src/spool_in.c4
-rw-r--r--src/src/spool_mbox.c2
-rw-r--r--src/src/transport.c12
7 files changed, 63 insertions, 59 deletions
diff --git a/src/src/dcc.c b/src/src/dcc.c
index 4c9c0964f..4c86c092b 100644
--- a/src/src/dcc.c
+++ b/src/src/dcc.c
@@ -60,7 +60,7 @@ dcc_process(uschar **listptr)
uschar *override_client_ip = NULL;
/* from local_scan */
- int i, j, k, c, retval, sockfd, resp, line;
+ int j, k, c, retval, sockfd, resp, line;
unsigned int portnr;
struct sockaddr_un serv_addr;
struct sockaddr_in serv_addr_in;
@@ -72,7 +72,6 @@ dcc_process(uschar **listptr)
uschar sendbuf[4096];
uschar recvbuf[4096];
uschar dcc_return_text[1024];
- uschar message_subdir[2];
struct header_line *dcchdr;
uschar *dcc_acl_options;
uschar dcc_acl_options_buffer[10];
@@ -98,11 +97,10 @@ dcc_process(uschar **listptr)
return dcc_rc;
/* open the spooled body */
- message_subdir[1] = '\0';
- for (i = 0; i < 2; i++)
+ for (int i = 0; i < 2; i++)
{
- message_subdir[0] = split_spool_directory == (i == 0) ? message_id[5] : 0;
-
+ uschar message_subdir[2];
+ set_subdir_str(message_subdir, message_id, i);
if ((data_file = Ufopen(
spool_fname(US"input", message_subdir, message_id, US"-D"),
"rb")))
@@ -244,7 +242,7 @@ dcc_process(uschar **listptr)
}
/* let's send each of the recipients to dccifd */
- for (i = 0; i < recipients_count; i++){
+ for (int i = 0; i < recipients_count; i++){
DEBUG(D_acl)
debug_printf("DCC: recipient = %s\n",recipients_list[i].address);
if(Ustrlen(sendbuf) + Ustrlen(recipients_list[i].address) > sizeof(sendbuf))
@@ -281,7 +279,7 @@ dcc_process(uschar **listptr)
j = 0;
while(j < dcchdr->slen)
{
- for(i = 0; i < sizeof(sendbuf)-2; i++) {
+ for(int i = 0; i < sizeof(sendbuf)-2; i++) {
sendbuf[i] = dcchdr->text[j];
j++;
}
@@ -359,12 +357,11 @@ dcc_process(uschar **listptr)
debug_printf("DCC: Length of the output buffer is: %d\nDCC: Output buffer is:\nDCC: ------------\nDCC: %s\nDCC: -----------\n", c, recvbuf);
/* Now let's read each character and see what we've got */
- for(i = 0; i < c; i++) {
+ for(int i = 0; i < c; i++) {
/* First check if we reached the end of the line and
* then increment the line counter */
- if(recvbuf[i] == '\n') {
+ if(recvbuf[i] == '\n')
line++;
- }
else {
/* The first character of the first line is the
* overall response. If there's another character
diff --git a/src/src/functions.h b/src/src/functions.h
index 9f813d5ed..ee0ad139e 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -474,13 +474,10 @@ extern int spam(const uschar **);
extern FILE *spool_mbox(unsigned long *, const uschar *, uschar **);
#endif
extern void spool_clear_header_globals(void);
-extern uschar *spool_dname(const uschar *, uschar *);
-extern uschar *spool_fname(const uschar *, const uschar *, const uschar *, const uschar *);
extern BOOL spool_move_message(uschar *, uschar *, uschar *, uschar *);
extern int spool_open_datafile(uschar *);
extern int spool_open_temp(uschar *);
extern int spool_read_header(uschar *, BOOL, BOOL);
-extern uschar *spool_sname(const uschar *, uschar *);
extern int spool_write_header(uschar *, int, uschar **);
extern int stdin_getc(unsigned);
extern int stdin_feof(void);
@@ -859,6 +856,51 @@ store_get_dns_answer_trc(const uschar * func, unsigned line)
return store_get_3(sizeof(dns_answer), TRUE, CCS func, line); /* use tainted mem */
}
+/******************************************************************************/
+/* Routines with knowledge of spool layout */
+
+# ifndef COMPILE_UTILITY
+static inline void
+spool_pname_buf(uschar * buf, int len)
+{
+snprintf(CS buf, len, "%s/%s/input", spool_directory, queue_name);
+}
+
+static inline uschar *
+spool_dname(const uschar * purpose, uschar * subdir)
+{
+return string_sprintf("%s/%s/%s/%s",
+ spool_directory, queue_name, purpose, subdir);
+}
+# endif
+
+static inline uschar *
+spool_sname(const uschar * purpose, uschar * subdir)
+{
+return string_sprintf("%s%s%s%s%s",
+ queue_name, *queue_name ? "/" : "",
+ purpose,
+ *subdir ? "/" : "", subdir);
+}
+
+static inline uschar *
+spool_fname(const uschar * purpose, const uschar * subdir, const uschar * fname,
+ const uschar * suffix)
+{
+return string_sprintf("%s/%s/%s/%s/%s%s",
+ spool_directory, queue_name, purpose, subdir, fname, suffix);
+}
+
+static void
+set_subdir_str(uschar * subdir_str, const uschar * name,
+ int search_sequence)
+{
+subdir_str[0] = split_spool_directory == (search_sequence == 0)
+ ? name[5] : '\0';
+subdir_str[1] = '\0';
+}
+
+/******************************************************************************/
#endif /* !MACRO_PREDEF */
#endif /* _FUNCTIONS_H_ */
diff --git a/src/src/queue.c b/src/src/queue.c
index a124782e9..f65c65262 100644
--- a/src/src/queue.c
+++ b/src/src/queue.c
@@ -12,39 +12,6 @@
-/* Routines with knowledge of spool layout */
-
-#ifndef COMPILE_UTILITY
-static void
-spool_pname_buf(uschar * buf, int len)
-{
-snprintf(CS buf, len, "%s/%s/input", spool_directory, queue_name);
-}
-
-uschar *
-spool_dname(const uschar * purpose, uschar * subdir)
-{
-return string_sprintf("%s/%s/%s/%s",
- spool_directory, queue_name, purpose, subdir);
-}
-#endif
-
-uschar *
-spool_sname(const uschar * purpose, uschar * subdir)
-{
-return string_sprintf("%s%s%s%s%s",
- queue_name, *queue_name ? "/" : "",
- purpose,
- *subdir ? "/" : "", subdir);
-}
-
-uschar *
-spool_fname(const uschar * purpose, const uschar * subdir, const uschar * fname,
- const uschar * suffix)
-{
-return string_sprintf("%s/%s/%s/%s/%s%s",
- spool_directory, queue_name, purpose, subdir, fname, suffix);
-}
@@ -1034,7 +1001,7 @@ if (action >= MSG_SHOW_BODY)
for (int i = 0; i < 2; i++)
{
- message_subdir[0] = split_spool_directory == (i == 0) ? id[5] : 0;
+ set_subdir_str(message_subdir, id, i);
if ((fd = Uopen(spool_fname(subdirectory, message_subdir, id, suffix),
O_RDONLY, 0)) >= 0)
break;
diff --git a/src/src/receive.c b/src/src/receive.c
index c7553f802..6b5a28d31 100644
--- a/src/src/receive.c
+++ b/src/src/receive.c
@@ -2694,7 +2694,7 @@ it will fit. */
to be the least significant base-62 digit of the time of arrival. Otherwise
ensure that it is an empty string. */
-message_subdir[0] = split_spool_directory ? message_id[5] : 0;
+set_subdir_str(message_subdir, message_id, 0);
/* Now that we have the message-id, if there is no message-id: header, generate
one, but only for local (without suppress_local_fixups) or submission mode
diff --git a/src/src/spool_in.c b/src/src/spool_in.c
index 101a6c40c..c70835c29 100644
--- a/src/src/spool_in.c
+++ b/src/src/spool_in.c
@@ -52,7 +52,7 @@ for (int i = 0; i < 2; i++)
uschar * fname;
int save_errno;
- message_subdir[0] = split_spool_directory == i ? '\0' : id[5];
+ set_subdir_str(message_subdir, id, i);
fname = spool_fname(US"input", message_subdir, id, US"-D");
DEBUG(D_deliver) debug_printf("Trying spool file %s\n", fname);
@@ -356,7 +356,7 @@ and unsplit directories, as for the data file above. */
for (int n = 0; n < 2; n++)
{
if (!subdir_set)
- message_subdir[0] = split_spool_directory == (n == 0) ? name[5] : 0;
+ set_subdir_str(message_subdir, name, n);
if ((fp = Ufopen(spool_fname(US"input", message_subdir, name, US""), "rb")))
break;
diff --git a/src/src/spool_mbox.c b/src/src/spool_mbox.c
index caf1712cf..7b6a79607 100644
--- a/src/src/spool_mbox.c
+++ b/src/src/spool_mbox.c
@@ -117,7 +117,7 @@ if (!spool_mbox_ok)
message_subdir[1] = '\0';
for (int i = 0; i < 2; i++)
{
- message_subdir[0] = split_spool_directory == (i == 0) ? message_id[5] : 0;
+ set_subdir_str(message_subdir, message_id, i);
temp_string = spool_fname(US"input", message_subdir, message_id, US"-D");
if ((l_data_file = Ufopen(temp_string, "rb"))) break;
}
diff --git a/src/src/transport.c b/src/src/transport.c
index ce02adbf2..13a039d8c 100644
--- a/src/src/transport.c
+++ b/src/src/transport.c
@@ -1722,16 +1722,14 @@ while (1)
for (i = msgq_count - 1; i >= 0; --i) if (msgq[i].bKeep)
{
uschar subdir[2];
+ uschar * mid = msgq[i].message_id;
- subdir[0] = split_spool_directory ? msgq[i].message_id[5] : 0;
- subdir[1] = 0;
-
- if (Ustat(spool_fname(US"input", subdir, msgq[i].message_id, US"-D"),
- &statbuf) != 0)
+ set_subdir_str(subdir, mid, 0);
+ if (Ustat(spool_fname(US"input", subdir, mid, US"-D"), &statbuf) != 0)
msgq[i].bKeep = FALSE;
- else if (!oicf_func || oicf_func(msgq[i].message_id, oicf_data))
+ else if (!oicf_func || oicf_func(mid, oicf_data))
{
- Ustrcpy_nt(new_message_id, msgq[i].message_id);
+ Ustrcpy_nt(new_message_id, mid);
msgq[i].bKeep = FALSE;
bFound = TRUE;
break;