Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / cleanup / cleanup_final.c
blobc7b27e9f4c83d333adb64bab18e468ef641b61d1
1 /* $NetBSD$ */
3 /*++
4 /* NAME
5 /* cleanup_final 3
6 /* SUMMARY
7 /* finalize queue file
8 /* SYNOPSIS
9 /* #include "cleanup.h"
11 /* void cleanup_final(state)
12 /* CLEANUP_STATE *state;
13 /* DESCRIPTION
14 /* cleanup_final() performs final queue file content (not
15 /* attribute) updates so that the file is ready to be closed.
16 /* LICENSE
17 /* .ad
18 /* .fi
19 /* The Secure Mailer license must be distributed with this software.
20 /* AUTHOR(S)
21 /* Wietse Venema
22 /* IBM T.J. Watson Research
23 /* P.O. Box 704
24 /* Yorktown Heights, NY 10598, USA
25 /*--*/
27 /* System library. */
29 #include <sys_defs.h>
30 #include <errno.h>
32 /* Utility library. */
34 #include <msg.h>
36 /* Global library. */
38 #include <cleanup_user.h>
39 #include <rec_type.h>
41 /* Application-specific. */
43 #include "cleanup.h"
45 /* cleanup_final - final queue file content updates */
47 void cleanup_final(CLEANUP_STATE *state)
49 const char *myname = "cleanup_final";
52 * vstream_fseek() would flush the buffer anyway, but the code just reads
53 * better if we flush first, because it makes seek error handling more
54 * straightforward.
56 if (vstream_fflush(state->dst)) {
57 if (errno == EFBIG) {
58 msg_warn("%s: queue file size limit exceeded", state->queue_id);
59 state->errs |= CLEANUP_STAT_SIZE;
60 } else {
61 msg_warn("%s: write queue file: %m", state->queue_id);
62 state->errs |= CLEANUP_STAT_WRITE;
64 return;
68 * Update the preliminary message size and count fields with the actual
69 * values.
71 if (vstream_fseek(state->dst, 0L, SEEK_SET) < 0)
72 msg_fatal("%s: vstream_fseek %s: %m", myname, cleanup_path);
73 cleanup_out_format(state, REC_TYPE_SIZE, REC_TYPE_SIZE_FORMAT,
74 (REC_TYPE_SIZE_CAST1) (state->xtra_offset - state->data_offset),
75 (REC_TYPE_SIZE_CAST2) state->data_offset,
76 (REC_TYPE_SIZE_CAST3) state->rcpt_count,
77 (REC_TYPE_SIZE_CAST4) state->qmgr_opts,
78 (REC_TYPE_SIZE_CAST5) state->cont_length);