Blame gl/pathmax.h

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