Sync-to-go: update copyright for 2015
[s-roff.git] / src / lib-roff / maxpathname.cpp
blob2e5119970ebc8df8b4c7cfda121b28ccd9176794
1 /*@ path_name_max(dir) does the same as pathconf(dir, _PC_PATH_MAX).
3 * Copyright (c) 2014 - 2015 Steffen (Daode) Nurpmeso <sdaoden@users.sf.net>.
5 * Copyright (C) 2005 Free Software Foundation, Inc.
6 * Written by Werner Lemberg (wl@gnu.org)
8 * This is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2, or (at your option) any later
11 * version.
13 * This is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with groff; see the file COPYING. If not, write to the Free Software
20 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
23 #include "config.h"
24 #include "lib.h"
26 #include <sys/types.h>
28 #ifdef HAVE_UNISTD_H
29 # include <unistd.h>
30 #endif
32 #ifdef _POSIX_VERSION
33 size_t path_name_max()
35 return pathconf("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf("/",_PC_PATH_MAX);
38 #else
39 # include <stdlib.h>
41 # ifdef HAVE_DIRENT_H
42 # include <dirent.h>
43 # else
44 # ifdef HAVE_SYS_DIR_H
45 # include <sys/dir.h>
46 # endif
47 # endif
49 # ifndef PATH_MAX
50 # ifdef MAXPATHLEN
51 # define PATH_MAX MAXPATHLEN
52 # else
53 # ifdef MAX_PATH
54 # define PATH_MAX MAX_PATH
55 # else
56 # ifdef _MAX_PATH
57 # define PATH_MAX _MAX_PATH
58 # else
59 # define PATH_MAX 255
60 # endif
61 # endif
62 # endif
63 # endif
65 size_t path_name_max()
67 return PATH_MAX;
69 #endif /* _POSIX_VERSION */
71 // s-it2-mode