Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

fts.c File Reference

#include "system.h"
#include "fts.h"
#include "rpmio.h"
#include "rpmurl.h"

Go to the source code of this file.

Defines

#define __set_errno(val)   (*__errno_location ()) = (val)
#define __open   open
#define __close   close
#define __fchdir   fchdir
#define ALIGNBYTES   (__alignof__ (long double) - 1)
#define ALIGN(p)   (((unsigned long int) (p) + ALIGNBYTES) & ~ALIGNBYTES)
#define MAX(a, b)
#define ISDOT(a)   (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
#define CLR(opt)   (sp->fts_options &= ~(opt))
#define ISSET(opt)   (sp->fts_options & (opt))
#define SET(opt)   (sp->fts_options |= (opt))
#define FCHDIR(sp, fd)   (!ISSET(FTS_NOCHDIR) && __fchdir(fd))
#define BCHILD   1
#define BNAMES   2
#define BREAD   3
#define MAXPATHLEN   1024
#define NAPPEND(p)
#define __opendir2(path, flag)   (*sp->fts_opendir) (path)
#define ADJUST(p)

Functions

FTSENTfts_alloc (FTS *sp, const char *name, int namelen)
FTSENTfts_build (FTS *sp, int type)
void fts_lfree (FTSENT *head)
void fts_load (FTS *sp, FTSENT *p)
size_t fts_maxarglen (char *const *argv)
void fts_padjust (FTS *sp, FTSENT *head)
int fts_palloc (FTS *sp, size_t more)
FTSENTfts_sort (FTS *sp, FTSENT *head, int nitems)
u_short fts_stat (FTS *sp, FTSENT *p, int follow)
int fts_safe_changedir (FTS *sp, FTSENT *p, int fd, const char *path)
FTSFts_open (char *const *argv, int options, int(*compar)(const FTSENT **, const FTSENT **))
 Create a handle for file hierarchy traversal.
int Fts_close (FTS *sp)
 Destroy a file hierarchy traversal handle.
FTSENTFts_read (FTS *sp)
 Return next node in the file hierarchy traversal.
int Fts_set (FTS *sp, FTSENT *p, int instr)
 Modify the traversal for a file set member.
FTSENTFts_children (FTS *sp, int instr)
 Return list of children of the current node.


Define Documentation

#define __close   close
 

Definition at line 68 of file fts.c.

Referenced by Fts_children(), Fts_close(), Fts_read(), and fts_safe_changedir().

#define __fchdir   fchdir
 

Definition at line 69 of file fts.c.

Referenced by Fts_children(), Fts_close(), and fts_safe_changedir().

#define __open   open
 

Definition at line 67 of file fts.c.

Referenced by Fts_children(), Fts_open(), Fts_read(), and fts_safe_changedir().

#define __opendir2 path,
flag   )     (*sp->fts_opendir) (path)
 

Referenced by fts_build().

#define __set_errno val   )     (*__errno_location ()) = (val)
 

Definition at line 66 of file fts.c.

Referenced by fts_build(), Fts_children(), Fts_close(), Fts_open(), fts_palloc(), Fts_read(), fts_safe_changedir(), Fts_set(), and fts_stat().

#define ADJUST  ) 
 

Value:

do {                                                    \
        if ((p)->fts_accpath != (p)->fts_name) {                        \
                (p)->fts_accpath =                                      \
                    (char *)addr + ((p)->fts_accpath - (p)->fts_path);  \
        }                                                               \
        (p)->fts_path = addr;                                           \
} while (0)

Referenced by fts_padjust().

#define ALIGN  )     (((unsigned long int) (p) + ALIGNBYTES) & ~ALIGNBYTES)
 

Definition at line 80 of file fts.c.

Referenced by fts_alloc().

#define ALIGNBYTES   (__alignof__ (long double) - 1)
 

Definition at line 76 of file fts.c.

#define BCHILD   1
 

Definition at line 125 of file fts.c.

Referenced by fts_build().

#define BNAMES   2
 

