fts.h revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/***********************************************************************
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* This software is part of the ast package *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Copyright (c) 1985-2007 AT&T Knowledge Ventures *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* and is licensed under the *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Common Public License, Version 1.0 *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* by AT&T Knowledge Ventures *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* A copy of the License is available at *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* http://www.opensource.org/licenses/cpl1.0.txt *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Information and Software Systems Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* AT&T Research *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Florham Park NJ *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Glenn Fowler <gsf@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* David Korn <dgk@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Phong Vo <kpv@research.att.com> *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin***********************************************************************/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#pragma prototyped
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Glenn Fowler
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * David Korn
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * Phong Vo
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * AT&T Research
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * fts interface definitions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef _FTS_H
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define _FTS_H
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <ls.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * fts_open flags
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_LOGICAL 0 /* logical traversal, follow symlinks */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_META (1<<0) /* follow top dir symlinks even if phys */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_NOCHDIR (1<<1) /* don't chdir */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_NOPOSTORDER (1<<2) /* no postorder visits */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_NOPREORDER (1<<3) /* no preorder visits */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_NOSEEDOTDIR (1<<11) /* never retain leading . dir */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_NOSTAT (1<<4) /* don't stat children */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_ONEPATH (1<<5) /* pathnames arg is one const char* */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_PHYSICAL (1<<6) /* physical traversal, don't follow */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_SEEDOT (1<<7) /* return . and .. */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_SEEDOTDIR (1<<10) /* always retain leading . dir */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_TOP (1<<8) /* don't traverse subdirectories */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_XDEV (1<<9) /* don't cross mount points */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_USER (1<<12) /* first user flag bit */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_COMFOLLOW FTS_META
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * fts_info flags
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_DEFAULT 0 /* ok, someone must have wanted this */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_NS (1<<0) /* stat failed */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_F (1<<1) /* file - not directory or symbolic link*/
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_SL (1<<2) /* symbolic link */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_D (1<<3) /* directory - pre-order visit */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_C (1<<4) /* causes cycle */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_ERR (1<<5) /* some other error */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_DD (1<<6) /* . or .. */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_NR (1<<7) /* cannot read */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_NX (1<<8) /* cannot search */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_OK (1<<9) /* no info but otherwise ok */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_P (1<<10) /* post-order visit */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_DC (FTS_D|FTS_C) /* dir - would cause cycle */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_DNR (FTS_D|FTS_NR) /* dir - no read permission */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_DNX (FTS_D|FTS_NX) /* dir - no search permission */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_DOT (FTS_D|FTS_DD) /* . or .. */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_DP (FTS_D|FTS_P) /* dir - post-order visit */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_NSOK (FTS_NS|FTS_OK) /* no stat (because you asked) */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_SLNONE (FTS_SL|FTS_NS) /* symlink - to nowhere */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/*
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * fts_set flags
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_AGAIN FTS_TOP /* process entry again */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_FOLLOW FTS_META /* follow FTS_SL symlink */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_SKIP FTS_NOSTAT /* skip FTS_D directory */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define FTS_STAT FTS_PHYSICAL /* stat() done by user */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintypedef struct Fts FTS;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chintypedef struct Ftsent FTSENT;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstruct Ftsent
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin char* fts_accpath; /* path relative to . */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin char* fts_name; /* file name */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin char* fts_path; /* path relative to top dir */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FTSENT* fts_cycle; /* offender if cycle */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FTSENT* fts_link; /* next child */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin FTSENT* fts_parent; /* parent directory */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin struct stat* fts_statp; /* stat info */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef _FTSENT_LOCAL_PRIVATE_
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin _FTSENT_LOCAL_PRIVATE_
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin void* fts_pointer; /* local pointer value */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin long fts_number; /* local numeric value */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int fts_errno; /* errno for this entry */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unsigned short fts_info; /* info flags */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unsigned short fts_namelen; /* strlen(fts_name) */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin unsigned short fts_pathlen; /* strlen(fts_path) */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin short fts_level; /* file tree depth, 0 at top */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef _FTSENT_PRIVATE_
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin _FTSENT_PRIVATE_
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin};
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinstruct Fts
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin{
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int fts_errno; /* last errno */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef _FTS_PRIVATE_
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin _FTS_PRIVATE_
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin};
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if _BLD_ast && defined(__EXPORT__)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define extern __EXPORT__
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern FTSENT* fts_children(FTS*, int);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern int fts_close(FTS*);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern int fts_flags(void);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern int fts_notify(int(*)(FTS*, FTSENT*, void*), void*);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern FTS* fts_open(char* const*, int, int(*)(FTSENT* const*, FTSENT* const*));
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern FTSENT* fts_read(FTS*);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern int fts_set(FTS*, FTSENT*, int);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef extern
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif