char leaf [strlen (name) + 3]; char domain [strlen (name) + 3]; char ndomain [strlen (name) + 3];
size_t namelen = strlen (name); char leaf [namelen + 3]; char domain [namelen + 3]; char ndomain [namelen + 3];
rec_dirsearch (const_nis_name name, directory_obj *dir, u_long flags,	       nis_error *status){  fd_result *fd_res;  XDR xdrs;  switch (nis_dir_cmp (name, dir->do_name))    {    case SAME_NAME:      *status = NIS_SUCCESS;      return dir;    case NOT_SEQUENTIAL:      /* NOT_SEQUENTIAL means, go one up and try it there ! */    case HIGHER_NAME:      { /* We need data from a parent domain */	directory_obj *obj;	char ndomain [strlen (name) + 3];	nis_domain_of_r (dir->do_name, ndomain, sizeof (ndomain));	/* The root server of our domain is a replica of the parent	   domain ! (Now I understand why a root server must be a	   replica of the parent domain) */	fd_res = __nis_finddirectory (dir, ndomain);	*status = fd_res->status;	if (fd_res->status != NIS_SUCCESS)	  {	    /* Try the current directory obj, maybe it works */	    __free_fdresult (fd_res);	    return dir;	  }	obj = calloc(1, sizeof(directory_obj));	xdrmem_create(&xdrs, fd_res->dir_data.dir_data_val,		      fd_res->dir_data.dir_data_len, XDR_DECODE);	_xdr_directory_obj(&xdrs, obj);	xdr_destroy(&xdrs);	__free_fdresult (fd_res);	if (obj != NULL)	  {	    /* We have found a NIS+ server serving ndomain, now	       let us search for "name" */	    nis_free_directory (dir);	    return rec_dirsearch (name, obj, flags, status);	  }	else	  {	    /* Ups, very bad. Are we already the root server ? */	    nis_free_directory (dir);	    return NULL;	  }      }    break;    case LOWER_NAME:      {	directory_obj *obj;	char leaf [strlen (name) + 3];	char domain [strlen (name) + 3];	char ndomain [strlen (name) + 3];	char *cp;	u_int run = 0;	strcpy (domain, name);	do	  {	    if (strlen (domain) == 0)	      {		nis_free_directory (dir);		return NULL;	      }	    nis_leaf_of_r (domain, leaf, sizeof (leaf));	    nis_domain_of_r (domain, ndomain, sizeof (ndomain));	    strcpy (domain, ndomain);	    ++run;	  }	while (nis_dir_cmp (domain, dir->do_name) != SAME_NAME);	if (run == 1)	  {	    /* We have found the directory above. Use it. */	    return dir;	  }	cp = strchr (leaf, '\0');	*cp++ = '.';	strcpy (cp, domain);	fd_res = __nis_finddirectory (dir, leaf);	*status = fd_res->status;	if (fd_res->status != NIS_SUCCESS)	  {	    /* Try the current directory object, maybe it works */	    __free_fdresult (fd_res);	    return dir;	  }	obj = calloc(1, sizeof(directory_obj));	xdrmem_create(&xdrs, fd_res->dir_data.dir_data_val,		      fd_res->dir_data.dir_data_len, XDR_DECODE);	_xdr_directory_obj(&xdrs, obj);	xdr_destroy(&xdrs);	__free_fdresult (fd_res);	if (obj != NULL)	  {	    /* We have found a NIS+ server serving ndomain, now	       let us search for "name" */	    nis_free_directory (dir);	    return rec_dirsearch (name, obj, flags, status);	  }      }    break;    case BAD_NAME:      nis_free_directory (dir);      *status = NIS_BADNAME;      return NULL;    }  nis_free_directory (dir);  *status = NIS_FAIL;  return NULL;}