Home | History | Annotate | Line # | Download | only in librpcsvc
rnusers.x revision 1.14
      1 /*
      2  * Sun RPC is a product of Sun Microsystems, Inc. and is provided for
      3  * unrestricted use provided that this legend is included on all tape
      4  * media and as a part of the software program in whole or part.  Users
      5  * may copy or modify Sun RPC without charge, but are not authorized
      6  * to license or distribute it to anyone else except as part of a product or
      7  * program developed by the user.
      8  *
      9  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
     10  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
     11  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
     12  *
     13  * Sun RPC is provided with no support and without any obligation on the
     14  * part of Sun Microsystems, Inc. to assist in its use, correction,
     15  * modification or enhancement.
     16  *
     17  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
     18  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
     19  * OR ANY PART THEREOF.
     20  *
     21  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
     22  * or profits or other special, indirect and consequential damages, even if
     23  * Sun has been advised of the possibility of such damages.
     24  *
     25  * Sun Microsystems, Inc.
     26  * 2550 Garcia Avenue
     27  * Mountain View, California  94043
     28  */
     29 
     30 /*
     31  * Find out about remote users
     32  */
     33 
     34 #ifndef RPC_HDR
     35 %#include <sys/cdefs.h>
     36 %#ifndef __lint__
     37 %/*static char sccsid[] = "from: @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro";*/
     38 %/*static char sccsid[] = "from: @(#)rnusers.x	2.1 88/08/01 4.0 RPCSRC";*/
     39 %__RCSID("$NetBSD: rnusers.x,v 1.14 2011/08/30 17:06:20 plunky Exp $");
     40 %#endif /* not __lint__ */
     41 #endif
     42 
     43 
     44 #ifdef RPC_HDR
     45 %/*
     46 % * The following structures are used by version 2 of the rusersd protocol.
     47 % * They were not developed with rpcgen, so they do not appear as RPCL.
     48 % */
     49 %
     50 %#define 	RUSERSVERS_ORIG 1	/* original version */
     51 %#define	RUSERSVERS_IDLE 2
     52 %#define	MAXUSERS 100
     53 %
     54 %/*
     55 % * This is the structure used in version 2 of the rusersd RPC service.
     56 % * It corresponds to the utmp structure for BSD sytems.
     57 % */
     58 %struct ru_utmp {
     59 %	char	ut_line[8];		/* tty name */
     60 %	char	ut_name[8];		/* user id */
     61 %	char	ut_host[16];		/* host name, if remote */
     62 %	long	ut_time;		/* time on */
     63 %};
     64 %typedef struct ru_utmp rutmp;
     65 %
     66 %struct utmparr {
     67 %	struct utmp **uta_arr;
     68 %	int uta_cnt;
     69 %};
     70 %typedef struct utmparr utmparr;
     71 %
     72 %struct utmpidle {
     73 %	struct ru_utmp ui_utmp;
     74 %	unsigned ui_idle;
     75 %};
     76 %
     77 %struct utmpidlearr {
     78 %	struct utmpidle **uia_arr;
     79 %	int uia_cnt;
     80 %};
     81 %typedef struct utmpidlearr utmpidlearr;
     82 %
     83 %#include <sys/cdefs.h>
     84 %__BEGIN_DECLS
     85 %bool_t xdr_utmp __P((XDR *, struct ru_utmp *));
     86 %bool_t xdr_utmpptr __P((XDR *, struct ru_utmp **));
     87 %bool_t xdr_utmparr __P((XDR *, struct utmparr *));
     88 %bool_t xdr_utmpidle __P((XDR *, struct utmpidle *));
     89 %bool_t xdr_utmpidleptr __P((XDR *, struct utmpidle **));
     90 %bool_t xdr_utmpidlearr __P((XDR *, struct utmpidlearr *));
     91 %__END_DECLS
     92 %
     93 %#define RUSERSVERS_1 ((u_long)1)
     94 %#define RUSERSVERS_2 ((u_long)2)
     95 %#ifndef RUSERSPROG
     96 %#define RUSERSPROG ((u_long)100002)
     97 %#endif
     98 %#ifndef RUSERSPROC_NUM
     99 %#define RUSERSPROC_NUM ((u_long)1)
    100 %#endif
    101 %#ifndef RUSERSPROC_NAMES
    102 %#define RUSERSPROC_NAMES ((u_long)2)
    103 %#endif
    104 %#ifndef RUSERSPROC_ALLNAMES
    105 %#define RUSERSPROC_ALLNAMES ((u_long)3)
    106 %#endif
    107 %
    108 #endif	/* RPC_HDR */
    109 
    110 #ifdef	RPC_XDR
    111 %bool_t
    112 %xdr_utmp(xdrs, objp)
    113 %	XDR *xdrs;
    114 %	struct ru_utmp *objp;
    115 %{
    116 %	char *ptr;
    117 %	u_int size;
    118 %
    119 %	/*
    120 %	 * We are using a non-malloc allocated array,
    121 %	 * so we are not supposed to call xdr_free with it.
    122 %	 */
    123 %	if (xdrs->x_op == XDR_FREE)
    124 %		return (TRUE);
    125 %	ptr  = objp->ut_line;
    126 %	size = (u_int)sizeof(objp->ut_line);
    127 %	if (!xdr_bytes(xdrs, &ptr, &size, size))
    128 %		return (FALSE);
    129 %	ptr  = objp->ut_name;
    130 %	size = (u_int)sizeof(objp->ut_name);
    131 %	if (!xdr_bytes(xdrs, &ptr, &size, size))
    132 %		return (FALSE);
    133 %	ptr  = objp->ut_host;
    134 %	size = (u_int)sizeof(objp->ut_host);
    135 %	if (!xdr_bytes(xdrs, &ptr, &size, size))
    136 %		return (FALSE);
    137 %	if (!xdr_long(xdrs, &objp->ut_time))
    138 %		return (FALSE);
    139 %	return (TRUE);
    140 %}
    141 %
    142 %bool_t
    143 %xdr_utmpptr(xdrs, objpp)
    144 %	XDR *xdrs;
    145 %	struct ru_utmp **objpp;
    146 %{
    147 %
    148 %	if (!xdr_reference(xdrs, (char **) objpp, (u_int)sizeof(struct ru_utmp),
    149 %			   (xdrproc_t)xdr_utmp))
    150 %		return (FALSE);
    151 %	return (TRUE);
    152 %}
    153 %
    154 %bool_t
    155 %xdr_utmparr(xdrs, objp)
    156 %	XDR *xdrs;
    157 %	struct utmparr *objp;
    158 %{
    159 %
    160 %	if (!xdr_array(xdrs, (char **)(void *)&objp->uta_arr,
    161 %		       (u_int *)&objp->uta_cnt, MAXUSERS,
    162 %		       (u_int)sizeof(struct utmp *), (xdrproc_t)xdr_utmpptr))
    163 %		return (FALSE);
    164 %	return (TRUE);
    165 %}
    166 %
    167 %bool_t
    168 %xdr_utmpidle(xdrs, objp)
    169 %	XDR *xdrs;
    170 %	struct utmpidle *objp;
    171 %{
    172 %
    173 %	if (!xdr_utmp(xdrs, &objp->ui_utmp))
    174 %		return (FALSE);
    175 %	if (!xdr_u_int(xdrs, &objp->ui_idle))
    176 %		return (FALSE);
    177 %	return (TRUE);
    178 %}
    179 %
    180 %bool_t
    181 %xdr_utmpidleptr(xdrs, objpp)
    182 %	XDR *xdrs;
    183 %	struct utmpidle **objpp;
    184 %{
    185 %
    186 %	if (!xdr_reference(xdrs, (char **) objpp,
    187 %			   (u_int)sizeof(struct utmpidle),
    188 %			   (xdrproc_t)xdr_utmpidle))
    189 %		return (FALSE);
    190 %	return (TRUE);
    191 %}
    192 %
    193 %bool_t
    194 %xdr_utmpidlearr(xdrs, objp)
    195 %	XDR *xdrs;
    196 %	struct utmpidlearr *objp;
    197 %{
    198 %
    199 %	if (!xdr_array(xdrs, (char **)(void *)&objp->uia_arr,
    200 %	 	       (u_int *)&objp->uia_cnt, MAXUSERS,
    201 %		       (u_int)sizeof(struct utmpidle *),
    202 %		       (xdrproc_t)xdr_utmpidleptr))
    203 %		return (FALSE);
    204 %	return (TRUE);
    205 %}
    206 #endif
    207