3 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic License,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic License; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 4.0.
11 ?RCS: $Log: i_dirent.U,v $
12 ?RCS: Revision 3.0.1.4 1994/10/29 16:20:01 ram
13 ?RCS: patch36: failed scanning for 'd_namlen' with missing <dirent.h> (ADO)
15 ?RCS: Revision 3.0.1.3 1994/06/20 07:01:25 ram
16 ?RCS: patch30: added direntrytype for hints, merely for NeXT (ADO)
17 ?RCS: patch30: now checks for both struct dirent and direct (ADO)
19 ?RCS: Revision 3.0.1.2 1994/05/13 15:22:37 ram
20 ?RCS: patch27: new variable direntrytype for proper type setting (ADO)
22 ?RCS: Revision 3.0.1.1 1994/01/24 14:11:15 ram
23 ?RCS: patch16: added new Direntry_t pseudo-type for directory entries
25 ?RCS: Revision 3.0 1993/08/18 12:08:17 ram
26 ?RCS: Baseline for dist 3.0 netwide release.
29 ?X: This unit looks whether there is a dirent system or not
31 ?MAKE:i_dirent d_dirnamlen direntrytype: test contains Setvar \
32 Myread Findhdr cppstdin cppflags cppminus rm_try
33 ?MAKE: -pick add $@ %<
35 ?S: This variable conditionally defines I_DIRENT, which indicates
36 ?S: to the C program that it should include <dirent.h>.
39 ?S: This variable conditionally defines DIRNAMLEN, which indicates
40 ?S: to the C program that the length of directory entry names is
41 ?S: provided by a d_namelen field.
44 ?S: This symbol is set to 'struct direct' or 'struct dirent' depending on
45 ?S: whether dirent is available or not. You should use this pseudo type to
46 ?S: portably declare your directory entries.
49 ?C: This symbol, if defined, indicates to the C program that it should
50 ?C: include <dirent.h>. Using this symbol also triggers the definition
51 ?C: of the Direntry_t define which ends up being 'struct dirent' or
52 ?C: 'struct direct' depending on the availability of <dirent.h>.
55 ?C: This symbol, if defined, indicates to the C program that the length
56 ?C: of directory entry names is provided by a d_namlen field. Otherwise
57 ?C: you need to do strlen() on the d_name field.
60 ?C: This symbol is set to 'struct direct' or 'struct dirent' depending on
61 ?C: whether dirent is available or not. You should use this pseudo type to
62 ?C: portably declare your directory entries.
64 ?H:#$i_dirent I_DIRENT /**/
65 ?H:#$d_dirnamlen DIRNAMLEN /**/
66 ?H:?%<:@if I_DIRENT && Direntry_t
67 ?H:?%<:#define Direntry_t $direntrytype
71 ?LINT:set i_dirent d_dirnamlen
72 : see if this is a dirent system
74 if xinc=`./findhdr dirent.h`; $test "$xinc"; then
76 echo "<dirent.h> found." >&4
79 if xinc=`./findhdr sys/dir.h`; $test "$xinc"; then
80 echo "<sys/dir.h> found." >&4
83 xinc=`./findhdr sys/ndir.h`
85 echo "<dirent.h> NOT found." >&4
90 ?X: Use struct dirent or struct direct? If we're using dirent.h,
91 ?X: it's probably struct dirent, but apparently not always.
92 ?X: Assume $xinc still contains the name of the header file we're using.
93 @if direntrytype || Direntry_t
94 : Look for type of directory structure.
96 $cppstdin $cppflags $cppminus < "$xinc" > try.c
98 case "$direntrytype" in
101 $define) guess1='struct dirent' ;;
102 *) guess1='struct direct' ;;
105 *) guess1="$direntrytype"
110 'struct dirent') guess2='struct direct' ;;
111 *) guess2='struct dirent' ;;
114 if $contains "$guess1" try.c >/dev/null 2>&1; then
115 direntrytype="$guess1"
116 echo "Your directory entries are $direntrytype." >&4
117 elif $contains "$guess2" try.c >/dev/null 2>&1; then
118 direntrytype="$guess2"
119 echo "Your directory entries seem to be $direntrytype." >&4
121 echo "I don't recognize your system's directory entries." >&4
122 rp="What type is used for directory entries on this system?"
131 @if d_dirnamlen || DIRNAMLEN
132 : see if the directory entry stores field length
134 $cppstdin $cppflags $cppminus < "$xinc" > try.c
135 if $contains 'd_namlen' try.c >/dev/null 2>&1; then
136 echo "Good, your directory entry keeps length information in d_namlen." >&4
139 echo "Your directory entry does not know about the d_namlen field." >&4