1*7c478bd9Sstevel@tonic-gate/* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate/* LINTLIBRARY */ 23*7c478bd9Sstevel@tonic-gate/* PROTOLIB1 */ 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate/* 26*7c478bd9Sstevel@tonic-gate * Copyright (c) 1998 by Sun Microsystems, Inc. 27*7c478bd9Sstevel@tonic-gate * All rights reserved. 28*7c478bd9Sstevel@tonic-gate */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 31*7c478bd9Sstevel@tonic-gate/* All Rights Reserved */ 32*7c478bd9Sstevel@tonic-gate 33*7c478bd9Sstevel@tonic-gate#pragma ident "%Z%%M% %I% %E% SMI" 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate# include <sys/types.h> 37*7c478bd9Sstevel@tonic-gate# include <poll.h> 38*7c478bd9Sstevel@tonic-gate# include <stdarg.h> 39*7c478bd9Sstevel@tonic-gate# include <stropts.h> 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gatetypedef struct strbuf strbuf_t; /* STREAMS buffer */ 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gatetypedef struct mque 45*7c478bd9Sstevel@tonic-gate{ 46*7c478bd9Sstevel@tonic-gate struct mque *next; 47*7c478bd9Sstevel@tonic-gate struct strbuf *dat; 48*7c478bd9Sstevel@tonic-gate} MQUE; 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gatetypedef struct 51*7c478bd9Sstevel@tonic-gate{ 52*7c478bd9Sstevel@tonic-gate short type; /* type of connection */ 53*7c478bd9Sstevel@tonic-gate int readfd; /* STREAM fd to read from */ 54*7c478bd9Sstevel@tonic-gate int writefd; /* STREAM fd to write to */ 55*7c478bd9Sstevel@tonic-gate int wait; /* number of systems waiting for */ 56*7c478bd9Sstevel@tonic-gate char *file; /* pipe name if type==MD_FIFO */ 57*7c478bd9Sstevel@tonic-gate short state; /* Current state of client */ 58*7c478bd9Sstevel@tonic-gate short admin; /* Non zero if admin */ 59*7c478bd9Sstevel@tonic-gate short event; /* Event returned from poll */ 60*7c478bd9Sstevel@tonic-gate MQUE * mque; /* backlogged message ptr */ 61*7c478bd9Sstevel@tonic-gate uid_t uid; /* Clients UID */ 62*7c478bd9Sstevel@tonic-gate gid_t gid; /* Clients GID */ 63*7c478bd9Sstevel@tonic-gate void (**on_discon)(); /* Clean up functions */ 64*7c478bd9Sstevel@tonic-gate} MESG; 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate#define MSGMAX 2048 67*7c478bd9Sstevel@tonic-gatetypedef struct 68*7c478bd9Sstevel@tonic-gate{ 69*7c478bd9Sstevel@tonic-gate int full; 70*7c478bd9Sstevel@tonic-gate char save [MSGMAX], 71*7c478bd9Sstevel@tonic-gate *psave, 72*7c478bd9Sstevel@tonic-gate *psave_end; 73*7c478bd9Sstevel@tonic-gate} fifobuffer_t; 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gateMESG * mcreate ( char * ); 76*7c478bd9Sstevel@tonic-gateint mlisteninit ( MESG * ); 77*7c478bd9Sstevel@tonic-gateMESG * mlisten ( void ); 78*7c478bd9Sstevel@tonic-gateint mlistenadd ( MESG *, short ); 79*7c478bd9Sstevel@tonic-gateint mon_discon ( MESG *, void (*)()); 80*7c478bd9Sstevel@tonic-gateMESG * mlistenreset ( void ); 81*7c478bd9Sstevel@tonic-gateint mdestroy ( MESG * ); 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gateMESG * mconnect ( char *, int, int ); 84*7c478bd9Sstevel@tonic-gateint mgetm ( MESG *, int, ... ); 85*7c478bd9Sstevel@tonic-gateint mwrite ( MESG *, char * ); 86*7c478bd9Sstevel@tonic-gateint mputm ( MESG *, int, ... ); 87*7c478bd9Sstevel@tonic-gateint mread ( MESG *, char *, int ); 88*7c478bd9Sstevel@tonic-gateshort msize ( char * ); 89*7c478bd9Sstevel@tonic-gateshort mpeek ( MESG * ); 90*7c478bd9Sstevel@tonic-gateint mdisconnect ( MESG * ); 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gatevoid __mbfree ( void ); 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gateint mclose ( void ); 95*7c478bd9Sstevel@tonic-gateint mneeds ( void ); 96*7c478bd9Sstevel@tonic-gateint mopen ( void ); 97*7c478bd9Sstevel@tonic-gateint mrecv ( char *, int ); 98*7c478bd9Sstevel@tonic-gateint msend ( char * ); 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gateint Putmsg (MESG *, strbuf_t *, strbuf_t *, int); 101*7c478bd9Sstevel@tonic-gateint Getmsg (MESG *, strbuf_t *, strbuf_t *, int *); 102*7c478bd9Sstevel@tonic-gateint read3_2 (MESG * md, char *msgbuf, int size); 103*7c478bd9Sstevel@tonic-gateint write3_2 (MESG *, char *, int); 104*7c478bd9Sstevel@tonic-gateint read_fifo (int, char *, unsigned int); 105*7c478bd9Sstevel@tonic-gateint write_fifo (int, char *, unsigned int); 106*7c478bd9Sstevel@tonic-gateint ResetFifoBuffer (int); 107*7c478bd9Sstevel@tonic-gatefifobuffer_t *GetFifoBuffer (int); 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gatechar * htos ( char *, unsigned short ); 110*7c478bd9Sstevel@tonic-gatechar * ltos ( char *, unsigned long ); 111*7c478bd9Sstevel@tonic-gateunsigned long stol ( char * ); 112*7c478bd9Sstevel@tonic-gateunsigned short stoh ( char * ); 113*7c478bd9Sstevel@tonic-gateint _getmessage ( char *, short, va_list ); 114*7c478bd9Sstevel@tonic-gateint _putmessage ( char *, short, va_list ); 115*7c478bd9Sstevel@tonic-gateint getmessage ( char *, short, ... ); 116*7c478bd9Sstevel@tonic-gateint putmessage ( char *, short, ... ); 117