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