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