diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:44:05 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 19:44:05 +0000 |
commit | d318611dd6f23fcfedd50e9b9e24620b102ba96a (patch) | |
tree | 8b9eef82ca40fdd5a8deeabf07572074c236095d /src/libs/libgroff/maxpathname.cpp | |
parent | Initial commit. (diff) | |
download | groff-f22bf21391d2b916c7303c565592ae6e99efbb58.tar.xz groff-f22bf21391d2b916c7303c565592ae6e99efbb58.zip |
Adding upstream version 1.23.0.upstream/1.23.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libs/libgroff/maxpathname.cpp')
-rw-r--r-- | src/libs/libgroff/maxpathname.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/libs/libgroff/maxpathname.cpp b/src/libs/libgroff/maxpathname.cpp new file mode 100644 index 0000000..8041eeb --- /dev/null +++ b/src/libs/libgroff/maxpathname.cpp @@ -0,0 +1,70 @@ +// -*- C++ -*- +/* Copyright (C) 2005-2020 Free Software Foundation, Inc. + Written by Werner Lemberg (wl@gnu.org) + +This file is part of groff. + +groff is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation, either version 3 of the License, or +(at your option) any later version. + +groff is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +/* path_name_max(dir) does the same as pathconf(dir, _PC_PATH_MAX) */ + +#include "lib.h" + +#include <sys/types.h> + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif /* HAVE_UNISTD_H */ + +#ifdef _POSIX_VERSION + +size_t path_name_max() +{ + return pathconf("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf("/",_PC_PATH_MAX); +} + +#else /* not _POSIX_VERSION */ + +#include <stdlib.h> + +#ifdef HAVE_DIRENT_H +# include <dirent.h> +#else /* not HAVE_DIRENT_H */ +# ifdef HAVE_SYS_DIR_H +# include <sys/dir.h> +# endif /* HAVE_SYS_DIR_H */ +#endif /* not HAVE_DIRENT_H */ + +#ifndef PATH_MAX +# ifdef MAXPATHLEN +# define PATH_MAX MAXPATHLEN +# else /* !MAXPATHLEN */ +# ifdef MAX_PATH +# define PATH_MAX MAX_PATH +# else /* !MAX_PATH */ +# ifdef _MAX_PATH +# define PATH_MAX _MAX_PATH +# else /* !_MAX_PATH */ +# define PATH_MAX 255 +# endif /* !_MAX_PATH */ +# endif /* !MAX_PATH */ +# endif /* !MAXPATHLEN */ +#endif /* !PATH_MAX */ + +size_t path_name_max() +{ + return PATH_MAX; +} + +#endif /* not _POSIX_VERSION */ |