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