Blame lib/pathmax.h

Packit Service fdd496
/* Define PATH_MAX somehow.  Requires sys/types.h.
Packit Service fdd496
   Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2017 Free Software
Packit Service fdd496
   Foundation, Inc.
Packit Service fdd496
Packit Service fdd496
   This program is free software; you can redistribute it and/or modify
Packit Service fdd496
   it under the terms of the GNU General Public License as published by
Packit Service fdd496
   the Free Software Foundation; either version 3, or (at your option)
Packit Service fdd496
   any later version.
Packit Service fdd496
Packit Service fdd496
   This program is distributed in the hope that it will be useful,
Packit Service fdd496
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service fdd496
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service fdd496
   GNU General Public License for more details.
Packit Service fdd496
Packit Service fdd496
   You should have received a copy of the GNU General Public License
Packit Service fdd496
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
Packit Service fdd496
Packit Service fdd496
#ifndef _PATHMAX_H
Packit Service fdd496
# define _PATHMAX_H
Packit Service fdd496
Packit Service fdd496
/* POSIX:2008 defines PATH_MAX to be the maximum number of bytes in a filename,
Packit Service fdd496
   including the terminating NUL byte.
Packit Service fdd496
   <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html>
Packit Service fdd496
   PATH_MAX is not defined on systems which have no limit on filename length,
Packit Service fdd496
   such as GNU/Hurd.
Packit Service fdd496
Packit Service fdd496
   This file does *not* define PATH_MAX always.  Programs that use this file
Packit Service fdd496
   can handle the GNU/Hurd case in several ways:
Packit Service fdd496
     - Either with a package-wide handling, or with a per-file handling,
Packit Service fdd496
     - Either through a
Packit Service fdd496
         #ifdef PATH_MAX
Packit Service fdd496
       or through a fallback like
Packit Service fdd496
         #ifndef PATH_MAX
Packit Service fdd496
         # define PATH_MAX 8192
Packit Service fdd496
         #endif
Packit Service fdd496
       or through a fallback like
Packit Service fdd496
         #ifndef PATH_MAX
Packit Service fdd496
         # define PATH_MAX pathconf ("/", _PC_PATH_MAX)
Packit Service fdd496
         #endif
Packit Service fdd496
 */
Packit Service fdd496
Packit Service fdd496
# include <unistd.h>
Packit Service fdd496
Packit Service fdd496
# include <limits.h>
Packit Service fdd496
Packit Service fdd496
# ifndef _POSIX_PATH_MAX
Packit Service fdd496
#  define _POSIX_PATH_MAX 256
Packit Service fdd496
# endif
Packit Service fdd496
Packit Service fdd496
/* Don't include sys/param.h if it already has been.  */
Packit Service fdd496
# if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
Packit Service fdd496
#  include <sys/param.h>
Packit Service fdd496
# endif
Packit Service fdd496
Packit Service fdd496
# if !defined PATH_MAX && defined MAXPATHLEN
Packit Service fdd496
#  define PATH_MAX MAXPATHLEN
Packit Service fdd496
# endif
Packit Service fdd496
Packit Service fdd496
# ifdef __hpux
Packit Service fdd496
/* On HP-UX, PATH_MAX designates the maximum number of bytes in a filename,
Packit Service fdd496
   *not* including the terminating NUL byte, and is set to 1023.
Packit Service fdd496
   Additionally, when _XOPEN_SOURCE is defined to 500 or more, PATH_MAX is
Packit Service fdd496
   not defined at all any more.  */
Packit Service fdd496
#  undef PATH_MAX
Packit Service fdd496
#  define PATH_MAX 1024
Packit Service fdd496
# endif
Packit Service fdd496
Packit Service fdd496
# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
Packit Service fdd496
/* The page "Naming Files, Paths, and Namespaces" on msdn.microsoft.com,
Packit Service fdd496
   section "Maximum Path Length Limitation",
Packit Service fdd496
   <http://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath>
Packit Service fdd496
   explains that the maximum size of a filename, including the terminating
Packit Service fdd496
   NUL byte, is 260 = 3 + 256 + 1.
Packit Service fdd496
   This is the same value as
Packit Service fdd496
     - FILENAME_MAX in <stdio.h>,
Packit Service fdd496
     - _MAX_PATH in <stdlib.h>,
Packit Service fdd496
     - MAX_PATH in <windef.h>.
Packit Service fdd496
   Undefine the original value, because mingw's <limits.h> gets it wrong.  */
Packit Service fdd496
#  undef PATH_MAX
Packit Service fdd496
#  define PATH_MAX 260
Packit Service fdd496
# endif
Packit Service fdd496
Packit Service fdd496
#endif /* _PATHMAX_H */