GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* Written by David MacKenzie <djm@ai.mit.edu>. */
+/* Written by David MacKenzie <djm@gnu.ai.mit.edu>. */
-#include <sys/types.h>
-#ifdef DIRENT
-#include <dirent.h>
-#ifdef direct
-#undef direct
+#ifdef HAVE_CONFIG_H
+#include <config.h>
#endif
-#define direct dirent
-#define NLENGTH(direct) (strlen((direct)->d_name))
-#else
-#define NLENGTH(direct) ((direct)->d_namlen)
-#ifdef USG
-#ifdef SYSNDIR
-#include <sys/ndir.h>
-#else
-#include <ndir.h>
+
+#include <sys/types.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
#endif
+
+#if HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) strlen((dirent)->d_name)
#else
-#include <sys/dir.h>
-#endif
+# define dirent direct
+# define NAMLEN(dirent) (dirent)->d_namlen
+# if HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# if HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# if HAVE_NDIR_H
+# include <ndir.h>
+# endif
#endif
-#ifdef VOID_CLOSEDIR
+#ifdef CLOSEDIR_VOID
/* Fake a return value. */
#define CLOSEDIR(d) (closedir (d), 0)
#else
#else
char *malloc ();
char *realloc ();
+#endif
#ifndef NULL
#define NULL 0
#endif
-#endif
char *stpcpy ();
unsigned name_size;
{
DIR *dirp;
- struct direct *dp;
+ struct dirent *dp;
char *name_space;
char *namep;
|| (dp->d_name[1] != '\0'
&& (dp->d_name[1] != '.' || dp->d_name[2] != '\0')))
{
- unsigned size_needed = (namep - name_space) + NLENGTH (dp) + 2;
+ unsigned size_needed = (namep - name_space) + NAMLEN (dp) + 2;
if (size_needed > name_size)
{