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