1 /*
2 * CDDL HEADER START
3 *
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.
8 *
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.
13 *
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]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * db_dictxdr.c
24 *
25 * Copyright 2015 Gary Mills
26 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
28 */
29
30 #include "db_dictionary_c.h"
31 #include "db_dictionary.h"
32 #include "db_vers_c.h"
33
34 extern vers db_update_version;
35
36 extern void make_zero(vers*);
37
38 /* Special xdr_db_dict_desc that understands optional version number at end. */
39 bool_t
xdr_db_dict_desc(XDR * xdrs,db_dict_desc * objp)40 xdr_db_dict_desc(XDR *xdrs, db_dict_desc *objp)
41 {
42
43 if (!xdr_db_dict_version(xdrs, &objp->impl_vers))
44 return (FALSE);
45 if (!xdr_array(xdrs, (char **)&objp->tables.tables_val,
46 (uint_t *)&objp->tables.tables_len, ~0,
47 sizeof (db_table_desc_p), (xdrproc_t)xdr_db_table_desc_p))
48 return (FALSE);
49 if (!xdr_int(xdrs, &objp->count))
50 return (FALSE);
51
52 if (xdrs->x_op == XDR_DECODE) {
53 /* If no version was found, set version to 0. */
54 if (!xdr_vers(xdrs, (void**) &db_update_version))
55 make_zero(&db_update_version);
56 return (TRUE);
57 } else if (xdrs->x_op == XDR_ENCODE) {
58 /* Always write out version */
59 if (!xdr_vers(xdrs, (void**) &db_update_version))
60 return (FALSE);
61 } /* else XDR_FREE: do nothing */
62
63 return (TRUE);
64 }
65