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 */
26 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.6 */
38 extern int Lp_prio_msg
;
41 ** Function: int mread( MESG *, char *, int)
42 ** Args: message descriptor
43 ** message buffer (var)
45 ** Return: The size of the message in message buffer.
46 ** or -1 on error. Possible errnos are:
47 ** EINVAL Bad value for md or msgbuf.
48 ** E2BIG Not enough space for message.
49 ** EPIPE Far end dropped the connection.
50 ** ENOMSG No valid message available on fifo.
52 ** mread examines message descriptor and either calls read3_2
53 ** to read 3.2 HPI messages or getmsg(2) to read 4.0 HPI messages.
54 ** If a message is read, it is returned in message buffer.
58 int mread ( MESG
* md
, char * msgbuf
, int size
)
60 int mread ( md
, msgbuf
, size
)
71 if (md
== NULL
|| msgbuf
== NULL
)
91 ctl
.maxlen
= sizeof (buff
);
94 Lp_prio_msg
= 0; /* clean this up so there are no surprises */
96 if (Getmsg(md
, &ctl
, &dat
, &flag
) < 0)
105 (void) Close(md
->readfd
);
112 if (size
< CONTROL_LEN
)
118 if (read3_2(md
, msgbuf
, size
) < 0)
123 return((int)msize(msgbuf
));