Mercurial > hg > octave-jordi > gnulib-hg
annotate lib/pathmax.h @ 18070:d460ec17f09f
autoupdate
author | Karl Berry <karl@freefriends.org> |
---|---|
date | Tue, 28 Jul 2015 13:57:32 -0700 (2015-07-28) |
parents | ab58d4870664 |
children |
rev | line source |
---|---|
212 | 1 /* Define PATH_MAX somehow. Requires sys/types.h. |
17848 | 2 Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2015 Free Software |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12518
diff
changeset
|
3 Foundation, Inc. |
212 | 4 |
5 This program is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 2, or (at your option) | |
8 any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16366
bb182ee4a09d
maint: replace FSF snail-mail addresses with URLs
Paul Eggert <eggert@cs.ucla.edu>
parents:
16201
diff
changeset
|
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */ |
212 | 17 |
18 #ifndef _PATHMAX_H | |
1874
95710aec0c81
cpp indent and split a long line
Jim Meyering <jim@meyering.net>
parents:
647
diff
changeset
|
19 # define _PATHMAX_H |
212 | 20 |
15305
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
21 /* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename, |
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
22 including the terminating NUL byte. |
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
23 <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html> |
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
24 PATH_MAX is not defined on systems which have no limit on filename length, |
15496
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
25 such as GNU/Hurd. |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
26 |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
27 This file does *not* define PATH_MAX always. Programs that use this file |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
28 can handle the GNU/Hurd case in several ways: |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
29 - Either with a package-wide handling, or with a per-file handling, |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
30 - Either through a |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
31 #ifdef PATH_MAX |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
32 or through a fallback like |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
33 #ifndef PATH_MAX |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
34 # define PATH_MAX 8192 |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
35 #endif |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
36 or through a fallback like |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
37 #ifndef PATH_MAX |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
38 # define PATH_MAX pathconf ("/", _PC_PATH_MAX) |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
39 #endif |
451ec8bd8a1c
pathmax: Leave PATH_MAX undefined on the Hurd, and a constant otherwise.
Bruno Haible <bruno@clisp.org>
parents:
15305
diff
changeset
|
40 */ |
15305
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
41 |
6275 | 42 # include <unistd.h> |
212 | 43 |
5907 | 44 # include <limits.h> |
212 | 45 |
1874
95710aec0c81
cpp indent and split a long line
Jim Meyering <jim@meyering.net>
parents:
647
diff
changeset
|
46 # ifndef _POSIX_PATH_MAX |
5907 | 47 # define _POSIX_PATH_MAX 256 |
1874
95710aec0c81
cpp indent and split a long line
Jim Meyering <jim@meyering.net>
parents:
647
diff
changeset
|
48 # endif |
212 | 49 |
50 /* Don't include sys/param.h if it already has been. */ | |
3342 | 51 # if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN |
1874
95710aec0c81
cpp indent and split a long line
Jim Meyering <jim@meyering.net>
parents:
647
diff
changeset
|
52 # include <sys/param.h> |
95710aec0c81
cpp indent and split a long line
Jim Meyering <jim@meyering.net>
parents:
647
diff
changeset
|
53 # endif |
212 | 54 |
3342 | 55 # if !defined PATH_MAX && defined MAXPATHLEN |
1874
95710aec0c81
cpp indent and split a long line
Jim Meyering <jim@meyering.net>
parents:
647
diff
changeset
|
56 # define PATH_MAX MAXPATHLEN |
95710aec0c81
cpp indent and split a long line
Jim Meyering <jim@meyering.net>
parents:
647
diff
changeset
|
57 # endif |
212 | 58 |
15305
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
59 # ifdef __hpux |
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
60 /* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename, |
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
61 *not* including the terminating NUL byte, and is set to 1023. |
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
62 Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is |
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
63 not defined at all any more. */ |
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
64 # undef PATH_MAX |
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
65 # define PATH_MAX 1024 |
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
66 # endif |
78615c8f44e6
pathmax: Ensure correct value for PATH_MAX on HP-UX.
Bruno Haible <bruno@clisp.org>
parents:
14079
diff
changeset
|
67 |
15611
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
68 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
69 /* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com, |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
70 section "Maximum Path Length Limitation", |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
71 <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath> |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
72 explains that the maximum size of a filename, including the terminating |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
73 NUL byte, is 260 = 3 + 256 + 1. |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
74 This is the same value as |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
75 - FILENAME_MAX in <stdio.h>, |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
76 - _MAX_PATH in <stdlib.h>, |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
77 - MAX_PATH in <windef.h>. |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
78 Undefine the original value, because mingw's <limits.h> gets it wrong. */ |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
79 # undef PATH_MAX |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
80 # define PATH_MAX 260 |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
81 # endif |
ddf0241e1a64
pathmax: Support for native Windows.
Bruno Haible <bruno@clisp.org>
parents:
15496
diff
changeset
|
82 |
212 | 83 #endif /* _PATHMAX_H */ |