Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / groff / src / libs / libgroff / maxpathname.cpp
blob2402458510c48309a91594faf75a1e4cb1904396
1 /* $NetBSD$ */
3 // -*- C++ -*-
4 /* Copyright (C) 2005 Free Software Foundation, Inc.
5 Written by Werner Lemberg (wl@gnu.org)
7 This file is part of groff.
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.
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.
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. */
23 /* path_name_max(dir) does the same as pathconf(dir, _PC_PATH_MAX) */
25 #include "lib.h"
27 #include <sys/types.h>
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif /* HAVE_UNISTD_H */
33 #ifdef _POSIX_VERSION
35 size_t path_name_max()
37 return pathconf("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf("/",_PC_PATH_MAX);
40 #else /* not _POSIX_VERSION */
42 #include <stdlib.h>
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 */
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 */
68 size_t path_name_max()
70 return PATH_MAX;
73 #endif /* not _POSIX_VERSION */