Definition at line 126 of file fts.c.

#define BREAD   3
 

Definition at line 127 of file fts.c.

Referenced by Fts_read().

#define CLR opt   )     (sp->fts_options &= ~(opt))
 

Definition at line 118 of file fts.c.

Referenced by Fts_read().

#define FCHDIR sp,
fd   )     (!ISSET(FTS_NOCHDIR) && __fchdir(fd))
 

Definition at line 122 of file fts.c.

Referenced by fts_build(), and Fts_read().

#define ISDOT  )     (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2])))
 

Definition at line 116 of file fts.c.

Referenced by fts_build(), and fts_stat().

#define ISSET opt   )     (sp->fts_options & (opt))
 

Definition at line 119 of file fts.c.

Referenced by fts_alloc(), fts_build(), Fts_children(), Fts_close(), Fts_open(), Fts_read(), fts_safe_changedir(), and fts_stat().

#define MAX a,
 ) 
 

Value:

({ __typeof__ (a) _a = (a); \
                           __typeof__ (b) _b = (b); \
                           _a > _b ? _a : _b; })

Definition at line 111 of file fts.c.

Referenced by Fts_open().

#define MAXPATHLEN   1024
 

#define NAPPEND  ) 
 

Value:

(p->fts_path[p->fts_pathlen - 1] == '/'                         \
            ? p->fts_pathlen - 1 : p->fts_pathlen)

Definition at line 353 of file fts.c.

Referenced by fts_build(), and Fts_read().

#define SET opt   )     (sp->fts_options |= (opt))
 

Definition at line 120 of file fts.c.

Referenced by fts_build(), Fts_children(), Fts_open(), and Fts_read().


Function Documentation

FTSENT * fts_alloc FTS sp,
const char *  name,
int  namelen
[static]
 

< don't get stat info

< don't get stat info

< no instructions

Definition at line 1045 of file fts.c.

References ALIGN, _ftsent::fts_errno, _ftsent::fts_flags, _ftsent::fts_instr, _ftsent::fts_name, _ftsent::fts_namelen, FTS_NOSTAT, _ftsent::fts_number, FTS::fts_path, _ftsent::fts_path, _ftsent::fts_pointer, _ftsent::fts_statp, FTSENT, and ISSET.

Referenced by fts_build(), and Fts_open().

FTSENT * fts_build FTS sp,
int  type
[static]
 

< unreadable directory

< don't get stat info

< physical walk

< return dot and dot-dot

< don't chdir .. to the parent

< don't change directories

< return dot and dot-dot

< error; errno is set

< (private) unrecoverable error

< don't change directories

< error; errno is set

< (private) unrecoverable error

< stat(2) failed

< no stat(2) requested

< don't change directories

< no stat(2) requested

< don't change directories

< preorder directory

< directory that causes cycles

< dot or dot-dot

< don't change directories

< don't change directories

< error; errno is set

< (private) unrecoverable error

< postorder directory

Definition at line 655 of file fts.c.

References __opendir2, __set_errno, BCHILD, dirent, DT_DIR, FCHDIR, _ftsent::fts_accpath, fts_alloc(), FTS::fts_closedir, FTS::fts_compar, FTS::fts_cur, FTS_D, FTS_DC, _ftsent::fts_errno, _ftsent::fts_flags, _ftsent::fts_info, _ftsent::fts_level, fts_lfree(), _ftsent::fts_link, _ftsent::fts_name, _ftsent::fts_namelen, _ftsent::fts_nlink, FTS_NOCHDIR, FTS_NOSTAT, fts_padjust(), fts_palloc(), _ftsent::fts_parent, _ftsent::fts_path, FTS::fts_path, _ftsent::fts_pathlen, FTS::fts_pathlen, FTS_PHYSICAL, FTS::fts_readdir, FTS::fts_rfd, FTS_ROOTLEVEL, fts_safe_changedir(), FTS_SEEDOT, fts_sort(), fts_stat(), FTS_STOP, FTS_WHITEOUT, FTSENT, ISDOT, ISSET, NAPPEND, and SET.

