1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
24
25 #include "mail.h"
26 /*
27 * Remove an entry from its linked list and free any malloc'd memory..
28 */
poplist(hdrtype,where)29 void poplist (hdrtype, where)
30 register int hdrtype;
31 register int where;
32 {
33 struct hdrs *hdr2rm, *cont2rm, *nextcont;
34
35 /* Remove first/last entry from list */
36
37 hdr2rm = (where == HEAD ?
38 hdrlines[hdrtype].head : hdrlines[hdrtype].tail);
39
40 if (hdr2rm == (struct hdrs *)NULL) {
41 return;
42 }
43 if (where == HEAD) {
44 if (hdr2rm->next == (struct hdrs *)NULL) {
45 /* Only 1 entry in list */
46 hdrlines[hdrtype].head = hdrlines[hdrtype].tail =
47 (struct hdrs *)NULL;
48 } else {
49 hdrlines[hdrtype].head = hdr2rm->next;
50 hdr2rm->next->prev = (struct hdrs *)NULL;
51 }
52 } else {
53 if (hdr2rm->prev == (struct hdrs *)NULL) {
54 /* Only 1 entry in list */
55 hdrlines[hdrtype].head = hdrlines[hdrtype].tail =
56 (struct hdrs *)NULL;
57 } else {
58 hdrlines[hdrtype].tail = hdr2rm->prev;
59 hdr2rm->prev->next = (struct hdrs *)NULL;
60 }
61 }
62 /* Keep track of total bytes added to message due to */
63 /* selected lines in case non-delivery */
64 /* notification needs to be sent. (See also copylet()) */
65 if (hdrtype == H_AFWDFROM) {
66 affbytecnt -=
67 (strlen(header[H_AFWDFROM].tag) + strlen(hdr2rm->value) + 2);
68 affcnt--;
69 }
70 if (hdrtype == H_RECEIVED) {
71 rcvbytecnt -=
72 (strlen(header[H_RECEIVED].tag) + strlen(hdr2rm->value) + 2);
73 }
74
75 cont2rm = hdr2rm->cont;
76 while (cont2rm != (struct hdrs *)NULL) {
77 nextcont = cont2rm->next;
78 if (hdrtype == H_AFWDFROM) {
79 affbytecnt -= (strlen(cont2rm->value) + 1);
80 affcnt--;
81 }
82 if (hdrtype == H_RECEIVED) {
83 rcvbytecnt -= (strlen(cont2rm->value) + 1);
84 }
85 free ((char *)cont2rm);
86 cont2rm = nextcont;
87 }
88 free ((char *)hdr2rm);
89 }
90