amq_xdr.c revision 174294
138494Sobrien/* 2174294Sobrien * Copyright (c) 1997-2006 Erez Zadok 338494Sobrien * Copyright (c) 1990 Jan-Simon Pendry 438494Sobrien * Copyright (c) 1990 Imperial College of Science, Technology & Medicine 538494Sobrien * Copyright (c) 1990 The Regents of the University of California. 638494Sobrien * All rights reserved. 738494Sobrien * 838494Sobrien * This code is derived from software contributed to Berkeley by 938494Sobrien * Jan-Simon Pendry at Imperial College, London. 1038494Sobrien * 1138494Sobrien * Redistribution and use in source and binary forms, with or without 1238494Sobrien * modification, are permitted provided that the following conditions 1338494Sobrien * are met: 1438494Sobrien * 1. Redistributions of source code must retain the above copyright 1538494Sobrien * notice, this list of conditions and the following disclaimer. 1638494Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1738494Sobrien * notice, this list of conditions and the following disclaimer in the 1838494Sobrien * documentation and/or other materials provided with the distribution. 1938494Sobrien * 3. All advertising materials mentioning features or use of this software 2042629Sobrien * must display the following acknowledgment: 2138494Sobrien * This product includes software developed by the University of 2238494Sobrien * California, Berkeley and its contributors. 2338494Sobrien * 4. Neither the name of the University nor the names of its contributors 2438494Sobrien * may be used to endorse or promote products derived from this software 2538494Sobrien * without specific prior written permission. 2638494Sobrien * 2738494Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2838494Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2938494Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 3038494Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3138494Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3238494Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3338494Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3438494Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3538494Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3638494Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3738494Sobrien * SUCH DAMAGE. 3838494Sobrien * 3938494Sobrien * 40174294Sobrien * File: am-utils/amq/amq_xdr.c 4138494Sobrien * 4238494Sobrien */ 4338494Sobrien 4438494Sobrien#ifdef HAVE_CONFIG_H 4538494Sobrien# include <config.h> 4638494Sobrien#endif /* HAVE_CONFIG_H */ 4738494Sobrien#include <am_defs.h> 4838494Sobrien#include <amq.h> 4938494Sobrien 5038494Sobrien 5138494Sobrienbool_t 5238494Sobrienxdr_time_type(XDR *xdrs, time_type *objp) 5338494Sobrien{ 5438494Sobrien if (!xdr_long(xdrs, (long *) objp)) { 5538494Sobrien return (FALSE); 5638494Sobrien } 5738494Sobrien return (TRUE); 5838494Sobrien} 5938494Sobrien 6038494Sobrien 6138494Sobrienbool_t 6238494Sobrienxdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp) 6338494Sobrien{ 6438494Sobrien 6538494Sobrien if (!xdr_amq_string(xdrs, &objp->mt_mountinfo)) { 6638494Sobrien return (FALSE); 6738494Sobrien } 6838494Sobrien 6938494Sobrien if (!xdr_amq_string(xdrs, &objp->mt_directory)) { 7038494Sobrien return (FALSE); 7138494Sobrien } 7238494Sobrien 7338494Sobrien if (!xdr_amq_string(xdrs, &objp->mt_mountpoint)) { 7438494Sobrien return (FALSE); 7538494Sobrien } 7638494Sobrien 7738494Sobrien if (!xdr_amq_string(xdrs, &objp->mt_type)) { 7838494Sobrien return (FALSE); 7938494Sobrien } 8038494Sobrien 8138494Sobrien if (!xdr_time_type(xdrs, &objp->mt_mounttime)) { 8238494Sobrien return (FALSE); 8338494Sobrien } 8438494Sobrien 8538494Sobrien if (!xdr_u_short(xdrs, &objp->mt_mountuid)) { 8638494Sobrien return (FALSE); 8738494Sobrien } 8838494Sobrien 8938494Sobrien if (!xdr_int(xdrs, &objp->mt_getattr)) { 9038494Sobrien return (FALSE); 9138494Sobrien } 9238494Sobrien 9338494Sobrien if (!xdr_int(xdrs, &objp->mt_lookup)) { 9438494Sobrien return (FALSE); 9538494Sobrien } 9638494Sobrien 9738494Sobrien if (!xdr_int(xdrs, &objp->mt_readdir)) { 9838494Sobrien return (FALSE); 9938494Sobrien } 10038494Sobrien 10138494Sobrien if (!xdr_int(xdrs, &objp->mt_readlink)) { 10238494Sobrien return (FALSE); 10338494Sobrien } 10438494Sobrien 10538494Sobrien if (!xdr_int(xdrs, &objp->mt_statfs)) { 10638494Sobrien return (FALSE); 10738494Sobrien } 10838494Sobrien 109174294Sobrien if (!xdr_pointer(xdrs, 110174294Sobrien (char **) ((voidp) &objp->mt_next), 111174294Sobrien sizeof(amq_mount_tree), 112174294Sobrien (XDRPROC_T_TYPE) xdr_amq_mount_tree)) { 11338494Sobrien return (FALSE); 11438494Sobrien } 11538494Sobrien 116174294Sobrien if (!xdr_pointer(xdrs, 117174294Sobrien (char **) ((voidp) &objp->mt_child), 118174294Sobrien sizeof(amq_mount_tree), 119174294Sobrien (XDRPROC_T_TYPE) xdr_amq_mount_tree)) { 12038494Sobrien return (FALSE); 12138494Sobrien } 12238494Sobrien 12338494Sobrien return (TRUE); 12438494Sobrien} 12538494Sobrien 12638494Sobrien 12738494Sobrienbool_t 12838494Sobrienxdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp) 12938494Sobrien{ 130174294Sobrien if (!xdr_pointer(xdrs, 131174294Sobrien (char **) objp, 132174294Sobrien sizeof(amq_mount_tree), 133174294Sobrien (XDRPROC_T_TYPE) xdr_amq_mount_tree)) { 13438494Sobrien return (FALSE); 13538494Sobrien } 13638494Sobrien return (TRUE); 13738494Sobrien} 13838494Sobrien 13938494Sobrien 14038494Sobrienbool_t 14138494Sobrienxdr_amq_mount_info(XDR *xdrs, amq_mount_info *objp) 14238494Sobrien{ 14338494Sobrien 14438494Sobrien if (!xdr_amq_string(xdrs, &objp->mi_type)) { 14538494Sobrien return (FALSE); 14638494Sobrien } 14738494Sobrien 14838494Sobrien if (!xdr_amq_string(xdrs, &objp->mi_mountpt)) { 14938494Sobrien return (FALSE); 15038494Sobrien } 15138494Sobrien 15238494Sobrien if (!xdr_amq_string(xdrs, &objp->mi_mountinfo)) { 15338494Sobrien return (FALSE); 15438494Sobrien } 15538494Sobrien 15638494Sobrien if (!xdr_amq_string(xdrs, &objp->mi_fserver)) { 15738494Sobrien return (FALSE); 15838494Sobrien } 15938494Sobrien 16038494Sobrien if (!xdr_int(xdrs, &objp->mi_error)) { 16138494Sobrien return (FALSE); 16238494Sobrien } 16338494Sobrien 16438494Sobrien if (!xdr_int(xdrs, &objp->mi_refc)) { 16538494Sobrien return (FALSE); 16638494Sobrien } 16738494Sobrien 16838494Sobrien if (!xdr_int(xdrs, &objp->mi_up)) { 16938494Sobrien return (FALSE); 17038494Sobrien } 17138494Sobrien 17238494Sobrien return (TRUE); 17338494Sobrien} 17438494Sobrien 17538494Sobrien 17638494Sobrienbool_t 17738494Sobrienxdr_amq_mount_info_list(XDR *xdrs, amq_mount_info_list *objp) 17838494Sobrien{ 17938494Sobrien if (!xdr_array(xdrs, 180174294Sobrien (char **) ((voidp) &objp->amq_mount_info_list_val), 18138494Sobrien (u_int *) &objp->amq_mount_info_list_len, 18238494Sobrien ~0, 18338494Sobrien sizeof(amq_mount_info), 18438494Sobrien (XDRPROC_T_TYPE) xdr_amq_mount_info)) { 18538494Sobrien return (FALSE); 18638494Sobrien } 18738494Sobrien return (TRUE); 18838494Sobrien} 18938494Sobrien 19038494Sobrien 19138494Sobrienbool_t 19238494Sobrienxdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp) 19338494Sobrien{ 19438494Sobrien if (!xdr_array(xdrs, 195174294Sobrien (char **) ((voidp) &objp->amq_mount_tree_list_val), 19638494Sobrien (u_int *) &objp->amq_mount_tree_list_len, 19738494Sobrien ~0, 19838494Sobrien sizeof(amq_mount_tree_p), 19938494Sobrien (XDRPROC_T_TYPE) xdr_amq_mount_tree_p)) { 20038494Sobrien return (FALSE); 20138494Sobrien } 20238494Sobrien return (TRUE); 20338494Sobrien} 20438494Sobrien 20538494Sobrien 20638494Sobrienbool_t 20738494Sobrienxdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp) 20838494Sobrien{ 20938494Sobrien 21038494Sobrien if (!xdr_int(xdrs, &objp->as_drops)) { 21138494Sobrien return (FALSE); 21238494Sobrien } 21338494Sobrien 21438494Sobrien if (!xdr_int(xdrs, &objp->as_stale)) { 21538494Sobrien return (FALSE); 21638494Sobrien } 21738494Sobrien 21838494Sobrien if (!xdr_int(xdrs, &objp->as_mok)) { 21938494Sobrien return (FALSE); 22038494Sobrien } 22138494Sobrien 22238494Sobrien if (!xdr_int(xdrs, &objp->as_merr)) { 22338494Sobrien return (FALSE); 22438494Sobrien } 22538494Sobrien 22638494Sobrien if (!xdr_int(xdrs, &objp->as_uerr)) { 22738494Sobrien return (FALSE); 22838494Sobrien } 22938494Sobrien 23038494Sobrien return (TRUE); 23138494Sobrien} 23238494Sobrien 23338494Sobrien 23438494Sobrienbool_t 23538494Sobrienxdr_amq_opt(XDR *xdrs, amq_opt *objp) 23638494Sobrien{ 23738494Sobrien if (!xdr_enum(xdrs, (enum_t *) objp)) { 23838494Sobrien return (FALSE); 23938494Sobrien } 24038494Sobrien return (TRUE); 24138494Sobrien} 24238494Sobrien 24338494Sobrien 24438494Sobrienbool_t 24538494Sobrienxdr_amq_setopt(XDR *xdrs, amq_setopt *objp) 24638494Sobrien{ 24738494Sobrien 24838494Sobrien if (!xdr_amq_opt(xdrs, &objp->as_opt)) { 24938494Sobrien return (FALSE); 25038494Sobrien } 25138494Sobrien 25238494Sobrien if (!xdr_amq_string(xdrs, &objp->as_str)) { 25338494Sobrien return (FALSE); 25438494Sobrien } 25538494Sobrien 25638494Sobrien return (TRUE); 25738494Sobrien} 25838494Sobrien 25938494Sobrien 26038494Sobrienbool_t 26138494Sobrienxdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr) 26238494Sobrien{ 26338494Sobrien XDR xdr; 26438494Sobrien 26538494Sobrien xdr.x_op = XDR_FREE; 26638494Sobrien return ((*xdr_args) (&xdr, (caddr_t *) args_ptr)); 26738494Sobrien} 268