17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
5d67944fScott Rotondo * Common Development and Distribution License (the "License").
6d67944fScott Rotondo * You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate *
87c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate * See the License for the specific language governing permissions
117c478bdstevel@tonic-gate * and limitations under the License.
127c478bdstevel@tonic-gate *
137c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate *
197c478bdstevel@tonic-gate * CDDL HEADER END
207c478bdstevel@tonic-gate */
21d67944fScott Rotondo
227c478bdstevel@tonic-gate/*
23d67944fScott Rotondo * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
247c478bdstevel@tonic-gate * Use is subject to license terms.
257c478bdstevel@tonic-gate */
267c478bdstevel@tonic-gate
27d67944fScott Rotondo#ifndef _ST_PATHNAME_H
28d67944fScott Rotondo#define	_ST_PATHNAME_H
297c478bdstevel@tonic-gate
307c478bdstevel@tonic-gate#ifdef	__cplusplus
317c478bdstevel@tonic-gateextern "C" {
327c478bdstevel@tonic-gate#endif
337c478bdstevel@tonic-gate
347c478bdstevel@tonic-gate/*
357c478bdstevel@tonic-gate * Pathname structure.
367c478bdstevel@tonic-gate * System calls which operate on path names gather the
377c478bdstevel@tonic-gate * pathname from system call into this structure and reduce
387c478bdstevel@tonic-gate * it by peeling off translated components.  If a symbolic
397c478bdstevel@tonic-gate * link is encountered the new pathname to be translated
407c478bdstevel@tonic-gate * is also assembled in this structure.
417c478bdstevel@tonic-gate */
427c478bdstevel@tonic-gate
43d67944fScott Rotondostruct st_pathname {
447c478bdstevel@tonic-gate	char	*pn_buf;		/* underlying storage */
457c478bdstevel@tonic-gate	char	*pn_path;		/* remaining pathname */
467c478bdstevel@tonic-gate	uint_t	pn_pathlen;		/* remaining length */
477c478bdstevel@tonic-gate};
487c478bdstevel@tonic-gate
497c478bdstevel@tonic-gate#define	PN_STRIP 0x00		/* Strip next component off pn */
507c478bdstevel@tonic-gate#define	PN_PEEK	0x01  		/* Only peek at next pn component */
51d67944fScott Rotondo#define	stpn_peekcomponent(PNP, COMP) stpn_getcomponent(PNP, COMP, PN_PEEK)
52d67944fScott Rotondo#define	stpn_stripcomponent(PNP, COMP) stpn_getcomponent(PNP, COMP, PN_STRIP)
537c478bdstevel@tonic-gate
54d67944fScott Rotondo#define	stpn_peekchar(PNP) 	(((PNP)->pn_pathlen != 0) ? \
557c478bdstevel@tonic-gate				    *((PNP)->pn_path) : (char)0)
56d67944fScott Rotondo#define	stpn_pathleft(PNP)	((PNP)->pn_pathlen)
57d67944fScott Rotondo#define	stpn_getpath(PNP)		((PNP)->pn_path)
58d67944fScott Rotondo#define	stpn_copy(PNP1, PNP2)	(stpn_set(PNP2, stpn_getpath(PNP1)))
597c478bdstevel@tonic-gate
60d67944fScott Rotondoextern int	stpn_alloc();		/* allocate buffer for pathname */
61d67944fScott Rotondoextern int	stpn_get();		/* allocate buf and copy path into it */
62d67944fScott Rotondoextern int	stpn_set();		/* set pathname to string */
63d67944fScott Rotondoextern int	stpn_combine();		/* combine to pathnames (for symlink) */
64d67944fScott Rotondoextern int	stpn_getcomponent();	/* get next component of pathname */
65d67944fScott Rotondoextern void	stpn_skipslash();		/* skip over slashes */
66d67944fScott Rotondoextern void	stpn_free();		/* free pathname buffer */
677c478bdstevel@tonic-gate
687c478bdstevel@tonic-gate#ifdef	__cplusplus
697c478bdstevel@tonic-gate}
707c478bdstevel@tonic-gate#endif
717c478bdstevel@tonic-gate
72d67944fScott Rotondo#endif /* _ST_PATHNAME_H */
73