Blame lib/pathmax.h

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