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 */
31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */
48 ** Size and pointer for mgetm()
50 static int MBGSize
= 0;
51 static char * MBG
= NULL
;
54 ** Size and pointer for mputm()
56 static int MBPSize
= 0;
57 static char * MBP
= NULL
;
62 int mgetm ( MESG
* md
, int type
, ... )
64 int mgetm (md
, type
, va_alist
)
81 if (needsize
<=0 || needsize
> MSGMAX
)
83 if (needsize
> MBGSize
)
87 if ((MBG
= (char *)Malloc(needsize
)) == NULL
)
96 if (mread(md
, MBG
, MBGSize
) < 0)
99 ret
= _getmessage(MBG
, type
, vp
);
106 #if defined(__STDC__)
107 int mputm ( MESG
* md
, int type
, ... )
109 int mputm (md
, type
, va_alist
)
118 #if defined(__STDC__)
123 needsize
= _putmessage(NULL
, type
, vp
);
128 if (needsize
> MBPSize
)
132 if ((MBP
= (char *)Malloc(needsize
)) == NULL
)
142 #if defined(__STDC__)
147 needsize
= _putmessage(MBP
, type
, vp
);
153 return(mwrite(md
, MBP
));
156 #if defined(__STDC__)
157 void __mbfree ( void )
162 MBGSize
= MBPSize
= 0;
170 #if defined(__STDC__)
171 short mpeek ( MESG
* md
)
179 if (md
->type
== MD_USR_FIFO
|| md
->type
== MD_SYS_FIFO
)
180 return(peek3_2(md
->readfd
) - EXCESS_3_2_LEN
);
182 if (ioctl(md
->readfd
, I_NREAD
, &size
))