home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / pathname.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  2.4 KB  |  58 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _SYS_PATHNAME_H
  11. #define _SYS_PATHNAME_H
  12.  
  13. #ident    "@(#)/usr/include/sys/pathname.h.sl 1.1 4.0 12/08/90 7819 AT&T-USL"
  14. /*
  15.  * Pathname structure.
  16.  * System calls that operate on path names gather the path name
  17.  * from the system call into this structure and reduce it by
  18.  * peeling off translated components.  If a symbolic link is
  19.  * encountered the new path name to be translated is also
  20.  * assembled in this structure.
  21.  *
  22.  * By convention pn_buf is not changed once it's been set to point
  23.  * to the underlying storage; routines which manipulate the pathname
  24.  * do so by changing pn_path and pn_pathlen.  pn_pathlen is redundant
  25.  * since the path name is null-terminated, but is provided to make
  26.  * some computations faster.
  27.  */
  28. typedef struct pathname {
  29.     char    *pn_buf;        /* underlying storage */
  30.     char    *pn_path;        /* remaining pathname */
  31.     u_int    pn_pathlen;        /* remaining length */
  32. } pathname_t;
  33.  
  34. #define PN_STRIP    0    /* Strip next component from pn */
  35. #define PN_PEEK        1    /* Only peek at next component of pn */
  36. #define pn_peekcomponent(pnp, comp) pn_getcomponent(pnp, comp, PN_PEEK)
  37. #define pn_stripcomponent(pnp, comp) pn_getcomponent(pnp, comp, PN_STRIP)
  38.  
  39. #define    pn_peekchar(pnp)    ((pnp)->pn_pathlen > 0 ? *((pnp)->pn_path) : 0)
  40. #define pn_pathleft(pnp)    ((pnp)->pn_pathlen)
  41.  
  42. extern void    pn_alloc();        /* allocate buffer for pathname */
  43. extern int    pn_get();        /* allocate buffer, copy path into it */
  44. extern int    pn_set();        /* set pathname to string */
  45. extern int    pn_insert();        /* combine two pathnames (symlink) */
  46. extern int    pn_getsymlink();    /* get symlink into pathname */
  47. extern int    pn_getcomponent();    /* get next component of pathname */
  48. extern void    pn_setlast();        /* set pathname to last component */
  49. extern void    pn_skipslash();        /* skip over slashes */
  50. extern void    pn_fixslash();        /* eliminate trailing slashes */
  51. extern void    pn_free();        /* free pathname buffer */
  52.  
  53. extern int    lookupname();        /* convert name to vnode */
  54. extern int    lookuppn();        /* convert pathname buffer to vnode */
  55. extern int    traverse();        /* traverse a mount point */
  56.  
  57. #endif    /* _SYS_PATHNAME_H */
  58.