dirlib.h revision 3e14f97f673e8a630f076077de35afdd43dc1587
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin/***********************************************************************
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* This software is part of the ast package *
3e14f97f673e8a630f076077de35afdd43dc1587Roger A. Faulkner* Copyright (c) 1985-2010 AT&T Intellectual Property *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* and is licensed under the *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin* Common Public License, Version 1.0 *
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin* by AT&T Intellectual Property *
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 * AT&T Research
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin *
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * directory stream access library private definitions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin * library routines should include this file rather than <dirent.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef _DIRLIB_H
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define _DIRLIB_H
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if defined(__STDPP__directive) && defined(__STDPP__hide)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin__STDPP__directive pragma pp:hide getdents getdirentries
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef getdents
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define getdents ______getdents
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef getdirentries
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define getdirentries ______getdirentries
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <ast.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <errno.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if _lib_opendir && ( _hdr_dirent || _hdr_ndir || _sys_dir )
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define _dir_ok 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <ls.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef _DIRENT_H
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if _hdr_dirent
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if _typ_off64_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef off_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <dirent.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if _typ_off64_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define off_t off64_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if _hdr_ndir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <ndir.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <sys/dir.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef dirent
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define dirent direct
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define DIRdirent dirent
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define dirent DIRdirent
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if defined(__STDPP__directive) && defined(__STDPP__hide)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin__STDPP__directive pragma pp:hide DIR closedir opendir readdir seekdir telldir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef DIR
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define DIR ______DIR
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef closedir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define closedir ______closedir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef opendir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define opendir ______opendir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef readdir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define readdir ______readdir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef seekdir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define seekdir ______seekdir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef telldir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define telldir ______telldir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <ast_param.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <ls.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <limits.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef _DIRENT_H
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if _hdr_dirent
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if _typ_off64_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef off_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <dirent.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if _typ_off64_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define off_t off64_t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if _hdr_direntry
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <direntry.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include <sys/dir.h>
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef dirent
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if defined(__STDPP__directive) && defined(__STDPP__hide)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin__STDPP__directive pragma pp:nohide DIR closedir opendir readdir seekdir telldir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef DIR
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef closedir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef opendir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef readdir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef seekdir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef telldir
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define _DIR_PRIVATE_ \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int dd_loc; /* offset in block */ \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin int dd_size; /* valid data in block */ \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin char* dd_buf; /* directory block */
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef _BLD_3d
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define DIR DIRDIR
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef _DIRENT_H
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#include "dirstd.h"
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef _DIRENT_H
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define _DIRENT_H 1
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef _BLD_3d
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef DIR
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef DIRBLKSIZ
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef DIRBLK
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define DIRBLKSIZ DIRBLK
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifdef DIRBUF
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define DIRBLKSIZ DIRBUF
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#define DIRBLKSIZ 8192
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#if defined(__STDPP__directive) && defined(__STDPP__hide)
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin__STDPP__directive pragma pp:nohide getdents getdirentries
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#else
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef getdents
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#undef getdirentries
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#ifndef errno
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern int errno;
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinextern ssize_t getdents(int, void*, size_t);
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin#endif