dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / librpcsvc / common / rusersxdr.c
blob7f0bd965f2d1b2216f45e0272e01b9a1a54bf9e0
1 /*
2 * CDDL HEADER START
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.
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]
20 * CDDL HEADER END
22 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
25 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
26 /* All Rights Reserved */
28 * Portions of this source code were derived from Berkeley
29 * 4.3 BSD under license from the Regents of the University of
30 * California.
33 #pragma ident "%Z%%M% %I% %E% SMI"
36 * rusersxdr.c
37 * These are the non-rpcgen-able XDR routines for version 2 of the rusers
38 * protocol.
42 #include <sys/types.h>
43 #include <rpc/rpc.h>
44 #include <rpcsvc/rusers.h>
46 int
47 xdr_ru_utmp(xdrsp, up)
48 XDR *xdrsp;
49 struct ru_utmp *up;
51 u_int len;
52 char *p;
55 * This code implements demented byte vectors: we send out the length
56 * of fixed-length vectors, followed by the opaque bytes. This is to
57 * be compatible with the over-the-wire protocol, as well as the
58 * rusers.h definition for struct ru_utmp.
60 len = (int)sizeof (up->ut_line);
61 if (xdr_u_int(xdrsp, &len) == FALSE)
62 return (0);
63 if (len != sizeof (up->ut_line)) {
64 return (0);
66 if (!xdr_opaque(xdrsp, (char *)up->ut_line, len)) {
67 return (0);
69 len = (int)sizeof (up->ut_name);
70 if (xdr_u_int(xdrsp, &len) == FALSE)
71 return (0);
72 if (len != sizeof (up->ut_name)) {
73 return (0);
75 if (!xdr_opaque(xdrsp, (char *)up->ut_name, len)) {
76 return (0);
78 len = (int)sizeof (up->ut_host);
79 if (xdr_u_int(xdrsp, &len) == FALSE)
80 return (0);
81 if (len != sizeof (up->ut_host)) {
82 return (0);
84 if (!xdr_opaque(xdrsp, (char *)up->ut_host, len)) {
85 return (0);
87 if (xdr_int(xdrsp, (int32_t *) &up->ut_time) == FALSE)
88 return (0);
89 return (1);
92 int
93 xdr_utmpidle(xdrsp, ui)
94 XDR *xdrsp;
95 struct utmpidle *ui;
97 if (xdr_ru_utmp(xdrsp, &ui->ui_utmp) == FALSE)
98 return (0);
99 if (xdr_u_int(xdrsp, &ui->ui_idle) == FALSE)
100 return (0);
101 return (1);
105 xdr_utmpidleptr(xdrsp, up)
106 XDR *xdrsp;
107 struct utmpidle **up;
109 if (xdr_reference(xdrsp, (char **) up, sizeof (struct utmpidle),
110 xdr_utmpidle) == FALSE)
111 return (0);
112 return (1);
116 xdr_utmpidlearr(xdrsp, up)
117 XDR *xdrsp;
118 struct utmpidlearr *up;
120 return (xdr_array(xdrsp, (char **) &up->uia_arr,
121 (u_int *)&(up->uia_cnt), MAXUSERS, sizeof (struct utmpidle *),
122 xdr_utmpidleptr));