-FILE *spool_mbox(unsigned long *mbox_file_size, uschar *source_file_override) {
- uschar message_subdir[2];
- uschar buffer[16384];
- uschar *temp_string;
- uschar *mbox_path;
- FILE *mbox_file = NULL;
- FILE *data_file = NULL;
- FILE *yield = NULL;
- header_line *my_headerlist;
- struct stat statbuf;
- int i, j;
- void *reset_point = store_get(0);
-
- mbox_path = string_sprintf("%s/scan/%s/%s.eml", spool_directory, message_id,
- message_id);
-
- /* Skip creation if already spooled out as mbox file */
- if (!spool_mbox_ok) {
- /* create temp directory inside scan dir, directory_make works recursively */
- temp_string = string_sprintf("scan/%s", message_id);
- if (!directory_make(spool_directory, temp_string, 0750, FALSE)) {
- log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
- "scan directory %s/scan/%s", spool_directory, temp_string));
- goto OUT;
- };
+FILE *
+spool_mbox(unsigned long *mbox_file_size, const uschar *source_file_override)
+{
+uschar message_subdir[2];
+uschar buffer[16384];
+uschar *temp_string;
+uschar *mbox_path;
+FILE *mbox_file = NULL;
+FILE *data_file = NULL;
+FILE *yield = NULL;
+header_line *my_headerlist;
+struct stat statbuf;
+int i, j;
+void *reset_point = store_get(0);
+
+mbox_path = string_sprintf("%s/scan/%s/%s.eml", spool_directory, message_id,
+ message_id);
+
+/* Skip creation if already spooled out as mbox file */
+if (!spool_mbox_ok)
+ {
+ /* create temp directory inside scan dir, directory_make works recursively */
+ temp_string = string_sprintf("scan/%s", message_id);
+ if (!directory_make(spool_directory, temp_string, 0750, FALSE))
+ {
+ log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
+ "scan directory %s/scan/%s", spool_directory, temp_string));
+ goto OUT;
+ }
+
+ /* open [message_id].eml file for writing */
+ mbox_file = modefopen(mbox_path, "wb", SPOOL_MODE);
+ if (mbox_file == NULL)
+ {
+ log_write(0, LOG_MAIN|LOG_PANIC, "%s", string_open_failed(errno,
+ "scan file %s", mbox_path));
+ goto OUT;
+ }
+
+ /* Generate mailbox headers. The $received_for variable is (up to at least
+ Exim 4.64) never set here, because it is only set when expanding the
+ contents of the Received: header line. However, the code below will use it
+ if it should become available in future. */