xref: /onnv-gate/usr/src/lib/libast/common/dir/dirlib.h (revision 12068:08a39a083754)
14887Schin /***********************************************************************
24887Schin *                                                                      *
34887Schin *               This software is part of the ast package               *
4*12068SRoger.Faulkner@Oracle.COM *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
54887Schin *                      and is licensed under the                       *
64887Schin *                  Common Public License, Version 1.0                  *
78462SApril.Chin@Sun.COM *                    by AT&T Intellectual Property                     *
84887Schin *                                                                      *
94887Schin *                A copy of the License is available at                 *
104887Schin *            http://www.opensource.org/licenses/cpl1.0.txt             *
114887Schin *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
124887Schin *                                                                      *
134887Schin *              Information and Software Systems Research               *
144887Schin *                            AT&T Research                             *
154887Schin *                           Florham Park NJ                            *
164887Schin *                                                                      *
174887Schin *                 Glenn Fowler <gsf@research.att.com>                  *
184887Schin *                  David Korn <dgk@research.att.com>                   *
194887Schin *                   Phong Vo <kpv@research.att.com>                    *
204887Schin *                                                                      *
214887Schin ***********************************************************************/
224887Schin #pragma prototyped
234887Schin /*
244887Schin  * AT&T Research
254887Schin  *
264887Schin  * directory stream access library private definitions
274887Schin  * library routines should include this file rather than <dirent.h>
284887Schin  */
294887Schin 
304887Schin #ifndef _DIRLIB_H
314887Schin #define _DIRLIB_H
324887Schin 
334887Schin #if defined(__STDPP__directive) && defined(__STDPP__hide)
344887Schin __STDPP__directive pragma pp:hide getdents getdirentries
354887Schin #else
364887Schin #undef	getdents
374887Schin #define getdents	______getdents
384887Schin #undef	getdirentries
394887Schin #define getdirentries	______getdirentries
404887Schin #endif
414887Schin 
424887Schin #include <ast.h>
434887Schin #include <errno.h>
444887Schin 
454887Schin #if _lib_opendir && ( _hdr_dirent || _hdr_ndir || _sys_dir )
464887Schin 
474887Schin #define _dir_ok		1
484887Schin 
494887Schin #include <ls.h>
504887Schin 
514887Schin #ifndef _DIRENT_H
524887Schin #if _hdr_dirent
534887Schin #if _typ_off64_t
544887Schin #undef	off_t
554887Schin #endif
564887Schin #include <dirent.h>
574887Schin #if _typ_off64_t
584887Schin #define off_t	off64_t
594887Schin #endif
604887Schin #else
614887Schin #if _hdr_ndir
624887Schin #include <ndir.h>
634887Schin #else
644887Schin #include <sys/dir.h>
654887Schin #endif
664887Schin #ifndef dirent
674887Schin #define dirent	direct
684887Schin #endif
694887Schin #endif
704887Schin #endif
714887Schin 
724887Schin #define DIRdirent	dirent
734887Schin 
744887Schin #else
754887Schin 
764887Schin #define dirent	DIRdirent
774887Schin 
784887Schin #if defined(__STDPP__directive) && defined(__STDPP__hide)
794887Schin __STDPP__directive pragma pp:hide DIR closedir opendir readdir seekdir telldir
804887Schin #else
814887Schin #undef	DIR
824887Schin #define DIR		______DIR
834887Schin #undef	closedir
844887Schin #define closedir	______closedir
854887Schin #undef	opendir
864887Schin #define opendir		______opendir
874887Schin #undef	readdir
884887Schin #define readdir		______readdir
894887Schin #undef	seekdir
904887Schin #define seekdir		______seekdir
914887Schin #undef	telldir
924887Schin #define telldir		______telldir
934887Schin #endif
944887Schin 
954887Schin #include <ast_param.h>
964887Schin 
974887Schin #include <ls.h>
984887Schin #include <limits.h>
994887Schin 
1004887Schin #ifndef _DIRENT_H
1014887Schin #if _hdr_dirent
1024887Schin #if _typ_off64_t
1034887Schin #undef	off_t
1044887Schin #endif
1054887Schin #include <dirent.h>
1064887Schin #if _typ_off64_t
1074887Schin #define off_t	off64_t
1084887Schin #endif
1094887Schin #else
1104887Schin #if _hdr_direntry
1114887Schin #include <direntry.h>
1124887Schin #else
1134887Schin #include <sys/dir.h>
1144887Schin #endif
1154887Schin #endif
1164887Schin #endif
1174887Schin 
1184887Schin #undef	dirent
1194887Schin #if defined(__STDPP__directive) && defined(__STDPP__hide)
1204887Schin __STDPP__directive pragma pp:nohide DIR closedir opendir readdir seekdir telldir
1214887Schin #else
1224887Schin #undef	DIR
1234887Schin #undef	closedir
1244887Schin #undef	opendir
1254887Schin #undef	readdir
1264887Schin #undef	seekdir
1274887Schin #undef	telldir
1284887Schin #endif
1294887Schin 
1304887Schin #define _DIR_PRIVATE_ \
1314887Schin 	int		dd_loc;		/* offset in block		*/ \
1324887Schin 	int		dd_size;	/* valid data in block		*/ \
1334887Schin 	char*		dd_buf;		/* directory block		*/
1344887Schin 
1354887Schin #ifdef _BLD_3d
1364887Schin #define DIR		DIRDIR
1374887Schin #endif
1384887Schin #undef	_DIRENT_H
1394887Schin #include "dirstd.h"
1404887Schin #ifndef _DIRENT_H
1414887Schin #define _DIRENT_H	1
1424887Schin #endif
1434887Schin #ifdef _BLD_3d
1444887Schin #undef	DIR
1454887Schin #endif
1464887Schin 
1474887Schin #ifndef	DIRBLKSIZ
1484887Schin #ifdef	DIRBLK
1494887Schin #define DIRBLKSIZ	DIRBLK
1504887Schin #else
1514887Schin #ifdef	DIRBUF
1524887Schin #define DIRBLKSIZ	DIRBUF
1534887Schin #else
1544887Schin #define DIRBLKSIZ	8192
1554887Schin #endif
1564887Schin #endif
1574887Schin #endif
1584887Schin 
1594887Schin #endif
1604887Schin 
1614887Schin #if defined(__STDPP__directive) && defined(__STDPP__hide)
1624887Schin __STDPP__directive pragma pp:nohide getdents getdirentries
1634887Schin #else
1644887Schin #undef	getdents
1654887Schin #undef	getdirentries
1664887Schin #endif
1674887Schin 
1684887Schin #ifndef errno
1694887Schin extern int	errno;
1704887Schin #endif
1714887Schin 
1724887Schin extern ssize_t		getdents(int, void*, size_t);
1734887Schin 
1744887Schin #endif
175