1 /* $NetBSD: dsb_scan.c,v 1.1.1.1 2009/06/23 10:08:45 tron Exp $ */ 2 3 /*++ 4 /* NAME 5 /* dsb_scan 6 /* SUMMARY 7 /* read DSN_BUF from stream 8 /* SYNOPSIS 9 /* #include <dsb_scan.h> 10 /* 11 /* int dsb_scan(scan_fn, stream, flags, ptr) 12 /* ATTR_SCAN_MASTER_FN scan_fn; 13 /* VSTREAM *stream; 14 /* int flags; 15 /* void *ptr; 16 /* DESCRIPTION 17 /* dsb_scan() reads a DSN_BUF from the named stream using the 18 /* specified attribute scan routine. dsb_scan() is meant 19 /* to be passed as a call-back to attr_scan(), thusly: 20 /* 21 /* ... ATTR_TYPE_FUNC, dsb_scan, (void *) &dsbuf, ... 22 /* DIAGNOSTICS 23 /* Fatal: out of memory. 24 /* LICENSE 25 /* .ad 26 /* .fi 27 /* The Secure Mailer license must be distributed with this software. 28 /* AUTHOR(S) 29 /* Wietse Venema 30 /* IBM T.J. Watson Research 31 /* P.O. Box 704 32 /* Yorktown Heights, NY 10598, USA 33 /*--*/ 34 35 /* System library. */ 36 37 #include <sys_defs.h> 38 39 /* Utility library. */ 40 41 #include <attr.h> 42 43 /* Global library. */ 44 45 #include <mail_proto.h> 46 #include <dsb_scan.h> 47 48 /* dsb_scan - read DSN_BUF from stream */ 49 50 int dsb_scan(ATTR_SCAN_MASTER_FN scan_fn, VSTREAM *fp, 51 int flags, void *ptr) 52 { 53 DSN_BUF *dsb = (DSN_BUF *) ptr; 54 int ret; 55 56 /* 57 * The attribute order is determined by backwards compatibility. It can 58 * be sanitized after all the ad-hoc DSN read/write code is replaced. 59 */ 60 ret = scan_fn(fp, flags | ATTR_FLAG_MORE, 61 ATTR_TYPE_STR, MAIL_ATTR_DSN_STATUS, dsb->status, 62 ATTR_TYPE_STR, MAIL_ATTR_DSN_DTYPE, dsb->dtype, 63 ATTR_TYPE_STR, MAIL_ATTR_DSN_DTEXT, dsb->dtext, 64 ATTR_TYPE_STR, MAIL_ATTR_DSN_MTYPE, dsb->mtype, 65 ATTR_TYPE_STR, MAIL_ATTR_DSN_MNAME, dsb->mname, 66 ATTR_TYPE_STR, MAIL_ATTR_DSN_ACTION, dsb->action, 67 ATTR_TYPE_STR, MAIL_ATTR_WHY, dsb->reason, 68 ATTR_TYPE_END); 69 return (ret == 7 ? 1 : -1); 70 } 71