Blame lib/pathmax.h

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