8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / mail / poplist.c
blob7f8614e52fdf5bef2dbce4d52f366188fc533275
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
26 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 2. */
27 #include "mail.h"
29 * Remove an entry from its linked list and free any malloc'd memory..
31 void poplist (hdrtype, where)
32 register int hdrtype;
33 register int where;
35 struct hdrs *hdr2rm, *cont2rm, *nextcont;
37 /* Remove first/last entry from list */
39 hdr2rm = (where == HEAD ?
40 hdrlines[hdrtype].head : hdrlines[hdrtype].tail);
42 if (hdr2rm == (struct hdrs *)NULL) {
43 return;
45 if (where == HEAD) {
46 if (hdr2rm->next == (struct hdrs *)NULL) {
47 /* Only 1 entry in list */
48 hdrlines[hdrtype].head = hdrlines[hdrtype].tail =
49 (struct hdrs *)NULL;
50 } else {
51 hdrlines[hdrtype].head = hdr2rm->next;
52 hdr2rm->next->prev = (struct hdrs *)NULL;
54 } else {
55 if (hdr2rm->prev == (struct hdrs *)NULL) {
56 /* Only 1 entry in list */
57 hdrlines[hdrtype].head = hdrlines[hdrtype].tail =
58 (struct hdrs *)NULL;
59 } else {
60 hdrlines[hdrtype].tail = hdr2rm->prev;
61 hdr2rm->prev->next = (struct hdrs *)NULL;
64 /* Keep track of total bytes added to message due to */
65 /* selected lines in case non-delivery */
66 /* notification needs to be sent. (See also copylet()) */
67 if (hdrtype == H_AFWDFROM) {
68 affbytecnt -=
69 (strlen(header[H_AFWDFROM].tag) + strlen(hdr2rm->value) + 2);
70 affcnt--;
72 if (hdrtype == H_RECEIVED) {
73 rcvbytecnt -=
74 (strlen(header[H_RECEIVED].tag) + strlen(hdr2rm->value) + 2);
77 cont2rm = hdr2rm->cont;
78 while (cont2rm != (struct hdrs *)NULL) {
79 nextcont = cont2rm->next;
80 if (hdrtype == H_AFWDFROM) {
81 affbytecnt -= (strlen(cont2rm->value) + 1);
82 affcnt--;
84 if (hdrtype == H_RECEIVED) {
85 rcvbytecnt -= (strlen(cont2rm->value) + 1);
87 free ((char *)cont2rm);
88 cont2rm = nextcont;
90 free ((char *)hdr2rm);