FreeBSD/usr.sbin/mountd/mountd.c
/*
 * Called from xdr_explist() to traverse the tree and export the
 * directory paths.
 */
Called from xdr_explist() to traverse the tree and export the
directory paths.
Called from xdr_explist () to traverse the tree and export the directory paths .
static int
put_exlist(struct dirlist *dp, XDR *xdrsp, struct dirlist *adp, int *putdefp,
	int brief)
{
	struct grouplist *grp;
	struct hostlist *hp;
	int true = 1;
	int false = 0;
	int gotalldir = 0;
	char *strp;
	if (dp) {
		if (put_exlist(dp->dp_left, xdrsp, adp, putdefp, brief))
			return (1);
		if (!xdr_bool(xdrsp, &true))
			return (1);
		strp = dp->dp_dirp;
		if (!xdr_string(xdrsp, &strp, MNTPATHLEN))
			return (1);
		if (adp && !strcmp(dp->dp_dirp, adp->dp_dirp)) {
			gotalldir = 1;
			*putdefp = 1;
		}
		if (brief) {
			if (!xdr_bool(xdrsp, &true))
				return (1);
			strp = "(...)";
			if (!xdr_string(xdrsp, &strp, MNTPATHLEN))
				return (1);
		} else if ((dp->dp_flag & DP_DEFSET) == 0 &&
		    (gotalldir == 0 || (adp->dp_flag & DP_DEFSET) == 0)) {
			hp = dp->dp_hosts;
			while (hp) {
				grp = hp->ht_grp;
				if (grp->gr_type == GT_HOST) {
					if (!xdr_bool(xdrsp, &true))
						return (1);
					strp = grp->gr_ptr.gt_addrinfo->ai_canonname;
					if (!xdr_string(xdrsp, &strp,
					    MNTNAMLEN))
						return (1);
				} else if (grp->gr_type == GT_NET) {
					if (!xdr_bool(xdrsp, &true))
						return (1);
					strp = grp->gr_ptr.gt_net.nt_name;
					if (!xdr_string(xdrsp, &strp,
					    MNTNAMLEN))
						return (1);
				}
				hp = hp->ht_next;
				if (gotalldir && hp == (struct hostlist *)NULL) {
					hp = adp->dp_hosts;
					gotalldir = 0;
				}
			}
		}
		if (!xdr_bool(xdrsp, &false))
			return (1);
		if (put_exlist(dp->dp_right, xdrsp, adp, putdefp, brief))
			return (1);
	}
	return (0);
}
static int put_exlist ( struct dirlist * dp , XDR * xdrsp , struct dirlist * adp , int * putdefp , int brief ) { struct grouplist * grp ; struct hostlist * hp ; int true = 1 ; int false = 0 ; int gotalldir = 0 ; char * strp ; if ( dp ) { if ( put_exlist ( dp -> dp_left , xdrsp , adp , putdefp , brief ) ) return ( 1 ) ; if ( ! xdr_bool ( xdrsp , & true ) ) return ( 1 ) ; strp = dp -> dp_dirp ; if ( ! xdr_string ( xdrsp , & strp , MNTPATHLEN ) ) return ( 1 ) ; if ( adp && ! strcmp ( dp -> dp_dirp , adp -> dp_dirp ) ) { gotalldir = 1 ; * putdefp = 1 ; } if ( brief ) { if ( ! xdr_bool ( xdrsp , & true ) ) return ( 1 ) ; strp = " " ; if ( ! xdr_string ( xdrsp , & strp , MNTPATHLEN ) ) return ( 1 ) ; } else if ( ( dp -> dp_flag & DP_DEFSET ) == 0 && ( gotalldir == 0 || ( adp -> dp_flag & DP_DEFSET ) == 0 ) ) { hp = dp -> dp_hosts ; while ( hp ) { grp = hp -> ht_grp ; if ( grp -> gr_type == GT_HOST ) { if ( ! xdr_bool ( xdrsp , & true ) ) return ( 1 ) ; strp = grp -> gr_ptr . gt_addrinfo -> ai_canonname ; if ( ! xdr_string ( xdrsp , & strp , MNTNAMLEN ) ) return ( 1 ) ; } else if ( grp -> gr_type == GT_NET ) { if ( ! xdr_bool ( xdrsp , & true ) ) return ( 1 ) ; strp = grp -> gr_ptr . gt_net . nt_name ; if ( ! xdr_string ( xdrsp , & strp , MNTNAMLEN ) ) return ( 1 ) ; } hp = hp -> ht_next ; if ( gotalldir && hp == ( struct hostlist * ) NULL ) { hp = adp -> dp_hosts ; gotalldir = 0 ; } } } if ( ! xdr_bool ( xdrsp , & false ) ) return ( 1 ) ; if ( put_exlist ( dp -> dp_right , xdrsp , adp , putdefp , brief ) ) return ( 1 ) ; } return ( 0 ) ; }
Called from xdr_explist() to traverse the tree and export the
 directory paths.
Called from xdr_explist () to traverse the tree and export the directory paths .