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
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]
22 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
23 /* All Rights Reserved */
25 #pragma ident "%Z%%M% %I% %E% SMI"
29 * link new entry into list of headerlines encountered of this type.
30 * If contflg == TRUE, link this line to the end of the continuation lines
31 * for the headerline specified (head or tail of type hdrtype).
33 void pushlist(hdrtype
, where
, s
, contflg
)
38 static char pn
[] = "pushlist";
40 struct hdrs
*nhp
, *ohp
, *nextcont
;
42 /* Keep track of total bytes added to message due to */
43 /* certain lines in case non-delivery */
44 /* notification needs to be sent. (See also copylet()) */
45 if (hdrtype
== H_AFWDFROM
) {
46 affbytecnt
+= (strlen(s
) + ((contflg
== TRUE
) ?
48 (strlen(header
[H_AFWDFROM
].tag
) + 2)) );
49 if (contflg
== FALSE
) {
53 if (hdrtype
== H_RECEIVED
) {
54 rcvbytecnt
+= (strlen(s
) + ((contflg
== TRUE
) ?
56 (strlen(header
[H_RECEIVED
].tag
) + 2)) );
58 if ((p
= malloc(sizeof(struct hdrs
))) == (char *)NULL
) {
59 errmsg(E_MEM
,"malloc failed in pushlist()");
62 memset(p
, 0, sizeof(struct hdrs
));
64 ohp
= (where
== HEAD
? hdrlines
[hdrtype
].head
: hdrlines
[hdrtype
].tail
);
65 nhp
= (struct hdrs
*)p
;
67 (void) strlcpy(nhp
->value
, s
, sizeof (nhp
->value
));
69 Dout(pn
, 0, "hdrtype = %d/%s, contflg = %d, saved value = '%s'\n",
70 hdrtype
, header
[hdrtype
].tag
, contflg
, s
);
73 if (ohp
== (struct hdrs
*)NULL
) {
74 /* This shouldn't happen.....? */
75 /* No headline of this type found so far. How */
76 /* did we think this is a continuation of something? */
78 Dout(pn
, 0, "H_CONT with no hdr yet\n");
81 /* Throw it on the floor... (!) */
83 /* Subtract anything that might have been added above */
84 if (hdrtype
== H_AFWDFROM
) {
85 affbytecnt
-= (strlen(s
) + ((contflg
== TRUE
) ?
87 (strlen(header
[H_AFWDFROM
].tag
) + 2)) );
89 if (hdrtype
== H_RECEIVED
) {
90 rcvbytecnt
-= (strlen(s
) + ((contflg
== TRUE
) ?
92 (strlen(header
[H_RECEIVED
].tag
) + 2)) );
97 /* Since we ONLY walk down 'cont' chains, */
98 /* we only need forward links */
100 while (nextcont
->cont
!= (struct hdrs
*)NULL
) {
101 nextcont
= nextcont
->cont
;
103 /* Add this one to end of list... */
104 nextcont
->cont
= nhp
;
108 /* link value from this header line to end of list for */
109 /* all header lines of the same type */
111 if (ohp
== (struct hdrs
*)NULL
) {
112 /* Empty list so far. New element goes first */
113 hdrlines
[hdrtype
].head
= hdrlines
[hdrtype
].tail
= nhp
;
116 /* Add new element to head of list */
118 hdrlines
[hdrtype
].head
= ohp
->prev
= nhp
;
120 /* Add new element to tail of list */
122 hdrlines
[hdrtype
].tail
= ohp
->next
= nhp
;