Referenced by Fts_children(), and Fts_read().

FTSENT* Fts_children FTS sp,
int  instr
 

Return list of children of the current node.

< (private) child names only

< (private) unrecoverable error

< initialized only

< preorder directory

< (private) child names only

< (private) child names only

< don't change directories

Definition at line 571 of file fts.c.

References __close, __fchdir, __open, __set_errno, _ftsent::fts_accpath, fts_build(), FTS::fts_child, FTS::fts_cur, FTS_D, _ftsent::fts_info, _ftsent::fts_level, fts_lfree(), _ftsent::fts_link, FTS_NAMEONLY, FTS_NOCHDIR, FTS_ROOTLEVEL, FTS_STOP, FTSENT, ISSET, and SET.

Referenced by rpmfts_Children().

int Fts_close FTS sp  ) 
 

Destroy a file hierarchy traversal handle.

< don't change directories

Definition at line 297 of file fts.c.

References __close, __fchdir, __set_errno, errno, FTS::fts_array, FTS::fts_child, FTS::fts_cur, _ftsent::fts_level, fts_lfree(), _ftsent::fts_link, FTS_NOCHDIR, _ftsent::fts_parent, FTS::fts_path, FTS::fts_rfd, FTSENT, and ISSET.

Referenced by main(), recurseDir(), and rpmfts_state().

void fts_lfree FTSENT head  )  [static]
 

Definition at line 1083 of file fts.c.

References _ftsent::fts_link, and FTSENT.

Referenced by fts_build(), Fts_children(), Fts_close(), Fts_open(), and Fts_read().

void fts_load FTS sp,
FTSENT p
[static]
 

Definition at line 271 of file fts.c.

References _ftsent::fts_accpath, _ftsent::fts_dev, FTS::fts_dev, _ftsent::fts_name, _ftsent::fts_namelen, _ftsent::fts_path, FTS::fts_path, _ftsent::fts_pathlen, and FTSENT.

Referenced by Fts_read().

size_t fts_maxarglen char *const *  argv  )  [static]
 

Definition at line 1163 of file fts.c.

References argv.

Referenced by Fts_open().

FTS* Fts_open char *const *  argv,
int  options,
int(*)(const FTSENT **, const FTSENT **)  compar
 

Create a handle for file hierarchy traversal.

< valid user option mask

< logical walk

< don't change directories

< don't change directories

< follow command line symlinks

< dot or dot-dot

< preorder directory

< initialized only

< don't change directories

< don't change directories

Definition at line 130 of file fts.c.

References __open, __set_errno, argv, _ftsent::fts_accpath, fts_alloc(), FTS_COMFOLLOW, _ftsent::fts_info, _ftsent::fts_level, fts_lfree(), _ftsent::fts_link, FTS_LOGICAL, fts_maxarglen(), _ftsent::fts_name, FTS_NOCHDIR, fts_palloc(), _ftsent::fts_parent, fts_sort(), fts_stat(), FTSENT, ISSET, MAX, MAXPATHLEN, SET, URL_IS_DASH, URL_IS_FTP, URL_IS_HTTP, URL_IS_PATH, URL_IS_UNKNOWN, and urlIsURL().

Referenced by main(), recurseDir(), and rpmfts_state().

void fts_padjust FTS sp,
FTSENT head
[static]
 

Definition at line 1139 of file fts.c.

References ADJUST, FTS::fts_child, _ftsent::fts_level, _ftsent::fts_link, _ftsent::fts_parent, FTS::fts_path, and FTSENT.

Referenced by fts_build().

int fts_palloc FTS sp,
size_t  more
[static]
 

Definition at line 1103 of file fts.c.

References __set_errno, FTS::fts_path, and FTS::fts_pathlen.

Referenced by fts_build(), and Fts_open().

FTSENT* Fts_read FTS sp  ) 
 

Return next node in the file hierarchy traversal.

< (private) unrecoverable error

