Update.
[glibc.git] / sunrpc / xdr_intXX_t.c
blob98132cd802c443b75bc40fbc92f763662272fd93
1 /* Copyright (c) 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1998.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
20 #include <rpc/types.h>
21 #include <rpc/xdr.h>
23 /* XDR 32bit integers */
24 bool_t
25 xdr_int32_t (XDR *xdrs, int32_t *lp)
27 switch (xdrs->x_op)
29 case XDR_ENCODE:
30 return XDR_PUTINT32 (xdrs, lp);
31 case XDR_DECODE:
32 return XDR_GETINT32 (xdrs, lp);
33 case XDR_FREE:
34 return TRUE;
35 default:
36 return FALSE;
40 /* XDR 32bit unsigned integers */
41 bool_t
42 xdr_uint32_t (XDR *xdrs, uint32_t *ulp)
44 switch (xdrs->x_op)
46 case XDR_DECODE:
47 return XDR_GETINT32 (xdrs, (int32_t *) ulp);
48 case XDR_ENCODE:
49 return XDR_PUTINT32 (xdrs, (int32_t *) ulp);
50 case XDR_FREE:
51 return TRUE;
52 default:
53 return FALSE;
57 /* XDR 16bit integers */
58 bool_t
59 xdr_int16_t (XDR *xdrs, int16_t *ip)
61 int32_t t;
63 switch (xdrs->x_op)
65 case XDR_ENCODE:
66 t = (int32_t) *ip;
67 return XDR_PUTINT32 (xdrs, &t);
68 case XDR_DECODE:
69 if (!XDR_GETINT32 (xdrs, &t))
70 return FALSE;
71 *ip = (int16_t) t;
72 return TRUE;
73 case XDR_FREE:
74 return TRUE;
75 default:
76 return FALSE;
80 /* XDR 16bit unsigned integers */
81 bool_t
82 xdr_uint16_t (XDR *xdrs, uint16_t *uip)
84 uint32_t ut;
86 switch (xdrs->x_op)
88 case XDR_DECODE:
89 ut = (uint32_t) *uip;
90 return XDR_GETINT32 (xdrs, (int32_t *) &ut);
91 case XDR_ENCODE:
92 if (!XDR_PUTINT32 (xdrs, (int32_t *) &ut))
93 return FALSE;
94 *uip = (uint16_t) ut;
95 return TRUE;
96 case XDR_FREE:
97 return TRUE;
98 default:
99 return FALSE;
103 /* XDR 8bit integers */
104 bool_t
105 xdr_int8_t (XDR *xdrs, int8_t *ip)
107 int32_t t;
109 switch (xdrs->x_op)
111 case XDR_ENCODE:
112 t = (int32_t) *ip;
113 return XDR_PUTINT32 (xdrs, &t);
114 case XDR_DECODE:
115 if (!XDR_GETINT32 (xdrs, &t))
116 return FALSE;
117 *ip = (int8_t) t;
118 return TRUE;
119 case XDR_FREE:
120 return TRUE;
121 default:
122 return FALSE;
126 /* XDR 8bit unsigned integers */
127 bool_t
128 xdr_uint8_t (XDR *xdrs, uint8_t *uip)
130 uint32_t ut;
132 switch (xdrs->x_op)
134 case XDR_DECODE:
135 ut = (uint32_t) *uip;
136 return XDR_GETINT32 (xdrs, (int32_t *) &ut);
137 case XDR_ENCODE:
138 if (!XDR_PUTINT32 (xdrs, (int32_t *) &ut))
139 return FALSE;
140 *uip = (uint8_t) ut;
141 return TRUE;
142 case XDR_FREE:
143 return TRUE;
144 default:
145 return FALSE;