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;
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];
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")))
}
/* 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))
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++;
}
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
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);
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_ */
-/* 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);
-}
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;
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
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);
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;
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;
}
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;