r23795: more v2->v3 conversion
[samba.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      ** NOTE! The following LGPL license applies to the replace
11      ** library. This does NOT imply that all of Samba is released
12      ** under the LGPL
13    
14    This library is free software; you can redistribute it and/or
15    modify it under the terms of the GNU Lesser General Public
16    License as published by the Free Software Foundation; either
17    version 3 of the License, or (at your option) any later version.
18
19    This library is distributed in the hope that it will be useful,
20    but WITHOUT ANY WARRANTY; without even the implied warranty of
21    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
22    Lesser General Public License for more details.
23
24    You should have received a copy of the GNU Lesser General Public
25    License along with this library; if not, write to the Free Software
26    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27 */
28
29 #if HAVE_DIRENT_H
30 # include <dirent.h>
31 # define NAMLEN(dirent) strlen((dirent)->d_name)
32 #else
33 # define dirent direct
34 # define NAMLEN(dirent) (dirent)->d_namlen
35 # if HAVE_SYS_NDIR_H
36 #  include <sys/ndir.h>
37 # endif
38 # if HAVE_SYS_DIR_H
39 #  include <sys/dir.h>
40 # endif
41 # if HAVE_NDIR_H
42 #  include <ndir.h>
43 # endif
44 #endif
45
46 #ifndef HAVE_MKDIR_MODE
47 #define mkdir(dir, mode) mkdir(dir)
48 #endif
49
50 /* Test whether a file name is the "." or ".." directory entries.
51  * These really should be inline functions.
52  */
53 #ifndef ISDOT
54 #define ISDOT(path) ( \
55                         *((const char *)(path)) == '.' && \
56                         *(((const char *)(path)) + 1) == '\0' \
57                     )
58 #endif
59
60 #ifndef ISDOTDOT
61 #define ISDOTDOT(path)  ( \
62                             *((const char *)(path)) == '.' && \
63                             *(((const char *)(path)) + 1) == '.' && \
64                             *(((const char *)(path)) + 2) == '\0' \
65                         )
66 #endif
67
68 #endif