2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1998 by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A */
2N/A
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A
2N/A#include <stdio.h> /* for fprintf() */
2N/A#include <stdlib.h> /* for malloc() */
2N/A#include <rpc/types.h>
2N/A#include <rpc/xdr.h>
2N/A#include <rpcsvc/mount.h>
2N/A
2N/A
2N/A/*
2N/A * XDR routines to handle mountlist structure
2N/A *
2N/A * These are iterative versions to avoid the stack-blowing problems of
2N/A * the recursive routines generated by rpcgen.
2N/A *
2N/A * XXXX These should be removed when rpcgen is fixed to produce better
2N/A * code in these circumstances.
2N/A */
2N/A
2N/A
2N/Abool_t
2N/Axdr_mountlist(xdrs, objp)
2N/A register XDR *xdrs;
2N/A mountlist *objp;
2N/A{
2N/A bool_t more_data;
2N/A
2N/A switch (xdrs->x_op) {
2N/A
2N/A case XDR_FREE: {
2N/A mountbody *mb, *tmp;
2N/A
2N/A tmp = *objp;
2N/A
2N/A while (tmp != NULL) {
2N/A mb = tmp;
2N/A tmp = mb->ml_next;
2N/A if (!xdr_name(xdrs, &mb->ml_hostname))
2N/A return (FALSE);
2N/A if (!xdr_dirpath(xdrs, &mb->ml_directory))
2N/A return (FALSE);
2N/A free(mb);
2N/A }
2N/A
2N/A break;
2N/A }
2N/A
2N/A case XDR_DECODE: {
2N/A mountbody *mb;
2N/A mountbody *mb_prev = NULL;
2N/A
2N/A for (;;) {
2N/A if (!xdr_bool(xdrs, &more_data))
2N/A return (FALSE);
2N/A
2N/A if (!more_data)
2N/A break;
2N/A
2N/A mb = (mountbody *)malloc(sizeof (struct mountbody));
2N/A if (mb == NULL) {
2N/A fprintf(stderr,
2N/A "xdr_mountlist: out of memory\n");
2N/A return (FALSE);
2N/A }
2N/A mb->ml_hostname = NULL;
2N/A mb->ml_directory = NULL;
2N/A mb->ml_next = NULL;
2N/A
2N/A if (mb_prev == NULL) {
2N/A mb_prev = mb;
2N/A *objp = mb;
2N/A }
2N/A
2N/A if (!xdr_name(xdrs, &mb->ml_hostname))
2N/A return (FALSE);
2N/A if (!xdr_dirpath(xdrs, &mb->ml_directory))
2N/A return (FALSE);
2N/A
2N/A if (mb_prev != mb) {
2N/A mb_prev->ml_next = mb;
2N/A mb_prev = mb;
2N/A }
2N/A }
2N/A break;
2N/A }
2N/A
2N/A case XDR_ENCODE: {
2N/A mountbody *mb;
2N/A
2N/A mb = *objp;
2N/A
2N/A for (;;) {
2N/A more_data = mb != NULL;
2N/A
2N/A if (!xdr_bool(xdrs, &more_data))
2N/A return (FALSE);
2N/A
2N/A if (!more_data)
2N/A break;
2N/A
2N/A if (!xdr_name(xdrs, &mb->ml_hostname))
2N/A return (FALSE);
2N/A if (!xdr_dirpath(xdrs, &mb->ml_directory))
2N/A return (FALSE);
2N/A
2N/A mb = mb->ml_next;
2N/A }
2N/A break;
2N/A }
2N/A
2N/A default:
2N/A break;
2N/A }
2N/A
2N/A return (TRUE);
2N/A}
2N/A
2N/A
2N/A/*
2N/A * xdr_mountbody() is included here simply for backward compatibility. It is
2N/A * no longer used by xdr_mountlist(), nor by any other SunOS routine as of
2N/A * now.
2N/A *
2N/A * This is simply a copy of the rpcgen generated routine.
2N/A */
2N/Abool_t
2N/Axdr_mountbody(xdrs, objp)
2N/A register XDR *xdrs;
2N/A mountbody *objp;
2N/A{
2N/A if (!xdr_name(xdrs, &objp->ml_hostname))
2N/A return (FALSE);
2N/A if (!xdr_dirpath(xdrs, &objp->ml_directory))
2N/A return (FALSE);
2N/A if (!xdr_mountlist(xdrs, &objp->ml_next))
2N/A return (FALSE);
2N/A return (TRUE);
2N/A}