file_case.{h,cpp}: wether->whether; 2017
[s-roff.git] / src / lib-roff / maxfilename.cpp
blob5c80f5b88249803654e66173e1adb9df7c5d9430
1 /*@ file_name_max(dir) does the same as pathconf(dir, _PC_NAME_MAX).
3 * Copyright (c) 2014 - 2017 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>.
5 * Copyright (C) 1992, 2001, 2003, 2005 Free Software Foundation, Inc.
6 * Written by James Clark (jjc@jclark.com)
8 * This is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2, or (at your option) any later
11 * version.
13 * This is distributed in the hope that it will be useful, but WITHOUT ANY
14 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with groff; see the file COPYING. If not, write to the Free Software
20 * Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA.
23 #include "config.h"
24 #include "lib.h"
26 #include <sys/types.h>
28 #ifdef HAVE_UNISTD_H
29 # include <unistd.h>
30 #endif
32 #ifdef _POSIX_VERSION
33 size_t file_name_max(const char *fname)
35 return pathconf(fname, _PC_NAME_MAX);
38 #else
39 # ifdef HAVE_DIRENT_H
40 # include <dirent.h>
41 # else
42 # ifdef HAVE_SYS_DIR_H
43 # include <sys/dir.h>
44 # endif
45 # endif
47 # ifndef NAME_MAX
48 # ifdef MAXNAMLEN
49 # define NAME_MAX MAXNAMLEN
50 # else
51 # ifdef MAXNAMELEN
52 # define NAME_MAX MAXNAMELEN
53 # else
54 # define NAME_MAX 14
55 # endif
56 # endif
57 # endif
59 size_t file_name_max(const char *)
61 return NAME_MAX;
63 #endif /* _POSIX_VERSION */
65 // s-it2-mode