xref: /dflybsd-src/contrib/grep/lib/dirname.h (revision 91b9ed38d3db6a8a8ac5b66da1d43e6e331e259a)
195b7b453SJohn Marino /*  Take file names apart into directory and base names.
295b7b453SJohn Marino 
3*09d4459fSDaniel Fojt     Copyright (C) 1998, 2001, 2003-2006, 2009-2020 Free Software Foundation,
495b7b453SJohn Marino     Inc.
595b7b453SJohn Marino 
695b7b453SJohn Marino     This program is free software: you can redistribute it and/or modify
795b7b453SJohn Marino     it under the terms of the GNU General Public License as published by
895b7b453SJohn Marino     the Free Software Foundation; either version 3 of the License, or
995b7b453SJohn Marino     (at your option) any later version.
1095b7b453SJohn Marino 
1195b7b453SJohn Marino     This program is distributed in the hope that it will be useful,
1295b7b453SJohn Marino     but WITHOUT ANY WARRANTY; without even the implied warranty of
1395b7b453SJohn Marino     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1495b7b453SJohn Marino     GNU General Public License for more details.
1595b7b453SJohn Marino 
1695b7b453SJohn Marino     You should have received a copy of the GNU General Public License
17*09d4459fSDaniel Fojt     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
1895b7b453SJohn Marino 
1995b7b453SJohn Marino #ifndef DIRNAME_H_
2095b7b453SJohn Marino # define DIRNAME_H_ 1
2195b7b453SJohn Marino 
2295b7b453SJohn Marino # include <stdbool.h>
2395b7b453SJohn Marino # include <stddef.h>
24200fbe8dSJohn Marino # include "dosname.h"
2595b7b453SJohn Marino 
2695b7b453SJohn Marino # ifndef DIRECTORY_SEPARATOR
2795b7b453SJohn Marino #  define DIRECTORY_SEPARATOR '/'
2895b7b453SJohn Marino # endif
2995b7b453SJohn Marino 
3095b7b453SJohn Marino # ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
3195b7b453SJohn Marino #  define DOUBLE_SLASH_IS_DISTINCT_ROOT 0
3295b7b453SJohn Marino # endif
3395b7b453SJohn Marino 
34dc7c36e4SJohn Marino #ifdef __cplusplus
35dc7c36e4SJohn Marino extern "C" {
36dc7c36e4SJohn Marino #endif
37dc7c36e4SJohn Marino 
3895b7b453SJohn Marino # if GNULIB_DIRNAME
39*09d4459fSDaniel Fojt char *base_name (char const *file) _GL_ATTRIBUTE_MALLOC;
4095b7b453SJohn Marino char *dir_name (char const *file);
4195b7b453SJohn Marino # endif
4295b7b453SJohn Marino 
4395b7b453SJohn Marino char *mdir_name (char const *file);
44cf28ed85SJohn Marino size_t base_len (char const *file) _GL_ATTRIBUTE_PURE;
45cf28ed85SJohn Marino size_t dir_len (char const *file) _GL_ATTRIBUTE_PURE;
46cf28ed85SJohn Marino char *last_component (char const *file) _GL_ATTRIBUTE_PURE;
4795b7b453SJohn Marino 
4895b7b453SJohn Marino bool strip_trailing_slashes (char *file);
4995b7b453SJohn Marino 
50dc7c36e4SJohn Marino #ifdef __cplusplus
51dc7c36e4SJohn Marino } /* extern "C" */
52dc7c36e4SJohn Marino #endif
53dc7c36e4SJohn Marino 
5495b7b453SJohn Marino #endif /* not DIRNAME_H_ */
55