Import upstream version 1.28
[debian/tar] / gnu / filename.h
1 /* -*- buffer-read-only: t -*- vi: set ro: */
2 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
3 /* Basic filename support macros.
4    Copyright (C) 2001-2004, 2007-2014 Free Software Foundation, Inc.
5
6    This program is free software: you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License 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 #ifndef _FILENAME_H
20 #define _FILENAME_H
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26
27 /* Pathname support.
28    ISSLASH(C)           tests whether C is a directory separator character.
29    IS_ABSOLUTE_PATH(P)  tests whether P is an absolute path.  If it is not,
30                         it may be concatenated to a directory pathname.
31    IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
32  */
33 #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
34   /* Native Windows, Cygwin, OS/2, DOS */
35 # define ISSLASH(C) ((C) == '/' || (C) == '\\')
36 # define HAS_DEVICE(P) \
37     ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
38      && (P)[1] == ':')
39 # define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
40 # define IS_PATH_WITH_DIR(P) \
41     (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
42 # define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
43 #else
44   /* Unix */
45 # define ISSLASH(C) ((C) == '/')
46 # define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
47 # define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
48 # define FILE_SYSTEM_PREFIX_LEN(P) 0
49 #endif
50
51
52 #ifdef __cplusplus
53 }
54 #endif
55
56 #endif /* _FILENAME_H */