/*
*      SCCS:   @(#)install/userintf/gen_pathres	1.1 (01/21/97)  VSXgen release 1.4
*
*	UniSoft Ltd., London, England
*/
/***********************************************************************

NAME:		gen_pathres - user-modifiable pathname resolution routines
PROJECT:	VSX (X/OPEN Validation Suite)
AUTHOR:		Geoff Clare, UniSoft Ltd.
DATE CREATED:	December 1996
MODIFICATIONS:

************************************************************************/

/*
 *	Pathdepth() is used to determine the depth of pathnames
 *	beginning with "//" below the root directory of the process.
 *	The return value is such that a path equivalent to "/usr"
 *	gives a value of 1, one equivalent to "/usr/bin" gives 2, etc.
 *	The default code supplied is suitable for systems which use
 *	"//" to refer to a directory level above the root, i.e. when
 *	the root directory is referred to by "//somename".
 */

public int
pathdepth(path)
char *path;
{
	char *p;
	int dircnt = 0;

	/* count '/' characters after the initial "//" */
	for (p = &path[2]; *p != '\0'; p++)
	{
		if (*p == '/')
		{
			++dircnt;
			/* skip multiple '/'s */
			while (*(p+1) == '/')
				++p;
			/* watch out for trailing '/' */
			if (*(p+1) == '\0')
				--dircnt;
		}
	
	}

	return dircnt;
}

