X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fsrc%2Ftransports%2Fautoreply.c;h=4a3fe47145c8e26be57fe774b041d29e7f5915fc;hb=cfb9cf20cb8112f45b4cb4f9106f290bfc7ede18;hp=54f9ef4de3fb276b5d1c2b79d6b436e163f7ea21;hpb=80fea873648ca2ab2e592999a336c59cf054ab55;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/src/src/transports/autoreply.c b/src/src/transports/autoreply.c index 54f9ef4de..4a3fe4714 100644 --- a/src/src/transports/autoreply.c +++ b/src/src/transports/autoreply.c @@ -62,6 +62,17 @@ address can appear in the tables drtables.c. */ int autoreply_transport_options_count = sizeof(autoreply_transport_options)/sizeof(optionlist); + +#ifdef MACRO_PREDEF + +/* Dummy values */ +autoreply_transport_options_block autoreply_transport_option_defaults = {0}; +void autoreply_transport_init(transport_instance *tblock) {} +BOOL autoreply_transport_entry(transport_instance *tblock, address_item *addr) {return FALSE;} + +#else /*!MACRO_PREDEF*/ + + /* Default private options block for the autoreply transport. */ autoreply_transport_options_block autoreply_transport_option_defaults = { @@ -484,8 +495,12 @@ if (oncelog != NULL && *oncelog != 0 && to != NULL) else { EXIM_DATUM key_datum, result_datum; - EXIM_DBOPEN(oncelog, O_RDWR|O_CREAT, ob->mode, &dbm_file); - if (dbm_file == NULL) + uschar * dirname = string_copy(oncelog); + uschar * s; + + if ((s = Ustrrchr(dirname, '/'))) *s = '\0'; + EXIM_DBOPEN(oncelog, dirname, O_RDWR|O_CREAT, ob->mode, &dbm_file); + if (!dbm_file) { addr->transport_return = DEFER; addr->message = string_sprintf("Failed to open %s file %s when sending " @@ -691,6 +706,17 @@ if (return_message) US"------ This is a copy of the body of the message, without the headers.\n" : US"------ This is a copy of the message, including all the headers.\n"; + transport_ctx tctx = { + fileno(f), + tblock, + addr, + NULL, NULL, + (tblock->body_only ? topt_no_headers : 0) | + (tblock->headers_only ? topt_no_body : 0) | + (tblock->return_path_add ? topt_add_return_path : 0) | + (tblock->delivery_date_add ? topt_add_delivery_date : 0) | + (tblock->envelope_to_add ? topt_add_envelope_to : 0) + }; if (bounce_return_size_limit > 0 && !tblock->headers_only) { @@ -710,14 +736,7 @@ if (return_message) fflush(f); transport_count = 0; - transport_write_message(addr, fileno(f), - (tblock->body_only? topt_no_headers : 0) | - (tblock->headers_only? topt_no_body : 0) | - (tblock->return_path_add? topt_add_return_path : 0) | - (tblock->delivery_date_add? topt_add_delivery_date : 0) | - (tblock->envelope_to_add? topt_add_envelope_to : 0), - bounce_return_size_limit, tblock->add_headers, tblock->remove_headers, - NULL, NULL, tblock->rewrite_rules, tblock->rewrite_existflags); + transport_write_message(&tctx, bounce_return_size_limit); } /* End the message and wait for the child process to end; no timeout. */ @@ -741,30 +760,32 @@ if (cache_fd >= 0) { uschar *from = cache_buff; int size = cache_size; - (void)lseek(cache_fd, 0, SEEK_SET); - if (cache_time == NULL) + if (lseek(cache_fd, 0, SEEK_SET) == 0) { - cache_time = from + size; - memcpy(cache_time + sizeof(time_t), to, add_size - sizeof(time_t)); - size += add_size; - - if (cache_size > 0 && size > ob->once_file_size) + if (!cache_time) { - from += sizeof(time_t) + Ustrlen(from + sizeof(time_t)) + 1; - size -= (from - cache_buff); + cache_time = from + size; + memcpy(cache_time + sizeof(time_t), to, add_size - sizeof(time_t)); + size += add_size; + + if (cache_size > 0 && size > ob->once_file_size) + { + from += sizeof(time_t) + Ustrlen(from + sizeof(time_t)) + 1; + size -= (from - cache_buff); + } } - } - memcpy(cache_time, &now, sizeof(time_t)); - if(write(cache_fd, from, size) != size) - DEBUG(D_transport) debug_printf("Problem writing cache file %s for %s " - "transport\n", oncelog, tblock->name); + memcpy(cache_time, &now, sizeof(time_t)); + if(write(cache_fd, from, size) != size) + DEBUG(D_transport) debug_printf("Problem writing cache file %s for %s " + "transport\n", oncelog, tblock->name); + } } /* Update DBM file */ -else if (dbm_file != NULL) +else if (dbm_file) { EXIM_DATUM key_datum, value_datum; EXIM_DATUM_INIT(key_datum); /* Some DBM libraries need to have */ @@ -865,7 +886,7 @@ if (logfile != NULL) } END_OFF: -if (dbm_file != NULL) EXIM_DBCLOSE(dbm_file); +if (dbm_file) EXIM_DBCLOSE(dbm_file); if (cache_fd > 0) (void)close(cache_fd); DEBUG(D_transport) debug_printf("%s transport succeeded\n", tblock->name); @@ -873,4 +894,5 @@ DEBUG(D_transport) debug_printf("%s transport succeeded\n", tblock->name); return FALSE; } +#endif /*!MACRO_PREDEF*/ /* End of transport/autoreply.c */