Blame include/filenames.h

Packit Service 72eb06
/* Macros for taking apart, interpreting and processing file names.
Packit Service 72eb06
Packit Service 72eb06
   These are here because some non-Posix (a.k.a. DOSish) systems have
Packit Service 72eb06
   drive letter brain-damage at the beginning of an absolute file name,
Packit Service 72eb06
   use forward- and back-slash in path names interchangeably, and
Packit Service 72eb06
   some of them have case-insensitive file names.
Packit Service 72eb06
Packit Service 72eb06
   Copyright (C) 2000-2018 Free Software Foundation, Inc.
Packit Service 72eb06
Packit Service 72eb06
This file is part of BFD, the Binary File Descriptor library.
Packit Service 72eb06
Packit Service 72eb06
This program is free software; you can redistribute it and/or modify
Packit Service 72eb06
it under the terms of the GNU General Public License as published by
Packit Service 72eb06
the Free Software Foundation; either version 2 of the License, or
Packit Service 72eb06
(at your option) any later version.
Packit Service 72eb06
Packit Service 72eb06
This program is distributed in the hope that it will be useful,
Packit Service 72eb06
but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 72eb06
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 72eb06
GNU General Public License for more details.
Packit Service 72eb06
Packit Service 72eb06
You should have received a copy of the GNU General Public License
Packit Service 72eb06
along with this program; if not, write to the Free Software
Packit Service 72eb06
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
Packit Service 72eb06
Packit Service 72eb06
#ifndef FILENAMES_H
Packit Service 72eb06
#define FILENAMES_H
Packit Service 72eb06
Packit Service 72eb06
#include "hashtab.h" /* for hashval_t */
Packit Service 72eb06
Packit Service 72eb06
#ifdef __cplusplus
Packit Service 72eb06
extern "C" {
Packit Service 72eb06
#endif
Packit Service 72eb06
Packit Service 72eb06
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) || defined (__CYGWIN__)
Packit Service 72eb06
#  ifndef HAVE_DOS_BASED_FILE_SYSTEM
Packit Service 72eb06
#    define HAVE_DOS_BASED_FILE_SYSTEM 1
Packit Service 72eb06
#  endif
Packit Service 72eb06
#  ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
Packit Service 72eb06
#    define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
Packit Service 72eb06
#  endif
Packit Service 72eb06
#  define HAS_DRIVE_SPEC(f) HAS_DOS_DRIVE_SPEC (f)
Packit Service 72eb06
#  define IS_DIR_SEPARATOR(c) IS_DOS_DIR_SEPARATOR (c)
Packit Service 72eb06
#  define IS_ABSOLUTE_PATH(f) IS_DOS_ABSOLUTE_PATH (f)
Packit Service 72eb06
#else /* not DOSish */
Packit Service 72eb06
#  if defined(__APPLE__)
Packit Service 72eb06
#    ifndef HAVE_CASE_INSENSITIVE_FILE_SYSTEM
Packit Service 72eb06
#      define HAVE_CASE_INSENSITIVE_FILE_SYSTEM 1
Packit Service 72eb06
#    endif
Packit Service 72eb06
#  endif /* __APPLE__ */
Packit Service 72eb06
#  define HAS_DRIVE_SPEC(f) (0)
Packit Service 72eb06
#  define IS_DIR_SEPARATOR(c) IS_UNIX_DIR_SEPARATOR (c)
Packit Service 72eb06
#  define IS_ABSOLUTE_PATH(f) IS_UNIX_ABSOLUTE_PATH (f)
Packit Service 72eb06
#endif
Packit Service 72eb06
Packit Service 72eb06
#define IS_DIR_SEPARATOR_1(dos_based, c)				\
Packit Service 72eb06
  (((c) == '/')								\
Packit Service 72eb06
   || (((c) == '\\') && (dos_based)))
Packit Service 72eb06
Packit Service 72eb06
#define HAS_DRIVE_SPEC_1(dos_based, f)			\
Packit Service 72eb06
  ((f)[0] && ((f)[1] == ':') && (dos_based))
Packit Service 72eb06
Packit Service 72eb06
/* Remove the drive spec from F, assuming HAS_DRIVE_SPEC (f).
Packit Service 72eb06
   The result is a pointer to the remainder of F.  */
Packit Service 72eb06
#define STRIP_DRIVE_SPEC(f)	((f) + 2)
Packit Service 72eb06
Packit Service 72eb06
#define IS_DOS_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (1, c)
Packit Service 72eb06
#define IS_DOS_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (1, f)
Packit Service 72eb06
#define HAS_DOS_DRIVE_SPEC(f) HAS_DRIVE_SPEC_1 (1, f)
Packit Service 72eb06
Packit Service 72eb06
#define IS_UNIX_DIR_SEPARATOR(c) IS_DIR_SEPARATOR_1 (0, c)
Packit Service 72eb06
#define IS_UNIX_ABSOLUTE_PATH(f) IS_ABSOLUTE_PATH_1 (0, f)
Packit Service 72eb06
Packit Service 72eb06
/* Note that when DOS_BASED is true, IS_ABSOLUTE_PATH accepts d:foo as
Packit Service 72eb06
   well, although it is only semi-absolute.  This is because the users
Packit Service 72eb06
   of IS_ABSOLUTE_PATH want to know whether to prepend the current
Packit Service 72eb06
   working directory to a file name, which should not be done with a
Packit Service 72eb06
   name like d:foo.  */
Packit Service 72eb06
#define IS_ABSOLUTE_PATH_1(dos_based, f)		 \
Packit Service 72eb06
  (IS_DIR_SEPARATOR_1 (dos_based, (f)[0])		 \
Packit Service 72eb06
   || HAS_DRIVE_SPEC_1 (dos_based, f))
Packit Service 72eb06
Packit Service 72eb06
extern int filename_cmp (const char *s1, const char *s2);
Packit Service 72eb06
#define FILENAME_CMP(s1, s2)	filename_cmp(s1, s2)
Packit Service 72eb06
Packit Service 72eb06
extern int filename_ncmp (const char *s1, const char *s2,
Packit Service 72eb06
			  size_t n);
Packit Service 72eb06
Packit Service 72eb06
extern hashval_t filename_hash (const void *s);
Packit Service 72eb06
Packit Service 72eb06
extern int filename_eq (const void *s1, const void *s2);
Packit Service 72eb06
Packit Service 72eb06
extern int canonical_filename_eq (const char *a, const char *b);
Packit Service 72eb06
Packit Service 72eb06
#ifdef __cplusplus
Packit Service 72eb06
}
Packit Service 72eb06
#endif
Packit Service 72eb06
Packit Service 72eb06
#endif /* FILENAMES_H */