1 /*++
2 /* NAME
3 /* opened 3
4 /* SUMMARY
5 /* log that a message was opened
6 /* SYNOPSIS
7 /* #include <opened.h>
8 /*
9 /* void opened(queue_id, sender, size, nrcpt, format, ...)
10 /* const char *queue_id;
11 /* const char *sender;
12 /* long size;
13 /* int nrcpt;
14 /* const char *format;
15 /* DESCRIPTION
16 /* opened() logs that a message was successfully delivered.
17 /*
18 /* vopened() implements an alternative interface.
19 /*
20 /* Arguments:
21 /* .IP queue_id
22 /* Message queue ID.
23 /* .IP sender
24 /* Sender address.
25 /* .IP size
26 /* Message content size.
27 /* .IP nrcpt
28 /* Number of recipients.
29 /* .IP format
30 /* Format of optional text.
31 /* DIAGNOSTICS
32 /* Fatal: out of memory.
33 /* BUGS
34 /* Should be replaced by routines with an attribute-value based
35 /* interface instead of an interface that uses a rigid argument list.
36 /* LICENSE
37 /* .ad
38 /* .fi
39 /* The Secure Mailer license must be distributed with this software.
40 /* AUTHOR(S)
41 /* Wietse Venema
42 /* IBM T.J. Watson Research
43 /* P.O. Box 704
44 /* Yorktown Heights, NY 10598, USA
45 /*
46 /* Wietse Venema
47 /* Google, Inc.
48 /* 111 8th Avenue
49 /* New York, NY 10011, USA
50 /*--*/
51
52 /* System library. */
53
54 #include <sys_defs.h>
55 #include <stdlib.h> /* 44BSD stdarg.h uses abort() */
56 #include <stdarg.h>
57
58 /* Utility library. */
59
60 #include <msg.h>
61 #include <vstring.h>
62
63 /* Global library. */
64
65 #include <opened.h>
66 #include <info_log_addr_form.h>
67
68 /* opened - log that a message was opened */
69
opened(const char * queue_id,const char * sender,long size,int nrcpt,const char * fmt,...)70 void opened(const char *queue_id, const char *sender, long size, int nrcpt,
71 const char *fmt,...)
72 {
73 va_list ap;
74
75 va_start(ap, fmt);
76 vopened(queue_id, sender, size, nrcpt, fmt, ap);
77 va_end(ap);
78 }
79
80 /* vopened - log that a message was opened */
81
vopened(const char * queue_id,const char * sender,long size,int nrcpt,const char * fmt,va_list ap)82 void vopened(const char *queue_id, const char *sender, long size, int nrcpt,
83 const char *fmt, va_list ap)
84 {
85 VSTRING *text = vstring_alloc(100);
86
87 #define TEXT (vstring_str(text))
88
89 vstring_vsprintf(text, fmt, ap);
90 msg_info("%s: from=<%s>, size=%ld, nrcpt=%d%s%s%s",
91 queue_id, info_log_addr_form_sender(sender), size, nrcpt,
92 *TEXT ? " (" : "", TEXT, *TEXT ? ")" : "");
93 vstring_free(text);
94 }
95