LCOV - code coverage report
Current view: top level - libs/libgroff - maxfilename.cpp (source / functions) Hit Total Coverage
Test: GNU roff Lines: 2 2 100.0 %
Date: 2026-01-16 17:51:41 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright 1992-2024 Free Software Foundation, Inc.
       2             :      Written by James Clark (jjc@jclark.com)
       3             : 
       4             : This file is part of groff, the GNU roff typesetting system.
       5             : 
       6             : groff is free software; you can redistribute it and/or modify it under
       7             : the terms of the GNU General Public License as published by the Free
       8             : Software Foundation, either version 3 of the License, or
       9             : (at your option) any later version.
      10             : 
      11             : groff is distributed in the hope that it will be useful, but WITHOUT ANY
      12             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14             : for more details.
      15             : 
      16             : You should have received a copy of the GNU General Public License
      17             : along with this program.  If not, see <http://www.gnu.org/licenses/>. */
      18             : 
      19             : #ifdef HAVE_CONFIG_H
      20             : #include <config.h>
      21             : #endif
      22             : 
      23             : // needed for _PC_NAME_MAX, pathconf()
      24             : #include "posix.h"
      25             : #include "nonposix.h"
      26             : 
      27             : #include "lib.h"
      28             : 
      29             : /* file_name_max(dir) does the same as pathconf(dir, _PC_NAME_MAX) */
      30             : 
      31             : #ifdef _POSIX_VERSION
      32             : 
      33         100 : size_t file_name_max(const char *fname)
      34             : {
      35         100 :   return pathconf(fname, _PC_NAME_MAX);
      36             : }
      37             : 
      38             : #else /* not _POSIX_VERSION */
      39             : 
      40             : #ifdef HAVE_DIRENT_H
      41             : #include <dirent.h>
      42             : #else /* not HAVE_DIRENT_H */
      43             : #ifdef HAVE_SYS_DIR_H
      44             : #include <sys/dir.h>
      45             : #endif /* HAVE_SYS_DIR_H */
      46             : #endif /* not HAVE_DIRENT_H */
      47             : 
      48             : #ifndef NAME_MAX
      49             : #ifdef MAXNAMLEN
      50             : #define NAME_MAX MAXNAMLEN
      51             : #endif
      52             : #endif
      53             : 
      54             : #ifndef NAME_MAX
      55             : #ifdef MAXNAMELEN
      56             : #define NAME_MAX MAXNAMELEN
      57             : #endif
      58             : #endif
      59             : 
      60             : #ifndef NAME_MAX
      61             : #include <stdio.h>
      62             : #ifdef FILENAME_MAX
      63             : #define NAME_MAX FILENAME_MAX
      64             : #endif
      65             : #endif
      66             : 
      67             : #ifndef NAME_MAX
      68             : #define NAME_MAX 14
      69             : #endif
      70             : 
      71             : size_t file_name_max(const char *)
      72             : {
      73             :   return NAME_MAX;
      74             : }
      75             : 
      76             : #endif /* not _POSIX_VERSION */
      77             : 
      78             : // Local Variables:
      79             : // fill-column: 72
      80             : // mode: C++
      81             : // End:
      82             : // vim: set cindent noexpandtab shiftwidth=2 textwidth=72:

Generated by: LCOV version 1.14