/* * @(#)return_messages.c 1.5 06/18/98 SMI * * Copyright 1997 by Sun Microsystems, Inc. * All rights reserved * * Dequeues messages from the specified channel, * and generate failed delivery status notifications * for all recipients of each message. * If the channel is not specified, the channel name used is "custom". * * Syntax: * return_messages [ -c channel_name ] */ #include #include #include #include immd_t md; static void check ( char *func, int status) { if ( status != 0 ) { printf( "ERROR %d in %s: %s\n", status, func, (char *)imta_error(status)); imta_end(); exit (status); } return; } static void usage() { printf("Usage:\n return_messages [ -c channel_name ]\n\n"); return; } main ( int argc, char **argv) { extern char *optarg; char c; char *channel = NULL; char *rcpt, *from, *orig_rcpt; int size, flags; /* parse command line */ while ((c = getopt(argc, argv, "c:")) != EOF) { switch (c) { case 'c': /* the recipient */ channel = (char *)strdup( optarg); break; default: usage(); exit( EX_USAGE); } } if ( channel == NULL ) channel = "custom"; /* initialize */ check( "imta_init", imta_init( channel) ); check( "immd_init", immd_init ( &md)); while ( immd_get_message ( md, &from, &size) == 0 ) { while ( immd_get_recipient( md, &flags, &rcpt, &orig_rcpt) == 0 ) { check( "immd_returnAddEntry", immd_return_add_entry( md, rcpt, orig_rcpt, NULL, IM_DLVSTAT_FAILED)); } check( "immd_return", immd_return( md)); check( "immd_dequeue", immd_dequeue(md)); } immd_end(md); imta_end(); }