1 /* $NetBSD: maxpathname.cpp,v 1.1.1.1 2016/01/13 18:41:48 christos Exp $ */ 2 3 // -*- C++ -*- 4 /* Copyright (C) 2005 Free Software Foundation, Inc. 5 Written by Werner Lemberg (wl@gnu.org) 6 7 This file is part of groff. 8 9 groff is free software; you can redistribute it and/or modify it under 10 the terms of the GNU General Public License as published by the Free 11 Software Foundation; either version 2, or (at your option) any later 12 version. 13 14 groff is distributed in the hope that it will be useful, but WITHOUT ANY 15 WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 17 for more details. 18 19 You should have received a copy of the GNU General Public License along 20 with groff; see the file COPYING. If not, write to the Free Software 21 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */ 22 23 /* path_name_max(dir) does the same as pathconf(dir, _PC_PATH_MAX) */ 24 25 #include "lib.h" 26 27 #include <sys/types.h> 28 29 #ifdef HAVE_UNISTD_H 30 #include <unistd.h> 31 #endif /* HAVE_UNISTD_H */ 32 33 #ifdef _POSIX_VERSION 34 35 size_t path_name_max() 36 { 37 return pathconf("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf("/",_PC_PATH_MAX); 38 } 39 40 #else /* not _POSIX_VERSION */ 41 42 #include <stdlib.h> 43 44 #ifdef HAVE_DIRENT_H 45 # include <dirent.h> 46 #else /* not HAVE_DIRENT_H */ 47 # ifdef HAVE_SYS_DIR_H 48 # include <sys/dir.h> 49 # endif /* HAVE_SYS_DIR_H */ 50 #endif /* not HAVE_DIRENT_H */ 51 52 #ifndef PATH_MAX 53 # ifdef MAXPATHLEN 54 # define PATH_MAX MAXPATHLEN 55 # else /* !MAXPATHLEN */ 56 # ifdef MAX_PATH 57 # define PATH_MAX MAX_PATH 58 # else /* !MAX_PATH */ 59 # ifdef _MAX_PATH 60 # define PATH_MAX _MAX_PATH 61 # else /* !_MAX_PATH */ 62 # define PATH_MAX 255 63 # endif /* !_MAX_PATH */ 64 # endif /* !MAX_PATH */ 65 # endif /* !MAXPATHLEN */ 66 #endif /* !PATH_MAX */ 67 68 size_t path_name_max() 69 { 70 return PATH_MAX; 71 } 72 73 #endif /* not _POSIX_VERSION */ 74