#undef PACKAGE_NAME and friends to avoid clashes
[haskell-directory.git] / include / HsDirectory.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The University of Glasgow 2001-2004
4  *
5  * Definitions for package `directory' which are visible in Haskell land.
6  *
7  * ---------------------------------------------------------------------------*/
8
9 #ifndef __HSDIRECTORY_H__
10 #define __HSDIRECTORY_H__
11
12 #include "HsDirectoryConfig.h"
13 // Otherwise these clash with similar definitions from other packages:
14 #undef PACKAGE_BUGREPORT
15 #undef PACKAGE_NAME
16 #undef PACKAGE_STRING
17 #undef PACKAGE_TARNAME
18 #undef PACKAGE_VERSION
19
20 #if HAVE_SYS_TYPES_H
21 #include <sys/types.h>
22 #endif
23 #if HAVE_UNISTD_H
24 #include <unistd.h>
25 #endif
26 #if HAVE_SYS_STAT_H
27 #include <sys/stat.h>
28 #endif
29
30 #include "HsFFI.h"
31
32 #if defined(__MINGW32__)
33 #include <shlobj.h>
34 #endif
35
36 #if defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)
37 extern int __hscore_getFolderPath(HWND hwndOwner,
38                   int nFolder,
39                   HANDLE hToken,
40                   DWORD dwFlags,
41                   char*  pszPath);
42 #endif
43
44 /* -----------------------------------------------------------------------------
45    INLINE functions.
46
47    These functions are given as inlines here for when compiling via C,
48    but we also generate static versions into the cbits library for
49    when compiling to native code.
50    -------------------------------------------------------------------------- */
51
52 #ifndef INLINE
53 # if defined(_MSC_VER)
54 #  define INLINE extern __inline
55 # else
56 #  define INLINE static inline
57 # endif
58 #endif
59
60 /* A size that will contain many path names, but not necessarily all
61  * (PATH_MAX is not defined on systems with unlimited path length,
62  * e.g. the Hurd).
63  */
64 INLINE HsInt __hscore_long_path_size() {
65 #ifdef PATH_MAX
66     return PATH_MAX;
67 #else
68     return 4096;
69 #endif
70 }
71
72 #ifdef __GLASGOW_HASKELL__
73 INLINE int __hscore_R_OK() { return R_OK; }
74 INLINE int __hscore_W_OK() { return W_OK; }
75 INLINE int __hscore_X_OK() { return X_OK; }
76
77 INLINE mode_t __hscore_S_IRUSR() { return S_IRUSR; }
78 INLINE mode_t __hscore_S_IWUSR() { return S_IWUSR; }
79 INLINE mode_t __hscore_S_IXUSR() { return S_IXUSR; }
80 #endif
81
82 #if defined(__MINGW32__)
83
84 /* Make sure we've got the reqd CSIDL_ constants in scope;
85  * w32api header files are lagging a bit in defining the full set.
86  */
87 #if !defined(CSIDL_APPDATA)
88 #define CSIDL_APPDATA 0x001a
89 #endif
90 #if !defined(CSIDL_PERSONAL)
91 #define CSIDL_PERSONAL 0x0005
92 #endif
93 #if !defined(CSIDL_PROFILE)
94 #define CSIDL_PROFILE 0x0028
95 #endif
96 #if !defined(CSIDL_WINDOWS)
97 #define CSIDL_WINDOWS 0x0024
98 #endif
99
100 INLINE int __hscore_CSIDL_PROFILE()  { return CSIDL_PROFILE;  }
101 INLINE int __hscore_CSIDL_APPDATA()  { return CSIDL_APPDATA;  }
102 INLINE int __hscore_CSIDL_WINDOWS()  { return CSIDL_WINDOWS;  }
103 INLINE int __hscore_CSIDL_PERSONAL() { return CSIDL_PERSONAL; }
104 #endif
105
106 #endif /* __HSDIRECTORY_H__ */
107