xref: /netbsd-src/external/gpl2/xcvs/dist/lib/pathmax.h (revision a7c918477dd5f12c1da816ba05caf44eab2d06d6)
1*a7c91847Schristos /* Define PATH_MAX somehow.  Requires sys/types.h.
2*a7c91847Schristos    Copyright (C) 1992, 1999, 2001, 2003, 2005 Free Software Foundation, Inc.
3*a7c91847Schristos 
4*a7c91847Schristos    This program is free software; you can redistribute it and/or modify
5*a7c91847Schristos    it under the terms of the GNU General Public License as published by
6*a7c91847Schristos    the Free Software Foundation; either version 2, or (at your option)
7*a7c91847Schristos    any later version.
8*a7c91847Schristos 
9*a7c91847Schristos    This program is distributed in the hope that it will be useful,
10*a7c91847Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
11*a7c91847Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*a7c91847Schristos    GNU General Public License for more details.
13*a7c91847Schristos 
14*a7c91847Schristos    You should have received a copy of the GNU General Public License
15*a7c91847Schristos    along with this program; if not, write to the Free Software Foundation,
16*a7c91847Schristos    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17*a7c91847Schristos 
18*a7c91847Schristos #ifndef _PATHMAX_H
19*a7c91847Schristos # define _PATHMAX_H
20*a7c91847Schristos 
21*a7c91847Schristos # if HAVE_UNISTD_H
22*a7c91847Schristos #  include <unistd.h>
23*a7c91847Schristos # endif
24*a7c91847Schristos 
25*a7c91847Schristos # include <limits.h>
26*a7c91847Schristos 
27*a7c91847Schristos # ifndef _POSIX_PATH_MAX
28*a7c91847Schristos #  define _POSIX_PATH_MAX 256
29*a7c91847Schristos # endif
30*a7c91847Schristos 
31*a7c91847Schristos # if !defined PATH_MAX && defined _PC_PATH_MAX
32*a7c91847Schristos #  define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 \
33*a7c91847Schristos 		    : pathconf ("/", _PC_PATH_MAX))
34*a7c91847Schristos # endif
35*a7c91847Schristos 
36*a7c91847Schristos /* Don't include sys/param.h if it already has been.  */
37*a7c91847Schristos # if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
38*a7c91847Schristos #  include <sys/param.h>
39*a7c91847Schristos # endif
40*a7c91847Schristos 
41*a7c91847Schristos # if !defined PATH_MAX && defined MAXPATHLEN
42*a7c91847Schristos #  define PATH_MAX MAXPATHLEN
43*a7c91847Schristos # endif
44*a7c91847Schristos 
45*a7c91847Schristos # ifndef PATH_MAX
46*a7c91847Schristos #  define PATH_MAX _POSIX_PATH_MAX
47*a7c91847Schristos # endif
48*a7c91847Schristos 
49*a7c91847Schristos #endif /* _PATHMAX_H */
50