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 2005 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"
36 /* maximum likely message - make sure you don't get run away input */
40 * read message routine used before a
41 * protocol is agreed upon.
42 * msg -> address of input buffer
43 * fn -> input file descriptor
45 * EOF -> no more messages
46 * 0 -> message returned
60 CDEBUG(7, "imsg %s>", "");
61 while ((i
= (*Read
)(fn
, msg
, sizeof(char))) == sizeof(char)) {
64 CDEBUG(7, "%s", c
< 040 ? "^" : "");
65 CDEBUG(7, "%c", c
< 040 ? c
| 0100 : c
);
66 if (c
== MSYNC
) { /* look for sync character */
74 if (c
== '\0' || c
== '\n') {
81 if (msg
- bmsg
> MAXIMSG
) /* unlikely */
84 /* have not found sync or end of message */
86 CDEBUG(7, "\nimsg read error: %s\n", strerror(errno
));
93 * initial write message routine -
94 * used before a protocol is agreed upon.
95 * type -> message type
96 * msg -> message body address
97 * fn -> file descriptor
99 * Must always return 0 - wmesg (WMESG) looks for zero
109 (void) sprintf(buf
, "%c%c%s", MSYNC
, type
, msg
);
110 DEBUG( 7, "omsg \"%s\"\n", &buf
[1] );
111 (*Write
)(fn
, buf
, strlen(buf
) + 1);
116 * null turnoff routine to be used for errors
117 * during protocol selection.