Dr Andrew Scott G7VAV

My photo
 
June 2025
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


rusers.x
001: /*
002:  * Copyright (c) 2010, Oracle America, Inc.
003:  * Redistribution and use in source and binary forms, with or without
004:  * modification, are permitted provided that the following conditions are
005:  * met:
006:  *
007:  *     * Redistributions of source code must retain the above copyright
008:  *       notice, this list of conditions and the following disclaimer.
009:  *     * Redistributions in binary form must reproduce the above
010:  *       copyright notice, this list of conditions and the following
011:  *       disclaimer in the documentation and/or other materials
012:  *       provided with the distribution.
013:  *     * Neither the name of the "Oracle America, Inc." nor the names of its
014:  *       contributors may be used to endorse or promote products derived
015:  *       from this software without specific prior written permission.
016:  *
017:  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
018:  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
019:  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
020:  *   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
021:  *   COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
022:  *   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
023:  *   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
024:  *   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025:  *   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
026:  *   WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
027:  *   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
028:  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029:  */
030: %/*
031: % * Find out about remote users
032: % */
033: 
034: const RUSERS_MAXUSERLEN = 32;
035: const RUSERS_MAXLINELEN = 32;
036: const RUSERS_MAXHOSTLEN = 257;
037: 
038: struct rusers_utmp {
039:         string ut_user<RUSERS_MAXUSERLEN>;      /* aka ut_name */
040:         string ut_line<RUSERS_MAXLINELEN>;      /* device */
041:         string ut_host<RUSERS_MAXHOSTLEN>;      /* host user logged on from */
042:         int ut_type;                            /* type of entry */
043:         int ut_time;                            /* time entry was made */
044:         unsigned int ut_idle;                   /* minutes idle */
045: };
046: 
047: typedef rusers_utmp utmp_array<>;
048: 
049: #ifdef RPC_HDR
050: %
051: %/*
052: % * Values for ut_type field above.
053: % */
054: #endif
055: const   RUSERS_EMPTY = 0;
056: const   RUSERS_RUN_LVL = 1;
057: const   RUSERS_BOOT_TIME = 2;
058: const   RUSERS_OLD_TIME = 3;
059: const   RUSERS_NEW_TIME = 4;
060: const   RUSERS_INIT_PROCESS = 5;
061: const   RUSERS_LOGIN_PROCESS = 6;
062: const   RUSERS_USER_PROCESS = 7;
063: const   RUSERS_DEAD_PROCESS = 8;
064: const   RUSERS_ACCOUNTING = 9;
065: 
066: program RUSERSPROG {
067: 
068:         version RUSERSVERS_3 {
069:                 int
070:                 RUSERSPROC_NUM(void) = 1;
071: 
072:                 utmp_array
073:                 RUSERSPROC_NAMES(void) = 2;
074: 
075:                 utmp_array
076:                 RUSERSPROC_ALLNAMES(void) = 3;
077:         } = 3;
078: 
079: } = 100002;
080: 
081: #ifdef RPC_HDR
082: %
083: %
084: %#ifdef __cplusplus
085: %extern "C" {
086: %#endif
087: %
088: %#include <rpc/xdr.h>
089: %
090: %/*
091: % * The following structures are used by version 2 of the rusersd protocol.
092: % * They were not developed with rpcgen, so they do not appear as RPCL.
093: % */
094: %
095: %#define        RUSERSVERS_IDLE 2
096: %#define        RUSERSVERS 3            /* current version */
097: %#define        MAXUSERS 100
098: %
099: %/*
100: % * This is the structure used in version 2 of the rusersd RPC service.
101: % * It corresponds to the utmp structure for BSD systems.
102: % */
103: %struct ru_utmp {
104: %       char    ut_line[8];             /* tty name */
105: %       char    ut_name[8];             /* user id */
106: %       char    ut_host[16];            /* host name, if remote */
107: %       long int ut_time;               /* time on */
108: %};
109: %
110: %struct utmparr {
111: %       struct ru_utmp **uta_arr;
112: %       int uta_cnt;
113: %};
114: %typedef struct utmparr utmparr;
115: %
116: %extern bool_t xdr_utmparr (XDR *xdrs, struct utmparr *objp) __THROW;
117: %
118: %struct utmpidle {
119: %       struct ru_utmp ui_utmp;
120: %       unsigned int ui_idle;
121: %};
122: %
123: %struct utmpidlearr {
124: %       struct utmpidle **uia_arr;
125: %       int uia_cnt;
126: %};
127: %
128: %extern bool_t xdr_utmpidlearr (XDR *xdrs, struct utmpidlearr *objp) __THROW;
129: %
130: %#ifdef __cplusplus
131: %}
132: %#endif
133: #endif
134: 
135: 
136: #ifdef  RPC_XDR
137: %bool_t xdr_utmp (XDR *xdrs, struct ru_utmp *objp);
138: %
139: %bool_t
140: %xdr_utmp(xdrs, objp)
141: %       XDR *xdrs;
142: %       struct ru_utmp *objp;
143: %{
144: %       /* Since the fields are char foo [xxx], we should not free them. */
145: %       if (xdrs->x_op != XDR_FREE)
146: %       {
147: %               char *ptr;
148: %               unsigned int size;
149: %               ptr = objp->ut_line;
150: %               size = sizeof (objp->ut_line);
151: %               if (!xdr_bytes (xdrs, &ptr, &size, size)) {
152: %                       return (FALSE);
153: %               }
154: %               ptr = objp->ut_name;
155: %               size = sizeof (objp->ut_name);
156: %               if (!xdr_bytes (xdrs, &ptr, &size, size)) {
157: %                       return (FALSE);
158: %               }
159: %               ptr = objp->ut_host;
160: %               size = sizeof (objp->ut_host);
161: %               if (!xdr_bytes (xdrs, &ptr, &size, size)) {
162: %                       return (FALSE);
163: %               }
164: %       }
165: %       if (!xdr_long(xdrs, &objp->ut_time)) {
166: %               return (FALSE);
167: %       }
168: %       return (TRUE);
169: %}
170: %
171: %bool_t xdr_utmpptr(XDR *xdrs, struct ru_utmp **objpp);
172: %
173: %bool_t
174: %xdr_utmpptr(xdrs, objpp)
175: %       XDR *xdrs;
176: %       struct ru_utmp **objpp;
177: %{
178: %       if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct ru_utmp),
179: %                          (xdrproc_t) xdr_utmp)) {
180: %               return (FALSE);
181: %       }
182: %       return (TRUE);
183: %}
184: %
185: %bool_t
186: %xdr_utmparr(xdrs, objp)
187: %       XDR *xdrs;
188: %       struct utmparr *objp;
189: %{
190: %       if (!xdr_array(xdrs, (char **)&objp->uta_arr, (u_int *)&objp->uta_cnt,
191: %                      MAXUSERS, sizeof(struct ru_utmp *),
192: %                      (xdrproc_t) xdr_utmpptr)) {
193: %               return (FALSE);
194: %       }
195: %       return (TRUE);
196: %}
197: %
198: %bool_t xdr_utmpidle(XDR *xdrs, struct utmpidle *objp);
199: %
200: %bool_t
201: %xdr_utmpidle(xdrs, objp)
202: %       XDR *xdrs;
203: %       struct utmpidle *objp;
204: %{
205: %       if (!xdr_utmp(xdrs, &objp->ui_utmp)) {
206: %               return (FALSE);
207: %       }
208: %       if (!xdr_u_int(xdrs, &objp->ui_idle)) {
209: %               return (FALSE);
210: %       }
211: %       return (TRUE);
212: %}
213: %
214: %bool_t xdr_utmpidleptr(XDR *xdrs, struct utmpidle **objp);
215: %
216: %bool_t
217: %xdr_utmpidleptr(xdrs, objpp)
218: %       XDR *xdrs;
219: %       struct utmpidle **objpp;
220: %{
221: %       if (!xdr_reference(xdrs, (char **) objpp, sizeof (struct utmpidle),
222: %                          (xdrproc_t) xdr_utmpidle)) {
223: %               return (FALSE);
224: %       }
225: %       return (TRUE);
226: %}
227: %
228: %bool_t
229: %xdr_utmpidlearr(xdrs, objp)
230: %       XDR *xdrs;
231: %       struct utmpidlearr *objp;
232: %{
233: %       if (!xdr_array(xdrs, (char **)&objp->uia_arr, (u_int *)&objp->uia_cnt,
234: %                      MAXUSERS, sizeof(struct utmpidle *),
235: %                      (xdrproc_t) xdr_utmpidleptr)) {
236: %               return (FALSE);
237: %       }
238: %       return (TRUE);
239: %}
240: #endif
241: 


for client (none)
© Andrew Scott 2006 - 2025,
All Rights Reserved
http://www.andrew-scott.uk/
Andrew Scott
http://www.andrew-scott.co.uk/