Blame gnulib/lib/pathmax.h

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