1 /* $NetBSD: deliver_attr.c,v 1.1.1.1 2009/06/23 10:08:48 tron Exp $ */ 2 3 /*++ 4 /* NAME 5 /* deliver_attr 3 6 /* SUMMARY 7 /* initialize message delivery attributes 8 /* SYNOPSIS 9 /* #include "local.h" 10 /* 11 /* void deliver_attr_init(attrp) 12 /* DELIVER_ATTR *attrp; 13 /* 14 /* void deliver_attr_dump(attrp) 15 /* DELIVER_ATTR *attrp; 16 /* 17 /* void deliver_attr_free(attrp) 18 /* DELIVER_ATTR *attrp; 19 /* DESCRIPTION 20 /* deliver_attr_init() initializes a structure with message delivery 21 /* attributes to a known initial state (all zeros). 22 /* 23 /* deliver_attr_dump() logs the contents of the given attribute list. 24 /* 25 /* deliver_attr_free() releases memory that was allocated by 26 /* deliver_attr_init(). 27 /* LICENSE 28 /* .ad 29 /* .fi 30 /* The Secure Mailer license must be distributed with this software. 31 /* AUTHOR(S) 32 /* Wietse Venema 33 /* IBM T.J. Watson Research 34 /* P.O. Box 704 35 /* Yorktown Heights, NY 10598, USA 36 /*--*/ 37 38 /* System library. */ 39 40 #include <sys_defs.h> 41 #include <unistd.h> 42 43 /* Utility library. */ 44 45 #include <msg.h> 46 #include <vstream.h> 47 #include <vstring.h> 48 49 /* Application-specific. */ 50 51 #include "local.h" 52 53 /* deliver_attr_init - set message delivery attributes to all-zero state */ 54 55 void deliver_attr_init(DELIVER_ATTR *attrp) 56 { 57 attrp->level = 0; 58 attrp->fp = 0; 59 attrp->queue_name = 0; 60 attrp->queue_id = 0; 61 attrp->offset = 0; 62 attrp->sender = 0; 63 RECIPIENT_ASSIGN(&(attrp->rcpt), 0, 0, 0, 0, 0); 64 attrp->domain = 0; 65 attrp->local = 0; 66 attrp->user = 0; 67 attrp->extension = 0; 68 attrp->unmatched = 0; 69 attrp->owner = 0; 70 attrp->delivered = 0; 71 attrp->relay = 0; 72 attrp->exp_type = 0; 73 attrp->exp_from = 0; 74 attrp->why = dsb_create(); 75 } 76 77 /* deliver_attr_dump - log message delivery attributes */ 78 79 void deliver_attr_dump(DELIVER_ATTR *attrp) 80 { 81 msg_info("level: %d", attrp->level); 82 msg_info("path: %s", VSTREAM_PATH(attrp->fp)); 83 msg_info("fp: 0x%lx", (long) attrp->fp); 84 msg_info("queue_name: %s", attrp->queue_name ? attrp->queue_name : "null"); 85 msg_info("queue_id: %s", attrp->queue_id ? attrp->queue_id : "null"); 86 msg_info("offset: %ld", attrp->rcpt.offset); 87 msg_info("sender: %s", attrp->sender ? attrp->sender : "null"); 88 msg_info("recipient: %s", attrp->rcpt.address ? attrp->rcpt.address : "null"); 89 msg_info("domain: %s", attrp->domain ? attrp->domain : "null"); 90 msg_info("local: %s", attrp->local ? attrp->local : "null"); 91 msg_info("user: %s", attrp->user ? attrp->user : "null"); 92 msg_info("extension: %s", attrp->extension ? attrp->extension : "null"); 93 msg_info("unmatched: %s", attrp->unmatched ? attrp->unmatched : "null"); 94 msg_info("owner: %s", attrp->owner ? attrp->owner : "null"); 95 msg_info("delivered: %s", attrp->delivered ? attrp->delivered : "null"); 96 msg_info("relay: %s", attrp->relay ? attrp->relay : "null"); 97 msg_info("exp_type: %d", attrp->exp_type); 98 msg_info("exp_from: %s", attrp->exp_from ? attrp->exp_from : "null"); 99 msg_info("why: %s", attrp->why ? "buffer" : "null"); 100 } 101 102 /* deliver_attr_free - release storage */ 103 104 void deliver_attr_free(DELIVER_ATTR *attrp) 105 { 106 dsb_free(attrp->why); 107 } 108