rpm  5.4.10
Macros | Functions | Variables
fts.c File Reference
#include "system.h"
#include "fts.h"
#include <rpmio.h>
#include <rpmurl.h>
#include <rpmdir.h>
#include "debug.h"
Include dependency graph for fts.c:

Go to the source code of this file.

Macros

#define _D_EXACT_NAMLEN(d)   (strlen((d)->d_name))
 
#define __set_errno(val)   (*__errno_location ()) = (val)
 
#define __open   open
 
#define __close   close
 
#define __fchdir   fchdir
 
#define USHRT_MAX   65535
 
#define alignof(TYPE)   ((int) &((struct { char dummy1; TYPE dummy2; } *) 0)->dummy2)
 
#define ALIGNBYTES   (alignof(long double) - 1)
 
#define ALIGN(p)   (((unsigned long int) (p) + ALIGNBYTES) & ~ALIGNBYTES)
 
#define ISDOT(a)   (a[0] == '.' && (!a[1] || (a[1] == '/' && !a[2]) || (a[1] == '.' && (!a[2] || (a[2] == '/' && !a[3])))))
 
#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 /* fts_children */
 
#define BNAMES   2 /* fts_children, names only */
 
#define BREAD   3 /* fts_read */
 
#define MAXPATHLEN   1024
 
#define NAPPEND(p)
 
#define __opendir2(path, flag)   (*sp->fts_opendir) (path)
 
#define ADJUST(p)
 

Functions

static FTSENTfts_alloc (FTS *sp, const char *name, int namelen)
 
static FTSENTfts_build (FTS *sp, int type)
 
static void fts_lfree (FTSENT *head)
 
static void fts_load (FTS *sp, FTSENT *p)
 
static size_t fts_maxarglen (char *const *argv)
 
static void fts_padjust (FTS *sp, FTSENT *head)
 
static int fts_palloc (FTS *sp, size_t more)
 
static FTSENTfts_sort (FTS *sp, FTSENT *head, int nitems)
 
static u_short fts_stat (FTS *sp, FTSENT *p, int follow)
 
static 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. More...
 
int Fts_close (FTS *sp)
 Destroy a file hierarchy traversal handle. More...
 
static const char * ftsInfoStr (int fts_info)
 
FTSENTFts_read (FTS *sp)
 Return next node in the file hierarchy traversal. More...
 
int Fts_set (FTS *sp, FTSENT *p, int instr)
 Modify the traversal for a file set member. More...
 
FTSENTFts_children (FTS *sp, int instr)
 Return list of children of the current node. More...
 

Variables

int _fts_debug = 0
 
static int indent = 2
 
static const char * ftsInfoStrings []
 

Macro Definition Documentation

§ __close

#define __close   close

Definition at line 140 of file fts.c.

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

§ __fchdir

#define __fchdir   fchdir

Definition at line 141 of file fts.c.

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

§ __open

#define __open   open

Definition at line 139 of file fts.c.

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

§ __opendir2

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

Referenced by fts_build().

§ __set_errno

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

§ _D_EXACT_NAMLEN

#define _D_EXACT_NAMLEN (   d)    (strlen((d)->d_name))

Definition at line 128 of file fts.c.

Referenced by fts_build().

§ ADJUST

#define ADJUST (   p)
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().

§ ALIGN

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

Definition at line 161 of file fts.c.

Referenced by dsort(), and fts_alloc().

§ ALIGNBYTES

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

Definition at line 157 of file fts.c.

Referenced by dsort(), and fts_alloc().

§ alignof

#define alignof (   TYPE)    ((int) &((struct { char dummy1; TYPE dummy2; } *) 0)->dummy2)

Definition at line 154 of file fts.c.

§ BCHILD

#define BCHILD   1 /* fts_children */

Definition at line 202 of file fts.c.

Referenced by fts_build(), and Fts_children().

§ BNAMES

#define BNAMES   2 /* fts_children, names only */

Definition at line 203 of file fts.c.

Referenced by fts_build(), and Fts_children().

§ BREAD

#define BREAD   3 /* fts_read */

Definition at line 204 of file fts.c.

Referenced by fts_build(), and Fts_read().

§ CLR

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

Definition at line 195 of file fts.c.

Referenced by Fts_read().

