xref: /dflybsd-src/contrib/cvs-1.12/lib/dirname.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
186d7f5d3SJohn Marino /*  Take file names apart into directory and base names.
286d7f5d3SJohn Marino 
386d7f5d3SJohn Marino     Copyright (C) 1998, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
486d7f5d3SJohn Marino 
586d7f5d3SJohn Marino     This program is free software; you can redistribute it and/or modify
686d7f5d3SJohn Marino     it under the terms of the GNU General Public License as published by
786d7f5d3SJohn Marino     the Free Software Foundation; either version 2, or (at your option)
886d7f5d3SJohn Marino     any later version.
986d7f5d3SJohn Marino 
1086d7f5d3SJohn Marino     This program is distributed in the hope that it will be useful,
1186d7f5d3SJohn Marino     but WITHOUT ANY WARRANTY; without even the implied warranty of
1286d7f5d3SJohn Marino     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1386d7f5d3SJohn Marino     GNU General Public License for more details.
1486d7f5d3SJohn Marino 
1586d7f5d3SJohn Marino     You should have received a copy of the GNU General Public License
1686d7f5d3SJohn Marino     along with this program; if not, write to the Free Software Foundation,
1786d7f5d3SJohn Marino     Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
1886d7f5d3SJohn Marino 
1986d7f5d3SJohn Marino #ifndef DIRNAME_H_
2086d7f5d3SJohn Marino # define DIRNAME_H_ 1
2186d7f5d3SJohn Marino 
2286d7f5d3SJohn Marino # include <stdbool.h>
2386d7f5d3SJohn Marino # include <stddef.h>
2486d7f5d3SJohn Marino 
2586d7f5d3SJohn Marino # ifndef DIRECTORY_SEPARATOR
2686d7f5d3SJohn Marino #  define DIRECTORY_SEPARATOR '/'
2786d7f5d3SJohn Marino # endif
2886d7f5d3SJohn Marino 
2986d7f5d3SJohn Marino # ifndef ISSLASH
3086d7f5d3SJohn Marino #  define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
3186d7f5d3SJohn Marino # endif
3286d7f5d3SJohn Marino 
3386d7f5d3SJohn Marino # ifndef FILE_SYSTEM_PREFIX_LEN
3486d7f5d3SJohn Marino #  define FILE_SYSTEM_PREFIX_LEN(File_name) 0
3586d7f5d3SJohn Marino # endif
3686d7f5d3SJohn Marino 
3786d7f5d3SJohn Marino # define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
3886d7f5d3SJohn Marino # define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
3986d7f5d3SJohn Marino 
4086d7f5d3SJohn Marino char *base_name (char const *file);
4186d7f5d3SJohn Marino char *dir_name (char const *file);
4286d7f5d3SJohn Marino size_t base_len (char const *file);
4386d7f5d3SJohn Marino size_t dir_len (char const *file);
4486d7f5d3SJohn Marino 
4586d7f5d3SJohn Marino bool strip_trailing_slashes (char *file);
4686d7f5d3SJohn Marino 
4786d7f5d3SJohn Marino #endif /* not DIRNAME_H_ */
48