1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 27*7c478bd9Sstevel@tonic-gate 28*7c478bd9Sstevel@tonic-gate /* 29*7c478bd9Sstevel@tonic-gate NAME 30*7c478bd9Sstevel@tonic-gate ckdlivopts - check delivery notification options 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate SYNOPSIS 33*7c478bd9Sstevel@tonic-gate int ckdlivopts(int tcopy_hdr, int *svopts) 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate DESCRIPTION 36*7c478bd9Sstevel@tonic-gate Check if delivery notification requested for message being 37*7c478bd9Sstevel@tonic-gate processed. Returns specified options as combined from H_DEFOPTS, 38*7c478bd9Sstevel@tonic-gate H_TROPTS, & H_TCOPY lines. 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate (Positive notification options) 41*7c478bd9Sstevel@tonic-gate 001 ==> /delivery requested 42*7c478bd9Sstevel@tonic-gate 002 ==> /nodelivery requested 43*7c478bd9Sstevel@tonic-gate (Negative notification options) 44*7c478bd9Sstevel@tonic-gate 010 ==> /report requested 45*7c478bd9Sstevel@tonic-gate 020 ==> /return requested 46*7c478bd9Sstevel@tonic-gate 040 ==> /ignore requested 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate Combinations are expected, i.e. - 011 ==> /delivery/report 49*7c478bd9Sstevel@tonic-gate If not specified, the assumed defaults are /nodelivery/return (rc=022) 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate The options discovered in the header are stored into svopts. 52*7c478bd9Sstevel@tonic-gate */ 53*7c478bd9Sstevel@tonic-gate #include "mail.h" 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate static void getopts(); 56*7c478bd9Sstevel@tonic-gate static void mergeopts(); 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate struct dlvopts { 59*7c478bd9Sstevel@tonic-gate int deliv; 60*7c478bd9Sstevel@tonic-gate int nodeliv; 61*7c478bd9Sstevel@tonic-gate int rept; 62*7c478bd9Sstevel@tonic-gate int rtrn; 63*7c478bd9Sstevel@tonic-gate int ign; 64*7c478bd9Sstevel@tonic-gate }; 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate int ckdlivopts(tcopy_hdr, svopts) 67*7c478bd9Sstevel@tonic-gate int tcopy_hdr; 68*7c478bd9Sstevel@tonic-gate int *svopts; 69*7c478bd9Sstevel@tonic-gate { 70*7c478bd9Sstevel@tonic-gate static char pn[] = "ckdlivopts"; 71*7c478bd9Sstevel@tonic-gate struct hdrs *hp; 72*7c478bd9Sstevel@tonic-gate struct dlvopts toopts, tropts, defopts; 73*7c478bd9Sstevel@tonic-gate int rc; 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate /* already done this once. no need to repeat..... */ 76*7c478bd9Sstevel@tonic-gate if (svopts && *svopts != 0) { 77*7c478bd9Sstevel@tonic-gate Dout(pn, 0, "*svopts = o%o\n", *svopts); 78*7c478bd9Sstevel@tonic-gate return (*svopts); 79*7c478bd9Sstevel@tonic-gate } 80*7c478bd9Sstevel@tonic-gate memset((char *)&defopts, 0, sizeof(struct dlvopts)); 81*7c478bd9Sstevel@tonic-gate if ((hp = hdrlines[H_DEFOPTS].head) != (struct hdrs *)NULL) { 82*7c478bd9Sstevel@tonic-gate Dout(pn, 3, "H_DEFOPTS line = '%s'\n", hp->value); 83*7c478bd9Sstevel@tonic-gate getopts(hp->value, &defopts); 84*7c478bd9Sstevel@tonic-gate } 85*7c478bd9Sstevel@tonic-gate memset((char *)&tropts, 0, sizeof(struct dlvopts)); 86*7c478bd9Sstevel@tonic-gate if ((hp = hdrlines[H_TROPTS].head) != (struct hdrs *)NULL) { 87*7c478bd9Sstevel@tonic-gate Dout(pn, 3, "H_TROPTS line = '%s'\n", hp->value); 88*7c478bd9Sstevel@tonic-gate getopts(hp->value, &tropts); 89*7c478bd9Sstevel@tonic-gate } 90*7c478bd9Sstevel@tonic-gate memset((char *)&toopts, 0, sizeof(struct dlvopts)); 91*7c478bd9Sstevel@tonic-gate if ((hp = hdrlines[tcopy_hdr].head) != (struct hdrs *)NULL) { 92*7c478bd9Sstevel@tonic-gate Dout(pn, 3,"H_TCOPY line = '%s'\n", hp->value); 93*7c478bd9Sstevel@tonic-gate getopts(hp->value, &toopts); 94*7c478bd9Sstevel@tonic-gate } 95*7c478bd9Sstevel@tonic-gate /* Combine options from different header lines. Precedence is */ 96*7c478bd9Sstevel@tonic-gate /* toopts --> tropts --> defopts. Results left in defopts */ 97*7c478bd9Sstevel@tonic-gate mergeopts(&tropts,&defopts); 98*7c478bd9Sstevel@tonic-gate mergeopts(&toopts,&defopts); 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate if (defopts.deliv) rc = DELIVERY; 101*7c478bd9Sstevel@tonic-gate else rc = NODELIVERY; 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate if (defopts.rtrn) rc += RETURN; 104*7c478bd9Sstevel@tonic-gate else if (defopts.rept) rc += REPORT; 105*7c478bd9Sstevel@tonic-gate else if (defopts.ign) rc += IGNORE; 106*7c478bd9Sstevel@tonic-gate else rc += RETURN; 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate Dout(pn, 0,"returning = o%o\n", rc); 109*7c478bd9Sstevel@tonic-gate if (svopts) 110*7c478bd9Sstevel@tonic-gate *svopts = rc; 111*7c478bd9Sstevel@tonic-gate return (rc); 112*7c478bd9Sstevel@tonic-gate } 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate /* 115*7c478bd9Sstevel@tonic-gate * Pick transport options off of header line. 116*7c478bd9Sstevel@tonic-gate * If conflicting options found, use MOST demanding; i.e. - /delivery/return. 117*7c478bd9Sstevel@tonic-gate */ 118*7c478bd9Sstevel@tonic-gate static void getopts(s, optr) 119*7c478bd9Sstevel@tonic-gate register char *s; 120*7c478bd9Sstevel@tonic-gate register struct dlvopts *optr; 121*7c478bd9Sstevel@tonic-gate { 122*7c478bd9Sstevel@tonic-gate register char *op; 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate for (op = strchr (s, '/'); op++; op = strchr(op, '/')) { 125*7c478bd9Sstevel@tonic-gate if (casncmp(op, "delivery", 7) == 0) { 126*7c478bd9Sstevel@tonic-gate optr->deliv = 1; 127*7c478bd9Sstevel@tonic-gate optr->nodeliv = 0; 128*7c478bd9Sstevel@tonic-gate } else if (casncmp(op, "nodelivery", 10) == 0) { 129*7c478bd9Sstevel@tonic-gate if (optr->deliv == 0) { 130*7c478bd9Sstevel@tonic-gate optr->nodeliv = 1; 131*7c478bd9Sstevel@tonic-gate } 132*7c478bd9Sstevel@tonic-gate } else if (casncmp(op, "report", 6) == 0) { 133*7c478bd9Sstevel@tonic-gate optr->ign = 0; 134*7c478bd9Sstevel@tonic-gate if (optr->rtrn == 0) { 135*7c478bd9Sstevel@tonic-gate optr->rept = 1; 136*7c478bd9Sstevel@tonic-gate } 137*7c478bd9Sstevel@tonic-gate } else if (casncmp(op, "return", 6) == 0) { 138*7c478bd9Sstevel@tonic-gate optr->rtrn = 1; 139*7c478bd9Sstevel@tonic-gate optr->rept = optr->ign = 0; 140*7c478bd9Sstevel@tonic-gate } else if (casncmp(op, "ignore", 6) == 0) { 141*7c478bd9Sstevel@tonic-gate optr->rept = 0; 142*7c478bd9Sstevel@tonic-gate if (optr->rtrn == 0) { 143*7c478bd9Sstevel@tonic-gate optr->ign = 1; 144*7c478bd9Sstevel@tonic-gate } 145*7c478bd9Sstevel@tonic-gate } 146*7c478bd9Sstevel@tonic-gate } 147*7c478bd9Sstevel@tonic-gate } 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate /* 150*7c478bd9Sstevel@tonic-gate * Merge options between 2 sets. Higher set has precedence. 151*7c478bd9Sstevel@tonic-gate * Results left in lower set. 152*7c478bd9Sstevel@tonic-gate */ 153*7c478bd9Sstevel@tonic-gate static void mergeopts(higher, lower) 154*7c478bd9Sstevel@tonic-gate register struct dlvopts *higher, *lower; 155*7c478bd9Sstevel@tonic-gate { 156*7c478bd9Sstevel@tonic-gate if (higher->deliv == 1) { 157*7c478bd9Sstevel@tonic-gate lower->deliv = 1; 158*7c478bd9Sstevel@tonic-gate lower->nodeliv = 0; 159*7c478bd9Sstevel@tonic-gate } 160*7c478bd9Sstevel@tonic-gate if (higher->nodeliv == 1) { 161*7c478bd9Sstevel@tonic-gate lower->nodeliv = 1; 162*7c478bd9Sstevel@tonic-gate lower->deliv = 0; 163*7c478bd9Sstevel@tonic-gate } 164*7c478bd9Sstevel@tonic-gate if (higher->rept == 1) { 165*7c478bd9Sstevel@tonic-gate lower->rept = 1; 166*7c478bd9Sstevel@tonic-gate lower->rtrn = lower->ign = 0; 167*7c478bd9Sstevel@tonic-gate } 168*7c478bd9Sstevel@tonic-gate if (higher->rtrn == 1) { 169*7c478bd9Sstevel@tonic-gate lower->rtrn = 1; 170*7c478bd9Sstevel@tonic-gate lower->rept = lower->ign = 0; 171*7c478bd9Sstevel@tonic-gate } 172*7c478bd9Sstevel@tonic-gate if (higher->ign == 1) { 173*7c478bd9Sstevel@tonic-gate lower->ign = 1; 174*7c478bd9Sstevel@tonic-gate lower->rept = lower->rtrn = 0; 175*7c478bd9Sstevel@tonic-gate } 176*7c478bd9Sstevel@tonic-gate } 177