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
47/* System library. */
48
49#include <sys_defs.h>
50#include <stdlib.h>			/* 44BSD stdarg.h uses abort() */
51#include <stdarg.h>
52
53/* Utility library. */
54
55#include <msg.h>
56#include <vstring.h>
57
58/* Global library. */
59
60#include "opened.h"
61
62/* opened - log that a message was opened */
63
64void    opened(const char *queue_id, const char *sender, long size, int nrcpt,
65	               const char *fmt,...)
66{
67    va_list ap;
68
69    va_start(ap, fmt);
70    vopened(queue_id, sender, size, nrcpt, fmt, ap);
71    va_end(ap);
72}
73
74/* vopened - log that a message was opened */
75
76void    vopened(const char *queue_id, const char *sender, long size, int nrcpt,
77		        const char *fmt, va_list ap)
78{
79    VSTRING *text = vstring_alloc(100);
80
81#define TEXT (vstring_str(text))
82
83    vstring_vsprintf(text, fmt, ap);
84    msg_info("%s: from=<%s>, size=%ld, nrcpt=%d%s%s%s",
85	     queue_id, sender, size, nrcpt,
86	     *TEXT ? " (" : "", TEXT, *TEXT ? ")" : "");
87    vstring_free(text);
88}
89