win32_os.inc 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. { Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. }
  16. {$ifdef WINDOWS}
  17. {
  18. * Compile the server including all the Windows NT 4.0 header files by
  19. * default. We still want the server to run on Win95/98 so use
  20. * runtime checks before calling NT specific functions to verify we are
  21. * really running on an NT system.
  22. }
  23. const
  24. _WIN32_WINNT = $0400;
  25. { If it isn't too late, prevent windows.h from including the original
  26. * winsock.h header, so that we can still include winsock2.h
  27. }
  28. {#if !defined(_WINSOCKAPI_) || !defined(_WINDOWS_)
  29. #define _WINSOCKAPI_
  30. #include <windows.h>
  31. #include <winsock2.h>
  32. #include <mswsock.h>
  33. #else
  34. #include <windows.h>
  35. #endif
  36. #include <process.h>
  37. #include <malloc.h>
  38. #include <io.h>
  39. #include <fcntl.h>}
  40. PLATFORM = 'Win32';
  41. {
  42. * This file in included in all Apache source code. It contains definitions
  43. * of facilities available on _this_ operating system (HAVE_* macros),
  44. * and prototypes of OS specific functions defined in os.c
  45. }
  46. { temporarily replace crypt }
  47. { char *crypt(const char *pw, const char *salt); }
  48. //#define crypt(buf,salt) (buf)
  49. { Although DIR_TYPE is dirent (see nt/readdir.h) we need direct.h for
  50. chdir() }
  51. //#include <direct.h>
  52. {$define STATUS}
  53. {$define STRICT}
  54. {$define CASE_BLIND_FILESYSTEM}
  55. {$define NO_WRITEV}
  56. {$define NO_SETSID}
  57. {$define NO_USE_SIGACTION}
  58. {$define NO_TIMES}
  59. {$define NO_GETTIMEOFDAY}
  60. {$define USE_LONGJMP}
  61. {$define HAVE_MMAP}
  62. {$define USE_MMAP_SCOREBOARD}
  63. {$define MULTITHREAD}
  64. {$define HAVE_CANONICAL_FILENAME}
  65. {$define HAVE_DRIVE_LETTERS}
  66. {$define HAVE_UNC_PATHS}
  67. type
  68. uid_t = cint;
  69. gid_t = cint;
  70. pid_t = cint;
  71. Ppid_t = ^pid_t;
  72. tid_t = cint;
  73. {$ifdef _MSC_VER}
  74. { modified to match declaration in sys/stat.h }
  75. mode_t = cushort;
  76. {$endif}
  77. caddr_t = PChar;
  78. {
  79. Define export types. API_EXPORT_NONSTD is a nasty hack to avoid having to declare
  80. every configuration function as __stdcall.
  81. }
  82. {#ifdef SHARED_MODULE
  83. #define API_VAR_EXPORT __declspec(dllimport)
  84. #define API_EXPORT(type) __declspec(dllimport) type __stdcall
  85. #define API_EXPORT_NONSTD(type) __declspec(dllimport) type __cdecl
  86. #else
  87. #define API_VAR_EXPORT __declspec(dllexport)
  88. #define API_EXPORT(type) __declspec(dllexport) type __stdcall
  89. #define API_EXPORT_NONSTD(type) __declspec(dllexport) type __cdecl
  90. #endif
  91. #define MODULE_VAR_EXPORT __declspec(dllexport)
  92. #define strcasecmp(s1, s2) stricmp(s1, s2)
  93. #define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
  94. #define lstat(x, y) stat(x, y)
  95. #ifndef S_ISLNK
  96. #define S_ISLNK(m) (0)
  97. #endif
  98. #ifndef S_ISREG
  99. #define S_ISREG(m) ((m & _S_IFREG) == _S_IFREG)
  100. #endif
  101. #ifndef S_ISDIR
  102. #define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
  103. #endif
  104. #define STDIN_FILENO 0
  105. #define STDOUT_FILENO 1
  106. #define STDERR_FILENO 2
  107. #define JMP_BUF jmp_buf
  108. #define sleep(t) Sleep(t*1000)
  109. #ifndef O_CREAT
  110. #define O_CREAT _O_CREAT
  111. #endif
  112. #ifndef O_RDWR
  113. #define O_RDWR _O_RDWR
  114. #endif
  115. #define SIGPIPE 17}
  116. { Seems Windows is not a subgenius }
  117. {$define NO_SLACK}
  118. //#include <stddef.h>
  119. { MSVC asserts that strtol "errno is set to ERANGE
  120. * if overflow or underflow occurs"
  121. * Ergo we can use the library strtol safely.
  122. }
  123. //#define ap_strtol strtol
  124. {$define NO_OTHER_CHILD}
  125. {$define NO_RELIABLE_PIPED_LOGS}
  126. //__inline int ap_os_is_path_absolute(const char *file)
  127. {
  128. For now, just do the same check that http_request.c and mod_alias.c
  129. * do.
  130. return file && (file[0] == '/' || (file[1] == ':' && file[2] == '/'));
  131. }
  132. {#define stat(f,ps) os_stat(f,ps)
  133. API_EXPORT(int) os_stat(const char *szPath,struct stat *pStat);
  134. API_EXPORT(int) os_strftime(char *s, size_t max, const char *format, const struct tm *tm);
  135. #define _spawnv(mode,cmdname,argv) os_spawnv(mode,cmdname,argv)
  136. #define spawnv(mode,cmdname,argv) os_spawnv(mode,cmdname,argv)
  137. API_EXPORT(int) os_spawnv(int mode,const char *cmdname,const char *const *argv);
  138. #define _spawnve(mode,cmdname,argv,envp) os_spawnve(mode,cmdname,argv,envp)
  139. #define spawnve(mode,cmdname,argv,envp) os_spawnve(mode,cmdname,argv,envp)
  140. API_EXPORT(int) os_spawnve(int mode,const char *cmdname,const char *const *argv,const char *const *envp);
  141. #define _spawnle os_spawnle
  142. #define spawnle os_spawnle
  143. API_EXPORT_NONSTD(int) os_spawnle(int mode,const char *cmdname,...);}
  144. { OS-dependent filename routines in util_win32.c }
  145. //API_EXPORT(int) ap_os_is_filename_valid(const char *file);
  146. { Abstractions for dealing with shared object files (DLLs on Win32).
  147. * These are used by mod_so.c
  148. }
  149. {#define ap_os_dso_handle_t HINSTANCE
  150. #define ap_os_dso_init()
  151. #define ap_os_dso_unload(l) FreeLibrary(l)
  152. #define ap_os_dso_sym(h,s) GetProcAddress(h,s)
  153. API_EXPORT(ap_os_dso_handle_t) ap_os_dso_load(const char *);
  154. API_EXPORT(const char *) ap_os_dso_error(void);}
  155. { Other ap_os_ routines not used by this platform }
  156. //#define ap_os_kill(pid, sig) kill(pid, sig)
  157. { Some Win32isms }
  158. {$define HAVE_ISNAN}
  159. //#define isnan(n) _isnan(n)
  160. {$define HAVE_ISINF}
  161. //#define isinf(n) (!_finite(n))
  162. //#define gettid() ((tid_t)GetCurrentThreadId())
  163. {$endif} { WINDOWS }