Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:19

0001 /*  $NetBSD: fts.h,v 1.14 2005/09/13 01:44:32 christos Exp $    */
0002 
0003 /*
0004  * Copyright (c) 1989, 1993
0005  *  The Regents of the University of California.  All rights reserved.
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  * 3. Neither the name of the University nor the names of its contributors
0016  *    may be used to endorse or promote products derived from this software
0017  *    without specific prior written permission.
0018  *
0019  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
0020  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0022  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
0023  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0024  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0025  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0026  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0027  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0028  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0029  * SUCH DAMAGE.
0030  *
0031  *  @(#)fts.h   8.3 (Berkeley) 8/14/94
0032  */
0033 
0034 #ifndef _FTS_H_
0035 #define _FTS_H_
0036 
0037 #ifndef __fts_stat_t
0038 #define __fts_stat_t    struct stat
0039 #endif
0040 #ifndef __fts_nlink_t
0041 #define __fts_nlink_t   nlink_t
0042 #endif
0043 #ifndef __fts_ino_t
0044 #define __fts_ino_t ino_t
0045 #endif
0046 
0047 typedef struct {
0048     struct _ftsent *fts_cur;    /* current node */
0049     struct _ftsent *fts_child;  /* linked list of children */
0050     struct _ftsent **fts_array; /* sort array */
0051     dev_t fts_dev;          /* starting device # */
0052     char *fts_path;         /* path for this descent */
0053     int fts_rfd;            /* fd for root */
0054     u_int fts_pathlen;      /* sizeof(path) */
0055     u_int fts_nitems;       /* elements in the sort array */
0056     int (*fts_compar)       /* compare function */
0057         (const struct _ftsent **, const struct _ftsent **);
0058 
0059 #define FTS_COMFOLLOW   0x001       /* follow command line symlinks */
0060 #define FTS_LOGICAL 0x002       /* logical walk */
0061 #define FTS_NOCHDIR 0x004       /* don't change directories */
0062 #define FTS_NOSTAT  0x008       /* don't get stat info */
0063 #define FTS_PHYSICAL    0x010       /* physical walk */
0064 #define FTS_SEEDOT  0x020       /* return dot and dot-dot */
0065 #define FTS_XDEV    0x040       /* don't cross devices */
0066 #define FTS_WHITEOUT    0x080       /* return whiteout information */
0067 #define FTS_OPTIONMASK  0x0ff       /* valid user option mask */
0068 
0069 #define FTS_NAMEONLY    0x100       /* (private) child names only */
0070 #define FTS_STOP    0x200       /* (private) unrecoverable error */
0071     int fts_options;        /* fts_open options, global flags */
0072 } FTS;
0073 
0074 typedef struct _ftsent {
0075     struct _ftsent *fts_cycle;  /* cycle node */
0076     struct _ftsent *fts_parent; /* parent directory */
0077     struct _ftsent *fts_link;   /* next file in directory */
0078     long fts_number;            /* local numeric value */
0079     void *fts_pointer;          /* local address value */
0080     char *fts_accpath;      /* access path */
0081     char *fts_path;         /* root path */
0082     int fts_errno;          /* errno for this node */
0083     int fts_symfd;          /* fd for symlink */
0084     u_short fts_pathlen;        /* strlen(fts_path) */
0085     u_short fts_namelen;        /* strlen(fts_name) */
0086 
0087     __fts_ino_t fts_ino;        /* inode */
0088     dev_t fts_dev;          /* device */
0089     __fts_nlink_t fts_nlink;    /* link count */
0090 
0091 #define FTS_ROOTPARENTLEVEL -1
0092 #define FTS_ROOTLEVEL        0
0093     short fts_level;        /* depth (-1 to N) */
0094 
0095 #define FTS_D        1      /* preorder directory */
0096 #define FTS_DC       2      /* directory that causes cycles */
0097 #define FTS_DEFAULT  3      /* none of the above */
0098 #define FTS_DNR      4      /* unreadable directory */
0099 #define FTS_DOT      5      /* dot or dot-dot */
0100 #define FTS_DP       6      /* postorder directory */
0101 #define FTS_ERR      7      /* error; errno is set */
0102 #define FTS_F        8      /* regular file */
0103 #define FTS_INIT     9      /* initialized only */
0104 #define FTS_NS      10      /* stat(2) failed */
0105 #define FTS_NSOK    11      /* no stat(2) requested */
0106 #define FTS_SL      12      /* symbolic link */
0107 #define FTS_SLNONE  13      /* symbolic link without target */
0108 #define FTS_W       14      /* whiteout object */
0109     u_short fts_info;       /* user flags for FTSENT structure */
0110 
0111 #define FTS_DONTCHDIR    0x01       /* don't chdir .. to the parent */
0112 #define FTS_SYMFOLLOW    0x02       /* followed a symlink to get here */
0113 #define FTS_ISW      0x04       /* this is a whiteout object */
0114     u_short fts_flags;      /* private flags for FTSENT structure */
0115 
0116 #define FTS_AGAIN    1      /* read node again */
0117 #define FTS_FOLLOW   2      /* follow symbolic link */
0118 #define FTS_NOINSTR  3      /* no instructions */
0119 #define FTS_SKIP     4      /* discard node */
0120     u_short fts_instr;      /* fts_set() instructions */
0121 
0122     __fts_stat_t *fts_statp;    /* stat(2) information */
0123     char fts_name[1];       /* file name */
0124 } FTSENT;
0125 
0126 #include <sys/cdefs.h>
0127 
0128 #define __RENAME(n)
0129 #define fts_children rtems_shell_fts_children
0130 #define fts_close    rtems_shell_fts_close
0131 #define fts_open     rtems_shell_fts_open
0132 #define fts_read     rtems_shell_fts_read
0133 #define fts_set      rtems_shell_fts_set
0134 
0135 __BEGIN_DECLS
0136 #ifndef __LIBC12_SOURCE__
0137 FTSENT  *fts_children(FTS *, int)       __RENAME(__fts_children30);
0138 int  fts_close(FTS *)           __RENAME(__fts_close30);
0139 FTS *fts_open(char * const *, int,
0140     int (*)(const FTSENT **, const FTSENT **))  __RENAME(__fts_open30);
0141 FTSENT  *fts_read(FTS *)            __RENAME(__fts_read30);
0142 int  fts_set(FTS *, FTSENT *, int)      __RENAME(__fts_set30);
0143 #endif
0144 __END_DECLS
0145 
0146 #endif /* !_FTS_H_ */