Blame gettext-tools/gnulib-lib/pathmax.h

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