1151497Sru// -*- C++ -*- 2151497Sru/* Copyright (C) 2005 Free Software Foundation, Inc. 3151497Sru Written by Werner Lemberg (wl@gnu.org) 4151497Sru 5151497SruThis file is part of groff. 6151497Sru 7151497Srugroff is free software; you can redistribute it and/or modify it under 8151497Sruthe terms of the GNU General Public License as published by the Free 9151497SruSoftware Foundation; either version 2, or (at your option) any later 10151497Sruversion. 11151497Sru 12151497Srugroff is distributed in the hope that it will be useful, but WITHOUT ANY 13151497SruWARRANTY; without even the implied warranty of MERCHANTABILITY or 14151497SruFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15151497Srufor more details. 16151497Sru 17151497SruYou should have received a copy of the GNU General Public License along 18151497Sruwith groff; see the file COPYING. If not, write to the Free Software 19151497SruFoundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ 20151497Sru 21151497Sru/* path_name_max(dir) does the same as pathconf(dir, _PC_PATH_MAX) */ 22151497Sru 23151497Sru#include "lib.h" 24151497Sru 25151497Sru#include <sys/types.h> 26151497Sru 27151497Sru#ifdef HAVE_UNISTD_H 28151497Sru#include <unistd.h> 29151497Sru#endif /* HAVE_UNISTD_H */ 30151497Sru 31151497Sru#ifdef _POSIX_VERSION 32151497Sru 33151497Srusize_t path_name_max() 34151497Sru{ 35151497Sru return pathconf("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf("/",_PC_PATH_MAX); 36151497Sru} 37151497Sru 38151497Sru#else /* not _POSIX_VERSION */ 39151497Sru 40151497Sru#include <stdlib.h> 41151497Sru 42151497Sru#ifdef HAVE_DIRENT_H 43151497Sru# include <dirent.h> 44151497Sru#else /* not HAVE_DIRENT_H */ 45151497Sru# ifdef HAVE_SYS_DIR_H 46151497Sru# include <sys/dir.h> 47151497Sru# endif /* HAVE_SYS_DIR_H */ 48151497Sru#endif /* not HAVE_DIRENT_H */ 49151497Sru 50151497Sru#ifndef PATH_MAX 51151497Sru# ifdef MAXPATHLEN 52151497Sru# define PATH_MAX MAXPATHLEN 53151497Sru# else /* !MAXPATHLEN */ 54151497Sru# ifdef MAX_PATH 55151497Sru# define PATH_MAX MAX_PATH 56151497Sru# else /* !MAX_PATH */ 57151497Sru# ifdef _MAX_PATH 58151497Sru# define PATH_MAX _MAX_PATH 59151497Sru# else /* !_MAX_PATH */ 60151497Sru# define PATH_MAX 255 61151497Sru# endif /* !_MAX_PATH */ 62151497Sru# endif /* !MAX_PATH */ 63151497Sru# endif /* !MAXPATHLEN */ 64151497Sru#endif /* !PATH_MAX */ 65151497Sru 66151497Srusize_t path_name_max() 67151497Sru{ 68151497Sru return PATH_MAX; 69151497Sru} 70151497Sru 71151497Sru#endif /* not _POSIX_VERSION */ 72