r18127: Add macro AC_CHECK_DECL() for systems that don't have it.
[jelmer/samba4-debian.git] / source / lib / replace / system / dir.h
1 #ifndef _system_dir_h
2 #define _system_dir_h
3 /* 
4    Unix SMB/CIFS implementation.
5
6    directory system include wrappers
7
8    Copyright (C) Andrew Tridgell 2004
9    
10    This program is free software; you can redistribute it and/or modify
11    it under the terms of the GNU General Public License as published by
12    the Free Software Foundation; either version 2 of the License, or
13    (at your option) any later version.
14    
15    This program is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19    
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25 #if HAVE_DIRENT_H
26 # include <dirent.h>
27 # define NAMLEN(dirent) strlen((dirent)->d_name)
28 #else
29 # define dirent direct
30 # define NAMLEN(dirent) (dirent)->d_namlen
31 # if HAVE_SYS_NDIR_H
32 #  include <sys/ndir.h>
33 # endif
34 # if HAVE_SYS_DIR_H
35 #  include <sys/dir.h>
36 # endif
37 # if HAVE_NDIR_H
38 #  include <ndir.h>
39 # endif
40 #endif
41
42 #ifndef HAVE_MKDIR_MODE
43 #define mkdir(dir, mode) mkdir(dir)
44 #endif
45
46 /* Test whether a file name is the "." or ".." directory entries.
47  * These really should be inline functions.
48  */
49 #ifndef ISDOT
50 #define ISDOT(path) ( \
51                         *((const char *)(path)) == '.' && \
52                         *(((const char *)(path)) + 1) == '\0' \
53                     )
54 #endif
55
56 #ifndef ISDOTDOT
57 #define ISDOTDOT(path)  ( \
58                             *((const char *)(path)) == '.' && \
59                             *(((const char *)(path)) + 1) == '.' && \
60                             *(((const char *)(path)) + 2) == '\0' \
61                         )
62 #endif
63
64 #endif