Blame lib/pathmax.h

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