§ FCHDIR

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

Definition at line 199 of file fts.c.

Referenced by fts_build(), and Fts_read().

§ ISDOT

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

Definition at line 193 of file fts.c.

Referenced by fts_build(), and fts_stat().

§ ISSET

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

§ MAXPATHLEN

#define MAXPATHLEN   1024

§ NAPPEND

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

Definition at line 462 of file fts.c.

Referenced by fts_build(), and Fts_read().

§ SET

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

Definition at line 197 of file fts.c.

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

§ USHRT_MAX

#define USHRT_MAX   65535

Definition at line 145 of file fts.c.

Referenced by fts_build(), and fts_palloc().

Function Documentation

§ fts_alloc()

static FTSENT * fts_alloc ( FTS sp,
const char *  name,
int  namelen 
)
static

§ fts_build()

static FTSENT * fts_build ( FTS sp,
int  type 
)
static

§ Fts_children()

FTSENT* Fts_children ( FTS sp,
int  instr 
)

Return list of children of the current node.

Parameters
spfile hierarchy state
instr
Returns
file set member

Definition at line 705 of file fts.c.

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

Referenced by mtreeVisitD(), and rpmfts_Children().

§ Fts_close()

int Fts_close ( FTS sp)

§ fts_lfree()

static void fts_lfree ( FTSENT head)
static

Definition at line 1221 of file fts.c.

References _ftsent::fts_link.

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

§ fts_load()

static void fts_load ( FTS sp,
FTSENT p 
)
static

§ fts_maxarglen()

static size_t fts_maxarglen ( char *const *  argv)
static

Definition at line 1295 of file fts.c.

Referenced by Fts_open().

§ Fts_open()

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

§ fts_padjust()

static void fts_padjust ( FTS sp,
FTSENT head 
)
static

§ fts_palloc()

static int fts_palloc ( FTS sp,
size_t  more 
)
static

Definition at line 1239 of file fts.c.

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

Referenced by fts_build(), and Fts_open().

§ Fts_read()

FTSENT* Fts_read ( FTS sp)

§ fts_safe_changedir()

static int fts_safe_changedir ( FTS sp,
FTSENT p,
int  fd,
const char *  path 
)
static

Definition at line 1311 of file fts.c.

References __close, __fchdir, __open, __set_errno, errno, _ftsent::fts_dev, _ftsent::fts_ino, FTS_NOCHDIR, ISSET, URL_IS_PATH, and urlPath().

Referenced by fts_build(), and Fts_read().

§ Fts_set()

int Fts_set ( FTS sp,
FTSENT p,
int  instr 
)

Modify the traversal for a file set member.

Parameters
spfile hierarchy state
pfile set member
instrnew disposition for file set member
Returns
0 on success, -1 on error

Definition at line 688 of file fts.c.

References __set_errno, _fts_debug, FTS_AGAIN, FTS_FOLLOW, _ftsent::fts_instr, FTS_NOINSTR, and FTS_SKIP.

Referenced by cacheWalkPathFilter(), mtreeCWalk(), mtreeVWalk(), rpmcliWalkFirst(), rpmdcCWalk(), and rpmfts_Set().

§ fts_sort()

static FTSENT * fts_sort ( FTS sp,
FTSENT head,
int  nitems 
)
static

Definition at line 1147 of file fts.c.

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

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

§ fts_stat()

static u_short fts_stat ( FTS sp,
FTSENT p,
int  follow 
)
static

§ ftsInfoStr()

static const char* ftsInfoStr ( int  fts_info)
static

Definition at line 451 of file fts.c.

Referenced by Fts_read().

Variable Documentation

§ _fts_debug

int _fts_debug = 0

Definition at line 165 of file fts.c.

Referenced by dsort(), Fts_children(), Fts_close(), Fts_open(), Fts_read(), and Fts_set().

§ ftsInfoStrings

const char* ftsInfoStrings[]
static
Initial value:
= {
"UNKNOWN",
"D",
"DC",
"DEFAULT",
"DNR",
"DOT",
"DP",
"ERR",
"F",
"INIT",
"NS",
"NSOK",
"SL",
"SLNONE",
"W",
}

Definition at line 433 of file fts.c.

§ indent

int indent = 2
static

Definition at line 431 of file fts.c.