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]
23 * Copyright 1994 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
32 * University Copyright- Copyright (c) 1982, 1986, 1988
33 * The Regents of the University of California
36 * University Acknowledgment- Portions of this document are derived from
37 * software developed by the University of California, Berkeley, and its
41 #pragma ident "%Z%%M% %I% %E% SMI"
49 * mailx -- a modified version of a University of California at Berkeley
52 * Local version of fopen() and fclose(). These maintain a list of
53 * file pointers which can be run down when we need to close
54 * all files, such as before executing external commands.
57 static NODE
*append();
59 static NODE
*getnode();
60 static NODE
*search();
67 if ((newnode
= (NODE
*)malloc(sizeof(NODE
))) == (NODE
*)NULL
) {
68 (void) fputs("Cannot allocate node space\n", stderr
);
72 newnode
->next
= (NODE
*)NULL
;
81 for (tmp
= fplist
; tmp
!= (NODE
*)NULL
; tmp
= tmp
->next
)
84 return( tmp
!= (NODE
*)NULL
? tmp
: NOFP
);
90 register NODE
*newnode
;
92 if ((newnode
= getnode(fp
)) == (NODE
*)NULL
)
97 newnode
->next
= curptr
->next
;
98 curptr
->next
= newnode
;
106 register NODE
*cur
, *prev
;
108 for (prev
= cur
= fplist
; cur
!= (NODE
*)NULL
; cur
= cur
->next
) {
111 cur
= fplist
= cur
->next
;
113 prev
->next
= cur
->next
;
114 cur
= prev
->next
? prev
->next
: prev
;
116 if (curptr
== oldcur
)
127 my_fopen(char *file
, char *mode
)
131 if ((fp
= fopen(file
, mode
)) == NULL
) {
141 my_fclose(register FILE *iop
)
145 int ret
= fclose(iop
);
146 if (fplist
!= NOFP
) {