2 * Copyright (c) 2010 Your Filesystem Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 #include <afsconfig.h>
26 #include <afs/param.h>
29 # include "afs/sysincludes.h"
37 xdrlen_destroy(XDR *xdrs)
42 xdrlen_getint32(XDR *xdrs, afs_int32 * lp)
48 xdrlen_putint32(XDR *xdrs, afs_int32 * lp)
50 xdrs->x_handy += sizeof(afs_int32);
55 xdrlen_getbytes(XDR *xdrs, caddr_t addr, u_int len)
61 xdrlen_putbytes(XDR *xdrs, caddr_t addr, u_int len)
68 xdrlen_getpos(XDR *xdrs)
74 xdrlen_setpos(XDR *xdrs, u_int pos)
81 xdrlen_inline(XDR *xdrs, u_int len)
86 static struct xdr_ops xdrlen_ops = {
87 #ifndef HAVE_STRUCT_LABEL_SUPPORT
88 #ifdef AFS_XDR_64BITOPS
92 /* Windows does not support labeled assigments */
93 #if !(defined(KERNEL) && defined(AFS_SUN57_ENV))
94 xdrlen_getint32, /* not supported */
95 xdrlen_putint32, /* serialize an afs_int32 */
97 xdrlen_getbytes, /* not supported */
98 xdrlen_putbytes, /* serialize counted bytes */
99 xdrlen_getpos, /* get offset in the stream */
100 xdrlen_setpos, /* set offset in the stream */
101 xdrlen_inline, /* not supported */
102 xdrlen_destroy, /* destroy stream */
103 #if (defined(KERNEL) && defined(AFS_SUN57_ENV))
104 NULL, /* control - not implemented */
105 xdrlen_getint32, /* not supported */
106 xdrlen_putint32, /* serialize an afs_int32 */
109 #ifdef AFS_XDR_64BITOPS
113 .x_getint32 = xdrlen_getint32,
114 .x_putint32 = xdrlen_putint32,
115 .x_getbytes = xdrlen_getbytes,
116 .x_putbytes = xdrlen_putbytes,
117 .x_getpostn = xdrlen_getpos,
118 .x_setpostn = xdrlen_setpos,
119 .x_inline = xdrlen_inline,
120 .x_destroy = xdrlen_destroy
125 * Initialise an XDR stream to calculate the space required to encode
127 * This initialises an XDR stream object which can be used to calculate
128 * the space required to encode a particular structure into memory. No
129 * encoding is actually performed, a later call using xdrmem is necessary
133 * A pointer to a preallocated XDR sized block of memory.
136 xdrlen_create(XDR * xdrs)
138 xdrs->x_op = XDR_ENCODE;
139 xdrs->x_ops = &xdrlen_ops;