xref: /titanic_50/usr/src/lib/libast/common/include/ast_dir.h (revision 356f72340a69936724c69f2f87fffa6f5887f885)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *            http://www.opensource.org/licenses/cpl1.0.txt             *
11 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #pragma prototyped
23 
24 /*
25  * AT&T Research
26  *
27  * common dirent maintenance interface
28  */
29 
30 #ifndef _AST_DIR_H
31 #define _AST_DIR_H
32 
33 #include <ast_lib.h>
34 
35 #if _mem_d_fileno_dirent || _mem_d_ino_dirent
36 #if !_mem_d_fileno_dirent
37 #undef	_mem_d_fileno_dirent
38 #define _mem_d_fileno_dirent	1
39 #define d_fileno		d_ino
40 #endif
41 #endif
42 
43 #if _BLD_ast
44 #include "dirlib.h"
45 #else
46 #include <dirent.h>
47 #endif
48 
49 #if _mem_d_fileno_dirent
50 #define D_FILENO(d)		((d)->d_fileno)
51 #endif
52 
53 #if _mem_d_namlen_dirent
54 #define D_NAMLEN(d)		((d)->d_namlen)
55 #else
56 #define D_NAMLEN(d)		(strlen((d)->d_name))
57 #endif
58 
59 #if _mem_d_reclen_dirent
60 #define D_RECLEN(d)		((d)->d_reclen)
61 #else
62 #define D_RECLEN(d)		D_RECSIZ(d,D_NAMLEN(d))
63 #endif
64 
65 #define D_RECSIZ(d,n)		(sizeof(*(d))-sizeof((d)->d_name)+((n)+sizeof(char*))&~(sizeof(char*)-1))
66 
67 /*
68  * NOTE: 2003-03-27 mac osx bug symlink==DT_REG bug discovered;
69  *	 the kernel *and* all directories must be fixed, so d_type
70  *	 is summarily disabled until we see that happen
71  */
72 
73 #if _mem_d_type_dirent && defined(DT_UNKNOWN) && defined(DT_REG) && defined(DT_DIR) && defined(DT_LNK) && ! ( __APPLE__ || __MACH__ )
74 #define D_TYPE(d)		((d)->d_type)
75 #endif
76 
77 #endif
78