1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _PATHNAME_H 28 #define _PATHNAME_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" /* from SunOS4.1 2.12 */ 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 /* 37 * Pathname structure. 38 * System calls which operate on path names gather the 39 * pathname from system call into this structure and reduce 40 * it by peeling off translated components. If a symbolic 41 * link is encountered the new pathname to be translated 42 * is also assembled in this structure. 43 */ 44 45 struct pathname { 46 char *pn_buf; /* underlying storage */ 47 char *pn_path; /* remaining pathname */ 48 uint_t pn_pathlen; /* remaining length */ 49 }; 50 51 #define PN_STRIP 0x00 /* Strip next component off pn */ 52 #define PN_PEEK 0x01 /* Only peek at next pn component */ 53 #define pn_peekcomponent(PNP, COMP) pn_getcomponent(PNP, COMP, PN_PEEK) 54 #define pn_stripcomponent(PNP, COMP) pn_getcomponent(PNP, COMP, PN_STRIP) 55 56 #define pn_peekchar(PNP) (((PNP)->pn_pathlen != 0) ? \ 57 *((PNP)->pn_path) : (char)0) 58 #define pn_pathleft(PNP) ((PNP)->pn_pathlen) 59 #define pn_getpath(PNP) ((PNP)->pn_path) 60 #define pn_copy(PNP1, PNP2) (pn_set(PNP2, pn_getpath(PNP1))) 61 62 extern int pn_alloc(); /* allocat buffer for pathname */ 63 extern int pn_get(); /* allocate buf and copy path into it */ 64 #ifdef notneeded 65 extern int pn_getchar(); /* get next pathname char */ 66 #endif 67 extern int pn_set(); /* set pathname to string */ 68 extern int pn_combine(); /* combine to pathnames (for symlink) */ 69 extern int pn_getcomponent(); /* get next component of pathname */ 70 extern void pn_skipslash(); /* skip over slashes */ 71 extern void pn_free(); /* free pathname buffer */ 72 extern int pn_append(); /* Append string to pathname */ 73 extern int pn_getlast(); /* Get last component of pathname */ 74 75 #ifdef __cplusplus 76 } 77 #endif 78 79 #endif /* _PATHNAME_H */ 80