Blame lib/pathmax.h

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