Blame src/gl/pathmax.h

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