< no instructions

< read node again

< follow symbolic link

< symbolic link

< symbolic link without target

< preorder directory

< don't change directories

< error; errno is set

< followed a symlink to get here

< preorder directory

< discard node

< don't cross devices

< followed a symlink to get here

< postorder directory

< (private) child names only

< (private) child names only

< don't chdir .. to the parent

< (private) unrecoverable error

< don't change directories

< (private) unrecoverable error

< discard node

< follow symbolic link

< preorder directory

< don't change directories

< error; errno is set

< followed a symlink to get here

< no instructions

< don't change directories

< (private) unrecoverable error

< followed a symlink to get here

< don't change directories

< (private) unrecoverable error

< don't chdir .. to the parent

< (private) unrecoverable error

< error; errno is set

< postorder directory

Definition at line 358 of file fts.c.

References __close, __open, __set_errno, BREAD, CLR, FCHDIR, _ftsent::fts_accpath, fts_build(), FTS::fts_child, FTS::fts_cur, FTS_D, _ftsent::fts_dev, FTS::fts_dev, FTS_ERR, _ftsent::fts_errno, _ftsent::fts_flags, FTS_FOLLOW, _ftsent::fts_info, _ftsent::fts_instr, _ftsent::fts_level, fts_lfree(), _ftsent::fts_link, fts_load(), _ftsent::fts_name, _ftsent::fts_namelen, FTS_NAMEONLY, FTS_NOCHDIR, _ftsent::fts_parent, FTS::fts_path, _ftsent::fts_pathlen, FTS::fts_rfd, fts_safe_changedir(), FTS_SKIP, FTS_SL, fts_stat(), FTS_STOP, _ftsent::fts_symfd, FTS_XDEV, FTSENT, ISSET, NAPPEND, and SET.

Referenced by main(), recurseDir(), and rpmfts_step().

int fts_safe_changedir FTS sp,
FTSENT p,
int  fd,
const char *  path
[static]
 

< don't change directories

Definition at line 1179 of file fts.c.

References __close, __fchdir, __open, __set_errno, _ftsent::fts_dev, _ftsent::fts_ino, FTS_NOCHDIR, FTSENT, and ISSET.

Referenced by fts_build(), and Fts_read().

int Fts_set FTS sp,
FTSENT p,
int  instr
 

Modify the traversal for a file set member.

< read node again

< follow symbolic link

< no instructions

< discard node

Definition at line 557 of file fts.c.

References __set_errno, FTS_AGAIN, FTS_FOLLOW, _ftsent::fts_instr, FTS_NOINSTR, and FTSENT.

Referenced by ftsPrint(), and rpmfts_Set().

FTSENT * fts_sort FTS sp,
FTSENT head,
int  nitems
[static]
 

Definition at line 1007 of file fts.c.

References FTS::fts_array, FTS::fts_compar, _ftsent::fts_link, FTS::fts_nitems, and FTSENT.

Referenced by fts_build(), and Fts_open().

u_short fts_stat FTS sp,
FTSENT p,
int  follow
[static]
 

< don't get stat info

< logical walk

< symbolic link without target

< stat(2) failed

< dot or dot-dot

< directory that causes cycles

< preorder directory

< symbolic link

< regular file

< none of the above

Definition at line 923 of file fts.c.

References __set_errno, _ftsent::fts_accpath, _ftsent::fts_cycle, _ftsent::fts_dev, _ftsent::fts_errno, _ftsent::fts_flags, _ftsent::fts_ino, _ftsent::fts_level, FTS_LOGICAL, FTS::fts_lstat, _ftsent::fts_name, _ftsent::fts_nlink, FTS_NOSTAT, _ftsent::fts_parent, FTS::fts_stat, _ftsent::fts_statp, FTSENT, ISDOT, ISSET, and S_ISLNK.

Referenced by fts_build(), Fts_open(), and Fts_read().


Generated on Mon Feb 21 17:21:35 2005 for rpm by  doxygen 1.3.9.1