2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 //%% (c) Copyright 1993, 1994 Hewlett-Packard Company
24 //%% (c) Copyright 1993, 1994 International Business Machines Corp.
25 //%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
26 //%% (c) Copyright 1993, 1994 Novell, Inc.
27 //%% $XConsortium: tt_xdr_utils.C /main/6 1996/08/29 18:08:20 drk $
32 * Copyright (c) 1990 by Sun Microsystems, Inc.
35 #include <rpc/types.h>
39 #include <util/tt_xdr_utils.h>
41 #include "tt_options.h"
43 typedef bool_t (*local_xdrproc_t)(XDR *, caddr_t *);
45 #ifndef OPT_XDR_LONG_TYPE
46 # define OPT_XDR_LONG_TYPE long
49 tt_x_putlong(XDR *xp, OPT_XDR_LONG_TYPE *)
56 /* The second argument is caddr_t and not void * in both SUN, DEC headers
58 * The third agrument is also wrong. Both SUN and DEC system header files
59 * expect int instead of u_int.
61 tt_x_putbytes(XDR *xp, caddr_t, int len)
63 xp->x_handy += RNDUP (len);
67 #if defined(ultrix) || defined(__osf__)
72 tt_x_inline(XDR *xp, int len)
74 /* Be paranoid -- some code really expects inline to
75 * always succeed, so we keep a small buffer around
76 * just in case. Not too paranoid, though -- it's
77 * legal to not support inline!
79 /* It is better to promote len to caddr_t than demote x_base to
82 if (len > 0 && (caddr_t) len < xp->x_base) {
83 xp->x_handy += RNDUP (len);
84 #if defined(ultrix) || defined(__osf__)
85 return (int *) xp->x_private;
87 return (long *) xp->x_private;
95 _tt_xdr_sizeof(xdrproc_t f, void *data)
97 _Tt_xdr_size_stream x;
99 if ((*(local_xdrproc_t)f) ((XDR *)x, (caddr_t *)data) == TRUE) {
106 _Tt_xdr_size_stream::
107 _Tt_xdr_size_stream() {
108 memset ((char *)&ops, 0, sizeof ops);
109 #if defined(OPT_BUG_SUNOS_4) || defined(OPT_BUG_HPUX)
110 ops.x_putlong = (int (*)(...))tt_x_putlong;
111 ops.x_putbytes = (int (*)(...))tt_x_putbytes;
112 ops.x_inline = (long *(*)(...))tt_x_inline;
113 #elif defined(OPT_BUG_AIX)
114 ops.x_putlong = (int (*)(XDR *, long *))tt_x_putlong;
115 ops.x_putbytes = (int (*)(XDR *, caddr_t, u_int))tt_x_putbytes;
116 ops.x_inline = (long *(*)(XDR *, u_int))tt_x_inline;
117 #elif defined(OPT_BUG_SUNOS_5)
118 ops.x_putlong = tt_x_putlong;
119 ops.x_putbytes = (bool_t (*)(XDR *, caddr_t, int))tt_x_putbytes;
120 ops.x_inline = tt_x_inline;
122 ops.x_putlong = tt_x_putlong;
123 ops.x_putbytes = tt_x_putbytes;
124 ops.x_inline = (inline_t *(*)(...))tt_x_inline;
125 #elif defined(OPT_BUG_USL) || defined(OPT_BUG_UXP)
126 ops.x_putlong = tt_x_putlong;
127 ops.x_putbytes = (bool_t (*)(XDR *, caddr_t, u_int)) tt_x_putbytes;
128 #if defined(OPT_BUG_UW_1)
129 ops.x_inline = (long *(*)(struct __XDR *, const int)) tt_x_inline;
131 ops.x_inline = (long *(*)(struct XDR *, int)) tt_x_inline;
132 #endif /* OPT_BUG_UW1 */
134 ops.x_putlong = tt_x_putlong;
135 ops.x_putbytes = tt_x_putbytes;
136 ops.x_inline = tt_x_inline;
138 xdrstream.x_op = XDR_ENCODE;
139 xdrstream.x_ops = &ops;
140 xdrstream.x_handy = 0;
141 xdrstream.x_private = (caddr_t) buf;
142 xdrstream.x_base = (caddr_t) sizeof buf;
145 _Tt_xdr_size_stream::