No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / groff / src / libs / libgroff / maxfilename.cpp
blobeeb3b1e3e5619fbaa63088861bbfaf4c557003d6
1 /* $NetBSD$ */
3 // -*- C++ -*-
4 /* Copyright (C) 1992, 2001, 2003, 2005 Free Software Foundation, Inc.
5 Written by James Clark (jjc@jclark.com)
7 This file is part of groff.
9 groff is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 2, or (at your option) any later
12 version.
14 groff is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 for more details.
19 You should have received a copy of the GNU General Public License along
20 with groff; see the file COPYING. If not, write to the Free Software
21 Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
23 /* file_name_max(dir) does the same as pathconf(dir, _PC_NAME_MAX) */
25 #include "lib.h"
27 #include <sys/types.h>
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif /* HAVE_UNISTD_H */
33 #ifdef _POSIX_VERSION
35 size_t file_name_max(const char *fname)
37 return pathconf(fname, _PC_NAME_MAX);
40 #else /* not _POSIX_VERSION */
42 #ifdef HAVE_DIRENT_H
43 #include <dirent.h>
44 #else /* not HAVE_DIRENT_H */
45 #ifdef HAVE_SYS_DIR_H
46 #include <sys/dir.h>
47 #endif /* HAVE_SYS_DIR_H */
48 #endif /* not HAVE_DIRENT_H */
50 #ifndef NAME_MAX
51 #ifdef MAXNAMLEN
52 #define NAME_MAX MAXNAMLEN
53 #else /* !MAXNAMLEN */
54 #ifdef MAXNAMELEN
55 #define NAME_MAX MAXNAMELEN
56 #else /* !MAXNAMELEN */
57 #define NAME_MAX 14
58 #endif /* !MAXNAMELEN */
59 #endif /* !MAXNAMLEN */
60 #endif /* !NAME_MAX */
62 size_t file_name_max(const char *)
64 return NAME_MAX;
67 #endif /* not _POSIX_VERSION */