Remove the dependency on test_windirent.h from the generated shell.c file.
[sqlite.git] / src / test_windirent.h
blobd71b49f68444d8c94a3ebb857e166b9c672d9c74
1 /*
2 ** 2015 November 30
3 **
4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
6 **
7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give.
11 *************************************************************************
12 ** This file contains declarations for most of the opendir() family of
13 ** POSIX functions on Win32 using the MSVCRT.
16 #if defined(_WIN32) && defined(_MSC_VER) && !defined(SQLITE_WINDIRENT_H)
17 #define SQLITE_WINDIRENT_H
20 ** We need several data types from the Windows SDK header.
23 #define WIN32_LEAN_AND_MEAN
24 #include "windows.h"
27 ** We need several support functions from the SQLite core.
30 #include "sqlite3.h"
33 ** We need several things from the ANSI and MSVCRT headers.
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <errno.h>
39 #include <io.h>
40 #include <limits.h>
41 #include <sys/types.h>
42 #include <sys/stat.h>
45 ** We may need several defines that should have been in "sys/stat.h".
48 #ifndef S_ISREG
49 #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
50 #endif
52 #ifndef S_ISDIR
53 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
54 #endif
56 #ifndef S_ISLNK
57 #define S_ISLNK(mode) (0)
58 #endif
61 ** We may need to provide the "mode_t" type.
64 #ifndef MODE_T_DEFINED
65 #define MODE_T_DEFINED
66 typedef unsigned short mode_t;
67 #endif
70 ** We may need to provide the "ino_t" type.
73 #ifndef INO_T_DEFINED
74 #define INO_T_DEFINED
75 typedef unsigned short ino_t;
76 #endif
79 ** We need to define "NAME_MAX" if it was not present in "limits.h".
82 #ifndef NAME_MAX
83 # ifdef FILENAME_MAX
84 # define NAME_MAX (FILENAME_MAX)
85 # else
86 # define NAME_MAX (260)
87 # endif
88 #endif
91 ** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T".
94 #ifndef NULL_INTPTR_T
95 # define NULL_INTPTR_T ((intptr_t)(0))
96 #endif
98 #ifndef BAD_INTPTR_T
99 # define BAD_INTPTR_T ((intptr_t)(-1))
100 #endif
103 ** We need to provide the necessary structures and related types.
106 #ifndef DIRENT_DEFINED
107 #define DIRENT_DEFINED
108 typedef struct DIRENT DIRENT;
109 typedef DIRENT *LPDIRENT;
110 struct DIRENT {
111 ino_t d_ino; /* Sequence number, do not use. */
112 unsigned d_attributes; /* Win32 file attributes. */
113 char d_name[NAME_MAX + 1]; /* Name within the directory. */
115 #endif
117 #ifndef DIR_DEFINED
118 #define DIR_DEFINED
119 typedef struct DIR DIR;
120 typedef DIR *LPDIR;
121 struct DIR {
122 intptr_t d_handle; /* Value returned by "_findfirst". */
123 DIRENT d_first; /* DIRENT constructed based on "_findfirst". */
124 DIRENT d_next; /* DIRENT constructed based on "_findnext". */
126 #endif
129 ** Provide a macro, for use by the implementation, to determine if a
130 ** particular directory entry should be skipped over when searching for
131 ** the next directory entry that should be returned by the readdir() or
132 ** readdir_r() functions.
135 #ifndef is_filtered
136 # define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM))
137 #endif
140 ** Provide the function prototype for the POSIX compatiable getenv()
141 ** function. This function is not thread-safe.
144 extern const char *windirent_getenv(const char *name);
147 ** Finally, we can provide the function prototypes for the opendir(),
148 ** readdir(), readdir_r(), and closedir() POSIX functions.
151 extern LPDIR opendir(const char *dirname);
152 extern LPDIRENT readdir(LPDIR dirp);
153 extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result);
154 extern INT closedir(LPDIR dirp);
156 #endif /* defined(WIN32) && defined(_MSC_VER) */