X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsrc%2Fspool_mbox.c;h=e96dca48f25ef004a3ff6ec04a67a4c95257a7ff;hb=2e88a017b6c7a845bc223b2b883e10828407c00c;hp=dd5d73b7ae794af5412aaa6945a558e2f096a591;hpb=c58b88df956cd5f2b2febc6c447d8549928b454b;p=exim.git diff --git a/src/src/spool_mbox.c b/src/src/spool_mbox.c index dd5d73b7a..e96dca48f 100644 --- a/src/src/spool_mbox.c +++ b/src/src/spool_mbox.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/spool_mbox.c,v 1.8 2005/07/01 10:49:02 ph10 Exp $ */ +/* $Cambridge: exim/src/src/spool_mbox.c,v 1.10 2005/08/01 14:41:25 ph10 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -48,14 +48,14 @@ FILE *spool_mbox(unsigned long *mbox_file_size) { }; /* create temp directory inside scan dir */ - snprintf(CS mbox_path, 1024, "%s/scan/%s", spool_directory, message_id); + (void)string_format(mbox_path, 1024, "%s/scan/%s", spool_directory, message_id); if (!directory_make(NULL, mbox_path, 0750, FALSE)) { debug_printf("unable to create directory: %s/scan/%s\n", spool_directory, message_id); return NULL; }; /* open [message_id].eml file for writing */ - snprintf(CS mbox_path, 1024, "%s/scan/%s/%s.eml", spool_directory, message_id, message_id); + (void)string_format(mbox_path, 1024, "%s/scan/%s/%s.eml", spool_directory, message_id, message_id); mbox_file = Ufopen(mbox_path,"wb"); if (mbox_file == NULL) { @@ -134,10 +134,22 @@ FILE *spool_mbox(unsigned long *mbox_file_size) { break; }; - (void)fread(data_buffer, 1, 18, data_file); + /* The code used to use this line, but it doesn't work in Cygwin. + * + * (void)fread(data_buffer, 1, 18, data_file); + * + * What's happening is that spool_mbox used to use an fread to jump over the + * file header. That fails under Cygwin because the header is locked, but + * doing an fseek succeeds. We have to output the leading newline + * explicitly, because the one in the file is parted of the locked area. + */ + + (void)fwrite("\n", 1, 1, mbox_file); + (void)fseek(data_file, SPOOL_DATA_START_OFFSET, SEEK_SET); do { j = fread(data_buffer, 1, sizeof(data_buffer), data_file); + if (j > 0) { i = fwrite(data_buffer, 1, j, mbox_file); if (i != j) { @@ -155,7 +167,7 @@ FILE *spool_mbox(unsigned long *mbox_file_size) { spool_mbox_ok = 1; }; - snprintf(CS mbox_path, 1024, "%s/scan/%s/%s.eml", spool_directory, message_id, message_id); + (void)string_format(mbox_path, 1024, "%s/scan/%s/%s.eml", spool_directory, message_id, message_id); /* get the size of the mbox message */ stat(CS mbox_path, &statbuf); @@ -192,7 +204,7 @@ void unspool_mbox(void) { struct dirent *entry; DIR *tempdir; - snprintf(CS mbox_path, 1024, "%s/scan/%s", spool_directory, spooled_message_id); + (void)string_format(mbox_path, 1024, "%s/scan/%s", spool_directory, spooled_message_id); tempdir = opendir(CS mbox_path); /* loop thru dir & delete entries */ @@ -200,7 +212,7 @@ void unspool_mbox(void) { do { entry = readdir(tempdir); if (entry == NULL) break; - snprintf(CS file_path, 1024,"%s/scan/%s/%s", spool_directory, spooled_message_id, entry->d_name); + (void)string_format(file_path, 1024,"%s/scan/%s/%s", spool_directory, spooled_message_id, entry->d_name); if ( (Ustrcmp(entry->d_name,"..") != 0) && (Ustrcmp(entry->d_name,".") != 0) ) { debug_printf("unspool_mbox(): unlinking '%s'\n", file_path); n = unlink(CS file_path);