1/* 2 * CDDL HEADER START 3 * 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 7 * with the License. 8 * 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. 13 * 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] 19 * 20 * CDDL HEADER END 21 */ 22/* LINTLIBRARY */ 23/* PROTOLIB1 */ 24 25/* 26 * Copyright (c) 1998 by Sun Microsystems, Inc. 27 * All rights reserved. 28 */ 29 30/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 31/* All Rights Reserved */ 32 33#pragma ident "%Z%%M% %I% %E% SMI" 34 35 36# include <sys/types.h> 37# include <poll.h> 38# include <stdarg.h> 39# include <stropts.h> 40 41 42typedef struct strbuf strbuf_t; /* STREAMS buffer */ 43 44typedef struct mque 45{ 46 struct mque *next; 47 struct strbuf *dat; 48} MQUE; 49 50typedef struct 51{ 52 short type; /* type of connection */ 53 int readfd; /* STREAM fd to read from */ 54 int writefd; /* STREAM fd to write to */ 55 int wait; /* number of systems waiting for */ 56 char *file; /* pipe name if type==MD_FIFO */ 57 short state; /* Current state of client */ 58 short admin; /* Non zero if admin */ 59 short event; /* Event returned from poll */ 60 MQUE * mque; /* backlogged message ptr */ 61 uid_t uid; /* Clients UID */ 62 gid_t gid; /* Clients GID */ 63 void (**on_discon)(); /* Clean up functions */ 64} MESG; 65 66#define MSGMAX 2048 67typedef struct 68{ 69 int full; 70 char save [MSGMAX], 71 *psave, 72 *psave_end; 73} fifobuffer_t; 74 75MESG * mcreate ( char * ); 76int mlisteninit ( MESG * ); 77MESG * mlisten ( void ); 78int mlistenadd ( MESG *, short ); 79int mon_discon ( MESG *, void (*)()); 80MESG * mlistenreset ( void ); 81int mdestroy ( MESG * ); 82 83MESG * mconnect ( char *, int, int ); 84int mgetm ( MESG *, int, ... ); 85int mwrite ( MESG *, char * ); 86int mputm ( MESG *, int, ... ); 87int mread ( MESG *, char *, int ); 88short msize ( char * ); 89short mpeek ( MESG * ); 90int mdisconnect ( MESG * ); 91 92void __mbfree ( void ); 93 94int mclose ( void ); 95int mneeds ( void ); 96int mopen ( void ); 97int mrecv ( char *, int ); 98int msend ( char * ); 99 100int Putmsg (MESG *, strbuf_t *, strbuf_t *, int); 101int Getmsg (MESG *, strbuf_t *, strbuf_t *, int *); 102int read3_2 (MESG * md, char *msgbuf, int size); 103int write3_2 (MESG *, char *, int); 104int read_fifo (int, char *, unsigned int); 105int write_fifo (int, char *, unsigned int); 106int ResetFifoBuffer (int); 107fifobuffer_t *GetFifoBuffer (int); 108 109char * htos ( char *, unsigned short ); 110char * ltos ( char *, unsigned long ); 111unsigned long stol ( char * ); 112unsigned short stoh ( char * ); 113int _getmessage ( char *, short, va_list ); 114int _putmessage ( char *, short, va_list ); 115int getmessage ( char *, short, ... ); 116int putmessage ( char *, short, ... ); 117