Browse Source

* Apache headers by Felipe Monteiro de Carvalho added

git-svn-id: trunk@4875 -
michael 19 years ago
parent
commit
2979d4b68a
100 changed files with 41672 additions and 31 deletions
  1. 133 0
      .gitattributes
  2. 89 22
      packages/base/Makefile
  3. 9 9
      packages/base/Makefile.fpc
  4. 2006 0
      packages/base/httpd/Makefile
  5. 15 0
      packages/base/httpd/Makefile.fpc
  6. 1988 0
      packages/base/httpd/examples/Makefile
  7. 16 0
      packages/base/httpd/examples/Makefile.fpc
  8. 42 0
      packages/base/httpd/examples/define.inc
  9. 66 0
      packages/base/httpd/examples/minimain.pas
  10. 1343 0
      packages/base/httpd/examples/mod_example.pp
  11. 131 0
      packages/base/httpd/examples/mod_hello.pp
  12. 654 0
      packages/base/httpd/examples/mod_spelling.pp
  13. 41 0
      packages/base/httpd/examples/testmodule.pp
  14. 1625 0
      packages/base/httpd/httpd-1.3/Makefile
  15. 19 0
      packages/base/httpd/httpd-1.3/Makefile.fpc
  16. 175 0
      packages/base/httpd/httpd-1.3/ap.inc
  17. 451 0
      packages/base/httpd/httpd-1.3/ap_alloc.inc
  18. 1496 0
      packages/base/httpd/httpd-1.3/ap_config.inc
  19. 237 0
      packages/base/httpd/httpd-1.3/ap_mmn.inc
  20. 234 0
      packages/base/httpd/httpd-1.3/buff.inc
  21. 97 0
      packages/base/httpd/httpd-1.3/hsregex.inc
  22. 402 0
      packages/base/httpd/httpd-1.3/http_config.inc
  23. 422 0
      packages/base/httpd/httpd-1.3/http_core.inc
  24. 126 0
      packages/base/httpd/httpd-1.3/http_log.inc
  25. 160 0
      packages/base/httpd/httpd-1.3/http_main.inc
  26. 239 0
      packages/base/httpd/httpd-1.3/http_protocol.inc
  27. 82 0
      packages/base/httpd/httpd-1.3/http_request.inc
  28. 49 0
      packages/base/httpd/httpd-1.3/http_vhost.inc
  29. 1263 0
      packages/base/httpd/httpd-1.3/httpd.inc
  30. 174 0
      packages/base/httpd/httpd-1.3/httpd.pas
  31. 84 0
      packages/base/httpd/httpd-1.3/util_uri.inc
  32. 191 0
      packages/base/httpd/httpd-1.3/win32_os.inc
  33. 1865 0
      packages/base/httpd/httpd-2.0/Makefile
  34. 19 0
      packages/base/httpd/httpd-2.0/Makefile.fpc
  35. 248 0
      packages/base/httpd/httpd-2.0/ap_config.inc
  36. 121 0
      packages/base/httpd/httpd-2.0/ap_mmn.inc
  37. 179 0
      packages/base/httpd/httpd-2.0/ap_mpm.inc
  38. 50 0
      packages/base/httpd/httpd-2.0/ap_provider.inc
  39. 53 0
      packages/base/httpd/httpd-2.0/ap_release.inc
  40. 246 0
      packages/base/httpd/httpd-2.0/apr/apr.pas
  41. 174 0
      packages/base/httpd/httpd-2.0/apr/apr_allocator.inc
  42. 1515 0
      packages/base/httpd/httpd-2.0/apr/apr_buckets.inc
  43. 95 0
      packages/base/httpd/httpd-2.0/apr/apr_dso.inc
  44. 1191 0
      packages/base/httpd/httpd-2.0/apr/apr_errno.inc
  45. 434 0
      packages/base/httpd/httpd-2.0/apr/apr_file_info.inc
  46. 807 0
      packages/base/httpd/httpd-2.0/apr/apr_file_io.inc
  47. 228 0
      packages/base/httpd/httpd-2.0/apr/apr_general.inc
  48. 206 0
      packages/base/httpd/httpd-2.0/apr/apr_hash.inc
  49. 221 0
      packages/base/httpd/httpd-2.0/apr/apr_lib.inc
  50. 884 0
      packages/base/httpd/httpd-2.0/apr/apr_network_io.inc
  51. 259 0
      packages/base/httpd/httpd-2.0/apr/apr_poll.inc
  52. 707 0
      packages/base/httpd/httpd-2.0/apr/apr_pools.inc
  53. 540 0
      packages/base/httpd/httpd-2.0/apr/apr_portable.inc
  54. 90 0
      packages/base/httpd/httpd-2.0/apr/apr_signal.inc
  55. 358 0
      packages/base/httpd/httpd-2.0/apr/apr_strings.inc
  56. 447 0
      packages/base/httpd/httpd-2.0/apr/apr_tables.inc
  57. 845 0
      packages/base/httpd/httpd-2.0/apr/apr_thread_proc.inc
  58. 262 0
      packages/base/httpd/httpd-2.0/apr/apr_time.inc
  59. 197 0
      packages/base/httpd/httpd-2.0/apr/apr_user.inc
  60. 112 0
      packages/base/httpd/httpd-2.0/apr/apr_version.inc
  61. 99 0
      packages/base/httpd/httpd-2.0/apriconv/api_version.inc
  62. 113 0
      packages/base/httpd/httpd-2.0/apriconv/apr_iconv.inc
  63. 59 0
      packages/base/httpd/httpd-2.0/apriconv/apriconv.pas
  64. 158 0
      packages/base/httpd/httpd-2.0/aprutil/apr_md5.inc
  65. 175 0
      packages/base/httpd/httpd-2.0/aprutil/apr_uri.inc
  66. 152 0
      packages/base/httpd/httpd-2.0/aprutil/apr_xlate.inc
  67. 349 0
      packages/base/httpd/httpd-2.0/aprutil/apr_xml.inc
  68. 64 0
      packages/base/httpd/httpd-2.0/aprutil/aprutil.pas
  69. 1160 0
      packages/base/httpd/httpd-2.0/http_config.inc
  70. 157 0
      packages/base/httpd/httpd-2.0/http_connection.inc
  71. 702 0
      packages/base/httpd/httpd-2.0/http_core.inc
  72. 337 0
      packages/base/httpd/httpd-2.0/http_log.inc
  73. 47 0
      packages/base/httpd/httpd-2.0/http_main.inc
  74. 829 0
      packages/base/httpd/httpd-2.0/http_protocol.inc
  75. 460 0
      packages/base/httpd/httpd-2.0/http_request.inc
  76. 83 0
      packages/base/httpd/httpd-2.0/http_vhost.inc
  77. 1758 0
      packages/base/httpd/httpd-2.0/httpd.inc
  78. 170 0
      packages/base/httpd/httpd-2.0/httpd.pas
  79. 85 0
      packages/base/httpd/httpd-2.0/pcreposix.inc
  80. 77 0
      packages/base/httpd/httpd-2.0/util_cfgtree.inc
  81. 523 0
      packages/base/httpd/httpd-2.0/util_filter.inc
  82. 66 0
      packages/base/httpd/httpd-2.0/util_md5.inc
  83. 140 0
      packages/base/httpd/httpd-2.0/util_script.inc
  84. 78 0
      packages/base/httpd/httpd-2.0/util_time.inc
  85. 1865 0
      packages/base/httpd/httpd-2.2/Makefile
  86. 19 0
      packages/base/httpd/httpd-2.2/Makefile.fpc
  87. 255 0
      packages/base/httpd/httpd-2.2/ap_config.inc
  88. 141 0
      packages/base/httpd/httpd-2.2/ap_mmn.inc
  89. 180 0
      packages/base/httpd/httpd-2.2/ap_mpm.inc
  90. 68 0
      packages/base/httpd/httpd-2.2/ap_provider.inc
  91. 138 0
      packages/base/httpd/httpd-2.2/ap_regex.inc
  92. 66 0
      packages/base/httpd/httpd-2.2/ap_release.inc
  93. 245 0
      packages/base/httpd/httpd-2.2/apr/apr.pas
  94. 165 0
      packages/base/httpd/httpd-2.2/apr/apr_allocator.inc
  95. 1483 0
      packages/base/httpd/httpd-2.2/apr/apr_buckets.inc
  96. 95 0
      packages/base/httpd/httpd-2.2/apr/apr_dso.inc
  97. 1205 0
      packages/base/httpd/httpd-2.2/apr/apr_errno.inc
  98. 433 0
      packages/base/httpd/httpd-2.2/apr/apr_file_info.inc
  99. 842 0
      packages/base/httpd/httpd-2.2/apr/apr_file_io.inc
  100. 219 0
      packages/base/httpd/httpd-2.2/apr/apr_general.inc

+ 133 - 0
.gitattributes

@@ -1306,6 +1306,139 @@ packages/base/hash/fpmake.pp svneol=native#text/plain
 packages/base/hash/md5.pp svneol=native#text/plain
 packages/base/hash/md5.ref -text
 packages/base/hash/md5test.pp svneol=native#text/plain
+packages/base/httpd/Makefile svneol=native#text/plain
+packages/base/httpd/Makefile.fpc svneol=native#text/plain
+packages/base/httpd/examples/Makefile svneol=native#text/plain
+packages/base/httpd/examples/Makefile.fpc svneol=native#text/plain
+packages/base/httpd/examples/define.inc svneol=native#text/plain
+packages/base/httpd/examples/minimain.pas svneol=native#text/plain
+packages/base/httpd/examples/mod_example.pp svneol=native#text/plain
+packages/base/httpd/examples/mod_hello.pp svneol=native#text/plain
+packages/base/httpd/examples/mod_spelling.pp svneol=native#text/plain
+packages/base/httpd/examples/testmodule.pp svneol=native#text/plain
+packages/base/httpd/httpd-1.3/Makefile svneol=native#text/plain
+packages/base/httpd/httpd-1.3/Makefile.fpc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/ap.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/ap_alloc.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/ap_config.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/ap_mmn.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/buff.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/hsregex.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/http_config.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/http_core.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/http_log.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/http_main.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/http_protocol.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/http_request.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/http_vhost.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/httpd.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/httpd.pas svneol=native#text/plain
+packages/base/httpd/httpd-1.3/util_uri.inc svneol=native#text/plain
+packages/base/httpd/httpd-1.3/win32_os.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/Makefile svneol=native#text/plain
+packages/base/httpd/httpd-2.0/Makefile.fpc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/ap_config.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/ap_mmn.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/ap_mpm.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/ap_provider.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/ap_release.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr.pas svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_allocator.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_buckets.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_dso.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_errno.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_file_info.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_file_io.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_general.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_hash.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_lib.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_network_io.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_poll.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_pools.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_portable.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_signal.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_strings.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_tables.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_thread_proc.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_time.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_user.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apr/apr_version.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apriconv/api_version.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apriconv/apr_iconv.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/apriconv/apriconv.pas svneol=native#text/plain
+packages/base/httpd/httpd-2.0/aprutil/apr_md5.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/aprutil/apr_uri.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/aprutil/apr_xlate.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/aprutil/apr_xml.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/aprutil/aprutil.pas svneol=native#text/plain
+packages/base/httpd/httpd-2.0/http_config.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/http_connection.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/http_core.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/http_log.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/http_main.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/http_protocol.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/http_request.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/http_vhost.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/httpd.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/httpd.pas svneol=native#text/plain
+packages/base/httpd/httpd-2.0/pcreposix.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/util_cfgtree.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/util_filter.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/util_md5.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/util_script.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.0/util_time.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/Makefile svneol=native#text/plain
+packages/base/httpd/httpd-2.2/Makefile.fpc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/ap_config.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/ap_mmn.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/ap_mpm.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/ap_provider.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/ap_regex.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/ap_release.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr.pas svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_allocator.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_buckets.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_dso.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_errno.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_file_info.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_file_io.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_general.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_hash.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_lib.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_network_io.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_poll.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_pools.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_portable.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_signal.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_strings.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_tables.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_thread_proc.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_time.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_user.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apr/apr_version.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apriconv/api_version.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apriconv/apr_iconv.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/apriconv/apriconv.pas svneol=native#text/plain
+packages/base/httpd/httpd-2.2/aprutil/apr_md5.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/aprutil/apr_uri.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/aprutil/apr_xlate.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/aprutil/apr_xml.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/aprutil/aprutil.pas svneol=native#text/plain
+packages/base/httpd/httpd-2.2/http_config.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/http_connection.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/http_core.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/http_log.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/http_main.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/http_protocol.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/http_request.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/http_vhost.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/httpd.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/httpd.pas svneol=native#text/plain
+packages/base/httpd/httpd-2.2/util_cfgtree.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/util_filter.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/util_md5.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/util_script.inc svneol=native#text/plain
+packages/base/httpd/httpd-2.2/util_time.inc svneol=native#text/plain
 packages/base/ibase/Makefile svneol=native#text/plain
 packages/base/ibase/Makefile.fpc svneol=native#text/plain
 packages/base/ibase/README -text

+ 89 - 22
packages/base/Makefile

@@ -231,28 +231,28 @@ UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
 endif
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
 ifeq ($(FULL_TARGET),i386-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus libc
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd libc
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint graph
 endif
 ifeq ($(FULL_TARGET),i386-win32)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint mysql ibase odbc sqlite postgres oracle graph imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint mysql ibase odbc sqlite postgres oracle graph imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),i386-freebsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync graph mysql ibase postgres oracle odbc sqlite pthreads imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync graph mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),i386-netbsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
@@ -261,13 +261,13 @@ ifeq ($(FULL_TARGET),i386-netware)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),i386-openbsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),i386-darwin)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
@@ -282,13 +282,13 @@ ifeq ($(FULL_TARGET),i386-wince)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  ibase sqlite postgres
 endif
 ifeq ($(FULL_TARGET),m68k-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync graph mysql ibase postgres oracle odbc sqlite pthreads imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync graph mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
@@ -297,16 +297,16 @@ ifeq ($(FULL_TARGET),m68k-atari)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),m68k-openbsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),powerpc-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
@@ -315,31 +315,31 @@ ifeq ($(FULL_TARGET),powerpc-macos)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),powerpc-darwin)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),sparc-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  libasync mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus libc
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd libc
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync graph mysql ibase postgres oracle odbc sqlite pthreads imagemagick
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync graph mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  mysql ibase odbc sqlite postgres oracle
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  mysql ibase odbc sqlite postgres oracle httpd
 endif
 ifeq ($(FULL_TARGET),arm-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
@@ -351,7 +351,7 @@ ifeq ($(FULL_TARGET),arm-gba)
 override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb
 endif
 ifeq ($(FULL_TARGET),powerpc64-linux)
-override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus
+override TARGET_DIRS+=hash paszlib pasjpeg regexpr netdb  gdbint libasync mysql ibase postgres oracle odbc pthreads sqlite graph imagemagick dbus httpd
 endif
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCSUBDIR=packages/base
@@ -1435,6 +1435,7 @@ TARGET_DIRS_SQLITE=1
 TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
+TARGET_DIRS_HTTPD=1
 TARGET_DIRS_LIBC=1
 endif
 ifeq ($(FULL_TARGET),i386-go32v2)
@@ -1461,6 +1462,7 @@ TARGET_DIRS_POSTGRES=1
 TARGET_DIRS_ORACLE=1
 TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),i386-os2)
 TARGET_DIRS_HASH=1
@@ -1486,6 +1488,7 @@ TARGET_DIRS_ODBC=1
 TARGET_DIRS_SQLITE=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),i386-beos)
 TARGET_DIRS_HASH=1
@@ -1508,6 +1511,7 @@ TARGET_DIRS_POSTGRES=1
 TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),i386-solaris)
 TARGET_DIRS_HASH=1
@@ -1524,6 +1528,7 @@ TARGET_DIRS_ODBC=1
 TARGET_DIRS_SQLITE=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),i386-qnx)
 TARGET_DIRS_HASH=1
@@ -1553,6 +1558,7 @@ TARGET_DIRS_POSTGRES=1
 TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),i386-wdosx)
 TARGET_DIRS_HASH=1
@@ -1576,6 +1582,7 @@ TARGET_DIRS_ODBC=1
 TARGET_DIRS_SQLITE=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),i386-emx)
 TARGET_DIRS_HASH=1
@@ -1626,6 +1633,7 @@ TARGET_DIRS_SQLITE=1
 TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),m68k-freebsd)
 TARGET_DIRS_HASH=1
@@ -1644,6 +1652,7 @@ TARGET_DIRS_ODBC=1
 TARGET_DIRS_SQLITE=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),m68k-netbsd)
 TARGET_DIRS_HASH=1
@@ -1659,6 +1668,7 @@ TARGET_DIRS_POSTGRES=1
 TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),m68k-amiga)
 TARGET_DIRS_HASH=1
@@ -1688,6 +1698,7 @@ TARGET_DIRS_POSTGRES=1
 TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),m68k-palmos)
 TARGET_DIRS_HASH=1
@@ -1714,6 +1725,7 @@ TARGET_DIRS_SQLITE=1
 TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),powerpc-netbsd)
 TARGET_DIRS_HASH=1
@@ -1729,6 +1741,7 @@ TARGET_DIRS_POSTGRES=1
 TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),powerpc-amiga)
 TARGET_DIRS_HASH=1
@@ -1759,6 +1772,7 @@ TARGET_DIRS_ODBC=1
 TARGET_DIRS_SQLITE=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),powerpc-morphos)
 TARGET_DIRS_HASH=1
@@ -1785,6 +1799,7 @@ TARGET_DIRS_SQLITE=1
 TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),sparc-netbsd)
 TARGET_DIRS_HASH=1
@@ -1800,6 +1815,7 @@ TARGET_DIRS_POSTGRES=1
 TARGET_DIRS_ORACLE=1
 TARGET_DIRS_ODBC=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),sparc-solaris)
 TARGET_DIRS_HASH=1
@@ -1816,6 +1832,7 @@ TARGET_DIRS_ODBC=1
 TARGET_DIRS_SQLITE=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),x86_64-linux)
 TARGET_DIRS_HASH=1
@@ -1835,6 +1852,7 @@ TARGET_DIRS_SQLITE=1
 TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
+TARGET_DIRS_HTTPD=1
 TARGET_DIRS_LIBC=1
 endif
 ifeq ($(FULL_TARGET),x86_64-freebsd)
@@ -1854,6 +1872,7 @@ TARGET_DIRS_ODBC=1
 TARGET_DIRS_SQLITE=1
 TARGET_DIRS_PTHREADS=1
 TARGET_DIRS_IMAGEMAGICK=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),x86_64-win64)
 TARGET_DIRS_HASH=1
@@ -1867,6 +1886,7 @@ TARGET_DIRS_ODBC=1
 TARGET_DIRS_SQLITE=1
 TARGET_DIRS_POSTGRES=1
 TARGET_DIRS_ORACLE=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),arm-linux)
 TARGET_DIRS_HASH=1
@@ -1886,6 +1906,7 @@ TARGET_DIRS_SQLITE=1
 TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
+TARGET_DIRS_HTTPD=1
 endif
 ifeq ($(FULL_TARGET),arm-palmos)
 TARGET_DIRS_HASH=1
@@ -1929,6 +1950,7 @@ TARGET_DIRS_SQLITE=1
 TARGET_DIRS_GRAPH=1
 TARGET_DIRS_IMAGEMAGICK=1
 TARGET_DIRS_DBUS=1
+TARGET_DIRS_HTTPD=1
 endif
 ifdef TARGET_DIRS_HASH
 hash_all:
@@ -2695,6 +2717,51 @@ dbus:
 	$(MAKE) -C dbus all
 .PHONY: dbus_all dbus_debug dbus_smart dbus_release dbus_units dbus_examples dbus_shared dbus_install dbus_sourceinstall dbus_exampleinstall dbus_distinstall dbus_zipinstall dbus_zipsourceinstall dbus_zipexampleinstall dbus_zipdistinstall dbus_clean dbus_distclean dbus_cleanall dbus_info dbus_makefiles dbus
 endif
+ifdef TARGET_DIRS_HTTPD
+httpd_all:
+	$(MAKE) -C httpd all
+httpd_debug:
+	$(MAKE) -C httpd debug
+httpd_smart:
+	$(MAKE) -C httpd smart
+httpd_release:
+	$(MAKE) -C httpd release
+httpd_units:
+	$(MAKE) -C httpd units
+httpd_examples:
+	$(MAKE) -C httpd examples
+httpd_shared:
+	$(MAKE) -C httpd shared
+httpd_install:
+	$(MAKE) -C httpd install
+httpd_sourceinstall:
+	$(MAKE) -C httpd sourceinstall
+httpd_exampleinstall:
+	$(MAKE) -C httpd exampleinstall
+httpd_distinstall:
+	$(MAKE) -C httpd distinstall
+httpd_zipinstall:
+	$(MAKE) -C httpd zipinstall
+httpd_zipsourceinstall:
+	$(MAKE) -C httpd zipsourceinstall
+httpd_zipexampleinstall:
+	$(MAKE) -C httpd zipexampleinstall
+httpd_zipdistinstall:
+	$(MAKE) -C httpd zipdistinstall
+httpd_clean:
+	$(MAKE) -C httpd clean
+httpd_distclean:
+	$(MAKE) -C httpd distclean
+httpd_cleanall:
+	$(MAKE) -C httpd cleanall
+httpd_info:
+	$(MAKE) -C httpd info
+httpd_makefiles:
+	$(MAKE) -C httpd makefiles
+httpd:
+	$(MAKE) -C httpd all
+.PHONY: httpd_all httpd_debug httpd_smart httpd_release httpd_units httpd_examples httpd_shared httpd_install httpd_sourceinstall httpd_exampleinstall httpd_distinstall httpd_zipinstall httpd_zipsourceinstall httpd_zipexampleinstall httpd_zipdistinstall httpd_clean httpd_distclean httpd_cleanall httpd_info httpd_makefiles httpd
+endif
 ifdef TARGET_DIRS_LIBC
 libc_all:
 	$(MAKE) -C libc all

+ 9 - 9
packages/base/Makefile.fpc

@@ -7,21 +7,21 @@ dirs=hash paszlib pasjpeg regexpr netdb
 dirs_i386_linux=libc
 dirs_x86_64_linux=libc
 dirs_linux=gdbint libasync mysql ibase postgres oracle odbc \
-            pthreads sqlite graph imagemagick dbus
-dirs_win32=gdbint mysql ibase odbc sqlite postgres oracle graph imagemagick 
-dirs_win64=mysql ibase odbc sqlite postgres oracle
+            pthreads sqlite graph imagemagick dbus httpd
+dirs_win32=gdbint mysql ibase odbc sqlite postgres oracle graph imagemagick httpd
+dirs_win64=mysql ibase odbc sqlite postgres oracle httpd
 dirs_wince=ibase sqlite postgres
-dirs_go32v2=gdbint graph
+dirs_go32v2=gdbint graph 
 dirs_netbsd=gdbint libasync \
-            mysql ibase postgres oracle odbc imagemagick
+            mysql ibase postgres oracle odbc imagemagick httpd
 dirs_openbsd=gdbint libasync \
-            mysql ibase postgres oracle odbc imagemagick
+            mysql ibase postgres oracle odbc imagemagick httpd
 dirs_freebsd=gdbint libasync graph \
-             mysql ibase postgres oracle odbc sqlite pthreads imagemagick
+             mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 dirs_darwin=libasync \
-             mysql ibase postgres oracle odbc sqlite pthreads imagemagick
+             mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 dirs_solaris=libasync \
-             mysql ibase postgres oracle odbc sqlite pthreads imagemagick
+             mysql ibase postgres oracle odbc sqlite pthreads imagemagick httpd
 
 [install]
 fpcpackage=y

+ 2006 - 0
packages/base/httpd/Makefile

@@ -0,0 +1,2006 @@
+#
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/08/20]
+#
+default: all
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd x86_64-win64 arm-linux arm-palmos arm-wince arm-gba powerpc64-linux
+BSDs = freebsd netbsd openbsd darwin
+UNIXs = linux $(BSDs) solaris qnx
+LIMIT83fs = go32v2 os2 emx watcom
+FORCE:
+.PHONY: FORCE
+override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
+ifneq ($(findstring darwin,$(OSTYPE)),)
+inUnix=1 #darwin
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+endif
+SEARCHPATH+=$(patsubst %/,%,$(subst \,/,$(dir $(MAKE))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygdrive,$(PATH)),)
+inCygWin=1
+endif
+endif
+ifdef inUnix
+SRCBATCHEXT=.sh
+else
+ifdef inOS2
+SRCBATCHEXT=.cmd
+else
+SRCBATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+ifdef inCygWin
+PATHSEP=/
+endif
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+ifdef inOS2
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=echo
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+endif
+override DEFAULT_FPCDIR=../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+else
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+FOUNDFPC:=$(strip $(wildcard $(FPC)))
+ifeq ($(FOUNDFPC),)
+FOUNDFPC=$(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))
+ifeq ($(FOUNDFPC),)
+$(error Compiler $(FPC) not found)
+endif
+endif
+ifndef FPC_COMPILERINFO
+FPC_COMPILERINFO:=$(shell $(FPC) -iVSPTPSOTO)
+endif
+ifndef FPC_VERSION
+FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO))
+endif
+export FPC FPC_VERSION FPC_COMPILERINFO
+unexport CHECKDEPEND ALLDEPENDENCIES
+ifndef CPU_TARGET
+ifdef CPU_TARGET_DEFAULT
+CPU_TARGET=$(CPU_TARGET_DEFAULT)
+endif
+endif
+ifndef OS_TARGET
+ifdef OS_TARGET_DEFAULT
+OS_TARGET=$(OS_TARGET_DEFAULT)
+endif
+endif
+ifneq ($(words $(FPC_COMPILERINFO)),5)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSO)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTO)
+endif
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 2,$(FPC_COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 3,$(FPC_COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 4,$(FPC_COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+TARGETSUFFIX=$(OS_TARGET)
+SOURCESUFFIX=$(OS_SOURCE)
+else
+TARGETSUFFIX=$(FULL_TARGET)
+SOURCESUFFIX=$(FULL_SOURCE)
+endif
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first)
+endif
+endif
+ifneq ($(findstring $(OS_TARGET),$(BSDs)),)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),linux)
+linuxHier=1
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(BASEDIR)
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+endif
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
+endif
+ifndef BINUTILSPREFIX
+ifndef CROSSBINDIR
+ifdef CROSSCOMPILE
+BINUTILSPREFIX=$(CPU_TARGET)-$(OS_TARGET)-
+endif
+endif
+endif
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX))
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+ifeq ($(FULL_TARGET),i386-linux)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override TARGET_DIRS+=httpd-2.0 httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-linux)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override TARGET_EXAMPLEDIRS+=examples
+endif
+override INSTALL_FPCPACKAGE=y
+override INSTALL_FPCSUBDIR=packages/base/httpd
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifneq ($(findstring $(OS_TARGET),$(UNIXs)),)
+UNIXHier=1
+endif
+else
+ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),)
+UNIXHier=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXHier
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifdef INSTALL_FPCSUBDIR
+export INSTALL_FPCSUBDIR
+endif
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef COMPILER_UNITTARGETDIR
+ifdef PACKAGEDIR_MAIN
+COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX)
+else
+COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX)
+endif
+endif
+ifndef COMPILER_TARGETDIR
+COMPILER_TARGETDIR=.
+endif
+ifndef INSTALL_BASEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXHier
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+ifdef CROSSCOMPILE
+ifdef CROSSINSTALL
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(SOURCESUFFIX)
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXHier
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXHier
+ifdef BSDhier
+SRCPREFIXDIR=share/src
+else
+ifdef linuxHier
+SRCPREFIXDIR=share/src
+else
+SRCPREFIXDIR=src
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXHier
+ifdef BSDhier
+DOCPREFIXDIR=share/doc
+else
+ifdef linuxHier
+DOCPREFIXDIR=share/doc
+else
+DOCPREFIXDIR=doc
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifndef INSTALL_SHAREDDIR
+INSTALL_SHAREDDIR=$(INSTALL_PREFIX)/lib
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(SOURCESUFFIX))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(TARGETSUFFIX)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+BATCHEXT=.bat
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+SHAREDLIBPREFIX=libfp
+STATICLIBPREFIX=libp
+IMPORTLIBPREFIX=libimp
+RSTEXT=.rst
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),go32v1)
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+OEXT=.obj
+ASMEXT=.asm
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),emx)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=emx
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),morphos)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=mos
+endif
+ifeq ($(OS_TARGET),atari)
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+ifeq ($(OS_TARGET),darwin)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=dwn
+endif
+ifeq ($(OS_TARGET),gba)
+EXEEXT=.gba
+SHAREDLIBEXT=.so
+SHORTSUFFIX=gba
+endif
+else
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.sl2
+STATICLIBPREFIX=
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+FPCMADE=fpcmade.$(SHORTSUFFIX)
+ZIPSUFFIX=$(SHORTSUFFIX)
+ZIPCROSSPREFIX=
+ZIPSOURCESUFFIX=src
+ZIPEXAMPLESUFFIX=exm
+else
+FPCMADE=fpcmade.$(TARGETSUFFIX)
+ZIPSOURCESUFFIX=.source
+ZIPEXAMPLESUFFIX=.examples
+ifdef CROSSCOMPILE
+ZIPSUFFIX=.$(SOURCESUFFIX)
+ZIPCROSSPREFIX=$(TARGETSUFFIX)-
+else
+ZIPSUFFIX=.$(TARGETSUFFIX)
+ZIPCROSSPREFIX=
+endif
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO= __missing_command_ECHO
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE= __missing_command_DATE
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL= __missing_command_GINSTALL
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG= __missing_command_CPPROG
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG= __missing_command_RMPROG
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG= __missing_command_MVPROG
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef MKDIRPROG
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG= __missing_command_MKDIRPROG
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+endif
+export MKDIRPROG
+ifndef ECHOREDIR
+ifndef inUnix
+ECHOREDIR=echo
+else
+ECHOREDIR=$(ECHO)
+endif
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -Rfp
+endif
+ifndef MKDIRTREE
+MKDIRTREE:=$(MKDIRPROG) -p
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE= __missing_command_PPUMOVE
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE= __missing_command_FPCMAKE
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG= __missing_command_ZIPPROG
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /gtar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG= __missing_command_TARPROG
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=$(BINUTILSPREFIX)as
+LDNAME=$(BINUTILSPREFIX)ld
+ARNAME=$(BINUTILSPREFIX)ar
+RCNAME=$(BINUTILSPREFIX)rc
+ifneq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),win32)
+ifeq ($(CROSSBINDIR),)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+endif
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(SRCBATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vj
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifneq ($(CPU_TARGET),$(CPU_SOURCE))
+override FPCOPT+=-P$(CPU_TARGET)
+endif
+ifeq ($(OS_SOURCE),openbsd)
+override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
+endif
+ifndef CROSSBOOTSTRAP
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-XP$(BINUTILSPREFIX) -Xc
+endif
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-Xr$(RLINKPATH)
+endif
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifneq ($(findstring 2.0.,$(FPC_VERSION)),)
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+endif
+ifeq ($(CPU_TARGET),powerpc)
+FPCCPUOPT:=-O1r
+endif
+else
+FPCCPUOPT:=-O1r
+endif
+override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+override FPCOPT+=-O2
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef CREATESHARED
+override FPCOPT+=-Cg
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-Aas
+endif
+endif
+ifdef LINKSHARED
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override AFULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+override AFULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(AFULL_TARGET),$(AFULL_SOURCE))
+override ACROSSCOMPILE=1
+endif
+ifdef ACROSSCOMPILE
+override FPCOPT+=$(CROSSOPT)
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_examples
+ifneq ($(TARGET_EXAMPLES),)
+HASEXAMPLES=1
+override EXAMPLESOURCEFILES:=$(wildcard $(addsuffix .pp,$(TARGET_EXAMPLES)) $(addsuffix .pas,$(TARGET_EXAMPLES)) $(addsuffix .lpr,$(TARGET_EXAMPLES)) $(addsuffix .dpr,$(TARGET_EXAMPLES)))
+override EXAMPLEFILES:=$(addsuffix $(EXEEXT),$(TARGET_EXAMPLES))
+override EXAMPLEOFILES:=$(addsuffix $(OEXT),$(TARGET_EXAMPLES)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES))) $(addprefix $(IMPORTLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_EXAMPLES)))
+override CLEANEXEFILES+=$(EXAMPLEFILES) $(EXAMPLEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+ifeq ($(OS_TARGET),emx)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_EXAMPLES))
+endif
+endif
+ifneq ($(TARGET_EXAMPLEDIRS),)
+HASEXAMPLES=1
+endif
+fpc_examples: all $(EXAMPLEFILES) $(addsuffix _all,$(TARGET_EXAMPLEDIRS))
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+ifdef DEBUGSYMEXT
+override CLEANPPULINKFILES+=$(subst $(PPUEXT),$(DEBUGSYMEXT),$(CLEANPPUFILES))
+endif
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *$(ASMEXT) *_ppas$(BATCHEXT)
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef COMPILER_UNITTARGETDIR
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+endif
+	-$(DELTREE) units
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+ifneq ($(PPUEXT),.ppu)
+	-$(DEL) *.o *.ppu *.a
+endif
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) fpcmade.* Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *_ppas$(BATCHEXT)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+ifdef DEBUGSYMEXT
+	-$(DEL) *$(DEBUGSYMEXT)
+endif
+fpc_distclean: cleanall
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Source.. $(FULL_SOURCE)
+	@$(ECHO)  Full Target.. $(FULL_TARGET)
+	@$(ECHO)  SourceSuffix. $(SOURCESUFFIX)
+	@$(ECHO)  TargetSuffix. $(TARGETSUFFIX)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Shell..... $(SHELL)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipName.............. $(ZIPNAME)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipCrossPrefix....... $(ZIPCROSSPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  FullZipName.......... $(FULLZIPNAME)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+ifeq ($(FULL_TARGET),i386-linux)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+TARGET_DIRS_HTTPD-2.0=1
+TARGET_DIRS_HTTPD-2.2=1
+endif
+ifdef TARGET_DIRS_HTTPD-2.0
+httpd-2.0_all:
+	$(MAKE) -C httpd-2.0 all
+httpd-2.0_debug:
+	$(MAKE) -C httpd-2.0 debug
+httpd-2.0_smart:
+	$(MAKE) -C httpd-2.0 smart
+httpd-2.0_release:
+	$(MAKE) -C httpd-2.0 release
+httpd-2.0_units:
+	$(MAKE) -C httpd-2.0 units
+httpd-2.0_examples:
+	$(MAKE) -C httpd-2.0 examples
+httpd-2.0_shared:
+	$(MAKE) -C httpd-2.0 shared
+httpd-2.0_install:
+	$(MAKE) -C httpd-2.0 install
+httpd-2.0_sourceinstall:
+	$(MAKE) -C httpd-2.0 sourceinstall
+httpd-2.0_exampleinstall:
+	$(MAKE) -C httpd-2.0 exampleinstall
+httpd-2.0_distinstall:
+	$(MAKE) -C httpd-2.0 distinstall
+httpd-2.0_zipinstall:
+	$(MAKE) -C httpd-2.0 zipinstall
+httpd-2.0_zipsourceinstall:
+	$(MAKE) -C httpd-2.0 zipsourceinstall
+httpd-2.0_zipexampleinstall:
+	$(MAKE) -C httpd-2.0 zipexampleinstall
+httpd-2.0_zipdistinstall:
+	$(MAKE) -C httpd-2.0 zipdistinstall
+httpd-2.0_clean:
+	$(MAKE) -C httpd-2.0 clean
+httpd-2.0_distclean:
+	$(MAKE) -C httpd-2.0 distclean
+httpd-2.0_cleanall:
+	$(MAKE) -C httpd-2.0 cleanall
+httpd-2.0_info:
+	$(MAKE) -C httpd-2.0 info
+httpd-2.0_makefiles:
+	$(MAKE) -C httpd-2.0 makefiles
+httpd-2.0:
+	$(MAKE) -C httpd-2.0 all
+.PHONY: httpd-2.0_all httpd-2.0_debug httpd-2.0_smart httpd-2.0_release httpd-2.0_units httpd-2.0_examples httpd-2.0_shared httpd-2.0_install httpd-2.0_sourceinstall httpd-2.0_exampleinstall httpd-2.0_distinstall httpd-2.0_zipinstall httpd-2.0_zipsourceinstall httpd-2.0_zipexampleinstall httpd-2.0_zipdistinstall httpd-2.0_clean httpd-2.0_distclean httpd-2.0_cleanall httpd-2.0_info httpd-2.0_makefiles httpd-2.0
+endif
+ifdef TARGET_DIRS_HTTPD-2.2
+httpd-2.2_all:
+	$(MAKE) -C httpd-2.2 all
+httpd-2.2_debug:
+	$(MAKE) -C httpd-2.2 debug
+httpd-2.2_smart:
+	$(MAKE) -C httpd-2.2 smart
+httpd-2.2_release:
+	$(MAKE) -C httpd-2.2 release
+httpd-2.2_units:
+	$(MAKE) -C httpd-2.2 units
+httpd-2.2_examples:
+	$(MAKE) -C httpd-2.2 examples
+httpd-2.2_shared:
+	$(MAKE) -C httpd-2.2 shared
+httpd-2.2_install:
+	$(MAKE) -C httpd-2.2 install
+httpd-2.2_sourceinstall:
+	$(MAKE) -C httpd-2.2 sourceinstall
+httpd-2.2_exampleinstall:
+	$(MAKE) -C httpd-2.2 exampleinstall
+httpd-2.2_distinstall:
+	$(MAKE) -C httpd-2.2 distinstall
+httpd-2.2_zipinstall:
+	$(MAKE) -C httpd-2.2 zipinstall
+httpd-2.2_zipsourceinstall:
+	$(MAKE) -C httpd-2.2 zipsourceinstall
+httpd-2.2_zipexampleinstall:
+	$(MAKE) -C httpd-2.2 zipexampleinstall
+httpd-2.2_zipdistinstall:
+	$(MAKE) -C httpd-2.2 zipdistinstall
+httpd-2.2_clean:
+	$(MAKE) -C httpd-2.2 clean
+httpd-2.2_distclean:
+	$(MAKE) -C httpd-2.2 distclean
+httpd-2.2_cleanall:
+	$(MAKE) -C httpd-2.2 cleanall
+httpd-2.2_info:
+	$(MAKE) -C httpd-2.2 info
+httpd-2.2_makefiles:
+	$(MAKE) -C httpd-2.2 makefiles
+httpd-2.2:
+	$(MAKE) -C httpd-2.2 all
+.PHONY: httpd-2.2_all httpd-2.2_debug httpd-2.2_smart httpd-2.2_release httpd-2.2_units httpd-2.2_examples httpd-2.2_shared httpd-2.2_install httpd-2.2_sourceinstall httpd-2.2_exampleinstall httpd-2.2_distinstall httpd-2.2_zipinstall httpd-2.2_zipsourceinstall httpd-2.2_zipexampleinstall httpd-2.2_zipdistinstall httpd-2.2_clean httpd-2.2_distclean httpd-2.2_cleanall httpd-2.2_info httpd-2.2_makefiles httpd-2.2
+endif
+ifeq ($(FULL_TARGET),i386-linux)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+TARGET_EXAMPLEDIRS_EXAMPLES=1
+endif
+ifdef TARGET_EXAMPLEDIRS_EXAMPLES
+examples_all:
+	$(MAKE) -C examples all
+examples_debug:
+	$(MAKE) -C examples debug
+examples_smart:
+	$(MAKE) -C examples smart
+examples_release:
+	$(MAKE) -C examples release
+examples_units:
+	$(MAKE) -C examples units
+examples_examples:
+	$(MAKE) -C examples examples
+examples_shared:
+	$(MAKE) -C examples shared
+examples_install:
+	$(MAKE) -C examples install
+examples_sourceinstall:
+	$(MAKE) -C examples sourceinstall
+examples_exampleinstall:
+	$(MAKE) -C examples exampleinstall
+examples_distinstall:
+	$(MAKE) -C examples distinstall
+examples_zipinstall:
+	$(MAKE) -C examples zipinstall
+examples_zipsourceinstall:
+	$(MAKE) -C examples zipsourceinstall
+examples_zipexampleinstall:
+	$(MAKE) -C examples zipexampleinstall
+examples_zipdistinstall:
+	$(MAKE) -C examples zipdistinstall
+examples_clean:
+	$(MAKE) -C examples clean
+examples_distclean:
+	$(MAKE) -C examples distclean
+examples_cleanall:
+	$(MAKE) -C examples cleanall
+examples_info:
+	$(MAKE) -C examples info
+examples_makefiles:
+	$(MAKE) -C examples makefiles
+examples:
+	$(MAKE) -C examples all
+.PHONY: examples_all examples_debug examples_smart examples_release examples_units examples_examples examples_shared examples_install examples_sourceinstall examples_exampleinstall examples_distinstall examples_zipinstall examples_zipsourceinstall examples_zipexampleinstall examples_zipdistinstall examples_clean examples_distclean examples_cleanall examples_info examples_makefiles examples
+endif
+all: $(addsuffix _all,$(TARGET_DIRS))
+debug: $(addsuffix _debug,$(TARGET_DIRS))
+smart: $(addsuffix _smart,$(TARGET_DIRS))
+release: $(addsuffix _release,$(TARGET_DIRS))
+units: $(addsuffix _units,$(TARGET_DIRS))
+examples: fpc_examples $(addsuffix _examples,$(TARGET_DIRS))
+shared: $(addsuffix _shared,$(TARGET_DIRS))
+install: $(addsuffix _install,$(TARGET_DIRS))
+sourceinstall: $(addsuffix _sourceinstall,$(TARGET_DIRS))
+exampleinstall: $(addsuffix _exampleinstall,$(TARGET_DIRS))
+distinstall: $(addsuffix _distinstall,$(TARGET_DIRS))
+zipinstall: $(addsuffix _zipinstall,$(TARGET_DIRS))
+zipsourceinstall: $(addsuffix _zipsourceinstall,$(TARGET_DIRS))
+zipexampleinstall: $(addsuffix _zipexampleinstall,$(TARGET_DIRS))
+zipdistinstall: $(addsuffix _zipdistinstall,$(TARGET_DIRS))
+clean: $(addsuffix _clean,$(TARGET_DIRS)) $(addsuffix _clean,$(TARGET_EXAMPLEDIRS))
+distclean: $(addsuffix _distclean,$(TARGET_DIRS))
+cleanall: $(addsuffix _cleanall,$(TARGET_DIRS))
+info: fpc_info
+makefiles: fpc_makefiles $(addsuffix _makefiles,$(TARGET_DIRS))
+.PHONY: all debug smart release units examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 15 - 0
packages/base/httpd/Makefile.fpc

@@ -0,0 +1,15 @@
+#
+#   Makefile.fpc for Free Pascal Packages
+#
+
+[target]
+# httpd-1.3 removed till it compiles
+dirs=httpd-2.0 httpd-2.2
+exampledirs=examples
+
+[install]
+fpcpackage=y
+fpcsubdir=packages/base/httpd
+
+[default]
+fpcdir=../../..

+ 1988 - 0
packages/base/httpd/examples/Makefile

@@ -0,0 +1,1988 @@
+#
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/08/20]
+#
+default: all
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd x86_64-win64 arm-linux arm-palmos arm-wince arm-gba powerpc64-linux
+BSDs = freebsd netbsd openbsd darwin
+UNIXs = linux $(BSDs) solaris qnx
+LIMIT83fs = go32v2 os2 emx watcom
+FORCE:
+.PHONY: FORCE
+override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
+ifneq ($(findstring darwin,$(OSTYPE)),)
+inUnix=1 #darwin
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+endif
+SEARCHPATH+=$(patsubst %/,%,$(subst \,/,$(dir $(MAKE))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygdrive,$(PATH)),)
+inCygWin=1
+endif
+endif
+ifdef inUnix
+SRCBATCHEXT=.sh
+else
+ifdef inOS2
+SRCBATCHEXT=.cmd
+else
+SRCBATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+ifdef inCygWin
+PATHSEP=/
+endif
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+ifdef inOS2
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=echo
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+endif
+override DEFAULT_FPCDIR=../../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+else
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+FOUNDFPC:=$(strip $(wildcard $(FPC)))
+ifeq ($(FOUNDFPC),)
+FOUNDFPC=$(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))
+ifeq ($(FOUNDFPC),)
+$(error Compiler $(FPC) not found)
+endif
+endif
+ifndef FPC_COMPILERINFO
+FPC_COMPILERINFO:=$(shell $(FPC) -iVSPTPSOTO)
+endif
+ifndef FPC_VERSION
+FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO))
+endif
+export FPC FPC_VERSION FPC_COMPILERINFO
+unexport CHECKDEPEND ALLDEPENDENCIES
+ifndef CPU_TARGET
+ifdef CPU_TARGET_DEFAULT
+CPU_TARGET=$(CPU_TARGET_DEFAULT)
+endif
+endif
+ifndef OS_TARGET
+ifdef OS_TARGET_DEFAULT
+OS_TARGET=$(OS_TARGET_DEFAULT)
+endif
+endif
+ifneq ($(words $(FPC_COMPILERINFO)),5)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSO)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTO)
+endif
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 2,$(FPC_COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 3,$(FPC_COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 4,$(FPC_COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+TARGETSUFFIX=$(OS_TARGET)
+SOURCESUFFIX=$(OS_SOURCE)
+else
+TARGETSUFFIX=$(FULL_TARGET)
+SOURCESUFFIX=$(FULL_SOURCE)
+endif
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first)
+endif
+endif
+ifneq ($(findstring $(OS_TARGET),$(BSDs)),)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),linux)
+linuxHier=1
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(BASEDIR)
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+endif
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
+endif
+ifndef BINUTILSPREFIX
+ifndef CROSSBINDIR
+ifdef CROSSCOMPILE
+BINUTILSPREFIX=$(CPU_TARGET)-$(OS_TARGET)-
+endif
+endif
+endif
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX))
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+ifeq ($(FULL_TARGET),i386-linux)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override TARGET_PROGRAMS+=mod_example  mod_hello  mod_spelling  testmodule
+endif
+ifeq ($(FULL_TARGET),i386-linux)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override TARGET_UNITS+=minimain
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override TARGET_UNITS+=minimain
+endif
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifneq ($(findstring $(OS_TARGET),$(UNIXs)),)
+UNIXHier=1
+endif
+else
+ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),)
+UNIXHier=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXHier
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifdef INSTALL_FPCSUBDIR
+export INSTALL_FPCSUBDIR
+endif
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef COMPILER_UNITTARGETDIR
+ifdef PACKAGEDIR_MAIN
+COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX)
+else
+COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX)
+endif
+endif
+ifndef COMPILER_TARGETDIR
+COMPILER_TARGETDIR=.
+endif
+ifndef INSTALL_BASEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXHier
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+ifdef CROSSCOMPILE
+ifdef CROSSINSTALL
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(SOURCESUFFIX)
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXHier
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXHier
+ifdef BSDhier
+SRCPREFIXDIR=share/src
+else
+ifdef linuxHier
+SRCPREFIXDIR=share/src
+else
+SRCPREFIXDIR=src
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXHier
+ifdef BSDhier
+DOCPREFIXDIR=share/doc
+else
+ifdef linuxHier
+DOCPREFIXDIR=share/doc
+else
+DOCPREFIXDIR=doc
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifndef INSTALL_SHAREDDIR
+INSTALL_SHAREDDIR=$(INSTALL_PREFIX)/lib
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(SOURCESUFFIX))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(TARGETSUFFIX)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+ifeq ($(OS_SOURCE),linux)
+ifndef GCCLIBDIR
+ifeq ($(CPU_TARGET),i386)
+ifneq ($(findstring x86_64,$(shell uname -a)),)
+ifeq ($(BINUTILSPREFIX),)
+GCCLIBDIR:=$(shell dirname `gcc -m32 -print-libgcc-file-name`)
+endif
+endif
+endif
+ifeq ($(CPU_TARGET),powerpc64)
+ifeq ($(BINUTILSPREFIX),)
+GCCLIBDIR:=$(shell dirname `gcc -m64 -print-libgcc-file-name`)
+endif
+endif
+endif
+ifndef GCCLIBDIR
+CROSSGCC=$(strip $(wildcard $(addsuffix /$(BINUTILSPREFIX)gcc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(CROSSGCC),)
+GCCLIBDIR:=$(shell dirname `$(CROSSGCC) -print-libgcc-file-name`)
+endif
+endif
+ifndef OTHERLIBDIR
+OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
+endif
+endif
+ifdef inUnix
+ifeq ($(OS_SOURCE),netbsd)
+OTHERLIBDIR+=/usr/pkg/lib
+endif
+export GCCLIBDIR OTHERLIB
+endif
+BATCHEXT=.bat
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+SHAREDLIBPREFIX=libfp
+STATICLIBPREFIX=libp
+IMPORTLIBPREFIX=libimp
+RSTEXT=.rst
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),go32v1)
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+OEXT=.obj
+ASMEXT=.asm
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),emx)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=emx
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),morphos)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=mos
+endif
+ifeq ($(OS_TARGET),atari)
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+ifeq ($(OS_TARGET),darwin)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=dwn
+endif
+ifeq ($(OS_TARGET),gba)
+EXEEXT=.gba
+SHAREDLIBEXT=.so
+SHORTSUFFIX=gba
+endif
+else
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.sl2
+STATICLIBPREFIX=
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+FPCMADE=fpcmade.$(SHORTSUFFIX)
+ZIPSUFFIX=$(SHORTSUFFIX)
+ZIPCROSSPREFIX=
+ZIPSOURCESUFFIX=src
+ZIPEXAMPLESUFFIX=exm
+else
+FPCMADE=fpcmade.$(TARGETSUFFIX)
+ZIPSOURCESUFFIX=.source
+ZIPEXAMPLESUFFIX=.examples
+ifdef CROSSCOMPILE
+ZIPSUFFIX=.$(SOURCESUFFIX)
+ZIPCROSSPREFIX=$(TARGETSUFFIX)-
+else
+ZIPSUFFIX=.$(TARGETSUFFIX)
+ZIPCROSSPREFIX=
+endif
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO= __missing_command_ECHO
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE= __missing_command_DATE
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL= __missing_command_GINSTALL
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG= __missing_command_CPPROG
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG= __missing_command_RMPROG
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG= __missing_command_MVPROG
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef MKDIRPROG
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG= __missing_command_MKDIRPROG
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+endif
+export MKDIRPROG
+ifndef ECHOREDIR
+ifndef inUnix
+ECHOREDIR=echo
+else
+ECHOREDIR=$(ECHO)
+endif
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -Rfp
+endif
+ifndef MKDIRTREE
+MKDIRTREE:=$(MKDIRPROG) -p
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE= __missing_command_PPUMOVE
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE= __missing_command_FPCMAKE
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG= __missing_command_ZIPPROG
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /gtar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG= __missing_command_TARPROG
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=$(BINUTILSPREFIX)as
+LDNAME=$(BINUTILSPREFIX)ld
+ARNAME=$(BINUTILSPREFIX)ar
+RCNAME=$(BINUTILSPREFIX)rc
+ifneq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),win32)
+ifeq ($(CROSSBINDIR),)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+endif
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(SRCBATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vj
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl httpd/httpd-2.0
+ifeq ($(FULL_TARGET),i386-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+REQUIRE_PACKAGES_RTL=1
+REQUIRE_PACKAGES_HTTPD/HTTPD-2.0=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_RTL)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_RTL) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifdef REQUIRE_PACKAGES_HTTPD/HTTPD-2.0
+PACKAGEDIR_HTTPD/HTTPD-2.0:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /httpd/httpd-2.0/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_HTTPD/HTTPD-2.0),)
+ifneq ($(wildcard $(PACKAGEDIR_HTTPD/HTTPD-2.0)/units/$(TARGETSUFFIX)),)
+UNITDIR_HTTPD/HTTPD-2.0=$(PACKAGEDIR_HTTPD/HTTPD-2.0)/units/$(TARGETSUFFIX)
+else
+UNITDIR_HTTPD/HTTPD-2.0=$(PACKAGEDIR_HTTPD/HTTPD-2.0)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_HTTPD/HTTPD-2.0)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_HTTPD/HTTPD-2.0) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_HTTPD/HTTPD-2.0)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_HTTPD/HTTPD-2.0=
+UNITDIR_HTTPD/HTTPD-2.0:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /httpd/httpd-2.0/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_HTTPD/HTTPD-2.0),)
+UNITDIR_HTTPD/HTTPD-2.0:=$(firstword $(UNITDIR_HTTPD/HTTPD-2.0))
+else
+UNITDIR_HTTPD/HTTPD-2.0=
+endif
+endif
+ifdef UNITDIR_HTTPD/HTTPD-2.0
+override COMPILER_UNITDIR+=$(UNITDIR_HTTPD/HTTPD-2.0)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifneq ($(CPU_TARGET),$(CPU_SOURCE))
+override FPCOPT+=-P$(CPU_TARGET)
+endif
+ifeq ($(OS_SOURCE),openbsd)
+override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
+endif
+ifndef CROSSBOOTSTRAP
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-XP$(BINUTILSPREFIX) -Xc
+endif
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-Xr$(RLINKPATH)
+endif
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifneq ($(findstring 2.0.,$(FPC_VERSION)),)
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+endif
+ifeq ($(CPU_TARGET),powerpc)
+FPCCPUOPT:=-O1r
+endif
+else
+FPCCPUOPT:=-O1r
+endif
+override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+override FPCOPT+=-O2
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef CREATESHARED
+override FPCOPT+=-Cg
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-Aas
+endif
+endif
+ifdef LINKSHARED
+endif
+ifdef GCCLIBDIR
+override FPCOPT+=-Fl$(GCCLIBDIR)
+endif
+ifdef OTHERLIBDIR
+override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override AFULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+override AFULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(AFULL_TARGET),$(AFULL_SOURCE))
+override ACROSSCOMPILE=1
+endif
+ifdef ACROSSCOMPILE
+override FPCOPT+=$(CROSSOPT)
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifneq ($(TARGET_UNITS),)
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(COMPILER_UNITTARGETDIR) $(UNITPPUFILES)
+.PHONY: fpc_exes
+ifndef CROSSINSTALL
+ifneq ($(TARGET_PROGRAMS),)
+override EXEFILES=$(addsuffix $(EXEEXT),$(TARGET_PROGRAMS))
+override EXEOFILES:=$(addsuffix $(OEXT),$(TARGET_PROGRAMS)) $(addprefix $(STATICLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_PROGRAMS))) $(addprefix $(IMPORTLIBPREFIX),$(addsuffix $(STATICLIBEXT),$(TARGET_PROGRAMS)))
+override ALLTARGET+=fpc_exes
+override INSTALLEXEFILES+=$(EXEFILES)
+override CLEANEXEFILES+=$(EXEFILES) $(EXEOFILES)
+ifeq ($(OS_TARGET),os2)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_PROGRAMS))
+endif
+ifeq ($(OS_TARGET),emx)
+override CLEANEXEFILES+=$(addsuffix $(AOUTEXT),$(TARGET_PROGRAMS))
+endif
+endif
+endif
+fpc_exes: $(COMPILER_TARGETDIR) $(COMPILER_UNITTARGETDIR) $(EXEFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release fpc_shared
+$(FPCMADE): $(ALLDEPENDENCIES) $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .lpr .dpr .pp .rc .res
+$(COMPILER_UNITTARGETDIR):
+	$(MKDIRTREE) $(COMPILER_UNITTARGETDIR)
+$(COMPILER_TARGETDIR):
+	$(MKDIRTREE) $(COMPILER_TARGETDIR)
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.lpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.dpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.lpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.dpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(OEXT) $(COMPILER_UNITTARGETDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_shared
+override INSTALLTARGET+=fpc_shared_install
+ifndef SHARED_LIBVERSION
+SHARED_LIBVERSION=$(FPC_VERSION)
+endif
+ifndef SHARED_LIBNAME
+SHARED_LIBNAME=$(PACKAGE_NAME)
+endif
+ifndef SHARED_FULLNAME
+SHARED_FULLNAME=$(SHAREDLIBPREFIX)$(SHARED_LIBNAME)-$(SHARED_LIBVERSION)$(SHAREDLIBEXT)
+endif
+ifndef SHARED_LIBUNITS
+SHARED_LIBUNITS:=$(TARGET_UNITS) $(TARGET_IMPLICITUNITS)
+override SHARED_LIBUNITS:=$(filter-out $(INSTALL_BUILDUNIT),$(SHARED_LIBUNITS))
+endif
+fpc_shared:
+ifdef HASSHAREDLIB
+	$(MAKE) all CREATESHARED=1 LINKSHARED=1 CREATESMART=1
+ifneq ($(SHARED_BUILD),n)
+	$(PPUMOVE) -q $(SHARED_LIBUNITS) -i$(COMPILER_UNITTARGETDIR) -o$(SHARED_FULLNAME) -d$(COMPILER_UNITTARGETDIR)
+endif
+else
+	@$(ECHO) Shared Libraries not supported
+endif
+fpc_shared_install:
+ifneq ($(SHARED_BUILD),n)
+ifneq ($(SHARED_LIBUNITS),)
+ifneq ($(wildcard $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME)),)
+	$(INSTALL) $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME) $(INSTALL_SHAREDDIR)
+endif
+endif
+endif
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT)$(PPUEXT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+ifneq ($(UNITTARGETDIRPREFIX),)
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPUFILES)))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPULINKFILES))))
+endif
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+ifneq ($(TARGETDIRPREFIX),)
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(notdir $(INSTALLEXEFILES)))
+endif
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR)/* $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+ifdef DEBUGSYMEXT
+override CLEANPPULINKFILES+=$(subst $(PPUEXT),$(DEBUGSYMEXT),$(CLEANPPUFILES))
+endif
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *$(ASMEXT) *_ppas$(BATCHEXT)
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef COMPILER_UNITTARGETDIR
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+endif
+	-$(DELTREE) units
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+ifneq ($(PPUEXT),.ppu)
+	-$(DEL) *.o *.ppu *.a
+endif
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) fpcmade.* Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *_ppas$(BATCHEXT)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+ifdef DEBUGSYMEXT
+	-$(DEL) *$(DEBUGSYMEXT)
+endif
+fpc_distclean: cleanall
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Source.. $(FULL_SOURCE)
+	@$(ECHO)  Full Target.. $(FULL_TARGET)
+	@$(ECHO)  SourceSuffix. $(SOURCESUFFIX)
+	@$(ECHO)  TargetSuffix. $(TARGETSUFFIX)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Shell..... $(SHELL)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipName.............. $(ZIPNAME)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipCrossPrefix....... $(ZIPCROSSPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  FullZipName.......... $(FULLZIPNAME)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+units: fpc_units
+examples:
+shared: fpc_shared
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall:
+zipinstall:
+zipsourceinstall:
+zipexampleinstall:
+zipdistinstall:
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release units examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 16 - 0
packages/base/httpd/examples/Makefile.fpc

@@ -0,0 +1,16 @@
+#
+#  Makefile.fpc for dbus units example
+#
+
+[target]
+units=minimain
+programs=mod_example  mod_hello  mod_spelling  testmodule
+
+[require]
+packages=httpd/httpd-2.0
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../../..

+ 42 - 0
packages/base/httpd/examples/define.inc

@@ -0,0 +1,42 @@
+{ **********************************************************************
+  Define one of the following versions. Default 2.0 will be taken if none
+  is defined  
+  **********************************************************************}
+
+{ $define apache1_3}
+{ $define apache2_0}
+{ $define apache2_2}
+
+{ *********************************************************************
+  No need to edit below this line.
+  *********************************************************************}
+
+{ *********************************************************************
+  The mode must be objfpc on this unit because the unix code uses
+  some extensions introduced on Free Pascal
+  *********************************************************************}
+
+{$ifdef fpc}
+  {$mode objfpc}{$H+}
+{$endif}
+
+{$IFNDEF FPC}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$IFDEF WIN32}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{ Set at least one define. Default to 2.0 for now}
+
+{$ifndef apache1_3}
+{$ifndef apache2_0}
+{$ifndef apache2_2}
+
+{ Default 2.0 }
+{$define apache2_0}
+
+{$endif}
+{$endif}
+{$endif}

+ 66 - 0
packages/base/httpd/examples/minimain.pas

@@ -0,0 +1,66 @@
+unit minimain; 
+ 
+interface 
+
+{$mode delphi}{$H+}
+ 
+uses 
+  SysUtils, Classes, httpd, apr;
+
+procedure RegisterHooks(p: Papr_pool_t); cdecl; 
+ 
+implementation 
+ 
+function DefaultHandler(r: Prequest_rec): Integer; cdecl;
+var
+  RequestedHandler: string;
+begin 
+  RequestedHandler := r^.handler;
+
+  { We decline to handle a request if hello-handler is not the value of r->handler }
+  if not SameText(RequestedHandler, 'testapache-handler') then
+  begin
+    Result := DECLINED;
+    Exit;
+  end;
+
+  { The following line just prints a message to the errorlog }
+  ap_log_error(APLOG_MARK, APLOG_NOERRNO or APLOG_NOTICE, 0, r^.server,
+   'mod_hello: %s', 'Before content is output');
+
+  { We set the content type before doing anything else }
+  ap_set_content_type(r, 'text/html');
+
+  { If the request is for a header only, and not a request for
+   the whole content, then return OK now. We don't have to do
+   anything else. }
+  if (r^.header_only <> 0) then
+  begin
+    Result := OK;
+    Exit;
+  end;
+
+  { Now we just print the contents of the document using the
+   ap_rputs and ap_rprintf functions. More information about
+   the use of these can be found in http_protocol.h }
+  ap_rputs('<HTML>' + LineEnding, r);
+  ap_rputs('<HEAD>' + LineEnding, r);
+  ap_rputs('<TITLE>Hello There</TITLE>' + LineEnding, r);
+  ap_rputs('</HEAD>' + LineEnding, r);
+  ap_rputs('<BODY BGCOLOR="#FFFFFF">' + LineEnding ,r);
+  ap_rputs('<H1>Hello world</H1>' + LineEnding, r);
+  ap_rputs('This is the first Apache Module working with the new binding from Free Pascal' + LineEnding, r);
+  ap_rprintf(r, '<br>A sample line generated by ap_rprintf<br>\n', []);
+  ap_rputs('</BODY></HTML>' + LineEnding, r);
+
+  { We can either return OK or DECLINED at this point. If we return
+         * OK, then no other modules will attempt to process this request }
+  Result := OK;
+end;
+ 
+procedure RegisterHooks(p: Papr_pool_t); cdecl; 
+begin 
+  ap_hook_handler(DefaultHandler,nil,nil,APR_HOOK_MIDDLE); 
+end; 
+ 
+end. 

+ 1343 - 0
packages/base/httpd/examples/mod_example.pp

@@ -0,0 +1,1343 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * Apache example module.  Provide demonstrations of how modules do things.
+ * It is not meant to be used in a production server.  Since it participates
+ * in all of the processing phases, it could conceivable interfere with
+ * the proper operation of other modules -- particularly the ones related
+ * to security.
+ *
+ * In the interest of brevity, all functions and structures internal to
+ * this module, but which may have counterparts in *real* modules, are
+ * prefixed with 'x_' instead of 'example_'.
+ }
+library mod_example;
+
+{$i define.inc}
+
+uses
+  Classes, SysUtils, httpd, apr, aprutil;
+
+var
+ example_module: module; {$ifdef Unix} public name 'example_module'; {$endif}
+ default_module_ptr: Pmodule;
+
+{$ifdef WINDOWS}
+exports
+ example_module name 'example_module';
+{$endif}
+
+const
+  MODULE_NAME = 'mod_example.so';
+
+{--------------------------------------------------------------------------}
+{                                                                          }
+{ Data declarations.                                                       }
+{                                                                          }
+{ Here are the static cells and structure declarations private to our      }
+{ module.                                                                  }
+{                                                                          }
+{--------------------------------------------------------------------------}
+
+{
+ * Sample configuration record.  Used for both per-directory and per-server
+ * configuration data.
+ *
+ * It's perfectly reasonable to have two different structures for the two
+ * different environments.  The same command handlers will be called for
+ * both, though, so the handlers need to be able to tell them apart.  One
+ * possibility is for both structures to start with an int which is 0 for
+ * one and 1 for the other.
+ *
+ * Note that while the per-directory and per-server configuration records are
+ * available to most of the module handlers, they should be treated as
+ * READ-ONLY by all except the command and merge handlers.  Sometimes handlers
+ * are handed a record that applies to the current location by implication or
+ * inheritance, and modifying it will change the rules for other locations.
+ }
+const
+  CONFIG_MODE_SERVER = 1;
+  CONFIG_MODE_DIRECTORY = 2;
+  CONFIG_MODE_COMBO = 3;     { Shouldn't ever happen. }
+
+type
+  x_cfg = record
+    cmode: Integer;              { Environment to which record applies
+                                 * (directory, server, or combination).
+                                 }
+    local: Integer;                  { Boolean: "Example" directive declared
+                                 * here?
+                                 }
+    congenital: Integer;             { Boolean: did we inherit an "Example"? }
+    trace: PChar;                { Pointer to trace string. }
+    loc: PChar;                  { Location to which this record applies. }
+  end;
+
+  Px_cfg = ^x_cfg;
+
+{
+ * Let's set up a module-local static cell to point to the accreting callback
+ * trace.  As each API callback is made to us, we'll tack on the particulars
+ * to whatever we've already recorded.  To avoid massive memory bloat as
+ * directories are walked again and again, we record the routine/environment
+ * the first time (non-request context only), and ignore subsequent calls for
+ * the same routine/environment.
+ }
+var
+  trace: PChar = nil;
+  static_calls_made: Papr_table_t = nil;
+
+{
+ * To avoid leaking memory from pools other than the per-request one, we
+ * allocate a module-private pool, and then use a sub-pool of that which gets
+ * freed each time we modify the trace.  That way previous layers of trace
+ * data don't get lost.
+ }
+  x_pool: Papr_pool_t = nil;
+  x_subpool: Papr_pool_t = nil;
+
+{--------------------------------------------------------------------------}
+{                                                                          }
+{ The following pseudo-prototype declarations illustrate the parameters    }
+{ passed to command handlers for the different types of directive          }
+{ syntax.  If an argument was specified in the directive definition        }
+{ (look for "command_rec" below), it's available to the command handler    }
+{ via the (void *) info field in the cmd_parms argument passed to the      }
+{ handler (cmd->info for the examples below).                              }
+{                                                                          }
+{--------------------------------------------------------------------------}
+
+{
+ * Command handler for a NO_ARGS directive.  Declared in the command_rec
+ * list with
+ *   AP_INIT_NO_ARGS("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_NO_ARGS(cmd_parms *cmd, void *mconfig);
+ }
+
+{
+ * Command handler for a RAW_ARGS directive.  The "args" argument is the text
+ * of the commandline following the directive itself.  Declared in the
+ * command_rec list with
+ *   AP_INIT_RAW_ARGS("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_RAW_ARGS(cmd_parms *cmd, void *mconfig,
+ *                                    const char *args);
+ }
+
+{
+ * Command handler for a FLAG directive.  The single parameter is passed in
+ * "bool", which is either zero or not for Off or On respectively.
+ * Declared in the command_rec list with
+ *   AP_INIT_FLAG("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_FLAG(cmd_parms *cmd, void *mconfig, int bool);
+ }
+
+{
+ * Command handler for a TAKE1 directive.  The single parameter is passed in
+ * "word1".  Declared in the command_rec list with
+ *   AP_INIT_TAKE1("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_TAKE1(cmd_parms *cmd, void *mconfig,
+ *                                 char *word1);
+ }
+
+{
+ * Command handler for a TAKE2 directive.  TAKE2 commands must always have
+ * exactly two arguments.  Declared in the command_rec list with
+ *   AP_INIT_TAKE2("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_TAKE2(cmd_parms *cmd, void *mconfig,
+ *                                 char *word1, char *word2);
+ }
+
+{
+ * Command handler for a TAKE3 directive.  Like TAKE2, these must have exactly
+ * three arguments, or the parser complains and doesn't bother calling us.
+ * Declared in the command_rec list with
+ *   AP_INIT_TAKE3("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_TAKE3(cmd_parms *cmd, void *mconfig,
+ *                                 char *word1, char *word2, char *word3);
+ }
+
+{
+ * Command handler for a TAKE12 directive.  These can take either one or two
+ * arguments.
+ * - word2 is a NULL pointer if no second argument was specified.
+ * Declared in the command_rec list with
+ *   AP_INIT_TAKE12("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_TAKE12(cmd_parms *cmd, void *mconfig,
+ *                                  char *word1, char *word2);
+ }
+
+{
+ * Command handler for a TAKE123 directive.  A TAKE123 directive can be given,
+ * as might be expected, one, two, or three arguments.
+ * - word2 is a NULL pointer if no second argument was specified.
+ * - word3 is a NULL pointer if no third argument was specified.
+ * Declared in the command_rec list with
+ *   AP_INIT_TAKE123("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_TAKE123(cmd_parms *cmd, void *mconfig,
+ *                                   char *word1, char *word2, char *word3);
+ }
+
+{
+ * Command handler for a TAKE13 directive.  Either one or three arguments are
+ * permitted - no two-parameters-only syntax is allowed.
+ * - word2 and word3 are NULL pointers if only one argument was specified.
+ * Declared in the command_rec list with
+ *   AP_INIT_TAKE13("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_TAKE13(cmd_parms *cmd, void *mconfig,
+ *                                  char *word1, char *word2, char *word3);
+ }
+
+{
+ * Command handler for a TAKE23 directive.  At least two and as many as three
+ * arguments must be specified.
+ * - word3 is a NULL pointer if no third argument was specified.
+ * Declared in the command_rec list with
+ *   AP_INIT_TAKE23("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_TAKE23(cmd_parms *cmd, void *mconfig,
+ *                                  char *word1, char *word2, char *word3);
+ }
+
+{
+ * Command handler for a ITERATE directive.
+ * - Handler is called once for each of n arguments given to the directive.
+ * - word1 points to each argument in turn.
+ * Declared in the command_rec list with
+ *   AP_INIT_ITERATE("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_ITERATE(cmd_parms *cmd, void *mconfig,
+ *                                   char *word1);
+ }
+
+{
+ * Command handler for a ITERATE2 directive.
+ * - Handler is called once for each of the second and subsequent arguments
+ *   given to the directive.
+ * - word1 is the same for each call for a particular directive instance (the
+ *   first argument).
+ * - word2 points to each of the second and subsequent arguments in turn.
+ * Declared in the command_rec list with
+ *   AP_INIT_ITERATE2("directive", function, mconfig, where, help)
+ *
+ * static const char *handle_ITERATE2(cmd_parms *cmd, void *mconfig,
+ *                                    char *word1, char *word2);
+ }
+
+{--------------------------------------------------------------------------}
+{                                                                          }
+{ These routines are strictly internal to this module, and support its     }
+{ operation.  They are not referenced by any external portion of the       }
+{ server.                                                                  }
+{                                                                          }
+{--------------------------------------------------------------------------}
+
+{
+ * Locate our directory configuration record for the current request.
+ }
+function our_dconfig(const r: Prequest_rec): Px_cfg; cdecl;
+begin
+  Result := Px_cfg(ap_get_module_config(r^.per_dir_config, @example_module));
+end;
+
+//#if 0
+{
+ * Locate our server configuration record for the specified server.
+ }
+function our_sconfig(const s: Pserver_rec): Px_cfg; cdecl;
+begin
+  Result := Px_cfg(ap_get_module_config(s^.module_config, @example_module));
+end;
+
+{
+ * Likewise for our configuration record for the specified request.
+ }
+function our_rconfig(const r: Prequest_rec): Px_cfg; cdecl;
+begin
+  Result := Px_cfg(ap_get_module_config(r^.request_config, @example_module));
+end;
+//#endif
+
+{
+ * Likewise for our configuration record for a connection.
+ }
+function our_cconfig(const c: Pconn_rec): Px_cfg; cdecl;
+begin
+  Result := Px_cfg(ap_get_module_config(c^.conn_config, @example_module));
+end;
+
+{
+ * This routine sets up some module-wide cells if they haven't been already.
+ }
+procedure setup_module_cells; cdecl;
+begin
+    {
+     * If we haven't already allocated our module-private pool, do so now.
+     }
+    if (x_pool = nil) then apr_pool_create(@x_pool, nil);
+
+    {
+     * Likewise for the table of routine/environment pairs we visit outside of
+     * request context.
+     }
+    if (static_calls_made = nil) then static_calls_made := apr_table_make(x_pool, 16);
+end;
+
+{
+ * This routine is used to add a trace of a callback to the list.  We're
+ * passed the server record (if available), the request record (if available),
+ * a pointer to our private configuration record (if available) for the
+ * environment to which the callback is supposed to apply, and some text.  We
+ * turn this into a textual representation and add it to the tail of the list.
+ * The list can be displayed by the x_handler() routine.
+ *
+ * If the call occurs within a request context (i.e., we're passed a request
+ * record), we put the trace into the request apr_pool_t and attach it to the
+ * request via the notes mechanism.  Otherwise, the trace gets added
+ * to the static (non-request-specific) list.
+ *
+ * Note that the r^.notes table is only for storing strings; if you need to
+ * maintain per-request data of any other type, you need to use another
+ * mechanism.
+ }
+
+const
+  TRACE_NOTE = 'example-trace';
+
+  EXAMPLE_LOG_EACH = 0;
+
+procedure trace_add(s: Pserver_rec; r: Prequest_rec; mconfig: Px_cfg; const note: PChar); cdecl;
+var
+  sofar, addon, where, trace_copy, key: PChar;
+  p: Papr_pool_t;
+begin
+    {
+     * Make sure our pools and tables are set up - we need 'em.
+     }
+    setup_module_cells();
+    {
+     * Now, if we're in request-context, we use the request pool.
+     }
+    if (r <> nil) then
+    begin
+        p := r^.pool;
+        trace_copy := apr_table_get(r^.notes, TRACE_NOTE);
+        if (trace_copy = nil) then trace_copy := '';
+    end
+    else
+    begin
+        {
+         * We're not in request context, so the trace gets attached to our
+         * module-wide pool.  We do the create/destroy every time we're called
+         * in non-request context; this avoids leaking memory in some of
+         * the subsequent calls that allocate memory only once (such as the
+         * key formation below).
+         *
+         * Make a new sub-pool and copy any existing trace to it.  Point the
+         * trace cell at the copied value.
+         }
+        apr_pool_create(@p, x_pool);
+        if (trace <> nil) then trace := apr_pstrdup(p, trace);
+
+        {
+         * Now, if we have a sub-pool from before, nuke it and replace with
+         * the one we just allocated.
+         }
+        if (x_subpool <> nil) then apr_pool_destroy(x_subpool);
+
+        x_subpool := p;
+        trace_copy := trace;
+    end;
+    {
+     * If we weren't passed a configuration record, we can't figure out to
+     * what location this call applies.  This only happens for co-routines
+     * that don't operate in a particular directory or server context.  If we
+     * got a valid record, extract the location (directory or server) to which
+     * it applies.
+     }
+    {
+       Translation note. The part bellow is commented because there is an unidentified
+      problem with it.
+     }
+    {if (mconfig <> nil) then where := mconfig^.loc
+    else} where := 'nowhere';
+    if (where = nil) then where := '';
+    {
+     * Now, if we're not in request context, see if we've been called with
+     * this particular combination before.  The apr_table_t is allocated in the
+     * module's private pool, which doesn't get destroyed.
+     }
+    if (r = nil) then
+    begin
+        key := apr_pstrcat(p, [note, PChar(':'), where, nil]);
+
+        if (apr_table_get(static_calls_made, key) <> nil) then
+            {
+             * Been here, done this.
+             }
+            Exit
+        else
+            {
+             * First time for this combination of routine and environment -
+             * log it so we don't do it again.
+             }
+            apr_table_set(static_calls_made, key, 'been here');
+    end;
+    addon := apr_pstrcat(p, [
+                        PChar('   <li>' + LineEnding +
+                        '    <dl>' + LineEnding +
+                        '     <dt><samp>'), note, PChar('</samp></dt>' + LineEnding +
+                        '     <dd><samp>['), where, PChar(']</samp></dd>' + LineEnding +
+                        '    </dl>' + LineEnding +
+                        '   </li>' + LineEnding),
+                        nil]);
+
+    if (trace_copy = nil) then sofar := '' else sofar := trace_copy;
+    
+    trace_copy := apr_pstrcat(p, [sofar, addon, nil]);
+    if (r <> nil) then apr_table_set(r^.notes, TRACE_NOTE, trace_copy)
+    else trace := trace_copy;
+
+    {
+     * You *could* change the following if you wanted to see the calling
+     * sequence reported in the server's error_log, but beware - almost all of
+     * these co-routines are called for every single request, and the impact
+     * on the size (and readability) of the error_log is considerable.
+     }
+    if ((EXAMPLE_LOG_EACH = 0) and (s <> nil)) then
+      ap_log_error(MODULE_NAME, 438, APLOG_DEBUG, 0, s, 'mod_example: ', [note]);
+end;
+
+{--------------------------------------------------------------------------}
+{ We prototyped the various syntax for command handlers (routines that     }
+{ are called when the configuration parser detects a directive declared    }
+{ by our module) earlier.  Now we actually declare a "real" routine that   }
+{ will be invoked by the parser when our "real" directive is               }
+{ encountered.                                                             }
+{                                                                          }
+{ If a command handler encounters a problem processing the directive, it   }
+{ signals this fact by returning a non-NULL pointer to a string            }
+{ describing the problem.                                                  }
+{                                                                          }
+{ The magic return value DECLINE_CMD is used to deal with directives       }
+{ that might be declared by multiple modules.  If the command handler      }
+{ returns NULL, the directive was processed; if it returns DECLINE_CMD,    }
+{ the next module (if any) that declares the directive is given a chance   }
+{ at it.  If it returns any other value, it's treated as the text of an    }
+{ error message.                                                           }
+{--------------------------------------------------------------------------}
+{
+ * Command handler for the NO_ARGS "Example" directive.  All we do is mark the
+ * call in the trace log, and flag the applicability of the directive to the
+ * current location in that location's configuration record.
+ }
+function cmd_example(cmd: Pcmd_parms; mconfig: Pointer): PChar; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := Px_cfg(mconfig);
+
+  { "Example Wuz Here" }
+  cfg^.local := 1;
+  trace_add(cmd^.server, nil, cfg, 'cmd_example()');
+  Result := nil;
+end;
+
+{--------------------------------------------------------------------------}
+{                                                                          }
+{ Now we declare our content handlers, which are invoked when the server   }
+{ encounters a document which our module is supposed to have a chance to   }
+{ see.  (See mod_mime's SetHandler and AddHandler directives, and the      }
+{ mod_info and mod_status examples, for more details.)                     }
+{                                                                          }
+{ Since content handlers are dumping data directly into the connection     }
+{ (using the r*() routines, such as rputs() and rprintf()) without         }
+{ intervention by other parts of the server, they need to make             }
+{ sure any accumulated HTTP headers are sent first.  This is done by       }
+{ calling send_http_header().  Otherwise, no header will be sent at all,   }
+{ and the output sent to the client will actually be HTTP-uncompliant.     }
+{--------------------------------------------------------------------------}
+{
+ * Sample content handler.  All this does is display the call list that has
+ * been built up so far.
+ *
+ * The return value instructs the caller concerning what happened and what to
+ * do next:
+ *  OK ("we did our thing")
+ *  DECLINED ("this isn't something with which we want to get involved")
+ *  HTTP_mumble ("an error status should be reported")
+ }
+function x_handler(r: Prequest_rec): Integer; cdecl;
+var
+  dcfg: Px_cfg;
+  tempstr: PChar;
+begin
+    tempstr := 'Undefined';
+
+    if not SameText(r^.handler, 'example-handler') then
+    begin
+      Result := DECLINED;
+      Exit;
+    end;
+
+    dcfg := our_dconfig(r);
+//    trace_add(r^.server, r, dcfg, 'x_handler()');
+    {
+     * We're about to start sending content, so we need to force the HTTP
+     * headers to be sent at this point.  Otherwise, no headers will be sent
+     * at all.  We can set any we like first, of course.  **NOTE** Here's
+     * where you set the "Content-type" header, and you do so by putting it in
+     * r^.content_type, *not* r^.headers_out("Content-type").  If you don't
+     * set it, it will be filled in with the server's default type (typically
+     * "text/plain").  You *must* also ensure that r^.content_type is lower
+     * case.
+     *
+     * We also need to start a timer so the server can know if the connexion
+     * is broken.
+     }
+    ap_set_content_type(r, 'text/html');
+    {
+     * If we're only supposed to send header information (HEAD request), we're
+     * already there.
+     }
+    if (r^.header_only <> 0) then
+    begin
+      Result := OK;
+      Exit;
+    end;
+
+    {
+     * Now send our actual output.  Since we tagged this as being
+     * "text/html", we need to embed any HTML.
+     }
+    ap_rputs(DOCTYPE_HTML_3_2, r);
+    ap_rputs('<HTML>' + LineEnding, r);
+    ap_rputs(' <HEAD>' + LineEnding, r);
+    ap_rputs('  <TITLE>mod_example Module Content-Handler Output' + LineEnding, r);
+    ap_rputs('  </TITLE>' + LineEnding, r);
+    ap_rputs(' </HEAD>' + LineEnding, r);
+    ap_rputs(' <BODY>' + LineEnding, r);
+    ap_rputs('  <H1><SAMP>mod_example</SAMP> Module Content-Handler Output' + LineEnding, r);
+    ap_rputs('  </H1>' + LineEnding, r);
+    ap_rputs('  <P>' + LineEnding, r);
+    ap_rprintf(r, '  Apache HTTP Server version: "%s"' + LineEnding, [ap_get_server_version()]);
+    ap_rputs('  <BR>' + LineEnding, r);
+    ap_rprintf(r, '  Server built: "%s"' + LineEnding, [ap_get_server_built()]);
+    ap_rputs('  </P>' + LineEnding, r);;
+    ap_rputs('  <P>' + LineEnding, r);
+    ap_rputs('  The format for the callback trace is:' + LineEnding, r);
+    ap_rputs('  </P>' + LineEnding, r);
+    ap_rputs('  <DL>' + LineEnding, r);
+    ap_rputs('   <DT><EM>n</EM>.<SAMP>&lt;routine-name&gt;', r);
+    ap_rputs('(&lt;routine-data&gt;)</SAMP>' + LineEnding, r);
+    ap_rputs('   </DT>' + LineEnding, r);
+    ap_rputs('   <DD><SAMP>[&lt;applies-to&gt;]</SAMP>' + LineEnding, r);
+    ap_rputs('   </DD>' + LineEnding, r);
+    ap_rputs('  </DL>' + LineEnding, r);
+    ap_rputs('  <P>' + LineEnding, r);
+    ap_rputs('  The <SAMP>&lt;routine-data&gt;</SAMP> is supplied by' + LineEnding, r);
+    ap_rputs('  the routine when it requests the trace,' + LineEnding, r);
+    ap_rputs('  and the <SAMP>&lt;applies-to&gt;</SAMP> is extracted' + LineEnding, r);
+    ap_rputs('  from the configuration record at the time of the trace.' + LineEnding, r);
+    ap_rputs('  <STRONG>SVR()</STRONG> indicates a server environment' + LineEnding, r);
+    ap_rputs('  (blank means the main or default server, otherwise it''s' + LineEnding, r);
+    ap_rputs('  the name of the VirtualHost); <STRONG>DIR()</STRONG>' + LineEnding, r);
+    ap_rputs('  indicates a location in the URL or filesystem' + LineEnding, r);
+    ap_rputs('  namespace.' + LineEnding, r);
+    ap_rputs('  </P>' + LineEnding, r);
+    ap_rprintf(r, '  <H2>Static callbacks so far:</H2>' + LineEnding +
+     '  <OL>' + LineEnding + '%s  </OL>' + LineEnding, [trace]);
+    ap_rputs('  <H2>Request-specific callbacks so far:</H2>' + LineEnding, r);
+    ap_rprintf(r, '  <OL>' + LineEnding + '%s  </OL>' + LineEnding, [apr_table_get(r^.notes, TRACE_NOTE)]);
+    ap_rputs('  <H2>Environment for <EM>this</EM> call:</H2>' + LineEnding, r);
+    ap_rputs('  <UL>' + LineEnding, r);
+//    ap_rprintf(r, '   <LI>Applies-to: <SAMP>%s</SAMP>' + LineEnding + '   </LI>' + LineEnding, [dcfg^.loc]);
+
+//    if dcfg^.local = 0 then tempstr := 'NO' else tempstr := 'Yes';
+
+    ap_rprintf(r, '   <LI>"Example" directive declared here: %s' + LineEnding + '   </LI>' + LineEnding,
+     [tempstr]);
+
+//    if dcfg^.congenital = 0 then tempstr := 'NO' else tempstr := 'Yes';
+
+    ap_rprintf(r, '   <LI>"Example" inherited: %s' + LineEnding + '   </LI>' + LineEnding, [tempstr]);
+    ap_rputs('  </UL>' + LineEnding, r);
+    ap_rputs(' </BODY>' + LineEnding, r);
+    ap_rputs('</HTML>' + LineEnding, r);
+    {
+     * We're all done, so cancel the timeout we set.  Since this is probably
+     * the end of the request we *could* assume this would be done during
+     * post-processing - but it's possible that another handler might be
+     * called and inherit our outstanding timer.  Not good; to each its own.
+     }
+    {
+     * We did what we wanted to do, so tell the rest of the server we
+     * succeeded.
+     }
+    Result := OK;
+end;
+
+{--------------------------------------------------------------------------}
+{                                                                          }
+{ Now let's declare routines for each of the callback phase in order.      }
+{ (That's the order in which they're listed in the callback list, *not     }
+{ the order in which the server calls them!  See the command_rec           }
+{ declaration near the bottom of this file.)  Note that these may be       }
+{ called for situations that don't relate primarily to our function - in   }
+{ other words, the fixup handler shouldn't assume that the request has     }
+{ to do with "example" stuff.                                              }
+{                                                                          }
+{ With the exception of the content handler, all of our routines will be   }
+{ called for each request, unless an earlier handler from another module   }
+{ aborted the sequence.                                                    }
+{                                                                          }
+{ Handlers that are declared as "int" can return the following:            }
+{                                                                          }
+{  OK          Handler accepted the request and did its thing with it.     }
+{  DECLINED    Handler took no action.                                     }
+{  HTTP_mumble Handler looked at request and found it wanting.             }
+{                                                                          }
+{ What the server does after calling a module handler depends upon the     }
+{ handler's return value.  In all cases, if the handler returns            }
+{ DECLINED, the server will continue to the next module with an handler    }
+{ for the current phase.  However, if the handler return a non-OK,         }
+{ non-DECLINED status, the server aborts the request right there.  If      }
+{ the handler returns OK, the server's next action is phase-specific;      }
+{ see the individual handler comments below for details.                   }
+{                                                                          }
+{--------------------------------------------------------------------------}
+{
+ * This function is called during server initialisation.  Any information
+ * that needs to be recorded must be in static cells, since there's no
+ * configuration record.
+ *
+ * There is no return value.
+ }
+
+{
+ * This function is called when an heavy-weight process (such as a child) is
+ * being run down or destroyed.  As with the child initialisation function,
+ * any information that needs to be recorded must be in static cells, since
+ * there's no configuration record.
+ *
+ * There is no return value.
+ }
+
+{
+ * This function is called during server initialisation when an heavy-weight
+ * process (such as a child) is being initialised.  As with the
+ * module initialisation function, any information that needs to be recorded
+ * must be in static cells, since there's no configuration record.
+ *
+ * There is no return value.
+ }
+
+{
+ * This function gets called to create a per-directory configuration
+ * record.  This will be called for the "default" server environment, and for
+ * each directory for which the parser finds any of our directives applicable.
+ * If a directory doesn't have any of our directives involved (i.e., they
+ * aren't in the .htaccess file, or a <Location>, <Directory>, or related
+ * block), this routine will *not* be called - the configuration for the
+ * closest ancestor is used.
+ *
+ * The return value is a pointer to the created module-specific
+ * structure.
+ }
+function x_create_dir_config(p: Papr_pool_t; dirspec: PChar): Pointer; cdecl;
+var
+  cfg: Px_cfg;
+  dname: PChar;
+begin
+  dname := dirspec;
+
+    {
+     * Allocate the space for our record from the pool supplied.
+     }
+    cfg := Px_cfg(apr_pcalloc(p, sizeof(x_cfg)));
+    {
+     * Now fill in the defaults.  If there are any `parent' configuration
+     * records, they'll get merged as part of a separate callback.
+     }
+    cfg^.local := 0;
+    cfg^.congenital := 0;
+    cfg^.cmode := CONFIG_MODE_DIRECTORY;
+    {
+     * Finally, add our trace to the callback list.
+     }
+    if dname = nil then dname := '';
+    cfg^.loc := apr_pstrcat(p, [PChar('DIR('), dname, PChar(')'), nil]);
+    trace_add(nil, nil, cfg, 'x_create_dir_config()');
+    Result := Pointer(cfg);
+end;
+
+{
+ * This function gets called to merge two per-directory configuration
+ * records.  This is typically done to cope with things like .htaccess files
+ * or <Location> directives for directories that are beneath one for which a
+ * configuration record was already created.  The routine has the
+ * responsibility of creating a new record and merging the contents of the
+ * other two into it appropriately.  If the module doesn't declare a merge
+ * routine, the record for the closest ancestor location (that has one) is
+ * used exclusively.
+ *
+ * The routine MUST NOT modify any of its arguments!
+ *
+ * The return value is a pointer to the created module-specific structure
+ * containing the merged values.
+ }
+function x_merge_dir_config(p: Papr_pool_t;
+ parent_conf, newloc_conf: Pointer): Pointer; cdecl;
+var
+  merged_config, pconf, nconf: Px_cfg;
+  note: PChar;
+begin
+    merged_config := Px_cfg(apr_pcalloc(p, sizeof(x_cfg)));
+    pconf := Px_cfg(parent_conf);
+    nconf := Px_cfg(newloc_conf);
+
+    {
+     * Some things get copied directly from the more-specific record, rather
+     * than getting merged.
+     }
+    merged_config^.local := nconf^.local;
+    merged_config^.loc := apr_pstrdup(p, nconf^.loc);
+    {
+     * Others, like the setting of the `congenital' flag, get ORed in.  The
+     * setting of that particular flag, for instance, is TRUE if it was ever
+     * true anywhere in the upstream configuration.
+     }
+    merged_config^.congenital := (pconf^.congenital or pconf^.local);
+    {
+     * If we're merging records for two different types of environment (server
+     * and directory), mark the new record appropriately.  Otherwise, inherit
+     * the current value.
+     }
+    if pconf^.cmode = nconf^.cmode then
+     merged_config^.cmode := pconf^.cmode
+    else merged_config^.cmode := CONFIG_MODE_COMBO;
+    {
+     * Now just record our being called in the trace list.  Include the
+     * locations we were asked to merge.
+     }
+    note := apr_pstrcat(p, [PChar('x_merge_dir_config("'), pconf^.loc, PChar('","'),
+     nconf^.loc, PChar('")'), nil]);
+    trace_add(nil, nil, merged_config, note);
+    Result := Pointer(merged_config);
+end;
+
+{
+ * This function gets called to create a per-server configuration
+ * record.  It will always be called for the "default" server.
+ *
+ * The return value is a pointer to the created module-specific
+ * structure.
+ }
+function x_create_server_config(p: Papr_pool_t; s: Pserver_rec): Pointer; cdecl;
+var
+  cfg: Px_cfg;
+  sname: PChar;
+begin
+    sname := s^.server_hostname;
+
+    {
+     * As with the x_create_dir_config() reoutine, we allocate and fill
+     * in an empty record.
+     }
+    cfg := Px_cfg(apr_pcalloc(p, sizeof(x_cfg)));
+    cfg^.local := 0;
+    cfg^.congenital := 0;
+    cfg^.cmode := CONFIG_MODE_SERVER;
+    {
+     * Note that we were called in the trace list.
+     }
+    if sname = nil then sname := '';
+    cfg^.loc := apr_pstrcat(p, [PChar('SVR('), sname, PChar(')'), nil]);
+    trace_add(s, nil, cfg, 'x_create_server_config()');
+    Result := Pointer(cfg);
+end;
+
+{
+ * This function gets called to merge two per-server configuration
+ * records.  This is typically done to cope with things like virtual hosts and
+ * the default server configuration  The routine has the responsibility of
+ * creating a new record and merging the contents of the other two into it
+ * appropriately.  If the module doesn't declare a merge routine, the more
+ * specific existing record is used exclusively.
+ *
+ * The routine MUST NOT modify any of its arguments!
+ *
+ * The return value is a pointer to the created module-specific structure
+ * containing the merged values.
+ }
+function x_merge_server_config(p: Papr_pool_t;
+ server1_conf, server2_conf: Pointer): Pointer; cdecl;
+var
+  merged_config, s1conf, s2conf: Px_cfg;
+  note: PChar;
+begin
+    merged_config := Px_cfg(apr_pcalloc(p, sizeof(x_cfg)));
+    s1conf := Px_cfg(server1_conf);
+    s2conf := Px_cfg(server2_conf);
+
+    {
+     * Our inheritance rules are our own, and part of our module's semantics.
+     * Basically, just note whence we came.
+     }
+    if s1conf^.cmode = s2conf^.cmode then
+     merged_config^.cmode := s1conf^.cmode
+    else merged_config^.cmode := CONFIG_MODE_COMBO;
+    
+    merged_config^.local := s2conf^.local;
+    merged_config^.congenital := (s1conf^.congenital or s1conf^.local);
+    merged_config^.loc := apr_pstrdup(p, s2conf^.loc);
+    {
+     * Trace our call, including what we were asked to merge.
+     }
+    note := apr_pstrcat(p, [PChar('x_merge_server_config("'), s1conf^.loc, PChar('","'),
+     s2conf^.loc, PChar('")'), nil]);
+    trace_add(nil, nil, merged_config, note);
+    Result := Pointer(merged_config);
+end;
+
+{
+ * This routine is called before the server processes the configuration
+ * files.  There is no return value.
+ }
+function x_pre_config(pconf, plog, ptemp: Papr_pool_t): Integer; cdecl;
+begin
+    {
+     * Log the call and exit.
+     }
+    trace_add(nil, nil, nil, 'x_pre_config()');
+
+    Result := OK;
+end;
+
+{
+ * This routine is called to perform any module-specific fixing of header
+ * fields, et cetera.  It is invoked just before any content-handler.
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
+ * server will still call any remaining modules with an handler for this
+ * phase.
+ }
+function x_post_config(pconf, plog, ptemp: Papr_pool_t; s: Pserver_rec): Integer; cdecl;
+begin
+    {
+     * Log the call and exit.
+     }
+    trace_add(nil, nil, nil, 'x_post_config()');
+    Result := OK;
+end;
+
+{
+ * This routine is called to perform any module-specific log file
+ * openings. It is invoked just before the post_config phase
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
+ * server will still call any remaining modules with an handler for this
+ * phase.
+ }
+function x_open_logs(pconf, plog, ptemp: Papr_pool_t; s: Pserver_rec): Integer; cdecl;
+begin
+    {
+     * Log the call and exit.
+     }
+    trace_add(s, nil, nil, 'x_open_logs()');
+    Result := OK;
+end;
+
+{
+ * All our process-death routine does is add its trace to the log.
+ }
+function x_child_exit(data: Pointer): apr_status_t; cdecl;
+var
+  note, sname: PChar;
+  s: Pserver_rec;
+begin
+    s := data;
+    sname := s^.server_hostname;
+
+    {
+     * The arbitrary text we add to our trace entry indicates for which server
+     * we're being called.
+     }
+    if sname = nil then sname := '';
+    note := apr_pstrcat(s^.process^.pool, [PChar('x_child_exit('), sname, PChar(')'), nil]);
+    trace_add(s, nil, nil, note);
+    Result := APR_SUCCESS;
+end;
+
+{
+ * All our process initialiser does is add its trace to the log.
+ }
+procedure x_child_init(p: Papr_pool_t; s: Pserver_rec); cdecl;
+var
+  note, sname: PChar;
+begin
+  sname := s^.server_hostname;
+
+    {
+     * Set up any module cells that ought to be initialised.
+     }
+    setup_module_cells();
+    {
+     * The arbitrary text we add to our trace entry indicates for which server
+     * we're being called.
+     }
+    if sname = nil then sname := '';
+    note := apr_pstrcat(p, [PChar('x_child_init('), sname, PChar(')'), nil]);
+    trace_add(s, nil, nil, note);
+
+    apr_pool_cleanup_register(p, s, @x_child_exit, @x_child_exit);
+end;
+
+{
+ * XXX: This routine is called XXX
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
+ * server will still call any remaining modules with an handler for this
+ * phase.
+ }
+//#if 0
+function x_http_method(const r: Prequest_rec): PChar; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_dconfig(r);
+
+  // Log the call and exit.
+
+  trace_add(r^.server, nil, cfg, 'x_http_method()');
+  Result := 'foo';
+end;
+
+{
+ * XXX: This routine is called XXX
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
+ * server will still call any remaining modules with an handler for this
+ * phase.
+ }
+function x_default_port(const r: Prequest_rec): apr_port_t; cdecl;
+var
+  cfg: Px_cfg;
+begin
+    cfg := our_dconfig(r);
+    {
+     * Log the call and exit.
+     }
+    trace_add(r^.server, nil, cfg, 'x_default_port()');
+  Result := 80;
+end;
+//#endif {0}
+
+{
+ * XXX: This routine is called XXX
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
+ * server will still call any remaining modules with an handler for this
+ * phase.
+ }
+procedure x_insert_filter(r: Prequest_rec); cdecl;
+var
+  cfg: Px_cfg;
+begin
+    cfg := our_dconfig(r);
+    {
+     * Log the call and exit.
+     }
+    trace_add(r^.server, nil, cfg, 'x_insert_filter()');
+end;
+
+{
+ * XXX: This routine is called XXX
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
+ * server will still call any remaining modules with an handler for this
+ * phase.
+ }
+function x_quick_handler(r: Prequest_rec; lookup_uri: Integer): Integer; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_dconfig(r);
+  
+  { Log the call and exit. }
+  
+  trace_add(r^.server, nil, cfg, 'x_post_config()');
+    
+  Result := DECLINED;
+end;
+
+{
+ * This routine is called just after the server accepts the connection,
+ * but before it is handed off to a protocol module to be served.  The point
+ * of this hook is to allow modules an opportunity to modify the connection
+ * as soon as possible. The core server uses this phase to setup the
+ * connection record based on the type of connection that is being used.
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
+ * server will still call any remaining modules with an handler for this
+ * phase.
+ }
+function x_pre_connection(c: Pconn_rec; csd: Pointer): Integer; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_cconfig(c);
+
+{$ifdef 0}
+  {
+   * Log the call and exit.
+   }
+  trace_add(r^.server, nil, cfg, 'x_post_config()');
+{$endif}
+
+  Result := OK;
+end;
+
+{ This routine is used to actually process the connection that was received.
+ * Only protocol modules should implement this hook, as it gives them an
+ * opportunity to replace the standard HTTP processing with processing for
+ * some other protocol.  Both echo and POP3 modules are available as
+ * examples.
+ *
+ * The return VALUE is OK, DECLINED, or HTTP_mumble.  If we return OK, no
+ * further modules are called for this phase.
+ }
+function x_process_connection(c: Pconn_rec): Integer; cdecl;
+begin
+  Result := DECLINED;
+end;
+
+{
+ * This routine is called after the request has been read but before any other
+ * phases have been processed.  This allows us to make decisions based upon
+ * the input header fields.
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, no
+ * further modules are called for this phase.
+ }
+function x_post_read_request(r: Prequest_rec): Integer; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_dconfig(r);
+  {
+   * We don't actually *do* anything here, except note the fact that we were
+   * called.
+   }
+  trace_add(r^.server, r, cfg, 'x_post_read_request()');
+  Result := DECLINED;
+end;
+
+{
+ * This routine gives our module an opportunity to translate the URI into an
+ * actual filename.  If we don't do anything special, the server's default
+ * rules (Alias directives and the like) will continue to be followed.
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, no
+ * further modules are called for this phase.
+ }
+function x_translate_handler(r: Prequest_rec): Integer; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_dconfig(r);
+  {
+   * We don't actually *do* anything here, except note the fact that we were
+   * called.
+   }
+  trace_add(r^.server, r, cfg, 'x_translate_handler()');
+    
+  Result := DECLINED;
+end;
+
+{
+ * this routine gives our module another chance to examine the request
+ * headers and to take special action. This is the first phase whose
+ * hooks' configuration directives can appear inside the <Directory>
+ * and similar sections, because at this stage the URI has been mapped
+ * to the filename. For example this phase can be used to block evil
+ * clients, while little resources were wasted on these.
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK,
+ * the server will still call any remaining modules with an handler
+ * for this phase.
+ }
+function x_header_parser_handler(r: Prequest_rec): Integer; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_dconfig(r);
+  {
+   * We don't actually *do* anything here, except note the fact that we were
+   * called.
+   }
+  trace_add(r^.server, r, cfg, 'header_parser_handler()');
+  
+  Result := DECLINED;
+end;
+
+
+{
+ * This routine is called to check the authentication information sent with
+ * the request (such as looking up the user in a database and verifying that
+ * the [encrypted] password sent matches the one in the database).
+ *
+ * The return value is OK, DECLINED, or some HTTP_mumble error (typically
+ * HTTP_UNAUTHORIZED).  If we return OK, no other modules are given a chance
+ * at the request during this phase.
+ }
+function x_check_user_id(r: Prequest_rec): Integer; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_dconfig(r);
+
+  { Don't do anything except log the call. }
+  
+  trace_add(r^.server, r, cfg, 'x_check_user_id()');
+
+  Result := DECLINED;
+end;
+
+{
+ * This routine is called to check to see if the resource being requested
+ * requires authorisation.
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, no
+ * other modules are called during this phase.
+ *
+ * If *all* modules return DECLINED, the request is aborted with a server
+ * error.
+ }
+function x_auth_checker(r: Prequest_rec): Integer; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_dconfig(r);
+    
+  { * Log the call and return OK, or access will be denied (even though we
+    * didn't actually do anything). }
+      
+  trace_add(r^.server, r, cfg, 'x_auth_checker()');
+  
+  Result := DECLINED;
+end;
+
+{
+ * This routine is called to check for any module-specific restrictions placed
+ * upon the requested resource.  (See the mod_access module for an example.)
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  All modules with an
+ * handler for this phase are called regardless of whether their predecessors
+ * return OK or DECLINED.  The first one to return any other status, however,
+ * will abort the sequence (and the request) as usual.
+ }
+function x_access_checker(r: Prequest_rec): Integer; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_dconfig(r);
+  trace_add(r^.server, r, cfg, 'x_access_checker()');
+    
+  Result := DECLINED;
+end;
+
+{
+ * This routine is called to determine and/or set the various document type
+ * information bits, like Content-type (via r^.content_type), language, et
+ * cetera.
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, no
+ * further modules are given a chance at the request for this phase.
+ }
+function x_type_checker(r: Prequest_rec): Integer; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_dconfig(r);
+
+  {  * Log the call, but don't do anything else - and report truthfully that
+     * we didn't do anything. }
+     
+  trace_add(r^.server, r, cfg, 'x_type_checker()');
+    
+  Result := DECLINED;
+end;
+
+{
+ * This routine is called to perform any module-specific fixing of header
+ * fields, et cetera.  It is invoked just before any content-handler.
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, the
+ * server will still call any remaining modules with an handler for this
+ * phase.
+ }
+function x_fixer_upper(r: Prequest_rec): Integer; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_dconfig(r);
+
+  { Log the call and exit. }
+
+  trace_add(r^.server, r, cfg, 'x_fixer_upper()');
+    
+  Result := OK;
+end;
+
+{
+ * This routine is called to perform any module-specific logging activities
+ * over and above the normal server things.
+ *
+ * The return value is OK, DECLINED, or HTTP_mumble.  If we return OK, any
+ * remaining modules with an handler for this phase will still be called.
+ }
+function x_logger(r: Prequest_rec): Integer; cdecl;
+var
+  cfg: Px_cfg;
+begin
+  cfg := our_dconfig(r);
+  trace_add(r^.server, r, cfg, 'x_logger()');
+  Result := DECLINED;
+end;
+
+{--------------------------------------------------------------------------}
+{                                                                          }
+{ Which functions are responsible for which hooks in the server.           }
+{                                                                          }
+{--------------------------------------------------------------------------}
+{
+ * Each function our module provides to handle a particular hook is
+ * specified here.  The functions are registered using
+ * ap_hook_foo(name, predecessors, successors, position)
+ * where foo is the name of the hook.
+ *
+ * The args are as follows:
+ * name         ^. the name of the function to call.
+ * predecessors ^. a list of modules whose calls to this hook must be
+ *                 invoked before this module.
+ * successors   ^. a list of modules whose calls to this hook must be
+ *                 invoked after this module.
+ * position     ^. The relative position of this module.  One of
+ *                 APR_HOOK_FIRST, APR_HOOK_MIDDLE, or APR_HOOK_LAST.
+ *                 Most modules will use APR_HOOK_MIDDLE.  If multiple
+ *                 modules use the same relative position, Apache will
+ *                 determine which to call first.
+ *                 If your module relies on another module to run first,
+ *                 or another module running after yours, use the
+ *                 predecessors and/or successors.
+ *
+ * The number in brackets indicates the order in which the routine is called
+ * during request processing.  Note that not all routines are necessarily
+ * called (such as if a resource doesn't have access restrictions).
+ * The actual delivery of content to the browser [9] is not handled by
+ * a hook; see the handler declarations below.
+ }
+procedure x_register_hooks(p: Papr_pool_t); cdecl;
+begin
+    ap_hook_pre_config(@x_pre_config, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_post_config(@x_post_config, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_open_logs(@x_open_logs, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_child_init(@x_child_init, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_handler(@x_handler, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_quick_handler(@x_quick_handler, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_pre_connection(@x_pre_connection, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_process_connection(@x_process_connection, nil, nil, APR_HOOK_MIDDLE);
+    { [1] post read_request handling }
+    ap_hook_post_read_request(@x_post_read_request, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_log_transaction(@x_logger, nil, nil, APR_HOOK_MIDDLE);
+{$ifdef 0}
+    ap_hook_http_method(x_http_method, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_default_port(x_default_port, nil, nil, APR_HOOK_MIDDLE);
+{$endif}
+    ap_hook_translate_name(@x_translate_handler, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_header_parser(@x_header_parser_handler, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_check_user_id(@x_check_user_id, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_fixups(@x_fixer_upper, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_type_checker(@x_type_checker, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_access_checker(@x_access_checker, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_auth_checker(@x_auth_checker, nil, nil, APR_HOOK_MIDDLE);
+    ap_hook_insert_filter(@x_insert_filter, nil, nil, APR_HOOK_MIDDLE);
+end;
+
+{--------------------------------------------------------------------------}
+{                                                                          }
+{ All of the routines have been declared now.  Here's the list of          }
+{ directives specific to our module, and information about where they      }
+{ may appear and how the command parser should pass them to us for         }
+{ processing.  Note that care must be taken to ensure that there are NO    }
+{ collisions of directive names between modules.                           }
+{                                                                          }
+{--------------------------------------------------------------------------}
+var
+  x_cmds: command_rec;
+
+{--------------------------------------------------------------------------}
+{                                                                          }
+{ Finally, the list of callback routines and data structures that provide  }
+{ the static hooks into our module from the other parts of the server.     }
+{                                                                          }
+{--------------------------------------------------------------------------}
+{
+ * Module definition for configuration.  If a particular callback is not
+ * needed, replace its routine name below with the word NULL.
+ }
+
+begin
+  default_module_ptr := @example_module;
+  FillChar(default_module_ptr^, SizeOf(default_module_ptr^), 0);
+  
+  STANDARD20_MODULE_STUFF(default_module_ptr^);
+  
+  { List of directives specific to our module. }
+  
+  with x_cmds do
+  begin
+    name := 'Example';
+    func := @cmd_example;
+    cmd_data := nil;
+    req_override := OR_OPTIONS;
+    args_how := NO_ARGS; // Or RAW_ARGS ?
+    errmsg := 'Example directive - no arguments';
+  end;
+
+  with example_module do
+  begin
+    name := MODULE_NAME;
+    magic := MODULE_MAGIC_COOKIE;
+    create_dir_config := @x_create_dir_config;      { per-directory config creator }
+    merge_dir_config := @x_merge_dir_config;        { dir config merger }
+    create_server_config := @x_create_server_config;{ server config creator }
+    merge_server_config := @x_merge_server_config;  { server config merger }
+    cmds := @x_cmds;                                { command table }
+    register_hooks := @x_register_hooks;            { set up other request processing hooks }
+  end;
+end.
+

+ 131 - 0
packages/base/httpd/examples/mod_hello.pp

@@ -0,0 +1,131 @@
+{*******************************************************************
+*  Test library of the Apache Pascal Headers
+*******************************************************************}
+library mod_hello;
+
+{$i define.inc}
+
+uses SysUtils, httpd {$ifndef Apache1_3}, apr{$endif};
+
+var
+ test_module: module; {$ifdef Unix} public name 'test_module'; {$endif}
+
+const
+  MODULE_NAME = 'mod_hello.so';
+  
+{*******************************************************************
+*  Free Pascal only supports exporting variables on Windows
+*******************************************************************}
+{$ifdef WINDOWS}
+exports
+ test_module name 'test_module';
+{$endif}
+
+{*******************************************************************
+*  Handles apache requests
+*******************************************************************}
+function DefaultHandler(r: Prequest_rec): Integer; cdecl;
+var
+  RequestedHandler: string;
+begin
+  RequestedHandler := r^.handler;
+
+  { We decline to handle a request if hello-handler is not the value of r->handler }
+  if not SameText(RequestedHandler, 'testapache-handler') then
+  begin
+    Result := DECLINED;
+    Exit;
+  end;
+
+  { The following line just prints a message to the errorlog }
+  ap_log_error(MODULE_NAME, 54, APLOG_NOERRNO or APLOG_NOTICE,
+   {$ifndef Apache1_3}0,{$endif} r^.server,
+   'mod_hello: %s', [PChar('Before content is output')]);
+
+  { We set the content type before doing anything else }
+  {$ifdef Apache1_3}
+    r^.content_type := 'text/html';
+    ap_send_http_header(r);
+  {$else}
+    ap_set_content_type(r, 'text/html');
+  {$endif}
+  
+  { If the request is for a header only, and not a request for
+   the whole content, then return OK now. We don't have to do
+   anything else. }
+  if (r^.header_only <> 0) then
+  begin
+    Result := OK;
+    Exit;
+  end;
+
+  { Now we just print the contents of the document using the
+   ap_rputs and ap_rprintf functions. More information about
+   the use of these can be found in http_protocol.inc }
+  ap_rputs(DOCTYPE_HTML_4_0T, r);
+  ap_rputs('<HTML>' + LineEnding, r);
+  ap_rputs('<HEAD>' + LineEnding, r);
+  ap_rputs('<TITLE>Hello There</TITLE>' + LineEnding, r);
+  ap_rputs('</HEAD>' + LineEnding, r);
+  ap_rputs('<BODY BGCOLOR="#FFFFFF">' + LineEnding ,r);
+  ap_rputs('<H1>Hello world</H1>' + LineEnding, r);
+  ap_rputs('This is the first Apache Module working with the new binding from Free Pascal' + LineEnding, r);
+  ap_rprintf(r, '<br>A sample line generated by %s <br>' + LineEnding, [PChar('ap_rprintf')]);
+  ap_rputs('</BODY></HTML>' + LineEnding, r);
+
+  { We can either return OK or DECLINED at this point. If we return
+         * OK, then no other modules will attempt to process this request }
+  Result := OK;
+end;
+
+{*******************************************************************
+*  Registers the hooks
+*******************************************************************}
+{$ifdef apache1_3}
+
+procedure hw_init(s: PServer_rec; p: PPool); cdecl;
+begin
+end;
+
+var
+  hw_handlers: array[0..1] of handler_rec =
+  (
+    (content_type: 'testapache-handler'; handler: @DefaultHandler),
+    (content_type: nil; handler: nil)
+  );
+
+{$else}
+
+procedure RegisterHooks(p: Papr_pool_t); cdecl;
+begin
+  ap_hook_handler(@DefaultHandler, nil, nil, APR_HOOK_MIDDLE);
+end;
+
+{$endif}
+
+{*******************************************************************
+*  Library initialization code
+*******************************************************************}
+begin
+  FillChar(test_module, SizeOf(test_module), 0);
+
+  {$ifdef apache1_3}
+    STANDARD_MODULE_STUFF(test_module);
+
+    with test_module do
+    begin
+      name := MODULE_NAME;
+      init := @hw_init;
+      handlers := hw_handlers;
+    end;
+  {$else}
+    STANDARD20_MODULE_STUFF(test_module);
+
+    with test_module do
+    begin
+      name := MODULE_NAME;
+      register_hooks := @RegisterHooks;
+    end;
+  {$endif}
+end.
+

+ 654 - 0
packages/base/httpd/examples/mod_spelling.pp

@@ -0,0 +1,654 @@
+{* Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *}
+library mod_spelling;
+
+{$i define.inc}
+
+uses SysUtils, Classes, httpd, apr;
+
+var
+  speling_module: module; {$ifdef Unix} cvar; public; {$endif}
+  default_module_ptr: Pmodule;
+
+const
+  MODULE_NAME = 'mod_speling.so';
+
+{*******************************************************************
+*  Free Pascal only supports exporting variables on Windows
+*******************************************************************}
+{$ifdef WINDOWS}
+exports
+  speling_module name 'speling_module';
+{$endif}
+
+{#include "apr.h"
+#include "apr_file_io.h"
+#include "apr_strings.h"
+#include "apr_lib.h"
+
+#define APR_WANT_STRFUNC
+#include "apr_want.h"
+
+#define WANT_BASENAME_MATCH
+
+#include "httpd.h"
+#include "http_core.h"
+#include "http_config.h"
+#include "http_request.h"
+#include "http_log.h" }
+
+{* mod_speling.c - by Alexei Kosut <[email protected]> June, 1996
+ *
+ * Translated to pascal by Felipe Monteiro de Carvalho - July, 2006
+ *
+ * This module is transparent, and simple. It attempts to correct
+ * misspellings of URLs that users might have entered, namely by checking
+ * capitalizations. If it finds a match, it sends a redirect.
+ *
+ * 08-Aug-1997 <[email protected]>
+ * o Upgraded module interface to apache_1.3a2-dev API (more NULL's in
+ *   speling_module).
+ * o Integrated tcsh's "spelling correction" routine which allows one
+ *   misspelling (character insertion/omission/typo/transposition).
+ *   Rewrote it to ignore case as well. This ought to catch the majority
+ *   of misspelled requests.
+ * o Commented out the second pass where files' suffixes are stripped.
+ *   Given the better hit rate of the first pass, this rather ugly
+ *   (request index.html, receive index.db ?!?!) solution can be
+ *   omitted.
+ * o wrote a "kind of" html page for mod_speling
+ *
+ * Activate it with "CheckSpelling On"
+ }
+
+type
+  spconfig = record
+    enabled: Integer;
+  end;
+  
+  Pspconfig = ^spconfig;
+
+{
+ * Create a configuration specific to this module for a server or directory
+ * location, and fill it with the default settings.
+ *
+ * The API says that in the absence of a merge function, the record for the
+ * closest ancestor is used exclusively.  That's what we want, so we don't
+ * bother to have such a function.
+ }
+
+function mkconfig(p: Papr_pool_t): Pointer;
+var
+  cfg: Pspconfig;
+begin
+  cfg := apr_pcalloc(p, sizeof(spconfig));
+  cfg^.enabled := 0;
+  Result := cfg;
+end;
+
+{
+ * Respond to a callback to create configuration record for a server or
+ * vhost environment.
+ }
+function create_mconfig_for_server(p: Papr_pool_t; s: Pserver_rec): Pointer; cdecl;
+begin
+  Result := mkconfig(p);
+end;
+
+{
+ * Respond to a callback to create a config record for a specific directory.
+ }
+function create_mconfig_for_directory(p: Papr_pool_t; dir: PChar): Pointer; cdecl;
+begin
+  Result := mkconfig(p);
+end;
+
+{
+ * Handler for the CheckSpelling directive, which is FLAG.
+ }
+function set_speling(cmd: Pcmd_parms; mconfig: Pointer; arg: Integer): PChar; cdecl;
+var
+  cfg: Pspconfig;
+begin
+  cfg := Pspconfig(mconfig);
+  cfg^.enabled := arg;
+  Result := nil;
+end;
+
+  {* Define the directives specific to this module.  This structure is referenced
+   * later by the 'module' structure. }
+
+var
+  speling_cmds: command_rec;
+
+type
+  sp_reason = (
+    SP_IDENTICAL = 0,
+    SP_MISCAPITALIZED = 1,
+    SP_TRANSPOSITION = 2,
+    SP_MISSINGCHAR = 3,
+    SP_EXTRACHAR = 4,
+    SP_SIMPLETYPO = 5,
+    SP_VERYDIFFERENT = 6
+  );
+
+const
+  sp_reason_str: array [0..7] of PChar =
+  (
+    'identical',
+    'miscapitalized',
+    'transposed characters',
+    'character missing',
+    'extra character',
+    'mistyped character',
+    'common basename',
+    nil
+  );
+
+type
+  misspelled_file = record
+    name: PChar;
+    quality: sp_reason;
+  end;
+  
+  Pmisspelled_file = ^misspelled_file;
+
+{
+ * spdist() is taken from Kernighan & Pike,
+ *  _The_UNIX_Programming_Environment_
+ * and adapted somewhat to correspond better to psychological reality.
+ * (Note the changes to the return values)
+ *
+ * According to Pollock and Zamora, CACM April 1984 (V. 27, No. 4),
+ * page 363, the correct order for this is:
+ * OMISSION = TRANSPOSITION > INSERTION > SUBSTITUTION
+ * thus, it was exactly backwards in the old version. -- PWP
+ *
+ * This routine was taken out of tcsh's spelling correction code
+ * (tcsh-6.07.04) and re-converted to apache data types ("char" type
+ * instead of tcsh's NLS'ed "Char"). Plus it now ignores the case
+ * during comparisons, so is a "approximate strcasecmp()".
+ * NOTE that is still allows only _one_ real "typo",
+ * it does NOT try to correct multiple errors.
+ }
+{
+  Extra notes about how this function works:
+  
+  * s and t are supposed different
+  
+  * s
+}
+function spdist(const cs, ct: PChar): sp_reason;
+var
+  s, t, i, j: PChar;
+begin
+  s := cs;
+  t := ct;
+
+  while apr_tolower(s^) = apr_tolower(t^) do
+  begin
+    if t^ = #0 then
+    begin
+      Result := SP_MISCAPITALIZED;   { exact match (sans case) }
+      Exit;
+    end;
+
+    Inc(s);
+    Inc(t);
+  end;
+
+  if s^ <> #0 then
+  begin
+    if t^ <> #0 then
+    begin
+      i := s;
+      Inc(i);
+      j := t;
+      Inc(j);
+    
+      if Integer(i^) and Integer(j^) <> 0 then
+       if (apr_tolower(s^) = apr_tolower(j^)) and (apr_tolower(t^) = apr_tolower(i^)) then
+       begin
+         Inc(i);
+         Inc(j);
+        
+         if stricomp(i, j) = 0 then
+         begin
+           Result := SP_TRANSPOSITION;        { transposition }
+           Exit;
+         end;
+       end;
+      
+      Dec(i);
+      Dec(j);
+      
+      if (stricomp(i, j) = 0) then
+      begin
+        Result := SP_SIMPLETYPO;   { 1 char mismatch }
+        Exit;
+      end;
+    end;
+    
+    
+    if (stricomp(i, t) = 0) then
+    begin
+      Result := SP_EXTRACHAR;        { extra character }
+      Exit;
+    end;
+  end;
+
+  if (t^ <> #0) and (stricomp(s, t + 1) = 0) then
+  begin
+    Result := SP_MISSINGCHAR;  { missing character }
+    Exit;
+  end;
+
+  Result := SP_VERYDIFFERENT;    { distance too large to fix. }
+end;
+
+function sort_by_quality(left, rite: Pointer): Integer;
+begin
+  Result := Integer(Pmisspelled_file(left)^.quality) - Integer(Pmisspelled_file(rite)^.quality);
+end;
+
+function check_speling(r: Prequest_rec): Integer; cdecl;
+var
+  cfg: Pspconfig;
+  good, bad, postgood, url: PChar;
+  dirent: apr_finfo_t;
+  filoc, dotloc, urlen, pglen: Integer;
+  candidates: Papr_array_header_t = nil;
+  dir: Papr_dir_t;
+  q: sp_reason;
+  sp_new, variant_, nvariant_: Pmisspelled_file;
+  nuri, ref, vuri, reason: PChar;
+  i, entloc: Integer;
+  p, sub_pool: Papr_pool_t;
+  notes: Papr_table_t;
+  t, v: Papr_array_header_t;
+  List: TList;
+  plist: Pointer;
+begin
+  cfg := Pspconfig(ap_get_module_config(r^.per_dir_config, @speling_module));
+  if (cfg^ .enabled = 0) then
+  begin
+    Result := DECLINED;
+    Exit;
+  end;
+
+  { We only want to worry about GETs }
+  if (r^.method_number <> M_GET) then
+  begin
+    Result := DECLINED;
+    Exit;
+  end;
+
+  { We've already got a file of some kind or another }
+  if (Integer(r^.finfo.filetype) <> 0) then
+  begin
+    Result := DECLINED;
+    Exit;
+  end;
+
+  { Not a file request }
+  if (r^.proxyreq or not r^.filename) then
+  begin
+    Result := DECLINED;
+    Exit;
+  end;
+
+  { This is a sub request - don't mess with it }
+  if (r^.main <> nil) then
+  begin
+    Result := DECLINED;
+    Exit;
+  end;
+
+  {
+   * The request should end up looking like this:
+   * r->uri: /correct-url/mispelling/more
+   * r->filename: /correct-file/mispelling r->path_info: /more
+   *
+   * So we do this in steps. First break r->filename into two pieces
+   }
+
+  filoc := ap_rind(r^.filename, '/');
+  {
+   * Don't do anything if the request doesn't contain a slash, or
+   * requests "/"
+   }
+  if (filoc = -1) or (strcomp(r^.uri, '/') = 0) then
+  begin
+    Result := DECLINED;
+    Exit;
+  end;
+
+  { good = /correct-file }
+  good := apr_pstrndup(r^.pool, r^.filename, filoc);
+  { bad = mispelling }
+  bad := apr_pstrdup(r^.pool, r^.filename + filoc + 1);
+  { postgood = mispelling/more }
+  postgood := apr_pstrcat(r^.pool, [bad, r^.path_info, nil]);
+
+  urlen := strlen(r^.uri);
+  pglen := strlen(postgood);
+
+  { Check to see if the URL pieces add up }
+  if (strcomp(postgood, r^.uri + (urlen - pglen))) <> 0 then
+  begin
+    Result := DECLINED;
+    Exit;
+  end;
+
+  { url = /correct-url }
+  url := apr_pstrndup(r^.pool, r^.uri, (urlen - pglen));
+
+  { Now open the directory and do ourselves a check... }
+  if (apr_dir_open(@dir, good, r^.pool) <> APR_SUCCESS) then
+      { Oops, not a directory... }
+  begin
+    Result := DECLINED;
+    Exit;
+  end;
+
+  candidates := apr_array_make(r^.pool, 2, sizeof(misspelled_file));
+
+  dotloc := ap_ind(bad, '.');
+
+  if (dotloc = -1) then dotloc := strlen(bad);
+
+  while (apr_dir_read(@dirent, APR_FINFO_DIRENT, dir) = APR_SUCCESS) do
+  begin
+    {
+     * If we end up with a "fixed" URL which is identical to the
+     * requested one, we must have found a broken symlink or some such.
+     * Do _not_ try to redirect this, it causes a loop!
+     }
+    if (strcomp(bad, dirent.name) = 0) then
+    begin
+      apr_dir_close(dir);
+      Result := OK;
+    end
+
+    {
+     * miscapitalization errors are checked first (like, e.g., lower case
+     * file, upper case request)
+     }
+    else if (stricomp(bad, dirent.name) = 0) then
+    begin
+      sp_new := Pmisspelled_file(apr_array_push(candidates));
+      sp_new^.name := apr_pstrdup(r^.pool, dirent.name);
+      sp_new^.quality := SP_MISCAPITALIZED;
+    end
+
+    {
+     * simple typing errors are checked next (like, e.g.,
+     * missing/extra/transposed char)
+     }
+    else if (spdist(bad, dirent.name) <> SP_VERYDIFFERENT) then
+    begin
+      q := spdist(bad, dirent.name);
+        
+      sp_new := Pmisspelled_file(apr_array_push(candidates));
+      sp_new^.name := apr_pstrdup(r^.pool, dirent.name);
+      sp_new^.quality := q;
+    end
+
+    {
+     * The spdist() should have found the majority of the misspelled
+     * requests.  It is of questionable use to continue looking for
+     * files with the same base name, but potentially of totally wrong
+     * type (index.html <-> index.db).
+     * I would propose to not set the WANT_BASENAME_MATCH define.
+     *      08-Aug-1997 <[email protected]>
+     *
+     * However, Alexei replied giving some reasons to add it anyway:
+     * > Oh, by the way, I remembered why having the
+     * > extension-stripping-and-matching stuff is a good idea:
+     * >
+     * > If you're using MultiViews, and have a file named foobar.html,
+     * > which you refer to as "foobar", and someone tried to access
+     * > "Foobar", mod_speling won't find it, because it won't find
+     * > anything matching that spelling. With the extension-munging,
+     * > it would locate "foobar.html". Not perfect, but I ran into
+     * > that problem when I first wrote the module.
+     }
+    else
+    begin
+{$ifdef WANT_BASENAME_MATCH}
+      {
+       * Okay... we didn't find anything. Now we take out the hard-core
+       * power tools. There are several cases here. Someone might have
+       * entered a wrong extension (.htm instead of .html or vice
+       * versa) or the document could be negotiated. At any rate, now
+       * we just compare stuff before the first dot. If it matches, we
+       * figure we got us a match. This can result in wrong things if
+       * there are files of different content types but the same prefix
+       * (e.g. foo.gif and foo.html) This code will pick the first one
+       * it finds. Better than a Not Found, though.
+       }
+      entloc := ap_ind(dirent.name, '.');
+      if (entloc = -1) then entloc := strlen(dirent.name);
+
+      if ((dotloc = entloc) and not strncasecmp(bad, dirent.name, dotloc)) then
+      begin
+	sp_new := Pmisspelled_file(apr_array_push(candidates));
+        sp_new^.name := apr_pstrdup(r^.pool, dirent.name);
+        sp_new^.quality := SP_VERYDIFFERENT;
+      end;
+{$endif}
+    end;
+  end;
+    
+  apr_dir_close(dir);
+
+  if (candidates^.nelts <> 0) then
+  begin
+    { Wow... we found us a mispelling. Construct a fixed url }
+    variant_ := Pmisspelled_file(candidates^.elts);
+
+    ref := apr_table_get(r^.headers_in, 'Referer');
+
+    List := TList.Create;
+    
+    try
+      for i := 0 to candidates^.nelts - 1 do
+      begin
+        plist := Pointer(candidates^.elts);
+        Inc(plist, sizeof(misspelled_file));
+        List.Add(plist);
+      end;
+
+      List.Sort(@sort_by_quality);
+    finally
+      List.Free;
+    end;
+
+    {
+     * Conditions for immediate redirection:
+     *     a) the first candidate was not found by stripping the suffix
+     * AND b) there exists only one candidate OR the best match is not
+     *         ambiguous
+     * then return a redirection right away.
+     }
+    nvariant_ := variant_;
+    Inc(nvariant_, sizeof(misspelled_file));
+     
+    if (variant_^.quality <> SP_VERYDIFFERENT) and ( (candidates^.nelts = 1)
+     or (Integer(variant_^.quality) <> Integer(nvariant_^.quality))) then
+    begin
+      nuri := ap_escape_uri(r^.pool, apr_pstrcat(r^.pool, [url,
+						     variant_^.name,
+						     r^.path_info, nil]));
+      if (r^.parsed_uri.query^ <> #0) then
+       nuri := apr_pstrcat(r^.pool, [nuri, PChar('?'), r^.parsed_uri.query, nil]);
+
+      apr_table_setn(r^.headers_out, 'Location',
+			  ap_construct_url(r^.pool, nuri, r));
+
+      if ref^ <> #0 then
+       ap_log_rerror(MODULE_NAME, 506, APLOG_INFO, APR_SUCCESS,
+        r, 'Fixed spelling: %s to %s from %s',  [r^.uri, nuri, ref])
+      else
+       ap_log_rerror(MODULE_NAME, 506, APLOG_INFO, APR_SUCCESS,
+        r, 'Fixed spelling: %s to %s',  [r^.uri, nuri, ref]);
+
+      Result := HTTP_MOVED_PERMANENTLY;
+      Exit;
+    end
+    {
+     * Otherwise, a "[300] Multiple Choices" list with the variants is
+     * returned.
+     }
+    else
+    begin
+      if (r^.main = nil) then
+      begin
+        p := r^.pool;
+        notes := r^.notes;
+      end
+      else
+      begin
+        p := r^.main^.pool;
+        notes := r^.main^.notes;
+      end;
+
+      if (apr_pool_create(@sub_pool, p) <> APR_SUCCESS) then
+      begin
+        Result := DECLINED;
+        Exit;
+      end;
+          
+      t := apr_array_make(sub_pool, candidates^.nelts * 8 + 8, sizeof(PChar));
+      v := apr_array_make(sub_pool, candidates^.nelts * 5, sizeof(PChar));
+
+       { Generate the response text. }
+
+      PPChar(apr_array_push(t))^ := 'The document name you requested (<code>';
+      PPChar(apr_array_push(t))^ := ap_escape_html(sub_pool, r^.uri);
+      PPChar(apr_array_push(t))^ :=
+		   '</code>) could not be found on this server.' + LineEnding +
+		   'However, we found documents with names similar ' +
+		   'to the one you requested.<p>' +
+		   'Available documents:' + LineEnding + '<ul>' + LineEnding;
+
+            for i := 0 to candidates^.nelts -1 do
+            begin
+		reason := sp_reason_str[Integer(variant_[i].quality)];
+                { The format isn't very neat... }
+                if r^.parsed_uri.query <> nil then
+                 vuri := apr_pstrcat(sub_pool, [url, variant_[i].name, r^.path_info,
+                  '?', r^.parsed_uri.query, nil])
+                else vuri := apr_pstrcat(sub_pool, [url, variant_[i].name, r^.path_info,
+		 PChar(''), PChar(''), nil]);
+   
+		PPChar(apr_array_push(v))^ := '"';
+		PPChar(apr_array_push(v))^ := ap_escape_uri(sub_pool, vuri);
+		PPChar(apr_array_push(v))^ := '";"';
+		PPChar(apr_array_push(v))^ := reason;
+		PPChar(apr_array_push(v))^ := '"';
+
+		PPChar(apr_array_push(t))^ := '<li><a href="';
+		PPChar(apr_array_push(t))^ := ap_escape_uri(sub_pool, vuri);
+		PPChar(apr_array_push(t))^ := '">';
+		PPChar(apr_array_push(t))^ := ap_escape_html(sub_pool, vuri);
+		PPChar(apr_array_push(t))^ := '</a> (';
+		PPChar(apr_array_push(t))^ := reason;
+		PPChar(apr_array_push(t))^ := ')' + LineEnding;
+
+                {
+                 * when we have printed the "close matches" and there are
+                 * more "distant matches" (matched by stripping the suffix),
+                 * then we insert an additional separator text to suggest
+                 * that the user LOOK CLOSELY whether these are really the
+                 * files she wanted.
+                 }
+                if (i > 0) and (i < candidates^.nelts - 1)
+                    and (variant_[i].quality <> SP_VERYDIFFERENT)
+                    and (variant_[i + 1].quality = SP_VERYDIFFERENT) then
+                 PPChar(apr_array_push(t))^ :=
+		  '</ul>' + LineEnding + 'Furthermore, the following related ' +
+                  'documents were found:' + LineEnding + '<ul>' + LineEnding;
+            end;
+            
+	    PPChar(apr_array_push(t))^ := '</ul>' + LineEnding;
+
+            { If we know there was a referring page, add a note: }
+            if (ref <> nil) then
+            begin
+              PPChar(apr_array_push(t))^ :=
+	       'Please consider informing the owner of the <a href="';
+	      PPChar(apr_array_push(t))^ := ap_escape_uri(sub_pool, ref);
+              PPChar(apr_array_push(t))^ := '">referring page</a> about the broken link.' + LineEnding;
+            end;
+
+            { Pass our apr_table_t to http_protocol.c (see mod_negotiation): }
+            apr_table_setn(notes, 'variant-list', apr_array_pstrcat(p, t, #0));
+
+	    apr_table_mergen(r^.subprocess_env, 'VARIANTS', apr_array_pstrcat(p, v, ','));
+
+	    apr_pool_destroy(sub_pool);
+
+            if ref <> '' then
+             ap_log_rerror(MODULE_NAME, 609, APLOG_INFO, 0, r,
+	      'Spelling fix: %s: %d candidates from %s', [r^.uri, candidates^.nelts, ref])
+            else ap_log_rerror(MODULE_NAME, 609, APLOG_INFO, 0, r,
+	      'Spelling fix: %s: %d candidates', [r^.uri, candidates^.nelts, ref]);
+
+            Result := HTTP_MULTIPLE_CHOICES;
+        end;
+    end;
+
+    Result := OK;
+end;
+
+procedure register_hooks_(p: Papr_pool_t); cdecl;
+begin
+  ap_hook_fixups(@check_speling, nil, nil, APR_HOOK_LAST);
+end;
+
+begin
+  default_module_ptr := @speling_module;
+  FillChar(default_module_ptr^, SizeOf(default_module_ptr^), 0);
+
+  STANDARD20_MODULE_STUFF(default_module_ptr^);
+
+  {* Define the directives specific to this module.  This structure is referenced
+   * later by the 'module' structure. }
+   
+  with speling_cmds do
+  begin
+    name := 'CheckSpelling';
+    func := cmd_func(@set_speling);
+    cmd_data := nil;
+    req_override := OR_OPTIONS;
+    args_how := FLAG;
+    errmsg := 'whether or not to fix miscapitalized/misspelled requests';
+  end;
+
+  with speling_module do
+  begin
+    name := MODULE_NAME;
+    magic := MODULE_MAGIC_COOKIE;
+    create_dir_config := @create_mconfig_for_directory;    { per-directory config creator }
+    merge_dir_config := nil;     { dir config merger }
+    create_server_config := @create_mconfig_for_server; { server config creator }
+    merge_server_config := nil;  { server config merger }
+    cmds := @speling_cmds;                 { command table }
+    register_hooks := @register_hooks_; { set up other request processing hooks }
+  end;
+end.
+

+ 41 - 0
packages/base/httpd/examples/testmodule.pp

@@ -0,0 +1,41 @@
+{*******************************************************************
+*  Test library of the Apache Pascal Headers
+*******************************************************************}
+library testmodule;
+
+{$i define.inc}
+
+{*******************************************************************
+*  Assembler code to export variables on UNIXes
+*******************************************************************}
+uses
+ minimain in 'minimain.pas';
+
+var
+ test_module: module; {$ifdef Unix} public name 'test_module'; {$endif}
+ default_module_ptr: Pmodule;
+
+{*******************************************************************
+*  Free Pascal only supports exporting variables on Windows
+*******************************************************************}
+{$ifdef WINDOWS}
+exports
+ test_module name 'test_module';
+{$endif}
+
+{*******************************************************************
+*  Library initialization code
+*******************************************************************}
+begin
+  default_module_ptr := @test_module;
+  FillChar(default_module_ptr^, SizeOf(default_module_ptr^), 0);
+  with default_module_ptr^ do begin
+    version := MODULE_MAGIC_NUMBER_MAJOR;
+    minor_version := MODULE_MAGIC_NUMBER_MINOR;
+    module_index := -1;
+    name := 'testmodule.so';
+    magic := MODULE_MAGIC_COOKIE;
+    register_hooks := @RegisterHooks;
+  end;
+end.
+

+ 1625 - 0
packages/base/httpd/httpd-1.3/Makefile

@@ -0,0 +1,1625 @@
+#
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/08/20]
+#
+default: all
+MAKEFILETARGETS=i386-linux
+BSDs = freebsd netbsd openbsd darwin
+UNIXs = linux $(BSDs) solaris qnx
+LIMIT83fs = go32v2 os2 emx watcom
+FORCE:
+.PHONY: FORCE
+override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
+ifneq ($(findstring darwin,$(OSTYPE)),)
+inUnix=1 #darwin
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+endif
+SEARCHPATH+=$(patsubst %/,%,$(subst \,/,$(dir $(MAKE))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygdrive,$(PATH)),)
+inCygWin=1
+endif
+endif
+ifdef inUnix
+SRCBATCHEXT=.sh
+else
+ifdef inOS2
+SRCBATCHEXT=.cmd
+else
+SRCBATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+ifdef inCygWin
+PATHSEP=/
+endif
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+ifdef inOS2
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=echo
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+endif
+override DEFAULT_FPCDIR=../../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+else
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+FOUNDFPC:=$(strip $(wildcard $(FPC)))
+ifeq ($(FOUNDFPC),)
+FOUNDFPC=$(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))
+ifeq ($(FOUNDFPC),)
+$(error Compiler $(FPC) not found)
+endif
+endif
+ifndef FPC_COMPILERINFO
+FPC_COMPILERINFO:=$(shell $(FPC) -iVSPTPSOTO)
+endif
+ifndef FPC_VERSION
+FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO))
+endif
+export FPC FPC_VERSION FPC_COMPILERINFO
+unexport CHECKDEPEND ALLDEPENDENCIES
+ifndef CPU_TARGET
+ifdef CPU_TARGET_DEFAULT
+CPU_TARGET=$(CPU_TARGET_DEFAULT)
+endif
+endif
+ifndef OS_TARGET
+ifdef OS_TARGET_DEFAULT
+OS_TARGET=$(OS_TARGET_DEFAULT)
+endif
+endif
+ifneq ($(words $(FPC_COMPILERINFO)),5)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSO)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTO)
+endif
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 2,$(FPC_COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 3,$(FPC_COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 4,$(FPC_COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+TARGETSUFFIX=$(OS_TARGET)
+SOURCESUFFIX=$(OS_SOURCE)
+else
+TARGETSUFFIX=$(FULL_TARGET)
+SOURCESUFFIX=$(FULL_SOURCE)
+endif
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first)
+endif
+endif
+ifneq ($(findstring $(OS_TARGET),$(BSDs)),)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),linux)
+linuxHier=1
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(BASEDIR)
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+endif
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
+endif
+ifndef BINUTILSPREFIX
+ifndef CROSSBINDIR
+ifdef CROSSCOMPILE
+BINUTILSPREFIX=$(CPU_TARGET)-$(OS_TARGET)-
+endif
+endif
+endif
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX))
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=httpd-1.3
+override PACKAGE_VERSION=2.0.4
+ifeq ($(FULL_TARGET),i386-linux)
+override TARGET_UNITS+=httpd
+endif
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifneq ($(findstring $(OS_TARGET),$(UNIXs)),)
+UNIXHier=1
+endif
+else
+ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),)
+UNIXHier=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXHier
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifdef INSTALL_FPCSUBDIR
+export INSTALL_FPCSUBDIR
+endif
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef COMPILER_UNITTARGETDIR
+ifdef PACKAGEDIR_MAIN
+COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX)
+else
+COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX)
+endif
+endif
+ifndef COMPILER_TARGETDIR
+COMPILER_TARGETDIR=.
+endif
+ifndef INSTALL_BASEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXHier
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+ifdef CROSSCOMPILE
+ifdef CROSSINSTALL
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(SOURCESUFFIX)
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXHier
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXHier
+ifdef BSDhier
+SRCPREFIXDIR=share/src
+else
+ifdef linuxHier
+SRCPREFIXDIR=share/src
+else
+SRCPREFIXDIR=src
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXHier
+ifdef BSDhier
+DOCPREFIXDIR=share/doc
+else
+ifdef linuxHier
+DOCPREFIXDIR=share/doc
+else
+DOCPREFIXDIR=doc
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifndef INSTALL_SHAREDDIR
+INSTALL_SHAREDDIR=$(INSTALL_PREFIX)/lib
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(SOURCESUFFIX))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(TARGETSUFFIX)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+ifeq ($(OS_SOURCE),linux)
+ifndef GCCLIBDIR
+ifeq ($(CPU_TARGET),i386)
+ifneq ($(findstring x86_64,$(shell uname -a)),)
+ifeq ($(BINUTILSPREFIX),)
+GCCLIBDIR:=$(shell dirname `gcc -m32 -print-libgcc-file-name`)
+endif
+endif
+endif
+ifeq ($(CPU_TARGET),powerpc64)
+ifeq ($(BINUTILSPREFIX),)
+GCCLIBDIR:=$(shell dirname `gcc -m64 -print-libgcc-file-name`)
+endif
+endif
+endif
+ifndef GCCLIBDIR
+CROSSGCC=$(strip $(wildcard $(addsuffix /$(BINUTILSPREFIX)gcc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(CROSSGCC),)
+GCCLIBDIR:=$(shell dirname `$(CROSSGCC) -print-libgcc-file-name`)
+endif
+endif
+ifndef OTHERLIBDIR
+OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
+endif
+endif
+ifdef inUnix
+ifeq ($(OS_SOURCE),netbsd)
+OTHERLIBDIR+=/usr/pkg/lib
+endif
+export GCCLIBDIR OTHERLIB
+endif
+BATCHEXT=.bat
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+SHAREDLIBPREFIX=libfp
+STATICLIBPREFIX=libp
+IMPORTLIBPREFIX=libimp
+RSTEXT=.rst
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),go32v1)
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+OEXT=.obj
+ASMEXT=.asm
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),emx)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=emx
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),morphos)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=mos
+endif
+ifeq ($(OS_TARGET),atari)
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+ifeq ($(OS_TARGET),darwin)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=dwn
+endif
+ifeq ($(OS_TARGET),gba)
+EXEEXT=.gba
+SHAREDLIBEXT=.so
+SHORTSUFFIX=gba
+endif
+else
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.sl2
+STATICLIBPREFIX=
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+FPCMADE=fpcmade.$(SHORTSUFFIX)
+ZIPSUFFIX=$(SHORTSUFFIX)
+ZIPCROSSPREFIX=
+ZIPSOURCESUFFIX=src
+ZIPEXAMPLESUFFIX=exm
+else
+FPCMADE=fpcmade.$(TARGETSUFFIX)
+ZIPSOURCESUFFIX=.source
+ZIPEXAMPLESUFFIX=.examples
+ifdef CROSSCOMPILE
+ZIPSUFFIX=.$(SOURCESUFFIX)
+ZIPCROSSPREFIX=$(TARGETSUFFIX)-
+else
+ZIPSUFFIX=.$(TARGETSUFFIX)
+ZIPCROSSPREFIX=
+endif
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO= __missing_command_ECHO
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE= __missing_command_DATE
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL= __missing_command_GINSTALL
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG= __missing_command_CPPROG
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG= __missing_command_RMPROG
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG= __missing_command_MVPROG
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef MKDIRPROG
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG= __missing_command_MKDIRPROG
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+endif
+export MKDIRPROG
+ifndef ECHOREDIR
+ifndef inUnix
+ECHOREDIR=echo
+else
+ECHOREDIR=$(ECHO)
+endif
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -Rfp
+endif
+ifndef MKDIRTREE
+MKDIRTREE:=$(MKDIRPROG) -p
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE= __missing_command_PPUMOVE
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE= __missing_command_FPCMAKE
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG= __missing_command_ZIPPROG
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /gtar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG= __missing_command_TARPROG
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=$(BINUTILSPREFIX)as
+LDNAME=$(BINUTILSPREFIX)ld
+ARNAME=$(BINUTILSPREFIX)ar
+RCNAME=$(BINUTILSPREFIX)rc
+ifneq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),win32)
+ifeq ($(CROSSBINDIR),)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+endif
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(SRCBATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vj
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(FULL_TARGET),i386-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_RTL)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_RTL) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifneq ($(CPU_TARGET),$(CPU_SOURCE))
+override FPCOPT+=-P$(CPU_TARGET)
+endif
+ifeq ($(OS_SOURCE),openbsd)
+override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
+endif
+ifndef CROSSBOOTSTRAP
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-XP$(BINUTILSPREFIX) -Xc
+endif
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-Xr$(RLINKPATH)
+endif
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifneq ($(findstring 2.0.,$(FPC_VERSION)),)
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+endif
+ifeq ($(CPU_TARGET),powerpc)
+FPCCPUOPT:=-O1r
+endif
+else
+FPCCPUOPT:=-O1r
+endif
+override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+override FPCOPT+=-O2
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef CREATESHARED
+override FPCOPT+=-Cg
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-Aas
+endif
+endif
+ifdef LINKSHARED
+endif
+ifdef GCCLIBDIR
+override FPCOPT+=-Fl$(GCCLIBDIR)
+endif
+ifdef OTHERLIBDIR
+override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override AFULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+override AFULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(AFULL_TARGET),$(AFULL_SOURCE))
+override ACROSSCOMPILE=1
+endif
+ifdef ACROSSCOMPILE
+override FPCOPT+=$(CROSSOPT)
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifneq ($(TARGET_UNITS),)
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(COMPILER_UNITTARGETDIR) $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release fpc_shared
+$(FPCMADE): $(ALLDEPENDENCIES) $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .lpr .dpr .pp .rc .res
+$(COMPILER_UNITTARGETDIR):
+	$(MKDIRTREE) $(COMPILER_UNITTARGETDIR)
+$(COMPILER_TARGETDIR):
+	$(MKDIRTREE) $(COMPILER_TARGETDIR)
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.lpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.dpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.lpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.dpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(OEXT) $(COMPILER_UNITTARGETDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_shared
+override INSTALLTARGET+=fpc_shared_install
+ifndef SHARED_LIBVERSION
+SHARED_LIBVERSION=$(FPC_VERSION)
+endif
+ifndef SHARED_LIBNAME
+SHARED_LIBNAME=$(PACKAGE_NAME)
+endif
+ifndef SHARED_FULLNAME
+SHARED_FULLNAME=$(SHAREDLIBPREFIX)$(SHARED_LIBNAME)-$(SHARED_LIBVERSION)$(SHAREDLIBEXT)
+endif
+ifndef SHARED_LIBUNITS
+SHARED_LIBUNITS:=$(TARGET_UNITS) $(TARGET_IMPLICITUNITS)
+override SHARED_LIBUNITS:=$(filter-out $(INSTALL_BUILDUNIT),$(SHARED_LIBUNITS))
+endif
+fpc_shared:
+ifdef HASSHAREDLIB
+	$(MAKE) all CREATESHARED=1 LINKSHARED=1 CREATESMART=1
+ifneq ($(SHARED_BUILD),n)
+	$(PPUMOVE) -q $(SHARED_LIBUNITS) -i$(COMPILER_UNITTARGETDIR) -o$(SHARED_FULLNAME) -d$(COMPILER_UNITTARGETDIR)
+endif
+else
+	@$(ECHO) Shared Libraries not supported
+endif
+fpc_shared_install:
+ifneq ($(SHARED_BUILD),n)
+ifneq ($(SHARED_LIBUNITS),)
+ifneq ($(wildcard $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME)),)
+	$(INSTALL) $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME) $(INSTALL_SHAREDDIR)
+endif
+endif
+endif
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT)$(PPUEXT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+ifneq ($(UNITTARGETDIRPREFIX),)
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPUFILES)))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPULINKFILES))))
+endif
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+ifneq ($(TARGETDIRPREFIX),)
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(notdir $(INSTALLEXEFILES)))
+endif
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR)/* $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(PACKAGE_NAME)
+endif
+endif
+ifndef FULLZIPNAME
+FULLZIPNAME=$(ZIPCROSSPREFIX)$(ZIPPREFIX)$(ZIPNAME)$(ZIPSUFFIX)
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(SRCBATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=$(ZIPSOURCESUFFIX)
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=$(ZIPEXAMPLESUFFIX)
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+ifdef DEBUGSYMEXT
+override CLEANPPULINKFILES+=$(subst $(PPUEXT),$(DEBUGSYMEXT),$(CLEANPPUFILES))
+endif
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *$(ASMEXT) *_ppas$(BATCHEXT)
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef COMPILER_UNITTARGETDIR
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+endif
+	-$(DELTREE) units
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+ifneq ($(PPUEXT),.ppu)
+	-$(DEL) *.o *.ppu *.a
+endif
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) fpcmade.* Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *_ppas$(BATCHEXT)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+ifdef DEBUGSYMEXT
+	-$(DEL) *$(DEBUGSYMEXT)
+endif
+fpc_distclean: cleanall
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Source.. $(FULL_SOURCE)
+	@$(ECHO)  Full Target.. $(FULL_TARGET)
+	@$(ECHO)  SourceSuffix. $(SOURCESUFFIX)
+	@$(ECHO)  TargetSuffix. $(TARGETSUFFIX)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Shell..... $(SHELL)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipName.............. $(ZIPNAME)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipCrossPrefix....... $(ZIPCROSSPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  FullZipName.......... $(FULLZIPNAME)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+units: fpc_units
+examples:
+shared: fpc_shared
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release units examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 19 - 0
packages/base/httpd/httpd-1.3/Makefile.fpc

@@ -0,0 +1,19 @@
+#
+#  Makefile.fpc for httpd 1.3 unit
+#
+
+[package]
+name=httpd-1.3
+version=2.0.4
+
+[target]
+units=httpd
+
+[require]
+libc=y
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../../..

+ 175 - 0
packages/base/httpd/httpd-1.3/ap.inc

@@ -0,0 +1,175 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * The ap_vsnprintf/ap_snprintf functions are based on, and used with the
+ * permission of, the  SIO stdio-replacement strx_* functions by Panos
+ * Tsirigotis <[email protected]> for xinetd.
+ }
+
+function ap_cpystrn(param1: PChar; const param2: PChar; param3: size_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{int ap_slack(int, int);
+int ap_execle(const char *, const char *, ...);
+int ap_execve(const char *, char * const argv[], char * const envp[]); }
+
+//function ap_getpass(const prompt: PChar; pwbuf: PChar; bufsiz: size_t): cint;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+//{$ifndef ap_strtol}
+//function ap_strtol(const nptr: PChar; endptr: PPChar; base: cint): clong;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+//{$endif}
+
+{ small utility macros to make things easier to read }
+
+{.$ifdef WIN32
+#define ap_killpg(x, y)
+#else
+#ifdef NO_KILLPG
+#define ap_killpg(x, y)		(kill (-(x), (y)))
+#else
+#define ap_killpg(x, y)		(killpg ((x), (y)))
+#endif
+#endif} { WIN32 }
+
+{ ap_vformatter() is a generic printf-style formatting routine
+ * with some extensions.  The extensions are:
+ *
+ * %pA	takes a struct in_addr *, and prints it as a.b.c.d
+ * %pI	takes a struct sockaddr_in * and prints it as a.b.c.d:port
+ * %pp  takes a void * and outputs it in hex
+ *
+ * The %p hacks are to force gcc's printf warning code to skip
+ * over a pointer argument without complaining.  This does
+ * mean that the ANSI-style %p (output a void * in hex format) won't
+ * work as expected at all, but that seems to be a fair trade-off
+ * for the increased robustness of having printf-warnings work.
+ *
+ * Additionally, ap_vformatter allows for arbitrary output methods
+ * using the ap_vformatter_buff and flush_func.
+ *
+ * The ap_vformatter_buff has two elements curpos and endpos.
+ * curpos is where ap_vformatter will write the next byte of output.
+ * It proceeds writing output to curpos, and updating curpos, until
+ * either the end of output is reached, or curpos == endpos (i.e. the
+ * buffer is full).
+ *
+ * If the end of output is reached, ap_vformatter returns the
+ * number of bytes written.
+ *
+ * When the buffer is full, the flush_func is called.  The flush_func
+ * can return -1 to indicate that no further output should be attempted,
+ * and ap_vformatter will return immediately with -1.  Otherwise
+ * the flush_func should flush the buffer in whatever manner is
+ * appropriate, re-initialize curpos and endpos, and return 0.
+ *
+ * Note that flush_func is only invoked as a result of attempting to
+ * write another byte at curpos when curpos >= endpos.  So for
+ * example, it's possible when the output exactly matches the buffer
+ * space available that curpos == endpos will be true when
+ * ap_vformatter returns.
+ *
+ * ap_vformatter does not call out to any other code, it is entirely
+ * self-contained.  This allows the callers to do things which are
+ * otherwise "unsafe".  For example, ap_psprintf uses the "scratch"
+ * space at the unallocated end of a block, and doesn't actually
+ * complete the allocation until ap_vformatter returns.  ap_psprintf
+ * would be completely broken if ap_vformatter were to call anything
+ * that used a pool.  Similarly http_bprintf() uses the "scratch"
+ * space at the end of its output buffer, and doesn't actually note
+ * that the space is in use until it either has to flush the buffer
+ * or until ap_vformatter returns.
+ }
+
+type
+  ap_vformatter_buff = record
+    curpos: PChar;
+    endpos: PChar;
+  end;
+  
+  Pap_vformatter_buff = ^ap_vformatter_buff;
+  
+  flush_func_t = function (param: Pap_vformatter_buff): cint;
+
+function ap_vformatter(flush_func: flush_func_t;
+ param2: Pap_vformatter_buff; const fmt: PChar; ap: va_list): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ These are snprintf implementations based on ap_vformatter().
+ *
+ * Note that various standards and implementations disagree on the return
+ * value of snprintf, and side-effects due to %n in the formatting string.
+ * ap_snprintf behaves as follows:
+ *
+ * Process the format string until the entire string is exhausted, or
+ * the buffer fills.  If the buffer fills then stop processing immediately
+ * (so no further %n arguments are processed), and return the buffer
+ * length.  In all cases the buffer is NUL terminated. The return value
+ * is the number of characters placed in the buffer, excluding the
+ * terminating NUL. All this implies that, at most, (len-1) characters
+ * will be copied over; if the return value is >= len, then truncation
+ * occured.
+ *
+ * In no event does ap_snprintf return a negative number.
+ }
+function ap_snprintf(buf: PChar; len: size_t; const format: PChar;
+ others: array of const): cint; cdecl; external LibHTTPD;
+
+//			    __attribute__((format(printf,3,4)));
+
+function ap_vsnprintf(buf: PChar; len: size_t; const format: PChar; ap: va_list): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Simple BASE64 encode/decode functions.
+ * 
+ * As we might encode binary strings, hence we require the length of
+ * the incoming plain source. And return the length of what we decoded.
+ *
+ * The decoding function takes any non valid char (i.e. whitespace, \0
+ * or anything non A-Z,0-9 etc as terminal.
+ * 
+ * plain strings/binary sequences are not assumed '\0' terminated. Encoded
+ * strings are neither. But propably should.
+ *
+ }
+function ap_base64encode_len(len: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_base64encode(coded_dst: PChar; const plain_src: PChar; len_plain_src: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_base64encode_binary(coded_dst: PChar; const plain_src: PChar; len_plain_src: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+
+function ap_base64decode_len(const coded_src: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_base64decode(plain_dst: PChar; const coded_src: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_base64decode_binary(plain_dst: PChar; const coded_src: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Password validation, as used in AuthType Basic which is able to cope
+ * (based on the prefix) with the SHA1, Apache's internal MD5 and (depending
+ * on your platform either plain or crypt(3) passwords.
+ }
+function ap_validate_password(const passwd, hash: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+

+ 451 - 0
packages/base/httpd/httpd-1.3/ap_alloc.inc

@@ -0,0 +1,451 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * Resource allocation routines...
+ *
+ * designed so that we don't have to keep track of EVERYTHING so that
+ * it can be explicitly freed later (a fundamentally unsound strategy ---
+ * particularly in the presence of die()).
+ *
+ * Instead, we maintain pools, and allocate items (both memory and I/O
+ * handlers) from the pools --- currently there are two, one for per
+ * transaction info, and one for config info.  When a transaction is over,
+ * we can delete everything in the per-transaction pool without fear, and
+ * without thinking too hard about it either.
+ *
+ * rst
+ }
+
+{ Arenas for configuration info and transaction info
+ * --- actual layout of the pool structure is private to 
+ * alloc.c.  
+ }
+
+ { Need declaration of DIR on Win32 }
+{$ifdef WIN32}
+//#include "readdir.h"
+{$endif}
+
+type
+  pool = record end;
+  Ppool = ^pool;
+  ap_pool = pool;
+  Pap_pool = ^ap_pool;
+
+function ap_init_alloc: PPool;                    { Set up everything }
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+//procedure ap_cleanup_alloc;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_make_sub_pool(param: PPool): PPool;   { All pools are subpools of permanent_pool }
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_destroy_pool(param: PPool);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ pools have nested lifetimes -- sub_pools are destroyed when the
+ * parent pool is cleared.  We allow certain liberties with operations
+ * on things such as tables (and on other structures in a more general
+ * sense) where we allow the caller to insert values into a table which
+ * were not allocated from the table's pool.  The table's data will
+ * remain valid as long as all the pools from which its values are
+ * allocated remain valid.
+ *
+ * For example, if B is a sub pool of A, and you build a table T in
+ * pool B, then it's safe to insert data allocated in A or B into T
+ * (because B lives at most as long as A does, and T is destroyed when
+ * B is cleared/destroyed).  On the other hand, if S is a table in
+ * pool A, it is safe to insert data allocated in A into S, but it
+ * is *not safe* to insert data allocated from B into S... because
+ * B can be cleared/destroyed before A is (which would leave dangling
+ * pointers in T's data structures).
+ *
+ * In general we say that it is safe to insert data into a table T
+ * if the data is allocated in any ancestor of T's pool.  This is the
+ * basis on which the POOL_DEBUG code works -- it tests these ancestor
+ * relationships for all data inserted into tables.  POOL_DEBUG also
+ * provides tools (ap_find_pool, and ap_pool_is_ancestor) for other
+ * folks to implement similar restrictions for their own data
+ * structures.
+ *
+ * However, sometimes this ancestor requirement is inconvenient --
+ * sometimes we're forced to create a sub pool (such as through
+ * ap_sub_req_lookup_uri), and the sub pool is guaranteed to have
+ * the same lifetime as the parent pool.  This is a guarantee implemented
+ * by the *caller*, not by the pool code.  That is, the caller guarantees
+ * they won't destroy the sub pool individually prior to destroying the
+ * parent pool.
+ *
+ * In this case the caller must call ap_pool_join() to indicate this
+ * guarantee to the POOL_DEBUG code.  There are a few examples spread
+ * through the standard modules.
+ }
+{$ifndef POOL_DEBUG}
+//#define ap_pool_join(a,b)
+{$else}
+//API_EXPORT(void) ap_pool_join(pool *p, pool *sub);
+//API_EXPORT(pool *) ap_find_pool(const void *ts);
+//API_EXPORT(int) ap_pool_is_ancestor(pool *a, pool *b);
+{$endif}
+
+{ Clearing out EVERYTHING in an pool... destroys any sub-pools }
+
+procedure ap_clear_pool(param1: Ppool);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Preparing for exec() --- close files, etc., but *don't* flush I/O
+ * buffers, *don't* wait for subprocesses, and *don't* free any memory.
+ }
+
+procedure ap_cleanup_for_exec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ routines to allocate memory from an pool... }
+
+function ap_palloc(p: PPool; nbytes: cint): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_pcalloc(p: PPool; nbytes: cint): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_pstrdup(p: PPool; const s: Char): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ make a nul terminated copy of the n characters starting with s }
+
+function ap_pstrndup(p: PPool; const s: PChar; n: cint): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+//API_EXPORT_NONSTD(char *) ap_pstrcat(struct pool *,...);	{ all '...' must be char* }
+//API_EXPORT_NONSTD(char *) ap_psprintf(struct pool *, const char *fmt, ...)
+//    __attribute__((format(printf,2,3)));
+//API_EXPORT(char *) ap_pvsprintf(struct pool *, const char *fmt, va_list);
+
+{ array and alist management... keeping lists of things.
+ * Common enough to want common support code ...
+ }
+
+type
+  Parray_header = ^array_header;
+
+  array_header = record
+    pool: Pap_pool;
+    elt_size: cint;
+    nelts: cint;
+    nalloc: cint;
+    elts: PChar;
+  end;
+
+//API_EXPORT(array_header *) ap_make_array(pool *p, int nelts, int elt_size);
+//API_EXPORT(void *) ap_push_array(array_header *);
+//API_EXPORT(void) ap_array_cat(array_header *dst, const array_header *src);
+//API_EXPORT(array_header *) ap_append_arrays(pool *, const array_header *,
+//					 const array_header *);
+
+{ ap_array_pstrcat generates a new string from the pool containing
+ * the concatenated sequence of substrings referenced as elements within
+ * the array.  The string will be empty if all substrings are empty or null,
+ * or if there are no elements in the array.
+ * If sep is non-NUL, it will be inserted between elements as a separator.
+ }
+function ap_array_pstrcat(p: PPool; const arr: Parray_header; const sep: Char): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ copy_array copies the *entire* array.  copy_array_hdr just copies
+ * the header, and arranges for the elements to be copied if (and only
+ * if) the code subsequently does a push or arraycat.
+ }
+
+//API_EXPORT(array_header *) ap_copy_array(pool *p, const array_header *src);
+//API_EXPORT(array_header *) ap_copy_array_hdr(pool *p, const array_header *src);
+
+
+{ Tables.  Implemented alist style, for now, though we try to keep
+ * it so that imposing a hash table structure on top in the future
+ * wouldn't be *too* hard...
+ *
+ * Note that key comparisons for these are case-insensitive, largely
+ * because that's what's appropriate and convenient everywhere they're
+ * currently being used...
+ }
+
+type
+  table = record end;
+  
+  Ptable = ^table;
+
+  table_entry = record
+    key: PChar;		{ maybe NULL in future;
+			 * check when iterating thru table_elts
+                         }
+    val: PChar;
+  end;
+
+  table_entry_t = table_entry;
+
+function ap_make_table(p: Ppool; nelts: cuint): Ptable;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_copy_table(p: Ppool; p1: Ptable): Ptable;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_clear_table(p1: Ptable);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_table_get(const p1: Ptable; const p2: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_table_set(p1: Ptable; const name, val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_table_setn(p1: Ptable; const name, val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_table_merge(p1: Ptable; const name, more_val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_table_mergen(p1: Ptable; const name, more_val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_table_unset(p1: Ptable; const key: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_table_add(p1: Ptable; const name, more_val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_table_addn(p1: Ptable; const name, more_val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{API_EXPORT_NONSTD(void) ap_table_do(int ( *comp) (void *, const char *, const char *),
+                                    void *rec, const table *t,...);
+
+API_EXPORT(table * ) ap_overlay_tables(pool *p, const table *overlay, const table *base);
+}
+{ Conceptually, ap_overlap_tables does this:
+
+    array_header *barr = ap_table_elts(b);
+    table_entry *belt = (table_entry *)barr->elts;
+    int i;
+
+    for (i = 0; i < barr->nelts; ++i) begin
+	if (flags & AP_OVERLAP_TABLES_MERGE) begin
+	    ap_table_mergen(a, belt[i].key, belt[i].val);
+        end
+	else begin
+	    ap_table_setn(a, belt[i].key, belt[i].val);
+        end;
+    end;
+
+    Except that it is more efficient (less space and cpu-time) especially
+    when b has many elements.
+
+    Notice the assumptions on the keys and values in b -- they must be
+    in an ancestor of a's pool.  In practice b and a are usually from
+    the same pool.
+}
+const
+  AP_OVERLAP_TABLES_SET	= (0);
+  AP_OVERLAP_TABLES_MERGE = (1);
+
+procedure ap_overlap_tables(a: Ptable; const b: Ptable; flags: cuint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ XXX: these know about the definition of struct table in alloc.c.  That
+ * definition is not here because it is supposed to be private, and by not
+ * placing it here we are able to get compile-time diagnostics from modules
+ * written which assume that a table is the same as an array_header. -djg
+ }
+//#define ap_table_elts(t) ((array_header *)(t))
+//#define ap_is_empty_table(t) (((t) == NULL)||(((array_header *)(t))->nelts == 0))
+
+{ routines to remember allocation of other sorts of things...
+ * generic interface first.  Note that we want to have two separate
+ * cleanup functions in the general case, one for exec() preparation,
+ * to keep CGI scripts and the like from inheriting access to things
+ * they shouldn't be able to touch, and one for actually cleaning up,
+ * when the actual server process wants to get rid of the thing,
+ * whatever it is.  
+ *
+ * kill_cleanup disarms a cleanup, presumably because the resource in
+ * question has been closed, freed, or whatever, and it's scarce
+ * enough to want to reclaim (e.g., descriptors).  It arranges for the
+ * resource not to be cleaned up a second time (it might have been
+ * reallocated).  run_cleanup does the same, but runs it first.
+ *
+ * Cleanups are identified for purposes of finding & running them off by the
+ * plain_cleanup and data, which should presumably be unique.
+ *
+ * NB any code which invokes register_cleanup or kill_cleanup directly
+ * is a critical section which should be guarded by block_alarms() and
+ * unblock_alarms() below...
+ *
+ * ap_register_cleanup_ex provided to allow for an optional "cleanup"
+ * to be run at call-time for things like setting CLOSEXEC flags
+ * on fd's or whatever else may make sense.
+ }
+
+//API_EXPORT(void) ap_register_cleanup(pool *p, void *data,
+//				     void (*plain_cleanup) (void *),
+//				     void (*child_cleanup) (void *));
+//API_EXPORT(void) ap_register_cleanup_ex(pool *p, void *data,
+//				      void (*plain_cleanup) (void *),
+//				      void (*child_cleanup) (void *),
+//				      int (*magic_cleanup) (void *));
+
+//API_EXPORT(void) ap_kill_cleanup(pool *p, void *data, void (*plain_cleanup) (void *));
+//API_EXPORT(void) ap_run_cleanup(pool *p, void *data, void (*cleanup) (void *));
+
+{ A "do-nothing" cleanup, for register_cleanup; it's faster to do
+ * things this way than to test for NULL. }
+//API_EXPORT_NONSTD(void) ap_null_cleanup(void *data);
+
+{ The time between when a resource is actually allocated, and when it
+ * its cleanup is registered is a critical section, during which the
+ * resource could leak if we got interrupted or timed out.  So, anything
+ * which registers cleanups should bracket resource allocation and the
+ * cleanup registry with these.  (This is done internally by run_cleanup).
+ *
+ * NB they are actually implemented in http_main.c, since they are bound
+ * up with timeout handling in general...
+ }
+
+procedure ap_block_alarms;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_unblock_alarms;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Common cases which want utility support..
+ * the note_cleanups_for_foo routines are for 
+ }
+
+{API_EXPORT(FILE *) ap_pfopen(struct pool *, const char *name, const char *fmode);
+API_EXPORT(FILE *) ap_pfdopen(struct pool *, int fd, const char *fmode);}
+
+function ap_popenf(p1: Ppool; const name: PChar; flg, mode: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_popenf_ex(p1: Ppool; const name: PChar; flg, mode, domagic: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{API_EXPORT(void) ap_note_cleanups_for_file(pool *, FILE *);
+API_EXPORT(void) ap_note_cleanups_for_file_ex(pool *, FILE *, int);}
+
+procedure ap_note_cleanups_for_fd(p1: Ppool; p2: cint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_note_cleanups_for_fd_ex(p1: Ppool; p2, p3: cint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{$ifdef WIN32}
+//API_EXPORT(void) ap_note_cleanups_for_h(pool *, HANDLE);
+{$endif}
+
+procedure ap_kill_cleanups_for_fd(p: Ppool; fd: cint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+
+procedure ap_note_cleanups_for_socket(p1: Ppool; p2: cint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_note_cleanups_for_socket_ex(p1: Ppool; p2, p3: cint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_kill_cleanups_for_socket(p: Ppool; sock: cint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_psocket(p: Ppool; p2, p3, p4: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_psocket_ex(p: Ppool; p2, p3, p4, p5: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_pclosesocket(a: Ppool; sock: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+
+function ap_pregcomp(p: Ppool; const pattern: PChar; cflags: cint): Pregex_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_pregfree(p: Ppool; reg: Pregex_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ routines to note closes... file descriptors are constrained enough
+ * on some systems that we want to support this.
+ }
+
+//API_EXPORT(int) ap_pfclose(struct pool *, FILE *);
+
+function ap_pclosef(p1: Ppool; fd: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{$ifdef WIN32}
+//API_EXPORT(int) ap_pcloseh(struct pool *, HANDLE hDevice);
+{$endif}
+
+{ routines to deal with directories }
+
+function ap_popendir(p: Ppool; const name: PChar): PDIR;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_pclosedir(p: Ppool; d: PDIR);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ ... even child processes (which we may want to wait for,
+ * or to kill outright, on unexpected termination).
+ *
+ * ap_spawn_child is a utility routine which handles an awful lot of
+ * the rigamarole associated with spawning a child --- it arranges
+ * for pipes to the child's stdin and stdout, if desired (if not,
+ * set the associated args to NULL).  It takes as args a function
+ * to call in the child, and an argument to be passed to the function.
+ }
+
+type
+  kill_conditions = (
+    kill_never,			{ process is never sent any signals }
+    kill_always,		{ process is sent SIGKILL on pool cleanup }
+    kill_after_timeout,		{ SIGTERM, wait 3 seconds, SIGKILL }
+    just_wait,			{ wait forever for the process to complete }
+    kill_only_once		{ send SIGTERM and then wait }
+  );
+
+procedure ap_note_subprocess(a: Ppool; pid: pid_t; how: kill_conditions);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{API_EXPORT(int) ap_spawn_child(pool *, int (*)(void *, child_info *),
+				   void *, enum kill_conditions,
+				   FILE **pipe_in, FILE **pipe_out,
+				   FILE **pipe_err);
+int ap_close_fd_on_exec(int fd);}
+
+{ magic numbers --- min free bytes to consider a free pool block useable,
+ * and the min amount to allocate if we have to go to malloc() }
+
+const
+  BLOCK_MINFREE = 4096;
+  BLOCK_MINALLOC = 8192;
+
+{ Finally, some accounting }
+
+function ap_bytes_in_pool(p: PPool): culong;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_bytes_in_free_blocks: culong;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+

+ 1496 - 0
packages/base/httpd/httpd-1.3/ap_config.inc

@@ -0,0 +1,1496 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * ap_config.h: system-dependant #defines and includes...
+ * See PORTING for a listing of what they mean
+ }
+
+{$include ap_mmn.inc}		{ MODULE_MAGIC_NUMBER_ }
+
+{
+ * Support for platform dependent autogenerated defines
+ }
+{.$if not defined(WIN32) and not defined(NETWARE) and not defined(TPF)}
+//#include "ap_config_auto.h"
+//#endif
+
+{$if defined(WIN32) or defined(NETWARE)}
+  { not available under WIN32, so provide important entries manually }
+  {$undefine HAVE_UNISTD_H}
+{$endif}
+
+{ Have to include sys/stat.h before ../win32/os.h so we can override
+stat() properly }
+//#ifndef NETWARE
+//#include <sys/types.h>
+//#endif
+//#include <sys/stat.h>
+
+
+{ So that we can use inline on some critical functions, and use
+ * GNUC attributes (such as to get -Wall warnings for printf-like
+ * functions).  Only do this in gcc 2.7 or later ... it may work
+ * on earlier stuff, but why chance it.
+ *
+ * We've since discovered that the gcc shipped with NeXT systems
+ * as "cc" is completely broken.  It claims to be __GNUC__ and so
+ * on, but it doesn't implement half of the things that __GNUC__
+ * means.  In particular it's missing inline and the __attribute__
+ * stuff.  So we hack around it.  PR#1613. -djg
+ }
+{#if !defined(__GNUC__) || __GNUC__ < 2 || \
+    (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ||\
+    defined(NEXT)
+#define ap_inline
+#define __attribute__(__x)
+#define ENUM_BITFIELD(e,n,w)  signed int n : w
+#else
+#define ap_inline __inline__
+#define USE_GNU_INLINE
+#define ENUM_BITFIELD(e,n,w)  e n : w
+#endif
+
+#include "os.h"}
+
+{ Define one of these according to your system. }
+{$if defined(MINT)}
+type rlim_t = cint;
+#define JMP_BUF sigjmp_buf
+{$define NO_LONG_DOUBLE}
+{$define HAVE_FLOCK_SERIALIZED_ACCEPT}
+{$define _BSD_SOURCE}
+#define EAGAIN EWOULDBLOCK
+int initgroups (char *, int);     
+char *crypt (const char *pw, const char *salt);
+int gethostname (char *name, int namelen);
+
+{$else}{$if defined(MPE)}
+#include <sys/times.h>
+{$define NO_SETSID}
+{$define NO_KILLPG}
+{$define NO_WRITEV}
+#define HAVE_SHMGET 1
+{$define USE_SHMGET_SCOREBOARD}
+{
+   UID/GID isn't a native concept for MPE, and it's definitely not a 100%
+   Unix implementation.  There isn't a traditional superuser concept either,
+   so we're forced to liberalize SHM security a bit so the parent & children
+   can communicate when they're running with different UIDs within the same
+   GID (the GID will *always* be the same on MPE).  Thus the weird SHM_R and
+   SHM_W below.
+}
+const
+  SHM_R = 0440;  { Read permission }
+  SHM_W = 0220;  { Write permission }
+  {$define NEED_INITGROUPS}
+  {$define NEED_STRCASECMP}
+  {$define NEED_STRDUP}
+  {$define NEED_STRNCASECMP}
+//extern void GETPRIVMODE();
+//extern void GETUSERMODE();
+//extern char *inet_ntoa();
+  {$define NO_SLACK}
+  S_IEXEC  = S_IXUSR;
+  S_IREAD  = S_IRUSR;
+  S_IWRITE = S_IWUSR;
+  PF_INET  = AF_INET;
+  {$define HAVE_FCNTL_SERIALIZED_ACCEPT}
+
+{$else}{$if defined(SUNOS4)}
+const
+  HAVE_GMTOFF = 1;
+{$undefine NO_KILLPG}
+#undef NO_SETSID
+//char *crypt(const char *pw, const char *salt);
+//char *mktemp(char *);
+  HAVE_MMAP = 1;
+{$define USE_MMAP_SCOREBOARD}
+{$define USE_MMAP_FILES}
+#include <sys/time.h>
+{$define NEED_STRERROR}
+type rlim_t = cint;
+#define memmove(a,b,c) bcopy(b,a,c)
+{$define NO_LINGCLOSE}
+{$define HAVE_FLOCK_SERIALIZED_ACCEPT}
+{$define NEED_DIFFTIME}
+  HAVE_SYSLOG = 1;
+
+{$else}{$if defined(SOLARIS2)}
+#undef HAVE_GMTOFF
+#define NO_KILLPG
+#undef NO_SETSID
+#define bzero(a,b) memset(a,0,b)
+#define HAVE_SYSVSEM_SERIALIZED_ACCEPT
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#define HAVE_PTHREAD_SERIALIZED_ACCEPT
+#if !defined(USE_SYSVSEM_SERIALIZED_ACCEPT) && \
+    !defined(USE_PTHREAD_SERIALIZED_ACCEPT)
+#define USE_FCNTL_SERIALIZED_ACCEPT
+#endif
+#define NEED_UNION_SEMUN
+#define HAVE_MMAP 1
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES
+int gethostname(char *name, int namelen);
+#define HAVE_SYSLOG 1
+#define SYS_SIGLIST _sys_siglist
+#define AP_ENABLE_EXCEPTION_HOOK
+#define NONBLOCK_WHEN_MULTI_LISTEN
+
+{$else}{$if defined(IRIX)}
+#undef HAVE_GMTOFF
+{ IRIX has killpg, but it's only in _BSD_COMPAT, so don't use it in case
+ * there's some weird conflict with non-BSD signals }
+#define NO_KILLPG
+#undef NO_SETSID
+#define HAVE_FLOCK_SERIALIZED_ACCEPT
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#define HAVE_USLOCK_SERIALIZED_ACCEPT
+#define HAVE_SYSVSEM_SERIALIZED_ACCEPT
+#if !defined(USE_FLOCK_SERIALIZED_ACCEPT) && \
+    !defined(USE_USLOCK_SERIALIZED_ACCEPT) && \
+    !defined(USE_SYSVSEM_SERIALIZED_ACCEPT)
+#define USE_FCNTL_SERIALIZED_ACCEPT
+#endif
+#define HAVE_SHMGET 1
+#define USE_SHMGET_SCOREBOARD
+#define HAVE_MMAP 1
+#define USE_MMAP_FILES
+#define NO_LONG_DOUBLE
+#define NO_LINGCLOSE
+#define HAVE_SYSLOG 1
+#define NONBLOCK_WHEN_MULTI_LISTEN
+
+{$else}{$if defined(HIUX)}
+#undef HAVE_GMTOFF
+#define NO_KILLPG
+#undef NO_SETSID
+#ifndef _HIUX_SOURCE
+#define _HIUX_SOURCE
+#endif
+#define HAVE_SHMGET 1
+#define USE_SHMGET_SCOREBOARD
+#define SELECT_NEEDS_CAST
+#define HAVE_SYSLOG 1
+
+{$else}{$if defined(HPUX11)}
+#ifndef _HPUX_SOURCE
+#define _HPUX_SOURCE
+#endif
+#define HAVE_SHMGET
+#define USE_SHMGET_SCOREBOARD
+#undef  HAVE_GMTOFF
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#define HAVE_MMAP
+#define USE_MMAP_FILES
+#define NO_KILLPG
+#undef  NO_SETSID
+#define HAVE_SYSLOG
+#define AP_ENABLE_EXCEPTION_HOOK
+
+{$else}{$if defined(HPUX) or defined(HPUX10)}
+#undef HAVE_GMTOFF
+#define NO_KILLPG
+#undef NO_SETSID
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#ifndef _HPUX_SOURCE
+#define _HPUX_SOURCE
+#endif
+#define HAVE_SHMGET 1
+#define USE_SHMGET_SCOREBOARD
+#define HAVE_SYSLOG 1
+#ifndef HPUX10
+#define SELECT_NEEDS_CAST
+typedef int rlim_t;
+#endif
+
+{$else}{$if defined(AIX)}
+#undef HAVE_GMTOFF
+#undef NO_KILLPG
+#undef NO_SETSID
+#ifndef __ps2__
+#define HAVE_MMAP 1
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES
+#define HAVE_SYSLOG 1
+#ifndef DEFAULT_GROUP
+#define DEFAULT_GROUP "nobody"
+#endif
+#endif
+#ifndef DEFAULT_USER
+#define DEFAULT_USER "nobody"
+#endif
+#ifdef NEED_RLIM_T
+typedef int rlim_t;
+#endif
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#define HAVE_SYSVSEM_SERIALIZED_ACCEPT
+#define NEED_UNION_SEMUN
+#if AIX >= 430
+#define HAVE_PTHREAD_SERIALIZED_ACCEPT
+#endif
+#define USE_FCNTL_SERIALIZED_ACCEPT
+#if AIX >= 432
+#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT 
+#endif
+#ifdef USEBCOPY
+#define memmove(a,b,c) bcopy(b,a,c)
+#endif
+#if AIX >= 510
+#define NET_SIZE_T socklen_t
+#elif AIX >= 420
+#define NET_SIZE_T size_t
+#endif
+#define AP_ENABLE_EXCEPTION_HOOK
+#define NONBLOCK_WHEN_MULTI_LISTEN
+
+{$else}{$if defined(ULTRIX)}
+{ we don't want to use sys/resource.h under
+   Ultrix although this header exists. }
+#undef HAVE_SYS_RESOURCE_H
+#define HAVE_GMTOFF 1
+#undef NO_KILLPG
+#undef NO_SETSID
+#define ULTRIX_BRAIN_DEATH
+#define NEED_STRDUP
+{ If you have Ultrix 4.3, and are using cc, const is broken }
+#ifndef __ultrix__		{ Hack to check for pre-Ultrix 4.4 cc }
+#define const			{ Not implemented }
+#endif
+
+{$else}{$if defined(OSF1)}
+#define HAVE_GMTOFF 1
+#undef NO_KILLPG
+#undef NO_SETSID
+#define HAVE_MMAP 1
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES
+#define NO_LONG_DOUBLE
+#define HAVE_SYSLOG 1
+#define HAVE_FLOCK_SERIALIZED_ACCEPT
+#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+#define NONBLOCK_WHEN_MULTI_LISTEN
+
+{$else}{$if defined(PARAGON)}
+#define HAVE_GMTOFF 1
+#undef NO_KILLPG
+#undef NO_SETSID
+#define HAVE_MMAP 1
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES
+#define NO_LONG_DOUBLE
+#define HAVE_SYSLOG 1
+typedef int rlim_t;
+
+{$else}{$if defined(SEQUENT)}
+#define DEFAULT_USER "nobody"
+#define DEFAULT_GROUP "nobody"
+#define NO_SHMGET 1
+#define HAVE_MMAP 1
+#define HAVE_SYSLOG 1
+#define USE_MMAP_FILES 1
+#define USE_MMAP_SCOREBOARD 1
+#define HAVE_FCNTL_SERIALIZED_ACCEPT 1
+#define JMP_BUF sigjmp_buf
+#undef NO_SETSID
+#if SEQUENT < 40
+typedef int rlim_t;
+#define NO_GETTIMEOFDAY
+#undef HAVE_SYS_RESOURCE_H { exists but does not provide *rlimit funcs }
+#include <sys/times.h>
+#endif
+#if SEQUENT < 42
+#define NEED_STRCASECMP
+#define NEED_STRNCASECMP
+#endif
+#if SEQUENT < 44
+#define NO_KILLPG 1
+#define NET_SIZE_T int
+#endif
+#if SEQUENT >= 44
+#undef NO_KILLPG
+#define NET_SIZE_T size_t
+#endif
+
+{$else}{$if defined(NEXT)}
+typedef unsigned short mode_t;
+typedef int rlim_t;
+#define HAVE_GMTOFF 1
+#undef NO_KILLPG
+#define NO_SETSID
+#define NEED_STRDUP
+#define NO_LINGCLOSE
+#undef _POSIX_SOURCE
+#ifndef FD_CLOEXEC
+#define FD_CLOEXEC 1
+#endif
+#ifndef S_ISDIR
+#define S_ISDIR(m)      (((m)&(S_IFMT)) == (S_IFDIR))
+#endif
+#ifndef S_ISREG
+#define S_ISREG(m)      (((m)&(S_IFMT)) == (S_IFREG))
+#endif
+#ifndef S_IXUSR
+#define S_IXUSR 00100
+#endif
+#ifndef S_IRGRP
+#define S_IRGRP 00040
+#endif
+#ifndef S_IXGRP
+#define S_IXGRP 00010
+#endif
+#ifndef S_IROTH
+#define S_IROTH 00004
+#endif
+#ifndef S_IXOTH
+#define S_IXOTH 00001
+#endif
+#ifndef S_IRUSR
+#define S_IRUSR S_IREAD
+#endif
+#ifndef S_IWUSR
+#define S_IWUSR S_IWRITE
+#endif
+#ifndef S_IWGRP
+#define S_IWGRP	000020
+#endif
+#ifndef S_IWOTH
+#define S_IWOTH 000002
+#endif
+
+#define STDIN_FILENO  0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+{ PR#2293 fix }
+#define	ap_wait_t	union wait
+#define waitpid(a,b,c) wait4((a) == -1 ? 0 : (a),(union wait *)(b),c,NULL)
+#define WEXITSTATUS(status)     (int)( WIFEXITED(status) ? ( (status).w_retcode ) : -1)
+#define WTERMSIG(status)	(int)( (status).w_termsig )
+
+typedef int pid_t;
+#define USE_LONGJMP
+#define NO_USE_SIGACTION
+#define HAVE_SYSLOG 1
+
+#if defined(__DYNAMIC__)
+#define HAVE_DYLD
+#define DYLD_CANT_UNLOAD
+#endif
+
+{$else}{$if defined(DARWIN)} { Darwin (Mac OS) }
+const
+  PLATFORM = 'Darwin';
+{$define HAVE_DYLD}
+{$define HAVE_GMTOFF}
+{$define HAVE_MMAP}
+{$define USE_MMAP_FILES}
+{$define USE_MMAP_SCOREBOARD}
+{$ifdef MAC_OS_X_SERVER}
+  {$define MAP_TMPFILE}
+{$endif} { MAC_OS_X_SERVER }
+{$define HAVE_RESOURCE}
+{$define HAVE_SNPRINTF}
+{$define JMP_BUF jmp_buf}
+{$define USE_LONGJMP}
+{$define HAVE_FLOCK_SERIALIZED_ACCEPT}
+{$define HAVE_FCNTL_SERIALIZED_ACCEPT}
+{$define USE_FLOCK_SERIALIZED_ACCEPT}
+{$define SINGLE_LISTEN_UNSERIALIZED_ACCEPT}
+{$define AP_ENABLE_EXCEPTION_HOOK}
+
+{$else}{$if defined(LINUX)}
+
+//#if LINUX > 1
+//#include <features.h>
+
+{ libc4 systems probably still work, it probably doesn't define
+ *  __GNU_LIBRARY__
+ * libc5 systems define __GNU_LIBRARY__ == 1, but don't define __GLIBC__
+ * glibc 2.x and later systems define __GNU_LIBRARY__ == 6, but list it as
+ * "deprecated in favour of __GLIBC__"; the value 6 will never be changed.
+ * glibc 1.x systems (i.e. redhat 4.x on sparc/alpha) should have
+ * __GLIBC__ < 2
+ * all glibc based systems need crypt.h
+ }
+//#if defined(__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
+//#include <crypt.h>
+//#endif
+
+{ glibc 2.0.0 through 2.0.4 need size_t * here, where 2.0.5 needs socklen_t *
+ * there's no way to discern between these two libraries.  But using int should
+ * be portable because otherwise these libs would be hopelessly broken with
+ * reams of existing networking code.  We'll use socklen_t * for 2.1.x and
+ * later.
+ *
+ * int works for all the earlier libs, and is picked up by default later.
+ }
+//#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 0))
+//#define NET_SIZE_T socklen_t
+//#endif
+
+const
+  HAVE_SHMGET = 1;
+{$define USE_SHMGET_SCOREBOARD}
+  HAVE_MMAP = 1;
+{$define USE_MMAP_FILES}
+
+//#if LINUX > 20
+{ see [email protected]
+ * in new-httpd archives for performance numbers indicating these
+ * are the right choices for linux 2.2.x and later
+ }
+{$define HAVE_SYSVSEM_SERIALIZED_ACCEPT}
+{$define HAVE_FCNTL_SERIALIZED_ACCEPT}
+{$define SINGLE_LISTEN_UNSERIALIZED_ACCEPT}
+//#include <sys/sem.h>
+{$ifdef _SEM_SEMUN_UNDEFINED}
+{$define NEED_UNION_SEMUN}
+{$endif}
+//#else
+//#define USE_FCNTL_SERIALIZED_ACCEPT
+//#endif
+
+//#define SYS_SIGLIST	_sys_siglist
+
+{#else
+#define USE_FCNTL_SERIALIZED_ACCEPT
+#endif}
+
+{$undef HAVE_GMTOFF}
+{$undef NO_KILLPG}
+{$undef NO_SETSID}
+{$undef NEED_STRDUP}
+//#include <sys/time.h>
+  HAVE_SYSLOG = 1;
+
+{ glibc 2.1 and later finally define rlim_t }
+{#if !defined(__GLIBC__) || __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 1)
+typedef int rlim_t;
+#endif}
+{$define AP_ENABLE_EXCEPTION_HOOK}
+
+{$else}{$if defined(SCO)}
+#undef HAVE_GMTOFF
+#undef NO_KILLPG
+#undef NO_SETSID
+#define NEED_INITGROUPS
+#define NO_WRITEV
+#include <sys/time.h>
+#define HAVE_SYSLOG 1
+#undef HAVE_SYS_RESOURCE_H
+
+{$else}{$if defined(ATHEOS)}
+
+#include <features.h>
+#include <crypt.h>
+#include <sys/time.h>
+
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#define USE_FCNTL_SERIALIZED_ACCEPT
+
+#undef HAVE_GMTOFF
+#undef NO_KILLPG
+#undef NO_SETSID
+#undef NEED_STRDUP
+const
+  HAVE_SYSLOG = 1;
+
+  PLATFORM = 'AtheOS';
+
+{$else}{$if defined(SCO5)}
+
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#define HAVE_MMAP 1
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES
+#define SecureWare
+#define HAVE_SYSLOG 1
+
+{ Although SCO 5 defines these in <strings.h> (note the "s") they don't have
+   consts. Sigh. }
+extern int strcasecmp(const char *, const char *);
+extern int strncasecmp(const char *, const char *, unsigned);
+
+{$else}{$if defined(AUX3)}
+{ These are to let -Wall compile more cleanly }
+extern int strcasecmp(const char *, const char *);
+extern int strncasecmp(const char *, const char *, unsigned);
+extern int set42sig(), getopt(), getpeername(), bzero();
+extern int listen(), bind(), socket(), getsockname();
+extern int accept(), gethostname(), connect(), lstat();
+extern int select(), killpg(), shutdown();
+extern int initgroups(), setsockopt();
+extern char *shmat();
+extern int shmctl();
+extern int shmget();
+extern char *sbrk();
+extern char *crypt();
+#include <sys/time.h>
+#undef HAVE_GMTOFF
+#undef NO_KILLPG
+#undef NO_SETSID
+#define NEED_STRDUP
+{ fcntl() locking is expensive with NFS }
+#define HAVE_FLOCK_SERIALIZED_ACCEPT
+#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+#define HAVE_SHMGET 1
+#define USE_SHMGET_SCOREBOARD
+{
+ * NOTE: If when you run Apache under A/UX and you get a warning
+ * that httpd couldn't move break, then the below value for
+ * MOVEBREAK (64megs) is too large for your setup. Try reducing
+ * to 0x2000000 which is still PLENTY of space. I doubt if
+ * even on heavy systems sbrk() would be called at all...
+ }
+#define MOVEBREAK		0x4000000
+#define NO_LINGCLOSE
+#define NO_SLACK
+#define HAVE_SYSLOG 1
+#undef HAVE_SYS_RESOURCE_H	{ exists but does not provide *rlimit funcs }
+
+{$else}{$if defined(SVR4)}
+#define NO_KILLPG
+#undef  NO_SETSID
+#undef NEED_STRDUP
+#ifndef MPRAS
+#define NEED_STRCASECMP
+#ifndef ENCORE
+#define NEED_STRNCASECMP
+#endif { ENCORE }
+#endif { MPRAS }
+#define bzero(a,b) memset(a,0,b)
+{ A lot of SVR4 systems need this }
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#ifdef SNI
+#define HAVE_SYSVSEM_SERIALIZED_ACCEPT
+#endif
+#ifndef USE_SYSVSEM_SERIALIZED_ACCEPT
+#define USE_FCNTL_SERIALIZED_ACCEPT
+#endif
+#define HAVE_SYSLOG 1
+#define NET_SIZE_T size_t
+#define HAVE_SHMGET 1
+#define USE_SHMGET_SCOREBOARD
+#ifdef _OSD_POSIX { BS2000-POSIX mainframe needs initgroups }
+#define NEED_HASHBANG_EMUL { execve() doesn't start shell scripts by default }
+#define _KMEMUSER          { Enable SHM_R/SHM_W defines in <shm.h> }
+#define AP_ENABLE_EXCEPTION_HOOK
+#undef NEED_STRCASECMP
+#undef NEED_STRNCASECMP
+#undef bzero
+#endif {_OSD_POSIX}
+
+{$else}{$if defined(UW)}
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#if UW < 700
+#define NO_LINGCLOSE
+#define NO_KILLPG
+#else
+#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+#endif
+#undef  NO_SETSID
+#undef NEED_STRDUP
+#define NEED_STRCASECMP
+#define NEED_STRNCASECMP
+#define bzero(a,b) memset(a,0,b)
+#define HAVE_MMAP 1
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES
+#define HAVE_SHMGET 1
+#undef USE_SHMGET_SCOREBOARD	{ force use of mmap() scoreboard }
+#include <sys/time.h>
+#if UW >= 200
+#define _POSIX_SOURCE
+#endif
+#define NET_SIZE_T size_t
+#define HAVE_SYSLOG 1
+
+{$else}{$if defined(DGUX)}
+#define NO_KILLPG
+#undef  NO_SETSID
+#undef NEED_STRDUP
+#ifdef _IX86_DG
+#undef NEED_STRCASECMP
+#undef NEED_STRNCASECMP
+#else
+#define NEED_STRCASECMP
+#define NEED_STRNCASECMP
+#endif
+#define bzero(a,b) memset(a,0,b)
+{ A lot of SVR4 systems need this }
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#define ap_inet_addr inet_network
+#define HAVE_SYSLOG 1
+
+{$else}{$if defined(__NetBSD__) or defined(__OpenBSD__) or defined(NETBSD)}
+#define HAVE_GMTOFF 1
+#undef NO_KILLPG
+#undef NO_SETSID
+#define HAVE_SYSLOG 1
+#ifndef DEFAULT_USER
+#define DEFAULT_USER "nobody"
+#endif
+#ifndef DEFAULT_GROUP
+#define DEFAULT_GROUP "nogroup"
+#endif
+#define HAVE_SHMGET 1
+#define HAVE_MMAP 1
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES
+#define HAVE_FLOCK_SERIALIZED_ACCEPT
+#if defined(__OpenBSD__)
+#define HAVE_SYSVSEM_SERIALIZED_ACCEPT
+#define USE_SYSVSEM_SERIALIZED_ACCEPT
+#include <sys/param.h>
+#if (OpenBSD >= 199912)
+#define NET_SIZE_T socklen_t
+#endif
+#endif
+#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+
+{$else}{$if defined(UTS21)}
+#undef HAVE_GMTOFF
+#undef NO_KILLPG
+#define NO_SETSID
+#define NEED_WAITPID
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+#define HAVE_SYSLOG 1
+#define USE_LONGJMP
+#define JMP_BUF jmp_buf
+#define NO_USE_SIGACTION
+#define NEED_STRERROR
+#define NEED_STRSTR
+#define NEED_HASHBANG_EMUL
+#define NDELAY_PIPE_RETURNS_ZERO
+#define NO_DATA NO_ADDRESS
+#define	ap_wait_t		union wait
+#define WEXITSTATUS(status)	(int)((status).w_retcode)
+#define WTERMSIG(status)	(int)((status).w_termsig)
+#define strftime(buf,bufsize,fmt,tm)    ascftime(buf,fmt,tm)
+#undef HAVE_SYS_RESOURCE_H { exists but does not provide *rlimit funcs }
+#include <sys/types.h>
+#include <sys/time.h>     
+
+{$else}{$if defined(APOLLO)}
+#undef HAVE_GMTOFF
+#undef NO_KILLPG
+#undef NO_SETSID
+#define HAVE_SYSLOG 1
+
+{$else}{$if defined(__FreeBSD__) or defined(__bsdi__)}
+#if defined(__FreeBSD__)
+#include <osreldate.h>
+#endif
+#define HAVE_GMTOFF 1
+#undef NO_KILLPG
+#undef NO_SETSID
+#define HAVE_MMAP 1
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES
+#ifndef DEFAULT_USER
+#define DEFAULT_USER "nobody"
+#endif
+#ifndef DEFAULT_GROUP
+#define DEFAULT_GROUP "nogroup"
+#endif
+#if defined(__bsdi__) || \
+(defined(__FreeBSD_version) && (__FreeBSD_version < 220000))
+typedef quad_t rlim_t;
+#endif
+#define HAVE_FLOCK_SERIALIZED_ACCEPT
+#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+#define HAVE_SYSLOG 1
+#define SYS_SIGLIST sys_siglist
+#if (defined(__FreeBSD_version) && (__FreeBSD_version >= 400000))
+#define NET_SIZE_T socklen_t
+#endif
+
+{$else}{$if defined(QNX)}
+#ifndef crypt
+char *crypt(const char *pw, const char *salt);
+#endif
+#ifndef initgroups
+int initgroups(char *, int);
+#endif
+#ifndef strncasecmp
+#define strncasecmp strnicmp
+#endif
+#undef NO_KILLPG
+#undef NO_SETSID
+#define NEED_INITGROUPS
+#define NEED_SELECT_H
+#define NEED_PROCESS_H
+#include <unix.h>
+#define HAVE_MMAP 1
+#define USE_POSIX_SCOREBOARD
+#define HAVE_FLOCK_SERIALIZED_ACCEPT
+#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+#define HAVE_SYSLOG 1
+
+{$else}{$if defined(LYNXOS)}
+#undef HAVE_GMTOFF
+#undef USE_MMAP_SCOREBOARD
+#undef USE_SHMGET_SCOREBOARD
+#undef HAVE_FCNTL_SERIALIZED_ACCEPT
+#undef HAVE_FLOCK_SERIALIZED_ACCEPT
+#define HAVE_NONE_SERIALIZED_ACCEPT
+#define USE_LONGJMP
+#undef NO_KILLPG
+#undef NO_SETSID
+#undef NO_USE_SIGACTION
+#undef NO_LINGCLOSE
+extern char *crypt(char *pw, char *salt);
+typedef int rlim_t;
+#define HAVE_SYSLOG 1
+
+{$else}{$if defined(UXPDS)}
+#undef NEED_STRCASECMP
+#undef NEED_STRNCASECMP
+#undef NEED_STRDUP
+#undef HAVE_GMTOFF
+#define NO_KILLPG
+#undef NO_SETSID
+#define bzero(a,b) memset(a,0,b)
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#define HAVE_MMAP 1
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES
+#define HAVE_SYSLOG 1
+
+{$else}{$if defined(OS2)}
+{ Defines required for EMX OS/2 port. }
+#define NO_KILLPG
+#define NEED_STRCASECMP
+#define NEED_STRNCASECMP
+#define NEED_PROCESS_H
+#define NO_SETSID
+#define NO_TIMES
+#define CASE_BLIND_FILESYSTEM
+{ Add some drive name support }
+#define chdir _chdir2
+#include <sys/time.h>
+#define MAXSOCKETS 2048
+#define USE_OS2_SCOREBOARD
+#define NO_RELIABLE_PIPED_LOGS
+#define HAVE_OS2SEM_SERIALIZED_ACCEPT
+#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+#define NO_SLACK
+#define FOPEN_REQUIRES_T
+
+{$else}{$if defined(__MACHTEN__)}
+typedef int rlim_t;
+#undef NO_KILLPG
+#define NO_SETSID
+#define HAVE_GMTOFF 1
+#ifndef __MACHTEN_PPC__
+#ifndef __MACHTEN_68K__
+#define __MACHTEN_68K__
+#endif
+#define HAVE_FLOCK_SERIALIZED_ACCEPT
+#define NO_USE_SIGACTION
+#define JMP_BUF sigjmp_buf
+#define USE_LONGJMP
+#undef NEED_STRDUP
+#else
+#define HAVE_SHMGET 1
+#define USE_SHMGET_SCOREBOARD
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#endif
+
+{ Convex OS v11 }
+{$else}{$if defined(CONVEXOS11)}
+#undef HAVE_GMTOFF
+#undef NO_KILLPG
+#undef NO_SETSID
+#undef NEED_STRDUP
+#define HAVE_MMAP 1
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES
+#define HAVE_SYSLOG 1
+
+#define NO_TIMEZONE
+#include <stdio.h>
+#include <sys/types.h>
+typedef int rlim_t;
+
+{$else}{$if defined(ISC)}
+#include <net/errno.h>
+#define NO_KILLPG
+#undef NO_SETSID
+#define HAVE_SHMGET 1
+#define USE_SHMGET_SCOREBOARD
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#define HAVE_SYSLOG 1
+
+{$else}{$if defined(NEWSOS)}
+#define HAVE_SHMGET 1
+#define USE_SHMGET_SCOREBOARD
+#define USE_LONGJMP
+#define NO_SETSID
+#define NO_USE_SIGACTION
+#define NEED_WAITPID
+#define NO_OTHER_CHILD
+#define HAVE_SYSLOG 1
+#include <sys/time.h>
+#include <stdlib.h>
+#include <sys/types.h>
+typedef int pid_t;
+typedef int rlim_t;
+typedef int mode_t;
+
+{$else}{$if defined(RISCIX)}
+#include <sys/time.h>
+typedef int rlim_t;
+#define NO_USE_SIGACTION
+#define USE_LONGJMP
+#define NEED_STRCASECMP
+#define NEED_STRNCASECMP
+#define NEED_STRDUP
+
+{$else}{$if defined(BEOS)}
+#undef PLATFORM
+#define PLATFORM "BeOS"
+#include <stddef.h>
+#include <kernel/OS.h>
+
+#define HAVE_BEOS_SERIALIZED_ACCEPT
+#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+
+#define NO_WRITEV
+#define NO_KILLPG
+#define NEED_INITGROUPS
+#define PF_INET AF_INET
+#define S_IEXEC S_IXUSR
+
+{$else}{$if defined(BONE)}
+#undef PLATFORM
+#define PLATFORM "BeOS BONE"
+#include <kernel/OS.h>
+
+#define NO_KILLPG
+#define NEED_INITGROUPS
+#define S_IEXEC S_IXUSR
+#define HAVE_BEOS_SERIALIZED_ACCEPT
+#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+
+{$else}{$if defined(_CX_SX)}
+#define JMP_BUF sigjmp_buf
+#include <sys/types.h>
+#include <sys/time.h>
+
+{$else}{$if defined(WIN32)}
+
+{ All windows stuff is now in os/win32/os.h }
+
+{$include win32_os.inc}
+
+{$else}{$if defined(TPF)} { IBM Transaction Processing Facility operating system }
+
+{ All TPF definitions are now in os/tpf/os.h }
+
+{$else}{$if defined(__TANDEM)}
+#define NO_WRITEV
+#define NO_KILLPG
+#define NEED_INITGROUPS
+#define NO_SLACK
+
+{$else}{$if defined(OS390)}                { IBM OS/390 Operating System      }
+#define HAVE_MMAP
+#define HAVE_SHMGET
+#define USE_SHMGET_SCOREBOARD
+#define USE_MMAP_FILES
+#define NEED_UNION_SEMUN
+#define HAVE_SYSVSEM_SERIALIZED_ACCEPT
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#define _POSIX_SOURCE
+#include <signal.h>
+#ifdef SIGDUMP  { SIGDUMP is not defined by OS/390 v1r2 }
+#define NSIG SIGDUMP+1
+#else
+#define NSIG 40
+#endif
+#define JMP_BUF sigjmp_buf
+#define _XOPEN_SOURCE_EXTENDED 1
+#define _OPEN_MSGQ_EXT
+#define _XOPEN_SOURCE
+#define SHM_R S_IRUSR
+#define SHM_W S_IWUSR
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/msg.h>
+#include <sys/socket.h>
+#define NET_SIZE_T size_t
+#define NEED_HASHBANG_EMUL
+#define NONBLOCK_WHEN_MULTI_LISTEN
+
+{$else}{$if defined(CYGWIN)}               { Cygwin 1.x POSIX layer for Win32 }
+#define SYSTEM_UID 18
+#define JMP_BUF jmp_buf
+#define NO_KILLPG
+#define NO_SETSID
+#define USE_LONGJMP
+#define GDBM_STATIC
+#define HAVE_MMAP 1
+#define USE_MMAP_SCOREBOARD
+#define USE_MMAP_FILES
+#define HAVE_SYSLOG 1
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#define HAVE_PTHREAD_SERIALIZED_ACCEPT
+#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
+#if !defined(USE_FCNTL_SERIALIZED_ACCEPT)
+#define USE_PTHREAD_SERIALIZED_ACCEPT
+#endif
+
+{$else}{$if defined(NETWARE)}
+#define NONBLOCK_WHEN_MULTI_LISTEN
+
+{$else}
+  { Unknown system - Edit these to match }
+  {$ifdef BSD}
+    {$define HAVE_GMTOFF}
+  {$else}
+    {$undefine HAVE_GMTOFF}
+  {$endif}
+  { NO_KILLPG is set on systems that don't have killpg }
+  {$undefine NO_KILLPG}
+  { NO_SETSID is set on systems that don't have setsid }
+  {$undefine NO_SETSID}
+  { NEED_STRDUP is set on stupid systems that don't have strdup. }
+  {$undefine NEED_STRDUP}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+
+//#ifdef HAVE_SYS_PARAM_H
+//#include <sys/param.h>
+//#endif { HAVE_SYS_PARAM_H }
+
+{ stuff marked API_EXPORT is part of the API, and intended for use
+ * by modules
+ }
+//#ifndef API_EXPORT
+//#define API_EXPORT(type)    type
+//#endif
+
+{ Stuff marked API_EXPORT_NONSTD is part of the API, and intended for
+ * use by modules.  The difference between API_EXPORT and
+ * API_EXPORT_NONSTD is that the latter is required for any functions
+ * which use varargs or are used via indirect function call.  This
+ * is to accomodate the two calling conventions in windows dlls.
+ }
+{#ifndef API_EXPORT_NONSTD
+#define API_EXPORT_NONSTD(type)    type
+#endif
+
+#ifndef MODULE_VAR_EXPORT
+#define MODULE_VAR_EXPORT
+#endif
+#ifndef API_VAR_EXPORT
+#define API_VAR_EXPORT
+#endi}
+
+{ modules should not used functions marked CORE_EXPORT
+ * or CORE_EXPORT_NONSTD }
+{#ifndef CORE_EXPORT
+#define CORE_EXPORT	API_EXPORT
+#endif
+#ifndef CORE_EXPORT_NONSTD
+#define CORE_EXPORT_NONSTD	API_EXPORT_NONSTD
+#endif
+}
+{ On Darwin, symbols that conflict with loaded dylibs
+ * (eg. System framework) need to be declared as private symbols with
+ * __private_extern__.
+ * For other systems, make that a no-op.
+ }
+{#if defined(DARWIN) && defined(__DYNAMIC__)
+#define ap_private_extern __private_extern__
+#else
+#define ap_private_extern
+#endif}
+
+{
+ * The particular directory style your system supports. If you have dirent.h
+ * in /usr/include (POSIX) or /usr/include/sys (SYSV), #include 
+ * that file and define DIR_TYPE to be dirent. Otherwise, if you have 
+ * /usr/include/sys/dir.h, define DIR_TYPE to be direct and include that
+ * file. If you have neither, I'm confused.
+ }
+
+{#ifndef NETWARE
+#include <sys/types.h>
+#endif
+#include <stdarg.h>}
+
+{#if !defined(NEXT) && !defined(WIN32)
+#include <dirent.h>
+#define DIR_TYPE dirent
+#elif !defined(WIN32)
+#include <sys/dir.h>
+#define DIR_TYPE direct
+#else
+#define DIR_TYPE dirent
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef __TANDEM
+#include <strings.h>
+#endif
+#include "ap_ctype.h"
+#if !defined(MPE) && !defined(WIN32) && !defined(TPF41) && !defined(__TANDEM) && !defined(NETWARE)
+#include <sys/file.h>
+#endif
+#if !defined(WIN32) && !defined(NETWARE)
+#include <sys/socket.h>
+#ifdef HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#endif }{ HAVE_SYS_SELECT_H }
+{#ifndef TPF41
+#include <netinet/in.h>
+#endif }{ ndef TPF41 }
+{#if defined(OS390) && !defined(NO_ADDRESS)
+#define NO_ADDRESS NO_DATA } { Not defined properly by OS/390 v1r2 }
+{#endif
+#include <netdb.h>
+#include <sys/ioctl.h>
+#if !defined(MPE) && !defined(BEOS) && !defined(TPF41)
+#include <arpa/inet.h>		}{ for inet_ntoa }
+{#endif
+#include <sys/wait.h>
+#include <pwd.h>
+#include <grp.h>
+#include <fcntl.h>
+#ifndef BEOS
+#define closesocket(s) close(s)
+#endif
+#ifndef O_BINARY
+#define O_BINARY (0)
+#endif
+#endif }{ ndef WIN32 }
+
+{#include <limits.h>
+#include <time.h>}		{ for ctime }
+{#ifdef WIN32
+#define strftime(s,max,format,tm)  os_strftime(s,max,format,tm)
+#endif
+#include <signal.h>
+#ifdef NETWARE
+#undef SIGKILL
+#undef SA_NOCLDSTOP
+#undef SIGALRM
+#undef SIGCHILD
+#undef SIGCONT
+#undef SIGHUP
+#undef SIGPIPE
+#undef SIGQUIT
+#undef SIGSTOP
+#undef SIGTSTP
+#undef SIGTTIN
+#undef SIGTTOU
+#undef SIGUSR1
+#undef SIGUSR2
+#undef SIG_BLOCK
+#undef SIG_SETMASK
+#undef SIG_UNBLOCK
+#endif
+#if defined(TPF41) && defined(NSIG)
+#undef NSIG
+#endif
+#include <errno.h>
+#if !defined(QNX) && !defined(CONVEXOS11) && !defined(NEXT) && !defined(TPF41) && !defined(NETWARE) && !defined(MPE)
+#include <memory.h>
+#endif
+
+#ifdef NEED_PROCESS_H
+#include <process.h>
+#endif}
+
+{#if defined(WIN32) || defined(USE_HSREGEX)
+#include "hsregex.h"
+#else
+#include <regex.h>
+#endif}
+
+{$include hsregex.inc}
+
+{#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#ifdef SUNOS4
+int getrlimit(int, struct rlimit *);
+int setrlimit(int, struct rlimit *);
+#endif
+#endif
+#ifdef USE_MMAP_SCOREBOARD
+#if !defined(OS2) && !defined(WIN32)}
+{ This file is not needed for OS/2 }
+{#include <sys/mman.h>
+#endif
+#endif
+#if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
+#define MAP_ANON MAP_ANONYMOUS
+#endif
+
+#if defined(USE_MMAP_FILES) && (defined(NO_MMAP) || !defined(HAVE_MMAP))
+#undef USE_MMAP_FILES
+#endif
+
+#if defined(USE_MMAP_SCOREBOARD) && (defined(NO_MMAP) || !defined(HAVE_MMAP))
+#undef USE_MMAP_SCOREBOARD
+#endif
+
+#if defined(USE_SHMGET_SCOREBOARD) && (defined(NO_SHMGET) || !defined(HAVE_SHMGET))
+#undef USE_SHMGET_SCOREBOARD
+#endif}
+
+{ A USE_FOO_SERIALIZED_ACCEPT implies a HAVE_FOO_SERIALIZED_ACCEPT }
+{#if defined(USE_USLOCK_SERIALIZED_ACCEPT) && !defined(HAVE_USLOCK_SERIALIZED_ACCEPT)
+#define HAVE_USLOCK_SERIALIZED_ACCEPT
+#endif
+#if defined(USE_PTHREAD_SERIALIZED_ACCEPT) && !defined(HAVE_PTHREAD_SERIALIZED_ACCEPT)
+#define HAVE_PTHREAD_SERIALIZED_ACCEPT
+#endif
+#if defined(USE_SYSVSEM_SERIALIZED_ACCEPT) && !defined(HAVE_SYSVSEM_SERIALIZED_ACCEPT)
+#define HAVE_SYSVSEM_SERIALIZED_ACCEPT
+#endif
+#if defined(USE_FCNTL_SERIALIZED_ACCEPT) && !defined(HAVE_FCNTL_SERIALIZED_ACCEPT)
+#define HAVE_FCNTL_SERIALIZED_ACCEPT
+#endif
+#if defined(USE_FLOCK_SERIALIZED_ACCEPT) && !defined(HAVE_FLOCK_SERIALIZED_ACCEPT)
+#define HAVE_FLOCK_SERIALIZED_ACCEPT
+#endif
+#if defined(USE_OS2SEM_SERIALIZED_ACCEPT) && !defined(HAVE_OS2SEM_SERIALIZED_ACCEPT)
+#define HAVE_OS2SEM_SERIALIZED_ACCEPT
+#endif
+#if defined(USE_TPF_CORE_SERIALIZED_ACCEPT) && !defined(HAVE_TPF_CORE_SERIALIZED_ACCEPT)
+#define HAVE_TPF_CORE_SERIALIZED_ACCEPT
+#endif
+#if defined(USE_BEOS_SERIALIZED_ACCEPT) && !defined(HAVE_BEOS_SERIALIZED_ACCEPT)
+#define HAVE_BEOS_SERIALIZED_ACCEPT
+#endif
+#if defined(USE_NONE_SERIALIZED_ACCEPT) && !defined(HAVE_NONE_SERIALIZED_ACCEPT)
+#define HAVE_NONE_SERIALIZED_ACCEPT
+#endif}
+
+  LOGNAME_MAX = 25;
+
+//#ifdef HAVE_UNISTD_H
+//#include <unistd.h>
+//#endif
+
+//#ifdef ultrix
+//#define ULTRIX_BRAIN_DEATH
+//#endif
+
+{#ifndef S_ISLNK
+#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+#endif
+
+#ifndef INADDR_NONE
+#define INADDR_NONE ((unsigned long) -1)
+#endif}
+
+{
+ * Replace signal function with sigaction equivalent
+ }
+{#ifndef NO_USE_SIGACTION
+typedef void Sigfunc(int);
+
+#if defined(SIG_IGN) && !defined(SIG_ERR)
+#define SIG_ERR ((Sigfunc *)-1)
+#endif}
+
+{
+ * For some strange reason, QNX defines signal to signal. Eliminate it.
+ }
+{#ifdef signal
+#undef signal
+#endif
+#define signal(s,f)	ap_signal(s,f)
+Sigfunc *signal(int signo, Sigfunc * func);
+#endif
+
+#include <setjmp.h>
+
+#if defined(USE_LONGJMP)
+#define ap_longjmp(x, y)        longjmp((x), (y))
+#define ap_setjmp(x)            setjmp(x)
+#ifndef JMP_BUF
+#define JMP_BUF jmp_buf
+#endif
+#else
+#define ap_longjmp(x, y)        siglongjmp((x), (y))
+#define ap_setjmp(x)            sigsetjmp((x), 1)
+#ifndef JMP_BUF
+#define JMP_BUF sigjmp_buf
+#endif
+#endif}
+
+{ Majority of os's want to verify FD_SETSIZE }
+{#if !defined(WIN32) && !defined(TPF) && !defined(NETWARE)
+#define CHECK_FD_SETSIZE
+#endif
+
+#ifdef USE_TPF_SELECT
+#define ap_select(_a, _b, _c, _d, _e)	\
+	tpf_select(_a, _b, _c, _d, _e)
+#elif defined(SELECT_NEEDS_CAST)
+#define ap_select(_a, _b, _c, _d, _e)   \
+    select((_a), (int *)(_b), (int *)(_c), (int *)(_d), (_e))
+#else
+#define ap_select(_a, _b, _c, _d, _e)   \
+	select(_a, _b, _c, _d, _e)
+#endif
+
+#ifdef USE_TPF_ACCEPT
+#define ap_accept(_fd, _sa, _ln)	tpf_accept(_fd, _sa, _ln)
+#else
+#define ap_accept(_fd, _sa, _ln)	accept(_fd, _sa, _ln)
+#endif
+
+#ifdef NEED_SIGNAL_INTERRUPT
+#define ap_check_signals()	tpf_process_signals()
+#else
+#define ap_check_signals()
+#endif
+
+#ifdef ULTRIX_BRAIN_DEATH
+#define ap_fdopen(d,m) fdopen((d), (char *)(m))
+#else
+#define ap_fdopen(d,m) fdopen((d), (m))
+#endif
+
+#ifndef ap_inet_addr
+#define ap_inet_addr inet_addr
+#endif
+
+#ifdef NO_OTHER_CHILD
+#define NO_RELIABLE_PIPED_LOGS
+#endif}
+
+{ When the underlying OS doesn't support exec() of scripts which start
+ * with a HASHBANG (#!) followed by interpreter name and args, define this.
+ }
+{#ifdef NEED_HASHBANG_EMUL
+extern int ap_execle(const char *filename, const char *arg,...);
+extern int ap_execve(const char *filename, char * const argv[],
+                     char * const envp[]);}
+{ ap_execle() is a wrapper function around ap_execve(). }
+{#define execle  ap_execle
+#define execve(path,argv,envp)  ap_execve(path,argv,envp)
+#endif}
+
+{ Finding offsets of elements within structures.
+ * Taken from the X code... they've sweated portability of this stuff
+ * so we don't have to.  Sigh...
+ }
+
+{#if defined(CRAY) || (defined(__arm) && !defined(LINUX))
+#ifdef __STDC__
+#define XtOffset(p_type,field) _Offsetof(p_type,field)
+#else
+#ifdef CRAY2
+#define XtOffset(p_type,field) \
+	(sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
+
+#else} { !CRAY2 }
+
+{#define XtOffset(p_type,field) ((unsigned int)&(((p_type)NULL)->field))
+
+#endif }{ !CRAY2 }
+//#endif { __STDC__ }
+//#else { ! (CRAY || __arm) }
+
+//#define XtOffset(p_type,field) \
+//	((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
+
+//#endif { !CRAY }
+
+{#ifndef XtOffsetOf
+#ifdef offsetof
+#define XtOffsetOf(s_type,field) offsetof(s_type,field)
+#else
+#define XtOffsetOf(s_type,field) XtOffset(s_type*,field)
+#endif
+#endif}
+
+{
+ * NET_SIZE_T exists because of shortsightedness on the POSIX committee.  BSD
+ * systems used "int *" as the parameter to accept(), getsockname(),
+ * getpeername() et al.  Consequently many unixes took an int * for that
+ * parameter.  The POSIX committee decided that "int" was just too generic and
+ * had to be replaced with size_t almost everywhere.  There's no problem with
+ * that when you're passing by value.  But when you're passing by reference
+ * this creates a gross source incompatibility with existing programs.  On
+ * 32-bit architectures it creates only a warning.  On 64-bit architectures it
+ * creates broken code -- because "int *" is a pointer to a 64-bit quantity and
+ * "size_t *" is frequently a pointer to a 32-bit quantity.
+ *
+ * Some Unixes adopted "size_t *" for the sake of POSIX compliance.  Others
+ * ignored it because it was such a broken interface.  Chaos ensued.  POSIX
+ * finally woke up and decided that it was wrong and created a new type
+ * socklen_t.  The only useful value for socklen_t is int, and that's how
+ * everyone who has a clue implements it.  It is almost always the case that
+ * NET_SIZE_T should be defined to be an int, unless the system being compiled
+ * for was created in the window of POSIX madness.
+ }
+type NET_SIZE_T = cint;
+
+{ Linux defines __WCOREDUMP, but doesn't define WCOREDUMP unless __USE_BSD
+ * is in use... we'd prefer to just use WCOREDUMP everywhere.
+ }
+//#if defined(__WCOREDUMP) && !defined(WCOREDUMP)
+//#define WCOREDUMP __WCOREDUMP
+//#endif
+
+//#ifdef SUNOS_LIB_PROTOTYPES
+{ Prototypes needed to get a clean compile with gcc -Wall.
+ * Believe it or not, these do have to be declared, at least on SunOS,
+ * because they aren't mentioned in the relevant system headers.
+ * Sun Quality Software.  Gotta love it.  This section is not 
+ * currently (13Nov97) used.
+ }
+
+{int getopt(int, char **, char *);
+
+int strcasecmp(const char *, const char *);
+int strncasecmp(const char *, const char *, int);
+int toupper(int);
+int tolower(int);
+
+int printf(char *,...);
+int fprintf(FILE *, char *,...);
+int fputs(char *, FILE *);
+int fread(char *, int, int, FILE *);
+int fwrite(char *, int, int, FILE *);
+int fgetc(FILE *);
+char *fgets(char *s, int, FILE*);
+int fflush(FILE *);
+int fclose(FILE *);
+int ungetc(int, FILE *);
+int _filbuf(FILE *);	}{ !!! }
+//int _flsbuf(unsigned char, FILE *);	{ !!! }
+{int sscanf(char *, char *,...);
+void setbuf(FILE *, char *);
+void perror(char *);
+
+time_t time(time_t *);
+int strftime(char *, int, const char *, struct tm *);
+
+int initgroups(char *, int);}
+//int wait3(int *, int, void *);	{ Close enough for us... }
+{int lstat(const char *, struct stat *);
+int stat(const char *, struct stat *);
+int flock(int, int);
+#ifndef NO_KILLPG
+int killpg(int, int);
+#endif
+int socket(int, int, int);
+int setsockopt(int, int, int, const char *, int);
+int listen(int, int);
+int bind(int, struct sockaddr *, int);
+int connect(int, struct sockaddr *, int);
+int accept(int, struct sockaddr *, int *);
+int shutdown(int, int);
+
+int getsockname(int s, struct sockaddr *name, int *namelen);
+int getpeername(int s, struct sockaddr *name, int *namelen);
+int gethostname(char *name, int namelen);
+void syslog(int, char *,...);
+char *mktemp(char *);
+
+int vfprintf(FILE *, const char *, va_list);
+
+#endif} { SUNOS_LIB_PROTOTYPES }
+
+{ The assumption is that when the functions are missing,
+ * then there's no matching prototype available either.
+ * Declare what is needed exactly as the replacement routines implement it.
+ }
+{#ifdef NEED_STRDUP
+extern char *strdup (const char *str);
+#endif
+#ifdef NEED_STRCASECMP
+extern int strcasecmp (const char *a, const char *b);
+#endif
+#ifdef NEED_STRNCASECMP
+extern int strncasecmp (const char *a, const char *b, int n);
+#endif
+#ifdef NEED_INITGROUPS
+extern int initgroups(const char *name, gid_t basegid);
+#endif
+#ifdef NEED_WAITPID
+extern int waitpid(pid_t pid, int *statusp, int options);
+#endif
+#ifdef NEED_STRERROR
+extern char *strerror (int err);
+#endif
+#ifdef NEED_DIFFTIME
+extern double difftime(time_t time1, time_t time0);
+#endif}
+
+{$ifndef ap_wait_t}
+type
+  ap_wait_t = cint;
+{$endif}
+

+ 237 - 0
packages/base/httpd/httpd-1.3/ap_mmn.inc

@@ -0,0 +1,237 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * MODULE_MAGIC_NUMBER_MAJOR
+ * Major API changes that could cause compatibility problems for older modules
+ * such as structure size changes.  No binary compatibility is possible across
+ * a change in the major version.
+ *
+ * MODULE_MAGIC_NUMBER_MINOR
+ * Minor API changes that do not cause binary compatibility problems.
+ * Should be reset to 0 when upgrading MODULE_MAGIC_NUMBER_MAJOR.
+ *
+ * See the MODULE_MAGIC_AT_LEAST macro below for an example.
+ }
+
+{
+ * 19950525		- original value
+ * 19960512 (1.1b2)	- updated, 1.1, version.
+ * 19960526 (1.1b3)	- get_token(), table_unset(), pstrndup()
+ *			  functions added
+ * 19960725 (1.2-dev)	- HTTP/1.1 compliance
+ *			  (new version of read_client_block)
+ * 19960806 (1.2-dev)	- scan_script_header_err() added
+ * 19961007 (1.2-dev)	- replace read_client_block() with get_client_block()
+ * 19961125 (1.2b1)	- change setup_client_block() to Roy's version
+ * 19961211 (1.2b3)	- rwrite() added
+ * 19970103 (1.2b5-dev)	- header parse API
+ * 19970427 (1.2b9-dev)	- port references made unsigned
+ * 19970526 (1.2)	- correct vhost walk for multiple requests on a single
+ *			  connect
+ * 19970623 (1.3-dev)	- NT changes
+ * 19970628 (1.3-dev)	- ap_slack (fd fixes) added
+ * 19970717 (1.3-dev)	- child_init API hook added
+ * 19970719 (1.3-dev)	- discard_request_body() added (to clear the decks
+ *			  as needed)
+ * 19970728 (1.3a2-dev)	- child_exit API hook added
+ * 19970818 (1.3a2-dev)	- post read-request phase added
+ * 19970825 (1.3a2-dev)	- r->mtime cell added
+ * 19970831 (1.3a2-dev)	- error logging changed to use aplog_error()
+ * 19970902 (1.3a2-dev)	- MD5 routines and structures renamed to ap_*
+ * 19970912 (1.3b1-dev)	- set_last_modified split into set_last_modified,
+ * 			  set_etag and meets_conditions
+ *			  register_other_child API
+ *			  piped_log API
+ *			  short_score split into parent and child pieces
+ *			  os_is_absolute_path
+ * 19971026 (1.3b3-dev)	- custom config hooks in place
+ * 19980126 (1.3b4-dev)	- ap_cpystrn(), table_addn(), table_setn(),
+ *			  table_mergen()
+ * 19980201 (1.3b4-dev)	- construct_url()
+ *			  prototype server_rec * -> request_rec *
+ *			  add get_server_name() and get_server_port()
+ * 19980207 (1.3b4-dev)	- add dynamic_load_handle to module structure as part
+ *			  of the STANDARD_MODULE_STUFF header
+ * 19980304 (1.3b6-dev)	- abstraction of SERVER_BUILT and SERVER_VERSION
+ * 19980305 (1.3b6-dev)	- ap_config.h added for use by external modules
+ * 19980312 (1.3b6-dev)	- parse_uri_components() and its ilk
+ *			  remove r->hostlen, add r->unparsed_uri
+ *			  set_string_slot_lower()
+ *			  clarification: non-RAW_ARGS cmd handlers do not
+ *			  need to pstrdup() their arguments
+ *			  clarification: request_rec members content_type,
+ *			  handler, content_encoding, content_language,
+ *			  content_languages MUST all be lowercase strings,
+ *			  and MAY NOT be modified in place -- modifications
+ *			  require pstrdup().
+ * 19980317 (1.3b6-dev)	- CORE_EXPORTs for win32 and <Perl>
+ *			  API export basic_http_header, send_header_field,
+ *			  set_keepalive, srm_command_loop, check_cmd_context,
+ *			  tm2sec
+ *			  spacetoplus(), plustospace(), client_to_stdout()
+ *			  removed
+ * 19980324 (1.3b6-dev)	- API_EXPORT(index_of_response)
+ * 19980413 (1.3b6-dev)	- The BIG SYMBOL RENAMING: general ap_ prefix
+ *			  (see src/include/compat.h for more details)
+ *			  ap_vformatter() API, see src/include/ap.h
+ * 19980507 (1.3b7-dev)	- addition of ap_add_version_component() and
+ *			  discontinuation of -DSERVER_SUBVERSION support
+ * 19980519 (1.3b7-dev)	- add child_info * to spawn function (as passed to
+ *			  ap_spawn_child_err_buff) and to ap_call_exec to make
+ *			  children work correctly on Win32.
+ * 19980527 (1.3b8-dev)	- renamed some more functions to ap_ prefix which were
+ *			  missed at the big renaming (they are defines):
+ *			  is_default_port, default_port and http_method.
+ *			  A new communication method for modules was added:
+ *			  they can create customized error messages under the
+ *			  "error-notes" key in the request_rec->notes table.
+ *			  This string will be printed in place of the canned
+ *			  error responses, and will be propagated to
+ *			  ErrorDocuments or cgi scripts in the
+ *			  (REDIRECT_)ERROR_NOTES variable.
+ * 19980627 (1.3.1-dev)	- More renaming that we forgot/bypassed. In particular:
+ *			  table_elts --> ap_table_elts
+ *			  is_table_empty --> ap_is_table_empty
+ * 19980708 (1.3.1-dev)	- ap_isalnum(), ap_isalpha(), ... "8-bit safe" ctype
+ *			  macros and apctype.h added
+ * 19980713 (1.3.1-dev)	- renaming of C header files:
+ *			  1. conf.h      -> ap_config.h
+ *			  2. conf_auto.h -> ap_config_auto.h - now merged
+ *			  3. ap_config.h -> ap_config_auto.h - now merged
+ *			  4. compat.h    -> ap_compat.h
+ *			  5. apctype.h   -> ap_ctype.h
+ * 19980806 (1.3.2-dev) - add ap_log_rerror()
+ *                      - add ap_scan_script_header_err_core()
+ *                      - add ap_uuencode()
+ *                      - add ap_custom_response()
+ * 19980811 (1.3.2-dev)	- added limit_req_line, limit_req_fieldsize, and
+ *			  limit_req_fields to server_rec.
+ *			  added limit_req_body to core_dir_config and
+ *			  ap_get_limit_req_body() to get its value.
+ * 19980812 (1.3.2-dev)	- split off MODULE_MAGIC_NUMBER
+ * 19980812.2           - add ap_overlap_tables()
+ * 19980816 (1.3.2-dev)	- change proxy to use tables for headers, change
+ *                        struct cache_req to typedef cache_req.
+ *                        Delete ap_proxy_get_header(), ap_proxy_add_header(),
+ *                        ap_proxy_del_header(). Change interface of 
+ *                        ap_proxy_send_fb() and ap_proxy_cache_error(). 
+ *                        Add ap_proxy_send_hdr_line() and ap_proxy_bputs2().
+ * 19980825 (1.3.2-dev) - renamed is_HTTP_xxx() macros to ap_is_HTTP_xxx()
+ * 19980825.1           - mod_proxy only (minor change): modified interface of
+ *                        ap_proxy_read_headers() and rdcache() to use a
+ *                        request_rec* instead of pool*
+ *                        (for implementing better error reporting).
+ * 19980906 (1.3.2-dev) - added ap_md5_binary()
+ * 19980917 (1.3.2-dev) - bs2000: changed os_set_authfile() to os_set_account()
+ * 19981108 (1.3.4-dev) - added ap_method_number_of()
+ *                      - changed value of M_INVALID and added WebDAV methods
+ * 19981108.1           - ap_exists_config_define() is now public (minor bump)
+ * 19981204             - scoreboard changes -- added generation, changed
+ *                        exit_generation to running_generation.  Somewhere
+ *                        earlier vhostrec was added, but it's only safe to use
+ *                        as of this rev.  See scoreboard.h for documentation.
+ * 19981211             - DSO changes -- added ap_single_module_configure()
+ *                                    -- added ap_single_module_init()
+ * 19981229             - mod_negotiation overhaul -- added ap_make_etag()
+ *                        and added vlist_validator to request_rec.
+ * 19990101             - renamed macro escape_uri() to ap_escape_uri()
+ *                      - added MODULE_MAGIC_COOKIE to identify module structs
+ * 19990103 (1.3.4-dev) - added ap_array_pstrcat()
+ * 19990105 (1.3.4-dev) - added ap_os_is_filename_valid()
+ * 19990106 (1.3.4-dev) - Move MODULE_MAGIC_COOKIE to the end of the
+ *                        STANDARD_MODULE_STUFF macro so the version
+ *                        numbers and file name remain at invariant offsets
+ * 19990108 (1.3.4-dev) - status_drops_connection -> ap_status_drops_connection
+ *                        scan_script_header -> ap_scan_script_header_err
+ *                      - reordered entries in request_rec that were waiting
+ *                        for a non-binary-compatible release.
+ *          (1.3.5-dev)
+ * 19990108.1           - add ap_MD5Encode() for MD5 password handling.
+ * 19990108.2           - add ap_validate_password() and change ap_MD5Encode()
+ *                        to use a stronger algorithm.
+ * 19990108.4           - add ap_size_list_item(), ap_get_list_item(), and
+ *                        ap_find_list_item()
+ * 19990108.5           - added ap_sub_req_method_uri() and added const to the
+ *                        definition of method in request_rec.
+ * 19990108.6           - SIGPIPE is now ignored by the core server.
+ * 19990108.7           - ap_isxdigit added
+ * 19990320             - METHODS and M_INVALID symbol values modified
+ * 19990320.1           - add ap_vrprintf()
+ * 19990320.2           - add cmd_parms.context, ap_set_config_vectors, 
+ *                        export ap_add_file_conf
+ * 19990320.3           - add ap_regexec() and ap_regerror()
+ * 19990320.4           - add ap_field_noparam()
+ * 19990320.5           - add local_ip/host to conn_rec for mass-vhost
+ * 19990320.6           - add ap_SHA1Final(), ap_SHA1Init(),
+ *                        ap_SHA1Update_binary(), ap_SHA1Update(),
+ *                        ap_base64encode(), ap_base64encode_binary(),
+ *                        ap_base64encode_len(), ap_base64decode(),
+ *                        ap_base64decode_binary(), ap_base64decode_len(),
+ *                        ap_pbase64decode(), ap_pbase64encode()
+ * 19990320.7           - add ap_strcasestr()
+ * 19990320.8           - add request_rec.case_preserved_filename
+ * 19990320.9           - renamed alloc.h to ap_alloc.h
+ * 19990320.10          - add ap_is_rdirectory() and ap_stripprefix()
+ * 19990320.11          - Add a couple of fields, callback_data and
+ *                        filter_callback to the end of buff.h
+ * 19990320.11          - Add some fields to the end of the core_dir_config
+ *                        structure
+ * 19990320.12		- add ap_getline(), ap_get_chunk_size()
+ * 19990320.13          - add ap_strtol()
+ * 19990320.14          - add ap_register_cleanup_ex(),
+ *                        ap_note_cleanups_for_fd_ex(),
+ *                        ap_note_cleanups_for_socket_ex(),
+ *                        ap_note_cleanups_for_file_ex(),
+ *                        ap_popenf_ex() and ap_psocket_ex().
+ * 19990320.15          - ap_is_recursion_limit_exceeded()
+ * 19990320.16          - ap_escape_errorlog_item()
+ * 19990320.17          - ap_auth_nonce() and ap_auth_nonce added
+ *                        in core_dir_config.
+ * 19990320.18          - trace_enable member added to core server_config
+ }
+
+const
+  MODULE_MAGIC_COOKIE = $41503133; { "AP13" }
+
+  MODULE_MAGIC_NUMBER_MAJOR = 19990320;
+  MODULE_MAGIC_NUMBER_MINOR = 18;                    { 0...n }
+
+{ Useful for testing for features. }
+
+{#define AP_MODULE_MAGIC_AT_LEAST(major,minor)		\
+    ((major) < MODULE_MAGIC_NUMBER_MAJOR 		\
+	|| ((major) == MODULE_MAGIC_NUMBER_MAJOR 	\
+	    && (minor) <= MODULE_MAGIC_NUMBER_MINOR))}
+
+{
+ * For example, suppose you wish to use the ap_overlap_tables
+ * function.  You can do this:
+ *
+ * #if AP_MODULE_MAGIC_AT_LEAST(19980812,2)
+ *    ... use ap_overlap_tables()
+ * #else
+ *    ... alternative code which doesn't use ap_overlap_tables()
+ * #endif
+ *
+ }
+
+{ deprecated. present for backwards compatibility }
+
+  MODULE_MAGIC_NUMBER = MODULE_MAGIC_NUMBER_MAJOR;
+
+//#define MODULE_MAGIC_AT_LEAST old_broken_macro_we_hope_you_are_not_using
+

+ 234 - 0
packages/base/httpd/httpd-1.3/buff.inc

@@ -0,0 +1,234 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{$ifdef B_SFIO}
+#include "sfio.h"
+{$endif}
+
+//#include <stdarg.h>
+
+const
+{ Reading is buffered }
+  B_RD    = (1);
+{ Writing is buffered }
+  B_WR    = (2);
+  B_RDWR  = (3);
+{ At end of file, or closed stream; no further input allowed }
+  B_EOF   = (4);
+{ No further output possible }
+  B_EOUT  = (8);
+{ A read error has occurred }
+  B_RDERR =(16);
+{ A write error has occurred }
+  B_WRERR =(32);
+//#ifdef B_ERROR  { in SVR4: sometimes defined in /usr/include/sys/buf.h }
+//#undef B_ERROR
+//#endif
+  B_ERROR =(48);
+{ Use chunked writing }
+  B_CHUNK =(64);
+{ bflush() if a read would block }
+  B_SAFEREAD =(128);
+{ buffer is a socket }
+  B_SOCKET =(256);
+{$ifdef CHARSET_EBCDIC}
+  B_ASCII2EBCDIC = $40000000;  { Enable conversion for this buffer }
+  B_EBCDIC2ASCII = $80000000;  { Enable conversion for this buffer }
+{$endif} {CHARSET_EBCDIC}
+
+type
+  Pbuff_struct = ^buff_struct;
+
+  PBUFF = Pbuff_struct;
+
+  PPBUFF = ^PBUFF;
+
+  error_t = procedure (fb: PBUFF; op: cint; data: Pointer);
+  
+  filter_callback_t = procedure (param1: PBUFF; const param2: Pointer; param3: cint);
+
+  buff_struct = record
+    flags: cint;		{ flags }
+    inptr: PChar;      	        { pointer to next location to read }
+    incnt: cint;		{ number of bytes left to read from input buffer;
+				 * always 0 if had a read error  }
+    outchunk: cint;		{ location of chunk header when chunking }
+    outcnt: cint;		{ number of byte put in output buffer }
+    inbase: PChar;
+    outbase: PChar;
+    bufsiz: cint;
+    error: error_t;
+    error_data: PChar;
+    bytes_sent: clong;  	{ number of bytes actually written }
+
+    pool: Pap_pool;
+
+{ could also put pointers to the basic I/O routines here }
+    fd: cint;			{ the file descriptor }
+    fd_in: cint;		{ input file descriptor, if different }
+{$ifdef WIN32}
+    hFH: HANDLE;		{ Windows filehandle }
+{$endif}
+
+    { transport handle, for RPC binding handle or some such }
+    t_handle: PChar;
+
+{$ifdef B_SFIO}
+    sf_in: PSfio_t;
+    sf_out: PSfio_t;
+{$endif}
+
+    callback_data: Pointer;
+    filter_callback: filter_callback_t;
+	
+  end;
+
+{$ifdef B_SFIO}
+  apache_sfio = record
+    disc: Sfdisc_t;
+    buff: PBUFF;
+  end;
+
+extern Sfdisc_t *bsfio_new(pool *p, BUFF *b);
+{$endif}
+
+{ Options to bset/getopt }
+const
+  BO_BYTECT = (1);
+
+{ Stream creation and modification }
+
+function ap_bcreate(p: PPool; flags: cint): PBUFF;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_bpushfd(fb: PBUFF; fd_in, fd_out: cint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{$ifdef WIN32}
+
+procedure ap_bpushh(fb: PBUFF; hFH: HANDLE);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{$endif}
+
+function ap_bsetopt(fb: PBUFF; optname: cint; const optval: Pointer): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_bgetopt(fb: PBUFF; optname: cint; optval: Pointer): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_bsetflag(fb: PBUFF; flag, value: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_bclose(fb: PBUFF): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+//#define ap_bgetflag(fb, flag)	((fb)->flags & (flag))
+
+{ Error handling }
+
+procedure ap_bonerror(fb: PBUFF; error: error_t; data: Pointer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ I/O }
+function ap_bread(fb: PBUFF; buf: Pointer; nbyte: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+{API_EXPORT(int) ap_bgets(char *s, int n, BUFF *fb);
+API_EXPORT(int) ap_blookc(char *buff, BUFF *fb);
+API_EXPORT(int) ap_bskiplf(BUFF *fb);
+API_EXPORT(int) ap_bwrite(BUFF *fb, const void *buf, int nbyte);
+API_EXPORT(int) ap_bflush(BUFF *fb);
+API_EXPORT(int) ap_bputs(const char *x, BUFF *fb);
+API_EXPORT_NONSTD(int) ap_bvputs(BUFF *fb,...);
+API_EXPORT_NONSTD(int) ap_bprintf(BUFF *fb, const char *fmt,...)
+				__attribute__((format(printf,2,3)));
+API_EXPORT(int) ap_vbprintf(BUFF *fb, const char *fmt, va_list vlist);
+}
+{ Internal routines }
+{API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb);
+API_EXPORT(int) ap_bfilbuf(BUFF *fb);
+
+#ifndef CHARSET_EBCDIC
+
+#define ap_bgetc(fb)   ( ((fb)->incnt == 0) ? ap_bfilbuf(fb) : \
+		    ((fb)->incnt--, *((fb)->inptr++)) )
+
+#define ap_bputc(c, fb) ((((fb)->flags & (B_EOUT|B_WRERR|B_WR)) != B_WR || \
+		     (fb)->outcnt == (fb)->bufsiz) ? ap_bflsbuf(c, (fb)) : \
+		     ((fb)->outbase[(fb)->outcnt++] = (c), 0))
+
+#else} {CHARSET_EBCDIC}
+{
+#define ap_bgetc(fb)   ( ((fb)->incnt == 0) ? ap_bfilbuf(fb) : \
+		    ((fb)->incnt--, (fb->flags & B_ASCII2EBCDIC)\
+		    ?os_toebcdic[(unsigned char)*((fb)->inptr++)]:*((fb)->inptr++)) )
+
+#define ap_bputc(c, fb) ((((fb)->flags & (B_EOUT|B_WRERR|B_WR)) != B_WR || \
+		     (fb)->outcnt == (fb)->bufsiz) ? ap_bflsbuf(c, (fb)) : \
+		     ((fb)->outbase[(fb)->outcnt++] = (fb->flags & B_EBCDIC2ASCII)\
+		     ?os_toascii[(unsigned char)c]:(c), 0))
+
+#endif} {CHARSET_EBCDIC}
+
+type
+  child_info = record
+{$ifdef WIN32}
+    {
+     *  These handles are used by ap_call_exec to call 
+     *  create process with pipe handles.
+     }
+    hPipeInputRead: HANDLE;
+    hPipeOutputWrite: HANDLE;
+    hPipeErrorWrite: HANDLE;
+{$else}
+    {
+     * We need to put a dummy member in here to avoid compilation
+     * errors under certain Unix compilers, like SGI's and HPUX's,
+     * which fail to compile a zero-sized struct.  Of course
+     * it would be much nicer if there was actually a use for this
+     * structure under Unix.  Aah the joys of x-platform code.
+     }
+    dummy: cint;
+{$endif}
+  end;
+  
+  Pchild_info = ^child_info;
+  
+  func_t = function (param1: Pointer; param2: Pchild_info): cint;
+
+function ap_bspawn_child(p: PPool;
+ func: func_t; data: Pointer; kill_how: kill_conditions; pipe_in, pipe_out, pipe_err: PPBUFF): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ enable non-blocking operations }
+function ap_bnonblock(fb: PBUFF; direction: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+{ and get an fd to select() on }
+function ap_bfileno(fb: PBUFF; direction: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ bflush() if a read now would block, but don't actually read anything }
+procedure ap_bhalfduplex(fb: PBUFF);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{$if defined(WIN32) or defined(NETWARE) or defined(CYGWIN_WINSOCK)}
+
+{ ap_recvwithtimeout/ap_sendwithtimeout socket primitives for WinSock }
+//API_EXPORT(int) ap_sendwithtimeout(int sock, const char *buf, int len, int flags);
+//API_EXPORT(int) ap_recvwithtimeout(int sock, char *buf, int len, int flags);
+
+{$endif}
+

+ 97 - 0
packages/base/httpd/httpd-1.3/hsregex.inc

@@ -0,0 +1,97 @@
+{ DON'T EVEN THINK ABOUT EDITING THIS, go see regex/Makefile,
+ * search for mkh }
+
+{ ========= begin header generated by ./mkh ========= }
+
+{ === regex2.h === }
+{#ifndef API_EXPORT
+#ifdef WIN32
+#define API_EXPORT(type)    __declspec(dllexport) type __stdcall
+#else
+#define API_EXPORT(type)    type
+#endif
+#endif}
+
+{#if defined(MAC_OS) || defined(MAC_OS_X_SERVER) || (defined(DARWIN) && defined(__DYNAMIC__))
+#define ap_private_extern __private_extern__
+#else
+#define ap_private_extern
+#endif}
+
+type
+  regoff_t = Integer;
+
+//  off_t = regoff_t;
+
+  Pregex_t = ^regex_t;
+  
+  Pre_guts = Pointer;
+  
+  regex_t = record
+    re_magic: cint;
+    re_nsub: size_t;		{ number of parenthesized subexpressions }
+    re_endp: PChar;     	{ end pointer for REG_PEND }
+    re_g: Pre_guts;	{ none of your business :-) }
+  end;
+
+  regmatch_t = record
+    rm_so: regoff_t;		{ start of match }
+    rm_eo: regoff_t;		{ end of match }
+  end;
+
+
+{ === regcomp.c === }
+//API_EXPORT(int) regcomp(regex_t *, const char *, int);
+
+const
+ 	REG_BASIC	= 0000;
+ 	REG_EXTENDED	= 0001;
+ 	REG_ICASE	= 0002;
+ 	REG_NOSUB	= 0004;
+ 	REG_NEWLINE	= 0010;
+ 	REG_NOSPEC	= 0020;
+ 	REG_PEND	= 0040;
+ 	REG_DUMP	= 0200;
+
+
+{ === regerror.c === }
+ 	REG_NOMATCH	= 1;
+ 	REG_BADPAT	= 2;
+ 	REG_ECOLLATE	= 3;
+ 	REG_ECTYPE	= 4;
+ 	REG_EESCAPE	= 5;
+ 	REG_ESUBREG	= 6;
+ 	REG_EBRACK	= 7;
+ 	REG_EPAREN	= 8;
+ 	REG_EBRACE	= 9;
+ 	REG_BADBR	=10;
+ 	REG_ERANGE	=11;
+ 	REG_ESPACE	=12;
+ 	REG_BADRPT	=13;
+ 	REG_EMPTY	=14;
+ 	REG_ASSERT	=15;
+ 	REG_INVARG	=16;
+ 	REG_ATOI	=255;	{ convert name to number (!) }
+ 	REG_ITOA	=0400;	{ convert number to name (!) }
+
+//API_EXPORT(size_t) regerror(int, const regex_t *, char *, size_t);
+
+
+{ === regexec.c === }
+//API_EXPORT(int) regexec(const regex_t *, const char *, size_t, regmatch_t [], int);
+
+const
+ 	REG_NOTBOL	= 00001;
+ 	REG_NOTEOL	= 00002;
+ 	REG_STARTEND	= 00004;
+ 	REG_TRACE	= 00400;	{ tracing of execution }
+ 	REG_LARGE	= 01000;	{ force large representation }
+ 	REG_BACKR	= 02000;	{ force use of backref code }
+
+
+{ === regfree.c === }
+//API_EXPORT(void) regfree(regex_t *);
+
+
+{ ========= end header generated by ./mkh ========= }
+

+ 402 - 0
packages/base/httpd/httpd-1.3/http_config.inc

@@ -0,0 +1,402 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * The central data structures around here...
+ }
+
+{ Command dispatch structures... }
+
+{ Note that for all of these except RAW_ARGS, the config routine is
+ * passed a freshly allocated string which can be modified or stored
+ * or whatever... it's only necessary to do pstrdup() stuff with
+ * RAW_ARGS.
+ }
+type
+  cmd_how = (
+    RAW_ARGS,			{ cmd_func parses command line itself }
+    TAKE1,			{ one argument only }
+    TAKE2,			{ two arguments only }
+    ITERATE,			{ one argument, occuring multiple times
+				 * (e.g., IndexIgnore)
+                                 }
+    ITERATE2,			{ two arguments, 2nd occurs multiple times
+				 * (e.g., AddIcon)
+                                 }
+    FLAG,			{ One of 'On' or 'Off' }
+    NO_ARGS,			{ No args at all, e.g. </Directory> }
+    TAKE12,			{ one or two arguments }
+    TAKE3,			{ three arguments only }
+    TAKE23,			{ two or three arguments }
+    TAKE123,			{ one, two or three arguments }
+    TAKE13			{ one or three arguments }
+  );
+
+  cs_func_t = function (): PChar;
+  
+  command_struct = record
+    name: PChar;		{ Name of this command }
+    func: cs_func_t;       	{ Function invoked }
+    cmd_data: Pointer;		{ Extra data, for functions which
+				 * implement multiple commands...
+                                 }
+    req_override: cint;		{ What overrides need to be allowed to
+				 * enable this command.
+                                 }
+    args_how: cmd_how;  	{ What the command expects as arguments }
+
+    errmsg: PChar;		{ 'usage' message, in case of syntax errors }
+  end;
+
+  command_rec = command_struct;
+
+  Pcommand_rec = ^command_rec;
+
+{ The allowed locations for a configuration directive are the union of
+ * those indicated by each set bit in the req_override mask.
+ *
+ * (req_override & RSRC_CONF)   => *.conf outside <Directory> or <Location>
+ * (req_override & ACCESS_CONF) => *.conf inside <Directory> or <Location>
+ * (req_override & OR_AUTHCFG)  => *.conf inside <Directory> or <Location>
+ *                                 and .htaccess when AllowOverride AuthConfig
+ * (req_override & OR_LIMIT)    => *.conf inside <Directory> or <Location>
+ *                                 and .htaccess when AllowOverride Limit
+ * (req_override & OR_OPTIONS)  => *.conf anywhere
+ *                                 and .htaccess when AllowOverride Options
+ * (req_override & OR_FILEINFO) => *.conf anywhere
+ *                                 and .htaccess when AllowOverride FileInfo
+ * (req_override & OR_INDEXES)  => *.conf anywhere
+ *                                 and .htaccess when AllowOverride Indexes
+ }
+const
+  OR_NONE = 0;
+  OR_LIMIT = 1;
+  OR_OPTIONS = 2;
+  OR_FILEINFO = 4;
+  OR_AUTHCFG = 8;
+  OR_INDEXES = 16;
+  OR_UNSET = 32;
+  ACCESS_CONF = 64;
+  RSRC_CONF = 128;
+  OR_ALL = (OR_LIMIT or OR_OPTIONS or OR_FILEINFO or OR_AUTHCFG or OR_INDEXES);
+
+{ This can be returned by a function if they don't wish to handle
+ * a command. Make it something not likely someone will actually use
+ * as an error code.
+ }
+
+  DECLINE_CMD = '\a\b';
+
+{
+ * This structure is passed to a command which is being invoked,
+ * to carry a large variety of miscellaneous data which is all of
+ * use to *somebody*...
+ }
+
+type
+  cmd_parms = record
+    info: Pointer;		{ Argument to command from cmd_table }
+    override: cint;		{ Which allow-override bits are set }
+    limited: cint;		{ Which methods are <Limit>ed }
+
+    config_file: Pconfigfile_t;	{ Config file structure from pcfg_openfile() }
+
+    pool: Pap_pool;		{ Pool to allocate new storage in }
+    temp_pool: Ppool;  	        { Pool for scratch memory; persists during
+				 * configuration, but wiped before the first
+				 * request is served...
+                                 }
+    server: Pserver_rec;	{ Server_rec being configured for }
+    path: PChar;	        { If configuring for a directory,
+				 * pathname of that directory.
+				 * NOPE!  That's what it meant previous to the
+				 * existance of <Files>, <Location> and regex
+				 * matching.  Now the only usefulness that can
+				 * be derived from this field is whether a command
+				 * is being called in a server context (path == NULL)
+				 * or being called in a dir context (path != NULL).
+                                 }
+    cmd: Pcommand_rec;	        { configuration command }
+    end_token: PChar;  	        { end token required to end a nested section }
+    context: Pointer;		{ per_dir_config vector passed
+				 * to handle_command }
+  end;
+
+{ This structure records the existence of handlers in a module... }
+
+  handler_t = function (param1: Prequest_rec): Integer; cdecl;
+
+  Phandler_rec = ^handler_rec;
+  
+  handler_rec = record
+    content_type: PChar;	{ MUST be all lower case }
+    handler: handler_t;
+  end;
+
+{
+ * Module structures.  Just about everything is dispatched through
+ * these, directly or indirectly (through the command and handler
+ * tables).
+ }
+
+  Pmodule_struct = ^module_struct;
+  
+{$ifdef ULTRIX_BRAIN_DEATH}
+    init_t = procedure (); cdecl;
+    create_dir_config_t = function (): Pointer; cdecl;
+    merge_dir_config_t = function (): Pointer; cdecl;
+    create_server_config_t = function (): Pointer; cdecl;
+    merge_server_config_t = function (): Pointer; cdecl;
+{$else}
+    init_t = procedure (param1: Pserver_rec; param2: Ppool); cdecl;
+    create_dir_config_t = function (p: Ppool; dir: PChar): Pointer; cdecl;
+    merge_dir_config_t = function (p: PPool; base_conf, new_conf: Pointer): Pointer; cdecl;
+    create_server_config_t = function (p: Ppool; s: Pserver_rec): Pointer; cdecl;
+    merge_server_config_t = function (p: Ppool; base_conf, new_conf: Pointer): Pointer; cdecl;
+{$endif}
+
+  hook_t = function (param1: Prequest_rec): cint; cdecl;
+
+{$ifdef ULTRIX_BRAIN_DEATH}
+  child_init_t = procedure ();
+  child_exit_t = procedure ();
+{$else}
+  child_init_t = procedure (param1: Pserver_rec; param2: Ppool); cdecl;
+  child_exit_t = procedure (param1: Pserver_rec; param2: Ppool); cdecl;
+{$endif}
+
+  module_struct = record
+    version: cint;		{ API version, *not* module version;
+				 * check that module is compatible with this
+				 * version of the server.
+                                 }
+    minor_version: cint;          { API minor version. Provides API feature
+                                 * milestones. Not checked during module init
+                                 }
+    module_index: cint;		{ Index to this modules structures in
+				 * config vectors.
+                                 }
+
+    name: PChar;
+    dynamic_load_handle: Pointer;
+
+    next: Pmodule_struct;
+
+    magic: culong;              { Magic Cookie to identify a module structure;
+                                 * It's mainly important for the DSO facility
+                                 * (see also mod_so).
+                                 }
+
+    { init() occurs after config parsing, but before any children are
+     * forked.
+     * Modules should not rely on the order in which create_server_config
+     * and create_dir_config are called.
+     }
+
+    init: init_t;
+    create_dir_config: create_dir_config_t;
+    merge_dir_config: merge_dir_config_t;
+    create_server_config: create_server_config_t;
+    merge_server_config: merge_server_config_t;
+
+    cmds: Pcommand_rec;
+    handlers: Phandler_rec;
+
+    { Hooks for getting into the middle of server ops...
+
+     * translate_handler --- translate URI to filename
+     * access_checker --- check access by host address, etc.   All of these
+     *                    run; if all decline, that's still OK.
+     * check_user_id --- get and validate user id from the HTTP request
+     * auth_checker --- see if the user (from check_user_id) is OK *here*.
+     *                  If all of *these* decline, the request is rejected
+     *                  (as a SERVER_ERROR, since the module which was
+     *                  supposed to handle this was configured wrong).
+     * type_checker --- Determine MIME type of the requested entity;
+     *                  sets content_type, _encoding and _language fields.
+     * logger --- log a transaction.
+     * post_read_request --- run right after read_request or internal_redirect,
+     *                  and not run during any subrequests.
+     }
+
+    translate_handler: hook_t;
+    ap_check_user_id: hook_t;
+    auth_checker: hook_t;
+    access_checker: hook_t;
+    type_checker: hook_t;
+    fixer_upper: hook_t;
+    logger: hook_t;
+    header_parser: hook_t;
+
+    { Regardless of the model the server uses for managing "units of
+     * execution", i.e. multi-process, multi-threaded, hybrids of those,
+     * there is the concept of a "heavy weight process".  That is, a
+     * process with its own memory space, file spaces, etc.  This method,
+     * child_init, is called once for each heavy-weight process before
+     * any requests are served.  Note that no provision is made yet for
+     * initialization per light-weight process (i.e. thread).  The
+     * parameters passed here are the same as those passed to the global
+     * init method above.
+     }
+
+    child_init: child_init_t;
+    child_exit: child_exit_t;
+
+    post_read_request: hook_t;
+  end;
+  
+  module = module_struct;
+
+  Pmodule = ^module;
+
+{ Initializer for the first few module slots, which are only
+ * really set up once we start running.  Note that the first two slots
+ * provide a version check; this should allow us to deal with changes to
+ * the API. The major number should reflect changes to the API handler table
+ * itself or removal of functionality. The minor number should reflect
+ * additions of functionality to the existing API. (the server can detect
+ * an old-format module, and either handle it back-compatibly, or at least
+ * signal an error). See src/include/ap_mmn.h for MMN version history.
+ }
+
+procedure STANDARD_MODULE_STUFF(var mod_: module);
+
+{ Generic accessors for other modules to get at their own module-specific
+ * data
+ }
+
+{API_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m);
+API_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val);
+
+#define ap_get_module_config(v,m)	\
+    (((void **)(v))[(m)->module_index])
+#define ap_set_module_config(v,m,val)	\
+    ((((void **)(v))[(m)->module_index]) = (val))}
+
+{ Generic command handling function... }
+
+{API_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *, char *, char *);
+API_EXPORT_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *, char *, char *);
+API_EXPORT_NONSTD(const char *) ap_set_flag_slot(cmd_parms *, char *, int);
+API_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *, char *, char *);}
+
+{ For modules which need to read config files, open logs, etc. ...
+ * this returns the fname argument if it begins with '/'; otherwise
+ * it relativizes it wrt server_root.
+ }
+
+//API_EXPORT(char *) ap_server_root_relative(pool *p, char *fname);
+
+{ Finally, the hook for dynamically loading modules in... }
+
+procedure ap_add_module(m: Pmodule);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_remove_module(m: Pmodule);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_add_loaded_module(m: Pmodule);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_add_named_module(const name: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_clear_module_list();
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_find_module_name(m: Pmodule): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_find_linked_module(const name: PChar): Pmodule;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ for implementing subconfigs and customized config files }
+{API_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config);
+
+#ifdef CORE_PRIVATE
+
+extern API_VAR_EXPORT module *top_module;
+
+extern module *ap_prelinked_modules[];
+extern module *ap_preloaded_modules[];
+extern API_VAR_EXPORT module **ap_loaded_modules;}
+
+{ For mod_so.c... }
+
+//API_EXPORT(void) ap_single_module_configure(pool *p, server_rec *s, module *m);
+
+{ For http_main.c... }
+
+{API_EXPORT(server_rec *) ap_read_config(pool *conf_pool, pool *temp_pool, char *config_name);
+API_EXPORT(void) ap_init_modules(pool *p, server_rec *s);
+API_EXPORT(void) ap_child_init_modules(pool *p, server_rec *s);
+API_EXPORT(void) ap_child_exit_modules(pool *p, server_rec *s);
+API_EXPORT(void) ap_setup_prelinked_modules(void);
+API_EXPORT(void) ap_show_directives(void);
+API_EXPORT(void) ap_show_modules(void);
+void ap_cleanup_method_ptrs(void);}
+
+{ For http_request.c... }
+
+{CORE_EXPORT(void *) ap_create_request_config(pool *p);
+CORE_EXPORT(void *) ap_create_per_dir_config(pool *p);
+CORE_EXPORT(void *) ap_merge_per_dir_configs(pool *p, void *base, void *new);}
+
+{ For http_core.c... (<Directory> command and virtual hosts) }
+
+{CORE_EXPORT(int) ap_parse_htaccess(void **result, request_rec *r, int override,
+		const char *path, const char *access_name);
+
+CORE_EXPORT(const char *) ap_init_virtual_host(pool *p, const char *hostname,
+				server_rec *main_server, server_rec **);
+CORE_EXPORT(void) ap_process_resource_config(server_rec *s, char *fname, pool *p, pool *ptemp);
+}
+{ ap_check_cmd_context() definitions: }
+//API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden);
+
+{ ap_check_cmd_context():              Forbidden in: }
+const
+  NOT_IN_VIRTUALHOST    = $01; { <Virtualhost> }
+  NOT_IN_LIMIT          = $02; { <Limit> }
+  NOT_IN_DIRECTORY      = $04; { <Directory> }
+  NOT_IN_LOCATION       = $08; { <Location> }
+  NOT_IN_FILES          = $10; { <Files> }
+  NOT_IN_DIR_LOC_FILE   = (NOT_IN_DIRECTORY or NOT_IN_LOCATION or NOT_IN_FILES); { <Directory>/<Location>/<Files>}
+  GLOBAL_ONLY           = (NOT_IN_VIRTUALHOST or NOT_IN_LIMIT or NOT_IN_DIR_LOC_FILE);
+
+
+{ Module-method dispatchers, also for http_request.c }
+
+//API_EXPORT(int) ap_translate_name(request_rec *);
+//API_EXPORT(int) ap_check_access(request_rec *);	{ check access on non-auth basis }
+//API_EXPORT(int) ap_check_user_id(request_rec *);	{ obtain valid username from client auth }
+//API_EXPORT(int) ap_check_auth(request_rec *);	{ check (validated) user is authorized here }
+//API_EXPORT(int) ap_find_types(request_rec *);	{ identify MIME type }
+//API_EXPORT(int) ap_run_fixups(request_rec *);	{ poke around for other metainfo, etc.... }
+//API_EXPORT(int) ap_invoke_handler(request_rec *);
+//API_EXPORT(int) ap_log_transaction(request_rec *r);
+//API_EXPORT(int) ap_header_parse(request_rec *);
+//API_EXPORT(int) ap_run_post_read_request(request_rec *);
+
+{ for mod_perl }
+
+//CORE_EXPORT(const command_rec *) ap_find_command(const char *name, const command_rec *cmds);
+//CORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod);
+//CORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod);
+//CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l);
+
+//#endif
+

+ 422 - 0
packages/base/httpd/httpd-1.3/http_core.inc

@@ -0,0 +1,422 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{****************************************************************
+ *
+ * The most basic server code is encapsulated in a single module
+ * known as the core, which is just *barely* functional enough to
+ * serve documents, though not terribly well.
+ *
+ * Largely for NCSA back-compatibility reasons, the core needs to
+ * make pieces of its config structures available to other modules.
+ * The accessors are declared here, along with the interpretation
+ * of one of them (allow_options).
+ }
+
+const
+  OPT_NONE = 0;
+  OPT_INDEXES = 1;
+  OPT_INCLUDES = 2;
+  OPT_SYM_LINKS = 4;
+  OPT_EXECCGI = 8;
+  OPT_UNSET = 16;
+  OPT_INCNOEXEC = 32;
+  OPT_SYM_OWNER = 64;
+  OPT_MULTI = 128;
+  OPT_ALL = (OPT_INDEXES or OPT_INCLUDES or OPT_SYM_LINKS or OPT_EXECCGI);
+
+{ options for get_remote_host() }
+{ REMOTE_HOST returns the hostname, or NULL if the hostname
+ * lookup fails.  It will force a DNS lookup according to the
+ * HostnameLookups setting.
+ }
+  REMOTE_HOST = (0);
+
+{ REMOTE_NAME returns the hostname, or the dotted quad if the
+ * hostname lookup fails.  It will force a DNS lookup according
+ * to the HostnameLookups setting.
+ }
+  REMOTE_NAME = (1);
+
+{ REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
+ * never forced.
+ }
+  REMOTE_NOLOOKUP = (2);
+
+{ REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
+ * a double reverse lookup, regardless of the HostnameLookups
+ * setting.  The result is the (double reverse checked) hostname,
+ * or NULL if any of the lookups fail.
+ }
+  REMOTE_DOUBLE_REV = (3);
+
+  SATISFY_ALL = 0;
+  SATISFY_ANY = 1;
+  SATISFY_NOSPEC = 2;
+
+{ default maximum of internal redirects }
+  AP_DEFAULT_MAX_INTERNAL_REDIRECTS = 20;
+
+{ default maximum subrequest nesting level }
+  AP_DEFAULT_MAX_SUBREQ_DEPTH = 20;
+
+function ap_allow_options(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_allow_overrides(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_default_type(r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_document_root(r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+                                      { Don't use this!  If your request went
+				      * through a Userdir, or something like
+				      * that, it'll screw you.  But it's
+				      * back-compatible...
+                                      }
+                                      
+function ap_get_remote_host(conn: Pconn_rec; dir_config: Pointer; type_: cint): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_get_remote_logname(r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Used for constructing self-referencing URLs, and things like SERVER_PORT,
+ * and SERVER_NAME.
+ }
+function ap_construct_url(p: Ppool; const uri: PChar; r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_get_server_name(r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_get_server_port(const r: Prequest_rec): cuint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_get_limit_req_body(const r: Prequest_rec): culong;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_custom_response(r: Prequest_rec; status: cint; string_: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_exists_config_define(name: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Check if the current request is beyond the configured max. number of redirects or subrequests
+ * @param r The current request
+ * @return true (is exceeded) or false
+ }
+function ap_is_recursion_limit_exceeded(const r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Authentication stuff.  This is one of the places where compatibility
+ * with the old config files *really* hurts; they don't discriminate at
+ * all between different authentication schemes, meaning that we need
+ * to maintain common state for all of them in the core, and make it
+ * available to the other modules through interfaces.
+ }
+    
+type
+  require_line = record
+    method_mask: cint;
+    requirement: PChar;
+  end;
+     
+{API_EXPORT(const char *) ap_auth_type (request_rec *);
+API_EXPORT(const char *) ap_auth_name (request_rec *);     
+API_EXPORT(const char *) ap_auth_nonce (request_rec *);
+API_EXPORT(int) ap_satisfies (request_rec *r);
+API_EXPORT(const array_header *) ap_requires (request_rec *);    }
+
+{$ifdef WIN32}
+{
+ * CGI Script stuff for Win32...
+ }
+type
+  file_type_e = ( eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, eFileTypeEXE32,
+   eFileTypeSCRIPT, eCommandShell16, eCommandShell32 );
+  interpreter_source_e = ( INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY,
+   INTERPRETER_SOURCE_SHEBANG );
+
+function ap_get_win32_interpreter(const param1: Prequest_rec; param2: PPChar): file_type_e;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+{$endif}
+
+{.$ifdef CORE_PRIVATE}
+
+{
+ * Core is also unlike other modules in being implemented in more than
+ * one file... so, data structures are declared here, even though most of
+ * the code that cares really is in http_core.c.  Also, another accessor.
+ }
+
+//API_EXPORT(char *) ap_response_code_string (request_rec *r, int error_index);
+
+//extern API_VAR_EXPORT module core_module;
+
+{ Per-directory configuration }
+
+type
+  allow_options_t = Char;
+  overrides_t = Char
+  ;
+{
+ * Bits of info that go into making an ETag for a file
+ * document.  Why a long?  Because char historically
+ * proved too short for Options, and int can be different
+ * sizes on different platforms.
+ }
+  etag_components_t = culong;
+
+const
+  ETAG_UNSET = 0;
+  ETAG_NONE  = (1 shl 0);
+  ETAG_MTIME = (1 shl 1);
+  ETAG_INODE = (1 shl 2);
+  ETAG_SIZE  = (1 shl 3);
+  ETAG_BACKWARD = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE);
+  ETAG_ALL   = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE);
+  
+  { Things moved up }
+  
+  HOSTNAME_LOOKUP_OFF	= 0;
+  HOSTNAME_LOOKUP_ON	= 1;
+  HOSTNAME_LOOKUP_DOUBLE= 2;
+  HOSTNAME_LOOKUP_UNSET	= 3;
+
+  USE_CANONICAL_NAME_OFF  = (0);
+  USE_CANONICAL_NAME_ON   = (1);
+  USE_CANONICAL_NAME_DNS  = (2);
+  USE_CANONICAL_NAME_UNSET= (3);
+
+  ADD_DEFAULT_CHARSET_OFF   = (0);
+  ADD_DEFAULT_CHARSET_ON    = (1);
+  ADD_DEFAULT_CHARSET_UNSET = (2);
+
+{$ifdef CHARSET_EBCDIC}
+
+  { Configurable EBCDIC Conversion stuff }
+  { Direction specific conversion: }
+  dir_Out = 0;               { 0utput (returned contents in a GET or POST) }
+  dir_In  = 1;               { 1nput  (uploaded contents in a PUT / POST) }
+
+  { Conversion Enabled/Disabled: }
+  conv_Unset = '?';          { Conversion unconfigured }
+  conv_Off   = '0';          { BINARY or ASCII file (no conversion) }
+  conv_On    = '1';          { TEXT file (EBCDIC->ASCII for dir_Out; ASCII->EBCDIC for dir_In) }
+
+  LEGACY_KLUDGE = 1; { After a couple of versions this legacy kludge should be set to 0 }
+  ASCIITEXT_MAGIC_TYPE_PREFIX = 'text/x-ascii-';     { Text files whose content-type starts with this are passed thru unconverted }
+
+{$endif}
+
+type
+  ap_flag_e = (
+    AP_FLAG_UNSET = 0,
+    AP_FLAG_ON = 1,
+    AP_FLAG_OFF = 2
+  );
+  
+  server_signature_t = ( srv_sig_unset, srv_sig_off, srv_sig_on,
+   srv_sig_withmail);
+
+
+  core_dir_config = record
+    { path of the directory/regex/etc.  see also d_is_fnmatch below }
+    d: PChar;
+    { the number of slashes in d }
+    d_components: cuint;
+
+    { If (opts & OPT_UNSET) then no absolute assignment to options has
+     * been made.
+     * invariant: (opts_add & opts_remove) == 0
+     * Which said another way means that the last relative (options + or -)
+     * assignment made to each bit is recorded in exactly one of opts_add
+     * or opts_remove.
+     }
+    opts: allow_options_t;
+    opts_add: allow_options_t;
+    opts_remove: allow_options_t;
+    override_: overrides_t;
+    
+    { MIME typing --- the core doesn't do anything at all with this,
+     * but it does know what to slap on a request for a document which
+     * goes untyped by other mechanisms before it slips out the door...
+     }
+    
+    ap_default_type: PChar;
+  
+    { Authentication stuff.  Groan... }
+    
+    satisfy: cint;
+    ap_auth_type: PChar;
+    ap_auth_name: PChar;
+    ap_requires: Parray_header;
+
+    { Custom response config. These can contain text or a URL to redirect to.
+     * if response_code_strings is NULL then there are none in the config,
+     * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES.
+     * This lets us do quick merges in merge_core_dir_configs().
+     }
+  
+    response_code_strings: PPChar; { from ErrorDocument, not from
+                                   * ap_custom_response()
+                                   }
+
+    { Hostname resolution etc }
+    
+    { Moved Up }
+
+//    unsigned int hostname_lookups : 4;
+
+//    signed int do_rfc1413 : 2;   { See if client is advertising a username? }
+
+//    signed int content_md5 : 2;  { calculate Content-MD5? }
+
+    { Moved Up }
+
+//    unsigned use_canonical_name : 2;
+
+    { since is_fnmatch(conf->d) was being called so frequently in
+     * directory_walk() and its relatives, this field was created and
+     * is set to the result of that call.
+     }
+//    unsigned d_is_fnmatch : 1;
+
+    { should we force a charset on any outgoing parameterless content-type?
+     * if so, which charset?
+     }
+     
+    { Moved up }
+
+//    unsigned add_default_charset : 2;
+    add_default_charset_name: PChar;
+
+    { System Resource Control }
+{$ifdef RLIMIT_CPU}
+    limit_cpu: Prlimit;
+{$endif}
+{$if defined(RLIMIT_DATA) or defined(RLIMIT_VMEM) or defined(RLIMIT_AS)}
+    limit_mem: Prlimit;
+{$endif}
+{$ifdef RLIMIT_NPROC}
+    limit_nproc: Prlimit;
+{$endif}
+    limit_req_body: culong;  { limit on bytes in request msg body }
+
+    { logging options }
+    server_signature: server_signature_t;
+    loglevel: cint;
+    
+    { Access control }
+    sec: Parray_header;
+    r: Pregex_t;
+
+{$ifdef WIN32}
+    { Where to find interpreter to run scripts }
+    script_interpreter_source: interpreter_source_e;
+{$endif}
+    
+{$ifdef CHARSET_EBCDIC}
+
+    { Moved up }
+
+    { The configuration args {On|Off}[={In|Out|InOut}] are currently stored
+     * as character strings ("0" = conv_Off, "1" = conv_On)
+     }
+    ebcdicconversion_by_ext_in: Ptable;
+    ebcdicconversion_by_ext_out: Ptable;
+    ebcdicconversion_by_type_in: Ptable;
+    ebcdicconversion_by_type_out: Ptable;
+
+    { Moved up }
+    
+    x_ascii_magic_kludge: cint;   { whether to handle the text/x-ascii- kludge }
+
+{$ifdef ADD_EBCDICCONVERT_DEBUG_HEADER}
+    ebcdicconversion_debug_header: cint; { whether to add an X-EBCDIC-Debug-{In,Out} header to the response }
+{$endif}
+{$endif} { CHARSET_EBCDIC }
+
+    {
+     * What attributes/data should be included in ETag generation?
+     }
+    etag_bits: etag_components_t;
+    etag_add: etag_components_t;
+    etag_remove: etag_components_t;
+
+    {
+     * Do we allow ISINDEX CGI scripts to pass their query argument as
+     * direct command line parameters or argv elements?
+     }
+    cgi_command_args: ap_flag_e;
+
+    { Digest auth. }
+    ap_auth_nonce: PChar;
+
+  end;
+
+{ Per-server core configuration }
+
+type
+  core_server_config = record
+  
+{$ifdef GPROF}
+    gprof_dir: PChar;
+{$endif}
+
+    { Name translations --- we want the core to be able to do *something*
+     * so it's at least a minimally functional web server on its own (and
+     * can be tested that way).  But let's keep it to the bare minimum:
+     }
+    ap_document_root: PChar;
+  
+    { Access control }
+
+    access_name: PChar;
+    sec: Parray_header;
+    sec_url: Parray_header;
+
+    { recursion backstopper }
+    recursion_limit_set: cint; { boolean }
+    redirect_limit: cint;      { maximum number of internal redirects }
+    subreq_limit: cint;        { maximum nesting level of subrequests }
+
+    { TRACE control }
+    trace_enable: cint;        { see AP_TRACE_ below }
+
+  end;
+
+{ trace_enable options }
+const
+  AP_TRACE_UNSET    =-1;
+  AP_TRACE_DISABLE  = 0;
+  AP_TRACE_ENABLE   = 1;
+  AP_TRACE_EXTENDED = 2;
+
+{ for http_config.c }
+//CORE_EXPORT(void) ap_core_reorder_directories(pool *, server_rec *);
+
+{ for mod_perl }
+//CORE_EXPORT(void) ap_add_per_dir_conf (server_rec *s, void *dir_config);
+//CORE_EXPORT(void) ap_add_per_url_conf (server_rec *s, void *url_config);
+//CORE_EXPORT(void) ap_add_file_conf(core_dir_config *conf, void *url_config);
+//CORE_EXPORT_NONSTD(const char *) ap_limit_section (cmd_parms *cmd, void *dummy, const char *arg);
+
+{.$endif}
+

+ 126 - 0
packages/base/httpd/httpd-1.3/http_log.inc

@@ -0,0 +1,126 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{$ifdef HAVE_SYSLOG}
+//#include <syslog.h>
+
+  APLOG_EMERG    = LOG_EMERG;     { system is unusable }
+  APLOG_ALERT    = LOG_ALERT;     { action must be taken immediately }
+  APLOG_CRIT     = LOG_CRIT;      { critical conditions }
+  APLOG_ERR      = LOG_ERR;       { error conditions }
+  APLOG_WARNING  = LOG_WARNING;   { warning conditions }
+  APLOG_NOTICE   = LOG_NOTICE;    { normal but significant condition }
+  APLOG_INFO     = LOG_INFO;      { informational }
+  APLOG_DEBUG    = LOG_DEBUG;     { debug-level messages }
+
+  APLOG_LEVELMASK= LOG_PRIMASK;   { mask off the level value }
+
+{$else}
+
+  APLOG_EMERG	= 0;	{ system is unusable }
+  APLOG_ALERT	= 1;	{ action must be taken immediately }
+  APLOG_CRIT	= 2;	{ critical conditions }
+  APLOG_ERR	= 3;	{ error conditions }
+  APLOG_WARNING	= 4;	{ warning conditions }
+  APLOG_NOTICE	= 5;	{ normal but significant condition }
+  APLOG_INFO	= 6;	{ informational }
+  APLOG_DEBUG	= 7;	{ debug-level messages }
+
+  APLOG_LEVELMASK= 7;	{ mask off the level value }
+
+{$endif}
+
+  APLOG_NOERRNO	=	(APLOG_LEVELMASK + 1);
+{$ifdef WIN32}
+{ Set to indicate that error msg should come from Win32's GetLastError(),
+ * not errno. }
+  APLOG_WIN32ERROR =	((APLOG_LEVELMASK + 1) * 2);
+{$endif}
+
+  DEFAULT_LOGLEVEL =	APLOG_WARNING;
+
+//#define APLOG_MARK	__FILE__,__LINE__
+
+procedure ap_open_logs(s: Pserver_rec; p: PPool);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ The two primary logging functions, ap_log_error and ap_log_rerror,
+ * use a printf style format string to build the log message.  It is
+ * VERY IMPORTANT that you not include any raw data from the network,
+ * such as the request-URI or request header fields, within the format
+ * string.  Doing so makes the server vulnerable to a denial-of-service
+ * attack and other messy behavior.  Instead, use a simple format string
+ * like "%s", followed by the string containing the untrusted data.
+ }
+procedure ap_log_error(
+ const file_: PChar; line, level: Integer;
+ const s: Pserver_rec; const fmt: PChar; others: array of const);
+ cdecl; external LibHTTPD;
+
+//			    __attribute__((format(printf,5,6)));
+
+procedure ap_log_rerror(
+ const file_: PChar; line, level: Integer;
+ const s: Prequest_rec; const fmt: PChar; others: array of const);
+ cdecl; external LibHTTPD;
+
+//			    __attribute__((format(printf,5,6)));
+
+procedure ap_error_log2stderr(s: Pserver_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_log_pid(p: PPool; fname: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ These are for legacy code, new code should use ap_log_error,
+ * or ap_log_rerror.
+ }
+{API_EXPORT(void) ap_log_error_old(const char *err, server_rec *s);
+API_EXPORT(void) ap_log_unixerr(const char *routine, const char *file,
+			     const char *msg, server_rec *s);
+API_EXPORT_NONSTD(void) ap_log_printf(const server_rec *s, const char *fmt, ...)
+			    __attribute__((format(printf,2,3)));
+API_EXPORT(void) ap_log_reason(const char *reason, const char *fname,
+			    request_rec *r);}
+
+type
+  piped_log = record
+    p: PPool;
+//#if !defined(NO_RELIABLE_PIPED_LOGS) || defined(TPF)
+    program_: PChar;
+    pid: cint;
+    fds: array[1..2] of cint;
+//#else
+//    FILE *write_f;
+//#endif
+  end;
+  
+  Ppiped_log = ^piped_log;
+
+procedure ap_open_piped_log(p: PPool; const program_: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_close_piped_log(p: Ppiped_log): Ppiped_log;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{#if !defined(NO_RELIABLE_PIPED_LOGS) || defined(TPF)
+#define ap_piped_log_read_fd(pl)	((pl)->fds[0])
+#define ap_piped_log_write_fd(pl)	((pl)->fds[1])
+#else}
+//#define ap_piped_log_read_fd(pl)	(-1)
+//#define ap_piped_log_write_fd(pl)	(fileno((pl)->write_f))
+//#endif
+

+ 160 - 0
packages/base/httpd/httpd-1.3/http_main.inc

@@ -0,0 +1,160 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * Routines in http_main.c which other code --- in particular modules ---
+ * may want to call.  Right now, that's limited to timeout handling.
+ * There are two functions which modules can call to trigger a timeout
+ * (with the per-virtual-server timeout duration); these are hard_timeout
+ * and soft_timeout.
+ *
+ * The difference between the two is what happens when the timeout
+ * expires (or earlier than that, if the client connection aborts) ---
+ * a soft_timeout just puts the connection to the client in an
+ * "aborted" state, which will cause http_protocol.c to stop trying to
+ * talk to the client, but otherwise allows the code to continue normally.
+ * hard_timeout(), by contrast, logs the request, and then aborts it
+ * completely --- longjmp()ing out to the accept() loop in http_main.
+ * Any resources tied into the request's resource pool will be cleaned up;
+ * everything that isn't will leak.
+ *
+ * soft_timeout() is recommended as a general rule, because it gives your
+ * code a chance to clean up.  However, hard_timeout() may be the most
+ * convenient way of dealing with timeouts waiting for some external
+ * resource other than the client, if you can live with the restrictions.
+ *
+ * (When a hard timeout is in scope, critical sections can be guarded
+ * with block_alarms() and unblock_alarms() --- these are declared in
+ * alloc.c because they are most often used in conjunction with
+ * routines to allocate something or other, to make sure that the
+ * cleanup does get registered before any alarm is allowed to happen
+ * which might require it to be cleaned up; they * are, however,
+ * implemented in http_main.c).
+ *
+ * NOTE!  It's not "fair" for a hard_timeout to be in scope through calls
+ * across modules.  Your module code really has no idea what other modules may
+ * be present in the server, and they may not take too kindly to having a
+ * longjmp() happen -- it could result in corrupted state.  Heck they may not
+ * even take to kindly to a soft_timeout()... because it can cause EINTR to
+ * happen on pretty much any syscall, and unless all the libraries and modules
+ * in use are known to deal well with EINTR it could cause corruption as well.
+ * But things are likely to do much better with a soft_timeout in scope than a
+ * hard_timeout.
+ * 
+ * A module MAY NOT use a hard_timeout() across * sub_req_lookup_xxx()
+ * functions, or across run_sub_request() functions.  A module SHOULD NOT use a
+ * soft_timeout() in either of these cases, but sometimes there's just no
+ * choice.
+ *
+ * kill_timeout() will disarm either variety of timeout.
+ *
+ * reset_timeout() resets the timeout in progress.
+ }
+
+procedure ap_start_shutdown();
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_start_restart(param: cint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_hard_timeout(p: PChar; r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_keepalive_timeout(p: PChar; r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_soft_timeout(p: PChar; r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_kill_timeout(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_reset_timeout(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+
+//procedure ap_child_terminate(r: Prequest_rec);
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_sync_scoreboard_image();
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_update_child_status(child_num, status: cint; r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ void ap_time_process_request(int child_num, int status); }
+
+type
+  fn_t = procedure (param: cint);
+
+function ap_set_callback_and_alarm(fn: fn_t; x: cint): cuint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_check_alarm(): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ void setup_signal_names(char *prefix);}
+
+{ functions for determination and setting of accept() mutexing }
+{char *ap_default_mutex_method(void);
+char *ap_init_mutex_method(char *t);}
+
+{$ifndef NO_OTHER_CHILD}
+{
+ * register an other_child -- a child which the main loop keeps track of
+ * and knows it is different than the rest of the scoreboard.
+ *
+ * pid is the pid of the child.
+ *
+ * maintenance is a function that is invoked with a reason, the data
+ * pointer passed here, and when appropriate a status result from waitpid().
+ *
+ * write_fd is an fd that is probed for writing by select() if it is ever
+ * unwritable, then maintenance is invoked with reason OC_REASON_UNWRITABLE.
+ * This is useful for log pipe children, to know when they've blocked.  To
+ * disable this feature, use -1 for write_fd.
+ }
+type
+  maintenance_t = procedure (reason: cint; data: Pointer; status: ap_wait_t);
+  
+procedure ap_register_other_child(pid: cint;
+ maintenance: maintenance_t; data: Pointer; write_fd: cint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+const
+  OC_REASON_DEATH      = 0;	{ child has died, caller must call
+					 * unregister still }
+  OC_REASON_UNWRITABLE = 1;	{ write_fd is unwritable }
+  OC_REASON_RESTART    = 2;	{ a restart is occuring, perform
+					 * any necessary cleanup (including
+					 * sending a special signal to child)
+                                         }
+  OC_REASON_UNREGISTER = 3;	{ unregister has been called, do
+					 * whatever is necessary (including
+					 * kill the child) }
+  OC_REASON_LOST       = 4;	{ somehow the child exited without
+					 * us knowing ... buggy os? }
+
+{
+ * unregister an other_child.  Note that the data pointer is used here, and
+ * is assumed to be unique' per other_child.  This is because the pid and
+ * write_fd are possibly killed off separately.
+ }
+procedure ap_unregister_other_child(data: Pointer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{$endif}
+

+ 239 - 0
packages/base/httpd/httpd-1.3/http_protocol.inc

@@ -0,0 +1,239 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * Prototypes for routines which either talk directly back to the user,
+ * or control the ones that eventually do.
+ }
+
+{ Read a request and fill in the fields. }
+
+function ap_read_request(c: Pconn_rec): Prequest_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Send a single HTTP header field }
+
+function ap_send_header_field(r: Prequest_rec; const fieldname, fieldval: PChar): cint;
+ cdecl; external LibHTTPD;
+
+{ Send the minimal part of an HTTP response header... but modules should be
+ * very careful about using this, and should prefer ap_send_http_header().
+ * Much of the HTTP/1.1 implementation correctness depends on code in
+ * ap_send_http_header().
+ }
+procedure ap_basic_http_header(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Send the Status-Line and header fields for HTTP response }
+
+procedure ap_send_http_header(l: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Send the response to special method requests }
+
+function ap_send_http_trace(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_send_http_options(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Finish up stuff after a request }
+
+procedure ap_finalize_request_protocol(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Send error back to client... last arg indicates error status in case
+ * we get an error in the process of trying to deal with an ErrorDocument
+ * to handle some other error.  In that case, we print the default report
+ * for the first thing that went wrong, and more briefly report on the
+ * problem with the ErrorDocument.
+ }
+
+procedure ap_send_error_response(r: Prequest_rec; recursive_error: cint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Set last modified header line from the lastmod date of the associated file.
+ * Also, set content length.
+ *
+ * May return an error status, typically USE_LOCAL_COPY (that when the
+ * permit_cache argument is set to one).
+ }
+
+function ap_set_content_length(r: Prequest_rec; length: clong): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_set_keepalive(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_rationalize_mtime(r: Prequest_rec; mtime: time_t): time_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_make_etag(r: Prequest_rec; force_weak: cint): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_set_etag(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_set_last_modified(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_meets_conditions(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Other ways to send stuff at the client.  All of these keep track
+ * of bytes_sent automatically.  This indirection is intended to make
+ * it a little more painless to slide things like HTTP-NG packetization
+ * underneath the main body of the code later.  In the meantime, it lets
+ * us centralize a bit of accounting (bytes_sent).
+ *
+ * These also return the number of bytes written by the call.
+ * They should only be called with a timeout registered, for obvious reaasons.
+ * (Ditto the send_header stuff).
+ }
+
+//function ap_send_fd(f: PFILE; r: Prequest_rec): clong;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+//function ap_send_fd_length(f: PFILE; r: Prequest_rec; length: clong): clong;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_send_fb(f: PBUFF; r: Prequest_rec): clong;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_send_fb_length(f: PBUFF; r: Prequest_rec): clong;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_send_mmap(mm: Pointer; r: Prequest_rec; offset, length: size_t): size_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Hmmm... could macrofy these for now, and maybe forever, though the
+ * definitions of the macros would get a whole lot hairier.
+ }
+
+function ap_rputc(c: cint; r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_rputs(const str: PChar; r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_rwrite(const buf: Pointer; nbyte: cint; r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_rvputs(r: Prequest_rec; others: array of const): cint;
+ cdecl; external LibHTTPD;
+
+function ap_vrprintf(r: Prequest_rec; const fmt: PChar; vlist: va_list): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_rprintf(r: Prequest_rec; const fmt: PChar; others: array of const): cint;
+ cdecl; external LibHTTPD;
+
+{				__attribute__((format(printf,2,3)));}
+
+function ap_rflush(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{
+ * Index used in custom_responses array for a specific error code
+ * (only use outside protocol.c is in getting them configured).
+ }
+
+function ap_index_of_response(status: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Reading a block of data from the client connection (e.g., POST arg) }
+
+function ap_setup_client_block(r: Prequest_rec; read_policy: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_should_client_block(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_get_client_block(r: Prequest_rec; buffer: PChar; bufsiz: cint): clong;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_discard_request_body(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Sending a byterange }
+
+function ap_set_byterange(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_each_byterange(r: Prequest_rec; offset, length: Pclong): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ Support for the Basic authentication protocol.  Note that there's
+ * nothing that prevents these from being in mod_auth.c, except that other
+ * modules which wanted to provide their own variants on finding users and
+ * passwords for Basic auth (a fairly common request) would then require
+ * mod_auth to be loaded or they wouldn't work.
+ *
+ * get_basic_auth_pw returns 0 (OK) if it set the 'pw' argument (and assured
+ * a correct value in r->connection->user); otherwise it returns an error
+ * code, either SERVER_ERROR if things are really confused, AUTH_REQUIRED
+ * if no authentication at all seemed to be in use, or DECLINED if there
+ * was authentication but it wasn't Basic (in which case, the caller should
+ * presumably decline as well).
+ *
+ * note_basic_auth_failure arranges for the right stuff to be scribbled on
+ * the HTTP return so that the client knows how to authenticate itself the
+ * next time. As does note_digest_auth_failure for Digest auth.
+ *
+ * note_auth_failure does the same thing, but will call the correct one
+ * based on the authentication type in use.
+ *
+ }
+
+procedure ap_note_auth_failure(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_note_basic_auth_failure(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_note_digest_auth_failure(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_get_basic_auth_pw(r: Prequest_rec; const pw: PPChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{
+ * Setting up the protocol fields for subsidiary requests...
+ * Also, a wrapup function to keep the internal accounting straight.
+ }
+
+procedure ap_set_sub_req_protocol(rnew, r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_finalize_sub_req_protocol(sub_r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ This is also useful for putting sub_reqs and internal_redirects together }
+
+//CORE_EXPORT(void) ap_parse_uri(request_rec *r, const char *uri);
+
+{ Get the method number associated with the given string, assumed to
+ * contain an HTTP method.  Returns M_INVALID if not recognized.
+ }
+function ap_method_number_of(const method: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_getline(s: PChar; n: cint; in_: PBUFF; fold: cint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_get_chunk_size(b: PChar): clong;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+

+ 82 - 0
packages/base/httpd/httpd-1.3/http_request.inc

@@ -0,0 +1,82 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{ http_request.c is the code which handles the main line of request
+ * processing, once a request has been read in (finding the right per-
+ * directory configuration, building it if necessary, and calling all
+ * the module dispatch functions in the right order).
+ *
+ * The pieces here which are public to the modules, allow them to learn
+ * how the server would handle some other file or URI, or perhaps even
+ * direct the server to serve that other file instead of the one the
+ * client requested directly.
+ *
+ * There are two ways to do that.  The first is the sub_request mechanism,
+ * which handles looking up files and URIs as adjuncts to some other
+ * request (e.g., directory entries for multiviews and directory listings);
+ * the lookup functions stop short of actually running the request, but
+ * (e.g., for includes), a module may call for the request to be run
+ * by calling run_sub_req.  The space allocated to create sub_reqs can be
+ * reclaimed by calling destroy_sub_req --- be sure to copy anything you care
+ * about which was allocated in its pool elsewhere before doing this.
+ }
+
+function ap_sub_req_lookup_uri(const new_file: PChar;
+ const r: Prequest_rec): Prequest_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_sub_req_lookup_file(const new_file: PChar;
+ const r: Prequest_rec): Prequest_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_sub_req_method_uri(const method, new_file: PChar;
+ const r: Prequest_rec): Prequest_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+
+function ap_run_sub_req(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_destroy_sub_req(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{
+ * Then there's the case that you want some other request to be served
+ * as the top-level request INSTEAD of what the client requested directly.
+ * If so, call this from a handler, and then immediately return OK.
+ }
+
+procedure ap_internal_redirect(const new_uri: PChar; param2: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_internal_redirect_handler(const new_uri: PChar; param2: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_some_auth_required(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_is_initial_req(r: Prequest_rec): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_update_mtime(r: Prequest_rec; dependency_mtime: time_t): time_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{$ifdef CORE_PRIVATE}
+{ Function called by main.c to handle first-level request }
+API_EXPORT(void) ap_process_request(request_rec *);
+API_EXPORT(void) ap_die(int type, request_rec *r);
+{$endif}
+

+ 49 - 0
packages/base/httpd/httpd-1.3/http_vhost.inc

@@ -0,0 +1,49 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{ called before any config is read }
+procedure ap_init_vhost_config(p: PPool);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ called after the config has been read }
+procedure ap_fini_vhost_config(p: PPool; main_server: Pserver_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ handle addresses in <VirtualHost> statement }
+function ap_parse_vhost_addrs(p: PPool; const hostname: PChar; s: Pserver_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ handle NameVirtualHost directive }
+//function ap_set_name_virtual_host(cmd: Pcmd_parms; dummy: Pointer; arg: PChar): PChar;
+// cdecl; external LibHTTPD;
+
+{ given an ip address only, give our best guess as to what vhost it is }
+procedure ap_update_vhost_given_ip(conn: Pconn_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ The above is never enough, and this is always called after the headers
+ * have been read.  It may change r->server.
+ }
+procedure ap_update_vhost_from_headers(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ return 1 if the host:port matches any of the aliases of r->server
+ * return 0 otherwise
+ }
+function ap_matches_request_vhost(r: Prequest_rec; const host: PChar;
+ port: cuint): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+

+ 1263 - 0
packages/base/httpd/httpd-1.3/httpd.inc

@@ -0,0 +1,1263 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * httpd.h: header for simple (ha! not anymore) http daemon
+ }
+
+{ Headers in which EVERYONE has an interest... }
+{$include ap_config.inc}
+{$include ap_alloc.inc}
+{$include buff.inc}
+{$include ap.inc}
+
+{$include util_uri.inc}
+
+{ ----------------------------- config dir ------------------------------ }
+
+{ Define this to be the default server home dir. Most things later in this
+ * file with a relative pathname will have this added.
+ }
+const
+  {$ifdef OS2}
+    { Set default for OS/2 file system }
+    HTTPD_ROOT = '/os2httpd';
+  {$else}{$ifdef WINDOWS}
+    { Set default for Windows file system }
+    HTTPD_ROOT = '/apache';
+  {$else}{$if defined(BEOS) or defined(BONE)}
+    { Set the default for BeOS }
+    HTTPD_ROOT = '/boot/home/apache';
+  {$else}{$ifdef NETWARE}
+    { Set the default for NetWare }
+    HTTPD_ROOT = 'sys:/apache';
+  {$else}
+    HTTPD_ROOT = '/usr/local/apache';
+  {$endif}
+  {$endif}
+  {$endif}
+  {$endif}
+
+{ Default location of documents.  Can be overridden by the DocumentRoot
+ * directive.
+ }
+  {$ifdef OS2}
+    { Set default for OS/2 file system }
+    DOCUMENT_LOCATION = HTTPD_ROOT + '/docs';
+  {$else}
+    DOCUMENT_LOCATION = HTTPD_ROOT + '/htdocs';
+  {$endif}
+
+  { Max. number of dynamically loaded modules }
+  DYNAMIC_MODULE_LIMIT = 64;
+
+  { Default administrator's address }
+  DEFAULT_ADMIN = '[no address given]';
+
+  { The target name of the installed Apache }
+  TARGET = 'httpd';
+
+{
+ * --------- You shouldn't have to edit anything below this line ----------
+ *
+ * Any modifications to any defaults not defined above should be done in the 
+ * respective config. file. 
+ *
+ }
+
+
+{ -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- }
+
+{#define HTTP_VERSION(major,minor) (1000*(major)+(minor))
+#define HTTP_VERSION_MAJOR(number) ((number)/1000)
+#define HTTP_VERSION_MINOR(number) ((number)%1000)}
+
+
+{ -------------- Port number for server running standalone --------------- }
+
+  DEFAULT_HTTP_PORT =	80;
+  DEFAULT_HTTPS_PORT =	443;
+//#define ap_is_default_port(port,r)	((port) == ap_default_port(r))
+{$ifdef NETWARE}
+#define ap_http_method(r) ap_os_http_method((void*)r)
+#define ap_default_port(r) ap_os_default_port((void*)r)
+{$else}
+//  ap_http_method(r) = 'http';
+//  ap_default_port(r) = DEFAULT_HTTP_PORT;
+{$endif}
+
+{ --------- Default user name and group name running standalone ---------- }
+{ --- These may be specified as numbers by placing a # before a number --- }
+
+  DEFAULT_USER = '#-1';
+  DEFAULT_GROUP = '#-1';
+
+{$ifndef DEFAULT_ERRORLOG}
+{$if defined(OS2) or defined(WIN32)}
+  DEFAULT_ERRORLOG = 'logs/error.log';
+{$else}
+  DEFAULT_ERRORLOG = 'logs/error_log';
+{$endif}
+{$endif} { DEFAULT_ERRORLOG }
+
+  DEFAULT_PIDLOG = 'logs/httpd.pid';
+
+  DEFAULT_SCOREBOARD = 'logs/apache_runtime_status';
+
+  DEFAULT_LOCKFILE = 'logs/accept.lock';
+
+{ Define this to be what your HTML directory content files are called }
+
+  DEFAULT_INDEX = 'index.html';
+
+{ Define this to 1 if you want fancy indexing, 0 otherwise }
+
+  DEFAULT_INDEXING = 0;
+
+{ Define this to be what type you'd like returned for files with unknown }
+{ suffixes.  MUST be all lower case. }
+
+  DEFAULT_CONTENT_TYPE = 'text/plain';
+
+{ Define this to be what your per-directory security files are called }
+{$ifndef DEFAULT_ACCESS_FNAME}
+{$ifdef OS2}
+{ Set default for OS/2 file system }
+  DEFAULT_ACCESS_FNAME = 'htaccess';
+{$else}
+  DEFAULT_ACCESS_FNAME = '.htaccess';
+{$endif}
+{$endif} { DEFAULT_ACCESS_FNAME }
+
+{ The name of the server config file }
+
+  SERVER_CONFIG_FILE = 'conf/httpd.conf';
+
+{ The name of the document config file }
+
+  RESOURCE_CONFIG_FILE = 'conf/srm.conf';
+
+{ The name of the MIME types file }
+
+  TYPES_CONFIG_FILE = 'conf/mime.types';
+
+{ The name of the access file }
+
+  ACCESS_CONFIG_FILE = 'conf/access.conf';
+
+{ Whether we should enable rfc1413 identity checking }
+
+  DEFAULT_RFC1413 = 0;
+
+{ The default directory in user's home dir }
+
+  DEFAULT_USER_DIR = 'public_html';
+
+{ The default path for CGI scripts if none is currently set }
+
+  DEFAULT_PATH = '/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin';
+
+{ The path to the shell interpreter, for parsed docs }
+
+  {$if defined(OS2) or defined(WIN32)}
+{ Set default for OS/2 and Windows file system }
+    SHELL_PATH = 'CMD.EXE';
+  {$else}
+    SHELL_PATH = '/bin/sh';
+  {$endif}
+
+{ The path to the suExec wrapper, can be overridden in Configuration }
+
+  SUEXEC_BIN = HTTPD_ROOT + '/bin/suexec';
+
+{ The default string lengths }
+  HUGE_STRING_LEN = 8192;
+  MAX_STRING_LEN = HUGE_STRING_LEN;
+
+{ The timeout for waiting for messages }
+
+  DEFAULT_TIMEOUT = 300;
+
+{ The timeout for waiting for keepalive timeout until next request }
+
+  DEFAULT_KEEPALIVE_TIMEOUT = 15;
+
+{ The number of requests to entertain per connection }
+
+  DEFAULT_KEEPALIVE = 100;
+
+{ The size of the server's internal read-write buffers }
+  IOBUFSIZE = 8192;
+
+{ The max number of regex captures that can be expanded by ap_pregsub }
+  AP_MAX_REG_MATCH = 10;
+
+{ Number of servers to spawn off by default --- also, if fewer than
+ * this free when the caretaker checks, it will spawn more.
+ }
+
+  DEFAULT_START_DAEMON = 5;
+
+{ Maximum number of *free* server processes --- more than this, and
+ * they will die off.
+ }
+
+  DEFAULT_MAX_FREE_DAEMON = 10;
+
+{ Minimum --- fewer than this, and more will be created }
+
+  DEFAULT_MIN_FREE_DAEMON = 5;
+
+{ Limit on the total --- clients will be locked out if more servers than
+ * this are needed.  It is intended solely to keep the server from crashing
+ * when things get out of hand.
+ *
+ * We keep a hard maximum number of servers, for two reasons --- first off,
+ * in case something goes seriously wrong, we want to stop the fork bomb
+ * short of actually crashing the machine we're running on by filling some
+ * kernel table.  Secondly, it keeps the size of the scoreboard file small
+ * enough that we can read the whole thing without worrying too much about
+ * the overhead.
+ }
+{$ifndef HARD_SERVER_LIMIT}
+{$ifdef WIN32}
+  HARD_SERVER_LIMIT = 1024;
+{$else}{$if defined(NETWARE)}
+  HARD_SERVER_LIMIT = 2048;
+{$else}
+  HARD_SERVER_LIMIT = 256;
+{$endif}
+{$endif}
+{$endif}
+
+{
+ * Special Apache error codes. These are basically used
+ *  in http_main.c so we can keep track of various errors.
+ *
+ *   APEXIT_OK:
+ *     A normal exit
+ *   APEXIT_INIT:
+ *     A fatal error arising during the server's init sequence
+ *   APEXIT_CHILDINIT:
+ *     The child died during it's init sequence
+ *   APEXIT_CHILDFATAL:
+ *     A fatal error, resulting in the whole server aborting.
+ *     If a child exits with this error, the parent process
+ *     considers this a server-wide fatal error and aborts.
+ *                 
+ }
+  APEXIT_OK	      =	$0;
+  APEXIT_INIT	      =	$2;
+  APEXIT_CHILDINIT    = $3;
+  APEXIT_CHILDFATAL   =	$f;
+
+{
+ * (Unix, OS/2 only)
+ * Interval, in microseconds, between scoreboard maintenance.  During
+ * each scoreboard maintenance cycle the parent decides if it needs to
+ * spawn a new child (to meet MinSpareServers requirements), or kill off
+ * a child (to meet MaxSpareServers requirements).  It will only spawn or
+ * kill one child per cycle.  Setting this too low will chew cpu.  The
+ * default is probably sufficient for everyone.  But some people may want
+ * to raise this on servers which aren't dedicated to httpd and where they
+ * don't like the httpd waking up each second to see what's going on.
+ }
+
+ SCOREBOARD_MAINTENANCE_INTERVAL = 1000000;
+
+{ Number of requests to try to handle in a single process.  If <= 0,
+ * the children don't die off.  That's the default here, since I'm still
+ * interested in finding and stanching leaks.
+ }
+
+  DEFAULT_MAX_REQUESTS_PER_CHILD = 0;
+
+  DEFAULT_THREADS_PER_CHILD = 50;
+
+  DEFAULT_EXCESS_REQUESTS_PER_CHILD = 0;
+
+{ The maximum length of the queue of pending connections, as defined
+ * by listen(2).  Under some systems, it should be increased if you
+ * are experiencing a heavy TCP SYN flood attack.
+ *
+ * It defaults to 511 instead of 512 because some systems store it 
+ * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is 
+ * 255 when truncated.
+ }
+
+  DEFAULT_LISTENBACKLOG = 511;
+
+{ Limits on the size of various request items.  These limits primarily
+ * exist to prevent simple denial-of-service attacks on a server based
+ * on misuse of the protocol.  The recommended values will depend on the
+ * nature of the server resources -- CGI scripts and database backends
+ * might require large values, but most servers could get by with much
+ * smaller limits than we use below.  The request message body size can
+ * be limited by the per-dir config directive LimitRequestBody.
+ *
+ * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE
+ * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190.
+ * These two limits can be lowered (but not raised) by the server config
+ * directives LimitRequestLine and LimitRequestFieldsize, respectively.
+ *
+ * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by
+ * the server config directive LimitRequestFields.
+ }
+
+  { default limit on bytes in Request-Line (Method+URI+HTTP-version) }
+  DEFAULT_LIMIT_REQUEST_LINE = 8190;
+
+  { default limit on bytes in any one header field  }
+  DEFAULT_LIMIT_REQUEST_FIELDSIZE = 8190;
+
+  { default limit on number of request header fields }
+  DEFAULT_LIMIT_REQUEST_FIELDS = 100;
+
+{
+ * The default default character set name to add if AddDefaultCharset is 
+ * enabled.  Overridden with AddDefaultCharsetName.
+ }
+  DEFAULT_ADD_DEFAULT_CHARSET_NAME = 'iso-8859-1';
+
+{
+ * The below defines the base string of the Server: header. Additional
+ * tokens can be added via the ap_add_version_component() API call.
+ *
+ * The tokens are listed in order of their significance for identifying the
+ * application.
+ *
+ * "Product tokens should be short and to the point -- use of them for 
+ * advertizing or other non-essential information is explicitly forbidden."
+ *
+ * Example: "Apache/1.1.0 MrWidget/0.1-alpha" 
+ }
+
+  SERVER_BASEVENDOR   = 'Apache Group';
+  SERVER_BASEPRODUCT  = 'Apache';
+  SERVER_BASEREVISION = '1.3.37';
+  SERVER_BASEVERSION  = SERVER_BASEPRODUCT + '/' + SERVER_BASEREVISION;
+
+  SERVER_PRODUCT  = SERVER_BASEPRODUCT;
+  SERVER_REVISION = SERVER_BASEREVISION;
+  SERVER_VERSION  = SERVER_PRODUCT + '/' + SERVER_REVISION;
+
+type
+  server_token_type = (
+    SrvTk_MIN,		{ eg: Apache/1.3.0 }
+    SrvTk_OS,		{ eg: Apache/1.3.0 (UNIX) }
+    SrvTk_FULL,		{ eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b }
+    SrvTk_PRODUCT_ONLY	{ eg: Apache }
+  );
+
+//API_EXPORT(const char *) ap_get_server_version(void);
+//API_EXPORT(void) ap_add_version_component(const char *component);
+//API_EXPORT(const char *) ap_get_server_built(void);
+
+{ Numeric release version identifier: MMNNFFRBB: major minor fix final beta
+ * Always increases along the same track as the source branch.
+ * For example, Apache 1.4.2 would be '10402100', 2.5b7 would be '20500007'.
+ }
+const
+  APACHE_RELEASE = 10337100;
+
+  SERVER_PROTOCOL = 'HTTP/1.1';
+  SERVER_SUPPORT = 'http://www.apache.org/';
+
+  DECLINED = -1;		{ Module declines to handle }
+  DONE = -2;			{ Module has served the response completely
+				 *  - it's safe to die() with no more output
+                                 }
+  OK = 0;			{ Module has handled this stage. }
+
+
+{ ----------------------- HTTP Status Codes  ------------------------- }
+
+{ The size of the static array in http_protocol.c for storing
+ * all of the potential response status-lines (a sparse table).
+ * A future version should dynamically generate the table at startup.
+ }
+  RESPONSE_CODES = 55;
+
+  HTTP_CONTINUE                     = 100;
+  HTTP_SWITCHING_PROTOCOLS          = 101;
+  HTTP_PROCESSING                   = 102;
+  HTTP_OK                           = 200;
+  HTTP_CREATED                      = 201;
+  HTTP_ACCEPTED                     = 202;
+  HTTP_NON_AUTHORITATIVE            = 203;
+  HTTP_NO_CONTENT                   = 204;
+  HTTP_RESET_CONTENT                = 205;
+  HTTP_PARTIAL_CONTENT              = 206;
+  HTTP_MULTI_STATUS                 = 207;
+  HTTP_MULTIPLE_CHOICES             = 300;
+  HTTP_MOVED_PERMANENTLY            = 301;
+  HTTP_MOVED_TEMPORARILY            = 302;
+  HTTP_SEE_OTHER                    = 303;
+  HTTP_NOT_MODIFIED                 = 304;
+  HTTP_USE_PROXY                    = 305;
+  HTTP_TEMPORARY_REDIRECT           = 307;
+  HTTP_BAD_REQUEST                  = 400;
+  HTTP_UNAUTHORIZED                 = 401;
+  HTTP_PAYMENT_REQUIRED             = 402;
+  HTTP_FORBIDDEN                    = 403;
+  HTTP_NOT_FOUND                    = 404;
+  HTTP_METHOD_NOT_ALLOWED           = 405;
+  HTTP_NOT_ACCEPTABLE               = 406;
+  HTTP_PROXY_AUTHENTICATION_REQUIRED= 407;
+  HTTP_REQUEST_TIME_OUT             = 408;
+  HTTP_CONFLICT                     = 409;
+  HTTP_GONE                         = 410;
+  HTTP_LENGTH_REQUIRED              = 411;
+  HTTP_PRECONDITION_FAILED          = 412;
+  HTTP_REQUEST_ENTITY_TOO_LARGE     = 413;
+  HTTP_REQUEST_URI_TOO_LARGE        = 414;
+  HTTP_UNSUPPORTED_MEDIA_TYPE       = 415;
+  HTTP_RANGE_NOT_SATISFIABLE        = 416;
+  HTTP_EXPECTATION_FAILED           = 417;
+  HTTP_UNPROCESSABLE_ENTITY         = 422;
+  HTTP_LOCKED                       = 423;
+  HTTP_FAILED_DEPENDENCY            = 424;
+  HTTP_INTERNAL_SERVER_ERROR        = 500;
+  HTTP_NOT_IMPLEMENTED              = 501;
+  HTTP_BAD_GATEWAY                  = 502;
+  HTTP_SERVICE_UNAVAILABLE          = 503;
+  HTTP_GATEWAY_TIME_OUT             = 504;
+  HTTP_VERSION_NOT_SUPPORTED        = 505;
+  HTTP_VARIANT_ALSO_VARIES          = 506;
+  HTTP_INSUFFICIENT_STORAGE         = 507;
+  HTTP_NOT_EXTENDED                 = 510;
+
+  DOCUMENT_FOLLOWS   = HTTP_OK;
+  PARTIAL_CONTENT    = HTTP_PARTIAL_CONTENT;
+  MULTIPLE_CHOICES   = HTTP_MULTIPLE_CHOICES;
+  MOVED              = HTTP_MOVED_PERMANENTLY;
+  REDIRECT           = HTTP_MOVED_TEMPORARILY;
+  USE_LOCAL_COPY     = HTTP_NOT_MODIFIED;
+  BAD_REQUEST        = HTTP_BAD_REQUEST;
+  AUTH_REQUIRED      = HTTP_UNAUTHORIZED;
+  FORBIDDEN          = HTTP_FORBIDDEN;
+  NOT_FOUND          = HTTP_NOT_FOUND;
+  METHOD_NOT_ALLOWED = HTTP_METHOD_NOT_ALLOWED;
+  NOT_ACCEPTABLE     = HTTP_NOT_ACCEPTABLE;
+  LENGTH_REQUIRED    = HTTP_LENGTH_REQUIRED;
+  PRECONDITION_FAILED= HTTP_PRECONDITION_FAILED;
+  SERVER_ERROR       = HTTP_INTERNAL_SERVER_ERROR;
+  NOT_IMPLEMENTED    = HTTP_NOT_IMPLEMENTED;
+  BAD_GATEWAY        = HTTP_BAD_GATEWAY;
+  VARIANT_ALSO_VARIES= HTTP_VARIANT_ALSO_VARIES;
+
+{#define ap_is_HTTP_INFO(x)         (((x) >= 100)&&((x) < 200))
+#define ap_is_HTTP_SUCCESS(x)      (((x) >= 200)&&((x) < 300))
+#define ap_is_HTTP_REDIRECT(x)     (((x) >= 300)&&((x) < 400))
+#define ap_is_HTTP_ERROR(x)        (((x) >= 400)&&((x) < 600))
+#define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
+#define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
+
+#define ap_status_drops_connection(x) \
+                                   (((x) == HTTP_BAD_REQUEST)           || \
+                                    ((x) == HTTP_REQUEST_TIME_OUT)      || \
+                                    ((x) == HTTP_LENGTH_REQUIRED)       || \
+                                    ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
+                                    ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
+                                    ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
+                                    ((x) == HTTP_SERVICE_UNAVAILABLE) || \
+				    ((x) == HTTP_NOT_IMPLEMENTED))}
+
+{ Methods recognized (but not necessarily handled) by the server.
+ * These constants are used in bit shifting masks of size int, so it is
+ * unsafe to have more methods than bits in an int.  HEAD == M_GET.
+ }
+  M_GET       = 0;
+  M_PUT       = 1;
+  M_POST      = 2;
+  M_DELETE    = 3;
+  M_CONNECT   = 4;
+  M_OPTIONS   = 5;
+  M_TRACE     = 6;
+  M_PATCH     = 7;
+  M_PROPFIND  = 8;
+  M_PROPPATCH = 9;
+  M_MKCOL    = 10;
+  M_COPY     = 11;
+  M_MOVE     = 12;
+  M_LOCK     = 13;
+  M_UNLOCK   = 14;
+  M_INVALID  = 15;
+
+  METHODS    = 16;
+
+  CGI_MAGIC_TYPE = 'application/x-httpd-cgi';
+  INCLUDES_MAGIC_TYPE = 'text/x-server-parsed-html';
+  INCLUDES_MAGIC_TYPE3 = 'text/x-server-parsed-html3';
+{$ifdef CHARSET_EBCDIC}
+  ASCIITEXT_MAGIC_TYPE_PREFIX = 'text/x-ascii-'; { Text files whose content-type starts with this are passed thru unconverted }
+{$endif} {CHARSET_EBCDIC}
+  MAP_FILE_MAGIC_TYPE = 'application/x-type-map';
+  ASIS_MAGIC_TYPE = 'httpd/send-as-is';
+  DIR_MAGIC_TYPE = 'httpd/unix-directory';
+  STATUS_MAGIC_TYPE = 'application/x-httpd-status';
+
+{
+ * Define the HTML doctype strings centrally.
+ }
+  DOCTYPE_HTML_2_0  = '<!DOCTYPE HTML PUBLIC "-//IETF//' +
+                          'DTD HTML 2.0//EN">' + LineEnding;
+  DOCTYPE_HTML_3_2  = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
+                          'DTD HTML 3.2 Final//EN">' + LineEnding;
+  DOCTYPE_HTML_4_0S = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
+                          'DTD HTML 4.0//EN"' + LineEnding +
+                          '"http://www.w3.org/TR/REC-html40/strict.dtd">' + LineEnding;
+  DOCTYPE_HTML_4_0T = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
+                          'DTD HTML 4.0 Transitional//EN"' + LineEnding +
+                          '"http://www.w3.org/TR/REC-html40/loose.dtd">' + LineEnding;
+  DOCTYPE_HTML_4_0F = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
+                          'DTD HTML 4.0 Frameset//EN"' + LineEnding +
+                          '"http://www.w3.org/TR/REC-html40/frameset.dtd">' + LineEnding;
+
+{ Just in case your linefeed isn't the one the other end is expecting. }
+{$ifndef CHARSET_EBCDIC}
+  LF = 10;
+  CR = 13;
+  CRLF = #15#12;
+//#define OS_ASC(c) (c)
+{$else} { CHARSET_EBCDIC }
+//#include "ap_ebcdic.h"
+{ OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in
+ * the buff package (bread/bputs/bwrite), so everywhere else, we use
+ * "native EBCDIC" CR and NL characters. These are therefore defined as
+ * '\r' and '\n'.
+ * NB: this is not the whole truth - sometimes \015 and \012 are contained
+ * in literal (EBCDIC!) strings, so these are not converted but passed.
+ }
+  CR = '\r';
+  LF = '\n';
+  CRLF = '\r\n';
+#define OS_ASC(c) (os_toascii[c])
+{$endif} { CHARSET_EBCDIC }
+
+{ Possible values for request_rec.read_body (set by handling module):
+ *    REQUEST_NO_BODY          Send 413 error if message has any body
+ *    REQUEST_CHUNKED_ERROR    Send 411 error if body without Content-Length
+ *    REQUEST_CHUNKED_DECHUNK  If chunked, remove the chunks for me.
+ *    REQUEST_CHUNKED_PASS     Pass the chunks to me without removal.
+ }
+  REQUEST_NO_BODY         = 0;
+  REQUEST_CHUNKED_ERROR   = 1;
+  REQUEST_CHUNKED_DECHUNK = 2;
+  REQUEST_CHUNKED_PASS    = 3;
+  
+  { Things moved up }
+  
+  DEFAULT_VHOST_ADDR = $ffffffff;
+
+{ Things which may vary per file-lookup WITHIN a request ---
+ * e.g., state of MIME config.  Basically, the name of an object, info
+ * about the object, and any other info we may ahve which may need to
+ * change as we go poking around looking for it (e.g., overridden by
+ * .htaccess files).
+ *
+ * Note how the default state of almost all these things is properly
+ * zero, so that allocating it with pcalloc does the right thing without
+ * a whole lot of hairy initialization... so long as we are willing to
+ * make the (fairly) portable assumption that the bit pattern of a NULL
+ * pointer is, in fact, zero.
+ }
+
+{ This represents the result of calling htaccess; these are cached for
+ * each request.
+ }
+type
+  Phtaccess_result = ^htaccess_result;
+  
+  htaccess_result = record
+    dir: PChar;			{ the directory to which this applies }
+    override_: cint;		{ the overrides allowed for the .htaccess file }
+    htaccess: Pointer;		{ the configuration directives }
+{ the next one, or NULL if no more; N.B. never change this }
+    next: Phtaccess_result;
+  end;
+
+  Pconn_rec = ^conn_rec;
+  Pserver_rec = ^server_rec;
+  Prequest_rec = ^request_rec;
+  Plisten_rec = ^listen_rec;
+
+{.$include util_uri.inc}
+
+  proxyreqtype = (
+    NOT_PROXY=0,
+    STD_PROXY,
+    PROXY_PASS
+  );
+
+  request_rec = record
+
+    pool: Pap_pool;
+    connection: Pconn_rec;
+    server: Pserver_rec;
+
+    next: Prequest_rec;		{ If we wind up getting redirected,
+				 * pointer to the request we redirected to.
+                                 }
+    prev: Prequest_rec;		{ If this is an internal redirect,
+				 * pointer to where we redirected *from*.
+                                 }
+
+    main: Prequest_rec;		{ If this is a sub_request (see request.h)
+				 * pointer back to the main request.
+                                 }
+
+    { Info about the request itself... we begin with stuff that only
+     * protocol.c should ever touch...
+     }
+
+    the_request: PChar;		{ First line of request, so we can log it }
+    assbackwards: cint;		{ HTTP/0.9, "simple" request }
+    proxyreq: proxyreqtype;     { A proxy request (calculated during
+				 * post_read_request or translate_name) }
+    header_only: cint;		{ HEAD request, as opposed to GET }
+    protocol: PChar;		{ Protocol, as given to us, or HTTP/0.9 }
+    proto_num: cint;		{ Number version of protocol; 1.1 = 1001 }
+    hostname: PChar;	{ Host, as set by full URI or Host: }
+
+    request_time: time_t;	{ When the request started }
+
+    status_line: PChar;	{ Status line, if set by script }
+    status: cint;			{ In any case }
+
+    { Request method, two ways; also, protocol, etc..  Outside of protocol.c,
+     * look, but don't touch.
+     }
+
+    method: PChar;		{ GET, HEAD, POST, etc. }
+    method_number: cint;		{ M_GET, M_POST, etc. }
+
+    {
+	allowed is a bitvector of the allowed methods.
+
+	A handler must ensure that the request method is one that
+	it is capable of handling.  Generally modules should DECLINE
+	any request methods they do not handle.  Prior to aborting the
+	handler like this the handler should set r->allowed to the list
+	of methods that it is willing to handle.  This bitvector is used
+	to construct the "Allow:" header required for OPTIONS requests,
+	and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes.
+
+	Since the default_handler deals with OPTIONS, all modules can
+	usually decline to deal with OPTIONS.  TRACE is always allowed,
+	modules don't need to set it explicitly.
+
+	Since the default_handler will always handle a GET, a
+	module which does *not* implement GET should probably return
+	METHOD_NOT_ALLOWED.  Unfortunately this means that a Script GET
+	handler can't be installed by mod_actions.
+    }
+    allowed: cint;		{ Allowed methods - for 405, OPTIONS, etc }
+
+    sent_bodyct: cint;		{ byte count in stream is for body }
+    bytes_sent: clong;		{ body byte count, for easy access }
+    mtime: time_t;		{ Time the resource was last modified }
+
+    { HTTP/1.1 connection-level features }
+
+    chunked: cint;		{ sending chunked transfer-coding }
+    byterange: cint;		{ number of byte ranges }
+    boundary: PChar;		{ multipart/byteranges boundary }
+    range: PChar;		{ The Range: header }
+    clength: clong;		{ The "real" content length }
+
+    remaining: clong;		{ bytes left to read }
+    read_length: clong;		{ bytes that have been read }
+    read_body: cint;		{ how the request body should be read }
+    read_chunked: cint;		{ reading chunked transfer-coding }
+    expecting_100: cuint;	{ is client waiting for a 100 response? }
+
+    { MIME header environments, in and out.  Also, an array containing
+     * environment variables to be passed to subprocesses, so people can
+     * write modules to add to that environment.
+     *
+     * The difference between headers_out and err_headers_out is that the
+     * latter are printed even on error, and persist across internal redirects
+     * (so the headers printed for ErrorDocument handlers will have them).
+     *
+     * The 'notes' table is for notes from one module to another, with no
+     * other set purpose in mind...
+     }
+
+    headers_in: PTable;
+    headers_out: PTable;
+    err_headers_out: PTable;
+    subprocess_env: PTable;
+    notes: PTable;
+
+    { content_type, handler, content_encoding, content_language, and all
+     * content_languages MUST be lowercased strings.  They may be pointers
+     * to static strings; they should not be modified in place.
+     }
+    content_type: PChar;	{ Break these out --- we dispatch on 'em }
+    handler: PChar;    	        { What we *really* dispatch on           }
+
+    content_encoding: PChar;
+    content_language: PChar;	{ for back-compat. only -- do not use }
+    content_languages: Parray_header;	{ array of (char*) }
+
+    vlist_validator: PChar;      { variant list validator (if negotiated) }
+
+    no_cache: cint;
+    no_local_copy: cint;
+
+    { What object is being requested (either directly, or via include
+     * or content-negotiation mapping).
+     }
+
+    unparsed_uri: PChar;	{ the uri without any parsing performed }
+    uri: PChar;			{ the path portion of the URI }
+    filename: PChar;		{ filename if found, otherwise NULL }
+    path_info: PChar;
+    args: PChar;		{ QUERY_ARGS, if any }
+    finfo: Integer;//stat;      { ST_MODE set to zero if no such file }
+    parsed_uri: uri_components;	{ components of uri, dismantled }
+
+    { Various other config info which may change with .htaccess files
+     * These are config vectors, with one void* pointer for each module
+     * (the thing pointed to being the module's business).
+     }
+
+    per_dir_config: Pointer;	{ Options set in config files, etc. }
+    request_config: Pointer;	{ Notes on *this* request }
+
+{
+ * a linked list of the configuration directives in the .htaccess files
+ * accessed by this request.
+ * N.B. always add to the head of the list, _never_ to the end.
+ * that way, a sub request's list can (temporarily) point to a parent's list
+ }
+    htaccess: Phtaccess_result;
+
+    { On systems with case insensitive file systems (Windows, OS/2, etc.),
+     * r->filename is case canonicalized (folded to either lower or upper 
+     * case, depending on the specific system) to accomodate file access
+     * checking. case_preserved_filename is the same as r->filename 
+     * except case is preserved. There is at least one instance where Apache 
+     * needs access to the case preserved filename: Java class files published 
+     * with WebDAV need to preserve filename case to make the Java compiler 
+     * happy.
+     }
+    case_preserved_filename: PChar;
+
+{$ifdef CHARSET_EBCDIC}
+    { We don't want subrequests to modify our current conversion flags.
+     * These flags save the state of the conversion flags when subrequests
+     * are run.
+     }
+    struct {
+        unsigned conv_in:1;    { convert ASCII->EBCDIC when read()ing? }
+        unsigned conv_out:1;   { convert EBCDIC->ASCII when write()ing? }
+    } ebcdic;
+{$endif}
+
+{ Things placed at the end of the record to avoid breaking binary
+ * compatibility.  It would be nice to remember to reorder the entire
+ * record to improve 64bit alignment the next time we need to break
+ * binary compatibility for some other reason.
+ }
+  end;
+
+
+{ Things which are per connection
+ }
+
+  sockaddr_in = record end;
+ 
+  conn_rec = record
+
+    pool: Pap_pool;
+    server: Pserver_rec;
+    base_server: Pserver_rec;	{ Physical vhost this conn come in on }
+    vhost_lookup_data: Pointer;	{ used by http_vhost.c }
+
+    { Information about the connection itself }
+
+    child_num: cint;		{ The number of the child handling conn_rec }
+    client: PBUFF;		{ Connection to the guy }
+
+    { Who is the client? }
+
+    local_addr: sockaddr_in;	{ local address }
+    remote_addr: sockaddr_in;	{ remote address }
+    remote_ip: PChar;		{ Client's IP address }
+    remote_host: PChar;		{ Client's DNS name, if known.
+				 * NULL if DNS hasn't been checked,
+				 * "" if it has and no address was found.
+				 * N.B. Only access this though
+				 * get_remote_host() }
+    remote_logname: PChar;	{ Only ever set if doing rfc1413 lookups.
+				 * N.B. Only access this through
+				 * get_remote_logname() }
+    user: PChar;			{ If an authentication check was made,
+				 * this gets set to the user name.  We assume
+				 * that there's only one user per connection(!)
+                                 }
+    ap_auth_type: PChar;		{ Ditto. }
+
+//    unsigned aborted:1;		{ Are we still talking? }
+//    signed int keepalive:2;	{ Are we using HTTP Keep-Alive?
+//				 * -1 fatal error, 0 undecided, 1 yes }
+//    unsigned keptalive:1;	{ Did we use HTTP Keep-Alive? }
+//    signed int double_reverse:2;{ have we done double-reverse DNS?
+//				 * -1 yes/failure, 0 not yet, 1 yes/success }
+    keepalives: cint;		{ How many times have we used it? }
+    local_ip: PChar;		{ server IP address }
+    local_host: PChar;		{ used for ap_get_server_name when
+				 * UseCanonicalName is set to DNS
+				 * (ignores setting of HostnameLookups) }
+  end;
+
+{ Per-vhost config... }
+
+{ The address 255.255.255.255, when used as a virtualhost address,
+ * will become the "default" server when the ip doesn't match other vhosts.
+ }
+
+  { Moved up }
+
+  Pserver_addr_rec = ^server_addr_rec;
+  
+  in_addr = record end;
+
+  server_addr_rec = record
+    next: Pserver_addr_rec;
+    host_addr: in_addr; 	{ The bound address, for this server }
+    host_port: cushort; 	{ The bound port, for this server }
+    virthost: PChar;		{ The name given in <VirtualHost> }
+  end;
+
+  server_rec = record
+
+    next: Pserver_rec;
+
+    { description of where the definition came from }
+    defn_name: PChar;
+    defn_line_number: cuint;
+
+    { Full locations of server config info }
+
+    srm_confname: PChar;
+    access_confname: PChar;
+
+    { Contact information }
+
+    server_admin: PChar;
+    server_hostname: PChar;
+    port: cushort;	{ for redirects, etc. }
+
+    { Log files --- note that transfer log is now in the modules... }
+
+    error_fname: PChar;
+    error_log: Pointer; //FILE *
+    loglevel: cint;
+
+    { Module-specific configuration for server, and defaults... }
+
+    is_virtual: cint;		{ true if this is the virtual server }
+    module_config: Pointer;	{ Config vector containing pointers to
+				 * modules' per-server config structures.
+                                 }
+    lookup_defaults: Pointer;	{ MIME type info, etc., before we start
+				 * checking per-directory info.
+                                 }
+    { Transaction handling }
+
+    addrs: Pserver_addr_rec;
+    timeout: cint;		{ Timeout, in seconds, before we give up }
+    keep_alive_timeout: cint;	{ Seconds we'll wait for another request }
+    keep_alive_max: cint;	{ Maximum requests per connection }
+    keep_alive: cint;		{ Use persistent connections? }
+    send_buffer_size: cint;	{ size of TCP send buffer (in bytes) }
+
+    path: PChar;		{ Pathname for ServerPath }
+    pathlen: cint;		{ Length of path }
+
+    names: Parray_header;	{ Normal names for ServerAlias servers }
+    wild_names: Parray_header;	{ Wildcarded names for ServerAlias servers }
+
+    server_uid: uid_t;        { effective user id when calling exec wrapper }
+    server_gid: gid_t;        { effective group id when calling exec wrapper }
+
+    limit_req_line: cint;      { limit on size of the HTTP request line    }
+    limit_req_fieldsize: cint; { limit on size of any request header field }
+    limit_req_fields: cint;    { limit on number of request header fields  }
+  end;
+
+  { These are more like real hosts than virtual hosts }
+
+  listen_rec = record
+    next: Plisten_rec;
+    local_addr: sockaddr_in;	{ local IP address and port }
+    fd: cint;
+    used: cint;			{ Only used during restart }
+    { more stuff here, like which protocol is bound to the port }
+  end;
+
+  tm = record end;
+  
+  Ptm = ^tm;
+  
+{ Prototypes for utilities... util.c.
+ }
+
+//extern void ap_util_init(void);
+
+{ Time }
+{extern API_VAR_EXPORT const char ap_month_snames[12][4];
+extern API_VAR_EXPORT const char ap_day_snames[7][4];}
+
+function ap_get_gmtoff(tz: Pcint): Ptm;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_get_time: PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_field_noparam(p: Ppool; const intype: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_ht_time(p: Ppool; t: time_t; const fmt: PChar; gmt: cint): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_gm_timestr_822(p: Ppool; t: time_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{ String handling. The *_nc variants allow you to use non-const char **s as
+   arguments (unfortunately C won't automatically convert a char ** to a const
+   char **) }
+
+function ap_getword(p: Ppool; const line: PPChar; stop: Char): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_getword_nc(p: Ppool; line: PPChar; stop: Char): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_getword_white(p: Ppool; const line: PPChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_getword_white_nc(p: Ppool; line: PPChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_getword_nulls(p: Ppool; const line: PPChar; stop: Char): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_getword_nulls_nc(p: Ppool; line: PPChar; stop: Char): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_getword_conf(p: Ppool; const line: PPChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_getword_conf_nc(p: Ppool; line: PPChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+
+function ap_size_list_item(const field: PPChar; len: Pcint): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_get_list_item(p: Ppool; const field: PPChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_find_list_item(p: Ppool; const line, tok: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+
+function ap_get_token(p: Ppool; const accept_line: PPChar; accept_white: cint): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_find_token(p: Ppool; const line, tok: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_find_last_token(p: Ppool; const line, tok: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+
+function ap_unescape_url(url: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_no2slash(name: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_getparents(name: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_escape_path_segment(p: Ppool; const s: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_os_escape_path(p: Ppool; const path: PChar; partial: cint): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+//#define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1)
+
+function ap_escape_html(p: Ppool; const s: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{API_EXPORT(char *) ap_construct_server(pool *p, const char *hostname,
+				    unsigned port, const request_rec *r);
+API_EXPORT(char *) ap_escape_logitem(pool *p, const char *str);
+API_EXPORT(size_t) ap_escape_errorlog_item(char *dest, const char *source,
+                                           size_t buflen);
+API_EXPORT(char *) ap_escape_shell_cmd(pool *p, const char *s);
+
+API_EXPORT(int) ap_count_dirs(const char *path);
+API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n);
+API_EXPORT(char *) ap_make_dirstr_parent(pool *p, const char *s);}
+{ deprecated.  The previous two routines are preferred. }
+{API_EXPORT(char *) ap_make_dirstr(pool *a, const char *s, int n);
+API_EXPORT(char *) ap_make_full_path(pool *a, const char *dir, const char *f);
+
+API_EXPORT(int) ap_is_matchexp(const char *str);
+API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp);
+API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp);
+API_EXPORT(char *) ap_stripprefix(const char *bigstring, const char *prefix);
+API_EXPORT(char *) ap_strcasestr(const char *s1, const char *s2);
+API_EXPORT(char *) ap_pbase64decode(pool *p, const char *bufcoded);
+API_EXPORT(char *) ap_pbase64encode(pool *p, char *string); 
+API_EXPORT(char *) ap_uudecode(pool *p, const char *bufcoded);
+API_EXPORT(char *) ap_uuencode(pool *p, char *string); }
+
+{$if defined(OS2) or defined(WIN32)}
+//API_EXPORT(char *) ap_double_quotes(pool *p, const char *str);
+//API_EXPORT(char *) ap_caret_escape_args(pool *p, const char *str);
+{$endif}
+
+{$ifdef OS2}
+void os2pathname(char *path);
+{$endif}
+
+{API_EXPORT(int)    ap_regexec(const regex_t *preg, const char *string,
+                              size_t nmatch, regmatch_t pmatch[], int eflags);
+API_EXPORT(size_t) ap_regerror(int errcode, const regex_t *preg, 
+                               char *errbuf, size_t errbuf_size);
+API_EXPORT(char *) ap_pregsub(pool *p, const char *input, const char *source,
+                              size_t nmatch, regmatch_t pmatch[]);
+
+API_EXPORT(void) ap_content_type_tolower(char *);
+API_EXPORT(void) ap_str_tolower(char *);
+API_EXPORT(int) ap_ind(const char *, char);}	{ Sigh... }
+{API_EXPORT(int) ap_rind(const char *, char);
+
+API_EXPORT(char *) ap_escape_quotes (pool *p, const char *instring);
+API_EXPORT(void) ap_remove_spaces(char *dest, char *src);}
+
+{ Common structure for reading of config files / passwd files etc. }
+type
+
+  Pconfigfile_t = ^configfile_t;
+  
+  getch_t = function (param: Pointer): cint;
+  
+  getstr_t = function (buf: Pointer; bufsiz: size_t; param: Pointer): Pointer;
+  
+  close_t = function (param: Pointer): cint;
+  
+  configfile_t = record
+    getch: getch_t;	{ a getc()-like function }
+    getstr: getstr_t;   { a fgets()-like function }
+    close: close_t;	{ a close hander function }
+    param: Pointer;	{ the argument passed to getch/getstr/close }
+    name: PChar;	{ the filename / description }
+    line_number: cuint;	{ current line number, starting at 1 }
+  end;
+
+{ Open a configfile_t as FILE, return open configfile_t struct pointer }
+//API_EXPORT(configfile_t *) ap_pcfg_openfile(pool *p, const char *name);
+
+{ Allocate a configfile_t handle with user defined functions and params }
+//API_EXPORT(configfile_t *) ap_pcfg_open_custom(pool *p, const char *descr,
+//    void *param,
+//    int( *getc_func)(void*),
+//    void *( *gets_func) (void *buf, size_t bufsiz, void *param),
+//    int( *close_func)(void *param));
+
+{ Read one line from open configfile_t, strip LF, increase line number }
+//API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, configfile_t *cfp);
+
+{ Read one char from open configfile_t, increase line number upon LF }
+//API_EXPORT(int) ap_cfg_getc(configfile_t *cfp);
+
+{ Detach from open configfile_t, calling the close handler }
+//API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp);
+
+{$ifdef NEED_STRERROR}
+//char *strerror(int err);
+{$endif}
+
+{ Misc system hackery }
+
+function ap_uname2id(const name: PChar): uid_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_gname2id(const name: PChar): gid_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_is_directory(const name: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_is_rdirectory(const name: PChar): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+function ap_can_exec(const stat: Pointer): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+procedure ap_chdir_file(const file_: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{$ifndef HAVE_CANONICAL_FILENAME}
+{
+ *  We can't define these in os.h because of dependence on pool pointer.
+ }
+{#define ap_os_canonical_filename(p,f)  (f)
+#define ap_os_case_canonical_filename(p,f)  (f)
+#define ap_os_systemcase_filename(p,f)  (f)}
+{$else}
+//API_EXPORT(char *) ap_os_canonical_filename(pool *p, const char *file);
+{$ifdef WIN32}
+//API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile);
+//API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile);
+{$else}{$ifdef OS2}
+//API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile);
+//API_EXPORT(char *) ap_os_systemcase_filename(pool *pPool, const char *szFile);
+{$else}{$ifdef NETWARE}
+//API_EXPORT(char *) ap_os_case_canonical_filename(pool *pPool, const char *szFile);
+//#define ap_os_systemcase_filename(p,f) ap_os_case_canonical_filename(p,f)
+{$else}
+//#define ap_os_case_canonical_filename(p,f) ap_os_canonical_filename(p,f)
+//#define ap_os_systemcase_filename(p,f) ap_os_canonical_filename(p,f)
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+
+{$ifdef CHARSET_EBCDIC}
+//API_EXPORT(int)    ap_checkconv(struct request_rec *r);    { for downloads }
+//API_EXPORT(int)    ap_checkconv_in(struct request_rec *r); { for uploads }
+{$endif} {#ifdef CHARSET_EBCDIC}
+
+{API_EXPORT(char *) ap_get_local_host(pool *);
+API_EXPORT(unsigned long) ap_get_virthost_addr(char *hostname, unsigned short *port);
+
+extern API_VAR_EXPORT time_t ap_restart_time;}
+
+{
+ * Apache tries to keep all of its long term filehandles (such as log files,
+ * and sockets) above this number.  This is to workaround problems in many
+ * third party libraries that are compiled with a small FD_SETSIZE.  There
+ * should be no reason to lower this, because it's only advisory.  If a file
+ * can't be allocated above this number then it will remain in the "slack"
+ * area.
+ *
+ * Only the low slack line is used by default.  If HIGH_SLACK_LINE is defined
+ * then an attempt is also made to keep all non-FILE * files above the high
+ * slack line.  This is to work around a Solaris C library limitation, where it
+ * uses an unsigned char to store the file descriptor.
+ }
+
+const
+  LOW_SLACK_LINE  = 15;
+
+  HIGH_SLACK_LINE = 255;
+
+{
+ * The ap_slack() function takes a fd, and tries to move it above the indicated
+ * line.  It returns an fd which may or may not have moved above the line, and
+ * never fails.  If the high line was requested and it fails it will also try
+ * the low line.
+ }
+{#ifdef NO_SLACK
+#define ap_slack(fd,line)   (fd)
+#else
+int ap_slack(int fd, int line);
+const
+  AP_SLACK_LOW	= 1;
+  AP_SLACK_HIGH	= 2;
+#endif
+
+API_EXPORT(char *) ap_escape_quotes(pool *p, const char *instr);}
+
+{
+ * Redefine assert() to something more useful for an Apache...
+ }
+{API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
+			    __attribute__((noreturn));
+#define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))}
+
+{ The optimized timeout code only works if we're not MULTITHREAD and we're
+ * also not using a scoreboard file
+ }
+{#if !defined (MULTITHREAD) && (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD))
+#define OPTIMIZE_TIMEOUTS
+#endif}
+
+{ A set of flags which indicate places where the server should raise(SIGSTOP).
+ * This is useful for debugging, because you can then attach to that process
+ * with gdb and continue.  This is important in cases where one_process
+ * debugging isn't possible.
+ }
+  SIGSTOP_DETACH	  = 1;
+  SIGSTOP_MAKE_CHILD	  = 2;
+  SIGSTOP_SPAWN_CHILD  	  = 4;
+  SIGSTOP_PIPED_LOG_SPAWN = 8;
+  SIGSTOP_CGI_CHILD	  = 16;
+
+{#ifdef DEBUG_SIGSTOP
+extern int raise_sigstop_flags;
+#define RAISE_SIGSTOP(x)	do begin
+	if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
+    end while (0)
+#else
+#define RAISE_SIGSTOP(x)
+#endif
+
+API_EXPORT(extern const char *) ap_psignature(const char *prefix, request_rec *r);}
+
+  { strtoul does not exist on sunos4. }
+
+//  strtoul = strtoul_is_not_a_portable_function_use_strtol_instead
+
+{$ifdef AP_ENABLE_EXCEPTION_HOOK}
+{ The exception hook allows a module to run from the server's signal
+ * handler, and perform tasks such as logging the current request or
+ * getting a backtrace or performing other diagnostic functions.  All
+ * operating system requirements for running in a signal handler must
+ * be respected, or the process may not exit properly.
+ *
+ * AP_ENABLE_EXCEPTION_HOOK is already defined for platforms that have
+ * been tested.  It likely will work on other platforms.  In order to
+ * test, define AP_ENABLE_EXCEPTION_HOOK at configure time.
+ }
+type
+  ap_exception_info_t = record
+    sig: cint;
+    pid: pid_t;
+  end;
+
+{ Register a function to be called after a fatal exception (on *X systems, a
+ * "synchronous signal" such as SIGSEGV, SIGILL, etc.).
+ *
+ * Returns 0 on success, non-zero on failure.
+ * If EnableExceptionHook directive is not set to "on", this function will
+ * report failure and no such hooks will be called.
+ }
+function ap_add_fatal_exception_hook(fn: procedure (param: Pap_exception_info_t) ): cint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
+
+{$endif} { AP_ENABLE_EXCEPTION_HOOK }
+

+ 174 - 0
packages/base/httpd/httpd-1.3/httpd.pas

@@ -0,0 +1,174 @@
+{
+ httpd.pas
+
+ Copyright (C) 2006 Felipe Monteiro de Carvalho
+
+ This unit is a pascal binding for the Apache 1.3.37 headers.
+ The headers were released under the following copyright:
+}
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+unit httpd;
+
+{$ifdef fpc}
+  {$mode delphi}{$H+}
+{$endif}
+
+{$IFNDEF FPC}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$IFDEF WIN32}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$ifdef Unix}
+  {$PACKRECORDS C}
+{$endif}
+
+{$define Apache1_3}
+
+interface
+
+uses
+{$ifdef WINDOWS}
+  Windows,
+{$ELSE}
+  UnixType,
+{$ENDIF}
+  ctypes;
+
+const
+{$ifndef fpc}
+  LineEnding = #13#10;
+{$endif}
+
+{$IFDEF WINDOWS}
+  LibHTTPD = 'ApacheCore.dll';
+{$ELSE}
+  LibHTTPD = '';
+{$ENDIF}
+
+{ Declarations moved here to be on top of all declarations }
+
+{ Various types}
+type
+  time_t = LongInt;
+  size_t = Integer;
+
+{ configuration vector structure }
+type
+  ap_conf_vector_t = record end;
+  Pap_conf_vector_t = ^ap_conf_vector_t;
+  PPap_conf_vector_t = ^Pap_conf_vector_t;
+
+{
+  Main httpd header files
+  
+  Note: There are more include files other then these, because some include files
+ include more files.
+}
+
+{.$include ap_provider.inc}
+{.$include util_cfgtree.inc}
+
+{$include httpd.inc}
+{$include http_config.inc}
+{$include http_core.inc}
+{$include http_log.inc}
+{$include http_main.inc}
+{$include http_protocol.inc}
+{$include http_request.inc}
+{$include http_vhost.inc}
+
+{.$include util_script.inc}
+{.$include util_time.inc}
+{.$include util_md5.inc}
+{.$include ap_mpm.inc}
+
+implementation
+
+{
+  Macros transformed into functions in the translation
+}
+
+{ from httpd.inc }
+
+{ Internal representation for a HTTP protocol number, e.g., HTTP/1.1 }
+function HTTP_VERSION(major, minor: Integer): Integer;
+begin
+  Result := (1000*(major)+(minor));
+end;
+
+{ Major part of HTTP protocol }
+function HTTP_VERSION_MAJOR(number: Integer): Integer;
+begin
+  Result := number div 1000;
+end;
+
+{ Minor part of HTTP protocol }
+function HTTP_VERSION_MINOR(number: Integer): Integer;
+begin
+  Result := number mod 1000;
+end;
+
+{function ap_escape_uri(p: Papr_pool_t; const path: PChar): PChar;
+begin
+  Result := ap_os_escape_path(p, path, 1);
+end;}
+
+{ from http_config.inc }
+
+{ Use this in all standard modules }
+
+procedure STANDARD_MODULE_STUFF(var mod_: module);
+begin
+  mod_.version := MODULE_MAGIC_NUMBER_MAJOR;
+  mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR;
+  mod_.module_index := -1;
+//  mod_.name: PChar;
+  mod_.dynamic_load_handle := nil;
+  mod_.next := nil;
+  mod_.magic := MODULE_MAGIC_COOKIE;
+end;
+
+{ Use this only in MPMs }
+//procedure MPM20_MODULE_STUFF(var mod_: module);
+//begin
+//  mod_.version := MODULE_MAGIC_NUMBER_MAJOR;
+//  mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR;
+//  mod_.module_index := -1;
+//  mod_.name: PChar;
+//  mod_.dynamic_load_handle := nil;
+//  mod_.next := nil;
+//  mod_.magic := MODULE_MAGIC_COOKIE;
+//end;
+
+function ap_get_module_config(v: Pap_conf_vector_t; m: Pmodule): Pap_conf_vector_t;
+begin
+  Result := Pointer(Integer(v) + m^.module_index);
+end;
+
+procedure ap_set_module_config(v: Pap_conf_vector_t; m: Pmodule; val: Pap_conf_vector_t);
+var
+  P: PPointer;
+begin
+  P := PPointer(Integer(v) + m^.module_index);
+  P^ := val;
+end;
+
+end.
+

+ 84 - 0
packages/base/httpd/httpd-1.3/util_uri.inc

@@ -0,0 +1,84 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * util_uri.h: External Interface of util_uri.c
+ }
+
+type
+  schemes_t = record
+    name: PChar;
+    default_port: cushort;
+  end;
+
+const
+  DEFAULT_FTP_DATA_PORT	= 20;
+  DEFAULT_FTP_PORT	= 21;
+  DEFAULT_GOPHER_PORT	= 70;
+  DEFAULT_NNTP_PORT	= 119;
+  DEFAULT_WAIS_PORT	= 210;
+  DEFAULT_SNEWS_PORT	= 563;
+  DEFAULT_PROSPERO_PORT	= 1525;	{ WARNING: conflict w/Oracle }
+
+  DEFAULT_URI_SCHEME = 'http';
+
+{ Flags passed to unparse_uri_components(): }
+  UNP_OMITSITEPART    = (1 shl 0);	{ suppress "scheme://user@site:port" }
+  UNP_OMITUSER 	      = (1 shl 1);	{ Just omit user }
+  UNP_OMITPASSWORD    = (1 shl 2);	{ Just omit password }
+  UNP_OMITUSERINFO    = (UNP_OMITUSER or UNP_OMITPASSWORD);	{ omit "user:password@" part }
+  UNP_REVEALPASSWORD  = (1 shl 3);	{ Show plain text password (default: show XXXXXXXX) }
+  UNP_OMITPATHINFO    = (1 shl 4);	{ Show "scheme://user@site:port" only }
+  UNP_OMITQUERY	      = (1 shl 5);	{ Omit the "?queryarg" from the path }
+
+type
+  hostent = record end;
+  Phostent = ^hostent;
+
+  uri_components = record
+    scheme: PChar;		{ scheme ("http"/"ftp"/...) }
+    hostinfo: PChar;            { combined [user[:password]@]host[:port] }
+    user: PChar;		{ user name, as in http://user:passwd@host:port/ }
+    password: PChar;		{ password, as in http://user:passwd@host:port/ }
+    hostname: PChar;		{ hostname from URI (or from Host: header) }
+    port_str: PChar;		{ port string (integer representation is in "port") }
+    path: PChar;		{ the request path (or "/" if only scheme://host was given) }
+    query: PChar;		{ Everything after a '?' in the path, if present }
+    fragment: PChar;		{ Trailing "#fragment" string, if present }
+
+    hostent: Phostent;
+
+    port: cushort;	{ The port number, numeric, valid only if port_str != NULL }
+    
+//    unsigned is_initialized:1;
+
+//    unsigned dns_looked_up:1;
+//    unsigned dns_resolved:1;
+
+  end;
+
+{ util_uri.c }
+{API_EXPORT(unsigned short) ap_default_port_for_scheme(const char *scheme_str);
+API_EXPORT(unsigned short) ap_default_port_for_request(const request_rec *r);
+API_EXPORT(struct hostent *) ap_pduphostent(pool *p, const struct hostent *hp);
+API_EXPORT(struct hostent *) ap_pgethostbyname(pool *p, const char *hostname);
+API_EXPORT(char *) ap_unparse_uri_components(pool *p, const uri_components *uptr,
+    unsigned flags);
+API_EXPORT(int) ap_parse_uri_components(pool *p, const char *uri, uri_components *uptr);
+API_EXPORT(int) ap_parse_hostinfo_components(pool *p, const char *hostinfo, uri_components *uptr);}
+{ called by the core in main() }
+//extern void ap_util_uri_init(void);
+

+ 191 - 0
packages/base/httpd/httpd-1.3/win32_os.inc

@@ -0,0 +1,191 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{$ifdef WIN32}
+
+{
+ * Compile the server including all the Windows NT 4.0 header files by
+ * default. We still want the server to run on Win95/98 so use
+ * runtime checks before calling NT specific functions to verify we are
+ * really running on an NT system.
+ }
+const
+  _WIN32_WINNT = $0400;
+
+{ If it isn't too late, prevent windows.h from including the original
+ * winsock.h header, so that we can still include winsock2.h
+ }
+{#if !defined(_WINSOCKAPI_) || !defined(_WINDOWS_)
+#define _WINSOCKAPI_
+#include <windows.h>
+#include <winsock2.h>
+#include <mswsock.h>
+#else
+#include <windows.h>
+#endif
+#include <process.h>
+#include <malloc.h>
+#include <io.h>
+#include <fcntl.h>}
+
+  PLATFORM = 'Win32';
+
+{
+ * This file in included in all Apache source code. It contains definitions
+ * of facilities available on _this_ operating system (HAVE_* macros),
+ * and prototypes of OS specific functions defined in os.c
+ }
+
+{ temporarily replace crypt }
+{ char *crypt(const char *pw, const char *salt); }
+//#define crypt(buf,salt)	    (buf)
+
+{ Although DIR_TYPE is dirent (see nt/readdir.h) we need direct.h for
+   chdir() }
+//#include <direct.h>
+
+{$define STATUS}
+{$define STRICT}
+{$define CASE_BLIND_FILESYSTEM}
+{$define NO_WRITEV}
+{$define NO_SETSID}
+{$define NO_USE_SIGACTION}
+{$define NO_TIMES}
+{$define NO_GETTIMEOFDAY}
+{$define USE_LONGJMP}
+{$define HAVE_MMAP}
+{$define USE_MMAP_SCOREBOARD}
+{$define MULTITHREAD}
+{$define HAVE_CANONICAL_FILENAME}
+{$define HAVE_DRIVE_LETTERS}
+{$define HAVE_UNC_PATHS}
+
+type
+  uid_t = cint;
+  gid_t = cint;
+  pid_t = cint;
+  Ppid_t = ^pid_t;
+  tid_t = cint;
+{$ifdef _MSC_VER}
+{ modified to match declaration in sys/stat.h }
+  mode_t = cushort;
+{$endif}
+  caddr_t = PChar;
+
+{
+Define export types. API_EXPORT_NONSTD is a nasty hack to avoid having to declare
+every configuration function as __stdcall.
+}
+
+{#ifdef SHARED_MODULE
+#define API_VAR_EXPORT          __declspec(dllimport)
+#define API_EXPORT(type)        __declspec(dllimport) type __stdcall
+#define API_EXPORT_NONSTD(type) __declspec(dllimport) type __cdecl
+#else
+#define API_VAR_EXPORT          __declspec(dllexport)
+#define API_EXPORT(type)        __declspec(dllexport) type __stdcall
+#define API_EXPORT_NONSTD(type) __declspec(dllexport) type __cdecl
+#endif
+#define MODULE_VAR_EXPORT   __declspec(dllexport)
+
+#define strcasecmp(s1, s2) stricmp(s1, s2)
+#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
+#define lstat(x, y) stat(x, y)
+#ifndef S_ISLNK
+#define S_ISLNK(m) (0)
+#endif
+#ifndef S_ISREG
+#define S_ISREG(m) ((m & _S_IFREG) == _S_IFREG)
+#endif
+#ifndef S_ISDIR
+#define S_ISDIR(m) (((m) & _S_IFDIR) == _S_IFDIR)
+#endif
+#define STDIN_FILENO  0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+#define JMP_BUF jmp_buf
+#define sleep(t) Sleep(t*1000)
+#ifndef O_CREAT
+#define O_CREAT _O_CREAT
+#endif
+#ifndef O_RDWR
+#define O_RDWR _O_RDWR
+#endif
+#define SIGPIPE 17}
+{ Seems Windows is not a subgenius }
+{$define NO_SLACK}
+//#include <stddef.h>
+
+{ MSVC asserts that strtol "errno is set to ERANGE
+ * if overflow or underflow occurs"
+ * Ergo we can use the library strtol safely.
+ }
+//#define ap_strtol strtol
+
+{$define NO_OTHER_CHILD}
+{$define NO_RELIABLE_PIPED_LOGS}
+
+//__inline int ap_os_is_path_absolute(const char *file)
+{
+  For now, just do the same check that http_request.c and mod_alias.c
+   * do.
+
+  return file && (file[0] == '/' || (file[1] == ':' && file[2] == '/'));
+}
+
+{#define stat(f,ps)  os_stat(f,ps)
+API_EXPORT(int) os_stat(const char *szPath,struct stat *pStat);
+
+API_EXPORT(int) os_strftime(char *s, size_t max, const char *format, const struct tm *tm);
+
+#define _spawnv(mode,cmdname,argv)	    os_spawnv(mode,cmdname,argv)
+#define spawnv(mode,cmdname,argv)	    os_spawnv(mode,cmdname,argv)
+API_EXPORT(int) os_spawnv(int mode,const char *cmdname,const char *const *argv);
+#define _spawnve(mode,cmdname,argv,envp)    os_spawnve(mode,cmdname,argv,envp)
+#define spawnve(mode,cmdname,argv,envp)	    os_spawnve(mode,cmdname,argv,envp)
+API_EXPORT(int) os_spawnve(int mode,const char *cmdname,const char *const *argv,const char *const *envp);
+#define _spawnle			    os_spawnle
+#define spawnle				    os_spawnle
+API_EXPORT_NONSTD(int) os_spawnle(int mode,const char *cmdname,...);}
+
+{ OS-dependent filename routines in util_win32.c }
+
+//API_EXPORT(int) ap_os_is_filename_valid(const char *file);
+
+{ Abstractions for dealing with shared object files (DLLs on Win32).
+ * These are used by mod_so.c
+ }
+{#define ap_os_dso_handle_t  HINSTANCE
+#define ap_os_dso_init()
+#define ap_os_dso_unload(l) FreeLibrary(l)
+#define ap_os_dso_sym(h,s)  GetProcAddress(h,s)
+
+API_EXPORT(ap_os_dso_handle_t) ap_os_dso_load(const char *);
+API_EXPORT(const char *) ap_os_dso_error(void);}
+
+{ Other ap_os_ routines not used by this platform }
+//#define ap_os_kill(pid, sig)                kill(pid, sig)
+
+{ Some Win32isms }
+{$define HAVE_ISNAN}
+//#define isnan(n) _isnan(n)
+{$define HAVE_ISINF}
+//#define isinf(n) (!_finite(n))
+
+//#define gettid() ((tid_t)GetCurrentThreadId())
+
+{$endif} { WIN32 }
+

+ 1865 - 0
packages/base/httpd/httpd-2.0/Makefile

@@ -0,0 +1,1865 @@
+#
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/08/20]
+#
+default: all
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd x86_64-win64 arm-linux arm-palmos arm-wince arm-gba powerpc64-linux
+BSDs = freebsd netbsd openbsd darwin
+UNIXs = linux $(BSDs) solaris qnx
+LIMIT83fs = go32v2 os2 emx watcom
+FORCE:
+.PHONY: FORCE
+override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
+ifneq ($(findstring darwin,$(OSTYPE)),)
+inUnix=1 #darwin
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+endif
+SEARCHPATH+=$(patsubst %/,%,$(subst \,/,$(dir $(MAKE))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygdrive,$(PATH)),)
+inCygWin=1
+endif
+endif
+ifdef inUnix
+SRCBATCHEXT=.sh
+else
+ifdef inOS2
+SRCBATCHEXT=.cmd
+else
+SRCBATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+ifdef inCygWin
+PATHSEP=/
+endif
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+ifdef inOS2
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=echo
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+endif
+override DEFAULT_FPCDIR=../../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+else
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+FOUNDFPC:=$(strip $(wildcard $(FPC)))
+ifeq ($(FOUNDFPC),)
+FOUNDFPC=$(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))
+ifeq ($(FOUNDFPC),)
+$(error Compiler $(FPC) not found)
+endif
+endif
+ifndef FPC_COMPILERINFO
+FPC_COMPILERINFO:=$(shell $(FPC) -iVSPTPSOTO)
+endif
+ifndef FPC_VERSION
+FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO))
+endif
+export FPC FPC_VERSION FPC_COMPILERINFO
+unexport CHECKDEPEND ALLDEPENDENCIES
+ifndef CPU_TARGET
+ifdef CPU_TARGET_DEFAULT
+CPU_TARGET=$(CPU_TARGET_DEFAULT)
+endif
+endif
+ifndef OS_TARGET
+ifdef OS_TARGET_DEFAULT
+OS_TARGET=$(OS_TARGET_DEFAULT)
+endif
+endif
+ifneq ($(words $(FPC_COMPILERINFO)),5)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSO)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTO)
+endif
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 2,$(FPC_COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 3,$(FPC_COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 4,$(FPC_COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+TARGETSUFFIX=$(OS_TARGET)
+SOURCESUFFIX=$(OS_SOURCE)
+else
+TARGETSUFFIX=$(FULL_TARGET)
+SOURCESUFFIX=$(FULL_SOURCE)
+endif
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first)
+endif
+endif
+ifneq ($(findstring $(OS_TARGET),$(BSDs)),)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),linux)
+linuxHier=1
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(BASEDIR)
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+endif
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
+endif
+ifndef BINUTILSPREFIX
+ifndef CROSSBINDIR
+ifdef CROSSCOMPILE
+BINUTILSPREFIX=$(CPU_TARGET)-$(OS_TARGET)-
+endif
+endif
+endif
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX))
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=httpd-2.0
+override PACKAGE_VERSION=2.0.4
+ifeq ($(FULL_TARGET),i386-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifneq ($(findstring $(OS_TARGET),$(UNIXs)),)
+UNIXHier=1
+endif
+else
+ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),)
+UNIXHier=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXHier
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifdef INSTALL_FPCSUBDIR
+export INSTALL_FPCSUBDIR
+endif
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef COMPILER_UNITTARGETDIR
+ifdef PACKAGEDIR_MAIN
+COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX)
+else
+COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX)
+endif
+endif
+ifndef COMPILER_TARGETDIR
+COMPILER_TARGETDIR=.
+endif
+ifndef INSTALL_BASEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXHier
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+ifdef CROSSCOMPILE
+ifdef CROSSINSTALL
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(SOURCESUFFIX)
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXHier
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXHier
+ifdef BSDhier
+SRCPREFIXDIR=share/src
+else
+ifdef linuxHier
+SRCPREFIXDIR=share/src
+else
+SRCPREFIXDIR=src
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXHier
+ifdef BSDhier
+DOCPREFIXDIR=share/doc
+else
+ifdef linuxHier
+DOCPREFIXDIR=share/doc
+else
+DOCPREFIXDIR=doc
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifndef INSTALL_SHAREDDIR
+INSTALL_SHAREDDIR=$(INSTALL_PREFIX)/lib
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(SOURCESUFFIX))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(TARGETSUFFIX)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+ifeq ($(OS_SOURCE),linux)
+ifndef GCCLIBDIR
+ifeq ($(CPU_TARGET),i386)
+ifneq ($(findstring x86_64,$(shell uname -a)),)
+ifeq ($(BINUTILSPREFIX),)
+GCCLIBDIR:=$(shell dirname `gcc -m32 -print-libgcc-file-name`)
+endif
+endif
+endif
+ifeq ($(CPU_TARGET),powerpc64)
+ifeq ($(BINUTILSPREFIX),)
+GCCLIBDIR:=$(shell dirname `gcc -m64 -print-libgcc-file-name`)
+endif
+endif
+endif
+ifndef GCCLIBDIR
+CROSSGCC=$(strip $(wildcard $(addsuffix /$(BINUTILSPREFIX)gcc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(CROSSGCC),)
+GCCLIBDIR:=$(shell dirname `$(CROSSGCC) -print-libgcc-file-name`)
+endif
+endif
+ifndef OTHERLIBDIR
+OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
+endif
+endif
+ifdef inUnix
+ifeq ($(OS_SOURCE),netbsd)
+OTHERLIBDIR+=/usr/pkg/lib
+endif
+export GCCLIBDIR OTHERLIB
+endif
+BATCHEXT=.bat
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+SHAREDLIBPREFIX=libfp
+STATICLIBPREFIX=libp
+IMPORTLIBPREFIX=libimp
+RSTEXT=.rst
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),go32v1)
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+OEXT=.obj
+ASMEXT=.asm
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),emx)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=emx
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),morphos)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=mos
+endif
+ifeq ($(OS_TARGET),atari)
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+ifeq ($(OS_TARGET),darwin)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=dwn
+endif
+ifeq ($(OS_TARGET),gba)
+EXEEXT=.gba
+SHAREDLIBEXT=.so
+SHORTSUFFIX=gba
+endif
+else
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.sl2
+STATICLIBPREFIX=
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+FPCMADE=fpcmade.$(SHORTSUFFIX)
+ZIPSUFFIX=$(SHORTSUFFIX)
+ZIPCROSSPREFIX=
+ZIPSOURCESUFFIX=src
+ZIPEXAMPLESUFFIX=exm
+else
+FPCMADE=fpcmade.$(TARGETSUFFIX)
+ZIPSOURCESUFFIX=.source
+ZIPEXAMPLESUFFIX=.examples
+ifdef CROSSCOMPILE
+ZIPSUFFIX=.$(SOURCESUFFIX)
+ZIPCROSSPREFIX=$(TARGETSUFFIX)-
+else
+ZIPSUFFIX=.$(TARGETSUFFIX)
+ZIPCROSSPREFIX=
+endif
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO= __missing_command_ECHO
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE= __missing_command_DATE
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL= __missing_command_GINSTALL
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG= __missing_command_CPPROG
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG= __missing_command_RMPROG
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG= __missing_command_MVPROG
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef MKDIRPROG
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG= __missing_command_MKDIRPROG
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+endif
+export MKDIRPROG
+ifndef ECHOREDIR
+ifndef inUnix
+ECHOREDIR=echo
+else
+ECHOREDIR=$(ECHO)
+endif
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -Rfp
+endif
+ifndef MKDIRTREE
+MKDIRTREE:=$(MKDIRPROG) -p
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE= __missing_command_PPUMOVE
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE= __missing_command_FPCMAKE
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG= __missing_command_ZIPPROG
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /gtar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG= __missing_command_TARPROG
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=$(BINUTILSPREFIX)as
+LDNAME=$(BINUTILSPREFIX)ld
+ARNAME=$(BINUTILSPREFIX)ar
+RCNAME=$(BINUTILSPREFIX)rc
+ifneq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),win32)
+ifeq ($(CROSSBINDIR),)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+endif
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(SRCBATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vj
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(FULL_TARGET),i386-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_RTL)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_RTL) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifneq ($(CPU_TARGET),$(CPU_SOURCE))
+override FPCOPT+=-P$(CPU_TARGET)
+endif
+ifeq ($(OS_SOURCE),openbsd)
+override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
+endif
+ifndef CROSSBOOTSTRAP
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-XP$(BINUTILSPREFIX) -Xc
+endif
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-Xr$(RLINKPATH)
+endif
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifneq ($(findstring 2.0.,$(FPC_VERSION)),)
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+endif
+ifeq ($(CPU_TARGET),powerpc)
+FPCCPUOPT:=-O1r
+endif
+else
+FPCCPUOPT:=-O1r
+endif
+override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+override FPCOPT+=-O2
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef CREATESHARED
+override FPCOPT+=-Cg
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-Aas
+endif
+endif
+ifdef LINKSHARED
+endif
+ifdef GCCLIBDIR
+override FPCOPT+=-Fl$(GCCLIBDIR)
+endif
+ifdef OTHERLIBDIR
+override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override AFULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+override AFULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(AFULL_TARGET),$(AFULL_SOURCE))
+override ACROSSCOMPILE=1
+endif
+ifdef ACROSSCOMPILE
+override FPCOPT+=$(CROSSOPT)
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifneq ($(TARGET_UNITS),)
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(COMPILER_UNITTARGETDIR) $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release fpc_shared
+$(FPCMADE): $(ALLDEPENDENCIES) $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .lpr .dpr .pp .rc .res
+$(COMPILER_UNITTARGETDIR):
+	$(MKDIRTREE) $(COMPILER_UNITTARGETDIR)
+$(COMPILER_TARGETDIR):
+	$(MKDIRTREE) $(COMPILER_TARGETDIR)
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.lpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.dpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.lpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.dpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(OEXT) $(COMPILER_UNITTARGETDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_shared
+override INSTALLTARGET+=fpc_shared_install
+ifndef SHARED_LIBVERSION
+SHARED_LIBVERSION=$(FPC_VERSION)
+endif
+ifndef SHARED_LIBNAME
+SHARED_LIBNAME=$(PACKAGE_NAME)
+endif
+ifndef SHARED_FULLNAME
+SHARED_FULLNAME=$(SHAREDLIBPREFIX)$(SHARED_LIBNAME)-$(SHARED_LIBVERSION)$(SHAREDLIBEXT)
+endif
+ifndef SHARED_LIBUNITS
+SHARED_LIBUNITS:=$(TARGET_UNITS) $(TARGET_IMPLICITUNITS)
+override SHARED_LIBUNITS:=$(filter-out $(INSTALL_BUILDUNIT),$(SHARED_LIBUNITS))
+endif
+fpc_shared:
+ifdef HASSHAREDLIB
+	$(MAKE) all CREATESHARED=1 LINKSHARED=1 CREATESMART=1
+ifneq ($(SHARED_BUILD),n)
+	$(PPUMOVE) -q $(SHARED_LIBUNITS) -i$(COMPILER_UNITTARGETDIR) -o$(SHARED_FULLNAME) -d$(COMPILER_UNITTARGETDIR)
+endif
+else
+	@$(ECHO) Shared Libraries not supported
+endif
+fpc_shared_install:
+ifneq ($(SHARED_BUILD),n)
+ifneq ($(SHARED_LIBUNITS),)
+ifneq ($(wildcard $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME)),)
+	$(INSTALL) $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME) $(INSTALL_SHAREDDIR)
+endif
+endif
+endif
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT)$(PPUEXT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+ifneq ($(UNITTARGETDIRPREFIX),)
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPUFILES)))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPULINKFILES))))
+endif
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+ifneq ($(TARGETDIRPREFIX),)
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(notdir $(INSTALLEXEFILES)))
+endif
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR)/* $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(PACKAGE_NAME)
+endif
+endif
+ifndef FULLZIPNAME
+FULLZIPNAME=$(ZIPCROSSPREFIX)$(ZIPPREFIX)$(ZIPNAME)$(ZIPSUFFIX)
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(SRCBATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=$(ZIPSOURCESUFFIX)
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=$(ZIPEXAMPLESUFFIX)
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+ifdef DEBUGSYMEXT
+override CLEANPPULINKFILES+=$(subst $(PPUEXT),$(DEBUGSYMEXT),$(CLEANPPUFILES))
+endif
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *$(ASMEXT) *_ppas$(BATCHEXT)
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef COMPILER_UNITTARGETDIR
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+endif
+	-$(DELTREE) units
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+ifneq ($(PPUEXT),.ppu)
+	-$(DEL) *.o *.ppu *.a
+endif
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) fpcmade.* Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *_ppas$(BATCHEXT)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+ifdef DEBUGSYMEXT
+	-$(DEL) *$(DEBUGSYMEXT)
+endif
+fpc_distclean: cleanall
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Source.. $(FULL_SOURCE)
+	@$(ECHO)  Full Target.. $(FULL_TARGET)
+	@$(ECHO)  SourceSuffix. $(SOURCESUFFIX)
+	@$(ECHO)  TargetSuffix. $(TARGETSUFFIX)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Shell..... $(SHELL)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipName.............. $(ZIPNAME)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipCrossPrefix....... $(ZIPCROSSPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  FullZipName.......... $(FULLZIPNAME)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+units: fpc_units
+examples:
+shared: fpc_shared
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release units examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 19 - 0
packages/base/httpd/httpd-2.0/Makefile.fpc

@@ -0,0 +1,19 @@
+#
+#  Makefile.fpc for httpd 1.3 unit
+#
+
+[package]
+name=httpd-2.0
+version=2.0.4
+
+[target]
+units=apr/apr apriconv/apriconv aprutil/aprutil httpd
+
+[require]
+libc=y
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../../..

+ 248 - 0
packages/base/httpd/httpd-2.0/ap_config.inc

@@ -0,0 +1,248 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{#include "apr.h"
+#include "apr_hooks.h"
+#include "apr_optional_hooks.h"}
+
+{
+ * @file ap_config.h
+ * @brief Symbol export macros and hook functions
+ }
+
+{ Although this file doesn't declare any hooks, declare the hook group here }
+{ @defgroup hooks Apache Hooks }
+
+{$ifdef DOXYGEN}
+{ define these just so doxygen documents them }
+
+{
+ * AP_DECLARE_STATIC is defined when including Apache's Core headers,
+ * to provide static linkage when the dynamic library may be unavailable.
+ *
+ * @see AP_DECLARE_EXPORT
+ *
+ * AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when
+ * including Apache's Core headers, to import and link the symbols from the
+ * dynamic Apache Core library and assure appropriate indirection and calling
+ * conventions at compile time.
+ }
+{$define AP_DECLARE_STATIC}
+{
+ * AP_DECLARE_EXPORT is defined when building the Apache Core dynamic
+ * library, so that all public symbols are exported.
+ *
+ * @see AP_DECLARE_STATIC
+ }
+{$define AP_DECLARE_EXPORT}
+
+{$endif} { def DOXYGEN }
+
+//#if !defined(WIN32)
+{
+ * Apache Core dso functions are declared with AP_DECLARE(), so they may
+ * use the most appropriate calling convention.  Hook functions and other
+ * Core functions with variable arguments must use AP_DECLARE_NONSTD().
+ * @code
+ * AP_DECLARE(rettype) ap_func(args)
+ * @endcode
+ }
+//#define AP_DECLARE(type)            type
+
+{
+ * Apache Core dso variable argument and hook functions are declared with
+ * AP_DECLARE_NONSTD(), as they must use the C language calling convention.
+ * @see AP_DECLARE
+ * @code
+ * AP_DECLARE_NONSTD(rettype) ap_func(args [...])
+ * @endcode
+ }
+//#define AP_DECLARE_NONSTD(type)     type
+
+{
+ * Apache Core dso variables are declared with AP_MODULE_DECLARE_DATA.
+ * This assures the appropriate indirection is invoked at compile time.
+ *
+ * @note AP_DECLARE_DATA extern type apr_variable; syntax is required for
+ * declarations within headers to properly import the variable.
+ * @code
+ * AP_DECLARE_DATA type apr_variable
+ * @endcode
+ }
+{#define AP_DECLARE_DATA
+
+#elif defined(AP_DECLARE_STATIC)
+#define AP_DECLARE(type)            type __stdcall
+#define AP_DECLARE_NONSTD(type)     type
+#define AP_DECLARE_DATA
+#elif defined(AP_DECLARE_EXPORT)
+#define AP_DECLARE(type)            __declspec(dllexport) type __stdcall
+#define AP_DECLARE_NONSTD(type)     __declspec(dllexport) type
+#define AP_DECLARE_DATA             __declspec(dllexport)
+#else
+#define AP_DECLARE(type)            __declspec(dllimport) type __stdcall
+#define AP_DECLARE_NONSTD(type)     __declspec(dllimport) type
+#define AP_DECLARE_DATA             __declspec(dllimport)
+#endif
+
+#if !defined(WIN32) || defined(AP_MODULE_DECLARE_STATIC)}
+{
+ * Declare a dso module's exported module structure as AP_MODULE_DECLARE_DATA.
+ *
+ * Unless AP_MODULE_DECLARE_STATIC is defined at compile time, symbols
+ * declared with AP_MODULE_DECLARE_DATA are always exported.
+ * @code
+ * module AP_MODULE_DECLARE_DATA mod_tag
+ * @endcode
+ }
+{#if defined(WIN32)
+#define AP_MODULE_DECLARE(type)            type __stdcall
+#else
+#define AP_MODULE_DECLARE(type)            type
+#endif
+#define AP_MODULE_DECLARE_NONSTD(type)     type
+#define AP_MODULE_DECLARE_DATA
+#else}
+{
+ * AP_MODULE_DECLARE_EXPORT is a no-op.  Unless contradicted by the
+ * AP_MODULE_DECLARE_STATIC compile-time symbol, it is assumed and defined.
+ *
+ * The old SHARED_MODULE compile-time symbol is now the default behavior,
+ * so it is no longer referenced anywhere with Apache 2.0.
+ }
+{#define AP_MODULE_DECLARE_EXPORT
+#define AP_MODULE_DECLARE(type)          __declspec(dllexport) type __stdcall
+#define AP_MODULE_DECLARE_NONSTD(type)   __declspec(dllexport) type
+#define AP_MODULE_DECLARE_DATA           __declspec(dllexport)
+#endif}
+
+{
+ * Declare a hook function
+ * @param ret The return type of the hook
+ * @param name The hook's name (as a literal)
+ * @param args The arguments the hook function takes, in brackets.
+ }
+{#define AP_DECLARE_HOOK(ret,name,args) \
+	APR_DECLARE_EXTERNAL_HOOK(ap,AP,ret,name,args)
+}
+{ @internal }
+{#define AP_IMPLEMENT_HOOK_BASE(name) \
+	APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ap,AP,name)
+}
+{
+ * Implement an Apache core hook that has no return code, and
+ * therefore runs all of the registered functions. The implementation
+ * is called ap_run_<i>name</i>.
+ *
+ * @param name The name of the hook
+ * @param args_decl The declaration of the arguments for the hook, for example
+ * "(int x,void *y)"
+ * @param args_use The arguments for the hook as used in a call, for example
+ * "(x,y)"
+ * @note If IMPLEMENTing a hook that is not linked into the Apache core,
+ * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_VOID.
+ }
+{#define AP_IMPLEMENT_HOOK_VOID(name,args_decl,args_use) \
+	APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ap,AP,name,args_decl,args_use)
+}
+{
+ * Implement an Apache core hook that runs until one of the functions
+ * returns something other than ok or decline. That return value is
+ * then returned from the hook runner. If the hooks run to completion,
+ * then ok is returned. Note that if no hook runs it would probably be
+ * more correct to return decline, but this currently does not do
+ * so. The implementation is called ap_run_<i>name</i>.
+ *
+ * @param ret The return type of the hook (and the hook runner)
+ * @param name The name of the hook
+ * @param args_decl The declaration of the arguments for the hook, for example
+ * "(int x,void *y)"
+ * @param args_use The arguments for the hook as used in a call, for example
+ * "(x,y)"
+ * @param ok The "ok" return value
+ * @param decline The "decline" return value
+ * @return ok, decline or an error.
+ * @note If IMPLEMENTing a hook that is not linked into the Apache core,
+ * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL.
+ }
+{#define AP_IMPLEMENT_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \
+	APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
+                                            args_use,ok,decline)
+}
+{
+ * Implement a hook that runs until a function returns something other than
+ * decline. If all functions return decline, the hook runner returns decline.
+ * The implementation is called ap_run_<i>name</i>.
+ *
+ * @param ret The return type of the hook (and the hook runner)
+ * @param name The name of the hook
+ * @param args_decl The declaration of the arguments for the hook, for example
+ * "(int x,void *y)"
+ * @param args_use The arguments for the hook as used in a call, for example
+ * "(x,y)"
+ * @param decline The "decline" return value
+ * @return decline or an error.
+ * @note If IMPLEMENTing a hook that is not linked into the Apache core
+ * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST.
+ }
+{#define AP_IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \
+	APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap,AP,ret,name,args_decl, \
+                                              args_use,decline)
+}
+{ Note that the other optional hook implementations are straightforward but
+ * have not yet been needed
+ }
+
+{
+ * Implement an optional hook. This is exactly the same as a standard hook
+ * implementation, except the hook is optional.
+ * @see AP_IMPLEMENT_HOOK_RUN_ALL
+ }
+{#define AP_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok, \
+					   decline) \
+	APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
+                                            args_use,ok,decline)
+}
+{
+ * Hook an optional hook. Unlike static hooks, this uses a macro instead of a
+ * function.
+ }
+{#define AP_OPTIONAL_HOOK(name,fn,pre,succ,order) \
+        APR_OPTIONAL_HOOK(ap,name,fn,pre,succ,order)
+
+#include "os.h"
+#if !defined(WIN32) && !defined(NETWARE)
+#include "ap_config_auto.h"
+#include "ap_config_layout.h"
+#endif
+#if defined(NETWARE)
+#define AP_NONBLOCK_WHEN_MULTI_LISTEN 1
+#endif}
+
+{ TODO - We need to put OS detection back to make all the following work }
+
+{$if defined(SUNOS) or defined(IRIX) or defined(NEXT) or defined(AUX)
+ or defined (UW) or defined(LYNXOS) or defined(TPF)}
+{ These systems don't do well with any lingering close code; I don't know
+ * why -- manoj }
+{$define NO_LINGCLOSE}
+{$endif}
+
+{ If APR has OTHER_CHILD logic, use reliable piped logs. }
+{$ifdef APR_HAS_OTHER_CHILD}
+{$define AP_HAVE_RELIABLE_PIPED_LOGS}
+{$endif}
+

+ 121 - 0
packages/base/httpd/httpd-2.0/ap_mmn.inc

@@ -0,0 +1,121 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @package Module Magic Number
+ }
+
+{
+ * MODULE_MAGIC_NUMBER_MAJOR
+ * Major API changes that could cause compatibility problems for older modules
+ * such as structure size changes.  No binary compatibility is possible across
+ * a change in the major version.
+ *
+ * MODULE_MAGIC_NUMBER_MINOR
+ * Minor API changes that do not cause binary compatibility problems.
+ * Should be reset to 0 when upgrading MODULE_MAGIC_NUMBER_MAJOR.
+ *
+ * See the MODULE_MAGIC_AT_LEAST macro below for an example.
+ }
+
+{
+ * 20010224 (2.0.13-dev) MODULE_MAGIC_COOKIE reset to "AP20"
+ * 20010523 (2.0.19-dev) bump for scoreboard structure reordering
+ * 20010627 (2.0.19-dev) more API changes than I can count
+ * 20010726 (2.0.22-dev) more big API changes
+ * 20010808 (2.0.23-dev) dir d_is_absolute bit introduced, bucket changes, etc
+ * 20010825 (2.0.25-dev) removed d_is_absolute, introduced map_to_storage hook
+ * 20011002 (2.0.26-dev) removed 1.3-depreciated request_rec.content_language
+ * 20011127 (2.0.29-dev) bump for postconfig hook change, and removal of socket
+ *                       from connection record
+ * 20011212 (2.0.30-dev) bump for new used_path_info member of request_rec
+ * 20011218 (2.0.30-dev) bump for new sbh member of conn_rec, different 
+ *                       declarations for scoreboard, new parameter to
+ *                       create_connection hook
+ * 20020102 (2.0.30-dev) bump for changed type of limit_req_body in 
+ *                       core_dir_config
+ * 20020109 (2.0.31-dev) bump for changed shm and scoreboard declarations
+ * 20020111 (2.0.31-dev) bump for ETag fields added at end of cor_dir_config
+ * 20020114 (2.0.31-dev) mod_dav changed how it asks its provider to fulfill
+ *                       a GET request
+ * 20020118 (2.0.31-dev) Input filtering split of blocking and mode
+ * 20020127 (2.0.31-dev) bump for pre_mpm hook change
+ * 20020128 (2.0.31-dev) bump for pre_config hook change
+ * 20020218 (2.0.33-dev) bump for AddOutputFilterByType directive
+ * 20020220 (2.0.33-dev) bump for scoreboard.h structure change
+ * 20020302 (2.0.33-dev) bump for protocol_filter additions.
+ * 20020306 (2.0.34-dev) bump for filter type renames.
+ * 20020318 (2.0.34-dev) mod_dav's API for REPORT generation changed
+ * 20020319 (2.0.34-dev) M_INVALID changed, plus new M_* methods for RFC 3253
+ * 20020327 (2.0.35-dev) Add parameter to quick_handler hook
+ * 20020329 (2.0.35-dev) bump for addition of freelists to bucket API
+ * 20020329.1 (2.0.36) minor bump for new arg to opt fn ap_cgi_build_command
+ * 20020506 (2.0.37-dev) Removed r->boundary in request_rec.
+ * 20020529 (2.0.37-dev) Standardized the names of some apr_pool_*_set funcs
+ * 20020602 (2.0.37-dev) Bucket API change (metadata buckets)
+ * 20020612 (2.0.38-dev) Changed server_rec->[keep_alive_]timeout to apr time
+ * 20020625 (2.0.40-dev) Changed conn_rec->keepalive to an enumeration
+ * 20020628 (2.0.40-dev) Added filter_init to filter registration functions
+ * 20020903 (2.0.41-dev) APR's error constants changed
+ * 20020903.2 (2.0.46-dev) add ap_escape_logitem
+ * 20020903.3 (2.0.46-dev) allow_encoded_slashes added to core_dir_config
+ * 20020903.4 (2.0.47-dev) add ap_is_recursion_limit_exceeded()
+ * 20020903.5 (2.0.49-dev) add ap_escape_errorlog_item()
+ * 20020903.6 (2.0.49-dev) add insert_error_filter hook
+ * 20020903.7 (2.0.49-dev) added XHTML Doctypes
+ * 20020903.8 (2.0.50-dev) export ap_set_sub_req_protocol and
+ *                         ap_finalize_sub_req_protocol on Win32 and NetWare
+ * 20020903.9 (2.0.51-dev) create pcommands and initialize arrays before
+ *                         calling ap_setup_prelinked_modules
+ * 20020903.10 (2.0.55-dev) add ap_log_cerror()
+ * 20020903.11 (2.0.55-dev) added trace_enable to core_server_config
+ * 20020903.12 (2.0.56-dev) added ap_get_server_revision / ap_version_t
+ }
+const
+
+  MODULE_MAGIC_COOKIE = $41503230; { "AP20" }
+
+  MODULE_MAGIC_NUMBER_MAJOR = 20020903; { For 2.0.58 Also works for 2.0.54}
+
+  MODULE_MAGIC_NUMBER_MINOR = 12;                    // 0...n
+
+{
+ * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
+ * specified value.
+ * <pre>
+ * Useful for testing for features.
+ * For example, suppose you wish to use the apr_table_overlap
+ *    function.  You can do this:
+ * 
+ * #if AP_MODULE_MAGIC_AT_LEAST(19980812,2)
+ *     ... use apr_table_overlap()
+ * #else
+ *     ... alternative code which doesn't use apr_table_overlap()
+ * #endif
+ * </pre>
+ * @param major The major module magic number
+ * @param minor The minor module magic number
+ * @deffunc AP_MODULE_MAGIC_AT_LEAST(int major, int minor)
+ }
+{#define AP_MODULE_MAGIC_AT_LEAST(major,minor)		\
+    ((major) < MODULE_MAGIC_NUMBER_MAJOR 		\
+	|| ((major) == MODULE_MAGIC_NUMBER_MAJOR 	\
+	    && (minor) <= MODULE_MAGIC_NUMBER_MINOR))}
+
+{ @deprecated present for backwards compatibility }
+  MODULE_MAGIC_NUMBER = MODULE_MAGIC_NUMBER_MAJOR;
+//#define MODULE_MAGIC_AT_LEAST old_broken_macro_we_hope_you_are_not_using
+

+ 179 - 0
packages/base/httpd/httpd-2.0/ap_mpm.inc

@@ -0,0 +1,179 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+//#include "apr_thread_proc.h"
+
+{
+ * @package Multi-Processing Module library
+ }
+
+{
+    The MPM, "multi-processing model" provides an abstraction of the
+    interface with the OS for distributing incoming connections to
+    threads/process for processing.  http_main invokes the MPM, and
+    the MPM runs until a shutdown/restart has been indicated.
+    The MPM calls out to the apache core via the ap_process_connection
+    function when a connection arrives.
+
+    The MPM may or may not be multithreaded.  In the event that it is
+    multithreaded, at any instant it guarantees a 1:1 mapping of threads
+    ap_process_connection invocations.  
+
+    Note: In the future it will be possible for ap_process_connection
+    to return to the MPM prior to finishing the entire connection; and
+    the MPM will proceed with asynchronous handling for the connection;
+    in the future the MPM may call ap_process_connection again -- but
+    does not guarantee it will occur on the same thread as the first call.
+
+    The MPM further guarantees that no asynchronous behaviour such as
+    longjmps and signals will interfere with the user code that is
+    invoked through ap_process_connection.  The MPM may reserve some
+    signals for its use (i.e. SIGUSR1), but guarantees that these signals
+    are ignored when executing outside the MPM code itself.  (This
+    allows broken user code that does not handle EINTR to function
+    properly.)
+
+    The suggested server restart and stop behaviour will be "graceful".
+    However the MPM may choose to terminate processes when the user
+    requests a non-graceful restart/stop.  When this occurs, the MPM kills
+    all threads with extreme prejudice, and destroys the pchild pool.
+    User cleanups registered in the pchild apr_pool_t will be invoked at
+    this point.  (This can pose some complications, the user cleanups
+    are asynchronous behaviour not unlike longjmp/signal... but if the
+    admin is asking for a non-graceful shutdown, how much effort should
+    we put into doing it in a nice way?)
+
+    unix/posix notes:
+    - The MPM does not set a SIGALRM handler, user code may use SIGALRM.
+	But the preferred method of handling timeouts is to use the
+	timeouts provided by the BUFF abstraction.
+    - The proper setting for SIGPIPE is SIG_IGN, if user code changes it
+        for any of their own processing, it must be restored to SIG_IGN
+	prior to executing or returning to any apache code.
+    TODO: add SIGPIPE debugging check somewhere to make sure it's SIG_IGN
+}
+
+{
+ * This is the function that MPMs must create.  This function is responsible
+ * for controlling the parent and child processes.  It will run until a 
+ * restart/shutdown is indicated.
+ * @param pconf the configuration pool, reset before the config file is read
+ * @param plog the log pool, reset after the config file is read
+ * @param server_conf the global server config.
+ * @return 1 for shutdown 0 otherwise.
+ * @deffunc int ap_mpm_run(apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf)
+ }
+function ap_mpm_run(pconf, plog: Papr_pool_t; server_conf: Pserver_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_mpm_run' + LibSuff12;
+
+{
+ * predicate indicating if a graceful stop has been requested ...
+ * used by the connection loop 
+ * @return 1 if a graceful stop has been requested, 0 otherwise
+ * @deffunc int ap_graceful_stop_signalled(*void)
+ }
+function ap_graceful_stop_signalled: Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_graceful_stop_signalled' + LibSuff0;
+
+{
+ * Spawn a process with privileges that another module has requested
+ * @param r The request_rec of the current request
+ * @param newproc The resulting process handle.
+ * @param progname The program to run 
+ * @param const_args the arguments to pass to the new program.  The first 
+ *                   one should be the program name.
+ * @param env The new environment apr_table_t for the new process.  This 
+ *            should be a list of NULL-terminated strings.
+ * @param attr the procattr we should use to determine how to create the new
+ *         process
+ * @param p The pool to use. 
+ }
+function ap_os_create_privileged_process(
+ const r: Prequest_rec;
+ newproc: Papr_proc_t;
+ const progname, args, env: PChar;
+ attr: Papr_procattr_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_os_create_privileged_process' + LibSuff28;
+
+const
+{ Subtypes/Values for AP_MPMQ_IS_THREADED and AP_MPMQ_IS_FORKED        }
+  AP_MPMQ_NOT_SUPPORTED     = 0;  { This value specifies whether }
+                                      { an MPM is capable of         }
+                                      { threading or forking.        }
+  AP_MPMQ_STATIC            = 1;  { This value specifies whether }
+                                      { an MPM is using a static #   }
+                                      { threads or daemons.          }
+  AP_MPMQ_DYNAMIC           = 2;  { This value specifies whether }
+                                      { an MPM is using a dynamic #  }
+                                      { threads or daemons.          }
+
+{ Values returned for AP_MPMQ_MPM_STATE }
+  AP_MPMQ_STARTING             = 0;
+  AP_MPMQ_RUNNING              = 1;
+  AP_MPMQ_STOPPING             = 2;
+
+  AP_MPMQ_MAX_DAEMON_USED      = 1;  { Max # of daemons used so far }
+  AP_MPMQ_IS_THREADED          = 2;  { MPM can do threading         }
+  AP_MPMQ_IS_FORKED            = 3;  { MPM can do forking           }
+  AP_MPMQ_HARD_LIMIT_DAEMONS   = 4;  { The compiled max # daemons   }
+  AP_MPMQ_HARD_LIMIT_THREADS   = 5;  { The compiled max # threads   }
+  AP_MPMQ_MAX_THREADS          = 6;  { # of threads/child by config }
+  AP_MPMQ_MIN_SPARE_DAEMONS    = 7;  { Min # of spare daemons       }
+  AP_MPMQ_MIN_SPARE_THREADS    = 8;  { Min # of spare threads       }
+  AP_MPMQ_MAX_SPARE_DAEMONS    = 9;  { Max # of spare daemons       }
+  AP_MPMQ_MAX_SPARE_THREADS   = 10;  { Max # of spare threads       }
+  AP_MPMQ_MAX_REQUESTS_DAEMON = 11;  { Max # of requests per daemon }
+  AP_MPMQ_MAX_DAEMONS         = 12;  { Max # of daemons by config   }
+  AP_MPMQ_MPM_STATE           = 13;  { starting, running, stopping  }
+
+{
+ * Query a property of the current MPM.  
+ * @param query_code One of APM_MPMQ_*
+ * @param result A location to place the result of the query
+ * @return APR_SUCCESS or APR_ENOTIMPL
+ * @deffunc int ap_mpm_query(int query_code, int *result)
+ }
+function ap_mpm_query(query_code: Integer; result: PInteger): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_mpm_query' + LibSuff8;
+
+{ Defining GPROF when compiling uses the moncontrol() function to
+ * disable gprof profiling in the parent, and enable it only for
+ * request processing in children (or in one_process mode).  It's
+ * absolutely required to get useful gprof results under linux
+ * because the profile itimers and such are disabled across a
+ * fork().  It's probably useful elsewhere as well.
+ }
+{#ifdef GPROF
+extern void moncontrol(int);
+#define AP_MONCONTROL(x) moncontrol(x)
+#else
+#define AP_MONCONTROL(x)
+#endif}
+
+{$ifdef AP_ENABLE_EXCEPTION_HOOK}
+type
+  ap_exception_info_t = record
+    sig: Integer;
+    pid: pid_t;
+  end;
+
+AP_DECLARE_HOOK(int,fatal_exception,(ap_exception_info_t *ei))
+{$endif} {AP_ENABLE_EXCEPTION_HOOK}
+

+ 50 - 0
packages/base/httpd/httpd-2.0/ap_provider.inc

@@ -0,0 +1,50 @@
+{ Copyright 2002-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+//#include "ap_config.h"
+
+{
+ * @package Provider API
+ }
+
+{
+ * This function is used to register a provider with the global
+ * provider pool.
+ * @param pool The pool to create any storage from
+ * @param provider_group The group to store the provider in
+ * @param provider_name The name for this provider
+ * @param provider_version The version for this provider
+ * @param provider Opaque structure for this provider
+ * @return APR_SUCCESS if all went well
+ }
+function ap_register_provider(pool: Papr_pool_t;
+ const provider_group, provider_name, provider_version: PChar;
+ const provider: Pointer): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_register_provider' + LibSuff20;
+
+{
+ * This function is used to retrieve a provider from the global
+ * provider pool.
+ * @param provider_group The group to look for this provider in
+ * @param provider_name The name for the provider
+ * @param provider_version The version for the provider
+ * @return provider pointer to provider if found, NULL otherwise
+ }
+function ap_lookup_provider(provider_group, provider_name, provider_version: PChar): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_lookup_provider' + LibSuff12;
+

+ 53 - 0
packages/base/httpd/httpd-2.0/ap_release.inc

@@ -0,0 +1,53 @@
+{ Copyright 2001-2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+//#include "apr_general.h" /* stringify */
+
+const
+  AP_SERVER_COPYRIGHT =
+    'Copyright 2001-2006 The Apache Software Foundation' +
+    ' or its licensors, as applicable.';
+
+{
+ * The below defines the base string of the Server: header. Additional
+ * tokens can be added via the ap_add_version_component() API call.
+ *
+ * The tokens are listed in order of their significance for identifying the
+ * application.
+ *
+ * "Product tokens should be short and to the point -- use of them for 
+ * advertizing or other non-essential information is explicitly forbidden."
+ *
+ * Example: "Apache/1.1.0 MrWidget/0.1-alpha" 
+ }
+  AP_SERVER_BASEVENDOR = 'Apache Software Foundation';
+  AP_SERVER_BASEPRODUCT = 'Apache';
+
+  AP_SERVER_MAJORVERSION_NUMBER = 2;
+  AP_SERVER_MINORVERSION_NUMBER = 0;
+  AP_SERVER_PATCHLEVEL_NUMBER   = 58;
+  AP_SERVER_ADD_STRING          = '';
+
+{ keep old macros as well }
+{#define AP_SERVER_MAJORVERSION APR_STRINGIFY(AP_SERVER_MAJORVERSION_NUMBER)
+#define AP_SERVER_MINORVERSION APR_STRINGIFY(AP_SERVER_MINORVERSION_NUMBER)
+#define AP_SERVER_PATCHLEVEL APR_STRINGIFY(AP_SERVER_PATCHLEVEL_NUMBER) \
+                              AP_SERVER_ADD_STRING
+
+#define AP_SERVER_MINORREVISION AP_SERVER_MAJORVERSION "." AP_SERVER_MINORVERSION
+#define AP_SERVER_BASEREVISION  AP_SERVER_MINORREVISION "." AP_SERVER_PATCHLEVEL
+#define AP_SERVER_BASEVERSION AP_SERVER_BASEPRODUCT "/" AP_SERVER_BASEREVISION
+#define AP_SERVER_VERSION  AP_SERVER_BASEVERSION}
+

+ 246 - 0
packages/base/httpd/httpd-2.0/apr/apr.pas

@@ -0,0 +1,246 @@
+{
+ apr.pas
+
+ Copyright (C) 2006 Felipe Monteiro de Carvalho
+
+ This unit is a pascal binding for the Apache 2.0.58 headers.
+ The headers were released under the following copyright:
+}
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+unit apr;
+
+interface
+
+{$ifdef fpc}
+  {$mode delphi}{$H+}
+{$endif}
+
+{$IFNDEF FPC}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$IFDEF WIN32}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$ifdef Unix}
+  {$PACKRECORDS C}
+{$endif}
+
+{$define Apache2_0}
+
+uses
+{$ifdef WINDOWS}
+  Windows, winsock,
+{$ELSE}
+  UnixType,
+{$ENDIF}
+  SysUtils, ctypes;
+  
+const
+{$IFDEF WINDOWS}
+  LibAPR = 'libapr.dll';
+{$ELSE}
+  LibAPR = '';
+{$ENDIF}
+
+{$IFDEF WINDOWS}
+  LibNamePrefix = '_';
+  LibSuff0 = '@0';
+  LibSuff4 = '@4';
+  LibSuff8 = '@8';
+  LibSuff12 = '@12';
+  LibSuff16 = '@16';
+  LibSuff20 = '@20';
+  LibSuff24 = '@24';
+  LibSuff28 = '@28';
+  LibSuff32 = '@32';
+{$ELSE}
+  LibNamePrefix = '';
+  LibSuff0 = '';
+  LibSuff4 = '';
+  LibSuff8 = '';
+  LibSuff12 = '';
+  LibSuff16 = '';
+  LibSuff20 = '';
+  LibSuff24 = '';
+  LibSuff28 = '';
+  LibSuff32 = '';
+{$ENDIF}
+
+type
+  uid_t = Integer;
+  gid_t = Integer;
+  time_t = LongInt;
+  size_t = Integer;
+  pid_t = Integer;
+  Ppid_t = ^pid_t;
+  apr_uint16_t = Word;
+  apr_uint32_t = Cardinal;
+  apr_int64_t = Int64;
+  apr_uint64_t = Int64;
+  apr_socklen_t = Integer;
+  
+  apr_uint32_tso_handle_t = cuint;
+
+type
+  {$IFDEF WINDOWS}
+  apr_off_t = Int64;
+  {$ENDIF}
+  {$IFDEF UNIX}
+  apr_off_t = Integer;
+  {$ENDIF}
+
+  apr_int32_t = Integer;
+  Papr_int32_t = ^Integer;
+  apr_size_t = size_t;
+  Papr_size_t = ^apr_size_t;
+  apr_int16_t = SmallInt;
+  Papr_int16_t = ^SmallInt;
+
+  // Network structures
+  
+  sockaddr = record
+    sa_family: cushort;    // address family, AF_xxx
+    sa_data: array [1..14] of Char;  // (NBO) 14 bytes of protocol address
+  end;
+  
+{$ifndef windows}
+
+  va_list = Pointer;
+
+  in_addr = record
+    s_addr: culong;        // load with inet_aton()
+  end;
+
+  sockaddr_in = record
+    sin_family: cshort;    // e.g. AF_INET
+    sin_port: cushort;     // e.g. htons(3490)
+    sin_addr: in_addr;     // see struct in_addr, below
+    sin_zero: array [1..8] of Char;  // zero this if you want to
+  end;
+  
+{$endif}
+
+  in6_addr = record
+   Case Integer of
+    1: (u6_addr8: array [1..16] of Byte);
+    2: (u6_addr16: array [1..8] of Word);
+    3: (u6_addr32: array [1..4] of Cardinal);
+  end;
+//#define s6_addr      in6_u.u6_addr8
+//#define s6_addr16    in6_u.u6_addr16
+//#define s6_addr32    in6_u.u6_addr32
+
+  sockaddr_in6 = record
+   sin6_family: cushort;
+    sin6_port: Word;
+    sin6_flowinfo: Cardinal;
+    sin6_addr: in6_addr;
+    sin6_scope_id: Cardinal;
+  end;
+
+  // TEMPORARY
+  
+  Papr_xml_ns_scope = Pointer;
+
+  Pap_method_list_t = Pointer;
+  Pcore_output_filter_ctx_t = Pointer;
+  Pap_directive_t = Pointer;
+  Pap_filter_t = Pointer;
+  Papr_file_t = Pointer;
+  Papr_off_t = Pointer;
+
+  iovec = record
+    /// byte count to read/write
+    iov_len: culong;
+    /// data to be read/written
+    iov_base: PChar;
+  end;
+  
+  Piovec = ^iovec;
+
+{$include apr_errno.inc}
+{$include apr_pools.inc}
+{$include apr_general.inc}
+{$include apr_dso.inc}
+{$include apr_user.inc}
+{$include apr_time.inc}
+{$include apr_tables.inc}
+{$include apr_file_info.inc}
+{$include apr_file_io.inc}
+{$include apr_strings.inc}
+{$include apr_lib.inc}
+{$include apr_signal.inc}
+{$include apr_network_io.inc}
+{.$include apr_portable.inc}
+
+{.$include ../aprutils/apr_uri.inc}
+
+{$include apr_thread_proc.inc}
+{$include apr_version.inc}
+{$include apr_poll.inc}
+
+implementation
+
+{
+  Macros transformed into functions in the translation
+}
+
+{ apr_pools.inc }
+
+{$ifndef DOXYGEN}
+function apr_pool_create(newpool: PPapr_pool_t; parent: Papr_pool_t): apr_status_t;
+begin
+  Result := apr_pool_create_ex(newpool, parent, nil, nil);
+end;
+{$endif}
+
+function apr_pool_sub_make(newpool: PPapr_pool_t; parent: Papr_pool_t;
+ abort_fn: apr_abortfunc_t): apr_status_t;
+begin
+  Result := apr_pool_create_ex(newpool, parent, abort_fn, nil);
+end;
+
+{ apr_lib.inc }
+
+function apr_tolower(c: Char): Char;
+var
+  buf: array[0..1] of Char;
+begin
+  buf[0] := c;
+  buf[1] := #0;
+  
+  buf := StrLower(@buf[0]);
+  
+  Result := buf[0];
+end;
+
+function apr_toupper(c: Char): Char;
+var
+  buf: array[0..1] of Char;
+begin
+  buf[0] := c;
+  buf[1] := #0;
+
+  buf := StrUpper(@buf[0]);
+
+  Result := buf[0];
+end;
+
+end.
+

+ 174 - 0
packages/base/httpd/httpd-2.0/apr/apr_allocator.inc

@@ -0,0 +1,174 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_allocator.h
+ * @brief APR Internal Memory Allocation
+ }
+
+{#include "apr.h"
+#include "apr_errno.h"
+#define APR_WANT_MEMFUNC < For no good reason?
+#include "apr_want.h"}
+
+{
+ * @defgroup apr_allocator Internal Memory Allocation
+ * @ingroup APR 
+ }
+
+type
+{ the allocator structure }
+  apr_allocator_t = record end;
+  Papr_allocator_t = ^apr_allocator_t;
+  PPapr_allocator_t = ^Papr_allocator_t;
+
+  { the structure which holds information about the allocation }
+
+  Papr_memnode_t = ^apr_memnode_t;
+  PPapr_memnode_t = ^Papr_memnode_t;
+
+  { basic memory node structure }
+
+  apr_memnode_t = record
+    next: Papr_memnode_t;            {< next memnode }
+    ref: PPapr_memnode_t;            {< reference to self }
+    index: apr_uint32_t;             {< size }
+    free_index: apr_uint32_t;        {< how much free }
+    first_avail: PChar;              {< pointer to first free memory }
+    endp: PChar;                     {< pointer to end of free memory }
+  end;
+
+{ The base size of a memory node - aligned.  }
+//#define APR_MEMNODE_T_SIZE APR_ALIGN_DEFAULT(sizeof(apr_memnode_t))
+
+{ Symbolic constants }
+const
+  APR_ALLOCATOR_MAX_FREE_UNLIMITED = 0;
+
+{
+ * Create a new allocator
+ * @param allocator The allocator we have just created.
+ *
+ }
+function apr_allocator_create(allocator: PPapr_allocator_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_create' + LibSuff4;
+
+{
+ * Destroy an allocator
+ * @param allocator The allocator to be destroyed
+ * @remark Any memnodes not given back to the allocator prior to destroying
+ *         will _not_ be free()d.
+ }
+procedure apr_allocator_destroy(allocator: Papr_allocator_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_destroy' + LibSuff4;
+
+{
+ * Allocate a block of mem from the allocator
+ * @param allocator The allocator to allocate from
+ * @param size The size of the mem to allocate (excluding the
+ *        memnode structure)
+ }
+function apr_allocator_alloc(allocator: Papr_allocator_t;
+ size: apr_size_t): Papr_memnode_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_alloc' + LibSuff8;
+
+{
+ * Free a block of mem, giving it back to the allocator
+ * @param allocator The allocator to give the mem back to
+ * @param memnode The memory node to return
+ }
+procedure apr_allocator_free(allocator: Papr_allocator_t; memnode: Papr_memnode_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_free' + LibSuff8;
+
+//#include "apr_pools.h"
+
+{
+ * Set the owner of the allocator
+ * @param allocator The allocator to set the owner for
+ * @param pool The pool that is to own the allocator
+ * @remark Typically pool is the highest level pool using the allocator
+ }
+{
+ * XXX: see if we can come up with something a bit better.  Currently
+ * you can make a pool an owner, but if the pool doesn't use the allocator
+ * the allocator will never be destroyed.
+ }
+procedure apr_allocator_owner_set(allocator: Papr_allocator_t; pool: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_owner_set' + LibSuff8;
+
+{ @deprecated @see apr_allocator_owner_set }
+{APR_DECLARE(void) apr_allocator_set_owner(apr_allocator_t *allocator,
+                                          apr_pool_t *pool);
+}
+{
+ * Get the current owner of the allocator
+ * @param allocator The allocator to get the owner from
+ }
+function apr_allocator_owner_get(allocator: Papr_allocator_t): Papr_pool_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_owner_get' + LibSuff4;
+
+{ @deprecated @see apr_allocator_owner_get }
+{APR_DECLARE(apr_pool_t *) apr_allocator_get_owner(
+                                  apr_allocator_t *allocator);
+}
+{
+ * Set the current threshold at which the allocator should start
+ * giving blocks back to the system.
+ * @param allocator The allocator the set the threshold on
+ * @param size The threshold.  0 == unlimited.
+ }
+procedure apr_allocator_max_free_set(allocator: Papr_allocator_t; size: apr_size_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_max_free_set' + LibSuff8;
+
+{ @deprecated @see apr_allocator_max_free_set }
+{APR_DECLARE(void) apr_allocator_set_max_free(apr_allocator_t *allocator,
+                                             apr_size_t size);
+
+#include "apr_thread_mutex.h"}
+
+{$ifdef APR_HAS_THREADS}
+{
+ * Set a mutex for the allocator to use
+ * @param allocator The allocator to set the mutex for
+ * @param mutex The mutex
+ }
+APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator,
+                                          apr_thread_mutex_t *mutex);
+
+{ @deprecated @see apr_allocator_mutex_set }
+APR_DECLARE(void) apr_allocator_set_mutex(apr_allocator_t *allocator,
+                                          apr_thread_mutex_t *mutex);
+
+{
+ * Get the mutex currently set for the allocator
+ * @param allocator The allocator
+ }
+APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get(
+                                      apr_allocator_t *allocator);
+
+{ @deprecated @see apr_allocator_mutex_get }
+APR_DECLARE(apr_thread_mutex_t *) apr_allocator_get_mutex(
+                                      apr_allocator_t *allocator);
+
+{$endif} { APR_HAS_THREADS }
+

+ 1515 - 0
packages/base/httpd/httpd-2.0/apr/apr_buckets.inc

@@ -0,0 +1,1515 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+{
+ * @file apr_buckets.h
+ * @brief APR-UTIL Buckets/Bucket Brigades
+ }
+
+{#if defined(APR_BUCKET_DEBUG) && !defined(APR_RING_DEBUG)
+#define APR_RING_DEBUG
+#endif
+
+#include "apu.h"
+#include "apr_network_io.h"
+#include "apr_file_io.h"
+#include "apr_general.h"
+#include "apr_mmap.h"
+#include "apr_errno.h"
+#include "apr_ring.h"
+#include "apr.h"
+#if APR_HAVE_SYS_UIO_H
+#include <sys/uio.h>	for struct iovec
+#endif
+#if APR_HAVE_STDARG_H
+#include <stdarg.h>
+#endif}
+
+{
+ * @defgroup APR_Util_Bucket_Brigades Bucket Brigades
+ * @ingroup APR_Util
+ }
+
+{ default bucket buffer size - 8KB minus room for memory allocator headers }
+const
+  APR_BUCKET_BUFF_SIZE = 8000;
+
+{ Determines how a bucket or brigade should be read }
+type
+  apr_read_type_e = (
+    APR_BLOCK_READ,   {< block until data becomes available }
+    APR_NONBLOCK_READ {< return immediately if no data is available }
+  );
+
+{
+ * The one-sentence buzzword-laden overview: Bucket brigades represent
+ * a complex data stream that can be passed through a layered IO
+ * system without unnecessary copying. A longer overview follows...
+ *
+ * A bucket brigade is a doubly linked list (ring) of buckets, so we
+ * aren't limited to inserting at the front and removing at the end.
+ * Buckets are only passed around as members of a brigade, although
+ * singleton buckets can occur for short periods of time.
+ *
+ * Buckets are data stores of various types. They can refer to data in
+ * memory, or part of a file or mmap area, or the output of a process,
+ * etc. Buckets also have some type-dependent accessor functions:
+ * read, split, copy, setaside, and destroy.
+ *
+ * read returns the address and size of the data in the bucket. If the
+ * data isn't in memory then it is read in and the bucket changes type
+ * so that it can refer to the new location of the data. If all the
+ * data doesn't fit in the bucket then a new bucket is inserted into
+ * the brigade to hold the rest of it.
+ *
+ * split divides the data in a bucket into two regions. After a split
+ * the original bucket refers to the first part of the data and a new
+ * bucket inserted into the brigade after the original bucket refers
+ * to the second part of the data. Reference counts are maintained as
+ * necessary.
+ *
+ * setaside ensures that the data in the bucket has a long enough
+ * lifetime. Sometimes it is convenient to create a bucket referring
+ * to data on the stack in the expectation that it will be consumed
+ * (output to the network) before the stack is unwound. If that
+ * expectation turns out not to be valid, the setaside function is
+ * called to move the data somewhere safer.
+ *
+ * copy makes a duplicate of the bucket structure as long as it's
+ * possible to have multiple references to a single copy of the
+ * data itself.  Not all bucket types can be copied.
+ *
+ * destroy maintains the reference counts on the resources used by a
+ * bucket and frees them if necessary.
+ *
+ * Note: all of the above functions have wrapper macros (apr_bucket_read(),
+ * apr_bucket_destroy(), etc), and those macros should be used rather
+ * than using the function pointers directly.
+ *
+ * To write a bucket brigade, they are first made into an iovec, so that we
+ * don't write too little data at one time.  Currently we ignore compacting the
+ * buckets into as few buckets as possible, but if we really want good
+ * performance, then we need to compact the buckets before we convert to an
+ * iovec, or possibly while we are converting to an iovec.
+ }
+
+{
+ * Forward declaration of the main types.
+ }
+
+{ @see apr_bucket_brigade }
+  Papr_bucket_brigade = ^apr_bucket_brigade;
+  PPapr_bucket_brigade = ^Papr_bucket_brigade;
+{ @see apr_bucket }
+  Papr_bucket = ^apr_bucket;
+  PPapr_bucket = ^Papr_bucket;
+{ @see apr_bucket_alloc_t }
+  apr_bucket_alloc_t = record end;
+  Papr_bucket_alloc_t = ^apr_bucket_alloc_t;
+
+{ @see apr_bucket_type_t }
+  Papr_bucket_type_t = ^apr_bucket_type_t;
+
+  is_metadata = (
+    { This bucket type represents actual data to send to the client. }
+    APR_BUCKET_DATA = 0,
+    { This bucket type represents metadata. }
+    APR_BUCKET_METADATA = 1
+  );
+  
+  destroy_t = procedure (data: Pointer);
+
+  read_t = function (b: Papr_bucket; const str: PPChar; len: Papr_size_t;
+   block: apr_read_type_e): apr_status_t;
+                         
+  setaside_t = function (e: Papr_bucket; pool: Papr_pool_t): apr_status_t;
+
+  split_t = function (e: Papr_bucket; point: apr_size_t): apr_status_t;
+
+  copy_t = function (e: Papr_bucket; c: PPapr_bucket): apr_status_t;
+{
+ * Basic bucket type
+ }
+  apr_bucket_type_t = record
+    {
+     * The name of the bucket type
+     }
+    name: PChar;
+    {
+     * The number of functions this bucket understands.  Can not be less than
+     * five.
+     }
+    num_func: Integer;
+    {
+     * Whether the bucket contains metadata (ie, information that
+     * describes the regular contents of the brigade).  The metadata
+     * is not returned by apr_bucket_read() and is not indicated by
+     * the ->length of the apr_bucket itself.  In other words, an
+     * empty bucket is safe to arbitrarily remove if and only if it
+     * contains no metadata.  In this sense, "data" is just raw bytes
+     * that are the "content" of the brigade and "metadata" describes
+     * that data but is not a proper part of it.
+     }
+
+     { Declaration moved up }
+
+    {
+     * Free the private data and any resources used by the bucket (if they
+     *  aren't shared with another bucket).  This function is required to be
+     *  implemented for all bucket types, though it might be a no-op on some
+     *  of them (namely ones that never allocate any private data structures).
+     * @param data The private data pointer from the bucket to be destroyed
+     }
+    destroy: destroy_t;
+
+    {
+     * Read the data from the bucket. This is required to be implemented
+     *  for all bucket types.
+     * @param b The bucket to read from
+     * @param str A place to store the data read.  Allocation should only be
+     *            done if absolutely necessary. 
+     * @param len The amount of data read.
+     * @param block Should this read function block if there is more data that
+     *              cannot be read immediately.
+     }
+    read: read_t;
+    
+    {
+     * Make it possible to set aside the data for at least as long as the
+     *  given pool. Buckets containing data that could potentially die before
+     *  this pool (e.g. the data resides on the stack, in a child pool of
+     *  the given pool, or in a disjoint pool) must somehow copy, shift, or
+     *  transform the data to have the proper lifetime.
+     * @param e The bucket to convert
+     * @remark Some bucket types contain data that will always outlive the
+     *         bucket itself. For example no data (EOS and FLUSH), or the data
+     *         resides in global, constant memory (IMMORTAL), or the data is on
+     *      the heap (HEAP). For these buckets, apr_bucket_setaside_noop can
+     *      be used.
+     }
+    setaside: setaside_t;
+
+    {
+     * Split one bucket in two at the specified position by duplicating
+     *  the bucket structure (not the data) and modifying any necessary
+     *  start/end/offset information.  If it's not possible to do this
+     *  for the bucket type (perhaps the length of the data is indeterminate,
+     *  as with pipe and socket buckets), then APR_ENOTIMPL is returned.
+     * @param e The bucket to split
+     * @param point The offset of the first byte in the new bucket
+     }
+    split: split_t;
+
+    {
+     * Copy the bucket structure (not the data), assuming that this is
+     *  possible for the bucket type. If it's not, APR_ENOTIMPL is returned.
+     * @param e The bucket to copy
+     * @param c Returns a pointer to the new bucket
+     }
+    copy: copy_t;
+  end;
+
+{
+ * apr_bucket structures are allocated on the malloc() heap and
+ * their lifetime is controlled by the parent apr_bucket_brigade
+ * structure. Buckets can move from one brigade to another e.g. by
+ * calling APR_BRIGADE_CONCAT(). In general the data in a bucket has
+ * the same lifetime as the bucket and is freed when the bucket is
+ * destroyed; if the data is shared by more than one bucket (e.g.
+ * after a split) the data is freed when the last bucket goes away.
+ }
+  free_t = procedure(e: Pointer);
+
+  link_t = record
+    next: Papr_bucket;
+    prev: Papr_bucket;
+  end;
+
+  apr_bucket = record
+    { Links to the rest of the brigade }
+    link: link_t;
+    
+    { The type of bucket.  }
+    type_: Papr_bucket_type_t;
+    { The length of the data in the bucket.  This could have been implemented
+     *  with a function, but this is an optimization, because the most
+     *  common thing to do will be to get the length.  If the length is unknown,
+     *  the value of this field will be (apr_size_t)(-1).
+     }
+    length: apr_size_t;
+    { The start of the data in the bucket relative to the private base
+     *  pointer.  The vast majority of bucket types allow a fixed block of
+     *  data to be referenced by multiple buckets, each bucket pointing to
+     *  a different segment of the data.  That segment starts at base+start
+     *  and ends at base+start+length.  
+     *  If the length == (apr_size_t)(-1), then start == -1.
+     }
+    start: apr_off_t;
+    { type-dependent data hangs off this pointer }
+    data: Pointer;
+    {
+     * Pointer to function used to free the bucket. This function should
+     * always be defined and it should be consistent with the memory
+     * function used to allocate the bucket. For example, if malloc() is 
+     * used to allocate the bucket, this pointer should point to free().
+     * @param e Pointer to the bucket being freed
+     }
+    free: free_t;
+    { The freelist from which this bucket was allocated }
+    list: Papr_bucket_alloc_t;
+  end;
+
+  { A list of buckets }
+  
+  apr_bucket_list = record
+    next: Papr_bucket;
+    prev: Papr_bucket;
+  end;
+
+  apr_bucket_brigade = record
+    { The pool to associate the brigade with.  The data is not allocated out
+     *  of the pool, but a cleanup is registered with this pool.  If the 
+     *  brigade is destroyed by some mechanism other than pool destruction,
+     *  the destroying function is responsible for killing the cleanup.
+     }
+    p: Papr_pool_t;
+    { The buckets in the brigade are on this list. }
+    {
+     * The apr_bucket_list structure doesn't actually need a name tag
+     * because it has no existence independent of struct apr_bucket_brigade;
+     * the ring macros are designed so that you can leave the name tag
+     * argument empty in this situation but apparently the Windows compiler
+     * doesn't like that.
+     }
+    list: apr_bucket_list;
+    { The freelist from which this bucket was allocated }
+    bucket_alloc: Papr_bucket_alloc_t;
+  end;
+
+
+{
+ * Function called when a brigade should be flushed
+ }
+  apr_brigade_flush = function (bb: Papr_bucket_brigade; ctx: Pointer): apr_status_t;
+
+{
+ * define APR_BUCKET_DEBUG if you want your brigades to be checked for
+ * validity at every possible instant.  this will slow your code down
+ * substantially but is a very useful debugging tool.
+ }
+{#ifdef APR_BUCKET_DEBUG
+
+#define APR_BRIGADE_CHECK_CONSISTENCY(b)				\
+        APR_RING_CHECK_CONSISTENCY(&(b)->list, apr_bucket, link)
+
+#define APR_BUCKET_CHECK_CONSISTENCY(e)					\
+        APR_RING_CHECK_ELEM_CONSISTENCY((e), apr_bucket, link)
+
+#else}
+{
+ * checks the ring pointers in a bucket brigade for consistency.  an
+ * abort() will be triggered if any inconsistencies are found.
+ *   note: this is a no-op unless APR_BUCKET_DEBUG is defined.
+ * @param b The brigade
+ }
+//#define APR_BRIGADE_CHECK_CONSISTENCY(b)
+{
+ * checks the brigade a bucket is in for ring consistency.  an
+ * abort() will be triggered if any inconsistencies are found.
+ *   note: this is a no-op unless APR_BUCKET_DEBUG is defined.
+ * @param e The bucket
+ }
+//#define APR_BUCKET_CHECK_CONSISTENCY(e)
+//#endif
+
+
+{
+ * Wrappers around the RING macros to reduce the verbosity of the code
+ * that handles bucket brigades.
+ }
+{
+ * The magic pointer value that indicates the head of the brigade
+ * @remark This is used to find the beginning and end of the brigade, eg:
+ * <pre>
+ *      while (e != APR_BRIGADE_SENTINEL(b)) (
+ *          ...
+ *          e = APR_BUCKET_NEXT(e);
+ *      )
+ * </pre>
+ * @param  b The brigade
+ * @return The magic pointer value
+ }
+//#define APR_BRIGADE_SENTINEL(b)	APR_RING_SENTINEL(&(b)->list, apr_bucket, link)
+
+{
+ * Determine if the bucket brigade is empty
+ * @param b The brigade to check
+ * @return true or false
+ }
+//#define APR_BRIGADE_EMPTY(b)	APR_RING_EMPTY(&(b)->list, apr_bucket, link)
+
+{
+ * Return the first bucket in a brigade
+ * @param b The brigade to query
+ * @return The first bucket in the brigade
+ }
+//#define APR_BRIGADE_FIRST(b)	APR_RING_FIRST(&(b)->list)
+{
+ * Return the last bucket in a brigade
+ * @param b The brigade to query
+ * @return The last bucket in the brigade
+ }
+//#define APR_BRIGADE_LAST(b)	APR_RING_LAST(&(b)->list)
+
+{
+ * Iterate through a bucket brigade
+ * @param e The current bucket
+ * @param b The brigade to iterate over
+ * @remark This is the same as either:
+ * <pre>
+ *	e = APR_BRIGADE_FIRST(b);
+ * 	while (e != APR_BRIGADE_SENTINEL(b)) (
+ *	    ...
+ * 	    e = APR_BUCKET_NEXT(e);
+ *      )
+ *  OR
+ * 	for (e = APR_BRIGADE_FIRST(b);
+ *           e != APR_BRIGADE_SENTINEL(b);
+ *           e = APR_BUCKET_NEXT(e)) (
+ *	    ...
+ *      )
+ * </pre>
+ * @warning Be aware that you cannot change the value of e within
+ * the foreach loop, nor can you destroy the bucket it points to.
+ * Modifying the prev and next pointers of the bucket is dangerous
+ * but can be done if you're careful.  If you change e's value or
+ * destroy the bucket it points to, then APR_BRIGADE_FOREACH
+ * will have no way to find out what bucket to use for its next
+ * iteration.  The reason for this can be seen by looking closely
+ * at the equivalent loops given in the tip above.  So, for example,
+ * if you are writing a loop that empties out a brigade one bucket
+ * at a time, APR_BRIGADE_FOREACH just won't work for you.  Do it
+ * by hand, like so:
+ * <pre>
+ *      while (!APR_BRIGADE_EMPTY(b)) (
+ *          e = APR_BRIGADE_FIRST(b);
+ *          ...
+ *          apr_bucket_delete(e);
+ *      )
+ * </pre>
+ * @deprecated This macro causes more headaches than it's worth.  Use
+ * one of the alternatives documented here instead; the clarity gained
+ * in what's really going on is well worth the extra line or two of code.
+ * This macro will be removed at some point in the future.
+ }
+//#define APR_BRIGADE_FOREACH(e, b)					\
+//	APR_RING_FOREACH((e), &(b)->list, apr_bucket, link)
+
+{
+ * Insert a list of buckets at the front of a brigade
+ * @param b The brigade to add to
+ * @param e The first bucket in a list of buckets to insert
+ }
+{#define APR_BRIGADE_INSERT_HEAD(b, e) do (				\
+	apr_bucket *ap__b = (e);                                        \
+	APR_RING_INSERT_HEAD(&(b)->list, ap__b, apr_bucket, link);	\
+        APR_BRIGADE_CHECK_CONSISTENCY((b));				\
+    ) while (0)}
+
+{
+ * Insert a list of buckets at the end of a brigade
+ * @param b The brigade to add to
+ * @param e The first bucket in a list of buckets to insert
+ }
+{#define APR_BRIGADE_INSERT_TAIL(b, e) do begin				\
+	apr_bucket *ap__b = (e);					\
+	APR_RING_INSERT_TAIL(&(b)->list, ap__b, apr_bucket, link);	\
+        APR_BRIGADE_CHECK_CONSISTENCY((b));				\
+    end while (0)}
+
+{
+ * Concatenate brigade b onto the end of brigade a, leaving brigade b empty
+ * @param a The first brigade
+ * @param b The second brigade
+ }
+{#define APR_BRIGADE_CONCAT(a, b) do begin
+        APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link);	\
+        APR_BRIGADE_CHECK_CONSISTENCY((a));				\
+    end while (0);}
+
+{
+ * Prepend brigade b onto the beginning of brigade a, leaving brigade b empty
+ * @param a The first brigade
+ * @param b The second brigade
+ }
+{#define APR_BRIGADE_PREPEND(a, b) do begin
+        APR_RING_PREPEND(&(a)->list, &(b)->list, apr_bucket, link);	\
+        APR_BRIGADE_CHECK_CONSISTENCY((a));				\
+    end while (0)}
+
+{
+ * Insert a list of buckets before a specified bucket
+ * @param a The bucket to insert before
+ * @param b The buckets to insert
+ }
+{#define APR_BUCKET_INSERT_BEFORE(a, b) do begin
+	apr_bucket *ap__a = (a), *ap__b = (b);				\
+	APR_RING_INSERT_BEFORE(ap__a, ap__b, link);			\
+        APR_BUCKET_CHECK_CONSISTENCY(ap__a);				\
+    end while (0)}
+
+{
+ * Insert a list of buckets after a specified bucket
+ * @param a The bucket to insert after
+ * @param b The buckets to insert
+ }
+{#define APR_BUCKET_INSERT_AFTER(a, b) do begin
+	apr_bucket *ap__a = (a), *ap__b = (b);				\
+	APR_RING_INSERT_AFTER(ap__a, ap__b, link);			\
+        APR_BUCKET_CHECK_CONSISTENCY(ap__a);				\
+    end while (0)}
+
+{
+ * Get the next bucket in the list
+ * @param e The current bucket
+ * @return The next bucket
+ }
+//#define APR_BUCKET_NEXT(e)	APR_RING_NEXT((e), link)
+{
+ * Get the previous bucket in the list
+ * @param e The current bucket
+ * @return The previous bucket
+ }
+//#define APR_BUCKET_PREV(e)	APR_RING_PREV((e), link)
+
+{
+ * Remove a bucket from its bucket brigade
+ * @param e The bucket to remove
+ }
+//#define APR_BUCKET_REMOVE(e)	APR_RING_REMOVE((e), link)
+
+{
+ * Initialize a new bucket's prev/next pointers
+ * @param e The bucket to initialize
+ }
+//#define APR_BUCKET_INIT(e)	APR_RING_ELEM_INIT((e), link)
+
+{
+ * Determine if a bucket contains metadata.  An empty bucket is
+ * safe to arbitrarily remove if and only if this is false.
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_METADATA(e)    ((e)->type->is_metadata)
+
+{
+ * Determine if a bucket is a FLUSH bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_FLUSH(e)       ((e)->type == &apr_bucket_type_flush)
+{
+ * Determine if a bucket is an EOS bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_EOS(e)         ((e)->type == &apr_bucket_type_eos)
+{
+ * Determine if a bucket is a FILE bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_FILE(e)        ((e)->type == &apr_bucket_type_file)
+{
+ * Determine if a bucket is a PIPE bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_PIPE(e)        ((e)->type == &apr_bucket_type_pipe)
+{
+ * Determine if a bucket is a SOCKET bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_SOCKET(e)      ((e)->type == &apr_bucket_type_socket)
+{
+ * Determine if a bucket is a HEAP bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_HEAP(e)        ((e)->type == &apr_bucket_type_heap)
+{
+ * Determine if a bucket is a TRANSIENT bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_TRANSIENT(e)   ((e)->type == &apr_bucket_type_transient)
+{
+ * Determine if a bucket is a IMMORTAL bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_IMMORTAL(e)    ((e)->type == &apr_bucket_type_immortal)
+//#if APR_HAS_MMAP
+{
+ * Determine if a bucket is a MMAP bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_MMAP(e)        ((e)->type == &apr_bucket_type_mmap)
+//#endif
+{
+ * Determine if a bucket is a POOL bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_POOL(e)        ((e)->type == &apr_bucket_type_pool)
+
+{
+ * General-purpose reference counting for the various bucket types.
+ *
+ * Any bucket type that keeps track of the resources it uses (i.e.
+ * most of them except for IMMORTAL, TRANSIENT, and EOS) needs to
+ * attach a reference count to the resource so that it can be freed
+ * when the last bucket that uses it goes away. Resource-sharing may
+ * occur because of bucket splits or buckets that refer to globally
+ * cached data. }
+
+{ @see apr_bucket_refcount }
+  Papr_bucket_refcount = ^apr_bucket_refcount;
+{
+ * The structure used to manage the shared resource must start with an
+ * apr_bucket_refcount which is updated by the general-purpose refcount
+ * code. A pointer to the bucket-type-dependent private data structure
+ * can be cast to a pointer to an apr_bucket_refcount and vice versa.
+ }
+  apr_bucket_refcount = record
+    { The number of references to this bucket }
+    refcount: Integer;
+  end;
+
+{  *****  Reference-counted bucket types  *****  }
+
+{ @see apr_bucket_heap }
+  Papr_bucket_heap = ^apr_bucket_heap;
+{
+ * A bucket referring to data allocated off the heap.
+ }
+  free_func_t = procedure (data: Pointer);
+
+  apr_bucket_heap = record
+    { Number of buckets using this memory }
+    refcount: apr_bucket_refcount;
+    { The start of the data actually allocated.  This should never be
+     * modified, it is only used to free the bucket.
+     }
+    base: PChar;
+    { how much memory was allocated }
+    alloc_len: apr_size_t;
+    { function to use to delete the data }
+    free_func: free_func_t;
+  end;
+
+{ @see apr_bucket_pool }
+  Papr_bucket_pool = ^apr_bucket_pool;
+{
+ * A bucket referring to data allocated from a pool
+ }
+  apr_bucket_pool = record
+    { The pool bucket must be able to be easily morphed to a heap
+     * bucket if the pool gets cleaned up before all references are
+     * destroyed.  This apr_bucket_heap structure is populated automatically
+     * when the pool gets cleaned up, and subsequent calls to pool_read()
+     * will result in the apr_bucket in question being morphed into a
+     * regular heap bucket.  (To avoid having to do many extra refcount
+     * manipulations and b->data manipulations, the apr_bucket_pool
+     * struct actually *contains* the apr_bucket_heap struct that it
+     * will become as its first element; the two share their
+     * apr_bucket_refcount members.)
+     }
+    heap: apr_bucket_heap;
+    { The block of data actually allocated from the pool.
+     * Segments of this block are referenced by adjusting
+     * the start and length of the apr_bucket accordingly.
+     * This will be NULL after the pool gets cleaned up.
+     }
+    base: PChar;
+    { The pool the data was allocated from.  When the pool
+     * is cleaned up, this gets set to NULL as an indicator
+     * to pool_read() that the data is now on the heap and
+     * so it should morph the bucket into a regular heap
+     * bucket before continuing.
+     }
+    pool: Papr_pool_t;
+    { The freelist this structure was allocated from, which is
+     * needed in the cleanup phase in order to allocate space on the heap
+     }
+    list: Papr_bucket_alloc_t;
+  end;
+
+{$ifdef APR_HAS_MMAP}
+{ @see apr_bucket_mmap }
+  Papr_bucket_mmap = ^apr_bucket_mmap;
+{
+ * A bucket referring to an mmap()ed file
+ }
+  apr_bucket_mmap = record
+    { Number of buckets using this memory }
+    refcount: apr_bucket_refcount;
+    { The mmap this sub_bucket refers to }
+    mmap: Papr_mmap_t;
+  end;
+{$endif}
+
+{ @see apr_bucket_file }
+  Papr_bucket_file = ^apr_bucket_file;
+{
+ * A bucket referring to an file
+ }
+  apr_bucket_file = record
+    { Number of buckets using this memory }
+    refcount: apr_bucket_refcount;
+    { The file this bucket refers to }
+    fd: Papr_file_t;
+    { The pool into which any needed structures should
+     *  be created while reading from this file bucket }
+    readpool: Papr_pool_t;
+{$ifdef APR_HAS_MMAP}
+    { Whether this bucket should be memory-mapped if
+     *  a caller tries to read from it }
+    can_mmap: Integer;
+{$endif} { APR_HAS_MMAP }
+  end;
+
+{ @see apr_bucket_structs }
+  Papr_bucket_structs = ^apr_bucket_structs;
+{
+ * A union of all bucket structures so we know what
+ * the max size is.
+ }
+  apr_bucket_structs = record
+    case Integer of
+     0: (b: apr_bucket);      {< Bucket }
+     1: (heap: apr_bucket_heap);   {< Heap }
+     2: (pool: apr_bucket_pool);   {< Pool }
+{$ifdef APR_HAS_MMAP}
+     3: (mmap: apr_bucket_mmap);   {< MMap }
+{$endif}
+     4: (file_: apr_bucket_file);   {< File }
+  end;
+
+{
+ * The amount that apr_bucket_alloc() should allocate in the common case.
+ * Note: this is twice as big as apr_bucket_structs to allow breathing
+ * room for third-party bucket types.
+ }
+//#define APR_BUCKET_ALLOC_SIZE  APR_ALIGN_DEFAULT(2*sizeof(apr_bucket_structs))
+
+{  *****  Bucket Brigade Functions  *****  }
+{
+ * Create a new bucket brigade.  The bucket brigade is originally empty.
+ * @param p The pool to associate with the brigade.  Data is not allocated out
+ *          of the pool, but a cleanup is registered.
+ * @param list The bucket allocator to use
+ * @return The empty bucket brigade
+ }
+//APU_DECLARE(apr_bucket_brigade *) apr_brigade_create(apr_pool_t *p,
+//                                                     apr_bucket_alloc_t *list);
+
+{
+ * destroy an entire bucket brigade.  This includes destroying all of the
+ * buckets within the bucket brigade's bucket list. 
+ * @param b The bucket brigade to destroy
+ }
+//APU_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b);
+
+{
+ * empty out an entire bucket brigade.  This includes destroying all of the
+ * buckets within the bucket brigade's bucket list.  This is similar to
+ * apr_brigade_destroy(), except that it does not deregister the brigade's
+ * pool cleanup function.
+ * @param data The bucket brigade to clean up
+ * @remark Generally, you should use apr_brigade_destroy().  This function
+ *         can be useful in situations where you have a single brigade that
+ *         you wish to reuse many times by destroying all of the buckets in
+ *         the brigade and putting new buckets into it later.
+ }
+//APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data);
+
+{
+ * Split a bucket brigade into two, such that the given bucket is the
+ * first in the new bucket brigade. This function is useful when a
+ * filter wants to pass only the initial part of a brigade to the next
+ * filter.
+ * @param b The brigade to split
+ * @param e The first element of the new brigade
+ * @return The new brigade
+ }
+//APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b,
+//                                                    apr_bucket *e);
+
+{
+ * Partition a bucket brigade at a given offset (in bytes from the start of
+ * the brigade).  This is useful whenever a filter wants to use known ranges
+ * of bytes from the brigade; the ranges can even overlap.
+ * @param b The brigade to partition
+ * @param point The offset at which to partition the brigade
+ * @param after_point Returns a pointer to the first bucket after the partition
+ }
+//APU_DECLARE(apr_status_t) apr_brigade_partition(apr_bucket_brigade *b,
+//                                                apr_off_t point,
+//                                                apr_bucket **after_point);
+
+//#if APR_NOT_DONE_YET
+{
+ * consume nbytes from beginning of b -- call apr_bucket_destroy as
+ * appropriate, and/or modify start on last element 
+ * @param b The brigade to consume data from
+ * @param nbytes The number of bytes to consume
+ }
+//APU_DECLARE(void) apr_brigade_consume(apr_bucket_brigade *b,
+//                                      apr_off_t nbytes);
+//#endif
+
+{
+ * Return the total length of the brigade.
+ * @param bb The brigade to compute the length of
+ * @param read_all Read unknown-length buckets to force a size
+ * @param length Returns the length of the brigade, or -1 if the brigade has
+ *               buckets of indeterminate length and read_all is 0.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb,
+                                             int read_all,
+                                             apr_off_t *length);
+}
+{
+ * Take a bucket brigade and store the data in a flat char*
+ * @param bb The bucket brigade to create the char* from
+ * @param c The char* to write into
+ * @param len The maximum length of the char array. On return, it is the
+ *            actual length of the char array.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_flatten(apr_bucket_brigade *bb,
+                                              char *c,
+                                              apr_size_t *len);
+}
+{
+ * Creates a pool-allocated string representing a flat bucket brigade
+ * @param bb The bucket brigade to create the char array from
+ * @param c On return, the allocated char array
+ * @param len On return, the length of the char array.
+ * @param pool The pool to allocate the string from.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_pflatten(apr_bucket_brigade *bb,
+                                               char **c,
+                                               apr_size_t *len,
+                                               apr_pool_t *pool);
+}
+{
+ * Split a brigade to represent one LF line.
+ * @param bbOut The bucket brigade that will have the LF line appended to.
+ * @param bbIn The input bucket brigade to search for a LF-line.
+ * @param block The blocking mode to be used to split the line.
+ * @param maxbytes The maximum bytes to read.  If this many bytes are seen
+ *                 without a LF, the brigade will contain a partial line.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_split_line(apr_bucket_brigade *bbOut,
+                                                 apr_bucket_brigade *bbIn,
+                                                 apr_read_type_e block,
+                                                 apr_off_t maxbytes);
+}
+{
+ * create an iovec of the elements in a bucket_brigade... return number 
+ * of elements used.  This is useful for writing to a file or to the
+ * network efficiently.
+ * @param b The bucket brigade to create the iovec from
+ * @param vec The iovec to create
+ * @param nvec The number of elements in the iovec. On return, it is the
+ *             number of iovec elements actually filled out.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_to_iovec(apr_bucket_brigade *b,
+                                               struct iovec *vec, int *nvec);
+}
+{
+ * This function writes a list of strings into a bucket brigade. 
+ * @param b The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param va A list of strings to add
+ * @return APR_SUCCESS or error code.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_vputstrs(apr_bucket_brigade *b,
+                                               apr_brigade_flush flush,
+                                               void *ctx,
+                                               va_list va);
+}
+{
+ * This function writes a string into a bucket brigade.
+ * @param b The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param str The string to add
+ * @param nbyte The number of bytes to write
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_write(apr_bucket_brigade *b,
+                                            apr_brigade_flush flush, void *ctx,
+                                            const char *str, apr_size_t nbyte);
+}
+{
+ * This function writes multiple strings into a bucket brigade.
+ * @param b The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param vec The strings to add (address plus length for each)
+ * @param nvec The number of entries in iovec
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_writev(apr_bucket_brigade *b,
+                                             apr_brigade_flush flush,
+                                             void *ctx,
+                                             const struct iovec *vec,
+                                             apr_size_t nvec);
+}
+{
+ * This function writes a string into a bucket brigade.
+ * @param bb The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param str The string to add
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_puts(apr_bucket_brigade *bb,
+                                           apr_brigade_flush flush, void *ctx,
+                                           const char *str);
+}
+{
+ * This function writes a character into a bucket brigade.
+ * @param b The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param c The character to add
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_putc(apr_bucket_brigade *b,
+                                           apr_brigade_flush flush, void *ctx,
+                                           const char c);
+}
+{
+ * This function writes an unspecified number of strings into a bucket brigade.
+ * @param b The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param ... The strings to add
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b,
+                                                     apr_brigade_flush flush,
+                                                     void *ctx, ...);
+}
+{
+ * Evaluate a printf and put the resulting string at the end 
+ * of the bucket brigade.
+ * @param b The brigade to write to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param fmt The format of the string to write
+ * @param ... The arguments to fill out the format
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_brigade_printf(apr_bucket_brigade *b,
+                                                    apr_brigade_flush flush,
+                                                    void *ctx,
+                                                    const char *fmt, ...)
+        __attribute__((format(printf,4,5)));
+}
+{
+ * Evaluate a printf and put the resulting string at the end 
+ * of the bucket brigade.
+ * @param b The brigade to write to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param fmt The format of the string to write
+ * @param va The arguments to fill out the format
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_vprintf(apr_bucket_brigade *b,
+                                              apr_brigade_flush flush,
+                                              void *ctx,
+                                              const char *fmt, va_list va);
+}
+{  *****  Bucket freelist functions *****  }
+{
+ * Create a bucket allocator.
+ * @param p This pool's underlying apr_allocator_t is used to allocate memory
+ *          for the bucket allocator.  When the pool is destroyed, the bucket
+ *          allocator's cleanup routine will free all memory that has been
+ *          allocated from it.
+ * @remark  The reason the allocator gets its memory from the pool's
+ *          apr_allocator_t rather than from the pool itself is because
+ *          the bucket allocator will free large memory blocks back to the
+ *          allocator when it's done with them, thereby preventing memory
+ *          footprint growth that would occur if we allocated from the pool.
+ * @warning The allocator must never be used by more than one thread at a time.
+ }
+//APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create(apr_pool_t *p);
+
+{
+ * Create a bucket allocator.
+ * @param allocator This apr_allocator_t is used to allocate both the bucket
+ *          allocator and all memory handed out by the bucket allocator.  The
+ *          caller is responsible for destroying the bucket allocator and the
+ *          apr_allocator_t -- no automatic cleanups will happen.
+ * @warning The allocator must never be used by more than one thread at a time.
+ }
+//APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create_ex(apr_allocator_t *allocator);
+
+{
+ * Destroy a bucket allocator.
+ * @param list The allocator to be destroyed
+ }
+//APU_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list);
+
+{
+ * Allocate memory for use by the buckets.
+ * @param size The amount to allocate.
+ * @param list The allocator from which to allocate the memory.
+ }
+//APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size, apr_bucket_alloc_t *list);
+
+{
+ * Free memory previously allocated with apr_bucket_alloc().
+ * @param block The block of memory to be freed.
+ }
+//APU_DECLARE_NONSTD(void) apr_bucket_free(void *block);
+
+
+{  *****  Bucket Functions  *****  }
+{
+ * Free the resources used by a bucket. If multiple buckets refer to
+ * the same resource it is freed when the last one goes away.
+ * @see apr_bucket_delete()
+ * @param e The bucket to destroy
+ }
+{#define apr_bucket_destroy(e) do begin
+        (e)->type->destroy((e)->data);					\
+        (e)->free(e);							\
+    end while (0)}
+
+{
+ * Delete a bucket by removing it from its brigade (if any) and then
+ * destroying it.
+ * @remark This mainly acts as an aid in avoiding code verbosity.  It is
+ * the preferred exact equivalent to:
+ * <pre>
+ *      APR_BUCKET_REMOVE(e);
+ *      apr_bucket_destroy(e);
+ * </pre>
+ * @param e The bucket to delete
+ }
+{#define apr_bucket_delete(e) do begin
+        APR_BUCKET_REMOVE(e);						\
+        apr_bucket_destroy(e);						\
+    end while (0)}
+
+{
+ * read the data from the bucket
+ * @param e The bucket to read from
+ * @param str The location to store the data in
+ * @param len The amount of data read
+ * @param block Whether the read function blocks
+ }
+//#define apr_bucket_read(e,str,len,block) (e)->type->read(e, str, len, block)
+
+{
+ * Setaside data so that stack data is not destroyed on returning from
+ * the function
+ * @param e The bucket to setaside
+ * @param p The pool to setaside into
+ }
+//#define apr_bucket_setaside(e,p) (e)->type->setaside(e,p)
+
+{
+ * Split one bucket in two.
+ * @param e The bucket to split
+ * @param point The offset to split the bucket at
+ }
+//#define apr_bucket_split(e,point) (e)->type->split(e, point)
+
+{
+ * Copy a bucket.
+ * @param e The bucket to copy
+ * @param c Returns a pointer to the new bucket
+ }
+//#define apr_bucket_copy(e,c) (e)->type->copy(e, c)
+
+{ Bucket type handling }
+
+{
+ * This function simply returns APR_SUCCESS to denote that the bucket does
+ * not require anything to happen for its setaside() function. This is
+ * appropriate for buckets that have "immortal" data -- the data will live
+ * at least as long as the bucket.
+ * @param data The bucket to setaside
+ * @param pool The pool defining the desired lifetime of the bucket data
+ * @return APR_SUCCESS
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_noop(apr_bucket *data,
+                                                          apr_pool_t *pool);
+}
+{
+ * A place holder function that signifies that the setaside function was not
+ * implemented for this bucket
+ * @param data The bucket to setaside
+ * @param pool The pool defining the desired lifetime of the bucket data
+ * @return APR_ENOTIMPL
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_notimpl(apr_bucket *data,
+                                                             apr_pool_t *pool);
+}
+{
+ * A place holder function that signifies that the split function was not
+ * implemented for this bucket
+ * @param data The bucket to split
+ * @param point The location to split the bucket
+ * @return APR_ENOTIMPL
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_split_notimpl(apr_bucket *data,
+                                                          apr_size_t point);
+}
+{
+ * A place holder function that signifies that the copy function was not
+ * implemented for this bucket
+ * @param e The bucket to copy
+ * @param c Returns a pointer to the new bucket
+ * @return APR_ENOTIMPL
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_copy_notimpl(apr_bucket *e,
+                                                         apr_bucket **c);
+}
+{
+ * A place holder function that signifies that this bucket does not need
+ * to do anything special to be destroyed.  That's only the case for buckets
+ * that either have no data (metadata buckets) or buckets whose data pointer
+ * points to something that's not a bucket-type-specific structure, as with
+ * simple buckets where data points to a string and pipe buckets where data
+ * points directly to the apr_file_t.
+ * @param data The bucket data to destroy
+ }
+//APU_DECLARE_NONSTD(void) apr_bucket_destroy_noop(void *data);
+
+{
+ * There is no apr_bucket_destroy_notimpl, because destruction is required
+ * to be implemented (it could be a noop, but only if that makes sense for
+ * the bucket type)
+ }
+
+{ There is no apr_bucket_read_notimpl, because it is a required function
+ }
+
+
+{ All of the bucket types implemented by the core }
+{
+ * The flush bucket type.  This signifies that all data should be flushed to
+ * the next filter.  The flush bucket should be sent with the other buckets.
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_flush;
+{
+ * The EOS bucket type.  This signifies that there will be no more data, ever.
+ * All filters MUST send all data to the next filter when they receive a
+ * bucket of this type
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_eos;
+{
+ * The FILE bucket type.  This bucket represents a file on disk
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_file;
+{
+ * The HEAP bucket type.  This bucket represents a data allocated from the
+ * heap.
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_heap;
+//#if APR_HAS_MMAP
+{
+ * The MMAP bucket type.  This bucket represents an MMAP'ed file
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_mmap;
+//#endif
+{
+ * The POOL bucket type.  This bucket represents a data that was allocated
+ * from a pool.  IF this bucket is still available when the pool is cleared,
+ * the data is copied on to the heap.
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pool;
+{
+ * The PIPE bucket type.  This bucket represents a pipe to another program.
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pipe;
+{
+ * The IMMORTAL bucket type.  This bucket represents a segment of data that
+ * the creator is willing to take responsibility for.  The core will do
+ * nothing with the data in an immortal bucket
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_immortal;
+{
+ * The TRANSIENT bucket type.  This bucket represents a data allocated off
+ * the stack.  When the setaside function is called, this data is copied on
+ * to the heap
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_transient;
+{
+ * The SOCKET bucket type.  This bucket represents a socket to another machine
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_socket;
+
+
+{  *****  Simple buckets  *****  }
+
+{
+ * Split a simple bucket into two at the given point.  Most non-reference
+ * counting buckets that allow multiple references to the same block of
+ * data (eg transient and immortal) will use this as their split function
+ * without any additional type-specific handling.
+ * @param b The bucket to be split
+ * @param point The offset of the first byte in the new bucket
+ * @return APR_EINVAL if the point is not within the bucket;
+ *         APR_ENOMEM if allocation failed;
+ *         or APR_SUCCESS
+ }
+//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_split(apr_bucket *b,
+//                                                         apr_size_t point);
+
+{
+ * Copy a simple bucket.  Most non-reference-counting buckets that allow
+ * multiple references to the same block of data (eg transient and immortal)
+ * will use this as their copy function without any additional type-specific
+ * handling.
+ * @param a The bucket to copy
+ * @param b Returns a pointer to the new bucket
+ * @return APR_ENOMEM if allocation failed;
+ *         or APR_SUCCESS
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_copy(apr_bucket *a,
+                                                        apr_bucket **b);
+
+}
+{  *****  Shared, reference-counted buckets  *****  }
+
+{
+ * Initialize a bucket containing reference-counted data that may be
+ * shared. The caller must allocate the bucket if necessary and
+ * initialize its type-dependent fields, and allocate and initialize
+ * its own private data structure. This function should only be called
+ * by type-specific bucket creation functions.
+ * @param b The bucket to initialize
+ * @param data A pointer to the private data structure
+ *             with the reference count at the start
+ * @param start The start of the data in the bucket
+ *              relative to the private base pointer
+ * @param length The length of the data in the bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data,
+				                 apr_off_t start, 
+                                                 apr_size_t length);
+}
+{
+ * Decrement the refcount of the data in the bucket. This function
+ * should only be called by type-specific bucket destruction functions.
+ * @param data The private data pointer from the bucket to be destroyed
+ * @return TRUE or FALSE; TRUE if the reference count is now
+ *         zero, indicating that the shared resource itself can
+ *         be destroyed by the caller.
+ }
+//APU_DECLARE(int) apr_bucket_shared_destroy(void *data);
+
+{
+ * Split a bucket into two at the given point, and adjust the refcount
+ * to the underlying data. Most reference-counting bucket types will
+ * be able to use this function as their split function without any
+ * additional type-specific handling.
+ * @param b The bucket to be split
+ * @param point The offset of the first byte in the new bucket
+ * @return APR_EINVAL if the point is not within the bucket;
+ *         APR_ENOMEM if allocation failed;
+ *         or APR_SUCCESS
+ }
+//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *b,
+//                                                         apr_size_t point);
+
+{
+ * Copy a refcounted bucket, incrementing the reference count. Most
+ * reference-counting bucket types will be able to use this function
+ * as their copy function without any additional type-specific handling.
+ * @param a The bucket to copy
+ * @param b Returns a pointer to the new bucket
+ * @return APR_ENOMEM if allocation failed;
+           or APR_SUCCESS
+ }
+//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_copy(apr_bucket *a,
+//                                                        apr_bucket **b);
+
+
+{  *****  Functions to Create Buckets of varying types  *****  }
+{
+ * Each bucket type foo has two initialization functions:
+ * apr_bucket_foo_make which sets up some already-allocated memory as a
+ * bucket of type foo; and apr_bucket_foo_create which allocates memory
+ * for the bucket, calls apr_bucket_make_foo, and initializes the
+ * bucket's list pointers. The apr_bucket_foo_make functions are used
+ * inside the bucket code to change the type of buckets in place;
+ * other code should call apr_bucket_foo_create. All the initialization
+ * functions change nothing if they fail.
+ }
+
+{
+ * Create an End of Stream bucket.  This indicates that there is no more data
+ * coming from down the filter stack.  All filters should flush at this point.
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+//APU_DECLARE(apr_bucket *) apr_bucket_eos_create(apr_bucket_alloc_t *list);
+
+{
+ * Make the bucket passed in an EOS bucket.  This indicates that there is no 
+ * more data coming from down the filter stack.  All filters should flush at 
+ * this point.
+ * @param b The bucket to make into an EOS bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+//APU_DECLARE(apr_bucket *) apr_bucket_eos_make(apr_bucket *b);
+
+{
+ * Create a flush  bucket.  This indicates that filters should flush their
+ * data.  There is no guarantee that they will flush it, but this is the
+ * best we can do.
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+//APU_DECLARE(apr_bucket *) apr_bucket_flush_create(apr_bucket_alloc_t *list);
+
+{
+ * Make the bucket passed in a FLUSH  bucket.  This indicates that filters 
+ * should flush their data.  There is no guarantee that they will flush it, 
+ * but this is the best we can do.
+ * @param b The bucket to make into a FLUSH bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+//APU_DECLARE(apr_bucket *) apr_bucket_flush_make(apr_bucket *b);
+
+{
+ * Create a bucket referring to long-lived data.
+ * @param buf The data to insert into the bucket
+ * @param nbyte The size of the data to insert.
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_immortal_create(const char *buf,
+                                                     apr_size_t nbyte,
+                                                     apr_bucket_alloc_t *list);
+}
+{
+ * Make the bucket passed in a bucket refer to long-lived data
+ * @param b The bucket to make into a IMMORTAL bucket
+ * @param buf The data to insert into the bucket
+ * @param nbyte The size of the data to insert.
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_immortal_make(apr_bucket *b,
+                                                   const char *buf, 
+                                                   apr_size_t nbyte);
+}
+{
+ * Create a bucket referring to data on the stack.
+ * @param buf The data to insert into the bucket
+ * @param nbyte The size of the data to insert.
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_transient_create(const char *buf,
+                                                      apr_size_t nbyte,
+                                                      apr_bucket_alloc_t *list);
+}
+{
+ * Make the bucket passed in a bucket refer to stack data
+ * @param b The bucket to make into a TRANSIENT bucket
+ * @param buf The data to insert into the bucket
+ * @param nbyte The size of the data to insert.
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_transient_make(apr_bucket *b,
+                                                    const char *buf,
+                                                    apr_size_t nbyte);
+}
+{
+ * Create a bucket referring to memory on the heap. If the caller asks
+ * for the data to be copied, this function always allocates 4K of
+ * memory so that more data can be added to the bucket without
+ * requiring another allocation. Therefore not all the data may be put
+ * into the bucket. If copying is not requested then the bucket takes
+ * over responsibility for free()ing the memory.
+ * @param buf The buffer to insert into the bucket
+ * @param nbyte The size of the buffer to insert.
+ * @param free_func Function to use to free the data; NULL indicates that the
+ *                  bucket should make a copy of the data
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_heap_create(const char *buf,
+                                                 apr_size_t nbyte,
+                                                 void ( *free_func)(void *data),
+                                                 apr_bucket_alloc_t *list);}
+{
+ * Make the bucket passed in a bucket refer to heap data
+ * @param b The bucket to make into a HEAP bucket
+ * @param buf The buffer to insert into the bucket
+ * @param nbyte The size of the buffer to insert.
+ * @param free_func Function to use to free the data; NULL indicates that the
+ *                  bucket should make a copy of the data
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_heap_make(apr_bucket *b, const char *buf,
+                                               apr_size_t nbyte,
+                                               void ( *free_func)(void *data));}
+
+{
+ * Create a bucket referring to memory allocated from a pool.
+ *
+ * @param buf The buffer to insert into the bucket
+ * @param length The number of bytes referred to by this bucket
+ * @param pool The pool the memory was allocated from
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_pool_create(const char *buf,
+                                                 apr_size_t length,
+                                                 apr_pool_t *pool,
+                                                 apr_bucket_alloc_t *list);}
+
+{
+ * Make the bucket passed in a bucket refer to pool data
+ * @param b The bucket to make into a pool bucket
+ * @param buf The buffer to insert into the bucket
+ * @param length The number of bytes referred to by this bucket
+ * @param pool The pool the memory was allocated from
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_pool_make(apr_bucket *b, const char *buf,
+                                               apr_size_t length, 
+                                               apr_pool_t *pool);}
+
+//#if APR_HAS_MMAP
+{
+ * Create a bucket referring to mmap()ed memory.
+ * @param mm The mmap to insert into the bucket
+ * @param start The offset of the first byte in the mmap
+ *              that this bucket refers to
+ * @param length The number of bytes referred to by this bucket
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_mmap_create(apr_mmap_t *mm,
+                                                 apr_off_t start,
+                                                 apr_size_t length,
+                                                 apr_bucket_alloc_t *list);
+}
+{
+ * Make the bucket passed in a bucket refer to an MMAP'ed file
+ * @param b The bucket to make into a MMAP bucket
+ * @param mm The mmap to insert into the bucket
+ * @param start The offset of the first byte in the mmap
+ *              that this bucket refers to
+ * @param length The number of bytes referred to by this bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_mmap_make(apr_bucket *b, apr_mmap_t *mm,
+                                               apr_off_t start, 
+                                               apr_size_t length);
+#endif}
+
+{
+ * Create a bucket referring to a socket.
+ * @param thissock The socket to put in the bucket
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *thissock,
+                                                   apr_bucket_alloc_t *list);}
+{
+ * Make the bucket passed in a bucket refer to a socket
+ * @param b The bucket to make into a SOCKET bucket
+ * @param thissock The socket to put in the bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_socket_make(apr_bucket *b,
+                                                 apr_socket_t *thissock);}
+
+{
+ * Create a bucket referring to a pipe.
+ * @param thispipe The pipe to put in the bucket
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_pipe_create(apr_file_t *thispipe,
+                                                 apr_bucket_alloc_t *list);}
+
+{
+ * Make the bucket passed in a bucket refer to a pipe
+ * @param b The bucket to make into a PIPE bucket
+ * @param thispipe The pipe to put in the bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_pipe_make(apr_bucket *b,
+                                               apr_file_t *thispipe);}
+
+{
+ * Create a bucket referring to a file.
+ * @param fd The file to put in the bucket
+ * @param offset The offset where the data of interest begins in the file
+ * @param len The amount of data in the file we are interested in
+ * @param p The pool into which any needed structures should be created
+ *          while reading from this file bucket
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd,
+                                                 apr_off_t offset,
+                                                 apr_size_t len, 
+                                                 apr_pool_t *p,
+                                                 apr_bucket_alloc_t *list);
+}
+{
+ * Make the bucket passed in a bucket refer to a file
+ * @param b The bucket to make into a FILE bucket
+ * @param fd The file to put in the bucket
+ * @param offset The offset where the data of interest begins in the file
+ * @param len The amount of data in the file we are interested in
+ * @param p The pool into which any needed structures should be created
+ *          while reading from this file bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_file_make(apr_bucket *b, apr_file_t *fd,
+                                               apr_off_t offset,
+                                               apr_size_t len, apr_pool_t *p);
+}
+{
+ * Enable or disable memory-mapping for a FILE bucket (default is enabled)
+ * @param b The bucket
+ * @param enabled Whether memory-mapping should be enabled
+ * @return APR_SUCCESS normally, or an error code if the operation fails
+ }
+{APU_DECLARE(apr_status_t) apr_bucket_file_enable_mmap(apr_bucket *b,
+                                                      int enabled);}
+

+ 95 - 0
packages/base/httpd/httpd-2.0/apr/apr_dso.inc

@@ -0,0 +1,95 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_dso.h
+ * @brief APR Dynamic Object Handling Routines
+ }
+
+{#include "apr.h"
+#include "apr_pools.h"
+#include "apr_errno.h"}
+
+{
+ * @defgroup apr_dso Dynamic Object Handling
+ * @ingroup APR 
+ }
+
+{$define APR_HAS_DSO}
+
+{$if defined(APR_HAS_DSO) or defined(DOXYGEN)}
+
+{
+ * Structure for referencing dynamic objects
+ }
+type
+  apr_dso_handle_t  = record
+  end;
+  Papr_dso_handle_t = ^apr_dso_handle_t;
+  PPapr_dso_handle_t = ^Papr_dso_handle_t;
+
+{
+ * Structure for referencing symbols from dynamic objects
+ }
+  apr_dso_handle_sym_t = Pointer;
+  Papr_dso_handle_sym_t = ^apr_dso_handle_sym_t;
+  PPapr_dso_handle_sym_t = ^Papr_dso_handle_sym_t;
+
+{
+ * Load a DSO library.
+ * @param res_handle Location to store new handle for the DSO.
+ * @param path Path to the DSO library
+ * @param ctx Pool to use.
+ * @bug We aught to provide an alternative to RTLD_GLOBAL, which
+ * is the only supported method of loading DSOs today.
+ }
+function apr_dso_load(res_handle: PPapr_dso_handle_t; const path: PChar;
+ ctx: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dso_load' + LibSuff12;
+
+{
+ * Close a DSO library.
+ * @param handle handle to close.
+ }
+function apr_dso_unload(handle: Papr_dso_handle_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dso_unload' + LibSuff4;
+
+{
+ * Load a symbol from a DSO handle.
+ * @param ressym Location to store the loaded symbol
+ * @param handle handle to load the symbol from.
+ * @param symname Name of the symbol to load.
+ }
+function apr_dso_sym(ressym: Papr_dso_handle_t; handle: Papr_dso_handle_t;
+ const symname: PChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dso_sym' + LibSuff12;
+
+{
+ * Report more information when a DSO function fails.
+ * @param dso The dso handle that has been opened
+ * @param buf Location to store the dso error
+ * @param bufsize The size of the provided buffer
+ }
+function apr_dso_error(dso: Papr_dso_handle_t; buf: PChar;
+ bufsize: apr_size_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dso_error' + LibSuff12;
+
+{$endif}
+

+ 1191 - 0
packages/base/httpd/httpd-2.0/apr/apr_errno.inc

@@ -0,0 +1,1191 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_errno.h
+ * @brief APR Error Codes
+ }
+
+{#include "apr.h"
+
+#if APR_HAVE_ERRNO_H
+#include <errno.h>
+#endif}
+
+{
+ * @defgroup apr_errno Error Codes
+ * @ingroup APR 
+ }
+
+{
+ * Type for specifying an error or status code.
+ }
+type
+  apr_status_t = Integer;
+  Papr_status_t = ^apr_status_t;
+
+{
+ * Return a human readable string describing the specified error.
+ * @param statcode The error code the get a string for.
+ * @param buf A buffer to hold the error string.
+ * @param bufsize Size of the buffer to hold the string.
+ }
+function apr_strerror(statcode: apr_status_t; buf: PChar; bufsize: apr_size_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_strerror' + LibSuff12;
+
+{$ifdef DOXYGEN)}
+{
+ * @def APR_FROM_OS_ERROR(os_err_type syserr)
+ * Fold a platform specific error into an apr_status_t code.
+ * @return apr_status_t
+ * @param e The platform os error code.
+ * @warning  macro implementation; the syserr argument may be evaluated
+ *      multiple times.
+ }
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+
+{
+ * @def APR_TO_OS_ERROR(apr_status_t statcode)
+ * @return os_err_type
+ * Fold an apr_status_t code back to the native platform defined error.
+ * @param e The apr_status_t folded platform os error code.
+ * @warning  macro implementation; the statcode argument may be evaluated
+ *      multiple times.  If the statcode was not created by apr_get_os_error 
+ *      or APR_FROM_OS_ERROR, the results are undefined.
+ }
+#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+{ @def apr_get_os_error()
+ * @return apr_status_t the last platform error, folded into apr_status_t, on most platforms
+ * @remark This retrieves errno, or calls a GetLastError() style function, and
+ *      folds it with APR_FROM_OS_ERROR.  Some platforms (such as OS2) have no
+ *      such mechanism, so this call may be unsupported.  Do NOT use this
+ *      call for socket errors from socket, send, recv etc!
+ }
+
+{ @def apr_set_os_error(e)
+ * Reset the last platform error, unfolded from an apr_status_t, on some platforms
+ * @param e The OS error folded in a prior call to APR_FROM_OS_ERROR()
+ * @warning This is a macro implementation; the statcode argument may be evaluated
+ *      multiple times.  If the statcode was not created by apr_get_os_error
+ *      or APR_FROM_OS_ERROR, the results are undefined.  This macro sets
+ *      errno, or calls a SetLastError() style function, unfolding statcode
+ *      with APR_TO_OS_ERROR.  Some platforms (such as OS2) have no such
+ *      mechanism, so this call may be unsupported.
+ }
+
+{ @def apr_get_netos_error()
+ * Return the last socket error, folded into apr_status_t, on all platforms
+ * @remark This retrieves errno or calls a GetLastSocketError() style function,
+ *      and folds it with APR_FROM_OS_ERROR.
+ }
+
+{ @def apr_set_netos_error(e)
+ * Reset the last socket error, unfolded from an apr_status_t
+ * @param e The socket error folded in a prior call to APR_FROM_OS_ERROR()
+ * @warning This is a macro implementation; the statcode argument may be evaluated
+ *      multiple times.  If the statcode was not created by apr_get_os_error
+ *      or APR_FROM_OS_ERROR, the results are undefined.  This macro sets
+ *      errno, or calls a WSASetLastError() style function, unfolding 
+ *      socketcode with APR_TO_OS_ERROR.
+ }
+
+{$endif} { defined(DOXYGEN) }
+
+const
+{
+ * APR_OS_START_ERROR is where the APR specific error values start.
+ }
+  APR_OS_START_ERROR =    20000;
+{
+ * APR_OS_ERRSPACE_SIZE is the maximum number of errors you can fit
+ *    into one of the error/status ranges below -- except for
+ *    APR_OS_START_USERERR, which see.
+ }
+  APR_OS_ERRSPACE_SIZE = 50000;
+{
+ * APR_OS_START_STATUS is where the APR specific status codes start.
+ }
+  APR_OS_START_STATUS =   (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE);
+{
+ * APR_OS_START_USERERR are reserved for applications that use APR that
+ *     layer their own error codes along with APR's.  Note that the
+ *     error immediately following this one is set ten times farther
+ *     away than usual, so that users of apr have a lot of room in
+ *     which to declare custom error codes.
+ }
+  APR_OS_START_USERERR =   (APR_OS_START_STATUS + APR_OS_ERRSPACE_SIZE);
+{
+ * APR_OS_START_USEERR is obsolete, defined for compatibility only.
+ * Use APR_OS_START_USERERR instead.
+ }
+  APR_OS_START_USEERR =    APR_OS_START_USERERR;
+{
+ * APR_OS_START_CANONERR is where APR versions of errno values are defined
+ *     on systems which don't have the corresponding errno.
+ }
+  APR_OS_START_CANONERR = (APR_OS_START_USERERR + (APR_OS_ERRSPACE_SIZE * 10));
+{
+ * APR_OS_START_EAIERR folds EAI_ error codes from getaddrinfo() into 
+ *     apr_status_t values.
+ }
+  APR_OS_START_EAIERR =   (APR_OS_START_CANONERR + APR_OS_ERRSPACE_SIZE);
+{
+ * APR_OS_START_SYSERR folds platform-specific system error values into 
+ *     apr_status_t values.
+ }
+  APR_OS_START_SYSERR =   (APR_OS_START_EAIERR + APR_OS_ERRSPACE_SIZE);
+
+{ no error. @see APR_STATUS_IS_SUCCESS }
+  APR_SUCCESS = 0;
+
+{
+ * @defgroup APR_Error APR Error Values
+ * <PRE>
+ * <b>APR ERROR VALUES</b>
+ * APR_ENOSTAT      APR was unable to perform a stat on the file 
+ * APR_ENOPOOL      APR was not provided a pool with which to allocate memory
+ * APR_EBADDATE     APR was given an invalid date 
+ * APR_EINVALSOCK   APR was given an invalid socket
+ * APR_ENOPROC      APR was not given a process structure
+ * APR_ENOTIME      APR was not given a time structure
+ * APR_ENODIR       APR was not given a directory structure
+ * APR_ENOLOCK      APR was not given a lock structure
+ * APR_ENOPOLL      APR was not given a poll structure
+ * APR_ENOSOCKET    APR was not given a socket
+ * APR_ENOTHREAD    APR was not given a thread structure
+ * APR_ENOTHDKEY    APR was not given a thread key structure
+ * APR_ENOSHMAVAIL  There is no more shared memory available
+ * APR_EDSOOPEN     APR was unable to open the dso object.  For more 
+ *                  information call apr_dso_error().
+ * APR_EGENERAL     General failure (specific information not available)
+ * APR_EBADIP       The specified IP address is invalid
+ * APR_EBADMASK     The specified netmask is invalid
+ * APR_ESYMNOTFOUND Could not find the requested symbol
+ * </PRE>
+ *
+ * <PRE>
+ * <b>APR STATUS VALUES</b>
+ * APR_INCHILD        Program is currently executing in the child
+ * APR_INPARENT       Program is currently executing in the parent
+ * APR_DETACH         The thread is detached
+ * APR_NOTDETACH      The thread is not detached
+ * APR_CHILD_DONE     The child has finished executing
+ * APR_CHILD_NOTDONE  The child has not finished executing
+ * APR_TIMEUP         The operation did not finish before the timeout
+ * APR_INCOMPLETE     The operation was incomplete although some processing
+ *                    was performed and the results are partially valid
+ * APR_BADCH          Getopt found an option not in the option string
+ * APR_BADARG         Getopt found an option that is missing an argument 
+ *                    and an argument was specified in the option string
+ * APR_EOF            APR has encountered the end of the file
+ * APR_NOTFOUND       APR was unable to find the socket in the poll structure
+ * APR_ANONYMOUS      APR is using anonymous shared memory
+ * APR_FILEBASED      APR is using a file name as the key to the shared memory
+ * APR_KEYBASED       APR is using a shared key as the key to the shared memory
+ * APR_EINIT          Ininitalizer value.  If no option has been found, but 
+ *                    the status variable requires a value, this should be used
+ * APR_ENOTIMPL       The APR function has not been implemented on this 
+ *                    platform, either because nobody has gotten to it yet, 
+ *                    or the function is impossible on this platform.
+ * APR_EMISMATCH      Two passwords do not match.
+ * APR_EABSOLUTE      The given path was absolute.
+ * APR_ERELATIVE      The given path was relative.
+ * APR_EINCOMPLETE    The given path was neither relative nor absolute.
+ * APR_EABOVEROOT     The given path was above the root path.
+ * APR_EBUSY          The given lock was busy.
+ * APR_EPROC_UNKNOWN  The given process wasn't recognized by APR
+ * </PRE>
+ }
+{ @see APR_STATUS_IS_ENOSTAT }
+  APR_ENOSTAT =       (APR_OS_START_ERROR + 1);
+{ @see APR_STATUS_IS_ENOPOOL }
+  APR_ENOPOOL =       (APR_OS_START_ERROR + 2);
+{ empty slot: +3 }
+{ @see APR_STATUS_IS_EBADDATE }
+  APR_EBADDATE =      (APR_OS_START_ERROR + 4);
+{ @see APR_STATUS_IS_EINVALSOCK }
+  APR_EINVALSOCK =    (APR_OS_START_ERROR + 5);
+{ @see APR_STATUS_IS_ENOPROC }
+  APR_ENOPROC =       (APR_OS_START_ERROR + 6);
+{ @see APR_STATUS_IS_ENOTIME }
+  APR_ENOTIME =       (APR_OS_START_ERROR + 7);
+{ @see APR_STATUS_IS_ENODIR }
+  APR_ENODIR  =       (APR_OS_START_ERROR + 8);
+{ @see APR_STATUS_IS_ENOLOCK }
+  APR_ENOLOCK =       (APR_OS_START_ERROR + 9);
+{ @see APR_STATUS_IS_ENOPOLL }
+  APR_ENOPOLL =       (APR_OS_START_ERROR + 10);
+{ @see APR_STATUS_IS_ENOSOCKET }
+  APR_ENOSOCKET =     (APR_OS_START_ERROR + 11);
+{ @see APR_STATUS_IS_ENOTHREAD }
+  APR_ENOTHREAD =     (APR_OS_START_ERROR + 12);
+{ @see APR_STATUS_IS_ENOTHDKEY }
+  APR_ENOTHDKEY =     (APR_OS_START_ERROR + 13);
+{ @see APR_STATUS_IS_EGENERAL }
+  APR_EGENERAL =      (APR_OS_START_ERROR + 14);
+{ @see APR_STATUS_IS_ENOSHMAVAIL }
+  APR_ENOSHMAVAIL =   (APR_OS_START_ERROR + 15);
+{ @see APR_STATUS_IS_EBADIP }
+  APR_EBADIP =        (APR_OS_START_ERROR + 16);
+{ @see APR_STATUS_IS_EBADMASK }
+  APR_EBADMASK =      (APR_OS_START_ERROR + 17);
+{ empty slot: +18 }
+{ @see APR_STATUS_IS_EDSOPEN }
+  APR_EDSOOPEN =      (APR_OS_START_ERROR + 19);
+{ @see APR_STATUS_IS_EABSOLUTE }
+  APR_EABSOLUTE =     (APR_OS_START_ERROR + 20);
+{ @see APR_STATUS_IS_ERELATIVE }
+  APR_ERELATIVE =     (APR_OS_START_ERROR + 21);
+{ @see APR_STATUS_IS_EINCOMPLETE }
+  APR_EINCOMPLETE =   (APR_OS_START_ERROR + 22);
+{ @see APR_STATUS_IS_EABOVEROOT }
+  APR_EABOVEROOT =    (APR_OS_START_ERROR + 23);
+{ @see APR_STATUS_IS_EBADPATH }
+ APR_EBADPATH =      (APR_OS_START_ERROR + 24);
+{ @see APR_STATUS_IS_EPATHWILD }
+  APR_EPATHWILD =     (APR_OS_START_ERROR + 25);
+{ @see APR_STATUS_IS_ESYMNOTFOUND }
+  APR_ESYMNOTFOUND =  (APR_OS_START_ERROR + 26);
+{ @see APR_STATUS_IS_EPROC_UNKNOWN }
+  APR_EPROC_UNKNOWN = (APR_OS_START_ERROR + 27);
+
+{
+ * @defgroup APR_STATUS_IS Status Value Tests
+ * @warning For any particular error condition, more than one of these tests
+ *      may match. This is because platform-specific error codes may not
+ *      always match the semantics of the POSIX codes these tests (and the
+ *      correcponding APR error codes) are named after. A notable example
+ *      are the APR_STATUS_IS_ENOENT and APR_STATUS_IS_ENOTDIR tests on
+ *      Win32 platforms. The programmer should always be aware of this and
+ *      adjust the order of the tests accordingly.
+ }
+{
+ * APR was unable to perform a stat on the file 
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_ENOSTAT(s)        ((s) == APR_ENOSTAT)
+{
+ * APR was not provided a pool with which to allocate memory 
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_ENOPOOL(s)        ((s) == APR_ENOPOOL)
+{ APR was given an invalid date  }
+//#define APR_STATUS_IS_EBADDATE(s)       ((s) == APR_EBADDATE)
+{ APR was given an invalid socket }
+//#define APR_STATUS_IS_EINVALSOCK(s)     ((s) == APR_EINVALSOCK)
+{ APR was not given a process structure }
+//#define APR_STATUS_IS_ENOPROC(s)        ((s) == APR_ENOPROC)
+{ APR was not given a time structure }
+//#define APR_STATUS_IS_ENOTIME(s)        ((s) == APR_ENOTIME)
+{ APR was not given a directory structure }
+//#define APR_STATUS_IS_ENODIR(s)         ((s) == APR_ENODIR)
+{ APR was not given a lock structure }
+//#define APR_STATUS_IS_ENOLOCK(s)        ((s) == APR_ENOLOCK)
+{ APR was not given a poll structure }
+//#define APR_STATUS_IS_ENOPOLL(s)        ((s) == APR_ENOPOLL)
+{ APR was not given a socket }
+//#define APR_STATUS_IS_ENOSOCKET(s)      ((s) == APR_ENOSOCKET)
+{ APR was not given a thread structure }
+//#define APR_STATUS_IS_ENOTHREAD(s)      ((s) == APR_ENOTHREAD)
+{ APR was not given a thread key structure }
+//#define APR_STATUS_IS_ENOTHDKEY(s)      ((s) == APR_ENOTHDKEY)
+{ Generic Error which can not be put into another spot }
+//#define APR_STATUS_IS_EGENERAL(s)       ((s) == APR_EGENERAL)
+{ There is no more shared memory available }
+//#define APR_STATUS_IS_ENOSHMAVAIL(s)    ((s) == APR_ENOSHMAVAIL)
+{ The specified IP address is invalid }
+//#define APR_STATUS_IS_EBADIP(s)         ((s) == APR_EBADIP)
+{ The specified netmask is invalid }
+//#define APR_STATUS_IS_EBADMASK(s)       ((s) == APR_EBADMASK)
+{ empty slot: +18 }
+{
+ * APR was unable to open the dso object.  
+ * For more information call apr_dso_error().
+ }
+//#if defined(WIN32)
+//#define APR_STATUS_IS_EDSOOPEN(s)       ((s) == APR_EDSOOPEN \
+//                       || APR_TO_OS_ERROR(s) == ERROR_MOD_NOT_FOUND)
+//#else
+//#define APR_STATUS_IS_EDSOOPEN(s)       ((s) == APR_EDSOOPEN)
+//#endif
+{ The given path was absolute. }
+//#define APR_STATUS_IS_EABSOLUTE(s)      ((s) == APR_EABSOLUTE)
+{ The given path was relative. }
+//#define APR_STATUS_IS_ERELATIVE(s)      ((s) == APR_ERELATIVE)
+{ The given path was neither relative nor absolute. }
+//#define APR_STATUS_IS_EINCOMPLETE(s)    ((s) == APR_EINCOMPLETE)
+{ The given path was above the root path. }
+//#define APR_STATUS_IS_EABOVEROOT(s)     ((s) == APR_EABOVEROOT)
+{ The given path was bad. }
+//#define APR_STATUS_IS_EBADPATH(s)       ((s) == APR_EBADPATH)
+{ The given path contained wildcards. }
+//#define APR_STATUS_IS_EPATHWILD(s)      ((s) == APR_EPATHWILD)
+{ Could not find the requested symbol.
+ * For more information call apr_dso_error().
+ }
+//#if defined(WIN32)
+//#define APR_STATUS_IS_ESYMNOTFOUND(s)   ((s) == APR_ESYMNOTFOUND \
+//                       || APR_TO_OS_ERROR(s) == ERROR_PROC_NOT_FOUND)
+//#else
+//#define APR_STATUS_IS_ESYMNOTFOUND(s)   ((s) == APR_ESYMNOTFOUND)
+//#endif
+{ The given process was not recognized by APR. }
+//#define APR_STATUS_IS_EPROC_UNKNOWN(s)  ((s) == APR_EPROC_UNKNOWN)
+
+{
+ * @addtogroup APR_Error
+ }
+{ @see APR_STATUS_IS_INCHILD }
+  APR_INCHILD       = (APR_OS_START_STATUS + 1);
+{ @see APR_STATUS_IS_INPARENT }
+  APR_INPARENT      = (APR_OS_START_STATUS + 2);
+{ @see APR_STATUS_IS_DETACH }
+  APR_DETACH        = (APR_OS_START_STATUS + 3);
+{ @see APR_STATUS_IS_NOTDETACH }
+  APR_NOTDETACH     = (APR_OS_START_STATUS + 4);
+{ @see APR_STATUS_IS_CHILD_DONE }
+  APR_CHILD_DONE    = (APR_OS_START_STATUS + 5);
+{ @see APR_STATUS_IS_CHILD_NOTDONE }
+  APR_CHILD_NOTDONE = (APR_OS_START_STATUS + 6);
+{ @see APR_STATUS_IS_TIMEUP }
+  APR_TIMEUP        = (APR_OS_START_STATUS + 7);
+{ @see APR_STATUS_IS_INCOMPLETE }
+  APR_INCOMPLETE    = (APR_OS_START_STATUS + 8);
+{ empty slot: +9 }
+{ empty slot: +10 }
+{ empty slot: +11 }
+{ @see APR_STATUS_IS_BADCH }
+  APR_BADCH         = (APR_OS_START_STATUS + 12);
+{ @see APR_STATUS_IS_BADARG }
+  APR_BADARG        = (APR_OS_START_STATUS + 13);
+{ @see APR_STATUS_IS_EOF }
+  APR_EOF           = (APR_OS_START_STATUS + 14);
+{ @see APR_STATUS_IS_NOTFOUND }
+  APR_NOTFOUND      = (APR_OS_START_STATUS + 15);
+{ empty slot: +16 }
+{ empty slot: +17 }
+{ empty slot: +18 }
+{ @see APR_STATUS_IS_ANONYMOUS }
+  APR_ANONYMOUS     = (APR_OS_START_STATUS + 19);
+{ @see APR_STATUS_IS_FILEBASED }
+  APR_FILEBASED     = (APR_OS_START_STATUS + 20);
+{ @see APR_STATUS_IS_KEYBASED }
+  APR_KEYBASED      = (APR_OS_START_STATUS + 21);
+{ @see APR_STATUS_IS_EINIT }
+  APR_EINIT         = (APR_OS_START_STATUS + 22);
+{ @see APR_STATUS_IS_ENOTIMPL }
+  APR_ENOTIMPL      = (APR_OS_START_STATUS + 23);
+{ @see APR_STATUS_IS_EMISMATCH }
+  APR_EMISMATCH     = (APR_OS_START_STATUS + 24);
+{ @see APR_STATUS_IS_EBUSY }
+  APR_EBUSY         = (APR_OS_START_STATUS + 25);
+
+{
+ * @addtogroup APR_STATUS_IS
+ }
+{
+ * Program is currently executing in the child 
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code }
+//#define APR_STATUS_IS_INCHILD(s)        ((s) == APR_INCHILD)
+{
+ * Program is currently executing in the parent 
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_INPARENT(s)       ((s) == APR_INPARENT)
+{
+ * The thread is detached 
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_DETACH(s)         ((s) == APR_DETACH)
+{
+ * The thread is not detached 
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_NOTDETACH(s)      ((s) == APR_NOTDETACH)
+{
+ * The child has finished executing
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_CHILD_DONE(s)     ((s) == APR_CHILD_DONE)
+{
+ * The child has not finished executing
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_CHILD_NOTDONE(s)  ((s) == APR_CHILD_NOTDONE)
+{
+ * The operation did not finish before the timeout
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP)
+{
+ * The operation was incomplete although some processing was performed
+ * and the results are partially valid.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_INCOMPLETE(s)     ((s) == APR_INCOMPLETE)
+{ empty slot: +9 }
+{ empty slot: +10 }
+{ empty slot: +11 }
+{
+ * Getopt found an option not in the option string
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_BADCH(s)          ((s) == APR_BADCH)
+{
+ * Getopt found an option not in the option string and an argument was 
+ * specified in the option string
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_BADARG(s)         ((s) == APR_BADARG)
+{
+ * APR has encountered the end of the file
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_EOF(s)            ((s) == APR_EOF)
+{
+ * APR was unable to find the socket in the poll structure
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_NOTFOUND(s)       ((s) == APR_NOTFOUND)
+{ empty slot: +16 }
+{ empty slot: +17 }
+{ empty slot: +18 }
+{
+ * APR is using anonymous shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_ANONYMOUS(s)      ((s) == APR_ANONYMOUS)
+{
+ * APR is using a file name as the key to the shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_FILEBASED(s)      ((s) == APR_FILEBASED)
+{
+ * APR is using a shared key as the key to the shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_KEYBASED(s)       ((s) == APR_KEYBASED)
+{
+ * Ininitalizer value.  If no option has been found, but 
+ * the status variable requires a value, this should be used
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_EINIT(s)          ((s) == APR_EINIT)
+{
+ * The APR function has not been implemented on this 
+ * platform, either because nobody has gotten to it yet, 
+ * or the function is impossible on this platform.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_ENOTIMPL(s)       ((s) == APR_ENOTIMPL)
+{
+ * Two passwords do not match.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_EMISMATCH(s)      ((s) == APR_EMISMATCH)
+{
+ * The given lock was busy
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_EBUSY(s)          ((s) == APR_EBUSY)
+
+{
+ * @addtogroup APR_Error APR Error Values
+ }
+{ APR CANONICAL ERROR VALUES }
+{ @see APR_STATUS_IS_EACCES }
+{#ifdef EACCES
+#define APR_EACCES EACCES
+#else
+#define APR_EACCES         (APR_OS_START_CANONERR + 1)
+#endif
+}
+{ @see APR_STATUS_IS_EXIST }
+{#ifdef EEXIST
+#define APR_EEXIST EEXIST
+#else
+#define APR_EEXIST         (APR_OS_START_CANONERR + 2)
+#endif
+}
+{ @see APR_STATUS_IS_ENAMETOOLONG }
+{#ifdef ENAMETOOLONG
+#define APR_ENAMETOOLONG ENAMETOOLONG
+#else
+#define APR_ENAMETOOLONG   (APR_OS_START_CANONERR + 3)
+#endif
+}
+{ @see APR_STATUS_IS_ENOENT }
+{#ifdef ENOENT
+#define APR_ENOENT ENOENT
+#else
+#define APR_ENOENT         (APR_OS_START_CANONERR + 4)
+#endif
+}
+{ @see APR_STATUS_IS_ENOTDIR }
+{#ifdef ENOTDIR
+#define APR_ENOTDIR ENOTDIR
+#else
+#define APR_ENOTDIR        (APR_OS_START_CANONERR + 5)
+#endif
+}
+{ @see APR_STATUS_IS_ENOSPC }
+{#ifdef ENOSPC
+#define APR_ENOSPC ENOSPC
+#else
+#define APR_ENOSPC         (APR_OS_START_CANONERR + 6)
+#endif
+}
+{ @see APR_STATUS_IS_ENOMEM }
+{#ifdef ENOMEM
+#define APR_ENOMEM ENOMEM
+#else
+#define APR_ENOMEM         (APR_OS_START_CANONERR + 7)
+#endif
+}
+{ @see APR_STATUS_IS_EMFILE }
+{#ifdef EMFILE
+#define APR_EMFILE EMFILE
+#else
+#define APR_EMFILE         (APR_OS_START_CANONERR + 8)
+#endif
+}
+{ @see APR_STATUS_IS_ENFILE }
+{#ifdef ENFILE
+#define APR_ENFILE ENFILE
+#else
+#define APR_ENFILE         (APR_OS_START_CANONERR + 9)
+#endif
+}
+{ @see APR_STATUS_IS_EBADF }
+{#ifdef EBADF
+#define APR_EBADF EBADF
+#else
+#define APR_EBADF          (APR_OS_START_CANONERR + 10)
+#endif
+}
+{ @see APR_STATUS_IS_EINVAL }
+{#ifdef EINVAL
+#define APR_EINVAL EINVAL
+#else
+#define APR_EINVAL         (APR_OS_START_CANONERR + 11)
+#endif
+}
+{ @see APR_STATUS_IS_ESPIPE }
+{#ifdef ESPIPE
+#define APR_ESPIPE ESPIPE
+#else
+#define APR_ESPIPE         (APR_OS_START_CANONERR + 12)
+#endif
+}
+{
+ * @see APR_STATUS_IS_EAGAIN 
+ * @warning use APR_STATUS_IS_EAGAIN instead of just testing this value
+ }
+{#ifdef EAGAIN
+#define APR_EAGAIN EAGAIN
+#elif defined(EWOULDBLOCK)
+#define APR_EAGAIN EWOULDBLOCK
+#else
+#define APR_EAGAIN         (APR_OS_START_CANONERR + 13)
+#endif
+}
+{ @see APR_STATUS_IS_EINTR }
+{#ifdef EINTR
+#define APR_EINTR EINTR
+#else
+#define APR_EINTR          (APR_OS_START_CANONERR + 14)
+#endif
+}
+{ @see APR_STATUS_IS_ENOTSOCK }
+{#ifdef ENOTSOCK
+#define APR_ENOTSOCK ENOTSOCK
+#else
+#define APR_ENOTSOCK       (APR_OS_START_CANONERR + 15)
+#endif
+}
+{ @see APR_STATUS_IS_ECONNREFUSED }
+{#ifdef ECONNREFUSED
+#define APR_ECONNREFUSED ECONNREFUSED
+#else
+#define APR_ECONNREFUSED   (APR_OS_START_CANONERR + 16)
+#endif
+}
+{ @see APR_STATUS_IS_EINPROGRESS }
+{#ifdef EINPROGRESS
+#define APR_EINPROGRESS EINPROGRESS
+#else
+#define APR_EINPROGRESS    (APR_OS_START_CANONERR + 17)
+#endif
+}
+{
+ * @see APR_STATUS_IS_ECONNABORTED
+ * @warning use APR_STATUS_IS_ECONNABORTED instead of just testing this value
+ }
+
+{#ifdef ECONNABORTED
+#define APR_ECONNABORTED ECONNABORTED
+#else
+#define APR_ECONNABORTED   (APR_OS_START_CANONERR + 18)
+#endif
+}
+{ @see APR_STATUS_IS_ECONNRESET }
+{#ifdef ECONNRESET
+#define APR_ECONNRESET ECONNRESET
+#else
+#define APR_ECONNRESET     (APR_OS_START_CANONERR + 19)
+#endif
+}
+{ @see APR_STATUS_IS_ETIMEDOUT }
+{#ifdef ETIMEDOUT
+#define APR_ETIMEDOUT ETIMEDOUT
+#else
+#define APR_ETIMEDOUT      (APR_OS_START_CANONERR + 20)
+#endif
+}
+{ @see APR_STATUS_IS_EHOSTUNREACH }
+{#ifdef EHOSTUNREACH
+#define APR_EHOSTUNREACH EHOSTUNREACH
+#else
+#define APR_EHOSTUNREACH   (APR_OS_START_CANONERR + 21)
+#endif
+}
+{ @see APR_STATUS_IS_ENETUNREACH }
+{#ifdef ENETUNREACH
+#define APR_ENETUNREACH ENETUNREACH
+#else
+#define APR_ENETUNREACH    (APR_OS_START_CANONERR + 22)
+#endif
+}
+{ @see APR_STATUS_IS_EFTYPE }
+{#ifdef EFTYPE
+#define APR_EFTYPE EFTYPE
+#else
+#define APR_EFTYPE        (APR_OS_START_CANONERR + 23)
+#endif
+}
+{ @see APR_STATUS_IS_EPIPE }
+{#ifdef EPIPE
+#define APR_EPIPE EPIPE
+#else
+#define APR_EPIPE         (APR_OS_START_CANONERR + 24)
+#endif
+}
+{ @see APR_STATUS_IS_EXDEV }
+{#ifdef EXDEV
+#define APR_EXDEV EXDEV
+#else
+#define APR_EXDEV         (APR_OS_START_CANONERR + 25)
+#endif
+}
+{ @see APR_STATUS_IS_ENOTEMPTY }
+{#ifdef ENOTEMPTY
+#define APR_ENOTEMPTY ENOTEMPTY
+#else
+#define APR_ENOTEMPTY     (APR_OS_START_CANONERR + 26)
+#endif
+
+#if defined(OS2) && !defined(DOXYGEN)
+
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define INCL_DOSERRORS
+#define INCL_DOS
+}
+{ Leave these undefined.
+ * OS2 doesn't rely on the errno concept.
+ * The API calls always return a result codes which
+ * should be filtered through APR_FROM_OS_ERROR().
+ *
+ * #define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
+ * #define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))
+ }
+
+{ A special case, only socket calls require this;
+ }
+{#define apr_get_netos_error()   (APR_FROM_OS_ERROR(errno))
+#define apr_set_netos_error(e)  (errno = APR_TO_OS_ERROR(e))
+}
+{ And this needs to be greped away for good:
+ }
+{#define APR_OS2_STATUS(e) (APR_FROM_OS_ERROR(e))
+
+#define APR_STATUS_IS_SUCCESS(s)           ((s) == APR_SUCCESS \
+                || (s) == APR_OS_START_SYSERR + NO_ERROR)
+}
+{ These can't sit in a private header, so in spite of the extra size,
+ * they need to be made available here.
+ }
+  SOCBASEERR             = 10000;
+  SOCEPERM               = (SOCBASEERR+1);             { Not owner }
+  SOCESRCH               = (SOCBASEERR+3);             { No such process }
+  SOCEINTR               = (SOCBASEERR+4);             { Interrupted system call }
+  SOCENXIO               = (SOCBASEERR+6);             { No such device or address }
+  SOCEBADF               = (SOCBASEERR+9);             { Bad file number }
+  SOCEACCES              = (SOCBASEERR+13);            { Permission denied }
+  SOCEFAULT              = (SOCBASEERR+14);            { Bad address }
+  SOCEINVAL              = (SOCBASEERR+22);            { Invalid argument }
+  SOCEMFILE              = (SOCBASEERR+24);            { Too many open files }
+  SOCEPIPE               = (SOCBASEERR+32);            { Broken pipe }
+  SOCEOS2ERR             = (SOCBASEERR+100);           { OS/2 Error }
+  SOCEWOULDBLOCK         = (SOCBASEERR+35);            { Operation would block }
+  SOCEINPROGRESS         = (SOCBASEERR+36);            { Operation now in progress }
+  SOCEALREADY            = (SOCBASEERR+37);            { Operation already in progress }
+  SOCENOTSOCK            = (SOCBASEERR+38);            { Socket operation on non-socket }
+  SOCEDESTADDRREQ        = (SOCBASEERR+39);            { Destination address required }
+  SOCEMSGSIZE            = (SOCBASEERR+40);            { Message too long }
+  SOCEPROTOTYPE          = (SOCBASEERR+41);            { Protocol wrong type for socket }
+  SOCENOPROTOOPT         = (SOCBASEERR+42);            { Protocol not available }
+  SOCEPROTONOSUPPORT     = (SOCBASEERR+43);            { Protocol not supported }
+  SOCESOCKTNOSUPPORT     = (SOCBASEERR+44);            { Socket type not supported }
+  SOCEOPNOTSUPP          = (SOCBASEERR+45);            { Operation not supported on socket }
+  SOCEPFNOSUPPORT        = (SOCBASEERR+46);            { Protocol family not supported }
+  SOCEAFNOSUPPORT        = (SOCBASEERR+47);            { Address family not supported by protocol family }
+  SOCEADDRINUSE          = (SOCBASEERR+48);            { Address already in use }
+  SOCEADDRNOTAVAIL       = (SOCBASEERR+49);            { Can't assign requested address }
+  SOCENETDOWN            = (SOCBASEERR+50);            { Network is down }
+  SOCENETUNREACH         = (SOCBASEERR+51);            { Network is unreachable }
+  SOCENETRESET           = (SOCBASEERR+52);            { Network dropped connection on reset }
+  SOCECONNABORTED        = (SOCBASEERR+53);            { Software caused connection abort }
+  SOCECONNRESET          = (SOCBASEERR+54);            { Connection reset by peer }
+  SOCENOBUFS             = (SOCBASEERR+55);            { No buffer space available }
+  SOCEISCONN             = (SOCBASEERR+56);            { Socket is already connected }
+  SOCENOTCONN            = (SOCBASEERR+57);            { Socket is not connected }
+  SOCESHUTDOWN           = (SOCBASEERR+58);            { Can't send after socket shutdown }
+  SOCETOOMANYREFS        = (SOCBASEERR+59);            { Too many references: can't splice }
+  SOCETIMEDOUT           = (SOCBASEERR+60);            { Connection timed out }
+  SOCECONNREFUSED        = (SOCBASEERR+61);            { Connection refused }
+  SOCELOOP               = (SOCBASEERR+62);            { Too many levels of symbolic links }
+  SOCENAMETOOLONG        = (SOCBASEERR+63);            { File name too long }
+  SOCEHOSTDOWN           = (SOCBASEERR+64);            { Host is down }
+  SOCEHOSTUNREACH        = (SOCBASEERR+65);            { No route to host }
+  SOCENOTEMPTY           = (SOCBASEERR+66);            { Directory not empty }
+
+{ APR CANONICAL ERROR TESTS }
+{#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES \
+                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
+                || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
+#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST \
+                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
+                || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS \
+                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
+#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
+                || (s) == APR_OS_START_SYSERR + SOCENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
+                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+                || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES \
+                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED)
+#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
+#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC \
+                || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
+#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
+#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE \
+                || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
+#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE)
+#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION)
+#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
+                || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
+                || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \
+                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION)
+#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
+                || (s) == APR_OS_START_SYSERR + SOCEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
+                || (s) == APR_OS_START_SYSERR + SOCENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
+                || (s) == APR_OS_START_SYSERR + SOCECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
+                || (s) == APR_OS_START_SYSERR + SOCEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
+                || (s) == APR_OS_START_SYSERR + SOCECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
+                || (s) == APR_OS_START_SYSERR + SOCECONNRESET)
+#define APR_STATUS_IS_ETIMEDOUT(s)      ((s) == APR_ETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)    
+#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
+                || (s) == APR_OS_START_SYSERR + SOCEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
+                || (s) == APR_OS_START_SYSERR + SOCENETUNREACH)
+#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE)
+#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE \
+                || (s) == APR_OS_START_SYSERR + SOCEPIPE)
+#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV \
+                || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
+#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY \
+                || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY \
+                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
+}
+{
+    Sorry, too tired to wrap this up for OS2... feel free to
+    fit the following into their best matches.
+
+    ( ERROR_NO_SIGNAL_SENT,     ESRCH           ),
+    ( SOCEALREADY,              EALREADY        ),
+    ( SOCEDESTADDRREQ,          EDESTADDRREQ    ),
+    ( SOCEMSGSIZE,              EMSGSIZE        ),
+    ( SOCEPROTOTYPE,            EPROTOTYPE      ),
+    ( SOCENOPROTOOPT,           ENOPROTOOPT     ),
+    ( SOCEPROTONOSUPPORT,       EPROTONOSUPPORT ),
+    ( SOCESOCKTNOSUPPORT,       ESOCKTNOSUPPORT ),
+    ( SOCEOPNOTSUPP,            EOPNOTSUPP      ),
+    ( SOCEPFNOSUPPORT,          EPFNOSUPPORT    ),
+    ( SOCEAFNOSUPPORT,          EAFNOSUPPORT    ),
+    ( SOCEADDRINUSE,            EADDRINUSE      ),
+    ( SOCEADDRNOTAVAIL,         EADDRNOTAVAIL   ),
+    ( SOCENETDOWN,              ENETDOWN        ),
+    ( SOCENETRESET,             ENETRESET       ),
+    ( SOCENOBUFS,               ENOBUFS         ),
+    ( SOCEISCONN,               EISCONN         ),
+    ( SOCENOTCONN,              ENOTCONN        ),
+    ( SOCESHUTDOWN,             ESHUTDOWN       ),
+    ( SOCETOOMANYREFS,          ETOOMANYREFS    ),
+    ( SOCELOOP,                 ELOOP           ),
+    ( SOCEHOSTDOWN,             EHOSTDOWN       ),
+    ( SOCENOTEMPTY,             ENOTEMPTY       ),
+    ( SOCEPIPE,                 EPIPE           )
+}
+
+//#elif defined(WIN32) && !defined(DOXYGEN) { !defined(OS2) }
+
+{#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
+#define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))}
+
+{ A special case, only socket calls require this:
+ }
+{#define apr_get_netos_error()   (APR_FROM_OS_ERROR(WSAGetLastError()))
+#define apr_set_netos_error(e)   (WSASetLastError(APR_TO_OS_ERROR(e)))
+
+#define APR_STATUS_IS_SUCCESS(s)           ((s) == APR_SUCCESS \
+                || (s) == APR_OS_START_SYSERR + ERROR_SUCCESS)
+}
+{ APR CANONICAL ERROR TESTS }
+{#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES \
+                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
+                || (s) == APR_OS_START_SYSERR + ERROR_CANNOT_MAKE \
+                || (s) == APR_OS_START_SYSERR + ERROR_CURRENT_DIRECTORY \
+                || (s) == APR_OS_START_SYSERR + ERROR_DRIVE_LOCKED \
+                || (s) == APR_OS_START_SYSERR + ERROR_FAIL_I24 \
+                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
+                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_FAILED \
+                || (s) == APR_OS_START_SYSERR + ERROR_NOT_LOCKED \
+                || (s) == APR_OS_START_SYSERR + ERROR_NETWORK_ACCESS_DENIED \
+                || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
+#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
+                || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS)
+#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
+                || (s) == APR_OS_START_SYSERR + WSAENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
+                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
+                || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES)
+#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR \
+                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+                || (s) == APR_OS_START_SYSERR + ERROR_BAD_NETPATH \
+                || (s) == APR_OS_START_SYSERR + ERROR_BAD_NET_NAME \
+                || (s) == APR_OS_START_SYSERR + ERROR_BAD_PATHNAME \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DRIVE)
+#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC \
+                || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
+#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM \
+                || (s) == APR_OS_START_SYSERR + ERROR_ARENA_TRASHED \
+                || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_MEMORY \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_BLOCK \
+                || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_QUOTA \
+                || (s) == APR_OS_START_SYSERR + ERROR_OUTOFMEMORY)
+#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE \
+                || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
+#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_TARGET_HANDLE)
+#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_ACCESS \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DATA \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
+                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_SEEK_ON_DEVICE \
+                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
+                || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
+                || (s) == APR_OS_START_SYSERR + ERROR_NO_PROC_SLOTS \
+                || (s) == APR_OS_START_SYSERR + ERROR_NESTING_NOT_ALLOWED \
+                || (s) == APR_OS_START_SYSERR + ERROR_MAX_THRDS_REACHED \
+                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
+                || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
+#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
+                || (s) == APR_OS_START_SYSERR + WSAEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
+                || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
+                || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
+                || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
+                || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
+                || (s) == APR_OS_START_SYSERR + ERROR_NETNAME_DELETED \
+                || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
+#define APR_STATUS_IS_ETIMEDOUT(s)      ((s) == APR_ETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
+                || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
+                || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
+#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_EXE_MACHINE_TYPE_MISMATCH \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DLL \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_MODULETYPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_BAD_EXE_FORMAT \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_EXE_SIGNATURE \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILE_CORRUPT \
+                || (s) == APR_OS_START_SYSERR + ERROR_BAD_FORMAT)
+#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE)
+#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV \
+                || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
+#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY \
+                || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY)
+}
+//#elif defined(NETWARE) && !defined(DOXYGEN) { !defined(OS2) && !defined(WIN32) }
+{
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define apr_get_os_error()    (errno)
+#define apr_set_os_error(e)   (errno = (e))
+}
+{ A special case, only socket calls require this: }
+{#define apr_get_netos_error()   (APR_FROM_OS_ERROR(WSAGetLastError()))
+#define apr_set_netos_error(e)  (WSASetLastError(APR_TO_OS_ERROR(e)))
+
+#define APR_STATUS_IS_SUCCESS(s)           ((s) == APR_SUCCESS)
+}
+{ APR CANONICAL ERROR TESTS }
+{#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES)
+#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST)
+#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT)
+#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
+#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC)
+#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
+#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE)
+#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF)
+#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL)
+#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE)
+
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
+                || (s) ==                       EWOULDBLOCK \
+                || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
+#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
+                || (s) == APR_OS_START_SYSERR + WSAEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
+                || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
+                || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
+                || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
+                || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
+                || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
+#define APR_STATUS_IS_ETIMEDOUT(s)      ((s) == APR_ETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
+                || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
+                || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
+#define APR_STATUS_IS_ENETDOWN(s)       ((s) == APR_OS_START_SYSERR + WSAENETDOWN)
+#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE)
+#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE)
+#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV)
+#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY)
+}
+//#else { !defined(NETWARE) && !defined(OS2) && !defined(WIN32) }
+
+{
+ *  os error codes are clib error codes
+ }
+{#define APR_FROM_OS_ERROR(e)  (e)
+#define APR_TO_OS_ERROR(e)    (e)
+
+#define apr_get_os_error()    (errno)
+#define apr_set_os_error(e)   (errno = (e))
+}
+{ A special case, only socket calls require this:
+ }
+//#define apr_get_netos_error() (errno)
+//#define apr_set_netos_error(e) (errno = (e))
+
+{
+ * @addtogroup APR_STATUS_IS
+ }
+{ no error }
+//#define APR_STATUS_IS_SUCCESS(s)        ((s) == APR_SUCCESS)
+
+{ permission denied }
+//#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES)
+{ file exists }
+//#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST)
+{ path name is too long }
+//#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG)
+{
+ * no such file or directory
+ * @remark
+ * EMVSCATLG can be returned by the automounter on z/OS for
+ * paths which do not exist.
+ }
+{#ifdef EMVSCATLG
+#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
+                                      || (s) == EMVSCATLG)
+#else
+#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT)
+#endif}
+{ not a directory }
+//#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
+{ no space left on device }
+//#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC)
+{ not enough memory }
+//#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
+{ too many open files }
+//#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE)
+{ file table overflow }
+//#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
+{ bad file # }
+//#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF)
+{ invalid argument }
+//#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL)
+{ illegal seek }
+//#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE)
+
+{ operation would block }
+{#if !defined(EWOULDBLOCK) || !defined(EAGAIN)
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN)
+#elif (EWOULDBLOCK == EAGAIN)
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN)
+#else
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
+                                      || (s) == EWOULDBLOCK)
+#endif
+}
+{ interrupted system call }
+//#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR)
+{ socket operation on a non-socket }
+//#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK)
+{ Connection Refused }
+//#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED)
+{ operation now in progress }
+//#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS)
+
+{
+ * Software caused connection abort 
+ * @remark
+ * EPROTO on certain older kernels really means ECONNABORTED, so we need to 
+ * ignore it for them.  See discussion in new-httpd archives nh.9701 & nh.9603
+ *
+ * There is potentially a bug in Solaris 2.x x<6, and other boxes that 
+ * implement tcp sockets in userland (i.e. on top of STREAMS).  On these
+ * systems, EPROTO can actually result in a fatal loop.  See PR#981 for 
+ * example.  It's hard to handle both uses of EPROTO.
+ }
+{#ifdef EPROTO
+#define APR_STATUS_IS_ECONNABORTED(s)    ((s) == APR_ECONNABORTED \
+                                       || (s) == EPROTO)
+#else
+#define APR_STATUS_IS_ECONNABORTED(s)    ((s) == APR_ECONNABORTED)
+#endif
+}
+{ Connection Reset by peer }
+//#define APR_STATUS_IS_ECONNRESET(s)      ((s) == APR_ECONNRESET)
+{ Operation timed out }
+//#define APR_STATUS_IS_ETIMEDOUT(s)       ((s) == APR_ETIMEDOUT)
+{ no route to host }
+//#define APR_STATUS_IS_EHOSTUNREACH(s)    ((s) == APR_EHOSTUNREACH)
+{ network is unreachable }
+//#define APR_STATUS_IS_ENETUNREACH(s)     ((s) == APR_ENETUNREACH)
+{ inappropiate file type or format }
+//#define APR_STATUS_IS_EFTYPE(s)          ((s) == APR_EFTYPE)
+{ broken pipe }
+//#define APR_STATUS_IS_EPIPE(s)           ((s) == APR_EPIPE)
+{ cross device link }
+//#define APR_STATUS_IS_EXDEV(s)           ((s) == APR_EXDEV)
+{ Directory Not Empty }
+//#define APR_STATUS_IS_ENOTEMPTY(s)       ((s) == APR_ENOTEMPTY || \
+//                                          (s) == APR_EEXIST)
+
+//#endif { !defined(NETWARE) && !defined(OS2) && !defined(WIN32) }
+

+ 434 - 0
packages/base/httpd/httpd-2.0/apr/apr_file_info.inc

@@ -0,0 +1,434 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_file_info.h
+ * @brief APR File Information
+ }
+
+{#include "apr.h"
+#include "apr_user.h"
+#include "apr_pools.h"
+#include "apr_tables.h"
+#include "apr_time.h"
+#include "apr_errno.h"
+
+#if APR_HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif}
+
+{
+ * @defgroup apr_file_info File Information
+ * @ingroup APR 
+ }
+
+{ Many applications use the type member to determine the
+ * existance of a file or initialization of the file info,
+ * so the APR_NOFILE value must be distinct from APR_UNKFILE.
+ }
+
+{ apr_filetype_e values for the filetype member of the
+ * apr_file_info_t structure
+ * @warning: Not all of the filetypes below can be determined.
+ * For example, a given platform might not correctly report 
+ * a socket descriptor as APR_SOCK if that type isn't 
+ * well-identified on that platform.  In such cases where
+ * a filetype exists but cannot be described by the recognized
+ * flags below, the filetype will be APR_UNKFILE.  If the
+ * filetype member is not determined, the type will be APR_NOFILE.
+ }
+
+type
+  apr_filetype_e = (
+    APR_NOFILE = 0,     {< no file type determined }
+    APR_REG,            {< a regular file }
+    APR_DIR,            {< a directory }
+    APR_CHR,            {< a character device }
+    APR_BLK,            {< a block device }
+    APR_PIPE,           {< a FIFO / pipe }
+    APR_LNK,            {< a symbolic link }
+    APR_SOCK,           {< a [unix domain] socket }
+    APR_UNKFILE = 127   {< a file of some other unknown type }
+  );
+
+{
+ * @defgroup apr_file_permissions File Permissions flags 
+ * @
+ }
+
+const
+  APR_USETID =     $8000; {< Set user id }
+  APR_UREAD =      $0400; {< Read by user }
+  APR_UWRITE =     $0200; {< Write by user }
+  APR_UEXECUTE =   $0100; {< Execute by user }
+
+  APR_GSETID =     $4000; {< Set group id }
+  APR_GREAD =      $0040; {< Read by group }
+  APR_GWRITE =     $0020; {< Write by group }
+  APR_GEXECUTE =   $0010; {< Execute by group }
+
+  APR_WSTICKY =    $2000; {< Sticky bit }
+  APR_WREAD =      $0004; {< Read by others }
+  APR_WWRITE =     $0002; {< Write by others }
+  APR_WEXECUTE =   $0001; {< Execute by others }
+
+  APR_OS_DEFAULT = $0FFF; {< use OS's default permissions }
+
+{ additional permission flags for apr_file_copy  and apr_file_append }
+  APR_FILE_SOURCE_PERMS = $1000; {< Copy source file's permissions }
+
+{
+ * Structure for referencing directories.
+ }
+type
+  apr_dir_t = record end;
+  Papr_dir_t = ^apr_dir_t;
+  PPapr_dir_t = ^Papr_dir_t;
+  
+{
+ * Structure for determining file permissions.
+ }
+  apr_fileperms_t = apr_int32_t;
+
+{$if defined(WIN32) or defined(NETWARE)}
+{
+ * Structure for determining the inode of the file.
+ }
+  apr_ino_t = apr_uint64_t;
+{
+ * Structure for determining the device the file is on.
+ }
+  apr_dev_t = apr_uint32_t;
+{$else}
+{ The inode of the file. }
+  apr_ino_t = ino_t;
+{
+ * Structure for determining the device the file is on.
+ }
+  apr_dev_t = dev_t;
+{$endif}
+
+{
+ * @defgroup apr_file_stat Stat Functions
+ * @
+ }
+
+const
+  APR_FINFO_LINK =  $00000001; {< Stat the link not the file itself if it is a link }
+  APR_FINFO_MTIME = $00000010; {< Modification Time }
+  APR_FINFO_CTIME = $00000020; {< Creation Time }
+  APR_FINFO_ATIME = $00000040; {< Access Time }
+  APR_FINFO_SIZE =  $00000100; {< Size of the file }
+  APR_FINFO_CSIZE = $00000200; {< Storage size consumed by the file }
+  APR_FINFO_DEV =   $00001000; {< Device }
+  APR_FINFO_INODE = $00002000; {< Inode }
+  APR_FINFO_NLINK = $00004000; {< Number of links }
+  APR_FINFO_TYPE =  $00008000; {< Type }
+  APR_FINFO_USER =  $00010000; {< User }
+  APR_FINFO_GROUP = $00020000; {< Group }
+  APR_FINFO_UPROT = $00100000; {< User protection bits }
+  APR_FINFO_GPROT = $00200000; {< Group protection bits }
+  APR_FINFO_WPROT = $00400000; {< World protection bits }
+  APR_FINFO_ICASE = $01000000; {< if dev is case insensitive }
+  APR_FINFO_NAME =  $02000000; {< ->name in proper case }
+
+  APR_FINFO_MIN =   $00008170; {< type, mtime, ctime, atime, size }
+  APR_FINFO_IDENT = $00003000; {< dev and inode }
+  APR_FINFO_OWNER = $00030000; {< user and group }
+  APR_FINFO_PROT =  $00700000; {<  all protections }
+  APR_FINFO_NORM =  $0073b170; {<  an atomic unix apr_stat() }
+  APR_FINFO_DIRENT = $02000000; {<  an atomic unix apr_dir_read() }
+
+{
+ * The file information structure.  This is analogous to the POSIX
+ * stat structure.
+ }
+type
+  apr_finfo_t = record
+    { Allocates memory and closes lingering handles in the specified pool }
+    pool: Papr_pool_t;
+    { The bitmask describing valid fields of this apr_finfo_t structure
+     *  including all available 'wanted' fields and potentially more }
+    valid: apr_int32_t;
+    { The access permissions of the file.  Mimics Unix access rights. }
+    protection: apr_fileperms_t;
+    { The type of file.  One of APR_REG, APR_DIR, APR_CHR, APR_BLK, APR_PIPE,
+     * APR_LNK or APR_SOCK.  If the type is undetermined, the value is APR_NOFILE.
+     * If the type cannot be determined, the value is APR_UNKFILE.
+     }
+    filetype: apr_filetype_e;
+    { The user id that owns the file }
+    user: apr_uid_t;
+    { The group id that owns the file }
+    group: apr_gid_t;
+    { The inode of the file. }
+    inode: apr_ino_t;
+    { The id of the device the file is on. }
+    device: apr_dev_t;
+    { The number of hard links to the file. }
+    nlink: apr_int32_t;
+    { The size of the file }
+    size: apr_off_t;
+    { The storage size consumed by the file }
+    csize: apr_off_t;
+    { The time the file was last accessed }
+    atime: apr_time_t;
+    { The time the file was last modified }
+    mtime: apr_time_t;
+    { The time the file was last changed }
+    ctime: apr_time_t;
+    { The pathname of the file (possibly unrooted) }
+    fname: PChar;
+    { The file's name (no path) in filesystem case }
+    name: PChar;
+    { The file's handle, if accessed (can be submitted to apr_duphandle) }
+    filehand: Papr_file_t;
+  end;
+  
+  Papr_finfo_t = ^apr_finfo_t;
+
+{
+ * get the specified file's stats.  The file is specified by filename, 
+ * instead of using a pre-opened file.
+ * @param finfo Where to store the information about the file, which is
+ * never touched if the call fails.
+ * @param fname The name of the file to stat.
+ * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_
+                 values 
+ * @param cont the pool to use to allocate the new file. 
+ *
+ * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may
+ *       not be filled in, and you need to check the @c finfo->valid bitmask
+ *       to verify that what you're looking for is there.
+ }
+function apr_stat(finfo: Papr_finfo_t; const fname: PChar;
+ wanted: apr_int32_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_stat' + LibSuff16;
+
+{
+ * get the specified file's stats.  The file is specified by filename, 
+ * instead of using a pre-opened file.  If the file is a symlink, this function
+ * will get the stats for the symlink not the file the symlink refers to.
+ * @param finfo Where to store the information about the file, which is
+ * never touched if the call fails.
+ * @param fname The name of the file to stat.
+ * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values 
+ * @param cont the pool to use to allocate the new file. 
+ * @deprecated This function is deprecated, it's equivalent to calling apr_stat with 
+ * the wanted flag value APR_FINFO_LINK
+ }
+function apr_lstat(finfo: Papr_finfo_t; const fname: PChar;
+ wanted: apr_int32_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_lstat' + LibSuff16;
+
+{
+ * @defgroup apr_dir Directory Manipulation Functions
+ }
+
+{
+ * Open the specified directory.
+ * @param new_dir The opened directory descriptor.
+ * @param dirname The full path to the directory (use / on all systems)
+ * @param cont The pool to use.
+ }
+function apr_dir_open(new_dir: PPapr_dir_t; const dirname: PChar;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_open' + LibSuff12;
+
+{
+ * close the specified directory. 
+ * @param thedir the directory descriptor to close.
+ }
+function apr_dir_close(thedir: Papr_dir_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_close' + LibSuff4;
+
+{
+ * Read the next entry from the specified directory. 
+ * @param finfo the file info structure and filled in by apr_dir_read
+ * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_
+                 values 
+ * @param thedir the directory descriptor returned from apr_dir_open
+ * @remark No ordering is guaranteed for the entries read.
+ *
+ * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may
+ *       not be filled in, and you need to check the @c finfo->valid bitmask
+ *       to verify that what you're looking for is there.
+ }
+function apr_dir_read(finfo: Papr_finfo_t; wanted: apr_int32_t;
+ thedir: Papr_dir_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_read' + LibSuff12;
+
+{
+ * Rewind the directory to the first entry.
+ * @param thedir the directory descriptor to rewind.
+ }
+function apr_dir_rewind(thedir: Papr_dir_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_rewind' + LibSuff4;
+
+{
+ * @defgroup apr_filepath Filepath Manipulation Functions
+ }
+
+const
+  { Cause apr_filepath_merge to fail if addpath is above rootpath }
+  APR_FILEPATH_NOTABOVEROOT =  $01;
+
+{ internal: Only meaningful with APR_FILEPATH_NOTABOVEROOT }
+  APR_FILEPATH_SECUREROOTTEST =$02;
+
+{ Cause apr_filepath_merge to fail if addpath is above rootpath,
+ * even given a rootpath /foo/bar and an addpath ../bar/bash
+ }
+  APR_FILEPATH_SECUREROOT =    $03;
+
+{ Fail apr_filepath_merge if the merged path is relative }
+  APR_FILEPATH_NOTRELATIVE =   $04;
+
+{ Fail apr_filepath_merge if the merged path is absolute }
+  APR_FILEPATH_NOTABSOLUTE =   $08;
+
+{ Return the file system's native path format (e.g. path delimiters
+ * of ':' on MacOS9, '\' on Win32, etc.) }
+  APR_FILEPATH_NATIVE =        $10;
+
+{ Resolve the true case of existing directories and file elements
+ * of addpath, (resolving any aliases on Win32) and append a proper 
+ * trailing slash if a directory
+ }
+  APR_FILEPATH_TRUENAME =      $20;
+
+{
+ * Extract the rootpath from the given filepath
+ * @param rootpath the root file path returned with APR_SUCCESS or APR_EINCOMPLETE
+ * @param filepath the pathname to parse for its root component
+ * @param flags the desired rules to apply, from
+ * <PRE>
+ *      APR_FILEPATH_NATIVE    Use native path seperators (e.g. '\' on Win32)
+ *      APR_FILEPATH_TRUENAME  Tests that the root exists, and makes it proper
+ * </PRE>
+ * @param p the pool to allocate the new path string from
+ * @remark on return, filepath points to the first non-root character in the
+ * given filepath.  In the simplest example, given a filepath of "/foo", 
+ * returns the rootpath of "/" and filepath points at "foo".  This is far 
+ * more complex on other platforms, which will canonicalize the root form
+ * to a consistant format, given the APR_FILEPATH_TRUENAME flag, and also
+ * test for the validity of that root (e.g., that a drive d:/ or network 
+ * share //machine/foovol/). 
+ * The function returns APR_ERELATIVE if filepath isn't rooted (an
+ * error), APR_EINCOMPLETE if the root path is ambigious (but potentially
+ * legitimate, e.g. "/" on Windows is incomplete because it doesn't specify
+ * the drive letter), or APR_EBADPATH if the root is simply invalid.
+ * APR_SUCCESS is returned if filepath is an absolute path.
+ }
+function apr_filepath_root(const rootpath, filepath: PPChar;
+ flags: apr_int32_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_root' + LibSuff16;
+
+{
+ * Merge additional file path onto the previously processed rootpath
+ * @param newpath the merged paths returned
+ * @param rootpath the root file path (NULL uses the current working path)
+ * @param addpath the path to add to the root path
+ * @param flags the desired APR_FILEPATH_ rules to apply when merging
+ * @param p the pool to allocate the new path string from
+ * @remark if the flag APR_FILEPATH_TRUENAME is given, and the addpath 
+ * contains wildcard characters ('*', '?') on platforms that don't support 
+ * such characters within filenames, the paths will be merged, but the 
+ * result code will be APR_EPATHWILD, and all further segments will not
+ * reflect the true filenames including the wildcard and following segments.
+ }
+function apr_filepath_merge(newpath: PPChar; const rootpath, addpath: PPChar;
+ flags: apr_int32_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_merge' + LibSuff20;
+
+{
+ * Split a search path into separate components
+ * @param pathelts the returned components of the search path
+ * @param liststr the search path (e.g., <tt>getenv("PATH")</tt>)
+ * @param p the pool to allocate the array and path components from
+ * @remark empty path componenta do not become part of @a pathelts.
+ * @remark the path separator in @a liststr is system specific;
+ * e.g., ':' on Unix, ';' on Windows, etc.
+ }
+function apr_filepath_list_split(pathelts: PPapr_array_header_t;
+ const liststr: PChar; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_list_split' + LibSuff12;
+
+{
+ * Merge a list of search path components into a single search path
+ * @param liststr the returned search path; may be NULL if @a pathelts is empty
+ * @param pathelts the components of the search path
+ * @param p the pool to allocate the search path from
+ * @remark emtpy strings in the source array are ignored.
+ * @remark the path separator in @a liststr is system specific;
+ * e.g., ':' on Unix, ';' on Windows, etc.
+ }
+function apr_filepath_list_merge(liststr: PPChar;
+ pathelts: Papr_array_header_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_list_merge' + LibSuff12;
+
+{
+ * Return the default file path (for relative file names)
+ * @param path the default path string returned
+ * @param flags optional flag APR_FILEPATH_NATIVE to retrieve the
+ *              default file path in os-native format.
+ * @param p the pool to allocate the default path string from
+ }
+function apr_filepath_get(path: PPChar; flags: apr_int32_t;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_get' + LibSuff12;
+
+{
+ * Set the default file path (for relative file names)
+ * @param path the default path returned
+ * @param p the pool to allocate any working storage
+ }
+function apr_filepath_set(const path: PChar; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_set' + LibSuff8;
+
+const
+  { The FilePath character encoding is unknown }
+  APR_FILEPATH_ENCODING_UNKNOWN = 0;
+
+  { The FilePath character encoding is locale-dependent }
+  APR_FILEPATH_ENCODING_LOCALE =  1;
+
+  { The FilePath character encoding is UTF-8 }
+  APR_FILEPATH_ENCODING_UTF8 =    2;
+
+{
+ * Determine the encoding used internally by the FilePath functions
+ * @param style points to a variable which receives the encoding style flag
+ * @param p the pool to allocate any working storage
+ * @remark Use @c apr_os_locale_encoding and/or @c apr_os_default_encoding
+ * to get the name of the path encoding if it's not UTF-8.
+ }
+function apr_filepath_encoding(style: PInteger; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_encoding' + LibSuff8;
+

+ 807 - 0
packages/base/httpd/httpd-2.0/apr/apr_file_io.inc

@@ -0,0 +1,807 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_file_io.h
+ * @brief APR File I/O Handling
+ }
+
+{#include "apr.h"
+#include "apr_pools.h"
+#include "apr_time.h"
+#include "apr_errno.h"}
+{.$include apr_file_info.inc}
+{#include "apr_inherit.h"}
+
+//#define APR_WANT_STDIO          {< for SEEK_* }
+//#define APR_WANT_IOVEC          {< for apr_file_writev }
+//#include "apr_want.h"
+
+{
+ * @defgroup apr_file_io File I/O Handling Functions
+ * @ingroup APR 
+ }
+
+{
+ * @defgroup apr_file_open_flags File Open Flags/Routines
+ }
+
+{ Note to implementors: Values in the range 0x00100000--0x80000000
+   are reserved for platform-specific values. }
+
+const
+  APR_READ =      $00001;     {< Open the file for reading }
+  APR_WRITE =     $00002;     {< Open the file for writing }
+  APR_CREATE =    $00004;     {< Create the file if not there }
+  APR_APPEND =    $00008;     {< Append to the end of the file }
+  APR_TRUNCATE =  $00010;     {< Open the file and truncate to 0 length }
+  APR_BINARY =    $00020;     {< Open the file in binary mode }
+  APR_EXCL =      $00040;     {< Open should fail if APR_CREATE and file
+                                        exists. }
+  APR_BUFFERED =  $00080;     {< Open the file for buffered I/O }
+  APR_DELONCLOSE =$00100;     {< Delete the file after close }
+  APR_XTHREAD =   $00200;     {< Platform dependent tag to open the file
+                                        for use across multiple threads }
+  APR_SHARELOCK = $00400;     {< Platform dependent support for higher
+                                        level locked read/write access to support
+                                        writes across process/machines }
+  APR_FILE_NOCLEANUP =$00800; {< Do not register a cleanup when the file
+                                        is opened }
+  APR_SENDFILE_ENABLED =$01000; {< Advisory flag that this file should
+                                          support apr_sendfile operation }
+  APR_LARGEFILE =  $04000;    {< Platform dependent flag to enable large file
+                                        support; WARNING see below. }
+
+{ @warning The APR_LARGEFILE flag only has effect on some platforms
+ * where sizeof(apr_off_t) == 4.  Where implemented, it allows opening
+ * and writing to a file which exceeds the size which can be
+ * represented by apr_off_t (2 gigabytes).  When a file's size does
+ * exceed 2Gb, apr_file_info_get() will fail with an error on the
+ * descriptor, likewise apr_stat()/apr_lstat() will fail on the
+ * filename.  apr_dir_read() will fail with APR_INCOMPLETE on a
+ * directory entry for a large file depending on the particular
+ * APR_FINFO_* flags.  Generally, it is not recommended to use this
+ * flag. }
+
+{
+ * @defgroup apr_file_seek_flags File Seek Flags
+ }
+
+{
+ * @defgroup apr_file_attrs_set_flags File Attribute Flags
+ }
+
+{ flags for apr_file_attrs_set }
+  APR_FILE_ATTR_READONLY =  $01;          {< File is read-only }
+  APR_FILE_ATTR_EXECUTABLE =$02;          {< File is executable }
+  APR_FILE_ATTR_HIDDEN =    $04;          {< File is hidden }
+
+{ File attributes }
+type
+  apr_fileattrs_t = apr_uint32_t;
+
+{ should be same as whence type in lseek, POSIX defines this as int }
+  apr_seek_where_t = Integer;
+
+{
+ * Structure for referencing files.
+ }
+  apr_file_t = record end;
+//  Papr_file_t = ^apr_file_t;
+  PPapr_file_t = ^Papr_file_t;
+
+{ File lock types/flags }
+{
+ * @defgroup apr_file_lock_types File Lock Types
+ }
+
+const
+  APR_FLOCK_SHARED =       1;       {< Shared lock. More than one process
+                                           or thread can hold a shared lock
+                                           at any given time. Essentially,
+                                           this is a "read lock", preventing
+                                           writers from establishing an
+                                           exclusive lock. }
+  APR_FLOCK_EXCLUSIVE =    2;       {< Exclusive lock. Only one process
+                                           may hold an exclusive lock at any
+                                           given time. This is analogous to
+                                           a "write lock". }
+
+  APR_FLOCK_TYPEMASK =     $000F;  {< mask to extract lock type }
+  APR_FLOCK_NONBLOCK =     $0010;  {< do not block while acquiring the
+                                           file lock }
+{
+ * Open the specified file.
+ * @param newf The opened file descriptor.
+ * @param fname The full path to the file (using / on all systems)
+ * @param flag Or'ed value of:
+ * <PRE>
+ *         APR_READ              open for reading
+ *         APR_WRITE             open for writing
+ *         APR_CREATE            create the file if not there
+ *         APR_APPEND            file ptr is set to end prior to all writes
+ *         APR_TRUNCATE          set length to zero if file exists
+ *         APR_BINARY            not a text file (This flag is ignored on 
+ *                               UNIX because it has no meaning)
+ *         APR_BUFFERED          buffer the data.  Default is non-buffered
+ *         APR_EXCL              return error if APR_CREATE and file exists
+ *         APR_DELONCLOSE        delete the file after closing.
+ *         APR_XTHREAD           Platform dependent tag to open the file
+ *                               for use across multiple threads
+ *         APR_SHARELOCK         Platform dependent support for higher
+ *                               level locked read/write access to support
+ *                               writes across process/machines
+ *         APR_FILE_NOCLEANUP    Do not register a cleanup with the pool 
+ *                               passed in on the <EM>cont</EM> argument (see below).
+ *                               The apr_os_file_t handle in apr_file_t will not
+ *                               be closed when the pool is destroyed.
+ *         APR_SENDFILE_ENABLED  Open with appropriate platform semantics
+ *                               for sendfile operations.  Advisory only,
+ *                               apr_sendfile does not check this flag.
+ * </PRE>
+ * @param perm Access permissions for file.
+ * @param pool The pool to use.
+ * @remark If perm is APR_OS_DEFAULT and the file is being created, appropriate 
+ *      default permissions will be used.  *arg1 must point to a valid file_t, 
+ *      or NULL (in which case it will be allocated)
+ }
+function apr_file_open(newf: PPapr_file_t; const fname: PChar;
+ flag: apr_int32_t; perm: apr_fileperms_t;
+ pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_open' + LibSuff20;
+
+{
+ * Close the specified file.
+ * @param file The file descriptor to close.
+ }
+function apr_file_close(file_: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_close' + LibSuff4;
+
+{
+ * delete the specified file.
+ * @param path The full path to the file (using / on all systems)
+ * @param cont The pool to use.
+ * @remark If the file is open, it won't be removed until all instances are closed.
+ }
+function apr_file_remove(const path: PChar; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_remove' + LibSuff8;
+
+{
+ * rename the specified file.
+ * @param from_path The full path to the original file (using / on all systems)
+ * @param to_path The full path to the new file (using / on all systems)
+ * @param pool The pool to use.
+ * @warning If a file exists at the new location, then it will be overwritten.  
+ *      Moving files or directories across devices may not be possible.
+ }
+function apr_file_rename(const from_path, to_path: PChar; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_rename' + LibSuff12;
+
+{
+ * copy the specified file to another file.
+ * @param from_path The full path to the original file (using / on all systems)
+ * @param to_path The full path to the new file (using / on all systems)
+ * @param perms Access permissions for the new file if it is created.
+ *     In place of the usual or'd combination of file permissions, the
+ *     value APR_FILE_SOURCE_PERMS may be given, in which case the source
+ *     file's permissions are copied.
+ * @param pool The pool to use.
+ * @remark The new file does not need to exist, it will be created if required.
+ * @warning If the new file already exists, its contents will be overwritten.
+ }
+function apr_file_copy(const from_path, to_path: PChar;
+ perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_copy' + LibSuff16;
+
+{
+ * append the specified file to another file.
+ * @param from_path The full path to the source file (using / on all systems)
+ * @param to_path The full path to the destination file (using / on all systems)
+ * @param perms Access permissions for the destination file if it is created.
+ *     In place of the usual or'd combination of file permissions, the
+ *     value APR_FILE_SOURCE_PERMS may be given, in which case the source
+ *     file's permissions are copied.
+ * @param pool The pool to use.
+ * @remark The new file does not need to exist, it will be created if required.
+ }
+function apr_file_append(const from_path, to_path: PChar;
+ perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_append' + LibSuff16;
+
+{
+ * Are we at the end of the file
+ * @param fptr The apr file we are testing.
+ * @remark Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise.
+ }
+function apr_file_eof(fptr: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_eof' + LibSuff4;
+
+{
+ * open standard error as an apr file pointer.
+ * @param thefile The apr file to use as stderr.
+ * @param cont The pool to allocate the file out of.
+ * 
+ * @remark The only reason that the apr_file_open_std* functions exist
+ * is that you may not always have a stderr/out/in on Windows.  This
+ * is generally a problem with newer versions of Windows and services.
+ * 
+ * The other problem is that the C library functions generally work
+ * differently on Windows and Unix.  So, by using apr_file_open_std*
+ * functions, you can get a handle to an APR struct that works with
+ * the APR functions which are supposed to work identically on all
+ * platforms.
+ }
+function apr_file_open_stderr(thefile: PPapr_file_t;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_open_stderr' + LibSuff8;
+
+{
+ * open standard output as an apr file pointer.
+ * @param thefile The apr file to use as stdout.
+ * @param cont The pool to allocate the file out of.
+ * 
+ * @remark The only reason that the apr_file_open_std* functions exist
+ * is that you may not always have a stderr/out/in on Windows.  This
+ * is generally a problem with newer versions of Windows and services.
+ * 
+ * The other problem is that the C library functions generally work
+ * differently on Windows and Unix.  So, by using apr_file_open_std*
+ * functions, you can get a handle to an APR struct that works with
+ * the APR functions which are supposed to work identically on all
+ * platforms.
+ }
+function apr_file_open_stdout(thefile: PPapr_file_t;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_open_stdout' + LibSuff8;
+
+{
+ * open standard input as an apr file pointer.
+ * @param thefile The apr file to use as stdin.
+ * @param cont The pool to allocate the file out of.
+ * 
+ * @remark The only reason that the apr_file_open_std* functions exist
+ * is that you may not always have a stderr/out/in on Windows.  This
+ * is generally a problem with newer versions of Windows and services.
+ * 
+ * The other problem is that the C library functions generally work
+ * differently on Windows and Unix.  So, by using apr_file_open_std*
+ * functions, you can get a handle to an APR struct that works with
+ * the APR functions which are supposed to work identically on all
+ * platforms.
+ }
+function apr_file_open_stdin(thefile: PPapr_file_t;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_open_stdin' + LibSuff8;
+
+{
+ * Read data from the specified file.
+ * @param thefile The file descriptor to read from.
+ * @param buf The buffer to store the data to.
+ * @param nbytes On entry, the number of bytes to read; on exit, the number of bytes read.
+ * @remark apr_file_read will read up to the specified number of bytes, but 
+ *         never more.  If there isn't enough data to fill that number of 
+ *         bytes, all of the available data is read.  The third argument is 
+ *         modified to reflect the number of bytes read.  If a char was put 
+ *         back into the stream via ungetc, it will be the first character 
+ *         returned. 
+ *
+ *         It is not possible for both bytes to be read and an APR_EOF or other 
+ *         error to be returned.
+ *
+ *         APR_EINTR is never returned.
+ }
+function apr_file_read(thefile: Papr_file_t; buf: Pointer;
+ nbytes: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_read' + LibSuff12;
+
+{
+ * Write data to the specified file.
+ * @param thefile The file descriptor to write to.
+ * @param buf The buffer which contains the data.
+ * @param nbytes On entry, the number of bytes to write; on exit, the number 
+ *               of bytes written.
+ * @remark apr_file_write will write up to the specified number of bytes, but never 
+ *      more.  If the OS cannot write that many bytes, it will write as many 
+ *      as it can.  The third argument is modified to reflect the * number 
+ *      of bytes written. 
+ *
+ *      It is possible for both bytes to be written and an error to be returned.
+ *
+ *      APR_EINTR is never returned.
+ }
+function apr_file_write(thefile: Papr_file_t; buf: Pointer;
+ nbytes: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_write' + LibSuff12;
+
+{
+ * Write data from iovec array to the specified file.
+ * @param thefile The file descriptor to write to.
+ * @param vec The array from which to get the data to write to the file.
+ * @param nvec The number of elements in the struct iovec array. This must 
+ *             be smaller than APR_MAX_IOVEC_SIZE.  If it isn't, the function 
+ *             will fail with APR_EINVAL.
+ * @param nbytes The number of bytes written.
+ * @remark It is possible for both bytes to be written and an error to be returned.
+ *      APR_EINTR is never returned.
+ *
+ *      apr_file_writev is available even if the underlying operating system 
+ *
+ *      doesn't provide writev().
+ }
+function apr_file_writev(thefile: Papr_file_t; const vec: Piovec;
+ nvec: apr_size_t; nbytes: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_writev' + LibSuff16;
+
+{
+ * Read data from the specified file, ensuring that the buffer is filled
+ * before returning.
+ * @param thefile The file descriptor to read from.
+ * @param buf The buffer to store the data to.
+ * @param nbytes The number of bytes to read.
+ * @param bytes_read If non-NULL, this will contain the number of bytes read.
+ * @remark apr_file_read will read up to the specified number of bytes, but never 
+ *      more.  If there isn't enough data to fill that number of bytes, 
+ *      then the process/thread will block until it is available or EOF 
+ *      is reached.  If a char was put back into the stream via ungetc, 
+ *      it will be the first character returned. 
+ *
+ *      It is possible for both bytes to be read and an error to be 
+ *      returned.  And if *bytes_read is less than nbytes, an
+ *      accompanying error is _always_ returned.
+ *
+ *      APR_EINTR is never returned.
+ }
+function apr_file_read_full(thefile: Papr_file_t; buf: Pointer;
+ nbytes: apr_size_t; bytes_read: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_read_full' + LibSuff16;
+
+{
+ * Write data to the specified file, ensuring that all of the data is
+ * written before returning.
+ * @param thefile The file descriptor to write to.
+ * @param buf The buffer which contains the data.
+ * @param nbytes The number of bytes to write.
+ * @param bytes_written If non-NULL, this will contain the number of bytes written.
+ * @remark apr_file_write will write up to the specified number of bytes, but never 
+ *      more.  If the OS cannot write that many bytes, the process/thread 
+ *      will block until they can be written. Exceptional error such as 
+ *      "out of space" or "pipe closed" will terminate with an error.
+ *
+ *      It is possible for both bytes to be written and an error to be 
+ *      returned.  And if *bytes_written is less than nbytes, an
+ *      accompanying error is _always_ returned.
+ *
+ *      APR_EINTR is never returned.
+ }
+function apr_file_write_full(thefile: Papr_file_t; buf: Pointer;
+ nbytes: apr_size_t; bytes_written: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_write_full' + LibSuff16;
+
+{
+ * put a character into the specified file.
+ * @param ch The character to write.
+ * @param thefile The file descriptor to write to
+ }
+function apr_file_putc(ch: Char; thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_putc' + LibSuff8;
+
+{
+ * get a character from the specified file.
+ * @param ch The character to read into
+ * @param thefile The file descriptor to read from
+ }
+function apr_file_getc(ch: PChar; thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_getc' + LibSuff8;
+
+{
+ * put a character back onto a specified stream.
+ * @param ch The character to write.
+ * @param thefile The file descriptor to write to
+ }
+function apr_file_ungetc(ch: Char; thefile: PPapr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_ungetc' + LibSuff8;
+
+{
+ * Get a string from a specified file.
+ * @param str The buffer to store the string in. 
+ * @param len The length of the string
+ * @param thefile The file descriptor to read from
+ * @remark The buffer will be '\0'-terminated if any characters are stored.
+ }
+function apr_file_gets(str: PChar; len: Integer;
+ thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_gets' + LibSuff12;
+
+{
+ * Put the string into a specified file.
+ * @param str The string to write. 
+ * @param thefile The file descriptor to write to
+ }
+function apr_file_puts(const str: PChar; thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_puts' + LibSuff8;
+
+{
+ * Flush the file's buffer.
+ * @param thefile The file descriptor to flush
+ }
+function apr_file_flush(thefile: PPapr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_flush' + LibSuff4;
+
+{
+ * duplicate the specified file descriptor.
+ * @param new_file The structure to duplicate into. 
+ * @param old_file The file to duplicate.
+ * @param p The pool to use for the new file.
+ * @remark *new_file must point to a valid apr_file_t, or point to NULL
+ }
+function apr_file_dup(new_file: PPapr_file_t; old_file: PPapr_file_t;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_dup' + LibSuff12;
+
+{
+ * duplicate the specified file descriptor and close the original
+ * @param new_file The old file that is to be closed and reused
+ * @param old_file The file to duplicate
+ * @param p        The pool to use for the new file
+ *
+ * @remark new_file MUST point at a valid apr_file_t. It cannot be NULL
+ }
+function apr_file_dup2(new_file: PPapr_file_t; old_file: PPapr_file_t;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_dup2' + LibSuff12;
+
+{
+ * move the specified file descriptor to a new pool
+ * @param new_file Pointer in which to return the new apr_file_t
+ * @param old_file The file to move
+ * @param p        The pool to which the descriptor is to be moved
+ * @remark Unlike apr_file_dup2(), this function doesn't do an
+ *         OS dup() operation on the underlying descriptor; it just
+ *         moves the descriptor's apr_file_t wrapper to a new pool.
+ * @remark The new pool need not be an ancestor of old_file's pool.
+ * @remark After calling this function, old_file may not be used
+ }
+function apr_file_setaside(new_file: PPapr_file_t; old_file: PPapr_file_t;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_setaside' + LibSuff12;
+
+{
+ * Move the read/write file offset to a specified byte within a file.
+ * @param thefile The file descriptor
+ * @param where How to move the pointer, one of:
+ * <PRE>
+ *            APR_SET  --  set the offset to offset
+ *            APR_CUR  --  add the offset to the current position 
+ *            APR_END  --  add the offset to the current file size 
+ * </PRE>
+ * @param offset The offset to move the pointer to.
+ * @remark The third argument is modified to be the offset the pointer
+          was actually moved to.
+ }
+function apr_file_seek(thefile: Papr_file_t;
+ where: apr_seek_where_t; offset: Papr_off_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_seek' + LibSuff12;
+
+{
+ * Create an anonymous pipe.
+ * @param in The file descriptor to use as input to the pipe.
+ * @param out The file descriptor to use as output from the pipe.
+ * @param cont The pool to operate on.
+ }
+function apr_file_pipe_create(in_: PPapr_file_t; out_: PPapr_file_t;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_pipe_create' + LibSuff12;
+
+{
+ * Create a named pipe.
+ * @param filename The filename of the named pipe
+ * @param perm The permissions for the newly created pipe.
+ * @param cont The pool to operate on.
+ }
+function apr_file_namedpipe_create(const filename: PChar;
+ perm: apr_fileperms_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_namedpipe_create' + LibSuff12;
+
+{
+ * Get the timeout value for a pipe or manipulate the blocking state.
+ * @param thepipe The pipe we are getting a timeout for.
+ * @param timeout The current timeout value in microseconds. 
+ }
+function apr_file_pipe_timeout_get(thepipe: Papr_file_t;
+ timeout: Papr_interval_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_get' + LibSuff8;
+
+{
+ * Set the timeout value for a pipe or manipulate the blocking state.
+ * @param thepipe The pipe we are setting a timeout on.
+ * @param timeout The timeout value in microseconds.  Values < 0 mean wait 
+ *        forever, 0 means do not wait at all.
+ }
+function apr_file_pipe_timeout_set(thepipe: Papr_file_t;
+ timeout: apr_interval_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_set' + LibSuff12;
+
+{ file (un)locking functions. }
+
+{
+ * Establish a lock on the specified, open file. The lock may be advisory
+ * or mandatory, at the discretion of the platform. The lock applies to
+ * the file as a whole, rather than a specific range. Locks are established
+ * on a per-thread/process basis; a second lock by the same thread will not
+ * block.
+ * @param thefile The file to lock.
+ * @param type The type of lock to establish on the file.
+ }
+function apr_file_lock(thefile: Papr_file_t; type_: Integer): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_lock' + LibSuff8;
+
+{
+ * Remove any outstanding locks on the file.
+ * @param thefile The file to unlock.
+ }
+function apr_file_unlock(thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_unlock' + LibSuff4;
+
+{accessor and general file_io functions. }
+
+{
+ * return the file name of the current file.
+ * @param new_path The path of the file.  
+ * @param thefile The currently open file.
+ }
+function apr_file_name_get(const newpath: PPChar; thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_name_get' + LibSuff8;
+
+{
+ * Return the data associated with the current file.
+ * @param data The user data associated with the file.  
+ * @param key The key to use for retreiving data associated with this file.
+ * @param file The currently open file.
+ }
+function apr_file_data_get(data: PPointer; const key: PChar;
+ file_: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_data_get' + LibSuff12;
+
+{
+ * Set the data associated with the current file.
+ * @param file The currently open file.
+ * @param data The user data to associate with the file.  
+ * @param key The key to use for assocaiteing data with the file.
+ * @param cleanup The cleanup routine to use when the file is destroyed.
+ }
+//function apr_file_data_set(ch: Char; thefile: PPapr_file_t): apr_status_t;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibAPR name LibNamePrefix + 'apr_file_data_set' + LibSuff4;
+//APR_DECLARE(apr_status_t) (apr_file_t *file, void *data,
+//                                           const char *key,
+//                                           apr_status_t (*cleanup)(void *));
+
+{
+ * Write a string to a file using a printf format.
+ * @param fptr The file to write to.
+ * @param format The format string
+ * @param ... The values to substitute in the format string
+ * @return The number of bytes written
+ }
+function apr_file_printf(fptr: Papr_file_t; const format: PChar;
+ othres: array of const): Integer;
+ cdecl; external LibAPR name 'apr_file_printf';
+
+{
+ * set the specified file's permission bits.
+ * @param fname The file (name) to apply the permissions to.
+ * @param perms The permission bits to apply to the file.
+ * @warning Some platforms may not be able to apply all of the available 
+ *      permission bits; APR_INCOMPLETE will be returned if some permissions 
+ *      are specified which could not be set.
+ *
+ *      Platforms which do not implement this feature will return APR_ENOTIMPL.
+ }
+function apr_file_perms_set(const fname: PChar;
+ perms: apr_fileperms_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_perms_set' + LibSuff8;
+
+{
+ * Set attributes of the specified file.
+ * @param fname The full path to the file (using / on all systems)
+ * @param attributes Or'd combination of
+ * <PRE>
+ *            APR_FILE_ATTR_READONLY   - make the file readonly
+ *            APR_FILE_ATTR_EXECUTABLE - make the file executable
+ *            APR_FILE_ATTR_HIDDEN     - make the file hidden
+ * </PRE>
+ * @param attr_mask Mask of valid bits in attributes.
+ * @param cont the pool to use.
+ * @remark This function should be used in preference to explict manipulation
+ *      of the file permissions, because the operations to provide these
+ *      attributes are platform specific and may involve more than simply
+ *      setting permission bits.
+ * @warning Platforms which do not implement this feature will return
+ *      APR_ENOTIMPL.
+ }
+function apr_file_attrs_set(const fname: PChar;
+ attributes, attr_mask: apr_fileattrs_t;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_attrs_set' + LibSuff16;
+
+{
+ * Set the mtime of the specified file.
+ * @param fname The full path to the file (using / on all systems)
+ * @param mtime The mtime to apply to the file.
+ * @param pool The pool to use.
+ * @warning Platforms which do not implement this feature will return
+ *      APR_ENOTIMPL.
+ }
+function apr_file_mtime_set(const fname: PChar;
+ mtime: apr_time_t; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_mtime_set' + LibSuff16;
+
+{
+ * Create a new directory on the file system.
+ * @param path the path for the directory to be created.  (use / on all systems)
+ * @param perm Permissions for the new direcoty.
+ * @param cont the pool to use.
+ }
+function apr_dir_make(const path: PChar; perm: apr_fileperms_t;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_make' + LibSuff12;
+
+{ Creates a new directory on the file system, but behaves like
+ * 'mkdir -p'. Creates intermediate directories as required. No error
+ * will be reported if PATH already exists.
+ * @param path the path for the directory to be created.  (use / on all systems)
+ * @param perm Permissions for the new direcoty.
+ * @param pool the pool to use.
+ }
+function apr_dir_make_recursive(const path: PChar;
+ perm: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_make_recursive' + LibSuff12;
+
+{
+ * Remove directory from the file system.
+ * @param path the path for the directory to be removed.  (use / on all systems)
+ * @param cont the pool to use.
+ }
+function apr_dir_remove(const path: PChar; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_remove' + LibSuff8;
+
+{
+ * get the specified file's stats.
+ * @param finfo Where to store the information about the file.
+ * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values 
+ * @param thefile The file to get information about.
+ }
+function apr_file_info_get(finfo: Papr_finfo_t;
+ wanted: apr_int32_t; thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_info_get' + LibSuff12;
+
+{
+ * Truncate the file's length to the specified offset
+ * @param fp The file to truncate
+ * @param offset The offset to truncate to.
+ }
+function apr_file_trunc(fp: Papr_file_t; offset: apr_off_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_trunc' + LibSuff12;
+
+{
+ * Retrieve the flags that were passed into apr_file_open()
+ * when the file was opened.
+ * @return apr_int32_t the flags
+ }
+function apr_file_flags_get(f: Papr_file_t): apr_int32_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_flags_get' + LibSuff4;
+
+{
+ * Get the pool used by the file.
+ }
+{APR_POOL_DECLARE_ACCESSOR(file);
+}
+{
+ * Set a file to be inherited by child processes.
+ *
+ }
+{APR_DECLARE_INHERIT_SET(file);
+}
+{ @deprecated @see apr_file_inherit_set }
+{APR_DECLARE(void) apr_file_set_inherit(apr_file_t *file);
+}
+{
+ * Unset a file from being inherited by child processes.
+ }
+{APR_DECLARE_INHERIT_UNSET(file);
+}
+{ @deprecated @see apr_file_inherit_unset }
+{APR_DECLARE(void) apr_file_unset_inherit(apr_file_t *file);
+}
+{
+ * Open a temporary file
+ * @param fp The apr file to use as a temporary file.
+ * @param templ The template to use when creating a temp file.
+ * @param flags The flags to open the file with. If this is zero,
+ *              the file is opened with 
+ *              APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE
+ * @param p The pool to allocate the file out of.
+ * @remark   
+ * This function  generates  a unique temporary file name from template.  
+ * The last six characters of template must be XXXXXX and these are replaced 
+ * with a string that makes the filename unique. Since it will  be  modified,
+ * template must not be a string constant, but should be declared as a character
+ * array.  
+ *
+ }
+function apr_file_mktemp(fp: PPapr_file_t; templ: PChar;
+ flags: apr_int32_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_mktemp' + LibSuff16;
+
+{
+ * Find an existing directory suitable as a temporary storage location.
+ * @param temp_dir The temp directory.
+ * @param p The pool to use for any necessary allocations.
+ * @remark   
+ * This function uses an algorithm to search for a directory that an
+ * an application can use for temporary storage.  Once such a
+ * directory is found, that location is cached by the library.  Thus,
+ * callers only pay the cost of this algorithm once if that one time
+ * is successful.
+ *
+ }
+function apr_temp_dir_get(const temp_dir: PPChar; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_temp_dir_get' + LibSuff8;
+

+ 228 - 0
packages/base/httpd/httpd-2.0/apr/apr_general.inc

@@ -0,0 +1,228 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_general.h
+ * This is collection of oddballs that didn't fit anywhere else,
+ * and might move to more appropriate headers with the release
+ * of APR 1.0.
+ * @brief APR Miscellaneous library routines
+ }
+
+{#include "apr.h"
+#include "apr_pools.h"
+#include "apr_errno.h"
+
+#if APR_HAVE_SIGNAL_H
+#include <signal.h>
+#endif}
+
+{
+ * @defgroup apr_general Miscellaneous library routines
+ * @ingroup APR 
+ * This is collection of oddballs that didn't fit anywhere else,
+ * and might move to more appropriate headers with the release
+ * of APR 1.0.
+ }
+
+const
+{ a space }
+  APR_ASCII_BLANK = #040;
+{ a carrige return }
+  APR_ASCII_CR    = #015;
+{ a line feed }
+  APR_ASCII_LF    = #012;
+{ a tab }
+  APR_ASCII_TAB   = #011;
+
+{ signal numbers typedef }
+type
+  apr_signum_t = Integer;
+
+{
+ * Finding offsets of elements within structures.
+ * Taken from the X code... they've sweated portability of this stuff
+ * so we don't have to.  Sigh...
+ * @param p_type pointer type name
+ * @param field  data field within the structure pointed to
+ * @return offset
+ }
+
+{#if defined(CRAY) || (defined(__arm) && !defined(LINUX))
+#ifdef __STDC__
+#define APR_OFFSET(p_type,field) _Offsetof(p_type,field)
+#else
+#ifdef CRAY2
+#define APR_OFFSET(p_type,field) \
+        (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
+
+#else} { !CRAY2 }
+
+{#define APR_OFFSET(p_type,field) ((unsigned int)&(((p_type)NULL)->field))
+
+#endif} { !CRAY2 }
+//#endif { __STDC__ }
+//#else { ! (CRAY || __arm) }
+
+//#define APR_OFFSET(p_type,field) \
+//        ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
+
+//#endif { !CRAY }
+
+{
+ * Finding offsets of elements within structures.
+ * @param s_type structure type name
+ * @param field  data field within the structure
+ * @return offset
+ }
+{#if defined(offsetof) && !defined(__cplusplus)
+#define APR_OFFSETOF(s_type,field) offsetof(s_type,field)
+#else
+#define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field)
+#endif}
+
+{ @deprecated @see APR_OFFSET }
+//#define APR_XtOffset APR_OFFSET
+
+{ @deprecated @see APR_OFFSETOF }
+//#define APR_XtOffsetOf APR_OFFSETOF
+
+{$ifndef DOXYGEN}
+
+{ A couple of prototypes for functions in case some platform doesn't
+ * have it
+ }
+{#if (!APR_HAVE_STRCASECMP) && (APR_HAVE_STRICMP)
+#define strcasecmp(s1, s2) stricmp(s1, s2)
+#elif (!APR_HAVE_STRCASECMP)
+int strcasecmp(const char *a, const char *b);
+#endif
+
+#if (!APR_HAVE_STRNCASECMP) && (APR_HAVE_STRNICMP)
+#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
+#elif (!APR_HAVE_STRNCASECMP)
+int strncasecmp(const char *a, const char *b, size_t n);
+#endif}
+
+{$endif}
+
+{
+ * Alignment macros
+ }
+
+{ APR_ALIGN() is only to be used to align on a power of 2 boundary }
+{#define APR_ALIGN(size, boundary) \
+    (((size) + ((boundary) - 1)) & ~((boundary) - 1))}
+
+{ Default alignment }
+//#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
+
+
+{
+ * String and memory functions
+ }
+
+{ Properly quote a value as a string in the C preprocessor }
+//#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
+{ Helper macro for APR_STRINGIFY }
+{#define APR_STRINGIFY_HELPER(n) #n
+
+#if (!APR_HAVE_MEMMOVE)
+#define memmove(a,b,c) bcopy(b,a,c)
+#endif
+
+#if (!APR_HAVE_MEMCHR)
+void *memchr(const void *s, int c, size_t n);
+#endif}
+
+{
+ * @defgroup apr_library Library initialization and termination
+ }
+
+{
+ * Setup any APR internal data structures.  This MUST be the first function 
+ * called for any APR library.
+ * @remark See apr_app_initialize if this is an application, rather than
+ * a library consumer of apr.
+ }
+function apr_initialize: apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_initialize' + LibSuff0;
+
+{
+ * Set up an application with normalized argc, argv (and optionally env) in
+ * order to deal with platform-specific oddities, such as Win32 services,
+ * code pages and signals.  This must be the first function called for any
+ * APR program.
+ * @param argc Pointer to the argc that may be corrected
+ * @param argv Pointer to the argv that may be corrected
+ * @param env Pointer to the env that may be corrected, may be NULL
+ * @remark See apr_initialize if this is a library consumer of apr.
+ * Otherwise, this call is identical to apr_initialize, and must be closed
+ * with a call to apr_terminate at the end of program execution.
+ }
+function apr_app_initialize(argc: PInteger; argv, env: PPChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_app_initialize' + LibSuff12;
+
+{
+ * Tear down any APR internal data structures which aren't torn down 
+ * automatically.
+ * @remark An APR program must call this function at termination once it 
+ *         has stopped using APR services.  The APR developers suggest using
+ *         atexit to ensure this is called.  When using APR from a language
+ *         other than C that has problems with the calling convention, use
+ *         apr_terminate2() instead.
+ }
+procedure apr_terminate;
+ cdecl; external LibAPR name 'apr_terminate';
+
+{
+ * Tear down any APR internal data structures which aren't torn down 
+ * automatically, same as apr_terminate
+ * @remark An APR program must call either the apr_terminate or apr_terminate2 
+ *         function once it it has finished using APR services.  The APR 
+ *         developers suggest using atexit(apr_terminate) to ensure this is done.
+ *         apr_terminate2 exists to allow non-c language apps to tear down apr, 
+ *         while apr_terminate is recommended from c language applications.
+ }
+procedure apr_terminate2;
+ cdecl; external LibAPR name LibNamePrefix + 'apr_terminate2' + LibSuff0;
+
+{
+ * @defgroup apr_random Random Functions
+ }
+
+{$if defined(APR_HAS_RANDOM) or defined(DOXYGEN)}
+
+{ TODO: I'm not sure this is the best place to put this prototype...}
+{
+ * Generate random bytes.
+ * @param buf Buffer to fill with random bytes
+ * @param length Length of buffer in bytes (becomes apr_size_t in APR 1.0)
+ }
+{$ifdef APR_ENABLE_FOR_1_0}
+function apr_generate_random_bytes(buf: PChar; length: apr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_generate_random_bytes' + LibSuff8;
+{$else}
+function apr_generate_random_bytes(buf: PChar; length: Integer): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_generate_random_bytes' + LibSuff8;
+{$endif}
+
+{$endif}
+

+ 206 - 0
packages/base/httpd/httpd-2.0/apr/apr_hash.inc

@@ -0,0 +1,206 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_hash.h
+ * @brief APR Hash Tables
+ }
+
+//#include "apr_pools.h"
+
+{
+ * @defgroup apr_hash Hash Tables
+ * @ingroup APR 
+ * @
+ }
+
+{
+ * When passing a key to apr_hash_set or apr_hash_get, this value can be
+ * passed to indicate a string-valued key, and have apr_hash compute the
+ * length automatically.
+ *
+ * @remark apr_hash will use strlen(key) for the length. The null-terminator
+ *         is not included in the hash value (why throw a constant in?).
+ *         Since the hash table merely references the provided key (rather
+ *         than copying it), apr_hash_this() will return the null-term'd key.
+ }
+const
+  APR_HASH_KEY_STRING = -1;
+
+{
+ * Abstract type for hash tables.
+ }
+type
+  apr_hash_t = record end;
+  Papr_hash_t = ^apr_hash_t;
+
+{
+ * Abstract type for scanning hash tables.
+ }
+  apr_hash_index_t = record end;
+  Papr_hash_index_t = ^apr_hash_index_t;
+
+{
+ * Create a hash table.
+ * @param pool The pool to allocate the hash table out of
+ * @return The hash table just created
+  }
+function apr_hash_make(pool: Papr_pool_t): Papr_hash_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_hash_make' + LibSuff4;
+
+{
+ * Make a copy of a hash table
+ * @param pool The pool from which to allocate the new hash table
+ * @param h The hash table to clone
+ * @return The hash table just created
+ * @remark Makes a shallow copy
+ }
+function apr_hash_copy(pool: Papr_pool_t; const h: Papr_hash_t): Papr_hash_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_hash_copy' + LibSuff8;
+
+{
+ * Associate a value with a key in a hash table.
+ * @param ht The hash table
+ * @param key Pointer to the key
+ * @param klen Length of the key. Can be APR_HASH_KEY_STRING to use the string length.
+ * @param val Value to associate with the key
+ * @remark If the value is NULL the hash entry is deleted.
+ }
+procedure apr_hash_set(ht: Papr_hash_t; const key: Pointer;
+ klen: apr_size_t; const val: Pointer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_hash_set' + LibSuff16;
+
+{
+ * Look up the value associated with a key in a hash table.
+ * @param ht The hash table
+ * @param key Pointer to the key
+ * @param klen Length of the key. Can be APR_HASH_KEY_STRING to use the string length.
+ * @return Returns NULL if the key is not present.
+ }
+function apr_hash_get(ht: Papr_hash_t; const key: Pointer;
+ klen: apr_size_t): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_hash_get' + LibSuff12;
+
+{
+ * Start iterating over the entries in a hash table.
+ * @param p The pool to allocate the apr_hash_index_t iterator. If this
+ *          pool is NULL, then an internal, non-thread-safe iterator is used.
+ * @param ht The hash table
+ * @remark  There is no restriction on adding or deleting hash entries during
+ * an iteration (although the results may be unpredictable unless all you do
+ * is delete the current entry) and multiple iterations can be in
+ * progress at the same time.
+
+ * @example
+ }
+{
+ * <PRE>
+ * 
+ * int sum_values(apr_pool_t *p, apr_hash_t *ht)
+ * (
+ *     apr_hash_index_t *hi;
+ *     void *val;
+ *     int sum = 0;
+ *     for (hi = apr_hash_first(p, ht); hi; hi = apr_hash_next(hi)) (
+ *         apr_hash_this(hi, NULL, NULL, &val);
+ *         sum += *(int * )val;
+ *     )
+ *     return sum;
+ * )
+ * </PRE>
+ }
+function apr_hash_first(p: Papr_pool_t; ht: Papr_hash_t): Papr_hash_index_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_hash_first' + LibSuff8;
+
+{
+ * Continue iterating over the entries in a hash table.
+ * @param hi The iteration state
+ * @return a pointer to the updated iteration state.  NULL if there are no more  
+ *         entries.
+ }
+function apr_hash_next(hi: Papr_hash_index_t): Papr_hash_index_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_hash_next' + LibSuff4;
+
+{
+ * Get the current entry's details from the iteration state.
+ * @param hi The iteration state
+ * @param key Return pointer for the pointer to the key.
+ * @param klen Return pointer for the key length.
+ * @param val Return pointer for the associated value.
+ * @remark The return pointers should point to a variable that will be set to the
+ *         corresponding data, or they may be NULL if the data isn't interesting.
+ }
+procedure apr_hash_this(hi: Papr_hash_index_t; const key: PPointer;
+ klen: Papr_size_t; val: PPointer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_hash_this' + LibSuff16;
+
+{
+ * Get the number of key/value pairs in the hash table.
+ * @param ht The hash table
+ * @return The number of key/value pairs in the hash table.
+ }
+function apr_hash_count(ht: Papr_hash_t): cuint;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_hash_count' + LibSuff4;
+
+{
+ * Merge two hash tables into one new hash table. The values of the overlay
+ * hash override the values of the base if both have the same key.
+ * @param p The pool to use for the new hash table
+ * @param overlay The table to add to the initial table
+ * @param base The table that represents the initial values of the new table
+ * @return A new hash table containing all of the data from the two passed in
+ }
+function apr_hash_overlay(p: Papr_pool_t;
+ const overlay, base: Papr_hash_t): Papr_hash_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_hash_overlay' + LibSuff12;
+
+{
+ * Merge two hash tables into one new hash table. If the same key
+ * is present in both tables, call the supplied merge function to
+ * produce a merged value for the key in the new table.
+ * @param p The pool to use for the new hash table
+ * @param h1 The first of the tables to merge
+ * @param h2 The second of the tables to merge
+ * @param merger A callback function to merge values, or NULL to
+ *  make values from h1 override values from h2 (same semantics as
+ *  apr_hash_overlay())
+ * @param data Client data to pass to the merger function
+ * @return A new hash table containing all of the data from the two passed in
+ }
+type
+  apr_hash_merge_t = function (p: Papr_pool_t; const key: Pointer; klen: apr_size_t;
+   const h1_val, h2_val, data: Pointer): Pointer; cdecl;
+
+function apr_hash_merge(p: Papr_pool_t;
+ const h1, h2: Papr_hash_t;
+ merger: apr_hash_merge_t; const data: Pointer): Papr_hash_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_hash_merge' + LibSuff20;
+
+{
+ * Get a pointer to the pool which the hash table was created in
+ }
+//APR_POOL_DECLARE_ACCESSOR(hash);
+

+ 221 - 0
packages/base/httpd/httpd-2.0/apr/apr_lib.inc

@@ -0,0 +1,221 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_lib.h
+ * This is collection of oddballs that didn't fit anywhere else,
+ * and might move to more appropriate headers with the release
+ * of APR 1.0.
+ * @brief APR general purpose library routines
+ }
+
+{#include "apr.h"
+#include "apr_errno.h"
+
+#if APR_HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#if APR_HAVE_STDARG_H
+#include <stdarg.h>
+#endif}
+
+{
+ * @defgroup apr_lib General Purpose Library Routines
+ * @ingroup APR 
+ * This is collection of oddballs that didn't fit anywhere else,
+ * and might move to more appropriate headers with the release
+ * of APR 1.0.
+ }
+
+{ A constant representing a 'large' string. }
+const HUGE_STRING_LEN = 8192;
+
+{
+ * Define the structures used by the APR general-purpose library.
+ }
+
+{ @see apr_vformatter_buff_t }
+type
+  Papr_vformatter_buff_t = ^apr_vformatter_buff_t;
+
+{
+ * Structure used by the variable-formatter routines.
+ }
+  apr_vformatter_buff_t = record
+    { The current position }
+    curpos: PChar;
+    { The end position of the format string }
+    endpos: PChar;
+  end;
+
+{
+ * return the final element of the pathname
+ * @param pathname The path to get the final element of
+ * @return the final element of the path
+ * @remark
+ * <PRE>
+ * For example:
+ *                 "/foo/bar/gum"    -> "gum"
+ *                 "/foo/bar/gum/"   -> ""
+ *                 "gum"             -> "gum"
+ *                 "bs\\path\\stuff" -> "stuff"
+ * </PRE>
+ }
+function apr_filepath_name_get(const pathname: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_name_get' + LibSuff4;
+
+{ @deprecated @see apr_filepath_name_get }
+function apr_filename_of_pathname(const pathname: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filename_of_pathname' + LibSuff4;
+
+{
+ * apr_killpg
+ * Small utility macros to make things easier to read.  Not usually a
+ * goal, to be sure..
+ }
+
+//#ifdef WIN32
+//#define apr_killpg(x, y)
+//#else { WIN32 }
+//#ifdef NO_KILLPG
+//#define apr_killpg(x, y)        (kill (-(x), (y)))
+//#else { NO_KILLPG }
+//#define apr_killpg(x, y)        (killpg ((x), (y)))
+//#endif { NO_KILLPG }
+//#endif { WIN32 }
+
+{
+ * apr_vformatter() is a generic printf-style formatting routine
+ * with some extensions.
+ * @param flush_func The function to call when the buffer is full
+ * @param c The buffer to write to
+ * @param fmt The format string
+ * @param ap The arguments to use to fill out the format string.
+ *
+ * @remark
+ * <PRE>
+ * The extensions are:
+ *
+ * %%pA	takes a struct in_addr *, and prints it as a.b.c.d
+ * %%pI	takes an apr_sockaddr_t * and prints it as a.b.c.d:port or
+ *      [ipv6-address]:port
+ * %%pT takes an apr_os_thread_t * and prints it in decimal
+ *      ('0' is printed if !APR_HAS_THREADS)
+ * %%pp takes a void * and outputs it in hex
+ *
+ * The %%p hacks are to force gcc's printf warning code to skip
+ * over a pointer argument without complaining.  This does
+ * mean that the ANSI-style %%p (output a void * in hex format) won't
+ * work as expected at all, but that seems to be a fair trade-off
+ * for the increased robustness of having printf-warnings work.
+ *
+ * Additionally, apr_vformatter allows for arbitrary output methods
+ * using the apr_vformatter_buff and flush_func.
+ *
+ * The apr_vformatter_buff has two elements curpos and endpos.
+ * curpos is where apr_vformatter will write the next byte of output.
+ * It proceeds writing output to curpos, and updating curpos, until
+ * either the end of output is reached, or curpos == endpos (i.e. the
+ * buffer is full).
+ *
+ * If the end of output is reached, apr_vformatter returns the
+ * number of bytes written.
+ *
+ * When the buffer is full, the flush_func is called.  The flush_func
+ * can return -1 to indicate that no further output should be attempted,
+ * and apr_vformatter will return immediately with -1.  Otherwise
+ * the flush_func should flush the buffer in whatever manner is
+ * appropriate, re apr_pool_t nitialize curpos and endpos, and return 0.
+ *
+ * Note that flush_func is only invoked as a result of attempting to
+ * write another byte at curpos when curpos >= endpos.  So for
+ * example, it's possible when the output exactly matches the buffer
+ * space available that curpos == endpos will be true when
+ * apr_vformatter returns.
+ *
+ * apr_vformatter does not call out to any other code, it is entirely
+ * self-contained.  This allows the callers to do things which are
+ * otherwise "unsafe".  For example, apr_psprintf uses the "scratch"
+ * space at the unallocated end of a block, and doesn't actually
+ * complete the allocation until apr_vformatter returns.  apr_psprintf
+ * would be completely broken if apr_vformatter were to call anything
+ * that used this same pool.  Similarly http_bprintf() uses the "scratch"
+ * space at the end of its output buffer, and doesn't actually note
+ * that the space is in use until it either has to flush the buffer
+ * or until apr_vformatter returns.
+ * </PRE>
+ }
+type
+  flush_func_t = function (b: Papr_vformatter_buff_t): Integer;
+  
+function apr_vformatter(flush_func: flush_func_t;
+ c: Papr_vformatter_buff_t; const fmt: PChar; ap: va_list): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_vformatter' + LibSuff16;
+
+{
+ * Display a prompt and read in the password from stdin.
+ * @param prompt The prompt to display
+ * @param pwbuf Buffer to store the password
+ * @param bufsize The length of the password buffer.
+ }
+function apr_password_get(const prompt: PChar;
+ pwbuf: PChar; bufsize: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_password_get' + LibSuff12;
+
+{
+ * @defgroup apr_ctype ctype functions
+ * These macros allow correct support of 8-bit characters on systems which
+ * support 8-bit characters.  Pretty dumb how the cast is required, but
+ * that's legacy libc for ya.  These new macros do not support EOF like
+ * the standard macros do.  Tough.
+ }
+{ @see isalnum }
+//#define apr_isalnum(c) (isalnum(((unsigned char)(c))))
+{ @see isalpha }
+//#define apr_isalpha(c) (isalpha(((unsigned char)(c))))
+{ @see iscntrl }
+//#define apr_iscntrl(c) (iscntrl(((unsigned char)(c))))
+{ @see isdigit }
+//#define apr_isdigit(c) (isdigit(((unsigned char)(c))))
+{ @see isgraph }
+//#define apr_isgraph(c) (isgraph(((unsigned char)(c))))
+{ @see islower}
+//#define apr_islower(c) (islower(((unsigned char)(c))))
+{ @see isascii }
+{#ifdef isascii
+#define apr_isascii(c) (isascii(((unsigned char)(c))))
+#else
+#define apr_isascii(c) (((c) & ~0x7f)==0)
+#endif}
+{ @see isprint }
+//#define apr_isprint(c) (isprint(((unsigned char)(c))))
+{ @see ispunct }
+//#define apr_ispunct(c) (ispunct(((unsigned char)(c))))
+{ @see isspace }
+//#define apr_isspace(c) (isspace(((unsigned char)(c))))
+{ @see isupper }
+//#define apr_isupper(c) (isupper(((unsigned char)(c))))
+{ @see isxdigit }
+//#define apr_isxdigit(c) (isxdigit(((unsigned char)(c))))
+{ @see tolower }
+function apr_tolower(c: Char): Char;
+{ @see toupper }
+function apr_toupper(c: Char): Char;
+

+ 884 - 0
packages/base/httpd/httpd-2.0/apr/apr_network_io.inc

@@ -0,0 +1,884 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_network_io.h
+ * @brief APR Network library
+ }
+
+{#include "apr.h"
+#include "apr_pools.h"
+#include "apr_file_io.h"
+#include "apr_errno.h"
+#include "apr_inherit.h" 
+
+#if APR_HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif}
+
+{
+ * @defgroup apr_network_io Network Routines
+ * @ingroup APR 
+ }
+
+const
+{ Maximum seconds to linger }
+  APR_MAX_SECS_TO_LINGER = 30;
+
+{ @deprecated @see APR_MAX_SECS_TO_LINGER }
+  MAX_SECS_TO_LINGER = APR_MAX_SECS_TO_LINGER;
+
+{ Maximum hostname length }
+  APRMAXHOSTLEN = 256;
+
+{ Default 'any' address }
+  APR_ANYADDR  = '0.0.0.0';
+
+{
+ * @defgroup apr_sockopt Socket option definitions
+ }
+  APR_SO_LINGER       = 1;    {< Linger }
+  APR_SO_KEEPALIVE    = 2;    {< Keepalive }
+  APR_SO_DEBUG        = 4;    {< Debug }
+  APR_SO_NONBLOCK     = 8;    {< Non-blocking IO }
+  APR_SO_REUSEADDR    = 16;   {< Reuse addresses }
+  APR_SO_TIMEOUT      = 32;   {< Timeout }
+  APR_SO_SNDBUF       = 64;   {< Send buffer }
+  APR_SO_RCVBUF       = 128;  {< Receive buffer }
+  APR_SO_DISCONNECTED = 256;  {< Disconnected }
+  APR_TCP_NODELAY     = 512;  {< For SCTP sockets, this is mapped
+                                   * to STCP_NODELAY internally.
+                                   }
+  APR_TCP_NOPUSH      = 1024; {< No push }
+  APR_RESET_NODELAY   = 2048; {< This flag is ONLY set internally
+                                   * when we set APR_TCP_NOPUSH with
+                                   * APR_TCP_NODELAY set to tell us that
+                                   * APR_TCP_NODELAY should be turned on
+                                   * again when NOPUSH is turned off
+                                   }
+  APR_INCOMPLETE_READ = 4096;  {< Set on non-blocking sockets
+				   * (timeout != 0) on which the
+				   * previous read() did not fill a buffer
+				   * completely.  the next apr_socket_recv() 
+                                   * will first call select()/poll() rather than
+				   * going straight into read().  (Can also
+				   * be set by an application to force a
+				   * select()/poll() call before the next
+				   * read, in cases where the app expects
+				   * that an immediate read would fail.)
+                                   }
+  APR_INCOMPLETE_WRITE = 8192; {< like APR_INCOMPLETE_READ, but for write
+                                   * @see APR_INCOMPLETE_READ
+                                   }
+  APR_IPV6_V6ONLY    = 16384; {< Don't accept IPv4 connections on an
+                                   * IPv6 listening socket.
+                                   }
+
+{ Define what type of socket shutdown should occur. }
+type
+  apr_shutdown_how_e = (
+    APR_SHUTDOWN_READ,          {< no longer allow read request }
+    APR_SHUTDOWN_WRITE,         {< no longer allow write requests }
+    APR_SHUTDOWN_READWRITE      {< no longer allow read or write requests }
+  );
+
+const
+  APR_IPV4_ADDR_OK = $01;  {< @see apr_sockaddr_info_get() }
+  APR_IPV6_ADDR_OK = $02;  {< @see apr_sockaddr_info_get() }
+
+{$ifndef APR_HAVE_IN_ADDR}
+{
+ * We need to make sure we always have an in_addr type, so APR will just
+ * define it ourselves, if the platform doesn't provide it.
+ }
+{type
+  in_addr = record
+    s_addr: apr_uint32_t; < storage to hold the IP#
+  end;}
+{$endif}
+
+const
+{
+ * @def APR_INET
+ * Not all platforms have these defined, so we'll define them here
+ * The default values come from FreeBSD 4.1.1
+ }
+//#define APR_INET     AF_INET
+{ @def APR_UNSPEC
+ * Let the system decide which address family to use
+ }
+{#ifdef AF_UNSPEC
+#define APR_UNSPEC   AF_UNSPEC
+#else
+#define APR_UNSPEC   0
+#endif
+#if APR_HAVE_IPV6
+#define APR_INET6    AF_INET6
+#endif}
+
+{
+ * @defgroup IP_Proto IP Protocol Definitions for use when creating sockets
+ }
+  APR_PROTO_TCP      = 6;   {< TCP  }
+  APR_PROTO_UDP     = 17;   {< UDP  }
+  APR_PROTO_SCTP   = 132;   {< SCTP }
+
+{
+ * Enum to tell us if we're interested in remote or local socket
+ }
+type
+  apr_interface_e = (
+    APR_LOCAL,
+    APR_REMOTE
+  );
+
+{
+ * The specific declaration of inet_addr's ... some platforms fall back
+ * inet_network (this is not good, but necessary)
+ }
+
+{$ifdef APR_HAVE_INET_ADDR}
+  apr_inet_addr   = inet_addr;
+{$else}
+{$ifdef APR_HAVE_INET_NETWORK}        { only DGUX, as far as I know }
+{
+ * @warning
+ * not generally safe... inet_network() and inet_addr() perform
+ * different functions }
+  apr_inet_addr   = inet_network;
+{$endif}
+{$endif}
+
+{ A structure to represent sockets }
+  apr_socket_t = record
+  end;
+  Papr_socket_t = ^apr_socket_t;
+  PPapr_socket_t = ^Papr_socket_t;
+
+{
+ * A structure to encapsulate headers and trailers for apr_socket_sendfile
+ }
+  Papr_hdtr_t = ^apr_hdtr_t;
+  { A structure to represent in_addr }
+  apr_in_addr_t = record
+  end;
+{ A structure to represent an IP subnet }
+  apr_ipsubnet_t = record
+  end;
+  Papr_ipsubnet_t = ^apr_ipsubnet_t;
+  PPapr_ipsubnet_t = ^Papr_ipsubnet_t;
+
+{ @remark use apr_uint16_t just in case some system has a short that isn't 16 bits... }
+  apr_port_t = apr_uint16_t;
+  Papr_port_t = ^apr_port_t;
+
+{ @remark It's defined here as I think it should all be platform safe...
+ * @see apr_sockaddr_t
+ }
+  Papr_sockaddr_t = ^apr_sockaddr_t;
+  PPapr_sockaddr_t = ^Papr_sockaddr_t;
+
+  sa_t = record
+   case Integer of
+    { IPv4 sockaddr structure }
+    0: (sin: sockaddr_in);
+{$ifdef APR_HAVE_IPV6}
+    { IPv6 sockaddr structure }
+    1: (sin6: sockaddr_in6);
+{$endif}
+  end;
+
+{
+ * APRs socket address type, used to ensure protocol independence
+ }
+  apr_sockaddr_t = record
+    { The pool to use... }
+    pool: Papr_pool_t;
+    { The hostname }
+    hostname: PChar;
+    { Either a string of the port number or the service name for the port }
+    servname: PChar;
+    { The numeric port }
+    port: apr_port_t;
+    { The family }
+    family: apr_int32_t;
+    { Union of either IPv4 or IPv6 sockaddr. }
+    sa: sa_t;
+    { How big is the sockaddr we're using? }
+    salen: apr_socklen_t;
+    { How big is the ip address structure we're using? }
+    ipaddr_len: cint;
+    { How big should the address buffer be?  16 for v4 or 46 for v6
+     *  used in inet_ntop... }
+    addr_str_len: cint;
+    { This points to the IP address structure within the appropriate
+     *  sockaddr structure.  }
+    ipaddr_ptr: Pointer;
+    { If multiple addresses were found by apr_sockaddr_info_get(), this
+     *  points to a representation of the next address. }
+    next: Papr_sockaddr_t;
+  end;
+
+{$ifdef APR_HAS_SENDFILE}
+{
+ * Support reusing the socket on platforms which support it (from disconnect,
+ * specifically Win32.
+ * @remark Optional flag passed into apr_socket_sendfile() 
+ }
+  APR_SENDFILE_DISCONNECT_SOCKET     = 1;
+{$endif}
+
+{ A structure to encapsulate headers and trailers for apr_socket_sendfile }
+  apr_hdtr_t = record
+    { An iovec to store the headers sent before the file. }
+    headers: Piovec;
+    { number of headers in the iovec }
+    numheaders: cint;
+    { An iovec to store the trailers sent after the file. }
+    trailers: Piovec;
+    { number of trailers in the iovec }
+    numtrailers: Integer;
+  end;
+
+{ function definitions }
+
+{
+ * Create a socket.
+ * @remark With APR 1.0, this function follows the prototype 
+ * of apr_socket_create_ex.
+ * @param new_sock The new socket that has been set up.
+ * @param family The address family of the socket (e.g., APR_INET).
+ * @param type The type of the socket (e.g., SOCK_STREAM).
+ * @param cont The pool to use
+ }
+function apr_socket_create(new_sock: PPapr_socket_t;
+ family, type_: Integer; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_create' + LibSuff16;
+
+{
+ * Create a socket.
+ * @remark With APR 1.0, this function is deprecated and apr_socket_create 
+ * follows this prototype.
+ * @param new_sock The new socket that has been set up.
+ * @param family The address family of the socket (e.g., APR_INET).
+ * @param type The type of the socket (e.g., SOCK_STREAM).
+ * @param protocol The protocol of the socket (e.g., APR_PROTO_TCP).
+ * @param cont The pool to use
+ }
+function apr_socket_create_ex(new_sock: PPapr_socket_t;
+ family, type_, protocol: Integer; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_create_ex' + LibSuff20;
+
+{
+ * Shutdown either reading, writing, or both sides of a socket.
+ * @param thesocket The socket to close 
+ * @param how How to shutdown the socket.  One of:
+ * <PRE>
+ *            APR_SHUTDOWN_READ         no longer allow read requests
+ *            APR_SHUTDOWN_WRITE        no longer allow write requests
+ *            APR_SHUTDOWN_READWRITE    no longer allow read or write requests 
+ * </PRE>
+ * @see apr_shutdown_how_e
+ * @remark This does not actually close the socket descriptor, it just
+ *      controls which calls are still valid on the socket.
+ }
+function apr_socket_shutdown(thesocket: Papr_socket_t;
+ how: apr_shutdown_how_e): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_shutdown' + LibSuff8;
+
+{ @deprecated @see apr_socket_shutdown }
+function apr_shutdown(thesocket: Papr_socket_t;
+ how: apr_shutdown_how_e): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_shutdown' + LibSuff8;
+
+{
+ * Close a socket.
+ * @param thesocket The socket to close 
+ }
+function apr_socket_close(thesocket: Papr_socket_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_close' + LibSuff4;
+
+{
+ * Bind the socket to its associated port
+ * @param sock The socket to bind 
+ * @param sa The socket address to bind to
+ * @remark This may be where we will find out if there is any other process
+ *      using the selected port.
+ }
+function apr_socket_bind(sock: Papr_socket_t;
+ sa: Papr_sockaddr_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_bind' + LibSuff8;
+
+{ @deprecated @see apr_socket_bind }
+function apr_bind(sock: Papr_socket_t;
+ sa: Papr_sockaddr_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_bind' + LibSuff8;
+
+{
+ * Listen to a bound socket for connections.
+ * @param sock The socket to listen on 
+ * @param backlog The number of outstanding connections allowed in the sockets
+ *                listen queue.  If this value is less than zero, the listen
+ *                queue size is set to zero.  
+ }
+function apr_socket_listen(sock: Papr_socket_t;
+ backlog: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_listen' + LibSuff8;
+
+{ @deprecated @see apr_socket_listen }
+function apr_listen(sock: Papr_socket_t;
+ backlog: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_listen' + LibSuff8;
+
+{
+ * Accept a new connection request
+ * @param new_sock A copy of the socket that is connected to the socket that
+ *                 made the connection request.  This is the socket which should
+ *                 be used for all future communication.
+ * @param sock The socket we are listening on.
+ * @param connection_pool The pool for the new socket.
+ }
+function apr_socket_accept(new_sock: PPapr_socket_t;
+ sock: Papr_socket_t; connection_pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_accept' + LibSuff12;
+
+{ @deprecated @see apr_socket_accept }
+{APR_DECLARE(apr_status_t) apr_accept(apr_socket_t **new_sock,
+                                     apr_socket_t *sock,
+                                     apr_pool_t *connection_pool);}
+
+{
+ * Issue a connection request to a socket either on the same machine 
+ * or a different one.
+ * @param sock The socket we wish to use for our side of the connection 
+ * @param sa The address of the machine we wish to connect to.  If NULL,
+ *           APR assumes that the sockaddr_in in the apr_socket is 
+ *           completely filled out.
+ }
+function apr_socket_connect(sock: Papr_socket_t; sa: Papr_sockaddr_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_connect' + LibSuff8;
+
+{ @deprecated @see apr_socket_connect }
+//APR_DECLARE(apr_status_t) apr_connect(apr_socket_t *sock, apr_sockaddr_t *sa);
+
+{
+ * Create apr_sockaddr_t from hostname, address family, and port.
+ * @param sa The new apr_sockaddr_t.
+ * @param hostname The hostname or numeric address string to resolve/parse, or
+ *               NULL to build an address that corresponds to 0.0.0.0 or ::
+ * @param family The address family to use, or APR_UNSPEC if the system should 
+ *               decide.
+ * @param port The port number.
+ * @param flags Special processing flags:
+ * <PRE>
+ *       APR_IPV4_ADDR_OK          first query for IPv4 addresses; only look
+ *                                 for IPv6 addresses if the first query failed;
+ *                                 only valid if family is APR_UNSPEC and hostname
+ *                                 isn't NULL; mutually exclusive with
+ *                                 APR_IPV6_ADDR_OK
+ *       APR_IPV6_ADDR_OK          first query for IPv6 addresses; only look
+ *                                 for IPv4 addresses if the first query failed;
+ *                                 only valid if family is APR_UNSPEC and hostname
+ *                                 isn't NULL and APR_HAVE_IPV6; mutually exclusive
+ *                                 with APR_IPV4_ADDR_OK
+ * </PRE>
+ * @param p The pool for the apr_sockaddr_t and associated storage.
+ }
+function apr_sockaddr_info_get(sa: PPapr_socket_t;
+ const hostname: PChar; family: apr_int32_t;
+ port: apr_port_t; flags: apr_int32_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_sockaddr_info_get' + LibSuff24;
+
+{
+ * Look up the host name from an apr_sockaddr_t.
+ * @param hostname The hostname.
+ * @param sa The apr_sockaddr_t.
+ * @param flags Special processing flags.
+ }
+function apr_getnameinfo(hostname: PPChar; sa: Papr_socket_t; flags: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_getnameinfo' + LibSuff12;
+
+{
+ * Parse hostname/IP address with scope id and port.
+ *
+ * Any of the following strings are accepted:
+ *   8080                  (just the port number)
+ *   www.apache.org        (just the hostname)
+ *   www.apache.org:8080   (hostname and port number)
+ *   [fe80::1]:80          (IPv6 numeric address string only)
+ *   [fe80::1%eth0]        (IPv6 numeric address string and scope id)
+ *
+ * Invalid strings:
+ *                         (empty string)
+ *   [abc]                 (not valid IPv6 numeric address string)
+ *   abc:65536             (invalid port number)
+ *
+ * @param addr The new buffer containing just the hostname.  On output, *addr 
+ *             will be NULL if no hostname/IP address was specfied.
+ * @param scope_id The new buffer containing just the scope id.  On output, 
+ *                 *scope_id will be NULL if no scope id was specified.
+ * @param port The port number.  On output, *port will be 0 if no port was 
+ *             specified.
+ *             ### FIXME: 0 is a legal port (per RFC 1700). this should
+ *             ### return something besides zero if the port is missing.
+ * @param str The input string to be parsed.
+ * @param p The pool from which *addr and *scope_id are allocated.
+ * @remark If scope id shouldn't be allowed, check for scope_id != NULL in 
+ *         addition to checking the return code.  If addr/hostname should be 
+ *         required, check for addr == NULL in addition to checking the 
+ *         return code.
+ }
+function apr_parse_addr_port(addr, scope_id: PPChar; port: Papr_port_t;
+ const str: PChar; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_parse_addr_port' + LibSuff20;
+
+{
+ * Get name of the current machine
+ * @param buf A buffer to store the hostname in.
+ * @param len The maximum length of the hostname that can be stored in the
+ *            buffer provided.  The suggested length is APRMAXHOSTLEN + 1.
+ * @param cont The pool to use.
+ * @remark If the buffer was not large enough, an error will be returned.
+ }
+function apr_gethostname(buf: PChar; len: Integer; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_gethostname' + LibSuff12;
+
+{
+ * Return the data associated with the current socket
+ * @param data The user data associated with the socket.
+ * @param key The key to associate with the user data.
+ * @param sock The currently open socket.
+ }
+function apr_socket_data_get(data: PPointer; const key: PChar;
+ sock: Papr_sockaddr_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_data_get' + LibSuff12;
+
+{
+ * Set the data associated with the current socket.
+ * @param sock The currently open socket.
+ * @param data The user data to associate with the socket.
+ * @param key The key to associate with the data.
+ * @param cleanup The cleanup to call when the socket is destroyed.
+ }
+type
+  cleanup_t = function (param: Pointer): apr_status_t;
+  
+function apr_socket_data_set(sock: Papr_socket_t; data: Pointer;
+ const key: PChar; cleanup: cleanup_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_data_set' + LibSuff16;
+
+{
+ * Send data over a network.
+ * @param sock The socket to send the data over.
+ * @param buf The buffer which contains the data to be sent. 
+ * @param len On entry, the number of bytes to send; on exit, the number
+ *            of bytes sent.
+ * @remark
+ * <PRE>
+ * This functions acts like a blocking write by default.  To change 
+ * this behavior, use apr_socket_timeout_set().
+ *
+ * It is possible for both bytes to be sent and an error to be returned.
+ *
+ * APR_EINTR is never returned.
+ * </PRE>
+ }
+function apr_socket_send(sock: Papr_socket_t; const buf: PChar;
+ len: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_send' + LibSuff12;
+
+{ @deprecated @see apr_socket_send }
+{APR_DECLARE(apr_status_t) apr_send(apr_socket_t *sock, const char *buf,
+                                   apr_size_t *len);}
+
+{
+ * Send multiple packets of data over a network.
+ * @param sock The socket to send the data over.
+ * @param vec The array of iovec structs containing the data to send 
+ * @param nvec The number of iovec structs in the array
+ * @param len Receives the number of bytes actually written
+ * @remark
+ * <PRE>
+ * This functions acts like a blocking write by default.  To change 
+ * this behavior, use apr_socket_timeout_set().
+ * The number of bytes actually sent is stored in argument 3.
+ *
+ * It is possible for both bytes to be sent and an error to be returned.
+ *
+ * APR_EINTR is never returned.
+ * </PRE>
+ }
+function apr_socket_sendv(sock: Papr_socket_t; const vec: Piovec;
+ nvec: apr_int32_t; len: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_sendv' + LibSuff16;
+
+{ @deprecated @see apr_socket_sendv }
+{APR_DECLARE(apr_status_t) apr_sendv(apr_socket_t *sock,
+                                    const struct iovec *vec,
+                                    apr_int32_t nvec, apr_size_t *len);}
+
+{
+ * @param sock The socket to send from
+ * @param where The apr_sockaddr_t describing where to send the data
+ * @param flags The flags to use
+ * @param buf  The data to send
+ * @param len  The length of the data to send
+ }
+function apr_socket_sendto(sock: Papr_socket_t; where: Papr_sockaddr_t;
+ flags: apr_int32_t; const buf: PChar; len: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_sendto' + LibSuff20;
+
+{ @deprecated @see apr_socket_sendto }
+{APR_DECLARE(apr_status_t) apr_sendto(apr_socket_t *sock, apr_sockaddr_t *where,
+                                     apr_int32_t flags, const char *buf, 
+                                     apr_size_t *len);}
+
+{
+ * @param from The apr_sockaddr_t to fill in the recipient info
+ * @param sock The socket to use
+ * @param flags The flags to use
+ * @param buf  The buffer to use
+ * @param len  The length of the available buffer
+ }
+function apr_socket_recvfrom(from: Papr_sockaddr_t; sock: Papr_socket_t;
+ flags: apr_int32_t; buf: PChar; len: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_recvfrom' + LibSuff20;
+
+{ @deprecated @see apr_socket_recvfrom }
+{APR_DECLARE(apr_status_t) apr_recvfrom(apr_sockaddr_t *from, apr_socket_t *sock,
+                                       apr_int32_t flags, char *buf, 
+                                       apr_size_t *len);}
+
+{$if defined(APR_HAS_SENDFILE) or defined(DOXYGEN)}
+
+{
+ * Send a file from an open file descriptor to a socket, along with 
+ * optional headers and trailers
+ * @param sock The socket to which we're writing
+ * @param file The open file from which to read
+ * @param hdtr A structure containing the headers and trailers to send
+ * @param offset Offset into the file where we should begin writing
+ * @param len (input)  - Number of bytes to send from the file 
+ *            (output) - Number of bytes actually sent, 
+ *                       including headers, file, and trailers
+ * @param flags APR flags that are mapped to OS specific flags
+ * @remark This functions acts like a blocking write by default.  To change 
+ *         this behavior, use apr_socket_timeout_set().
+ *         The number of bytes actually sent is stored in argument 5.
+ }
+function apr_socket_sendfile(sock: Papr_socket_t; file_: Papr_file_t;
+ hdtr: Papr_hdtr_t; offset: Papr_off_t; len: Papr_size_t;
+ flags: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_sendfile' + LibSuff24;
+
+{ @deprecated @see apr_socket_sendfile }
+{APR_DECLARE(apr_status_t) apr_sendfile(apr_socket_t *sock, apr_file_t *file,
+                                       apr_hdtr_t *hdtr, apr_off_t *offset,
+                                       apr_size_t *len, apr_int32_t flags);}
+
+{$endif} { APR_HAS_SENDFILE }
+
+{
+ * Read data from a network.
+ * @param sock The socket to read the data from.
+ * @param buf The buffer to store the data in. 
+ * @param len On entry, the number of bytes to receive; on exit, the number
+ *            of bytes received.
+ * @remark
+ * <PRE>
+ * This functions acts like a blocking read by default.  To change 
+ * this behavior, use apr_socket_timeout_set().
+ * The number of bytes actually sent is stored in argument 3.
+ *
+ * It is possible for both bytes to be received and an APR_EOF or
+ * other error to be returned.
+ *
+ * APR_EINTR is never returned.
+ * </PRE>
+ }
+function apr_socket_recv(sock: Papr_socket_t; buf: PChar; len: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_recv' + LibSuff12;
+
+{ @deprecated @see apr_socket_recv }
+{APR_DECLARE(apr_status_t) apr_recv(apr_socket_t *sock,
+                                   char *buf, apr_size_t *len);}
+
+{
+ * Setup socket options for the specified socket
+ * @param sock The socket to set up.
+ * @param opt The option we would like to configure.  One of:
+ * <PRE>
+ *            APR_SO_DEBUG      --  turn on debugging information 
+ *            APR_SO_KEEPALIVE  --  keep connections active
+ *            APR_SO_LINGER     --  lingers on close if data is present
+ *            APR_SO_NONBLOCK   --  Turns blocking on/off for socket
+ *            APR_SO_REUSEADDR  --  The rules used in validating addresses
+ *                                  supplied to bind should allow reuse
+ *                                  of local addresses.
+ *            APR_SO_SNDBUF     --  Set the SendBufferSize
+ *            APR_SO_RCVBUF     --  Set the ReceiveBufferSize
+ * </PRE>
+ * @param on Value for the option.
+ }
+function apr_socket_opt_set(sock: Papr_socket_t; opt, on_: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_opt_set' + LibSuff12;
+
+{ @deprecated @see apr_socket_opt_set }
+{APR_DECLARE(apr_status_t) apr_setsocketopt(apr_socket_t *sock,
+                                           apr_int32_t opt, apr_int32_t on);}
+
+{
+ * Setup socket timeout for the specified socket
+ * @param sock The socket to set up.
+ * @param t Value for the timeout.
+ * <PRE>
+ *   t > 0  -- read and write calls return APR_TIMEUP if specified time
+ *             elapsess with no data read or written
+ *   t == 0 -- read and write calls never block
+ *   t < 0  -- read and write calls block
+ * </PRE>
+ }
+function apr_socket_timeout_set(sock: Papr_socket_t; t: apr_interval_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_timeout_set' + LibSuff12;
+
+{
+ * Query socket options for the specified socket
+ * @param sock The socket to query
+ * @param opt The option we would like to query.  One of:
+ * <PRE>
+ *            APR_SO_DEBUG      --  turn on debugging information 
+ *            APR_SO_KEEPALIVE  --  keep connections active
+ *            APR_SO_LINGER     --  lingers on close if data is present
+ *            APR_SO_NONBLOCK   --  Turns blocking on/off for socket
+ *            APR_SO_REUSEADDR  --  The rules used in validating addresses
+ *                                  supplied to bind should allow reuse
+ *                                  of local addresses.
+ *            APR_SO_SNDBUF     --  Set the SendBufferSize
+ *            APR_SO_RCVBUF     --  Set the ReceiveBufferSize
+ *            APR_SO_DISCONNECTED -- Query the disconnected state of the socket.
+ *                                  (Currently only used on Windows)
+ * </PRE>
+ * @param on Socket option returned on the call.
+ }
+function apr_socket_opt_get(sock: Papr_socket_t; opt, on_: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_opt_get' + LibSuff12;
+
+{ @deprecated @see apr_socket_opt_set }
+{APR_DECLARE(apr_status_t) apr_getsocketopt(apr_socket_t *sock,
+                                           apr_int32_t opt, apr_int32_t *on);}
+
+{
+ * Query socket timeout for the specified socket
+ * @param sock The socket to query
+ * @param t Socket timeout returned from the query.
+ }
+function apr_socket_timeout_get(sock: Papr_socket_t; t: Papr_interval_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_timeout_get' + LibSuff8;
+
+{
+ * Query the specified socket if at the OOB/Urgent data mark
+ * @param sock The socket to query
+ * @param atmark Is set to true if socket is at the OOB/urgent mark,
+ *               otherwise is set to false.
+ }
+function apr_socket_atmark(sock: Papr_socket_t; atmark: PInteger): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_atmark' + LibSuff8;
+
+{
+ * Return an apr_sockaddr_t from an apr_socket_t
+ * @param sa The returned apr_sockaddr_t.
+ * @param which Which interface do we want the apr_sockaddr_t for?
+ * @param sock The socket to use
+ }
+function apr_socket_addr_get(sa: PPapr_sockaddr_t;
+ which: apr_interface_e; sock: Papr_socket_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_addr_get' + LibSuff12;
+
+{
+ * Set the port in an APR socket address.
+ * @param sockaddr The socket address to set.
+ * @param port The port to be stored in the socket address.
+ * @deprecated @see apr_sockaddr_info_get
+ }
+function apr_sockaddr_port_set(sockaddr: Papr_sockaddr_t; port: apr_port_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_sockaddr_port_set' + LibSuff8;
+
+{
+ * Return the port in an APR socket address.
+ * @param port The port from the socket address.
+ * @param sockaddr The socket address to reference.
+ * @deprecated Access port field directly.
+ }
+function apr_sockaddr_port_get(port: Papr_port_t; sockaddr: Papr_sockaddr_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_sockaddr_port_get' + LibSuff8;
+
+{
+ * Set the IP address in an APR socket address.
+ * @param sockaddr The socket address to use 
+ * @param addr The IP address to attach to the socket.
+ *             Use APR_ANYADDR to use any IP addr on the machine.
+ * @deprecated @see apr_sockaddr_info_get
+ }
+function apr_sockaddr_ip_set(sockaddr: Papr_sockaddr_t; const addr: PChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_sockaddr_ip_set' + LibSuff8;
+
+{
+ * Return the IP address (in numeric address string format) in
+ * an APR socket address.  APR will allocate storage for the IP address 
+ * string from the pool of the apr_sockaddr_t.
+ * @param addr The IP address.
+ * @param sockaddr The socket address to reference.
+ }
+function apr_sockaddr_ip_get(addr: PPChar; sockaddr: Papr_sockaddr_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_sockaddr_ip_get' + LibSuff8;
+
+{
+ * See if the IP addresses in two APR socket addresses are
+ * equivalent.  Appropriate logic is present for comparing
+ * IPv4-mapped IPv6 addresses with IPv4 addresses.
+ *
+ * @param addr1 One of the APR socket addresses.
+ * @param addr2 The other APR socket address.
+ * @remark The return value will be non-zero if the addresses
+ * are equivalent.
+ }
+function apr_sockaddr_equal(const addr1, addr2: Papr_sockaddr_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_sockaddr_equal' + LibSuff8;
+
+{$if defined(APR_FILES_AS_SOCKETS) or defined(DOXYGEN)}
+
+{
+ * Convert a File type to a socket so that it can be used in a poll operation.
+ * @param newsock the newly created socket which represents a file.
+ * @param file the file to mask as a socket.
+ * @warning This is not available on all platforms.  Platforms that have the
+ *      ability to poll files for data to be read/written/exceptions will
+ *      have the APR_FILES_AS_SOCKETS macro defined as true.
+ * @deprecated This function has been deprecated, because of the new poll
+ *             implementation.
+ }
+function apr_socket_from_file(newsock: Papr_socket_t; file_: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_connect' + LibSuff8;
+
+{$endif} { APR_FILES_AS_SOCKETS }
+
+{
+ * Given an apr_sockaddr_t and a service name, set the port for the service
+ * @param sockaddr The apr_sockaddr_t that will have its port set
+ * @param servname The name of the service you wish to use
+ }
+function apr_getservbyname(sockaddr: Papr_sockaddr_t; const servname: PChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_getservbyname' + LibSuff8;
+
+{
+ * Build an ip-subnet representation from an IP address and optional netmask or
+ * number-of-bits.
+ * @param ipsub The new ip-subnet representation
+ * @param ipstr The input IP address string
+ * @param mask_or_numbits The input netmask or number-of-bits string, or NULL
+ * @param p The pool to allocate from
+ }
+function apr_ipsubnet_create(ipsub: PPapr_ipsubnet_t;
+ const ipstr, mask_or_numbits: PChar; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_ipsubnet_create' + LibSuff16;
+
+{
+ * Test the IP address in an apr_sockaddr_t against a pre-built ip-subnet
+ * representation.
+ * @param ipsub The ip-subnet representation
+ * @param sa The socket address to test
+ * @return non-zero if the socket address is within the subnet, 0 otherwise
+ }
+function apr_ipsubnet_test(ipsub: Papr_ipsubnet_t; sa: Papr_sockaddr_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_ipsubnet_test' + LibSuff8;
+
+{$if defined(APR_HAS_SO_ACCEPTFILTER) or defined(DOXYGEN)}
+{
+ * Set an OS level accept filter.
+ * @param sock The socket to put the accept filter on.
+ * @param name The accept filter
+ * @param args Any extra args to the accept filter.  Passing NULL here removes
+ *             the accept filter. 
+ }
+function apr_socket_accept_filter(sock: Papr_socket_t; name, args: PChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_accept_filter' + LibSuff12;
+
+{$endif}
+
+{
+ * Return the protocol of the socket.
+ * @param sock The socket to query.
+ * @param protocol The returned protocol (e.g., APR_PROTO_TCP).
+ }
+function apr_socket_protocol_get(sock: Papr_socket_t; protocol: PInteger): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_socket_protocol_get' + LibSuff8;
+
+{
+ * Set a socket to be inherited by child processes.
+ }
+//APR_DECLARE_INHERIT_SET(socket);
+
+{ @deprecated @see apr_socket_inherit_set }
+{APR_DECLARE(void) apr_socket_set_inherit(apr_socket_t *skt);}
+
+{
+ * Unset a socket from being inherited by child processes.
+ }
+//APR_DECLARE_INHERIT_UNSET(socket);
+
+{ @deprecated @see apr_socket_inherit_unset }
+{APR_DECLARE(void) apr_socket_unset_inherit(apr_socket_t *skt);}
+

+ 259 - 0
packages/base/httpd/httpd-2.0/apr/apr_poll.inc

@@ -0,0 +1,259 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_poll.h
+ * @brief APR Poll interface
+ }
+{#include "apr.h"
+#include "apr_pools.h"
+#include "apr_errno.h"
+#include "apr_inherit.h" 
+#include "apr_file_io.h" 
+#include "apr_network_io.h" 
+
+#if APR_HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif}
+
+{
+ * @defgroup apr_poll Poll Routines
+ * @ingroup APR 
+ }
+
+{
+ * @defgroup apr_poll_opt Poll options
+ }
+const
+  APR_POLLIN   = $001;     {< Can read without blocking }
+  APR_POLLPRI  = $002;     {< Priority data available }
+  APR_POLLOUT  = $004;     {< Can write without blocking }
+  APR_POLLERR  = $010;     {< Pending error }
+  APR_POLLHUP  = $020;     {< Hangup occurred }
+  APR_POLLNVAL = $040;     {< Descriptior invalid }
+
+{ Used in apr_pollfd_t to determine what the apr_descriptor is }
+type
+  apr_datatype_e = (
+    APR_NO_DESC,                {< nothing here }
+    APR_POLL_SOCKET,            {< descriptor refers to a socket }
+    APR_POLL_FILE,              {< descriptor refers to a file }
+    APR_POLL_LASTDESC           {< descriptor is the last one in the list }
+  );
+
+{ Union of either an APR file or socket. }
+  apr_descriptor = record
+    case Integer of
+     1: (f: Papr_file_t);        {< file }
+     2: (s: Papr_socket_t);      {< socket }
+  end;
+
+{ @see apr_pollfd_t }
+  Papr_pollfd_t = ^apr_pollfd_t;
+
+  PPapr_pollfd_t = ^Papr_pollfd_t;
+
+{ Poll descriptor set. }
+  apr_pollfd_t = record
+    p: Papr_pool_t;              {< associated pool }
+    desc_type: apr_datatype_e;   {< descriptor type }
+    reqevents: apr_int16_t;      {< requested events }
+    rtnevents: apr_int16_t;      {< returned events }
+    desc: apr_descriptor;        {< @see apr_descriptor }
+    client_data: Pointer;        {< allows app to associate context }
+  end;
+
+{
+ * Setup the memory required for poll to operate properly
+ * @param new_poll The poll structure to be used. 
+ * @param num The number of socket descriptors to be polled.
+ * @param cont The pool to operate on.
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves.
+ }
+function apr_poll_setup(new_poll: PPapr_pollfd_t; num: apr_int32_t;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_poll_setup' + LibSuff12;
+
+{
+ * Poll the sockets in the poll structure
+ * @param aprset The poll structure we will be using. 
+ * @param numsock The number of sockets we are polling
+ * @param nsds The number of sockets signalled.
+ * @param timeout The amount of time in microseconds to wait.  This is 
+ *                a maximum, not a minimum.  If a socket is signalled, we 
+ *                will wake up before this time.  A negative number means 
+ *                wait until a socket is signalled.
+ * @remark
+ * <PRE>
+ * The number of sockets signalled is returned in the second argument. 
+ *
+ *        This is a blocking call, and it will not return until either a 
+ *        socket has been signalled, or the timeout has expired. 
+ * </PRE>
+ }
+function apr_poll(aprset: Papr_pollfd_t; numsock: apr_int32_t;
+ nsds: Papr_int32_t; timeout: apr_interval_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_poll' + LibSuff20;
+
+{
+ * Add a socket to the poll structure.
+ * @param aprset The poll structure we will be using. 
+ * @param sock The socket to add to the current poll structure. 
+ * @param event The events to look for when we do the poll.  One of:
+ * <PRE>
+ *            APR_POLLIN       signal if read will not block
+ *            APR_POLLPRI      signal if prioirty data is availble to be read
+ *            APR_POLLOUT      signal if write will not block
+ * </PRE>
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves.
+ }
+function apr_poll_socket_add(aprset: Papr_pollfd_t; sock: Papr_socket_t;
+ event: apr_int16_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_poll_socket_add' + LibSuff12;
+
+{
+ * Modify a socket in the poll structure with mask.
+ * @param aprset The poll structure we will be using. 
+ * @param sock The socket to modify in poll structure. 
+ * @param events The events to stop looking for during the poll.  One of:
+ * <PRE>
+ *            APR_POLLIN       signal if read will not block
+ *            APR_POLLPRI      signal if priority data is available to be read
+ *            APR_POLLOUT      signal if write will not block
+ * </PRE>
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves.
+ }
+function apr_poll_socket_mask(aprset: Papr_pollfd_t; sock: Papr_socket_t;
+ events: apr_int16_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_poll_socket_mask' + LibSuff12;
+
+{
+ * Remove a socket from the poll structure.
+ * @param aprset The poll structure we will be using. 
+ * @param sock The socket to remove from the current poll structure. 
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves.
+ }
+function apr_poll_socket_remove(aprset: Papr_pollfd_t; sock: Papr_socket_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_poll_socket_remove' + LibSuff8;
+
+{
+ * Clear all events in the poll structure.
+ * @param aprset The poll structure we will be using. 
+ * @param events The events to clear from all sockets.  One of:
+ * <PRE>
+ *            APR_POLLIN       signal if read will not block
+ *            APR_POLLPRI      signal if priority data is available to be read
+ *            APR_POLLOUT      signal if write will not block
+ * </PRE>
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves.
+ }
+function apr_poll_socket_clear(aprset: Papr_pollfd_t;
+ events: apr_int16_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_poll_socket_clear' + LibSuff8;
+
+{
+ * Get the return events for the specified socket.
+ * @param event The returned events for the socket.  One of:
+ * <PRE>
+ *            APR_POLLIN       Data is available to be read 
+ *            APR_POLLPRI      Priority data is availble to be read
+ *            APR_POLLOUT      Write will succeed
+ *            APR_POLLERR      An error occurred on the socket
+ *            APR_POLLHUP      The connection has been terminated
+ *            APR_POLLNVAL     This is an invalid socket to poll on.
+ *                             Socket not open.
+ * </PRE>
+ * @param sock The socket we wish to get information about. 
+ * @param aprset The poll structure we will be using. 
+ * @deprecated This function is deprecated, APR applications should control the pollset memory themselves.
+ }
+function apr_poll_revents_get(event: Papr_int16_t; sock: Papr_socket_t;
+ aprset: Papr_pollfd_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_poll_revents_get' + LibSuff12;
+
+{ General-purpose poll API for arbitrarily large numbers of
+ * file descriptors
+ }
+
+{ Opaque structure used for pollset API }
+type
+  apr_pollset_t = record end;
+  Papr_pollset_t = ^apr_pollset_t;
+  PPapr_pollset_t = ^Papr_pollset_t;
+
+{
+ * Setup a pollset object
+ * @param pollset  The pointer in which to return the newly created object 
+ * @param size The maximum number of descriptors that this pollset can hold
+ * @param p The pool from which to allocate the pollset
+ * @param flags Optional flags to modify the operation of the pollset
+ *              (reserved for future expansion)
+ }
+function apr_pollset_create(pollset: PPapr_pollset_t; size: apr_uint32_tso_handle_t;
+ p: Papr_pool_t; flags: apr_uint32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pollset_create' + LibSuff16;
+
+{
+ * Destroy a pollset object
+ * @param pollset The pollset to destroy
+ }
+function apr_pollset_destroy(pollset: Papr_pollset_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pollset_destroy' + LibSuff4;
+
+{
+ * Add a socket or file descriptor to a pollset
+ * @param pollset The pollset to which to add the descriptor
+ * @param descriptor The descriptor to add
+ * @remark If you set client_data in the descriptor, that value
+ *         will be returned in the client_data field whenever this
+ *         descriptor is signalled in apr_pollset_poll().
+ }
+function apr_pollset_add(pollset: Papr_pollset_t;
+ const descriptor: Papr_pollfd_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pollset_add' + LibSuff8;
+
+{
+ * Remove a descriptor from a pollset
+ * @param pollset The pollset from which to remove the descriptor
+ * @param descriptor The descriptor to remove
+ }
+function apr_pollset_remove(pollset: Papr_pollset_t;
+ const descriptor: Papr_pollfd_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pollset_remove' + LibSuff8;
+
+{
+ * Block for activity on the descriptor(s) in a pollset
+ * @param pollset The pollset to use
+ * @param timeout Timeout in microseconds
+ * @param num Number of signalled descriptors (output parameter)
+ * @param descriptors Array of signalled descriptors (output parameter)
+ }
+function apr_pollset_poll(pollset: Papr_pollset_t; timeout: apr_interval_time_t;
+ num: Papr_int32_t; const descriptors: PPapr_pollfd_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pollset_poll' + LibSuff20;
+

+ 707 - 0
packages/base/httpd/httpd-2.0/apr/apr_pools.inc

@@ -0,0 +1,707 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_pools.h
+ * @brief APR memory allocation
+ *
+ * Resource allocation routines...
+ *
+ * designed so that we don't have to keep track of EVERYTHING so that
+ * it can be explicitly freed later (a fundamentally unsound strategy ---
+ * particularly in the presence of die()).
+ *
+ * Instead, we maintain pools, and allocate items (both memory and I/O
+ * handlers) from the pools --- currently there are two, one for per
+ * transaction info, and one for config info.  When a transaction is over,
+ * we can delete everything in the per-transaction apr_pool_t without fear,
+ * and without thinking too hard about it either.
+ }
+
+{#include "apr.h"
+#include "apr_errno.h"
+#include "apr_general.h"{ { for APR_STRINGIFY }
+//#include "apr_want.h"
+
+{
+ * @defgroup apr_pools Memory Pool Functions
+ * @ingroup APR
+ * @
+ }
+
+{ The fundamental pool type }
+type
+  apr_pool_t = record end;
+  Papr_pool_t = ^apr_pool_t;
+  PPapr_pool_t = ^Papr_pool_t;
+
+{
+ * Declaration helper macro to construct apr_foo_pool_get()s.
+ *
+ * This standardized macro is used by opaque (APR) data types to return
+ * the apr_pool_t that is associated with the data type.
+ *
+ * APR_POOL_DECLARE_ACCESSOR() is used in a header file to declare the
+ * accessor function. A typical usage and result would be:
+ * <pre>
+ *    APR_POOL_DECLARE_ACCESSOR(file);
+ * becomes:
+ *    APR_DECLARE(apr_pool_t *) apr_file_pool_get(apr_file_t *ob);
+ * </pre>
+ * @remark Doxygen unwraps this macro (via doxygen.conf) to provide
+ * actual help for each specific occurance of apr_foo_pool_get.
+ * @remark the linkage is specified for APR. It would be possible to expand
+ *       the macros to support other linkages.
+ }
+{#define APR_POOL_DECLARE_ACCESSOR(type) \
+    APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \
+        (const apr_##type##_t *the##type)
+}
+{
+ * Implementation helper macro to provide apr_foo_pool_get()s.
+ *
+ * In the implementation, the APR_POOL_IMPLEMENT_ACCESSOR() is used to
+ * actually define the function. It assumes the field is named "pool".
+ }
+{#define APR_POOL_IMPLEMENT_ACCESSOR(type) \
+    APR_DECLARE(apr_pool_t *) apr_##type##_pool_get \
+            (const apr_##type##_t *the##type) \}
+        { return the##type->pool; }
+
+
+{
+ * Pool debug levels
+ *
+ * <pre>
+ * | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+ * ---------------------------------
+ * |   |   |   |   |   |   |   | x |  General debug code enabled (usefull in
+ *                                    combination with --with-efence).
+ *
+ * |   |   |   |   |   |   | x |   |  Verbose output on stderr (report
+ *                                    CREATE, CLEAR, DESTROY).
+ *
+ * |   |   |   | x |   |   |   |   |  Verbose output on stderr (report
+ *                                    PALLOC, PCALLOC).
+ *
+ * |   |   |   |   |   | x |   |   |  Lifetime checking. On each use of a
+ *                                    pool, check its lifetime.  If the pool
+ *                                    is out of scope, abort().
+ *                                    In combination with the verbose flag
+ *                                    above, it will output LIFE in such an
+ *                                    event prior to aborting.
+ *
+ * |   |   |   |   | x |   |   |   |  Pool owner checking.  On each use of a
+ *                                    pool, check if the current thread is the
+ *                                    pools owner.  If not, abort().  In
+ *                                    combination with the verbose flag above,
+ *                                    it will output OWNER in such an event
+ *                                    prior to aborting.  Use the debug
+ *                                    function apr_pool_owner_set() to switch
+ *                                    a pools ownership.
+ *
+ * When no debug level was specified, assume general debug mode.
+ * If level 0 was specified, debugging is switched off
+ * </pre>
+ }
+{#if defined(APR_POOL_DEBUG)
+#if (APR_POOL_DEBUG != 0) && (APR_POOL_DEBUG - 0 == 0)
+#undef APR_POOL_DEBUG
+#define APR_POOL_DEBUG 1
+#endif
+#else
+#define APR_POOL_DEBUG 0
+#endif
+}
+{ the place in the code where the particular function was called }
+//#define APR_POOL__FILE_LINE__ __FILE__ ":" APR_STRINGIFY(__LINE__)
+
+
+
+{ A function that is called when allocation fails. }
+type
+  apr_abortfunc_t = function (retcode: Integer): Integer;
+
+{
+ * APR memory structure manipulators (pools, tables, and arrays).
+ }
+
+{
+ * Initialization
+ }
+
+{
+ * Setup all of the internal structures required to use pools
+ * @remark Programs do NOT need to call this directly.  APR will call this
+ *      automatically from apr_initialize.
+ * @internal
+ }
+function apr_pool_initialize: apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_initialize' + LibSuff0;
+
+{
+ * Tear down all of the internal structures required to use pools
+ * @remark Programs do NOT need to call this directly.  APR will call this
+ *      automatically from apr_terminate.
+ * @internal
+ }
+procedure apr_pool_terminate;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_terminate' + LibSuff0;
+
+{
+ * Pool creation/destruction
+ }
+
+{$include apr_allocator.inc}
+
+{
+ * Create a new pool.
+ * @param newpool The pool we have just created.
+ * @param parent The parent pool.  If this is NULL, the new pool is a root
+ *        pool.  If it is non-NULL, the new pool will inherit all
+ *        of its parent pool's attributes, except the apr_pool_t will
+ *        be a sub-pool.
+ * @param abort_fn A function to use if the pool cannot allocate more memory.
+ * @param allocator The allocator to use with the new pool.  If NULL the
+ *        allocator of the parent pool will be used.
+ }
+function apr_pool_create_ex(newpool: PPapr_pool_t;
+ parent: Papr_pool_t; abort_fn: apr_abortfunc_t;
+ allocator: Papr_allocator_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_create_ex' + LibSuff16;
+
+{
+ * Debug version of apr_pool_create_ex.
+ * @param newpool @see apr_pool_create.
+ * @param parent @see apr_pool_create.
+ * @param abort_fn @see apr_pool_create.
+ * @param allocator @see apr_pool_create.
+ * @param file_line Where the function is called from.
+ *        This is usually APR_POOL__FILE_LINE__.
+ * @remark Only available when APR_POOL_DEBUG is defined.
+ *         Call this directly if you have you apr_pool_create_ex
+ *         calls in a wrapper function and wish to override
+ *         the file_line argument to reflect the caller of
+ *         your wrapper function.  If you do not have
+ *         apr_pool_create_ex in a wrapper, trust the macro
+ *         and don't call apr_pool_create_ex_debug directly.
+ }
+function apr_pool_create_ex_debug(newpool: PPapr_pool_t;
+ parent: Papr_pool_t; abort_fn: apr_abortfunc_t;
+ allocator: Papr_allocator_t; const file_line: PChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_create_ex_debug' + LibSuff20;
+
+{#if APR_POOL_DEBUG
+#define apr_pool_create_ex(newpool, parent, abort_fn, allocator)  \
+    apr_pool_create_ex_debug(newpool, parent, abort_fn, allocator, \
+                             APR_POOL__FILE_LINE__)
+#endif
+}
+{
+ * Create a new pool.
+ * @param newpool The pool we have just created.
+ * @param parent The parent pool.  If this is NULL, the new pool is a root
+ *        pool.  If it is non-NULL, the new pool will inherit all
+ *        of its parent pool's attributes, except the apr_pool_t will
+ *        be a sub-pool.
+ }
+{$ifdef DOXYGEN}
+function apr_pool_create(newpool: PPapr_pool_t;
+ parent: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_create' + LibSuff8;
+{$else}
+{.$ifdef APR_POOL_DEBUG}
+{#define apr_pool_create(newpool, parent) \
+    apr_pool_create_ex_debug(newpool, parent, NULL, NULL, \
+                             APR_POOL__FILE_LINE__)}
+{.$else}
+function apr_pool_create(newpool: PPapr_pool_t; parent: Papr_pool_t): apr_status_t;
+{.$endif}
+{$endif}
+
+{ @deprecated @see apr_pool_create_ex }
+{#if APR_POOL_DEBUG
+#define apr_pool_sub_make(newpool, parent, abort_fn) \
+    (void)apr_pool_create_ex_debug(newpool, parent, abort_fn, \
+                                   NULL, \
+                                   APR_POOL__FILE_LINE__)
+#else}
+function apr_pool_sub_make(newpool: PPapr_pool_t; parent: Papr_pool_t;
+ abort_fn: apr_abortfunc_t): apr_status_t;
+//#endif
+
+{
+ * Find the pools allocator
+ * @param pool The pool to get the allocator from.
+ }
+function apr_pool_allocator_get(pool: Papr_pool_t): Papr_allocator_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_allocator_get' + LibSuff4;
+
+{
+ * Clear all memory in the pool and run all the cleanups. This also destroys all
+ * subpools.
+ * @param p The pool to clear
+ * @remark This does not actually free the memory, it just allows the pool
+ *         to re-use this memory for the next allocation.
+ * @see apr_pool_destroy()
+ }
+procedure apr_pool_clear(p: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_clear' + LibSuff4;
+
+{
+ * Debug version of apr_pool_clear.
+ * @param p See: apr_pool_clear.
+ * @param file_line Where the function is called from.
+ *        This is usually APR_POOL__FILE_LINE__.
+ * @remark Only available when APR_POOL_DEBUG is defined.
+ *         Call this directly if you have you apr_pool_clear
+ *         calls in a wrapper function and wish to override
+ *         the file_line argument to reflect the caller of
+ *         your wrapper function.  If you do not have
+ *         apr_pool_clear in a wrapper, trust the macro
+ *         and don't call apr_pool_destroy_clear directly.
+ }
+procedure apr_pool_clear_debug(p: Papr_pool_t; const file_line: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_clear_debug' + LibSuff8;
+
+{#if APR_POOL_DEBUG
+#define apr_pool_clear(p) \
+    apr_pool_clear_debug(p, APR_POOL__FILE_LINE__)
+#endif}
+
+{
+ * Destroy the pool. This takes similar action as apr_pool_clear() and then
+ * frees all the memory.
+ * @param p The pool to destroy
+ * @remark This will actually free the memory
+ }
+procedure apr_pool_destroy(p: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_destroy' + LibSuff4;
+
+{
+ * Debug version of apr_pool_destroy.
+ * @param p See: apr_pool_destroy.
+ * @param file_line Where the function is called from.
+ *        This is usually APR_POOL__FILE_LINE__.
+ * @remark Only available when APR_POOL_DEBUG is defined.
+ *         Call this directly if you have you apr_pool_destroy
+ *         calls in a wrapper function and wish to override
+ *         the file_line argument to reflect the caller of
+ *         your wrapper function.  If you do not have
+ *         apr_pool_destroy in a wrapper, trust the macro
+ *         and don't call apr_pool_destroy_debug directly.
+ }
+procedure apr_pool_destroy_debug(p: Papr_pool_t; const file_line: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_destroy_debug' + LibSuff8;
+
+{#if APR_POOL_DEBUG
+#define apr_pool_destroy(p) \
+    apr_pool_destroy_debug(p, APR_POOL__FILE_LINE__)
+#endif}
+
+
+{
+ * Memory allocation
+ }
+
+{
+ * Allocate a block of memory from a pool
+ * @param p The pool to allocate from
+ * @param size The amount of memory to allocate
+ * @return The allocated memory
+ }
+function apr_palloc(p: Papr_pool_t; size: apr_size_t): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_palloc' + LibSuff8;
+
+{
+ * Debug version of apr_palloc
+ * @param p See: apr_palloc
+ * @param size See: apr_palloc
+ * @param file_line Where the function is called from.
+ *        This is usually APR_POOL__FILE_LINE__.
+ * @return See: apr_palloc
+ }
+function apr_palloc_debug(p: Papr_pool_t; size: apr_size_t;
+ const file_line: PChar): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_palloc_debug' + LibSuff12;
+
+{#if APR_POOL_DEBUG
+#define apr_palloc(p, size) \
+    apr_palloc_debug(p, size, APR_POOL__FILE_LINE__)
+#endif
+}
+{
+ * Allocate a block of memory from a pool and set all of the memory to 0
+ * @param p The pool to allocate from
+ * @param size The amount of memory to allocate
+ * @return The allocated memory
+ }
+{#if defined(DOXYGEN)}
+
+function apr_pcalloc(p: Papr_pool_t; size: apr_size_t): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pcalloc' + LibSuff8;
+
+{#elif !APR_POOL_DEBUG
+#define apr_pcalloc(p, size) memset(apr_palloc(p, size), 0, size)
+#endif
+}
+{
+ * Debug version of apr_pcalloc
+ * @param p See: apr_pcalloc
+ * @param size See: apr_pcalloc
+ * @param file_line Where the function is called from.
+ *        This is usually APR_POOL__FILE_LINE__.
+ * @return See: apr_pcalloc
+ }
+{APR_DECLARE(void *) apr_pcalloc_debug(apr_pool_t *p, apr_size_t size,
+                                      const char *file_line);
+
+#if APR_POOL_DEBUG
+#define apr_pcalloc(p, size) \
+    apr_pcalloc_debug(p, size, APR_POOL__FILE_LINE__)
+#endif
+
+}
+{
+ * Pool Properties
+ }
+
+{
+ * Set the function to be called when an allocation failure occurs.
+ * @remark If the program wants APR to exit on a memory allocation error,
+ *      then this function can be called to set the callback to use (for
+ *      performing cleanup and then exiting). If this function is not called,
+ *      then APR will return an error and expect the calling program to
+ *      deal with the error accordingly.
+ }
+procedure apr_pool_abort_set(abortfunc: apr_abortfunc_t; pool: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_abort_set' + LibSuff8;
+
+{ @deprecated @see apr_pool_abort_set }
+{APR_DECLARE(void) apr_pool_set_abort(apr_abortfunc_t abortfunc,
+                                     apr_pool_t *pool);
+}
+{
+ * Get the abort function associated with the specified pool.
+ * @param pool The pool for retrieving the abort function.
+ * @return The abort function for the given pool.
+ }
+function apr_pool_abort_get(pool: Papr_pool_t): apr_abortfunc_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_abort_get' + LibSuff4;
+
+{ @deprecated @see apr_pool_abort_get }
+//APR_DECLARE(apr_abortfunc_t) apr_pool_get_abort(apr_pool_t *pool);
+
+{
+ * Get the parent pool of the specified pool.
+ * @param pool The pool for retrieving the parent pool.
+ * @return The parent of the given pool.
+ }
+function apr_pool_parent_get(pool: Papr_pool_t): Papr_pool_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_parent_get' + LibSuff4;
+
+{ @deprecated @see apr_pool_parent_get }
+//APR_DECLARE(apr_pool_t *) apr_pool_get_parent(apr_pool_t *pool);
+
+{
+ * Determine if pool a is an ancestor of pool b
+ * @param a The pool to search
+ * @param b The pool to search for
+ * @return True if a is an ancestor of b, NULL is considered an ancestor
+ *         of all pools.
+ }
+function apr_pool_is_ancestor(a, b: Papr_pool_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_is_ancestor' + LibSuff8;
+
+{
+ * Tag a pool (give it a name)
+ * @param pool The pool to tag
+ * @param tag  The tag
+ }
+procedure apr_pool_tag(pool: Papr_pool_t; tag: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_tag' + LibSuff8;
+
+{
+ * User data management
+ }
+
+{
+ * Set the data associated with the current pool
+ * @param data The user data associated with the pool.
+ * @param key The key to use for association
+ * @param cleanup The cleanup program to use to cleanup the data (NULL if none)
+ * @param pool The current pool
+ * @warning The data to be attached to the pool should have a life span
+ *          at least as long as the pool it is being attached to.
+ *
+ *      Users of APR must take EXTREME care when choosing a key to
+ *      use for their data.  It is possible to accidentally overwrite
+ *      data by choosing a key that another part of the program is using.
+ *      Therefore it is advised that steps are taken to ensure that unique
+ *      keys are used for all of the userdata objects in a particular pool
+ *      (the same key in two different pools or a pool and one of its
+ *      subpools is okay) at all times.  Careful namespace prefixing of
+ *      key names is a typical way to help ensure this uniqueness.
+ }
+//function apr_pool_userdata_set(
+// const data: Pointer; const key: PChar;
+// cleanup: function(param: Pointer): apr_status_t,
+// pool: Papr_pool_t): apr_status_t;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibAPR name LibNamePrefix + 'apr_pool_userdata_set' + LibSuff20;
+
+{
+ * Set the data associated with the current pool
+ * @param data The user data associated with the pool.
+ * @param key The key to use for association
+ * @param cleanup The cleanup program to use to cleanup the data (NULL if none)
+ * @param pool The current pool
+ * @note same as apr_pool_userdata_set(), except that this version doesn't
+ *       make a copy of the key (this function is useful, for example, when
+ *       the key is a string literal)
+ * @warning This should NOT be used if the key could change addresses by
+ *       any means between the apr_pool_userdata_setn() call and a
+ *       subsequent apr_pool_userdata_get() on that key, such as if a
+ *       static string is used as a userdata key in a DSO and the DSO could
+ *       be unloaded and reloaded between the _setn() and the _get().  You
+ *       MUST use apr_pool_userdata_set() in such cases.
+ * @warning More generally, the key and the data to be attached to the
+ *       pool should have a life span at least as long as the pool itself.
+ *
+ }
+//function apr_pool_userdata_setn(
+// const data: Pointer; const key: PChar;
+// cleanup: function(param: Pointer): apr_status_t,
+// pool: Papr_pool_t): apr_status_t;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibAPR name LibNamePrefix + 'apr_pool_userdata_setn' + LibSuff20;
+
+{
+ * Return the data associated with the current pool.
+ * @param data The user data associated with the pool.
+ * @param key The key for the data to retrieve
+ * @param pool The current pool.
+ }
+function apr_pool_userdata_get(data: PPointer; const key: PChar;
+ pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_userdata_get' + LibSuff12;
+
+{
+ * Cleanup
+ *
+ * Cleanups are performed in the reverse order they were registered.  That is:
+ * Last In, First Out.
+ }
+
+{
+ * Register a function to be called when a pool is cleared or destroyed
+ * @param p The pool register the cleanup with
+ * @param data The data to pass to the cleanup function.
+ * @param plain_cleanup The function to call when the pool is cleared
+ *                      or destroyed
+ * @param child_cleanup The function to call when a child process is being
+ *                      shutdown - this function is called in the child, obviously!
+ }
+type
+  plain_cleanup_t = function(param: Pointer): apr_status_t; cdecl;
+  child_cleanup_t = function(param: Pointer): apr_status_t; cdecl;
+  
+procedure apr_pool_cleanup_register(p: Papr_pool_t;
+ const data: Pointer;
+ plain_cleanup: plain_cleanup_t;
+ child_cleanup: child_cleanup_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_cleanup_register' + LibSuff16;
+
+{
+ * Remove a previously registered cleanup function
+ * @param p The pool remove the cleanup from
+ * @param data The data to remove from cleanup
+ * @param cleanup The function to remove from cleanup
+ * @remarks For some strange reason only the plain_cleanup is handled by this
+ *          function
+ }
+//procedure  apr_pool_cleanup_for_exec;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0;
+
+//APR_DECLARE(void) apr_pool_cleanup_kill(apr_pool_t *p, const void *data,
+//                                        apr_status_t cleanup)(void );
+
+{
+ * Replace the child cleanup of a previously registered cleanup
+ * @param p The pool of the registered cleanup
+ * @param data The data of the registered cleanup
+ * @param plain_cleanup The plain cleanup function of the registered cleanup
+ * @param child_cleanup The function to register as the child cleanup
+ }
+//procedure  apr_pool_cleanup_for_exec;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0;
+
+{APR_DECLARE(void) apr_pool_child_cleanup_set(
+    apr_pool_t *p,
+    const void *data,
+    apr_status_t plain_cleanup)(void ,
+    apr_status_t child_cleanup)(void );
+}
+{
+ * Run the specified cleanup function immediately and unregister it. Use
+ * @a data instead of the data that was registered with the cleanup.
+ * @param p The pool remove the cleanup from
+ * @param data The data to remove from cleanup
+ * @param cleanup The function to remove from cleanup
+ }
+//procedure  apr_pool_cleanup_for_exec;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0;
+
+{APR_DECLARE(apr_status_t) apr_pool_cleanup_run(
+    apr_pool_t *p,
+    void *data,
+    apr_status_t cleanup)(void );}
+
+{
+ * An empty cleanup function
+ * @param data The data to cleanup
+ }
+//APR_DECLARE_NONSTD(apr_status_t) apr_pool_cleanup_null(void *data);
+
+{ Preparing for exec() --- close files, etc., but *don't* flush I/O
+ * buffers, *don't* wait for subprocesses, and *don't* free any memory.
+ }
+{
+ * Run all of the child_cleanups, so that any unnecessary files are
+ * closed because we are about to exec a new program
+ }
+procedure  apr_pool_cleanup_for_exec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_cleanup_for_exec' + LibSuff0;
+
+{
+ * @defgroup PoolDebug Pool Debugging functions.
+ *
+ * pools have nested lifetimes -- sub_pools are destroyed when the
+ * parent pool is cleared.  We allow certain liberties with operations
+ * on things such as tables (and on other structures in a more general
+ * sense) where we allow the caller to insert values into a table which
+ * were not allocated from the table's pool.  The table's data will
+ * remain valid as long as all the pools from which its values are
+ * allocated remain valid.
+ *
+ * For example, if B is a sub pool of A, and you build a table T in
+ * pool B, then it's safe to insert data allocated in A or B into T
+ * (because B lives at most as long as A does, and T is destroyed when
+ * B is cleared/destroyed).  On the other hand, if S is a table in
+ * pool A, it is safe to insert data allocated in A into S, but it
+ * is *not safe* to insert data allocated from B into S... because
+ * B can be cleared/destroyed before A is (which would leave dangling
+ * pointers in T's data structures).
+ *
+ * In general we say that it is safe to insert data into a table T
+ * if the data is allocated in any ancestor of T's pool.  This is the
+ * basis on which the APR_POOL_DEBUG code works -- it tests these ancestor
+ * relationships for all data inserted into tables.  APR_POOL_DEBUG also
+ * provides tools (apr_pool_find, and apr_pool_is_ancestor) for other
+ * folks to implement similar restrictions for their own data
+ * structures.
+ *
+ * However, sometimes this ancestor requirement is inconvenient --
+ * sometimes we're forced to create a sub pool (such as through
+ * apr_sub_req_lookup_uri), and the sub pool is guaranteed to have
+ * the same lifetime as the parent pool.  This is a guarantee implemented
+ * by the *caller*, not by the pool code.  That is, the caller guarantees
+ * they won't destroy the sub pool individually prior to destroying the
+ * parent pool.
+ *
+ * In this case the caller must call apr_pool_join() to indicate this
+ * guarantee to the APR_POOL_DEBUG code.  There are a few examples spread
+ * through the standard modules.
+ *
+ * These functions are only implemented when #APR_POOL_DEBUG is set.
+ *
+ }
+{$if defined(APR_POOL_DEBUG) or defined(DOXYGEN)}
+{
+ * Guarantee that a subpool has the same lifetime as the parent.
+ * @param p The parent pool
+ * @param sub The subpool
+ }
+procedure  apr_pool_join(p, sub: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_join' + LibSuff8;
+
+{
+ * Find a pool from something allocated in it.
+ * @param mem The thing allocated in the pool
+ * @return The pool it is allocated in
+ }
+function apr_pool_find(const mem: Pointer): Papr_pool_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_find' + LibSuff4;
+
+{
+ * Report the number of bytes currently in the pool
+ * @param p The pool to inspect
+ * @param recurse Recurse/include the subpools' sizes
+ * @return The number of bytes
+ }
+function apr_pool_num_bytes(p: Papr_pool_t; recurse: Integer): apr_size_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_num_bytes' + LibSuff8;
+
+{
+ * Lock a pool
+ * @param pool The pool to lock
+ * @param flag  The flag
+ }
+procedure  apr_pool_lock(pool: Papr_pool_t; flag: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_lock' + LibSuff8;
+
+{$else} { APR_POOL_DEBUG or DOXYGEN }
+
+{#ifdef apr_pool_join
+#undef apr_pool_join
+#endif
+#define apr_pool_join(a,b)
+
+#ifdef apr_pool_lock
+#undef apr_pool_lock
+#endif
+#define apr_pool_lock(pool, lock)}
+
+{$endif} { APR_POOL_DEBUG or DOXYGEN }
+

+ 540 - 0
packages/base/httpd/httpd-2.0/apr/apr_portable.inc

@@ -0,0 +1,540 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{ This header file is where you should put ANY platform specific information.
+ * This should be the only header file that programs need to include that 
+ * actually has platform dependant code which refers to the .
+ }
+
+{
+ * @file apr_portable.h
+ * @brief APR Portability Routines
+ }
+
+{#include "apr.h"
+#include "apr_pools.h"
+#include "apr_thread_proc.h"
+#include "apr_file_io.h"
+#include "apr_network_io.h"
+#include "apr_errno.h"
+#include "apr_global_mutex.h"
+#include "apr_proc_mutex.h"
+#include "apr_time.h"
+#include "apr_dso.h"
+#include "apr_shm.h"
+
+#if APR_HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+#if APR_HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#if APR_HAVE_PTHREAD_H
+#include <pthread.h>
+#endif}
+
+{
+ * @defgroup apr_portabile Portability Routines
+ * @ingroup APR 
+ }
+
+
+
+type
+
+{$ifdef WINDOWS}
+{ The primitives for Windows types }
+  apr_os_file_t = THandle;
+  apr_os_dir_t = THandle;
+  apr_os_sock_t = TSocket;
+  apr_os_proc_mutex_t = THandle;
+  apr_os_thread_t = THandle;
+  apr_os_proc_t = THandle;
+  apr_os_threadkey_t = Cardinal;
+  apr_os_imp_time_t = TFILETIME;
+  apr_os_exp_time_t = TSYSTEMTIME;
+  apr_os_dso_handle_t = THandle;
+  apr_os_shm_t = THandle;
+
+{$else}
+{$ifdef OS2}
+  HFILE                 apr_os_file_t;
+  HDIR                  apr_os_dir_t;
+  int                   apr_os_sock_t;
+  HMTX                  apr_os_proc_mutex_t;
+  TID                   apr_os_thread_t;
+  PID                   apr_os_proc_t;
+  PULONG                apr_os_threadkey_t;
+  struct timeval        apr_os_imp_time_t;
+  struct tm             apr_os_exp_time_t;
+  HMODULE               apr_os_dso_handle_t;
+  apr_os_shm_t: Pointer;
+
+{$else}
+{$ifdef BEOS}
+
+#include <kernel/OS.h>
+#include <kernel/image.h>
+
+  apr_os_proc_mutex_t = record
+    sem_id sem;
+    int32  ben;
+  end;
+
+  apr_os_file_t: cint;
+  DIR                   apr_os_dir_t;
+  apr_os_sock_t: cint;
+  struct apr_os_proc_mutex_t  apr_os_proc_mutex_t;
+  thread_id             apr_os_thread_t;
+  thread_id             apr_os_proc_t;
+  apr_os_threadkey_t: cint;
+  struct timeval        apr_os_imp_time_t;
+  struct tm             apr_os_exp_time_t;
+  image_id              apr_os_dso_handle_t;
+  apr_os_shm_t: Pointer;
+
+{$else}
+{$ifdef NETWARE}
+  apr_os_file_t: cint;
+  DIR                   apr_os_dir_t;
+  apr_os_sock_t: cint;
+  NXMutex_t             apr_os_proc_mutex_t;
+  NXThreadId_t          apr_os_thread_t;
+  long                  apr_os_proc_t;
+  NXKey_t               apr_os_threadkey_t;
+  struct timeval        apr_os_imp_time_t;
+  struct tm             apr_os_exp_time_t;
+  apr_os_dso_handle_t: Pointer;
+  apr_os_shm_t: Pointer;
+
+{$else}
+{ Any other OS should go above this one.  This is the lowest common
+ * denominator typedefs for  all UNIX-like systems.  :)
+ }
+
+{ Basic OS process mutex structure. }
+  apr_os_proc_mutex_t = record
+{$if defined(APR_HAS_SYSVSEM_SERIALIZE) or defined(APR_HAS_FCNTL_SERIALIZE) or defined(APR_HAS_FLOCK_SERIALIZE)}
+    crossproc: Integer;
+{$endif}
+{$ifdef APR_HAS_PROC_PTHREAD_SERIALIZE}
+    pthread_mutex_t *pthread_interproc;
+{$endif}
+{$ifdef APR_HAS_THREADS}
+    { If no threads, no need for thread locks }
+{$if APR_USE_PTHREAD_SERIALIZE}
+    pthread_mutex_t *intraproc;
+{$endif}
+{$endif}
+  end;
+
+  apr_os_file_t: Integer;        {< native file }
+typedef DIR                   apr_os_dir_t;         {< native dir }
+  apr_os_sock_t: Integer;        {< native dir }
+typedef struct apr_os_proc_mutex_t  apr_os_proc_mutex_t; {< native proces
+                                                          *   mutex
+                                                          }
+{$if defined(APR_HAS_THREADS) and defined(APR_HAVE_PTHREAD_H)}
+typedef pthread_t             apr_os_thread_t;      {< native thread }
+typedef pthread_key_t         apr_os_threadkey_t;   {< native thread address
+                                                     *   space }
+{$endif}
+typedef pid_t                 apr_os_proc_t;        {< native pid }
+typedef struct timeval        apr_os_imp_time_t;    {< native timeval }
+typedef struct tm             apr_os_exp_time_t;    {< native tm }
+{ @var apr_os_dso_handle_t
+ * native dso types
+ }
+{$ifdef HPUX}
+#include <dl.h>
+typedef shl_t                 apr_os_dso_handle_t;
+{$else}
+{$ifdef DARWIN}
+#include <mach-o/dyld.h>
+typedef NSModule              apr_os_dso_handle_t;
+{$else}
+typedef void *                apr_os_dso_handle_t;
+{$endif}
+{$endif}
+typedef void*                 apr_os_shm_t;         {< native SHM }
+
+{$endif}
+{$endif}
+{$endif}
+{$endif}
+
+  Papr_os_sock_t = ^apr_os_sock_t;
+  
+{
+ * @typedef apr_os_sock_info_t
+ * @brief alias for local OS socket
+ }
+{
+ * everything APR needs to know about an active socket to construct
+ * an APR socket from it; currently, this is platform-independent
+ }
+  apr_os_sock_info_t = record
+    os_sock: Papr_os_sock_t; {< always required }
+    local: Psockaddr; {< NULL if not yet bound }
+    remote: Psockaddr; {< NULL if not connected }
+    family: Integer;             {< always required (APR_INET, APR_INET6, etc.) }
+    type_: Integer;               {< always required (SOCK_STREAM, SOCK_DGRAM, etc.) }
+{$ifdef APR_ENABLE_FOR_1_0}   {< enable with APR 1.0 }
+    protocol: Integer;           {< 0 or actual protocol (APR_PROTO_SCTP, APR_PROTO_TCP, etc.) }
+{$endif}
+  end;
+
+  Papr_os_sock_info_t = ^apr_os_sock_info_t;
+
+{$if defined(APR_PROC_MUTEX_IS_GLOBAL) or defined(DOXYGEN)}
+{ Opaque global mutex type }
+#define apr_os_global_mutex_t apr_os_proc_mutex_t
+{ @return apr_os_global_mutex }
+#define apr_os_global_mutex_get apr_os_proc_mutex_get
+{$else}
+    { Thread and process mutex for those platforms where process mutexes
+     *  are not held in threads.
+     }
+    apr_os_global_mutex_t = record
+      pool: Papr_pool_t;
+      proc_mutex: Papr_proc_mutex_t;
+#if APR_HAS_THREADS
+      thread_mutex: Papr_proc_mutex_t;
+#endif { APR_HAS_THREADS }
+    end;
+    Papr_os_global_mutex_t = ^apr_os_global_mutex_t;
+
+APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmutex, 
+                                                apr_global_mutex_t *pmutex);
+{$endif}
+
+
+{
+ * convert the file from apr type to os specific type.
+ * @param thefile The os specific file we are converting to
+ * @param file The apr file to convert.
+ * @remark On Unix, it is only possible to get a file descriptor from 
+ *         an apr file type.
+ }
+function apr_os_file_get(thefile, file_: Papr_os_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_file_get' + LibSuff8;
+
+{
+ * convert the dir from apr type to os specific type.
+ * @param thedir The os specific dir we are converting to
+ * @param dir The apr dir to convert.
+ }
+function apr_os_dir_get(thedir: PPapr_os_dir_t; dir: Papr_dir_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_dir_get' + LibSuff8;
+
+{
+ * Convert the socket from an apr type to an OS specific socket
+ * @param thesock The socket to convert.
+ * @param sock The os specifc equivelant of the apr socket..
+ }
+function apr_os_sock_get(thesock, sock: Papr_os_sock_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_sock_get' + LibSuff8;
+
+{
+ * Convert the proc mutex from os specific type to apr type
+ * @param ospmutex The os specific proc mutex we are converting to.
+ * @param pmutex The apr proc mutex to convert.
+ }
+function apr_os_proc_mutex_get(ospmutex: Papr_os_proc_mutex_t;
+ pmutex: Papr_proc_mutex_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_proc_mutex_get' + LibSuff8;
+
+{
+ * Get the exploded time in the platforms native format.
+ * @param ostime the native time format
+ * @param aprtime the time to convert
+ }
+function apr_os_exp_time_get(ostime: PPapr_os_exp_time_t;
+ aprtime: Papr_time_exp_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_exp_time_get' + LibSuff8;
+
+{
+ * Get the imploded time in the platforms native format.
+ * @param ostime  the native time format
+ * @param aprtime the time to convert
+ }
+function apr_os_imp_time_get(ostime: PPapr_os_imp_time_t;
+ aprtime: Papr_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_imp_time_get' + LibSuff8;
+
+{
+ * convert the shm from apr type to os specific type.
+ * @param osshm The os specific shm representation
+ * @param shm The apr shm to convert.
+ }
+function apr_os_shm_get(osshm: Papr_os_shm_t; shm: Papr_shm_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_shm_get' + LibSuff8;
+
+{$if defined(APR_HAS_THREADS) or defined(DOXYGEN)}
+{
+ * @defgroup apr_os_thread Thread portability Routines
+ }
+{
+ * convert the thread to os specific type from apr type.
+ * @param thethd The apr thread to convert
+ * @param thd The os specific thread we are converting to
+ }
+function apr_os_thread_get(thethd: PPapr_os_thread_t;
+ thd: Papr_thread_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_thread_get' + LibSuff8;
+
+{
+ * convert the thread private memory key to os specific type from an apr type.
+ * @param thekey The apr handle we are converting from.
+ * @param key The os specific handle we are converting to.
+ }
+function apr_os_threadkey_get(thekey: Papr_os_threadkey_t;
+ key: Papr_threadkey_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_threadkey_get' + LibSuff8;
+
+{
+ * convert the thread from os specific type to apr type.
+ * @param thd The apr thread we are converting to.
+ * @param thethd The os specific thread to convert
+ * @param cont The pool to use if it is needed.
+ }
+function apr_os_thread_put(thd: PPapr_thread_t;
+ thethd: Papr_os_thread_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_thread_put' + LibSuff12;
+
+{
+ * convert the thread private memory key from os specific type to apr type.
+ * @param key The apr handle we are converting to.
+ * @param thekey The os specific handle to convert
+ * @param cont The pool to use if it is needed.
+ }
+function apr_os_threadkey_put(key: PPapr_threadkey_t;
+ thekey: Papr_os_threadkey_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_threadkey_put' + LibSuff12;
+
+{
+ * Get the thread ID
+ }
+function apr_os_thread_current: apr_os_thread_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_thread_current' + LibSuff0;
+
+{
+ * Compare two thread id's
+ * @param tid1 1st Thread ID to compare
+ * @param tid2 2nd Thread ID to compare
+ }
+function apr_os_thread_equal(tid1, tid2: apr_os_thread_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_thread_equal' + LibSuff8;
+
+{$endif} { APR_HAS_THREADS }
+
+{
+ * convert the file from os specific type to apr type.
+ * @param file The apr file we are converting to.
+ * @param thefile The os specific file to convert
+ * @param flags The flags that were used to open this file.
+ * @param cont The pool to use if it is needed.
+ * @remark On Unix, it is only possible to put a file descriptor into
+ *         an apr file type.
+ }
+function apr_os_file_put(file_: PPapr_file_t;
+ pthefilemutex: Papr_os_file_t; flags: apr_int32_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_file_put' + LibSuff16;
+
+{
+ * convert the file from os specific type to apr type.
+ * @param file The apr file we are converting to.
+ * @param thefile The os specific pipe to convert
+ * @param cont The pool to use if it is needed.
+ * @remark On Unix, it is only possible to put a file descriptor into
+ *         an apr file type.
+ }
+function apr_os_pipe_put(file_: PPapr_file_t;
+ thefile: Papr_os_file_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_pipe_put' + LibSuff12;
+
+{
+ * convert the file from os specific type to apr type.
+ * @param file The apr file we are converting to.
+ * @param thefile The os specific pipe to convert
+ * @param register_cleanup A cleanup will be registered on the apr_file_t
+ *   to issue apr_file_close().
+ * @param cont The pool to use if it is needed.
+ * @remark On Unix, it is only possible to put a file descriptor into
+ *         an apr file type.
+ }
+function apr_os_pipe_put_ex(file_: PPapr_file_t;
+ thefile: Papr_os_file_t; register_cleanup: Integer;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_pipe_put_ex' + LibSuff16;
+
+{
+ * convert the dir from os specific type to apr type.
+ * @param dir The apr dir we are converting to.
+ * @param thedir The os specific dir to convert
+ * @param cont The pool to use when creating to apr directory.
+ }
+function apr_os_dir_put(dir: PPapr_dir_t; thedir: Papr_os_dir_t;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_dir_put' + LibSuff12;
+
+{
+ * Convert a socket from the os specific type to the apr type
+ * @param sock The pool to use.
+ * @param thesock The socket to convert to.
+ * @param cont The socket we are converting to an apr type.
+ * @remark If it is a true socket, it is best to call apr_os_sock_make()
+ *         and provide APR with more information about the socket.
+ }
+function apr_os_sock_put(sock: PPapr_socket_t; thesock: Papr_socket_t;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_sock_put' + LibSuff8;
+
+{
+ * Create a socket from an existing descriptor and local and remote
+ * socket addresses.
+ * @param apr_sock The new socket that has been set up
+ * @param os_sock_info The os representation of the socket handle and
+ *        other characteristics of the socket
+ * @param cont The pool to use
+ * @remark If you only know the descriptor/handle or if it isn't really
+ *         a true socket, use apr_os_sock_put() instead.
+ }
+function apr_os_sock_make(apr_sock: PPapr_socket_t;
+ os_sock_info: Papr_os_sock_info_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_sock_make' + LibSuff12;
+
+{
+ * Convert the proc mutex from os specific type to apr type
+ * @param pmutex The apr proc mutex we are converting to.
+ * @param ospmutex The os specific proc mutex to convert.
+ * @param cont The pool to use if it is needed.
+ }
+function apr_os_proc_mutex_put(pmutex: PPapr_proc_mutex_t;
+ ospmutex: Papr_os_proc_mutex_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_proc_mutex_put' + LibSuff12;
+
+{
+ * Put the imploded time in the APR format.
+ * @param aprtime the APR time format
+ * @param ostime the time to convert
+ * @param cont the pool to use if necessary
+ }
+function apr_os_imp_time_put(aprtime: Papr_time_t;
+ ostime: PPapr_os_imp_time_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_imp_time_put' + LibSuff12;
+
+{
+ * Put the exploded time in the APR format.
+ * @param aprtime the APR time format
+ * @param ostime the time to convert
+ * @param cont the pool to use if necessary
+ }
+function apr_os_exp_time_put(aprtime: Papr_time_exp_t;
+ ostime: PPapr_os_exp_time_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_exp_time_put' + LibSuff12;
+
+{
+ * convert the shared memory from os specific type to apr type.
+ * @param shm The apr shm representation of osshm
+ * @param osshm The os specific shm identity
+ * @param cont The pool to use if it is needed.
+ * @remark On fork()ed architectures, this is typically nothing more than
+ * the memory block mapped.  On non-fork architectures, this is typically
+ * some internal handle to pass the mapping from process to process.
+ }
+function apr_os_shm_put(shm: PPapr_shm_t; osshm: Papr_os_shm_t;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_shm_put' + LibSuff8;
+
+{$if defined(APR_HAS_DSO) or defined(DOXYGEN)}
+{
+ * @defgroup apr_os_dso DSO (Dynamic Loading) Portabiliity Routines
+ }
+{
+ * convert the dso handle from os specific to apr
+ * @param dso The apr handle we are converting to
+ * @param thedso the os specific handle to convert
+ * @param pool the pool to use if it is needed
+ }
+function apr_os_dso_handle_put(dso: PPapr_dso_handle_t;
+ thedso: apr_os_dso_handle_t; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_dso_handle_put' + LibSuff12;
+
+{
+ * convert the apr dso handle into an os specific one
+ * @param aprdso The apr dso handle to convert
+ * @param dso The os specific dso to return
+ }
+function apr_os_dso_handle_get(dso: Papr_os_dso_handle_t;
+ aprdso: Papr_dso_handle_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_dso_handle_get' + LibSuff8;
+
+{$ifdef APR_HAS_OS_UUID}
+{
+ * Private: apr-util's apr_uuid module when supported by the platform
+ }
+function apr_os_uuid_get(uuid_data: PChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_uuid_get' + LibSuff8;
+{$endif}
+
+{$endif} { APR_HAS_DSO }
+
+
+{
+ * Get the name of the system default characer set.
+ * @param pool the pool to allocate the name from, if needed
+ }
+function apr_os_default_encoding(pool: Papr_pool_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_default_encoding' + LibSuff4;
+
+{
+ * Get the name of the current locale character set.
+ * @param pool the pool to allocate the name from, if needed
+ * @remark Defers to apr_os_default_encoding if the current locale's
+ * data can't be retreved on this system.
+ }
+function apr_os_locale_encoding(pool: Papr_pool_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_os_locale_encoding' + LibSuff4;
+

+ 90 - 0
packages/base/httpd/httpd-2.0/apr/apr_signal.inc

@@ -0,0 +1,90 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_signal.h 
+ * @brief APR Signal Handling
+ }
+
+{#include "apr.h"
+#include "apr_pools.h"
+
+#if APR_HAVE_SIGNAL_H
+#include <signal.h>
+#endif}
+
+{
+ * @defgroup apr_signal Handling
+ * @ingroup APR 
+ }
+
+{$if defined(APR_HAVE_SIGACTION) or defined(DOXYGEN)}
+
+{$ifdef DARWIN}
+{ work around Darwin header file bugs
+ *   http://www.opensource.apple.com/bugs/X/BSD%20Kernel/2657228.html
+ }
+#undef SIG_DFL
+#undef SIG_IGN
+#undef SIG_ERR
+#define SIG_DFL (void ( *)(int))0
+#define SIG_IGN (void ( *)(int))1
+#define SIG_ERR (void ( *)(int))-1
+{$endif}
+
+{ Function prototype for signal handlers }
+type apr_sigfunc_t = procedure(para: cint);
+
+{
+ * Set the signal handler function for a given signal
+ * @param signo The signal (eg... SIGWINCH)
+ * @param func the function to get called
+ }
+function apr_signal(signo: Integer; func: apr_sigfunc_t): Papr_sigfunc_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_signal' + LibSuff8;
+
+{if defined(SIG_IGN) && !defined(SIG_ERR)
+#define SIG_ERR ((apr_sigfunc_t *) -1)
+#endif
+
+#else} { !APR_HAVE_SIGACTION }
+{#define apr_signal(a, b) signal(a, b)
+#endif}
+
+
+{
+ * Get the description for a specific signal number
+ * @param signum The signal number
+ * @return The description of the signal
+ }
+function apr_signal_description_get(signo: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_signal_description_get' + LibSuff4;
+
+{ @deprecated @see apr_signal_description_get }
+function apr_signal_get_description(signo: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_signal_get_description' + LibSuff4;
+
+{
+ * APR-private function for initializing the signal package
+ * @internal
+ * @param pglobal The internal, global pool
+ }
+//void apr_signal_init(apr_pool_t *pglobal);
+
+{$endif}

+ 358 - 0
packages/base/httpd/httpd-2.0/apr/apr_strings.inc

@@ -0,0 +1,358 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{ Portions of this file are covered by }
+{ -*- mode: c; c-file-style: "k&r" -*-
+
+  strnatcmp.c -- Perform 'natural order' comparisons of strings in C.
+  Copyright (C) 2000 by Martin Pool <[email protected]>
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+}
+
+{
+ * @file apr_strings.h
+ * @brief APR Strings library
+ }
+
+{#include "apr.h"
+#include "apr_errno.h"
+#include "apr_pools.h"
+#define APR_WANT_IOVEC
+#include "apr_want.h"
+
+#if APR_HAVE_STDARG_H
+#include <stdarg.h>
+#endif}
+
+{
+ * @defgroup apr_strings String routines
+ * @ingroup APR 
+ }
+
+{
+ * Do a natural order comparison of two strings.
+ * @param a The first string to compare
+ * @param b The second string to compare
+ * @return Either <0, 0, or >0.  If the first string is less than the second
+ *          this returns <0, if they are equivalent it returns 0, and if the
+ *          first string is greater than second string it retuns >0.
+ }
+function apr_strnatcmp(a, b: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_strnatcmp' + LibSuff8;
+
+{
+ * Do a natural order comparison of two strings ignoring the case of the 
+ * strings.
+ * @param a The first string to compare
+ * @param b The second string to compare
+ * @return Either <0, 0, or >0.  If the first string is less than the second
+ *         this returns <0, if they are equivalent it returns 0, and if the
+ *         first string is greater than second string it retuns >0.
+ }
+function apr_strnatcasecmp(a, b: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_strnatcasecmp' + LibSuff8;
+
+{
+ * duplicate a string into memory allocated out of a pool
+ * @param p The pool to allocate out of
+ * @param s The string to duplicate
+ * @return The new string
+ }
+function apr_pstrdup(p: Papr_pool_t; s: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pstrdup' + LibSuff8;
+
+{
+ * Create a null-terminated string by making a copy of a sequence
+ * of characters and appending a null byte
+ * @param p The pool to allocate out of
+ * @param s The block of characters to duplicate
+ * @param n The number of characters to duplicate
+ * @return The new string
+ * @remark This is a faster alternative to apr_pstrndup, for use
+ *         when you know that the string being duplicated really
+ *         has 'n' or more characters.  If the string might contain
+ *         fewer characters, use apr_pstrndup.
+ }
+function apr_pstrmemdup(p: Papr_pool_t; s: PChar; n: apr_size_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pstrmemdup' + LibSuff12;
+
+{
+ * duplicate the first n characters of a string into memory allocated 
+ * out of a pool; the new string will be null-terminated
+ * @param p The pool to allocate out of
+ * @param s The string to duplicate
+ * @param n The number of characters to duplicate
+ * @return The new string
+ }
+function apr_pstrndup(p: Papr_pool_t; s: PChar; n: apr_size_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pstrndup' + LibSuff12;
+
+{
+ * Duplicate a block of memory.
+ *
+ * @param p The pool to allocate from
+ * @param m The memory to duplicate
+ * @param n The number of bytes to duplicate
+ * @return The new block of memory
+ }
+function apr_pmemdup(p: Papr_pool_t; m: Pointer; n: apr_size_t): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pmemdup' + LibSuff12;
+
+{
+ * Concatenate multiple strings, allocating memory out a pool
+ * @param p The pool to allocate out of
+ * @param ... The strings to concatenate.  The final string must be NULL
+ * @return The new string
+ }
+function apr_pstrcat(p: Papr_pool_t; others: array of const): PChar;
+ cdecl; external LibAPR name 'apr_pstrcat';
+
+{
+ * Concatenate multiple strings specified in a writev-style vector
+ * @param p The pool from which to allocate
+ * @param vec The strings to concatenate
+ * @param nvec The number of strings to concatenate
+ * @param nbytes (output) strlen of new string (pass in NULL to omit)
+ * @return The new string
+ }
+function apr_pstrcatv(p: Papr_pool_t; const vec: Piovec;
+ nvec: apr_size_t; nbytes: Papr_size_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pstrcatv' + LibSuff16;
+
+{
+ * printf-style style printing routine.  The data is output to a string 
+ * allocated from a pool
+ * @param p The pool to allocate out of
+ * @param fmt The format of the string
+ * @param ap The arguments to use while printing the data
+ * @return The new string
+ }
+function apr_pvsprintf(p: Papr_pool_t; const fmt: PChar; ap: va_list): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pvsprintf' + LibSuff12;
+
+{
+ * printf-style style printing routine.  The data is output to a string 
+ * allocated from a pool
+ * @param p The pool to allocate out of
+ * @param fmt The format of the string
+ * @param ... The arguments to use while printing the data
+ * @return The new string
+ }
+function apr_psprintf(p: Papr_pool_t; const fmt: PChar; others: array of const): PChar;
+ cdecl; external LibAPR name 'apr_psprintf';
+
+{
+ * copy n characters from src to dst
+ * @param dst The destination string
+ * @param src The source string
+ * @param dst_size The space available in dst; dst always receives
+ *                 null-termination, so if src is longer than
+ *                 dst_size, the actual number of characters copied is
+ *                 dst_size - 1.
+ * @remark
+ * <PRE>
+ * We re-implement this function to implement these specific changes:
+ *       1) strncpy() doesn't always null terminate and we want it to.
+ *       2) strncpy() null fills, which is bogus, esp. when copy 8byte strings
+ *          into 8k blocks.
+ *       3) Instead of returning the pointer to the beginning of the
+ *          destination string, we return a pointer to the terminating null
+ *          to allow us to check for truncation.
+ * </PRE>
+ }
+function apr_cpystrn(dst: PChar; const src: PChar;
+ dst_size: apr_size_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_cpystrn' + LibSuff12;
+
+{
+ * Strip spaces from a string
+ * @param dest The destination string.  It is okay to modify the string
+ *             in place.  Namely dest == src
+ * @param src The string to rid the spaces from.
+ }
+function apr_collapse_spaces(dst: PChar; const src: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_collapse_spaces' + LibSuff8;
+
+{
+ * Convert the arguments to a program from one string to an array of 
+ * strings terminated by a NULL pointer
+ * @param arg_str The arguments to convert
+ * @param argv_out Output location.  This is a pointer to an array of strings.
+ * @param token_context Pool to use.
+ }
+function apr_tokenize_to_argv(const arg_str: PChar;
+ var argv_out: PPChar; token_context: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_tokenize_to_argv' + LibSuff12;
+
+{
+ * Split a string into separate null-terminated tokens.  The tokens are 
+ * delimited in the string by one or more characters from the sep
+ * argument.
+ * @param str The string to separate; this should be specified on the
+ *            first call to apr_strtok() for a given string, and NULL
+ *            on subsequent calls.
+ * @param sep The set of delimiters
+ * @param last Internal state saved by apr_strtok() between calls.
+ * @return The next token from the string
+ }
+function apr_strtok(str: PChar;
+ const sep: PChar; last: PPChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_strtok' + LibSuff12;
+
+{
+ * @defgroup APR_Strings_Snprintf snprintf implementations
+ * @warning
+ * These are snprintf implementations based on apr_vformatter().
+ *
+ * Note that various standards and implementations disagree on the return
+ * value of snprintf, and side-effects due to %n in the formatting string.
+ * apr_snprintf (and apr_vsnprintf) behaves as follows:
+ *
+ * Process the format string until the entire string is exhausted, or
+ * the buffer fills.  If the buffer fills then stop processing immediately
+ * (so no further %n arguments are processed), and return the buffer
+ * length.  In all cases the buffer is NUL terminated. It will return the
+ * number of characters inserted into the buffer, not including the
+ * terminating NUL. As a special case, if len is 0, apr_snprintf will
+ * return the number of characters that would have been inserted if
+ * the buffer had been infinite (in this case, *buffer can be NULL)
+ *
+ * In no event does apr_snprintf return a negative number.
+ * @{
+ }
+
+{
+ * snprintf routine based on apr_vformatter.  This means it understands the
+ * same extensions.
+ * @param buf The buffer to write to
+ * @param len The size of the buffer
+ * @param format The format string
+ * @param ... The arguments to use to fill out the format string.
+ }
+function apr_snprintf(buf: PChar; len: apr_size_t;
+ const format: PChar; others: array of const): PChar;
+ cdecl; external LibAPR name 'apr_snprintf';
+
+{
+ * vsnprintf routine based on apr_vformatter.  This means it understands the
+ * same extensions.
+ * @param buf The buffer to write to
+ * @param len The size of the buffer
+ * @param format The format string
+ * @param ap The arguments to use to fill out the format string.
+ }
+function apr_vsnprintf(buf: PChar; len: apr_size_t;
+ const format: PChar; ap: va_list): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_vsnprintf' + LibSuff16;
+
+{
+ * create a string representation of an int, allocated from a pool
+ * @param p The pool from which to allocate
+ * @param n The number to format
+ * @return The string representation of the number
+ }
+function apr_itoa(p: Papr_pool_t; n: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_itoa' + LibSuff8;
+
+{
+ * create a string representation of a long, allocated from a pool
+ * @param p The pool from which to allocate
+ * @param n The number to format
+ * @return The string representation of the number
+ }
+function apr_ltoa(p: Papr_pool_t; n: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_ltoa' + LibSuff8;
+
+{
+ * create a string representation of an apr_off_t, allocated from a pool
+ * @param p The pool from which to allocate
+ * @param n The number to format
+ * @return The string representation of the number
+ }
+function apr_off_t_toa(p: Papr_pool_t; n: apr_off_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_off_t_toa' + LibSuff12;
+
+{
+ * parse a numeric string into a 64-bit numeric value
+ * @param buf The string to parse. It may contain optional whitespace,
+ *   followed by an optional '+' (positive, default) or '-' (negative)
+ *   character, followed by an optional '0x' prefix if base is 0 or 16,
+ *   followed by numeric digits appropriate for base.
+ * @param end A pointer to the end of the valid character in buf. If
+ *   not nil, it is set to the first invalid character in buf.
+ * @param base A numeric base in the range between 2 and 36 inclusive,
+ *   or 0.  If base is zero, buf will be treated as base ten unless its
+ *   digits are prefixed with '0x', in which case it will be treated as
+ *   base 16.
+ * @return The numeric value of the string.
+ }
+function apr_strtoi64(const buf: PChar; end_: PPChar; base: Integer): apr_int64_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_strtoi64' + LibSuff12;
+
+{
+ * parse a base-10 numeric string into a 64-bit numeric value.
+ * Equivalent to apr_strtoi64(buf, (char**)NULL, 10).
+ * @param buf The string to parse
+ * @return The numeric value of the string
+ }
+function apr_atoi64(const buf: PChar): apr_int64_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_atoi64' + LibSuff4;
+
+{
+ * Format a binary size (magnitiudes are 2^10 rather than 10^3) from an apr_off_t,
+ * as bytes, K, M, T, etc, to a four character compacted human readable string.
+ * @param size The size to format
+ * @param buf The 5 byte text buffer (counting the trailing null)
+ * @return The buf passed to apr_strfsize()
+ * @remark All negative sizes report '  - ', apr_strfsize only formats positive values.
+ }
+function apr_strfsize(size: apr_off_t; buf: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_strfsize' + LibSuff12;
+

+ 447 - 0
packages/base/httpd/httpd-2.0/apr/apr_tables.inc

@@ -0,0 +1,447 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_tables.h
+ * @brief APR Table library
+ }
+
+{
+ * @defgroup apr_tables Table and Array Functions
+ * @ingroup APR
+ * Tables are used to store entirely opaque structures
+ * for applications, while Arrays are usually used to
+ * deal with string lists.
+ }
+
+{ the table abstract data type }
+type
+  apr_table_t = record end;
+  Papr_table_t = ^apr_table_t;
+
+{ An opaque array type }
+  apr_array_header_t = record
+    { The pool the array is allocated out of }
+    pool: Papr_pool_t;
+    { The amount of memory allocated for each element of the array }
+    elt_size: Integer;
+    { The number of active elements in the array }
+    nelts: Integer;
+    { The number of elements allocated in the array }
+    nalloc: Integer;
+    { The elements in the array }
+    elts: PChar;
+  end;
+  Papr_array_header_t = ^apr_array_header_t;
+  PPapr_array_header_t = ^Papr_array_header_t;
+
+{
+ * The (opaque) structure for string-content tables.
+ }
+
+{ The type for each entry in a string-content table }
+  apr_table_entry_t = record
+    { The key for the current table entry }
+    key: PChar;          { maybe NULL in future;
+                         * check when iterating thru table_elts
+                         }
+    { The value for the current table entry }
+    val: PChar;
+
+    { A checksum for the key, for use by the apr_table internals }
+    key_checksum: apr_uint32_t;
+  end;
+
+{
+ * Get the elements from a table
+ * @param t The table
+ * @return An array containing the contents of the table
+ }
+function apr_table_elts(const t: Papr_table_t): Papr_array_header_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_elts' + LibSuff4;
+
+{
+ * Determine if the table is empty
+ * @param t The table to check
+ * @return True if empty, False otherwise
+ }
+function apr_is_empty_table(const t: Papr_table_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_is_empty_table' + LibSuff4;
+
+{
+ * Determine if the array is empty
+ * @param a The array to check
+ * @return True if empty, False otherwise
+ }
+function apr_is_empty_array(const a: Papr_array_header_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_is_empty_array' + LibSuff4;
+
+{
+ * Create an array
+ * @param p The pool to allocate the memory out of
+ * @param nelts the number of elements in the initial array
+ * @param elt_size The size of each element in the array.
+ * @return The new array
+ }
+function apr_array_make(p: Papr_pool_t;
+ nelts, elt_size: Integer): Papr_array_header_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_array_make' + LibSuff12;
+
+{
+ * Add a new element to an array
+ * @param arr The array to add an element to.
+ * @return Location for the new element in the array.
+ * @remark If there are no free spots in the array, then this function will
+ *         allocate new space for the new element.
+ }
+function apr_array_push(arr: Papr_array_header_t): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_array_push' + LibSuff4;
+
+{
+ * Remove an element from an array
+ * @param arr The array to remove an element from.
+ * @return Location of the element in the array.
+ * @remark If there are no elements in the array, NULL is returned.
+ }
+function apr_array_pop(arr: Papr_array_header_t): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_array_pop' + LibSuff4;
+
+{
+ * Concatenate two arrays together
+ * @param dst The destination array, and the one to go first in the combined
+ *            array
+ * @param src The source array to add to the destination array
+ }
+procedure apr_array_cat(dst: Papr_array_header_t;
+ const src: Papr_array_header_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_array_cat' + LibSuff8;
+
+{
+ * Copy the entire array
+ * @param p The pool to allocate the copy of the array out of
+ * @param arr The array to copy
+ * @return An exact copy of the array passed in
+ * @remark The alternate apr_array_copy_hdr copies only the header, and arranges
+ *         for the elements to be copied if (and only if) the code subsequently
+ *         does a push or arraycat.
+ }
+function apr_array_copy(p: Papr_pool_t;
+ const arr: Papr_array_header_t): Papr_array_header_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_array_copy' + LibSuff8;
+
+{
+ * Copy the headers of the array, and arrange for the elements to be copied if
+ * and only if the code subsequently does a push or arraycat.
+ * @param p The pool to allocate the copy of the array out of
+ * @param arr The array to copy
+ * @return An exact copy of the array passed in
+ * @remark The alternate apr_array_copy copies the *entire* array.
+ }
+function apr_array_copy_hdr(p: Papr_pool_t;
+ const arr: Papr_array_header_t): Papr_array_header_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_array_copy_hdr' + LibSuff8;
+
+{
+ * Append one array to the end of another, creating a new array in the process.
+ * @param p The pool to allocate the new array out of
+ * @param first The array to put first in the new array.
+ * @param second The array to put second in the new array.
+ * @return A new array containing the data from the two arrays passed in.
+}
+function apr_array_append(p: Papr_pool_t;
+ const first, second: Papr_array_header_t): Papr_array_header_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_array_append' + LibSuff12;
+
+{
+ * Generates a new string from the apr_pool_t containing the concatenated
+ * sequence of substrings referenced as elements within the array.  The string
+ * will be empty if all substrings are empty or null, or if there are no
+ * elements in the array.  If sep is non-NUL, it will be inserted between
+ * elements as a separator.
+ * @param p The pool to allocate the string out of
+ * @param arr The array to generate the string from
+ * @param sep The separator to use
+ * @return A string containing all of the data in the array.
+ }
+function apr_array_pstrcat(p: Papr_pool_t;
+ const arr: Papr_array_header_t; sep: Char): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_array_pstrcat' + LibSuff12;
+
+{
+ * Make a new table
+ * @param p The pool to allocate the pool out of
+ * @param nelts The number of elements in the initial table.
+ * @return The new table.
+ * @warning This table can only store text data
+ }
+function apr_table_make(p: Papr_pool_t; nelts: Integer): Papr_table_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_make' + LibSuff8;
+
+{
+ * Create a new table and copy another table into it
+ * @param p The pool to allocate the new table out of
+ * @param t The table to copy
+ * @return A copy of the table passed in
+ }
+function apr_table_copy(p: Papr_pool_t; const t: Papr_table_t): Papr_table_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_copy' + LibSuff8;
+
+{
+ * Delete all of the elements from a table
+ * @param t The table to clear
+ }
+procedure apr_table_clear(t: Papr_table_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_clear' + LibSuff4;
+
+{
+ * Get the value associated with a given key from the table.  After this call,
+ * The data is still in the table
+ * @param t The table to search for the key
+ * @param key The key to search for
+ * @return The value associated with the key
+ }
+function apr_table_get(t: Papr_table_t; key: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_get' + LibSuff8;
+
+{
+ * Add a key/value pair to a table, if another element already exists with the
+ * same key, this will over-write the old data.
+ * @param t The table to add the data to.
+ * @param key The key fo use
+ * @param val The value to add
+ * @remark When adding data, this function makes a copy of both the key and the
+ *         value.
+ }
+procedure apr_table_set(t: Papr_table_t; const key, val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_set' + LibSuff12;
+
+{
+ * Add a key/value pair to a table, if another element already exists with the
+ * same key, this will over-write the old data.
+ * @param t The table to add the data to.
+ * @param key The key to use
+ * @param val The value to add
+ * @warning When adding data, this function does not make a copy of the key or
+ *          the value, so care should be taken to ensure that the values will
+ *          not change after they have been added..
+ }
+procedure apr_table_setn(t: Papr_table_t; const key, val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_setn' + LibSuff12;
+
+{
+ * Remove data from the table
+ * @param t The table to remove data from
+ * @param key The key of the data being removed
+ }
+procedure apr_table_unset(t: Papr_table_t; const key: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_unset' + LibSuff8;
+
+{
+ * Add data to a table by merging the value with data that has already been
+ * stored
+ * @param t The table to search for the data
+ * @param key The key to merge data for
+ * @param val The data to add
+ * @remark If the key is not found, then this function acts like apr_table_add
+ }
+procedure apr_table_merge(t: Papr_table_t; const key, val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_merge' + LibSuff12;
+
+{
+ * Add data to a table by merging the value with data that has already been
+ * stored
+ * @param t The table to search for the data
+ * @param key The key to merge data for
+ * @param val The data to add
+ * @remark If the key is not found, then this function acts like apr_table_addn
+ }
+procedure apr_table_mergen(t: Papr_table_t; const key, val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_mergen' + LibSuff12;
+
+{
+ * Add data to a table, regardless of whether there is another element with the
+ * same key.
+ * @param t The table to add to
+ * @param key The key to use
+ * @param val The value to add.
+ * @remark When adding data, this function makes a copy of both the key and the
+ *         value.
+ }
+procedure apr_table_add(t: Papr_table_t; const key, val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_add' + LibSuff12;
+
+{
+ * Add data to a table, regardless of whether there is another element with the
+ * same key.
+ * @param t The table to add to
+ * @param key The key to use
+ * @param val The value to add.
+ * @remark When adding data, this function does not make a copy of the key or the
+ *         value, so care should be taken to ensure that the values will not
+ *         change after they have been added..
+ }
+procedure apr_table_addn(t: Papr_table_t; const key, val: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_addn' + LibSuff12;
+
+{
+ * Merge two tables into one new table
+ * @param p The pool to use for the new table
+ * @param overlay The first table to put in the new table
+ * @param base The table to add at the end of the new table
+ * @return A new table containing all of the data from the two passed in
+ }
+function apr_table_overlay(t: Papr_table_t;
+ const overlay, base: Papr_table_t): Papr_table_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_overlay' + LibSuff12;
+
+{
+ * Declaration prototype for the iterator callback function of apr_table_do()
+ * and apr_table_vdo().
+ * @param rec The data passed as the first argument to apr_table_[v]do()
+ * @param key The key from this iteration of the table
+ * @param value The value from this iteration of the table
+ * @remark Iteration continues while this callback function returns non-zero.
+ * To export the callback function for apr_table_[v]do() it must be declared
+ * in the _NONSTD convention.
+ }
+type
+  apr_table_do_callback_fn_t = function (rec: Pointer;
+   const key, value: PChar): Integer;
+   
+  Papr_table_do_callback_fn_t = ^apr_table_do_callback_fn_t;
+
+{
+ * Iterate over a table running the provided function once for every
+ * element in the table.  If there is data passed in as a vararg, then the
+ * function is only run on those elements whose key matches something in
+ * the vararg.  If the vararg is NULL, then every element is run through the
+ * function.  Iteration continues while the function returns non-zero.
+ * @param comp The function to run
+ * @param rec The data to pass as the first argument to the function
+ * @param t The table to iterate over
+ * @param ... The vararg.  If this is NULL, then all elements in the table are
+ *            run through the function, otherwise only those whose key matches
+ *            are run.
+ * @return FALSE if one of the comp() iterations returned zero; TRUE if all
+ *            iterations returned non-zero
+ * @see apr_table_do_callback_fn_t
+ }
+{APR_DECLARE_NONSTD(int) apr_table_do(apr_table_do_callback_fn_t *comp,
+                                     void *rec, const apr_table_t *t, ...);
+}
+{
+ * Iterate over a table running the provided function once for every
+ * element in the table.  If there is data passed in as a vararg, then the
+ * function is only run on those element's whose key matches something in
+ * the vararg.  If the vararg is NULL, then every element is run through the
+ * function.  Iteration continues while the function returns non-zero.
+ * @param comp The function to run
+ * @param rec The data to pass as the first argument to the function
+ * @param t The table to iterate over
+ * @param vp The vararg table.  If this is NULL, then all elements in the
+ *                table are run through the function, otherwise only those
+ *                whose key matches are run.
+ * @return FALSE if one of the comp() iterations returned zero; TRUE if all
+ *            iterations returned non-zero
+ * @see apr_table_do_callback_fn_t
+ }
+function apr_table_vdo(comp: Papr_table_do_callback_fn_t;
+ rec: Pointer; const t: Papr_table_t; vp: va_list): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_vdo' + LibSuff16;
+
+const
+  { flag for overlap to use apr_table_setn }
+  APR_OVERLAP_TABLES_SET = 0;
+  { flag for overlap to use apr_table_mergen }
+  APR_OVERLAP_TABLES_MERGE = 1;
+
+{
+ * For each element in table b, either use setn or mergen to add the data
+ * to table a.  Which method is used is determined by the flags passed in.
+ * @param a The table to add the data to.
+ * @param b The table to iterate over, adding its data to table a
+ * @param flags How to add the table to table a.  One of:
+ *          APR_OVERLAP_TABLES_SET        Use apr_table_setn
+ *          APR_OVERLAP_TABLES_MERGE      Use apr_table_mergen
+ * @remark  This function is highly optimized, and uses less memory and CPU cycles
+ *          than a function that just loops through table b calling other functions.
+ }
+{
+ *<PRE>
+ * Conceptually, apr_table_overlap does this:
+ *
+ *  apr_array_header_t *barr = apr_table_elts(b);
+ *  apr_table_entry_t *belt = (apr_table_entry_t *)barr->elts;
+ *  int i;
+ *
+ *  for (i = 0; i < barr->nelts; ++i) (
+ *      if (flags & APR_OVERLAP_TABLES_MERGE) (
+ *          apr_table_mergen(a, belt[i].key, belt[i].val);
+ *      )
+ *      else (
+ *          apr_table_setn(a, belt[i].key, belt[i].val);
+ *      )
+ *  )
+ *
+ *  Except that it is more efficient (less space and cpu-time) especially
+ *  when b has many elements.
+ *
+ *  Notice the assumptions on the keys and values in b -- they must be
+ *  in an ancestor of a's pool.  In practice b and a are usually from
+ *  the same pool.
+ * </PRE>
+ }
+procedure apr_table_overlap(a: Papr_table_t;
+ const b: Papr_table_t; flags: cuint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_overlap' + LibSuff12;
+
+{
+ * Eliminate redunandant entries in a table by either overwriting
+ * or merging duplicates
+ *
+ * @param t Table.
+ * @param flags APR_OVERLAP_TABLES_MERGE to merge, or
+ *              APR_OVERLAP_TABLES_SET to overwrite
+ }
+procedure apr_table_compress(t: Papr_table_t; flags: cuint);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_table_compress' + LibSuff8;
+

+ 845 - 0
packages/base/httpd/httpd-2.0/apr/apr_thread_proc.inc

@@ -0,0 +1,845 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_thread_proc.h
+ * @brief APR Thread and Process Library
+ }
+
+{#include "apr.h"
+#include "apr_file_io.h"
+#include "apr_pools.h"
+#include "apr_errno.h"
+
+#if APR_HAVE_STRUCT_RLIMIT
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif}
+
+{
+ * @defgroup apr_thread_proc Threads and Process Functions
+ * @ingroup APR 
+ }
+
+type
+  apr_cmdtype_e = (
+    APR_SHELLCMD,       {< use the shell to invoke the program }
+    APR_PROGRAM,        {< invoke the program directly, no copied env }
+    APR_PROGRAM_ENV,    {< invoke the program, replicating our environment }
+    APR_PROGRAM_PATH,   {< find program on PATH, use our environment }
+    APR_SHELLCMD_ENV    {< use the shell to invoke the program,
+                          *   replicating our environment      }
+  );
+
+  apr_wait_how_e = (
+    APR_WAIT,           {< wait for the specified process to finish }
+    APR_NOWAIT          {< do not wait -- just see if it has finished }
+  );
+
+{ I am specifically calling out the values so that the macros below make
+ * more sense.  Yes, I know I don't need to, but I am hoping this makes what
+ * I am doing more clear.  If you want to add more reasons to exit, continue
+ * to use bitmasks.
+ }
+  apr_exit_why_e = (
+    APR_PROC_EXIT = 1,          {< process exited normally }
+    APR_PROC_SIGNAL = 2,        {< process exited due to a signal }
+    APR_PROC_SIGNAL_CORE = 4    {< process exited and dumped a core file }
+  );
+  Papr_exit_why_e = ^apr_exit_why_e;
+
+{ did we exit the process }
+//#define APR_PROC_CHECK_EXIT(x)        (x & APR_PROC_EXIT)
+{ did we get a signal }
+//#define APR_PROC_CHECK_SIGNALED(x)    (x & APR_PROC_SIGNAL)
+{ did we get core }
+//#define APR_PROC_CHECK_CORE_DUMP(x)   (x & APR_PROC_SIGNAL_CORE)
+
+const
+{ @see apr_procattr_io_set }
+  APR_NO_PIPE         = 0;
+
+{ @see apr_procattr_io_set }
+  APR_FULL_BLOCK      = 1;
+{ @see apr_procattr_io_set }
+  APR_FULL_NONBLOCK   = 2;
+{ @see apr_procattr_io_set }
+  APR_PARENT_BLOCK    = 3;
+{ @see apr_procattr_io_set }
+  APR_CHILD_BLOCK     = 4;
+
+{ @see apr_procattr_limit_set }
+  APR_LIMIT_CPU       = 0;
+{ @see apr_procattr_limit_set }
+  APR_LIMIT_MEM       = 1;
+{ @see apr_procattr_limit_set }
+  APR_LIMIT_NPROC     = 2;
+{ @see apr_procattr_limit_set }
+  APR_LIMIT_NOFILE    = 3;
+
+{
+ * @defgroup APR_OC Other Child Flags
+ }
+  APR_OC_REASON_DEATH        = 0;     {< child has died, caller must call
+                                           * unregister still }
+  APR_OC_REASON_UNWRITABLE   = 1;     {< write_fd is unwritable }
+  APR_OC_REASON_RESTART      = 2;     {< a restart is occuring, perform
+                                           * any necessary cleanup (including
+                                           * sending a special signal to child)
+                                           }
+  APR_OC_REASON_UNREGISTER   = 3;     {< unregister has been called, do
+                                           * whatever is necessary (including
+                                           * kill the child) }
+  APR_OC_REASON_LOST         = 4;     {< somehow the child exited without
+                                           * us knowing ... buggy os? }
+  APR_OC_REASON_RUNNING      = 5;     {< a health check is occuring,
+                                           * for most maintainence functions
+                                           * this is a no-op.
+                                           }
+
+{ The APR process type }
+type
+  apr_proc_t = record
+    { The process ID }
+    pid: pid_t;
+    { Parent's side of pipe to child's stdin }
+    in_: Papr_file_t;
+    { Parent's side of pipe to child's stdout }
+    out_: Papr_file_t;
+    { Parent's side of pipe to child's stdouterr }
+    err: Papr_file_t;
+{$if defined(APR_HAS_PROC_INVOKED) or defined(DOXYGEN)}
+    { Diagnositics/debugging string of the command invoked for
+     *  this process [only present if APR_HAS_PROC_INVOKED is true]
+     * @remark Only enabled on Win32 by default.
+     * @bug This should either always or never be present in release
+     * builds - since it breaks binary compatibility.  We may enable
+     * it always in APR 1.0 yet leave it undefined in most cases.
+     }
+    invoked: PChar;
+{$endif}
+{$if defined(WIN32) or defined(DOXYGEN)}
+    { (Win32 only) Creator's handle granting access to the process
+     * @remark This handle is closed and reset to NULL in every case
+     * corresponding to a waitpid() on Unix which returns the exit status.
+     * Therefore Win32 correspond's to Unix's zombie reaping characteristics
+     * and avoids potential handle leaks.
+     }
+    hproc: HANDLE;
+{$endif}
+  end;
+  
+  Papr_proc_t = ^apr_proc_t;
+
+{
+ * The prototype for APR child errfn functions.  (See the description
+ * of apr_procattr_child_errfn_set() for more information.)
+ * It is passed the following parameters:
+ * @param pool Pool associated with the apr_proc_t.  If your child
+ *             error function needs user data, associate it with this
+ *             pool.
+ * @param err APR error code describing the error
+ * @param description Text description of type of processing which failed
+ }
+  apr_child_errfn_t = procedure (proc: Papr_pool_t;
+   err: apr_status_t; const description: PChar);
+
+{ Opaque Thread structure. }
+  apr_thread_t = record end;
+  Papr_thread_t = ^apr_thread_t;
+  PPapr_thread_t = ^Papr_thread_t;
+
+{ Opaque Thread attributes structure. }
+  apr_threadattr_t = record end;
+  Papr_threadattr_t = ^apr_threadattr_t;
+  PPapr_threadattr_t = ^Papr_threadattr_t;
+
+{ Opaque Process attributes structure. }
+  apr_procattr_t = record end;
+  Papr_procattr_t = ^apr_procattr_t;
+  PPapr_procattr_t = ^Papr_procattr_t;
+
+{ Opaque control variable for one-time atomic variables.  }
+  apr_thread_once_t = record end;
+  Papr_thread_once_t = ^apr_thread_once_t;
+  PPapr_thread_once_t = ^Papr_thread_once_t;
+
+{ Opaque thread private address space. }
+  apr_threadkey_t = record end;
+  Papr_threadkey_t = ^apr_threadkey_t;
+  PPapr_threadkey_t = ^Papr_threadkey_t;
+
+{ Opaque record of child process. }
+  apr_other_child_rec_t = record end;
+  Papr_other_child_rec_t = ^apr_other_child_rec_t;
+  PPapr_other_child_rec_t = ^Papr_other_child_rec_t;
+
+{
+ * The prototype for any APR thread worker functions.
+ }
+  apr_thread_start_t = function(param: Papr_thread_t; param2: Pointer): Pointer;
+
+  apr_kill_conditions_e = (
+    APR_KILL_NEVER,             {< process is never sent any signals }
+    APR_KILL_ALWAYS,            {< process is sent SIGKILL on apr_pool_t cleanup }
+    APR_KILL_AFTER_TIMEOUT,     {< SIGTERM, wait 3 seconds, SIGKILL }
+    APR_JUST_WAIT,              {< wait forever for the process to complete }
+    APR_KILL_ONLY_ONCE          {< send SIGTERM and then wait }
+  );
+
+{ Thread Function definitions }
+
+//{$if APR_HAS_THREADS}
+
+{
+ * Create and initialize a new threadattr variable
+ * @param new_attr The newly created threadattr.
+ * @param cont The pool to use
+ }
+function apr_threadattr_create(new_attr: PPapr_threadattr_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_threadattr_create' + LibSuff8;
+
+{
+ * Set if newly created threads should be created in detached state.
+ * @param attr The threadattr to affect 
+ * @param on Thread detach state on or off
+ }
+function apr_threadattr_detach_set(attr: Papr_threadattr_t; on_: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_threadattr_detach_set' + LibSuff8;
+
+{
+ * Get the detach state for this threadattr.
+ * @param attr The threadattr to reference 
+ }
+function apr_threadattr_detach_get(attr: PPapr_threadattr_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_threadattr_detach_get' + LibSuff4;
+
+{
+ * Set the stack size of newly created threads.
+ * @param attr The threadattr to affect 
+ * @param stacksize The stack size in bytes
+ }
+function apr_threadattr_stacksize_set(new_attr: PPapr_threadattr_t; stacksize: apr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_threadattr_stacksize_set' + LibSuff8;
+
+{
+ * Create a new thread of execution
+ * @param new_thread The newly created thread handle.
+ * @param attr The threadattr to use to determine how to create the thread
+ * @param func The function to start the new thread in
+ * @param data Any data to be passed to the starting function
+ * @param cont The pool to use
+ }
+function apr_thread_create(new_thread: PPapr_thread_t;
+ attr: Papr_threadattr_t; func: apr_thread_start_t;
+ data: Pointer; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_thread_create' + LibSuff20;
+
+{
+ * stop the current thread
+ * @param thd The thread to stop
+ * @param retval The return value to pass back to any thread that cares
+ }
+function apr_thread_exit(thd: Papr_thread_t; retval: apr_status_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_thread_exit' + LibSuff8;
+
+{
+ * block until the desired thread stops executing.
+ * @param retval The return value from the dead thread.
+ * @param thd The thread to join
+ }
+function apr_thread_join(retval: Papr_status_t; thd: Papr_thread_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_thread_join' + LibSuff8;
+
+{
+ * force the current thread to yield the processor
+ }
+procedure apr_thread_yield;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_thread_yield' + LibSuff0;
+
+{
+ * Initialize the control variable for apr_thread_once.  If this isn't
+ * called, apr_initialize won't work.
+ * @param control The control variable to initialize
+ * @param p The pool to allocate data from.
+ }
+function apr_thread_once_init(control: PPapr_thread_once_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_thread_once_init' + LibSuff8;
+
+{
+ * Run the specified function one time, regardless of how many threads
+ * call it.
+ * @param control The control variable.  The same variable should
+ *                be passed in each time the function is tried to be
+ *                called.  This is how the underlying functions determine
+ *                if the function has ever been called before.
+ * @param func The function to call.
+ }
+type
+  func_t = procedure;
+  
+function apr_thread_once(control: Papr_thread_once_t; func: func_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_thread_once' + LibSuff8;
+
+{
+ * detach a thread
+ * @param thd The thread to detach 
+ }
+function apr_thread_detach(thd: Papr_thread_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_thread_detach' + LibSuff4;
+
+{
+ * Return the pool associated with the current thread.
+ * @param data The user data associated with the thread.
+ * @param key The key to associate with the data
+ * @param thread The currently open thread.
+ }
+function apr_thread_data_get(data: PPointer; const key: PChar;
+ thread: Papr_thread_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_thread_data_get' + LibSuff12;
+
+{
+ * Return the pool associated with the current thread.
+ * @param data The user data to associate with the thread.
+ * @param key The key to use for associating the data with the thread
+ * @param cleanup The cleanup routine to use when the thread is destroyed.
+ * @param thread The currently open thread.
+ }
+function apr_thread_data_set(data: Pointer; const key: PChar;
+ cleanup: cleanup_t; thread: Papr_thread_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_thread_data_set' + LibSuff16;
+
+{
+ * Create and initialize a new thread private address space
+ * @param key The thread private handle.
+ * @param dest The destructor to use when freeing the private memory.
+ * @param cont The pool to use
+ }
+type
+  dest_t = procedure (param: Pointer);
+  
+function apr_threadkey_private_create(key: PPapr_threadkey_t;
+ dest: dest_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_threadkey_private_create' + LibSuff12;
+
+{
+ * Get a pointer to the thread private memory
+ * @param new_mem The data stored in private memory 
+ * @param key The handle for the desired thread private memory 
+ }
+function apr_threadkey_private_get(new_mem: PPointer; key: Papr_threadkey_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_threadkey_private_get' + LibSuff8;
+
+{
+ * Set the data to be stored in thread private memory
+ * @param priv The data to be stored in private memory 
+ * @param key The handle for the desired thread private memory 
+ }
+function apr_threadkey_private_set(priv: Pointer; key: Papr_threadkey_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_threadkey_private_set' + LibSuff8;
+
+{
+ * Free the thread private memory
+ * @param key The handle for the desired thread private memory 
+ }
+function apr_threadkey_private_delete(key: Papr_threadkey_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_threadkey_private_delete' + LibSuff4;
+
+{
+ * Return the pool associated with the current threadkey.
+ * @param data The user data associated with the threadkey.
+ * @param key The key associated with the data
+ * @param threadkey The currently open threadkey.
+ }
+function apr_threadkey_data_get(data: PPointer; const key: PChar;
+ threadkey: Papr_threadkey_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_threadkey_data_get' + LibSuff12;
+
+{
+ * Return the pool associated with the current threadkey.
+ * @param data The data to set.
+ * @param key The key to associate with the data.
+ * @param cleanup The cleanup routine to use when the file is destroyed.
+ * @param threadkey The currently open threadkey.
+ }
+function apr_threadkey_data_set(data: Pointer; const key: PChar;
+ cleanup: cleanup_t; threadkey: Papr_threadkey_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_threadkey_data_set' + LibSuff16;
+
+{.$endif}
+
+{
+ * Create and initialize a new procattr variable
+ * @param new_attr The newly created procattr. 
+ * @param cont The pool to use
+ }
+function apr_procattr_create(new_attr: PPapr_procattr_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_create' + LibSuff8;
+
+{
+ * Determine if any of stdin, stdout, or stderr should be linked to pipes 
+ * when starting a child process.
+ * @param attr The procattr we care about. 
+ * @param in Should stdin be a pipe back to the parent?
+ * @param out Should stdout be a pipe back to the parent?
+ * @param err Should stderr be a pipe back to the parent?
+ }
+function apr_procattr_io_set(attr: Papr_procattr_t;
+ in_, out_, err: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_io_set' + LibSuff16;
+
+{
+ * Set the child_in and/or parent_in values to existing apr_file_t values.
+ * @param attr The procattr we care about. 
+ * @param child_in apr_file_t value to use as child_in. Must be a valid file.
+ * @param parent_in apr_file_t value to use as parent_in. Must be a valid file.
+ * @remark  This is NOT a required initializer function. This is
+ *          useful if you have already opened a pipe (or multiple files)
+ *          that you wish to use, perhaps persistently across multiple
+ *          process invocations - such as a log file. You can save some 
+ *          extra function calls by not creating your own pipe since this
+ *          creates one in the process space for you.
+ }
+function apr_procattr_child_in_set(attr: Papr_procattr_t;
+ child_in, parent_in: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_child_in_set' + LibSuff12;
+
+{
+ * Set the child_out and parent_out values to existing apr_file_t values.
+ * @param attr The procattr we care about. 
+ * @param child_out apr_file_t value to use as child_out. Must be a valid file.
+ * @param parent_out apr_file_t value to use as parent_out. Must be a valid file.
+ * @remark This is NOT a required initializer function. This is
+ *         useful if you have already opened a pipe (or multiple files)
+ *         that you wish to use, perhaps persistently across multiple
+ *         process invocations - such as a log file. 
+ }
+function apr_procattr_child_out_set(attr: Papr_procattr_t;
+ child_out, parent_out: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_child_out_set' + LibSuff12;
+
+{
+ * Set the child_err and parent_err values to existing apr_file_t values.
+ * @param attr The procattr we care about. 
+ * @param child_err apr_file_t value to use as child_err. Must be a valid file.
+ * @param parent_err apr_file_t value to use as parent_err. Must be a valid file.
+ * @remark This is NOT a required initializer function. This is
+ *         useful if you have already opened a pipe (or multiple files)
+ *         that you wish to use, perhaps persistently across multiple
+ *         process invocations - such as a log file. 
+ }
+function apr_procattr_child_err_set(attr: Papr_procattr_t;
+ child_err, parent_err: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_child_err_set' + LibSuff12;
+
+{
+ * Set which directory the child process should start executing in.
+ * @param attr The procattr we care about. 
+ * @param dir Which dir to start in.  By default, this is the same dir as
+ *            the parent currently resides in, when the createprocess call
+ *            is made. 
+ }
+function apr_procattr_dir_set(attr: Papr_procattr_t; const dir: PChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_dir_set' + LibSuff8;
+
+{
+ * Set what type of command the child process will call.
+ * @param attr The procattr we care about. 
+ * @param cmd The type of command.  One of:
+ * <PRE>
+ *            APR_SHELLCMD     --  Anything that the shell can handle
+ *            APR_PROGRAM      --  Executable program   (default) 
+ *            APR_PROGRAM_ENV  --  Executable program, copy environment
+ *            APR_PROGRAM_PATH --  Executable program on PATH, copy env
+ * </PRE>
+ }
+function apr_procattr_cmdtype_set(attr: Papr_procattr_t; cmd: apr_cmdtype_e): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_cmdtype_set' + LibSuff8;
+
+{
+ * Determine if the child should start in detached state.
+ * @param attr The procattr we care about. 
+ * @param detach Should the child start in detached state?  Default is no. 
+ }
+function apr_procattr_detach_set(attr: Papr_procattr_t; detach: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_detach_set' + LibSuff8;
+
+{$ifdef APR_HAVE_STRUCT_RLIMIT}
+{
+ * Set the Resource Utilization limits when starting a new process.
+ * @param attr The procattr we care about. 
+ * @param what Which limit to set, one of:
+ * <PRE>
+ *                 APR_LIMIT_CPU
+ *                 APR_LIMIT_MEM
+ *                 APR_LIMIT_NPROC
+ *                 APR_LIMIT_NOFILE
+ * </PRE>
+ * @param limit Value to set the limit to.
+ }
+function apr_procattr_limit_set(attr: Papr_procattr_t; what: apr_int32_t;
+ limit: Pointer): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_limit_set' + LibSuff12;
+
+{$endif}
+
+{
+ * Specify an error function to be called in the child process if APR
+ * encounters an error in the child prior to running the specified program.
+ * @param attr The procattr describing the child process to be created.
+ * @param errfn The function to call in the child process.
+ * @remark At the present time, it will only be called from apr_proc_create()
+ *         on platforms where fork() is used.  It will never be called on other
+ *         platforms, on those platforms apr_proc_create() will return the error
+ *         in the parent process rather than invoke the callback in the now-forked
+ *         child process.
+ }
+function apr_procattr_child_errfn_set(attr: Papr_procattr_t; errfn: apr_child_errfn_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_child_errfn_set' + LibSuff8;
+
+{
+ * Specify that apr_proc_create() should do whatever it can to report
+ * failures to the caller of apr_proc_create(), rather than find out in
+ * the child.
+ * @param attr The procattr describing the child process to be created.
+ * @param chk Flag to indicate whether or not extra work should be done
+ *            to try to report failures to the caller.
+ * @remark This flag only affects apr_proc_create() on platforms where
+ *         fork() is used.  This leads to extra overhead in the calling
+ *         process, but that may help the application handle such
+ *         errors more gracefully.
+ }
+function apr_procattr_error_check_set(attr: Papr_procattr_t; chk: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_error_check_set' + LibSuff8;
+
+{
+ * Determine if the child should start in its own address space or using the 
+ * current one from its parent
+ * @param attr The procattr we care about. 
+ * @param addrspace Should the child start in its own address space?  Default
+ *                  is no on NetWare and yes on other platforms.
+ }
+function apr_procattr_addrspace_set(attr: Papr_procattr_t; addrspace: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_procattr_addrspace_set' + LibSuff8;
+
+{$ifdef APR_HAS_FORK}
+{
+ * This is currently the only non-portable call in APR.  This executes 
+ * a standard unix fork.
+ * @param proc The resulting process handle. 
+ * @param cont The pool to use. 
+ }
+function apr_proc_fork(proc: Papr_proc_t; cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_fork' + LibSuff8;
+
+{$endif}
+
+{
+ * Create a new process and execute a new program within that process.
+ * @param new_proc The resulting process handle.
+ * @param progname The program to run 
+ * @param args the arguments to pass to the new program.  The first 
+ *             one should be the program name.
+ * @param env The new environment table for the new process.  This 
+ *            should be a list of NULL-terminated strings. This argument
+ *            is ignored for APR_PROGRAM_ENV, APR_PROGRAM_PATH, and
+ *            APR_SHELLCMD_ENV types of commands.
+ * @param attr the procattr we should use to determine how to create the new
+ *         process
+ * @param cont The pool to use. 
+ }
+function apr_proc_create(new_proc: Papr_proc_t;
+ const progname: PChar; args, arnv: PPChar;
+ attr: Papr_procattr_t;
+ cont: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_create' + LibSuff24;
+
+{
+ * Wait for a child process to die
+ * @param proc The process handle that corresponds to the desired child process 
+ * @param exitcode The returned exit status of the child, if a child process 
+ *                 dies, or the signal that caused the child to die.
+ *                 On platforms that don't support obtaining this information, 
+ *                 the status parameter will be returned as APR_ENOTIMPL.
+ * @param exitwhy Why the child died, the bitwise or of:
+ * <PRE>
+ *            APR_PROC_EXIT         -- process terminated normally
+ *            APR_PROC_SIGNAL       -- process was killed by a signal
+ *            APR_PROC_SIGNAL_CORE  -- process was killed by a signal, and
+ *                                     generated a core dump.
+ * </PRE>
+ * @param waithow How should we wait.  One of:
+ * <PRE>
+ *            APR_WAIT   -- block until the child process dies.
+ *            APR_NOWAIT -- return immediately regardless of if the 
+ *                          child is dead or not.
+ * </PRE>
+ * @remark The childs status is in the return code to this process.  It is one of:
+ * <PRE>
+ *            APR_CHILD_DONE     -- child is no longer running.
+ *            APR_CHILD_NOTDONE  -- child is still running.
+ * </PRE>
+ }
+function apr_proc_wait(proc: Papr_proc_t; exitcode: PInteger;
+ exitwhy: Papr_exit_why_e; waithow: apr_wait_how_e): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_wait' + LibSuff16;
+
+{
+ * Wait for any current child process to die and return information 
+ * about that child.
+ * @param proc Pointer to NULL on entry, will be filled out with child's 
+ *             information 
+ * @param exitcode The returned exit status of the child, if a child process 
+ *                 dies, or the signal that caused the child to die.
+ *                 On platforms that don't support obtaining this information, 
+ *                 the status parameter will be returned as APR_ENOTIMPL.
+ * @param exitwhy Why the child died, the bitwise or of:
+ * <PRE>
+ *            APR_PROC_EXIT         -- process terminated normally
+ *            APR_PROC_SIGNAL       -- process was killed by a signal
+ *            APR_PROC_SIGNAL_CORE  -- process was killed by a signal, and
+ *                                     generated a core dump.
+ * </PRE>
+ * @param waithow How should we wait.  One of:
+ * <PRE>
+ *            APR_WAIT   -- block until the child process dies.
+ *            APR_NOWAIT -- return immediately regardless of if the 
+ *                          child is dead or not.
+ * </PRE>
+ * @param p Pool to allocate child information out of.
+ * @bug Passing proc as a *proc rather than **proc was an odd choice
+ * for some platforms... this should be revisited in 1.0
+ }
+function apr_proc_wait_all_procs(proc: Papr_proc_t; exitcode: PInteger;
+ exitwhy: Papr_exit_why_e; waithow: apr_wait_how_e;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_wait_all_procs' + LibSuff20;
+
+const
+  APR_PROC_DETACH_FOREGROUND = 0;    {< Do not detach }
+  APR_PROC_DETACH_DAEMONIZE = 1;     {< Detach }
+
+{
+ * Detach the process from the controlling terminal.
+ * @param daemonize set to non-zero if the process should daemonize
+ *                  and become a background process, else it will
+ *                  stay in the foreground.
+ }
+{ Not present on the dll }
+//function apr_proc_detach(daemonize: Integer): apr_status_t;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibAPR name LibNamePrefix + 'apr_proc_detach' + LibSuff4;
+
+{
+ * Register an other_child -- a child associated to its registered 
+ * maintence callback.  This callback is invoked when the process
+ * dies, is disconnected or disappears.
+ * @param proc The child process to register.
+ * @param maintenance maintenance is a function that is invoked with a 
+ *                    reason and the data pointer passed here.
+ * @param data Opaque context data passed to the maintenance function.
+ * @param write_fd An fd that is probed for writing.  If it is ever unwritable
+ *                 then the maintenance is invoked with reason 
+ *                 OC_REASON_UNWRITABLE.
+ * @param p The pool to use for allocating memory.
+ * @bug write_fd duplicates the proc->out stream, it's really redundant
+ * and should be replaced in the APR 1.0 API with a bitflag of which
+ * proc->in/out/err handles should be health checked.
+ * @bug no platform currently tests the pipes health.
+ }
+type
+  maintenance_t = procedure (reason: Integer; param: Pointer; status: Integer);
+  
+procedure apr_proc_other_child_register(proc: Papr_proc_t;
+ maintenance: maintenance_t; data: Pointer; write_fd: Papr_file_t;
+ p: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_other_child_register' + LibSuff20;
+
+{
+ * Stop watching the specified other child.  
+ * @param data The data to pass to the maintenance function.  This is
+ *             used to find the process to unregister.
+ * @warning Since this can be called by a maintenance function while we're
+ *          scanning the other_children list, all scanners should protect 
+ *          themself by loading ocr->next before calling any maintenance 
+ *          function.
+ }
+procedure apr_proc_other_child_unregister(data: Pointer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_other_child_unregister' + LibSuff4;
+
+{
+ * Notify the maintenance callback of a registered other child process
+ * that application has detected an event, such as death.
+ * @param proc The process to check
+ * @param reason The reason code to pass to the maintenance function
+ * @param status The status to pass to the maintenance function
+ * @remark An example of code using this behavior;
+ * <pre>
+ * rv = apr_proc_wait_all_procs(&proc, &exitcode, &status, APR_WAIT, p);
+ * if (APR_STATUS_IS_CHILD_DONE(rv)) (
+ * #if APR_HAS_OTHER_CHILD
+ *     if (apr_proc_other_child_alert(&proc, APR_OC_REASON_DEATH, status)
+ *             == APR_SUCCESS) (
+ *         ;  (already handled)
+ *     )
+ *     else
+ * #endif
+ *         [... handling non-otherchild processes death ...]
+ * </pre>
+ }
+function apr_proc_other_child_alert(proc: Papr_proc_t;
+ reason, status: Integer): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_other_child_alert' + LibSuff12;
+
+{
+ * Test one specific other child processes and invoke the maintenance callback 
+ * with the appropriate reason code, if still running, or the appropriate reason 
+ * code if the process is no longer healthy.
+ * @param ocr The registered other child
+ * @param reason The reason code (e.g. APR_OC_REASON_RESTART) if still running
+ }
+procedure apr_proc_other_child_refresh(ocr: Papr_other_child_rec_t; reason: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_other_child_refresh' + LibSuff8;
+
+{
+ * Test all registered other child processes and invoke the maintenance callback 
+ * with the appropriate reason code, if still running, or the appropriate reason 
+ * code if the process is no longer healthy.
+ * @param reason The reason code (e.g. APR_OC_REASON_RESTART) to running processes
+ }
+procedure apr_proc_other_child_refresh_all(reason: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_other_child_refresh_all' + LibSuff4;
+
+{ @deprecated @see apr_proc_other_child_refresh_all
+ * @remark Call apr_proc_other_child_refresh_all(APR_OC_REASON_RESTART)
+ * or apr_proc_other_child_refresh_all(APR_OC_REASON_RUNNING) instead.
+ * @bug The differing implementations of this function on Win32 (_RUNNING checks) 
+ * and Unix (used only for _RESTART) are the reason it will be dropped with APR 1.0.
+ }
+procedure apr_proc_other_child_check;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_other_child_check' + LibSuff0;
+
+{ @deprecated @see apr_proc_other_child_alert
+ * @bug This function's name had nothing to do with it's purpose
+ }
+function apr_proc_other_child_read(proc: Papr_proc_t; status: Integer): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_other_child_read' + LibSuff8;
+
+{
+ * Terminate a process.
+ * @param proc The process to terminate.
+ * @param sig How to kill the process.
+ }
+function apr_proc_kill(proc: Papr_proc_t; sig: Integer): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_proc_kill' + LibSuff8;
+
+{
+ * Register a process to be killed when a pool dies.
+ * @param a The pool to use to define the processes lifetime 
+ * @param proc The process to register
+ * @param how How to kill the process, one of:
+ * <PRE>
+ *         APR_KILL_NEVER         -- process is never sent any signals
+ *         APR_KILL_ALWAYS        -- process is sent SIGKILL on apr_pool_t cleanup
+ *         APR_KILL_AFTER_TIMEOUT -- SIGTERM, wait 3 seconds, SIGKILL
+ *         APR_JUST_WAIT          -- wait forever for the process to complete
+ *         APR_KILL_ONLY_ONCE     -- send SIGTERM and then wait
+ * </PRE>
+ }
+procedure apr_pool_note_subprocess(a: Papr_pool_t;
+ proc: Papr_proc_t; how: apr_kill_conditions_e);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_pool_note_subprocess' + LibSuff12;
+
+{.$ifdef APR_HAS_THREADS}
+
+{$if (defined(APR_HAVE_SIGWAIT) or defined(APR_HAVE_SIGSUSPEND)) and not defined(OS2)}
+
+{
+ * Setup the process for a single thread to be used for all signal handling.
+ * @warning This must be called before any threads are created
+ }
+function apr_setup_signal_thread: apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_setup_signal_thread' + LibSuff0;
+
+{
+ * Make the current thread listen for signals.  This thread will loop
+ * forever, calling a provided function whenever it receives a signal.  That
+ * functions should return 1 if the signal has been handled, 0 otherwise.
+ * @param signal_handler The function to call when a signal is received
+ * apr_status_t apr_signal_thread((int)( *signal_handler)(int signum))
+ }
+type
+  signal_handler_t = function (signum: Integer): Integer;
+  
+function apr_signal_thread(signal_handler: signal_handler_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_signal_thread' + LibSuff8;
+
+{$endif} { (APR_HAVE_SIGWAIT || APR_HAVE_SIGSUSPEND) && !defined(OS2) }
+
+{
+ * Get the child-pool used by the thread from the thread info.
+ * @return apr_pool_t the pool
+ }
+//APR_POOL_DECLARE_ACCESSOR(thread);
+
+//#endif { APR_HAS_THREADS }
+

+ 262 - 0
packages/base/httpd/httpd-2.0/apr/apr_time.inc

@@ -0,0 +1,262 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_time.h
+ * @brief APR Time Library
+ }
+
+{#include "apr.h"
+#include "apr_pools.h"
+#include "apr_errno.h"}
+
+{
+ * @defgroup apr_time Time Routines
+ * @ingroup APR 
+ }
+
+{ month names }
+//APR_DECLARE_DATA extern const char apr_month_snames[12][4];
+{ day names }
+//APR_DECLARE_DATA extern const char apr_day_snames[7][4];
+
+
+{ number of microseconds since 00:00:00 january 1, 1970 UTC }
+type
+  apr_time_t = apr_int64_t;
+  Papr_time_t = ^apr_time_t;
+
+
+{ mechanism to properly type apr_time_t literals }
+//#define APR_TIME_C(val) APR_INT64_C(val)
+
+{ mechanism to properly print apr_time_t values }
+//  APR_TIME_T_FMT = APR_INT64_T_FMT;
+
+{ intervals for I/O timeouts, in microseconds }
+  apr_interval_time_t = apr_int64_t;
+  Papr_interval_time_t = ^apr_interval_time_t;
+{ short interval for I/O timeouts, in microseconds }
+  apr_short_interval_time_t = apr_int32_t;
+
+{ number of microseconds per second }
+//  APR_USEC_PER_SEC APR_TIME_C(1000000)
+
+{ @return apr_time_t as a second }
+//#define apr_time_sec(time) ((time) / APR_USEC_PER_SEC)
+
+{ @return apr_time_t as a usec }
+//#define apr_time_usec(time) ((time) % APR_USEC_PER_SEC)
+
+{ @return apr_time_t as a msec }
+//#define apr_time_msec(time) (((time) / 1000) % 1000)
+
+{ @return apr_time_t as a msec }
+//#define apr_time_as_msec(time) ((time) / 1000)
+
+{ @return a second as an apr_time_t }
+//#define apr_time_from_sec(sec) ((apr_time_t)(sec) * APR_USEC_PER_SEC)
+
+{ @return a second and usec combination as an apr_time_t }
+//#define apr_time_make(sec, usec) ((apr_time_t)(sec) * APR_USEC_PER_SEC \
+//                                + (apr_time_t)(usec))
+
+{
+ * @return the current time
+ }
+function apr_time_now: apr_time_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_time_now' + LibSuff0;
+
+{ @see apr_time_exp_t }
+type
+  Papr_time_exp_t = ^apr_time_exp_t;
+
+{
+ * a structure similar to ANSI struct tm with the following differences:
+ *  - tm_usec isn't an ANSI field
+ *  - tm_gmtoff isn't an ANSI field (it's a bsdism)
+ }
+  apr_time_exp_t = record
+    { microseconds past tm_sec }
+    tm_usec: apr_int32_t;
+    { (0-61) seconds past tm_min }
+    tm_sec: apr_int32_t;
+    { (0-59) minutes past tm_hour }
+    tm_min: apr_int32_t;
+    { (0-23) hours past midnight }
+    tm_hour: apr_int32_t;
+    { (1-31) day of the month }
+    tm_mday: apr_int32_t;
+    { (0-11) month of the year }
+    tm_mon: apr_int32_t;
+    { year since 1900 }
+    tm_year: apr_int32_t;
+    { (0-6) days since sunday }
+    tm_wday: apr_int32_t;
+    { (0-365) days since jan 1 }
+    tm_yday: apr_int32_t;
+    { daylight saving time }
+    tm_isdst: apr_int32_t;
+    { seconds east of UTC }
+    tm_gmtoff: apr_int32_t;
+  end;
+
+{
+ * convert an ansi time_t to an apr_time_t
+ * @param result the resulting apr_time_t
+ * @param input the time_t to convert
+ }
+function apr_time_ansi_put(result: Papr_time_t;
+ input: time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_time_ansi_put' + LibSuff8;
+
+{
+ * convert a time to its human readable components using an offset
+ * from GMT
+ * @param result the exploded time
+ * @param input the time to explode
+ * @param offs the number of seconds offset to apply
+ }
+function apr_time_exp_tz(result: Papr_time_exp_t;
+ input: apr_time_t; offs: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_time_exp_tz' + LibSuff16;
+
+{ @deprecated @see apr_time_exp_tz }
+function apr_explode_time(result: Papr_time_exp_t;
+ input: apr_time_t; offs: apr_int32_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_explode_time' + LibSuff16;
+
+{
+ * convert a time to its human readable components in GMT timezone
+ * @param result the exploded time
+ * @param input the time to explode
+ }
+function apr_time_exp_gmt(result: Papr_time_exp_t;
+ input: apr_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_time_exp_gmt' + LibSuff12;
+
+{
+ * convert a time to its human readable components in local timezone
+ * @param result the exploded time
+ * @param input the time to explode
+ }
+function apr_time_exp_lt(result: Papr_time_exp_t;
+ input: apr_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_time_exp_lt' + LibSuff12;
+
+{ @deprecated @see apr_time_exp_lt }
+function apr_explode_localtime(result: Papr_time_exp_t;
+ input: apr_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_explode_localtime' + LibSuff12;
+
+{
+ * Convert time value from human readable format to a numeric apr_time_t 
+ * e.g. elapsed usec since epoch
+ * @param result the resulting imploded time
+ * @param input the input exploded time
+ }
+function apr_time_exp_get(result: Papr_time_t;
+ input: Papr_time_exp_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_time_exp_get' + LibSuff8;
+
+{
+ * Convert time value from human readable format to a numeric apr_time_t that
+ * always represents GMT
+ * @param result the resulting imploded time
+ * @param input the input exploded time
+ }
+function apr_time_exp_gmt_get(result: Papr_time_t;
+ input: Papr_time_exp_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_time_exp_gmt_get' + LibSuff8;
+
+{ @deprecated @see apr_time_exp_gmt_get }
+function apr_implode_gmt(result: Papr_time_t;
+ input: Papr_time_exp_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_implode_gmt' + LibSuff8;
+
+{
+ * Sleep for the specified number of micro-seconds.
+ * @param t desired amount of time to sleep.
+ * @warning May sleep for longer than the specified time. 
+ }
+procedure apr_sleep(t: apr_interval_time_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_sleep' + LibSuff8;
+
+{ length of a RFC822 Date }
+const APR_RFC822_DATE_LEN = (30);
+{
+ * apr_rfc822_date formats dates in the RFC822
+ * format in an efficient manner.  It is a fixed length
+ * format which requires the indicated amount of storage,
+ * including the trailing null byte.
+ * @param date_str String to write to.
+ * @param t the time to convert 
+ }
+function apr_rfc822_date(date_str: PChar; t: apr_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_rfc822_date' + LibSuff12;
+
+{ length of a CTIME date }
+const APR_CTIME_LEN = (25);
+{
+ * apr_ctime formats dates in the ctime() format
+ * in an efficient manner.  it is a fixed length format
+ * and requires the indicated amount of storage including
+ * the trailing null byte.
+ * Unlike ANSI/ISO C ctime(), apr_ctime() does not include
+ * a \n at the end of the string.
+ * @param date_str String to write to.
+ * @param t the time to convert 
+ }
+function apr_ctime(date_str: PChar; t: apr_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_ctime' + LibSuff12;
+
+{
+ * formats the exploded time according to the format specified
+ * @param s string to write to
+ * @param retsize The length of the returned string
+ * @param max The maximum length of the string
+ * @param format The format for the time string
+ * @param tm The time to convert
+ }
+function apr_strftime(s: PChar; retsize: apr_size_t;
+ max: apr_size_t; const format: PChar;
+ tm: Papr_time_exp_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_strftime' + LibSuff20;
+
+{
+ * Improve the clock resolution for the lifetime of the given pool.
+ * Generally this is only desireable on benchmarking and other very
+ * time-sensitive applications, and has no impact on most platforms.
+ * @param p The pool to associate the finer clock resolution 
+ }
+procedure apr_time_clock_hires(p: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_time_clock_hires' + LibSuff4;
+

+ 197 - 0
packages/base/httpd/httpd-2.0/apr/apr_user.inc

@@ -0,0 +1,197 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_user.h
+ * @brief APR User ID Services 
+ }
+
+{#include "apr.h"
+#include "apr_errno.h"
+#include "apr_pools.h"}
+
+{
+ * @defgroup apr_user User and Group ID Services
+ * @ingroup APR 
+ }
+
+{
+ * Structure for determining user ownership.
+ }
+type
+{$ifdef WIN32}
+  apr_uid_t = PSID;
+{$else}
+  apr_uid_t = uid_t;
+{$endif}
+
+  Papr_uid_t = ^apr_uid_t;
+
+{
+ * Structure for determining group ownership.
+ }
+{$ifdef WIN32}
+  apr_gid_t = PSID;
+{$else}
+  apr_gid_t = gid_t;
+{$endif}
+
+  Papr_gid_t = ^apr_gid_t;
+
+{$define APR_HAS_USER}
+
+{$ifdef APR_HAS_USER}
+
+{
+ * Get the userid (and groupid) of the calling process
+ * @param userid   Returns the user id
+ * @param groupid  Returns the user's group id
+ * @param p The pool from which to allocate working space
+ * @remark This function is available only if APR_HAS_USER is defined.
+ }
+function apr_uid_current(userid: Papr_uid_t; groupid: Papr_gid_t;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_uid_current' + LibSuff12;
+
+{ @deprecated @see apr_uid_current }
+{APR_DECLARE(apr_status_t) apr_current_userid(apr_uid_t *userid,
+                                             apr_gid_t *groupid,
+                                             apr_pool_t *p);}
+{
+ * Get the user name for a specified userid
+ * @param username Pointer to new string containing user name (on output)
+ * @param userid The userid
+ * @param p The pool from which to allocate the string
+ * @remark This function is available only if APR_HAS_USER is defined.
+ }
+function apr_uid_name_get(username: PPChar; userid: apr_uid_t;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_uid_name_get' + LibSuff12;
+
+{ @deprecated @see apr_uid_name_get }
+{APR_DECLARE(apr_status_t) apr_get_username(char **username, apr_uid_t userid,
+                                           apr_pool_t *p);}
+{
+ * Get the userid (and groupid) for the specified username
+ * @param userid   Returns the user id
+ * @param groupid  Returns the user's group id
+ * @param username The username to lookup
+ * @param p The pool from which to allocate working space
+ * @remark This function is available only if APR_HAS_USER is defined.
+ }
+function apr_uid_get(userid: Papr_uid_t; groupid: Papr_gid_t;
+ const username: PChar; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_uid_get' + LibSuff16;
+
+{ @deprecated @see apr_uid_get }
+{APR_DECLARE(apr_status_t) apr_get_userid(apr_uid_t *userid, apr_gid_t *groupid,
+                                         const char *username, apr_pool_t *p);}
+
+{
+ * Get the home directory for the named user
+ * @param dirname Pointer to new string containing directory name (on output)
+ * @param username The named user
+ * @param p The pool from which to allocate the string
+ * @remark This function is available only if APR_HAS_USER is defined.
+ }
+function apr_uid_homepath_get(dirname: PPChar; const username: PChar;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_uid_homepath_get' + LibSuff12;
+
+{ @deprecated @see apr_uid_homepath_get }
+{APR_DECLARE(apr_status_t) apr_get_home_directory(char **dirname,
+                                                 const char *username,
+                                                 apr_pool_t *p);}
+
+{
+ * Compare two user identifiers for equality.
+ * @param left One uid to test
+ * @param right Another uid to test
+ * @return APR_SUCCESS if the apr_uid_t strutures identify the same user,
+ * APR_EMISMATCH if not, APR_BADARG if an apr_uid_t is invalid.
+ * @remark This function is available only if APR_HAS_USER is defined.
+ }
+{$ifdef WIN32}
+//APR_DECLARE(apr_status_t) apr_uid_compare(apr_uid_t left, apr_uid_t right);
+
+{ @deprecated @see apr_uid_compare }
+//APR_DECLARE(apr_status_t) apr_compare_users(apr_uid_t left, apr_uid_t right);
+{$else}
+//#define apr_uid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
+{ @deprecated @see apr_uid_compare }
+//#define apr_compare_users(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
+{$endif}
+
+{
+ * Get the group name for a specified groupid
+ * @param groupname Pointer to new string containing group name (on output)
+ * @param groupid The groupid
+ * @param p The pool from which to allocate the string
+ * @remark This function is available only if APR_HAS_USER is defined.
+ }
+function apr_gid_name_get(groupname: PPChar; groupid: apr_gid_t;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_gid_name_get' + LibSuff12;
+
+{ @deprecated @see apr_gid_name_get }
+{APR_DECLARE(apr_status_t) apr_group_name_get(char **groupname,
+                                             apr_gid_t groupid, apr_pool_t *p);}
+
+{ @deprecated @see apr_gid_name_get }
+{APR_DECLARE(apr_status_t) apr_get_groupname(char **groupname,
+                                            apr_gid_t groupid, apr_pool_t *p);}
+
+{
+ * Get the groupid for a specified group name
+ * @param groupid Pointer to the group id (on output)
+ * @param groupname The group name to look up
+ * @param p The pool from which to allocate the string
+ * @remark This function is available only if APR_HAS_USER is defined.
+ }
+function apr_gid_get(groupid: Papr_gid_t; const groupname: PChar;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_gid_get' + LibSuff12;
+
+{ @deprecated @see apr_gid_get }
+{APR_DECLARE(apr_status_t) apr_get_groupid(apr_gid_t *groupid,
+                                          const char *groupname, apr_pool_t *p);}
+
+{
+ * Compare two group identifiers for equality.
+ * @param left One gid to test
+ * @param right Another gid to test
+ * @return APR_SUCCESS if the apr_gid_t strutures identify the same group,
+ * APR_EMISMATCH if not, APR_BADARG if an apr_gid_t is invalid.
+ * @remark This function is available only if APR_HAS_USER is defined.
+ }
+{$ifdef WIN32}
+//APR_DECLARE(apr_status_t) apr_gid_compare(apr_gid_t left, apr_gid_t right);
+{ @deprecated @see apr_gid_compare }
+//APR_DECLARE(apr_status_t) apr_compare_groups(apr_gid_t left, apr_gid_t right);
+{$else}
+//#define apr_gid_compare(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
+{ @deprecated @see apr_gid_compare }
+//#define apr_compare_groups(left,right) (((left) == (right)) ? APR_SUCCESS : APR_EMISMATCH)
+{$endif}
+
+{$endif}  { ! APR_HAS_USER }
+

+ 112 - 0
packages/base/httpd/httpd-2.0/apr/apr_version.inc

@@ -0,0 +1,112 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+//#include "apr.h"
+
+{
+ * @file apr_version.h
+ * @brief APR Versioning Interface
+ * 
+ * APR's Version
+ *
+ * There are several different mechanisms for accessing the version. There
+ * is a string form, and a set of numbers; in addition, there are constants
+ * which can be compiled into your application, and you can query the library
+ * being used for its actual version.
+ *
+ * Note that it is possible for an application to detect that it has been
+ * compiled against a different version of APR by use of the compile-time
+ * constants and the use of the run-time query function.
+ *
+ * APR version numbering follows the guidelines specified in:
+ *
+ *     http://apr.apache.org/versioning.html
+ }
+
+{ The numeric compile-time version constants. These constants are the
+ * authoritative version numbers for APR. 
+ }
+
+{ major version
+ * Major API changes that could cause compatibility problems for older
+ * programs such as structure size changes.  No binary compatibility is
+ * possible across a change in the major version.
+ }
+const
+  APR_MAJOR_VERSION = 0;
+
+{
+ * Minor API changes that do not cause binary compatibility problems.
+ * Should be reset to 0 when upgrading APR_MAJOR_VERSION
+ }
+  APR_MINOR_VERSION = 9;
+
+{ patch level }
+  APR_PATCH_VERSION = 12;
+
+{
+ *  This symbol is defined for internal, "development" copies of APR. This
+ *  symbol will be #undef'd for releases. 
+ }
+{.$undef APR_IS_DEV_VERSION}
+
+
+{ The formatted string of APR's version }
+{#define APR_VERSION_STRING \
+     APR_STRINGIFY(APR_MAJOR_VERSION) "." \
+     APR_STRINGIFY(APR_MINOR_VERSION) "." \
+     APR_STRINGIFY(APR_PATCH_VERSION) \
+     APR_IS_DEV_STRING}
+
+
+{
+ * The numeric version information is broken out into fields within this 
+ * structure. 
+ }
+type
+  apr_version_t = record
+    major: Integer;      {< major number }
+    minor: Integer;      {< minor number }
+    patch: Integer;      {< patch number }
+    is_dev: Integer;     {< is development (1 or 0) }
+  end;
+
+  Papr_version_t = ^apr_version_t;
+
+{
+ * Return APR's version information information in a numeric form.
+ *
+ *  @param pvsn Pointer to a version structure for returning the version
+ *              information.
+ }
+procedure apr_version(pvsn: Papr_version_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_version' + LibSuff4;
+
+{ Return APR's version information as a string. }
+function apr_version_string: PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_version_string' + LibSuff0;
+
+
+{ Internal: string form of the "is dev" flag }
+{#ifdef APR_IS_DEV_VERSION
+#define APR_IS_DEV_STRING "-dev"
+#else}
+const
+  APR_IS_DEV_STRING = '';
+//#endif
+

+ 99 - 0
packages/base/httpd/httpd-2.0/apriconv/api_version.inc

@@ -0,0 +1,99 @@
+{ Copyright 2000-2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{#include "apr.h"
+#include "apr_version.h"
+
+#include "apr_iconv.h"}
+
+{
+ * @file api_version.h
+ * @brief 
+ * 
+ * APR-iconv's Version
+ *
+ * There are several different mechanisms for accessing the version. There
+ * is a string form, and a set of numbers; in addition, there are constants
+ * which can be compiled into your application, and you can query the library
+ * being used for its actual version.
+ *
+ * Note that it is possible for an application to detect that it has been
+ * compiled against a different version of API by use of the compile-time
+ * constants and the use of the run-time query function.
+ *
+ * API version numbering follows the guidelines specified in:
+ *
+ *     http://apr.apache.org/versioning.html
+ }
+
+{ The numeric compile-time version constants. These constants are the
+ * authoritative version numbers for API. 
+ }
+
+{ major version
+ * Major API changes that could cause compatibility problems for older
+ * programs such as structure size changes.  No binary compatibility is
+ * possible across a change in the major version.
+ }
+const
+  API_MAJOR_VERSION      = 0;
+
+{
+ * Minor API changes that do not cause binary compatibility problems.
+ * Should be reset to 0 when upgrading API_MAJOR_VERSION
+ }
+  API_MINOR_VERSION      = 9;
+
+{ patch level }
+  API_PATCH_VERSION      = 7;
+
+{
+ *  This symbol is defined for internal, "development" copies of API. This
+ *  symbol will be #undef'd for releases. 
+ }
+{ #define API_IS_DEV_VERSION }
+
+
+{ The formatted string of API's version }
+{#define API_VERSION_STRING \
+     APR_STRINGIFY(API_MAJOR_VERSION) "." \
+     APR_STRINGIFY(API_MINOR_VERSION) "." \
+     APR_STRINGIFY(API_PATCH_VERSION) \
+     API_IS_DEV_STRING}
+
+{
+ * Return APR-util's version information information in a numeric form.
+ *
+ *  @param pvsn Pointer to a version structure for returning the version
+ *              information.
+ }
+//procedure api_version(pvsn: Papr_version_t);
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibAPRIconv name LibNamePrefix + 'api_version' + LibSuff4;
+
+{ Return API's version information as a string. }
+//function api_version_string: PChar;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibAPRIconv name LibNamePrefix + 'api_version_string' + LibSuff0;
+
+
+{ Internal: string form of the "is dev" flag }
+const
+{$ifdef API_IS_DEV_VERSION}
+  API_IS_DEV_STRING = '-dev';
+{$else}
+  API_IS_DEV_STRING = '';
+{$endif}
+

+ 113 - 0
packages/base/httpd/httpd-2.0/apriconv/apr_iconv.inc

@@ -0,0 +1,113 @@
+{-
+ * Copyright (c) 1999,2000
+ *	Konstantin Chuguev.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Konstantin Chuguev
+ *	and its contributors.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ }
+
+{#include "apr.h"
+#include "apr_pools.h"
+#include <stddef.h>}
+
+{
+ * API_DECLARE_EXPORT is defined when building the libapriconv dynamic 
+ * library, so that all public symbols are exported.
+ *
+ * API_DECLARE_STATIC is defined when including the apriconv public headers, 
+ * to provide static linkage when the dynamic library may be unavailable.
+ *
+ * API_DECLARE_STATIC and API_DECLARE_EXPORT are left undefined when
+ * including the apr-iconv public headers, to import and link the symbols 
+ * from the dynamic libapriconv library and assure appropriate indirection 
+ * and calling conventions at compile time.
+ }
+
+//#if !defined(WIN32)
+{
+ * The public apr-iconv functions are declared with API_DECLARE(), so they 
+ * use the most portable calling convention.  Public apr-iconv functions 
+ * with variable arguments must use API_DECLARE_NONSTD().
+ *
+ * @deffunc API_DECLARE(rettype) apr_func(args);
+ }
+//#define API_DECLARE(type)            type
+{
+ * The private apr-iconv functions are declared with API_DECLARE_NONSTD(), 
+ * so they use the most optimal C language calling conventions.
+ *
+ * @deffunc API_DECLARE(rettype) apr_func(args);
+ }
+//#define API_DECLARE_NONSTD(type)     type
+{
+ * All exported apr-iconv variables are declared with API_DECLARE_DATA
+ * This assures the appropriate indirection is invoked at compile time.
+ *
+ * @deffunc API_DECLARE_DATA type apr_variable;
+ * @tip extern API_DECLARE_DATA type apr_variable; syntax is required for
+ * declarations within headers to properly import the variable.
+ }
+{#define API_DECLARE_DATA
+#elif defined(API_DECLARE_STATIC)
+#define API_DECLARE(type)            type __stdcall
+#define API_DECLARE_NONSTD(type)     type
+#define API_DECLARE_DATA
+#elif defined(API_DECLARE_EXPORT)
+#define API_DECLARE(type)            __declspec(dllexport) type __stdcall
+#define API_DECLARE_NONSTD(type)     __declspec(dllexport) type
+#define API_DECLARE_DATA             __declspec(dllexport)
+#else
+#define API_DECLARE(type)            __declspec(dllimport) type __stdcall
+#define API_DECLARE_NONSTD(type)     __declspec(dllimport) type
+#define API_DECLARE_DATA             __declspec(dllimport)
+#endif}
+
+{
+ * apr_iconv_t:	charset conversion descriptor type
+ }
+type
+  apr_iconv_t = Pointer;
+  Papr_iconv_t = ^apr_iconv_t;
+
+{ __BEGIN_DECLS }
+
+function apr_iconv_open(const param1, param2: PChar;
+ param3: Papr_pool_t; param4: Papr_iconv_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRIconv name LibNamePrefix + 'apr_iconv_open' + LibSuff16;
+
+function apr_iconv(param1: apr_iconv_t; const param2: PPChar;
+ param3: Papr_pool_t; param4: PPchar;
+ param5, param6: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRIconv name LibNamePrefix + 'apr_iconv' + LibSuff24;
+
+function apr_iconv_close(param1: apr_iconv_t; param2: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRIconv name LibNamePrefix + 'apr_iconv_close' + LibSuff8;
+
+{ __END_DECLS }
+

+ 59 - 0
packages/base/httpd/httpd-2.0/apriconv/apriconv.pas

@@ -0,0 +1,59 @@
+{
+ apriconv.pas
+
+ Copyright (C) 2006 Felipe Monteiro de Carvalho
+
+ This unit is a pascal binding for the Apache 2.0.58 headers.
+ The headers were released under the following copyright:
+}
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+unit apriconv;
+
+interface
+
+{$ifdef fpc}
+  {$mode delphi}{$H+}
+{$endif}
+
+{$IFNDEF FPC}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$IFDEF WIN32}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$ifdef Unix}
+  {$PACKRECORDS C}
+{$endif}
+
+uses apr;
+
+const
+{$IFDEF WINDOWS}
+  LibAPRIconv = 'libapriconv.dll';
+{$ELSE}
+  LibAPRIconv = '';
+{$ENDIF}
+
+{$include apr_iconv.inc}
+{$include api_version.inc}
+
+implementation
+
+end.
+

+ 158 - 0
packages/base/httpd/httpd-2.0/aprutil/apr_md5.inc

@@ -0,0 +1,158 @@
+{
+ * This is work is derived from material Copyright RSA Data Security, Inc.
+ *
+ * The RSA copyright statement and Licence for that original material is
+ * included below. This is followed by the Apache copyright statement and
+ * licence for the modifications made to that material.
+ }
+
+{ Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
+   rights reserved.
+
+   License to copy and use this software is granted provided that it
+   is identified as the "RSA Data Security, Inc. MD5 Message-Digest
+   Algorithm" in all material mentioning or referencing this software
+   or this function.
+
+   License is also granted to make and use derivative works provided
+   that such works are identified as "derived from the RSA Data
+   Security, Inc. MD5 Message-Digest Algorithm" in all material
+   mentioning or referencing the derived work.
+
+   RSA Data Security, Inc. makes no representations concerning either
+   the merchantability of this software or the suitability of this
+   software for any particular purpose. It is provided "as is"
+   without express or implied warranty of any kind.
+
+   These notices must be retained in any copies of any part of this
+   documentation and/or software.
+ }
+
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{#include "apu.h"}
+{$include apr_xlate.inc}
+
+{
+ * @file apr_md5.h
+ * @brief APR MD5 Routines
+ }
+
+{
+ * @defgroup APR_MD5 MD5 Routines
+ * @ingroup APR
+ }
+
+const
+{ The MD5 digest size }
+  APR_MD5_DIGESTSIZE = 16;
+  MD5_DIGESTSIZE = APR_MD5_DIGESTSIZE;   {< @deprecated }
+
+{ @see apr_md5_ctx_t }
+type
+  TDigestArray = array [0..APR_MD5_DIGESTSIZE] of Char;
+
+  Papr_md5_ctx_t = ^apr_md5_ctx_t;
+
+{ MD5 context. }
+  apr_md5_ctx_t = record
+    { state (ABCD) }
+    state: array [1..4] of apr_uint32_t;
+    { number of bits, modulo 2^64 (lsb first) }
+    count: array [1..2] of apr_uint32_t;
+    { input buffer }
+    buffer: array [1..64] of Char;
+    { translation handle
+     *  ignored if xlate is unsupported
+     }
+    xlate: Papr_xlate_t;
+  end;
+
+{
+ * MD5 Initialize.  Begins an MD5 operation, writing a new context.
+ * @param context The MD5 context to initialize.
+ }
+function apr_md5_init(context: Papr_md5_ctx_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_md5_init' + LibSuff4;
+
+{
+ * MD5 translation setup.  Provides the APR translation handle to be used 
+ * for translating the content before calculating the digest.
+ * @param context The MD5 content to set the translation for.
+ * @param xlate The translation handle to use for this MD5 context 
+ }
+function apr_md5_set_xlate(context: Papr_md5_ctx_t;
+ xlate: Papr_xlate_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_md5_set_xlate' + LibSuff8;
+
+{
+ * MD5 block update operation.  Continue an MD5 message-digest operation, 
+ * processing another message block, and updating the context.
+ * @param context The MD5 content to update.
+ * @param input next message block to update
+ * @param inputLen The length of the next message block
+ }
+function apr_md5_update(context: Papr_md5_ctx_t;
+ input: Pointer; inputLen: apr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_md5_update' + LibSuff12;
+
+{
+ * MD5 finalization.  Ends an MD5 message-digest operation, writing the 
+ * message digest and zeroing the context
+ * @param digest The final MD5 digest
+ * @param context The MD5 content we are finalizing.
+ }
+function apr_md5_final(digest: TDigestArray;
+ context: Papr_md5_ctx_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_md5_final' + LibSuff8;
+
+{
+ * MD5 in one step
+ * @param digest The final MD5 digest
+ * @param input The message block to use
+ * @param inputLen The length of the message block
+ }
+function apr_md5(digest: TDigestArray;
+ input: Pointer; inputLen: apr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_md5' + LibSuff12;
+
+{
+ * Encode a password using an MD5 algorithm
+ * @param password The password to encode
+ * @param salt The salt to use for the encoding
+ * @param result The string to store the encoded password in
+ * @param nbytes The length of the string
+ }
+function apr_md5_encode(const password, salt: PChar;
+ result: PChar; nbytes: apr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_md5_encode' + LibSuff16;
+
+{
+ * Validate any password encypted with any algorithm that APR understands
+ * @param passwd The password to validate
+ * @param hash The password to validate against
+ }
+function apr_password_validate(const passwd, hash: PChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_password_validate' + LibSuff8;
+

+ 175 - 0
packages/base/httpd/httpd-2.0/aprutil/apr_uri.inc

@@ -0,0 +1,175 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * apr_uri.h: External Interface of apr_uri.c
+ }
+
+{
+ * @file apr_uri.h
+ * @brief APR-UTIL URI Routines
+ }
+
+{#include "apu.h"
+
+#include "apr_network_io.h"}
+
+{
+ * @defgroup APR_Util_URI URI
+ * @ingroup APR_Util
+ }
+const
+  APR_URI_FTP_DEFAULT_PORT        = 21; {< default FTP port }
+  APR_URI_SSH_DEFAULT_PORT        = 22; {< default SSH port }
+  APR_URI_TELNET_DEFAULT_PORT     = 23; {< default telnet port }
+  APR_URI_GOPHER_DEFAULT_PORT     = 70; {< default Gopher port }
+  APR_URI_HTTP_DEFAULT_PORT       = 80; {< default HTTP port }
+  APR_URI_POP_DEFAULT_PORT       = 110; {< default POP port }
+  APR_URI_NNTP_DEFAULT_PORT      = 119; {< default NNTP port }
+  APR_URI_IMAP_DEFAULT_PORT      = 143; {< default IMAP port }
+  APR_URI_PROSPERO_DEFAULT_PORT  = 191; {< default Prospero port }
+  APR_URI_WAIS_DEFAULT_PORT      = 210; {< default WAIS port }
+  APR_URI_LDAP_DEFAULT_PORT      = 389; {< default LDAP port }
+  APR_URI_HTTPS_DEFAULT_PORT     = 443; {< default HTTPS port }
+  APR_URI_RTSP_DEFAULT_PORT      = 554; {< default RTSP port }
+  APR_URI_SNEWS_DEFAULT_PORT     = 563; {< default SNEWS port }
+  APR_URI_ACAP_DEFAULT_PORT      = 674; {< default ACAP port }
+  APR_URI_NFS_DEFAULT_PORT      = 2049; {< default NFS port }
+  APR_URI_TIP_DEFAULT_PORT      = 3372; {< default TIP port }
+  APR_URI_SIP_DEFAULT_PORT      = 5060; {< default SIP port }
+
+{ Flags passed to unparse_uri_components(): }
+{ suppress "scheme://user\@site:port" }
+  APR_URI_UNP_OMITSITEPART    = (1 shl 0);
+{ Just omit user }
+  APR_URI_UNP_OMITUSER        = (1 shl 1);
+{ Just omit password }
+  APR_URI_UNP_OMITPASSWORD    = (1 shl 2);
+{ omit "user:password\@" part }
+  APR_URI_UNP_OMITUSERINFO    = (APR_URI_UNP_OMITUSER or APR_URI_UNP_OMITPASSWORD);
+{ Show plain text password (default: show XXXXXXXX) }
+  APR_URI_UNP_REVEALPASSWORD  = (1 shl 3);
+{ Show "scheme://user\@site:port" only }
+  APR_URI_UNP_OMITPATHINFO    = (1 shl 4);
+{ Omit the "?queryarg" from the path }
+  APR_URI_UNP_OMITQUERY       = (1 shl 5);
+
+type
+{ @see apr_uri_t }
+  Papr_uri_t = ^apr_uri_t;
+
+{
+ * A structure to encompass all of the fields in a uri
+ }
+  apr_uri_t = record
+    { scheme ("http"/"ftp"/...) }
+    scheme: PChar;
+    { combined [user[:password]\@]host[:port] }
+    hostinfo: PChar;
+    { user name, as in http://user:passwd\@host:port/ }
+    user: PChar;
+    { password, as in http://user:passwd\@host:port/ }
+    password: PChar;
+    { hostname from URI (or from Host: header) }
+    hostname: PChar;
+    { port string (integer representation is in "port") }
+    port_str: PChar;
+    { the request path (or "/" if only scheme://host was given) }
+    path: PChar;
+    { Everything after a '?' in the path, if present }
+    query: PChar;
+    { Trailing "#fragment" string, if present }
+    fragment: PChar;
+
+    { structure returned from gethostbyname() }
+    hostent: Pointer;
+
+    { The port number, numeric, valid only if port_str != NULL }
+    port: apr_port_t;
+    
+    { has the structure been initialized }
+//    unsigned is_initialized:1;
+
+    { has the DNS been looked up yet }
+//    unsigned dns_looked_up:1;
+    { has the dns been resolved yet }
+//    unsigned dns_resolved:1;
+  end;
+
+{ apr_uri.c }
+{
+ * Return the default port for a given scheme.  The schemes recognized are
+ * http, ftp, https, gopher, wais, nntp, snews, and prospero
+ * @param scheme_str The string that contains the current scheme
+ * @return The default port for this scheme
+ }
+function apr_uri_port_of_scheme(const scheme_str: PChar): apr_port_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_uri_port_of_scheme' + LibSuff4;
+
+{ @deprecated @see apr_uri_port_of_scheme }
+function apr_uri_default_port_for_scheme(const scheme_str: PChar): apr_port_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_uri_default_port_for_scheme' + LibSuff4;
+
+{
+ * Unparse a apr_uri_t structure to an URI string.  Optionally 
+ * suppress the password for security reasons.
+ * @param p The pool to allocate out of
+ * @param uptr All of the parts of the uri
+ * @param flags How to unparse the uri.  One of:
+ * <PRE>
+ *    APR_URI_UNP_OMITSITEPART        Suppress "scheme://user\@site:port" 
+ *    APR_URI_UNP_OMITUSER            Just omit user 
+ *    APR_URI_UNP_OMITPASSWORD        Just omit password 
+ *    APR_URI_UNP_OMITUSERINFO        Omit "user:password\@" part
+ *    APR_URI_UNP_REVEALPASSWORD      Show plain text password (default: show XXXXXXXX)
+ *    APR_URI_UNP_OMITPATHINFO        Show "scheme://user\@site:port" only 
+ *    APR_URI_UNP_OMITQUERY           Omit "?queryarg" or "#fragment" 
+ * </PRE>
+ * @return The uri as a string
+ }
+function apr_uri_unparse(p: Papr_pool_t; const uptr: Papr_uri_t;
+ flags: cuint): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_uri_unparse' + LibSuff12;
+
+{
+ * Parse a given URI, fill in all supplied fields of a apr_uri_t
+ * structure. This eliminates the necessity of extracting host, port,
+ * path, query info repeatedly in the modules.
+ * @param p The pool to allocate out of
+ * @param uri The uri to parse
+ * @param uptr The apr_uri_t to fill out
+ * @return APR_SUCCESS for success or error code
+ }
+function apr_uri_parse(p: Papr_pool_t; const uri: PChar;
+ uptr: Papr_uri_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_uri_parse' + LibSuff12;
+
+{
+ * Special case for CONNECT parsing: it comes with the hostinfo part only
+ * @param p The pool to allocate out of
+ * @param hostinfo The hostinfo string to parse
+ * @param uptr The apr_uri_t to fill out
+ * @return APR_SUCCESS for success or error code
+ }
+function apr_uri_parse_hostinfo(p: Papr_pool_t;
+ const hostinfo: PChar; uptr: Papr_uri_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_uri_parse_hostinfo' + LibSuff12;
+

+ 152 - 0
packages/base/httpd/httpd-2.0/aprutil/apr_xlate.inc

@@ -0,0 +1,152 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{#include "apu.h"
+#include "apr_pools.h"
+#include "apr_errno.h"}
+
+{
+ * @file apr_xlate.h
+ * @brief APR I18N translation library
+ }
+
+{
+ * @defgroup APR_XLATE I18N translation library
+ * @ingroup APR
+ }
+{ Opaque translation buffer }
+type
+  Papr_xlate_t = Pointer;
+  PPapr_xlate_t = ^Papr_xlate_t;
+
+{
+ * Set up for converting text from one charset to another.
+ * @param convset The handle to be filled in by this function
+ * @param topage The name of the target charset
+ * @param frompage The name of the source charset
+ * @param pool The pool to use
+ * @remark
+ *  Specify APR_DEFAULT_CHARSET for one of the charset
+ *  names to indicate the charset of the source code at
+ *  compile time.  This is useful if there are literal
+ *  strings in the source code which must be translated
+ *  according to the charset of the source code.
+ *  APR_DEFAULT_CHARSET is not useful if the source code
+ *  of the caller was not encoded in the same charset as
+ *  APR at compile time.
+ *
+ * @remark
+ *  Specify APR_LOCALE_CHARSET for one of the charset
+ *  names to indicate the charset of the current locale.
+ *
+ * @remark
+ *  Return APR_EINVAL if unable to procure a convset, or APR_ENOTIMPL
+ *  if charset transcoding is not available in this instance of
+ *  apr-util at all (i.e., APR_HAS_XLATE is undefined).
+ }
+function apr_xlate_open(convset: PPapr_xlate_t;
+ const topage, frompage: PChar; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xlate_open' + LibSuff16;
+
+{
+ * This is to indicate the charset of the sourcecode at compile time
+ * names to indicate the charset of the source code at
+ * compile time.  This is useful if there are literal
+ * strings in the source code which must be translated
+ * according to the charset of the source code.
+ }
+//#define APR_DEFAULT_CHARSET (const char *)0
+{
+ * To indicate charset names of the current locale 
+ }
+//#define APR_LOCALE_CHARSET (const char *)1
+
+{
+ * Find out whether or not the specified conversion is single-byte-only.
+ * @param convset The handle allocated by apr_xlate_open, specifying the 
+ *                parameters of conversion
+ * @param onoff Output: whether or not the conversion is single-byte-only
+ * @remark
+ *  Return APR_ENOTIMPL if charset transcoding is not available
+ *  in this instance of apr-util (i.e., APR_HAS_XLATE is undefined).
+ }
+function apr_xlate_sb_get(convset: Papr_xlate_t; onoff: PInteger): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xlate_sb_get' + LibSuff8;
+
+{ @deprecated @see apr_xlate_sb_get }
+function apr_xlate_get_sb(convset: Papr_xlate_t; onoff: PInteger): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xlate_get_sb' + LibSuff8;
+
+{
+ * Convert a buffer of text from one codepage to another.
+ * @param convset The handle allocated by apr_xlate_open, specifying 
+ *                the parameters of conversion
+ * @param inbuf The address of the source buffer
+ * @param inbytes_left Input: the amount of input data to be translated
+ *                     Output: the amount of input data not yet translated    
+ * @param outbuf The address of the destination buffer
+ * @param outbytes_left Input: the size of the output buffer
+ *                      Output: the amount of the output buffer not yet used
+ * @remark
+ *  Return APR_ENOTIMPL if charset transcoding is not available
+ *  in this instance of apr-util (i.e., APR_HAS_XLATE is undefined).
+ }
+function apr_xlate_conv_buffer(convset: Papr_xlate_t; const inbuf: PChar;
+ inbytes_left: Papr_size_t; outbuf: PChar; outbytes_left: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xlate_conv_buffer' + LibSuff20;
+
+{ @see apr_file_io.h the comment in apr_file_io.h about this hack }
+{$ifdef APR_NOT_DONE_YET}
+{
+ * The purpose of apr_xlate_conv_char is to translate one character
+ * at a time.  This needs to be written carefully so that it works
+ * with double-byte character sets. 
+ * @param convset The handle allocated by apr_xlate_open, specifying the
+ *                parameters of conversion
+ * @param inchar The character to convert
+ * @param outchar The converted character
+ }
+APU_DECLARE(apr_status_t) apr_xlate_conv_char(apr_xlate_t *convset, 
+                                              char inchar, char outchar);
+{$endif}
+
+{
+ * Convert a single-byte character from one charset to another.
+ * @param convset The handle allocated by apr_xlate_open, specifying the 
+ *                parameters of conversion
+ * @param inchar The single-byte character to convert.
+ * @warning This only works when converting between single-byte character sets.
+ *          -1 will be returned if the conversion can't be performed.
+ }
+function apr_xlate_conv_byte(convset: Papr_xlate_t; inchar: Char): apr_int32_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xlate_conv_byte' + LibSuff8;
+
+{
+ * Close a codepage translation handle.
+ * @param convset The codepage translation handle to close
+ * @remark
+ *  Return APR_ENOTIMPL if charset transcoding is not available
+ *  in this instance of apr-util (i.e., APR_HAS_XLATE is undefined).
+ }
+function apr_xlate_close(convset: Papr_xlate_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xlate_close' + LibSuff4;
+

+ 349 - 0
packages/base/httpd/httpd-2.0/aprutil/apr_xml.inc

@@ -0,0 +1,349 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+{
+ * @file apr_xml.h
+ * @brief APR-UTIL XML Library
+ }
+
+{
+ * @defgroup APR_Util_XML XML 
+ * @ingroup APR_Util
+ }
+{#include "apr_pools.h"
+#include "apr_tables.h"
+#include "apr_file_io.h"
+
+#include "apu.h"}
+
+{
+ * @package Apache XML library
+ }
+
+{ -------------------------------------------------------------------- }
+
+{ ### these will need to move at some point to a more logical spot }
+
+{ @see apr_text }
+type
+  Papr_text = ^apr_text;
+
+  { Structure to keep a linked list of pieces of text }
+
+  apr_text = record
+    { The current piece of text }
+    text: PChar;
+    { a pointer to the next piece of text }
+    next: Papr_text;
+  end;
+
+{ @see apr_text_header }
+  Papr_text_header = ^apr_text_header;
+
+{ A list of pieces of text }
+  apr_text_header = record
+    { The first piece of text in the list }
+    first: Papr_text;
+    { The last piece of text in the list }
+    last: Papr_text;
+  end;
+
+{
+ * Append a piece of text to the end of a list
+ * @param p The pool to allocate out of
+ * @param hdr The text header to append to
+ * @param text The new text to append
+ }
+procedure apr_text_append(p: Papr_pool_t; hdr: Papr_text_header;
+ const text: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_text_append' + LibSuff12;
+
+{ --------------------------------------------------------------------
+**
+** XML PARSING
+}
+
+{
+** Qualified namespace values
+**
+** APR_XML_NS_DAV_ID
+**    We always insert the "DAV:" namespace URI at the head of the
+**    namespace array. This means that it will always be at ID==0,
+**    making it much easier to test for.
+**
+** APR_XML_NS_NONE
+**    This special ID is used for two situations:
+**
+**    1) The namespace prefix begins with "xml" (and we do not know
+**       what it means). Namespace prefixes with "xml" (any case) as
+**       their first three characters are reserved by the XML Namespaces
+**       specification for future use. mod_dav will pass these through
+**       unchanged. When this identifier is used, the prefix is LEFT in
+**       the element/attribute name. Downstream processing should not
+**       prepend another prefix.
+**
+**    2) The element/attribute does not have a namespace.
+**
+**       a) No prefix was used, and a default namespace has not been
+**          defined.
+**       b) No prefix was used, and the default namespace was specified
+**          to mean "no namespace". This is done with a namespace
+**          declaration of:  xmlns=""
+**          (this declaration is typically used to override a previous
+**          specification for the default namespace)
+**
+**       In these cases, we need to record that the elem/attr has no
+**       namespace so that we will not attempt to prepend a prefix.
+**       All namespaces that are used will have a prefix assigned to
+**       them -- mod_dav will never set or use the default namespace
+**       when generating XML. This means that "no prefix" will always
+**       mean "no namespace".
+**
+**    In both cases, the XML generation will avoid prepending a prefix.
+**    For the first case, this means the original prefix/name will be
+**    inserted into the output stream. For the latter case, it means
+**    the name will have no prefix, and since we never define a default
+**    namespace, this means it will have no namespace.
+**
+** Note: currently, mod_dav understands the "xmlns" prefix and the
+**     "xml:lang" attribute. These are handled specially (they aren't
+**     left within the XML tree), so the APR_XML_NS_NONE value won't ever
+**     really apply to these values.
+}
+const
+  APR_XML_NS_DAV_ID	= 0;	{< namespace ID for "DAV:" }
+  APR_XML_NS_NONE	= -10;	{< no namespace for this elem/attr }
+
+  APR_XML_NS_ERROR_BASE	= -100;	{< used only during processing }
+{ Is this namespace an error? }
+//  APR_XML_NS_IS_ERROR(e)	((e) <= APR_XML_NS_ERROR_BASE)
+
+type
+{ @see apr_xml_attr }
+  Papr_xml_attr = ^apr_xml_attr;
+{ @see apr_xml_elem }
+  Papr_xml_elem = ^apr_xml_elem;
+{ @see apr_xml_doc }
+  Papr_xml_doc = ^apr_xml_doc;
+  PPapr_xml_doc = ^Papr_xml_doc;
+
+{ apr_xml_attr: holds a parsed XML attribute }
+  apr_xml_attr = record
+    { attribute name }
+    name: PChar;
+    { index into namespace array }
+    ns: Integer;
+
+    { attribute value }
+    value: PChar;
+
+    { next attribute }
+    next: Papr_xml_attr;
+  end;
+
+{ apr_xml_elem: holds a parsed XML element }
+  apr_xml_elem = record
+    { element name }
+    name: PChar;
+    { index into namespace array }
+    ns: Integer;
+    { xml:lang for attrs/contents }
+    lang: PChar;
+
+    { cdata right after start tag }
+    first_cdata: apr_text_header;
+    { cdata after MY end tag }
+    following_cdata: apr_text_header;
+
+    { parent element }
+    parent: Papr_xml_elem;
+    { next (sibling) element }
+    next: Papr_xml_elem;
+    { first child element }
+    first_child: Papr_xml_elem;
+    { first attribute }
+    attr: Papr_xml_attr;
+
+    { used only during parsing }
+    { last child element }
+    last_child: Papr_xml_elem;
+    { namespaces scoped by this elem }
+    ns_scope: Papr_xml_ns_scope;
+
+    { used by modules during request processing }
+    { Place for modules to store private data }
+    priv: Pointer;
+  end;
+
+{ Is this XML element empty? }
+//#define APR_XML_ELEM_IS_EMPTY(e) ((e)->first_child == NULL && \
+//                                  (e)->first_cdata.first == NULL)
+
+{ apr_xml_doc: holds a parsed XML document }
+  apr_xml_doc = record
+    { root element }
+    root: Papr_xml_elem;
+    { array of namespaces used }
+    namespaces: Papr_array_header_t;
+  end;
+
+{ Opaque XML parser structure }
+  apr_xml_parser = record end;
+  Papr_xml_parser = ^apr_xml_parser;
+  PPapr_xml_parser = ^Papr_xml_parser;
+
+{
+ * Create an XML parser
+ * @param pool The pool for allocating the parser and the parse results.
+ * @return The new parser.
+ }
+function apr_xml_parser_create(pool: Papr_pool_t): Papr_xml_parser;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_create' + LibSuff4;
+
+{
+ * Parse a File, producing a xml_doc
+ * @param p      The pool for allocating the parse results.
+ * @param parser A pointer to *parser (needed so calling function can get
+ *               errors), will be set to NULL on successfull completion.
+ * @param ppdoc  A pointer to *apr_xml_doc (which has the parsed results in it)
+ * @param xmlfd  A file to read from.
+ * @param buffer_length Buffer length which would be suitable 
+ * @return Any errors found during parsing.
+ }
+function apr_xml_parse_file(p: Papr_pool_t;
+ parser: PPapr_xml_parser; ppdoc: PPapr_xml_doc;
+ xmlfd: Papr_file_t; buffer_length: apr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xml_parse_file' + LibSuff20;
+
+{
+ * Feed input into the parser
+ * @param parser The XML parser for parsing this data.
+ * @param data The data to parse.
+ * @param len The length of the data.
+ * @return Any errors found during parsing.
+ * @remark Use apr_xml_parser_geterror() to get more error information.
+ }
+function apr_xml_parser_feed(parser: Papr_xml_parser;
+ const data: PChar; len: apr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_feed' + LibSuff12;
+
+{
+ * Terminate the parsing and return the result
+ * @param parser The XML parser for parsing this data.
+ * @param pdoc The resulting parse information. May be NULL to simply
+ *             terminate the parsing without fetching the info.
+ * @return Any errors found during the final stage of parsing.
+ * @remark Use apr_xml_parser_geterror() to get more error information.
+ }
+function apr_xml_parser_done(parser: Papr_xml_parser;
+ pdoc: PPapr_xml_doc): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_done' + LibSuff8;
+
+{
+ * Fetch additional error information from the parser.
+ * @param parser The XML parser to query for errors.
+ * @param errbuf A buffer for storing error text.
+ * @param errbufsize The length of the error text buffer.
+ * @return The error buffer
+ }
+function apr_xml_parser_geterror(parser: Papr_xml_parser;
+ errbuf: PChar; errbufsize: apr_size_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xml_parser_geterror' + LibSuff12;
+
+{
+ * Converts an XML element tree to flat text 
+ * @param p The pool to allocate out of
+ * @param elem The XML element to convert
+ * @param style How to covert the XML.  One of:
+ * <PRE>
+ *     APR_XML_X2T_FULL                start tag, contents, end tag 
+ *     APR_XML_X2T_INNER               contents only 
+ *     APR_XML_X2T_LANG_INNER          xml:lang + inner contents 
+ *     APR_XML_X2T_FULL_NS_LANG        FULL + ns defns + xml:lang 
+ * </PRE>
+ * @param namespaces The namespace of the current XML element
+ * @param ns_map Namespace mapping
+ * @param pbuf Buffer to put the converted text into
+ * @param psize Size of the converted text
+ }
+procedure apr_xml_to_text(p: Papr_pool_t; const elem: Papr_xml_elem;
+ style: Integer; namespaces: Papr_array_header_t;
+ ns_map: PInteger; const pbuf: PPChar; psize: Papr_size_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xml_to_text' + LibSuff28;
+
+{ style argument values: }
+const
+  APR_XML_X2T_FULL         = 0;	{< start tag, contents, end tag }
+  APR_XML_X2T_INNER        = 1;	{< contents only }
+  APR_XML_X2T_LANG_INNER   = 2;	{< xml:lang + inner contents }
+  APR_XML_X2T_FULL_NS_LANG = 3;	{< FULL + ns defns + xml:lang }
+
+{
+ * empty XML element
+ * @param p The pool to allocate out of
+ * @param elem The XML element to empty
+ * @return the string that was stored in the XML element
+ }
+function apr_xml_empty_elem(p: Papr_pool_t; const elem: Papr_xml_elem): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xml_empty_elem' + LibSuff8;
+
+{
+ * quote an XML string
+ * Replace '<', '>', and '&' with '&lt;', '&gt;', and '&amp;'.
+ * @param p The pool to allocate out of
+ * @param s The string to quote
+ * @param quotes If quotes is true, then replace '"' with '&quot;'.
+ * @return The quoted string
+ * @note If the string does not contain special characters, it is not
+ * duplicated into the pool and the original string is returned.
+ }
+function apr_xml_quote_string(p: Papr_pool_t; const s: PChar;
+ quotes: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xml_quote_string' + LibSuff12;
+
+{
+ * Quote an XML element
+ * @param p The pool to allocate out of
+ * @param elem The element to quote
+ }
+procedure apr_xml_quote_elem(p: Papr_pool_t; elem: Papr_xml_elem);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xml_quote_elem' + LibSuff8;
+
+{ manage an array of unique URIs: apr_xml_insert_uri() and APR_XML_URI_ITEM() }
+
+{
+ * return the URI's (existing) index, or insert it and return a new index 
+ * @param uri_array array to insert into
+ * @param uri The uri to insert
+ * @return int The uri's index
+ }
+function apr_xml_insert_uri(uri_array: Papr_array_header_t;
+ const uri: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPRUtil name LibNamePrefix + 'apr_xml_insert_uri' + LibSuff8;
+
+{ Get the URI item for this XML element }
+//#define APR_XML_GET_URI_ITEM(ary, i) (((const char * const *)(ary)->elts)[i])
+

+ 64 - 0
packages/base/httpd/httpd-2.0/aprutil/aprutil.pas

@@ -0,0 +1,64 @@
+{
+ aprutil.pas
+
+ Copyright (C) 2006 Felipe Monteiro de Carvalho
+
+ This unit is a pascal binding for the Apache 2.0.58 headers.
+ The headers were released under the following copyright:
+}
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+unit aprutil;
+
+interface
+
+{$ifdef fpc}
+  {$mode delphi}{$H+}
+{$endif}
+
+{$IFNDEF FPC}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$IFDEF WIN32}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$ifdef Unix}
+  {$PACKRECORDS C}
+{$endif}
+
+uses
+{$ifdef WINDOWS}
+  Windows,
+{$ENDIF}
+  apr, ctypes;
+
+const
+{$IFDEF WINDOWS}
+  LibAPRUtil = 'libaprutil.dll';
+{$ELSE}
+  LibAPRUtil = '';
+{$ENDIF}
+
+{$include apr_xml.inc}
+{$include apr_uri.inc}
+{$include apr_md5.inc}
+
+implementation
+
+end.
+

+ 1160 - 0
packages/base/httpd/httpd-2.0/http_config.inc

@@ -0,0 +1,1160 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+  Declarations from other files centered here
+}
+const
+  (* Hook orderings *)
+  (** run this hook first, before ANYTHING *)
+  APR_HOOK_REALLY_FIRST	= -10;
+  (** run this hook first *)
+  APR_HOOK_FIRST	= 0;
+  (** run this hook somewhere *)
+  APR_HOOK_MIDDLE	= 10;
+  (** run this hook after every other hook which is defined*)
+  APR_HOOK_LAST		= 20;
+  (** run this hook last, after EVERYTHING *)
+  APR_HOOK_REALLY_LAST	= 30;
+
+
+//#include "apr_hooks.h"
+{.$include util_cfgtree.inc}
+
+{
+ * @file http_config.h
+ * @brief Apache Configuration
+ }
+
+{
+ * @defgroup ConfigDirectives Allowed locations for configuration directives.
+ *
+ * The allowed locations for a configuration directive are the union of
+ * those indicated by each set bit in the req_override mask.
+ }
+const
+  OR_NONE = 0;            {< *.conf is not available anywhere in this override }
+  OR_LIMIT = 1;	          {< *.conf inside <Directory> or <Location>
+				and .htaccess when AllowOverride Limit }
+  OR_OPTIONS = 2;         {< *.conf anywhere
+                                and .htaccess when AllowOverride Options }
+  OR_FILEINFO = 4;        {< *.conf anywhere
+				and .htaccess when AllowOverride FileInfo }
+  OR_AUTHCFG = 8;         {< *.conf inside <Directory> or <Location>
+				and .htaccess when AllowOverride AuthConfig }
+  OR_INDEXES = 16;        {< *.conf anywhere
+				and .htaccess when AllowOverride Indexes }
+  OR_UNSET = 32;          {< unset a directive (in Allow) }
+  ACCESS_CONF = 64;       {< *.conf inside <Directory> or <Location> }
+  RSRC_CONF = 128;	     {< *.conf outside <Directory> or <Location> }
+  EXEC_ON_READ = 256;     {< force directive to execute a command
+                which would modify the configuration (like including another
+                file, or IFModule }
+{ this directive can be placed anywhere }
+  OR_ALL = (OR_LIMIT or OR_OPTIONS or OR_FILEINFO or OR_AUTHCFG or OR_INDEXES);
+
+{
+ * This can be returned by a function if they don't wish to handle
+ * a command. Make it something not likely someone will actually use
+ * as an error code.
+ }
+const
+  DECLINE_CMD = '\a\b';
+
+{
+ * The central data structures around here...
+}
+
+{ Command dispatch structures... }
+
+{
+ * How the directives arguments should be parsed.
+ * @remark Note that for all of these except RAW_ARGS, the config routine is
+ *      passed a freshly allocated string which can be modified or stored
+ *      or whatever...
+ }
+type
+  cmd_how = (
+    RAW_ARGS,			{< cmd_func parses command line itself }
+    TAKE1,			{< one argument only }
+    TAKE2,			{< two arguments only }
+    ITERATE,			{< one argument, occuring multiple times
+				 * (e.g., IndexIgnore)
+                                 }
+    ITERATE2,			{< two arguments, 2nd occurs multiple times
+				 * (e.g., AddIcon)
+                                 }
+    FLAG,			{< One of 'On' or 'Off' }
+    NO_ARGS,			{< No args at all, e.g. </Directory> }
+    TAKE12,			{< one or two arguments }
+    TAKE3,			{< three arguments only }
+    TAKE23,			{< two or three arguments }
+    TAKE123,			{< one, two or three arguments }
+    TAKE13			{< one or three arguments }
+  );
+
+{
+ * This structure is passed to a command which is being invoked,
+ * to carry a large variety of miscellaneous data which is all of
+ * use to *somebody*...
+ }
+  Pcmd_parms = ^cmd_parms_struct;
+  
+//#if defined(AP_HAVE_DESIGNATED_INITIALIZER) || defined(DOXYGEN)
+
+{
+ * All the types of functions that can be used in directives
+ * @internal
+ }
+  cmd_func = function(cmd: Pcmd_parms; mconfig: Pointer): PChar; cdecl;
+  Pcmd_func = ^cmd_func;
+
+  { function to call for a no-args }
+  no_args_t = function (parms: Pcmd_parms; mconfig: Pointer): PChar;
+  { function to call for a raw-args }
+  raw_args_t = function (parms: Pcmd_parms; mconfig: Pointer; const args: PChar): Pchar;
+  { function to call for a take1 }
+  take1_t = function (parms: Pcmd_parms; mconfig: Pointer; const w: PChar): PChar;
+  { function to call for a take2 }
+  take2_t = function (parms: Pcmd_parms; mconfig: Pointer; const w, w2: PChar): PChar;
+  { function to call for a take3 }
+  take3_t = function (parms: Pcmd_parms; mconfig: Pointer; const w, w2, w3: PChar): PChar;
+  { function to call for a flag }
+  flag_t = function (parms: Pcmd_parms; mconfig: Pointer; on_: Integer): PChar;
+
+//const
+  { This configuration directive does not take any arguments }
+//  AP_NO_ARGS =	func.no_args;
+  { This configuration directive will handle it's own parsing of arguments}
+//  AP_RAW_ARGS =	func.raw_args;
+  { This configuration directive takes 1 argument}
+//  AP_TAKE1 =	func.take1;
+  { This configuration directive takes 2 arguments }
+//  AP_TAKE2 =	func.take2;
+  { This configuration directive takes 3 arguments }
+//  AP_TAKE3 =	func.take3;
+  { This configuration directive takes a flag (on/off) as a argument}
+//  AP_FLAG =	func.flag;
+
+{ method of declaring a directive with no arguments }
+//# define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
+    // directive, { .no_args=func }, mconfig, where, RAW_ARGS, help }
+{ method of declaring a directive with raw argument parsing }
+//# define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
+    // directive, { .raw_args=func }, mconfig, where, RAW_ARGS, help }
+{ method of declaring a directive which takes 1 argument }
+//# define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
+    // directive, { .take1=func }, mconfig, where, TAKE1, help }
+{ method of declaring a directive which takes multiple arguments }
+//# define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
+    // directive, { .take1=func }, mconfig, where, ITERATE, help }
+{ method of declaring a directive which takes 2 arguments }
+//# define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
+    // directive, { .take2=func }, mconfig, where, TAKE2, help }
+{ method of declaring a directive which takes 1 or 2 arguments }
+//# define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
+    // directive, { .take2=func }, mconfig, where, TAKE12, help }
+{ method of declaring a directive which takes multiple 2 arguments }
+//# define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
+    // directive, { .take2=func }, mconfig, where, ITERATE2, help }
+{ method of declaring a directive which takes 1 or 3 arguments }
+//# define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
+    // directive, { .take3=func }, mconfig, where, TAKE13, help }
+{ method of declaring a directive which takes 2 or 3 arguments }
+//# define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
+    // directive, { .take3=func }, mconfig, where, TAKE23, help }
+{ method of declaring a directive which takes 1 to 3 arguments }
+//# define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
+    // directive, { .take3=func }, mconfig, where, TAKE123, help }
+{ method of declaring a directive which takes 3 arguments }
+//# define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
+    // directive, { .take3=func }, mconfig, where, TAKE3, help }
+{ method of declaring a directive which takes a flag (on/off) as a argument}
+//# define AP_INIT_FLAG(directive, func, mconfig, where, help) \
+    // directive, { .flag=func }, mconfig, where, FLAG, help }
+
+//#else { AP_HAVE_DESIGNATED_INITIALIZER }
+
+//typedef const char *( *cmd_func) ();
+
+//# define AP_NO_ARGS  func
+//# define AP_RAW_ARGS func
+//# define AP_TAKE1    func
+//# define AP_TAKE2    func
+//# define AP_TAKE3    func
+//# define AP_FLAG     func
+
+//# define AP_INIT_NO_ARGS(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, RAW_ARGS, help }
+//# define AP_INIT_RAW_ARGS(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, RAW_ARGS, help }
+//# define AP_INIT_TAKE1(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, TAKE1, help }
+//# define AP_INIT_ITERATE(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, ITERATE, help }
+//# define AP_INIT_TAKE2(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, TAKE2, help }
+//# define AP_INIT_TAKE12(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, TAKE12, help }
+//# define AP_INIT_ITERATE2(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, ITERATE2, help }
+//# define AP_INIT_TAKE13(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, TAKE13, help }
+//# define AP_INIT_TAKE23(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, TAKE23, help }
+//# define AP_INIT_TAKE123(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, TAKE123, help }
+//# define AP_INIT_TAKE3(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, TAKE3, help }
+//# define AP_INIT_FLAG(directive, func, mconfig, where, help) \
+    { directive, func, mconfig, where, FLAG, help }
+
+//#endif { AP_HAVE_DESIGNATED_INITIALIZER }
+
+{
+ * The command record structure.  Each modules can define a table of these
+ * to define the directives it will implement.
+ }
+  command_struct = record
+    { Name of this command }
+    name: PChar;
+    { The function to be called when this directive is parsed }
+    func: cmd_func;
+    { Extra data, for functions which implement multiple commands... }
+    cmd_data: Pointer;
+    { What overrides need to be allowed to enable this command. }
+    req_override: Integer;
+    { What the command expects as arguments
+     *  @defvar cmd_how args_how}
+    args_how: cmd_how;
+
+    { 'usage' message, in case of syntax errors }
+    errmsg: PChar;
+  end;
+  command_rec = command_struct;
+  Pcommand_rec = ^command_rec;
+
+  { Constants here were moved up }
+
+  { Common structure for reading of config files / passwd files etc. }
+
+  getch_t = function (param: Pointer): Integer;
+  
+  getstr_t = function (buf: Pointer; bufsiz: size_t; param: Pointer): Pointer;
+  
+  close_t = function (param: Pointer): Integer;
+
+  ap_configfile_t = record
+    getch: getch_t;    {< a getc()-like function }
+    getstr: getstr_t;  {< a fgets()-like function }
+    close: close_t;    {< a close handler function }
+    param: Pointer;    {< the argument passed to getch/getstr/close }
+    name: PChar;       {< the filename / description }
+    line_number: cuint;{< current line number, starting at 1 }
+  end;
+  
+  Pap_configfile_t = ^ap_configfile_t;
+  PPap_configfile_t = ^Pap_configfile_t;
+
+{
+ * This structure is passed to a command which is being invoked,
+ * to carry a large variety of miscellaneous data which is all of
+ * use to *somebody*...
+ }
+  cmd_parms_struct = record
+    { Argument to command from cmd_table }
+    info: Pointer;
+    { Which allow-override bits are set }
+    override_: Integer;
+    { Which methods are <Limit>ed }
+    limited: apr_int64_t;
+    { methods which are limited }
+    limited_xmethods: Papr_array_header_t;
+    { methods which are xlimited }
+    xlimited: Pap_method_list_t;
+
+    { Config file structure. }
+    config_file: Pap_configfile_t;
+    { the directive specifying this command }
+    directive: Pap_directive_t;
+
+    { Pool to allocate new storage in }
+    pool: Papr_pool_t;
+    { Pool for scratch memory; persists during configuration, but
+     *  wiped before the first request is served...  }
+    temp_pool: Papr_pool_t;
+    { Server_rec being configured for }
+    server: Pserver_rec;
+    { If configuring for a directory, pathname of that directory.
+     *  NOPE!  That's what it meant previous to the existance of <Files>, 
+     * <Location> and regex matching.  Now the only usefulness that can be 
+     * derived from this field is whether a command is being called in a 
+     * server context (path == NULL) or being called in a dir context 
+     * (path != NULL).  }
+    path: PChar;
+    { configuration command }
+    cmd: Pcommand_rec;
+
+    { per_dir_config vector passed to handle_command }
+    context: Pap_conf_vector_t;
+    { directive with syntax error }
+    err_directive: Pap_directive_t;
+  end;
+
+  cmd_parms = cmd_parms_struct;
+
+{
+ * Module structures.  Just about everything is dispatched through
+ * these, directly or indirectly (through the command and handler
+ * tables).
+ }
+type
+  Pmodule_struct = ^module_struct;
+
+  module_struct = record
+    { API version, *not* module version; check that module is
+     * compatible with this version of the server.
+     }
+    version: Integer;
+    { API minor version. Provides API feature milestones. Not checked
+     *  during module init }
+    minor_version: Integer;
+    { Index to this modules structures in config vectors.  }
+    module_index: Integer;
+
+    { The name of the module's C file }
+    name: PChar;
+    { The handle for the DSO.  Internal use only }
+    dynamic_load_handle: Pointer;
+
+    { A pointer to the next module in the list
+     *  @defvar module_struct *next }
+    next: Pmodule_struct;
+
+    { Magic Cookie to identify a module structure;  It's mainly
+     *  important for the DSO facility (see also mod_so).  }
+    magic: Cardinal;
+
+    { Function to allow MPMs to re-write command line arguments.  This
+     *  hook is only available to MPMs.
+     *  @param The process that the server is running in.
+     }
+    rewrite_args: procedure(process: Pprocess_rec); cdecl;
+
+    { Function to allow all modules to create per directory configuration
+     *  structures.
+     *  @param p The pool to use for all allocations.
+     *  @param dir The directory currently being processed.
+     *  @return The per-directory structure created
+     }
+    create_dir_config: function(p: Papr_pool_t; dir: PChar): Pointer; cdecl;
+
+    { Function to allow all modules to merge the per directory configuration
+     *  structures for two directories.
+     *  @param p The pool to use for all allocations.
+     *  @param base_conf The directory structure created for the parent directory.
+     *  @param new_conf The directory structure currently being processed.
+     *  @return The new per-directory structure created
+     }
+    merge_dir_config: function(p: Papr_pool_t; base_conf: Pointer;
+      new_conf: Pointer): Pointer; cdecl;
+
+    { Function to allow all modules to create per server configuration
+     *  structures.
+     *  @param p The pool to use for all allocations.
+     *  @param s The server currently being processed.
+     *  @return The per-server structure created
+     }
+    create_server_config: function(p: Papr_pool_t; s: Pserver_rec): Pointer; cdecl;
+
+    { Function to allow all modules to merge the per server configuration
+     *  structures for two servers.
+     *  @param p The pool to use for all allocations.
+     *  @param base_conf The directory structure created for the parent directory.
+     *  @param new_conf The directory structure currently being processed.
+     *  @return The new per-directory structure created
+     }
+    merge_server_config: function(p: Papr_pool_t; base_conf: Pointer;
+      new_conf: Pointer): Pointer; cdecl;
+
+    { A command_rec table that describes all of the directives this module
+     * defines. }
+    cmds: Pcommand_rec;
+
+    { A hook to allow modules to hook other points in the request processing.
+     *  In this function, modules should call the ap_hook_*() functions to
+     *  register an interest in a specific step in processing the current
+     *  request.
+     *  @param p the pool to use for all allocations
+     }
+    register_hooks: procedure(p: Papr_pool_t); cdecl;
+  end;
+
+  module = module_struct;
+  Pmodule = ^module;
+  PPmodule = ^Pmodule;
+
+{
+ * @defgroup ModuleInit Module structure initializers
+ *
+ * Initializer for the first few module slots, which are only
+ * really set up once we start running.  Note that the first two slots
+ * provide a version check; this should allow us to deal with changes to
+ * the API. The major number should reflect changes to the API handler table
+ * itself or removal of functionality. The minor number should reflect
+ * additions of functionality to the existing API. (the server can detect
+ * an old-format module, and either handle it back-compatibly, or at least
+ * signal an error). See src/include/ap_mmn.h for MMN version history.
+ }
+
+{ The one used in Apache 1.3, which will deliberately cause an error }
+//#define STANDARD_MODULE_STUFF	this_module_needs_to_be_ported_to_apache_2_0
+
+{ Use this in all standard modules }
+procedure STANDARD20_MODULE_STUFF(var mod_: module);
+
+{ Use this only in MPMs }
+procedure MPM20_MODULE_STUFF(var mod_: module);
+
+{ CONFIGURATION VECTOR FUNCTIONS }
+
+{ configuration vector structure - Moved to httpd.pas}
+
+{
+  ap_get_module_config, ap_set_module_config are both commented out because even thought
+ they are on the headers, they are not present on the libhttpd.dll library.
+}
+
+{
+ * Generic accessors for other modules to get at their own module-specific
+ * data
+ * @param conf_vector The vector in which the modules configuration is stored.
+ *        usually r->per_dir_config or s->module_config
+ * @param m The module to get the data for.
+ * @return The module-specific data
+ }
+{
+  Function not found on the dll
+}
+//function ap_get_module_config(const cv: Pap_conf_vector_t; const m: Pmodule): Pointer;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibHTTPD name LibNamePrefix + 'ap_get_module_config' + LibSuff8;
+
+{
+ * Generic accessors for other modules to set at their own module-specific
+ * data
+ * @param conf_vector The vector in which the modules configuration is stored.
+ *        usually r->per_dir_config or s->module_config
+ * @param m The module to set the data for.
+ * @param val The module-specific data to set
+ }
+//procedure ap_set_module_config(const cv: Pap_conf_vector_t; const m: Pmodule;
+// val: Pointer);
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibHTTPD name LibNamePrefix + 'ap_set_module_config' + LibSuff12;
+
+{$ifndef AP_DEBUG}
+
+function ap_get_module_config(v: Pap_conf_vector_t; m: Pmodule): Pap_conf_vector_t;
+
+procedure ap_set_module_config(v: Pap_conf_vector_t; m: Pmodule; val: Pap_conf_vector_t);
+
+{$endif} { AP_DEBUG }
+
+
+{
+ * Generic command handling function for strings
+ * @param cmd The command parameters for this directive
+ * @param struct_ptr pointer into a given type
+ * @param arg The argument to the directive
+ * @return An error string or NULL on success
+ }
+function ap_set_string_slot(cmd: Pcmd_parms; struct_ptr: Pointer; const arg: PChar): PChar;
+ cdecl; external LibHTTPD name 'ap_set_string_slot';
+
+{
+ * Generic command handling function for integers
+ * @param cmd The command parameters for this directive
+ * @param struct_ptr pointer into a given type
+ * @param arg The argument to the directive
+ * @return An error string or NULL on success
+ }
+function ap_set_int_slot(cmd: Pcmd_parms; struct_ptr: Pointer; const arg: PChar): PChar;
+ cdecl; external LibHTTPD name 'ap_set_int_slot';
+
+{
+ * Return true if the specified method is limited by being listed in
+ * a <Limit> container, or by *not* being listed in a <LimiteExcept>
+ * container.
+ *
+ * @param   method  Pointer to a string specifying the method to check.
+ * @param   cmd     Pointer to the cmd_parms structure passed to the
+ *                  directive handler.
+ * @return  0 if the method is not limited in the current scope
+ }
+function ap_method_is_limited(cmd: Pcmd_parms; const method: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_method_is_limited' + LibSuff8;
+
+{
+ * Generic command handling function for strings, always sets the value
+ * to a lowercase string
+ * @param cmd The command parameters for this directive
+ * @param struct_ptr pointer into a given type
+ * @param arg The argument to the directive
+ * @return An error string or NULL on success
+ }
+function ap_set_string_slot_lower(cmd: Pcmd_parms; struct_ptr: Pointer; const arg: PChar): PChar;
+ cdecl; external LibHTTPD name 'ap_set_string_slot_lower';
+
+{
+ * Generic command handling function for flags
+ * @param cmd The command parameters for this directive
+ * @param struct_ptr pointer into a given type
+ * @param arg The argument to the directive (either 1 or 0)
+ * @return An error string or NULL on success
+ }
+function ap_set_flag_slot(cmd: Pcmd_parms; struct_ptr: Pointer; const arg: PChar): PChar;
+ cdecl; external LibHTTPD name 'ap_set_flag_slot';
+
+{
+ * Generic command handling function for files
+ * @param cmd The command parameters for this directive
+ * @param struct_ptr pointer into a given type
+ * @param arg The argument to the directive
+ * @return An error string or NULL on success
+ }
+function ap_set_file_slot(cmd: Pcmd_parms; struct_ptr: Pointer; const arg: PChar): PChar;
+ cdecl; external LibHTTPD name 'ap_set_file_slot';
+
+{
+ * Generic command handling function to respond with cmd->help as an error
+ * @param cmd The command parameters for this directive
+ * @param struct_ptr pointer into a given type
+ * @param arg The argument to the directive
+ * @return The cmd->help value as the error string
+ * @tip This allows simple declarations such as;
+ * <pre>
+ *     AP_INIT_RAW_ARGS("Foo", ap_set_deprecated, NULL, OR_ALL, 
+ *         "The Foo directive is no longer supported, use Bar"),
+ * </pre>
+ }
+function ap_set_deprecated(cmd: Pcmd_parms; struct_ptr: Pointer; const arg: PChar): PChar;
+ cdecl; external LibHTTPD name 'ap_set_deprecated';
+
+{
+ * For modules which need to read config files, open logs, etc. this returns
+ * the canonical form of fname made absolute to ap_server_root.
+ * @param p pool to allocate data from
+ * @param fname The file name
+ }
+function ap_server_root_relative(p: Papr_pool_t; const fname: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_server_root_relative' + LibSuff8;
+
+{ Finally, the hook for dynamically loading modules in... }
+
+{
+ * Add a module to the server
+ * @param m The module structure of the module to add
+ * @param p The pool of the same lifetime as the module
+ }
+procedure ap_add_module(m: Pmodule; p: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_add_module' + LibSuff8;
+
+{
+ * Remove a module from the server.  There are some caveats:
+ * when the module is removed, its slot is lost so all the current
+ * per-dir and per-server configurations are invalid. So we should
+ * only ever call this function when you are invalidating almost
+ * all our current data. I.e. when doing a restart.
+ * @param m the module structure of the module to remove
+ }
+procedure ap_remove_module(m: Pmodule);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_remove_module' + LibSuff4;
+
+{
+ * Add a module to the chained modules list and the list of loaded modules
+ * @param m The module structure of the module to add
+ * @param p The pool with the same lifetime as the module
+ }
+procedure ap_add_loaded_module(mod_: Pmodule; p: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_add_loaded_module' + LibSuff8;
+
+{
+ * Remove a module fromthe chained modules list and the list of loaded modules
+ * @param m the module structure of the module to remove
+ }
+procedure ap_remove_loaded_module(m: Pmodule);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_remove_loaded_module' + LibSuff4;
+
+{
+ * Add a module to the list of loaded module based on the name of the
+ * module
+ * @param name The name of the module
+ * @param p The pool valid for the lifetime of the module
+ * @return 1 on success, 0 on failure
+ }
+function ap_add_named_module(const name: PChar; p: Papr_pool_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_add_named_module' + LibSuff8;
+
+{
+ * Find the name of the specified module
+ * @param m The module to get the name for
+ * @return the name of the module
+ }
+function ap_find_module_name(m: Pmodule): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_find_module_name' + LibSuff4;
+
+{
+ * Find a module based on the name of the module
+ * @param name the name of the module
+ * @return the module structure if found, NULL otherwise
+ }
+function ap_find_linked_module(const name: PChar): Pmodule;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_find_linked_module' + LibSuff4;
+
+{
+ * Open a ap_configfile_t as apr_file_t
+ * @param ret_cfg open ap_configfile_t struct pointer
+ * @param p The pool to allocate the structure from
+ * @param name the name of the file to open
+ }
+function ap_pcfg_openfile(ret_cfg: PPap_configfile_t;
+ p: Papr_pool_t; const name: PChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_pcfg_openfile' + LibSuff12;
+
+{
+ * Allocate a ap_configfile_t handle with user defined functions and params 
+ * @param p The pool to allocate from
+ * @param descr The name of the file
+ * @param param The argument passed to getch/getstr/close
+ * @param getc_func The getch function
+ * @param gets_func The getstr function
+ * @param close_func The close function
+ }
+type
+  getc_func_t = function (param: Pointer): Integer;
+  gets_func_t = function (buf: Pointer; bufsiz: size_t; param: Pointer): Pointer;
+  close_func_t = function (param: Pointer): Integer;
+
+function ap_pcfg_open_custom(p: Papr_pool_t;
+ const descr: PChar; param: Pointer;
+ getc_func: getc_func_t; gets_func: gets_func_t;
+ close_func: close_func_t): Pap_configfile_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_pcfg_open_custom' + LibSuff24;
+
+{
+ * Read one line from open ap_configfile_t, strip LF, increase line number
+ * @param buf place to store the line read
+ * @param bufsize size of the buffer
+ * @param cfp File to read from
+ * @return 1 on success, 0 on failure
+ }
+function ap_cfg_getline(bug: PChar;
+ bufsize: size_t; cfp: Pap_configfile_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_cfg_getline' + LibSuff12;
+
+{
+ * Read one char from open configfile_t, increase line number upon LF 
+ * @param cfp The file to read from
+ * @return the character read
+ }
+function ap_cfg_getc(cfp: Pap_configfile_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_cfg_getc' + LibSuff4;
+
+{
+ * Detach from open ap_configfile_t, calling the close handler
+ * @param cfp The file to close
+ * @return 1 on sucess, 0 on failure
+ }
+function ap_cfg_closefile(cfp: Pap_configfile_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_cfg_closefile' + LibSuff4;
+
+{
+ * Read all data between the current <foo> and the matching </foo>.  All
+ * of this data is forgotten immediately.  
+ * @param cmd The cmd_parms to pass to the directives inside the container
+ * @param directive The directive name to read until
+ * @return Error string on failure, NULL on success
+ }
+function ap_soak_end_container(cmd: Pcmd_parms; directive: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_soak_end_container' + LibSuff8;
+
+{
+ * Read all data between the current <foo> and the matching </foo> and build
+ * a config tree from it
+ * @param p pool to allocate from
+ * @param temp_pool Temporary pool to allocate from
+ * @param parms The cmd_parms to pass to all directives read
+ * @param current The current node in the tree
+ * @param curr_parent The current parent node
+ * @param orig_directive The directive to read until hit.
+ * @return Error string on failure, NULL on success
+}
+function ap_build_cont_config(p, temp_pool: Papr_pool_t;
+ parms: Pcmd_parms; current, curr_parent: PPap_directive_t;
+ orig_directive: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_build_cont_config' + LibSuff24;
+
+{
+ * Build a config tree from a config file
+ * @param parms The cmd_parms to pass to all of the directives in the file
+ * @param conf_pool The pconf pool
+ * @param temp_pool The temporary pool
+ * @param conftree Place to store the root node of the config tree
+ * @return Error string on erro, NULL otherwise
+ }
+function ap_build_config(parms: Pcmd_parms;
+ conf_pool, temp_pool: Papr_pool_t; conftree: PPap_directive_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_build_config' + LibSuff16;
+
+{
+ * Walk a config tree and setup the server's internal structures
+ * @param conftree The config tree to walk
+ * @param parms The cmd_parms to pass to all functions
+ * @param section_vector The per-section config vector.
+ * @return Error string on error, NULL otherwise
+ }
+function ap_walk_config(conftree: Pap_directive_t;
+ parms: Pcmd_parms; section_vector: Pap_conf_vector_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_walk_config' + LibSuff12;
+
+{
+ * @defgroup ap_check_cmd_context ap_check_cmd_context
+ }
+{
+ * Check the context a command is used in.
+ * @param cmd The command to check
+ * @param forbidden Where the command is forbidden.
+ * @return Error string on error, NULL on success
+ }
+function ap_check_cmd_context(cmd: Pcmd_parms;
+ forbidden: cuint): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_check_cmd_context' + LibSuff8;
+
+const
+  NOT_IN_VIRTUALHOST    = $01; {< Forbidden in <Virtualhost> }
+  NOT_IN_LIMIT          = $02; {< Forbidden in <Limit> }
+  NOT_IN_DIRECTORY      = $04; {< Forbidden in <Directory> }
+  NOT_IN_LOCATION       = $08; {< Forbidden in <Location> }
+  NOT_IN_FILES          = $10; {< Forbidden in <Files> }
+{ Forbidden in <Directory>/<Location>/<Files>}
+  NOT_IN_DIR_LOC_FILE   = (NOT_IN_DIRECTORY or NOT_IN_LOCATION or NOT_IN_FILES);
+{ Forbidden in <VirtualHost>/<Limit>/<Directory>/<Location>/<Files> }
+  GLOBAL_ONLY           = (NOT_IN_VIRTUALHOST or NOT_IN_LIMIT or NOT_IN_DIR_LOC_FILE);
+
+//#ifdef CORE_PRIVATE
+
+{
+ * The topmost module in the list
+ * @defvar module *ap_top_module
+ }
+//AP_DECLARE_DATA extern module *ap_top_module;
+
+{
+ * Array of all statically linked modules
+ * @defvar module *ap_prelinked_modules[]
+ }
+//AP_DECLARE_DATA extern module *ap_prelinked_modules[];
+{
+ * Array of all preloaded modules
+ * @defvar module *ap_preloaded_modules[]
+ }
+//AP_DECLARE_DATA extern module *ap_preloaded_modules[];
+{
+ * Array of all loaded modules
+ * @defvar module **ap_loaded_modules
+ }
+//AP_DECLARE_DATA extern module **ap_loaded_modules;
+
+{ For mod_so.c... }
+{ Run a single module's two create_config hooks
+ *  @param p the pool to allocate from
+ *  @param s The server to configure for.
+ *  @param m The module to configure
+ }
+procedure ap_single_module_configure(p: Papr_pool_t;
+ s: Pserver_rec; m: Pmodule);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_single_module_configure' + LibSuff12;
+
+{ For http_main.c... }
+{
+ * Add all of the prelinked modules into the loaded module list
+ * @param process The process that is currently running the server
+ }
+procedure ap_setup_prelinked_modules(process: Pprocess_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_setup_prelinked_modules' + LibSuff4;
+
+{
+ * Show the preloaded configuration directives, the help string explaining
+ * the directive arguments, in what module they are handled, and in
+ * what parts of the configuration they are allowed.  Used for httpd -h.
+ }
+procedure ap_show_directives;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_show_directives' + LibSuff0;
+
+{
+ * Show the preloaded module names.  Used for httpd -l. 
+ }
+procedure ap_show_modules;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_show_modules' + LibSuff0;
+
+{
+ * Show the MPM name.  Used in reporting modules such as mod_info to
+ * provide extra information to the user
+ }
+function ap_show_mpm: PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_show_mpm' + LibSuff0;
+
+{
+ * Read all config files and setup the server
+ * @param process The process running the server
+ * @param temp_pool A pool to allocate temporary data from.
+ * @param config_name The name of the config file
+ * @param conftree Place to store the root of the config tree
+ * @return The setup server_rec list.
+ }
+function ap_read_config(process: Pprocess_rec;
+ temp_pool: Papr_pool_t; const config_name: PChar;
+ conftree: PPap_directive_t): Pserver_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_read_config' + LibSuff16;
+
+{
+ * Run all rewrite args hooks for loaded modules
+ * @param process The process currently running the server
+ }
+procedure ap_run_rewrite_args(process: Pprocess_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_run_rewrite_args' + LibSuff4;
+
+{
+ * Run the register hooks function for a specified module
+ * @param m The module to run the register hooks function fo
+ * @param p The pool valid for the lifetime of the module
+ }
+procedure ap_register_hooks(m: Pmodule; p: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_register_hooks' + LibSuff8;
+
+{
+ * Setup all virtual hosts
+ * @param p The pool to allocate from
+ * @param main_server The head of the server_rec list
+ }
+procedure ap_fixup_virtual_hosts(p: Papr_pool_t; main_server: Pserver_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_fixup_virtual_hosts' + LibSuff8;
+
+{ For http_request.c... }
+
+{
+ * Setup the config vector for a request_rec
+ * @param p The pool to allocate the config vector from
+ * @return The config vector
+ }
+function ap_create_request_config(p: Papr_pool_t): Pap_conf_vector_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_create_request_config' + LibSuff4;
+
+{
+ * Setup the config vector for per dir module configs
+ * @param p The pool to allocate the config vector from
+ * @return The config vector
+ }
+function ap_create_per_dir_config(p: Papr_pool_t): Pap_conf_vector_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_create_per_dir_config' + LibSuff4;
+
+{
+ * Run all of the modules merge per dir config functions
+ * @param p The pool to pass to the merge functions
+ * @param base The base directory config structure
+ * @param new_conf The new directory config structure
+ }
+function ap_merge_per_dir_configs(p: Papr_pool_t;
+ base, new_conf: Pap_conf_vector_t): Pap_conf_vector_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_merge_per_dir_configs' + LibSuff12;
+
+{ For http_connection.c... }
+{
+ * Setup the config vector for a connection_rec
+ * @param p The pool to allocate the config vector from
+ * @return The config vector
+ }
+function ap_create_conn_config(p: Papr_pool_t): Pap_conf_vector_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_create_conn_config' + LibSuff4;
+
+{ For http_core.c... (<Directory> command and virtual hosts) }
+
+{
+ * parse an htaccess file
+ * @param resulting htaccess_result
+ * @param r The request currently being served
+ * @param override Which overrides are active
+ * @param path The path to the htaccess file
+ * @param access_name The list of possible names for .htaccess files
+ * int The status of the current request
+ }
+function ap_parse_htaccess(result: PPap_conf_vector_t;
+ r: Prequest_rec; override_: Integer;
+ const path, access_name: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_parse_htaccess' + LibSuff20;
+
+{
+ * Setup a virtual host
+ * @param p The pool to allocate all memory from
+ * @param hostname The hostname of the virtual hsot
+ * @param main_server The main server for this Apache configuration
+ * @param ps Place to store the new server_rec
+ * return Error string on error, NULL on success
+ }
+function ap_init_virtual_host(p: Papr_pool_t;
+ const hostname: PChar; main_server: Pserver_rec;
+ m: PPserver_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_init_virtual_host' + LibSuff16;
+
+{
+ * Process the config file for Apache
+ * @param s The server rec to use for the command parms
+ * @param fname The name of the config file
+ * @param conftree The root node of the created config tree
+ * @param p Pool for general allocation
+ * @param ptem Pool for temporary allocation
+ }
+procedure ap_process_resource_config(s: Pserver_rec;
+ const fname: PChar; conftree: PPap_directive_t;
+ p, ptemp: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_process_resource_config' + LibSuff20;
+
+{
+ * Process all directives in the config tree
+ * @param s The server rec to use in the command parms
+ * @param conftree The config tree to process
+ * @param p The pool for general allocation
+ * @param ptemp The pool for temporary allocations
+ }
+procedure ap_process_config_tree(s: Pserver_rec;
+ conftree: Pap_directive_t; p, ptemp: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_process_config_tree' + LibSuff16;
+
+{ Module-method dispatchers, also for http_request.c }
+{
+ * Run the handler phase of each module until a module accepts the
+ * responsibility of serving the request
+ * @param r The current request
+ * @return The status of the current request
+ }
+function ap_invoke_handler(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_invoke_handler' + LibSuff4;
+
+{ for mod_perl }
+
+{
+ * Find a given directive in a command_rec table
+ * @param name The directive to search for
+ * @param cmds The table to search
+ * @return The directive definition of the specified directive
+ }
+function ap_find_command(const name: PChar;
+ const cmds: Pcommand_rec): Pcommand_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_find_command' + LibSuff8;
+
+{
+ * Find a given directive in a list module
+ * @param cmd_name The directive to search for
+ * @param mod The module list to search
+ * @return The directive definition of the specified directive
+ }
+function ap_find_command_in_modules(const cmd_name: PChar;
+ mod_: PPmodule): Pcommand_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_find_command_in_modules' + LibSuff8;
+
+{
+ * Ask a module to create per-server and per-section (dir/loc/file) configs
+ * (if it hasn't happened already). The results are stored in the server's
+ * config, and the specified per-section config vector.
+ * @param server The server to operate upon.
+ * @param section_vector The per-section config vector.
+ * @param section Which section to create a config for.
+ * @param mod The module which is defining the config data.
+ * @param pconf A pool for all configuration allocations.
+ * @return The (new) per-section config data.
+ }
+function ap_set_config_vectors(server: Pserver_rec;
+ ection_vector: Pap_conf_vector_t; const section: PChar;
+ mod_: Pmodule; pconf: Papr_pool_t): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_set_config_vectors' + LibSuff20;
+
+{#endif}
+
+{ Hooks }
+
+{
+ * Run the header parser functions for each module
+ * @param r The current request
+ * @return OK or DECLINED
+ }
+type
+  ap_HOOK_header_parser_t = function(r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_header_parser(pf: ap_HOOK_header_parser_t;
+ const aszPre: PPChar; const aszSucc:
+ PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_header_parser' + LibSuff16;
+
+{
+ * Run the pre_config function for each module
+ * @param pconf The config pool
+ * @param plog The logging streams pool
+ * @param ptemp The temporary pool
+ * @return OK or DECLINED on success anything else is a error
+ }
+type
+  ap_HOOK_pre_config_t = function(pconf: Papr_pool_t; plog: Papr_pool_t;
+    ptemp: Papr_pool_t): Integer; cdecl;
+
+procedure ap_hook_pre_config(pf: ap_HOOK_pre_config_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_pre_config' + LibSuff16;
+
+{
+ * Run the post_config function for each module
+ * @param pconf The config pool
+ * @param plog The logging streams pool
+ * @param ptemp The temporary pool
+ * @param s The list of server_recs
+ * @return OK or DECLINED on success anything else is a error
+ }
+type
+  ap_HOOK_post_config_t = function(pconf, plog, ptemp: Papr_pool_t; s: Pserver_rec): Integer; cdecl;
+
+procedure ap_hook_post_config(pf: ap_HOOK_post_config_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_post_config' + LibSuff16;
+
+{
+ * Run the open_logs functions for each module
+ * @param pconf The config pool
+ * @param plog The logging streams pool
+ * @param ptemp The temporary pool
+ * @param s The list of server_recs
+ * @return OK or DECLINED on success anything else is a error
+ }
+type
+  ap_HOOK_open_logs_t = function(pconf: Papr_pool_t; plog: Papr_pool_t;
+    ptemp: Papr_pool_t; s: Pserver_rec): Integer; cdecl;
+
+procedure ap_hook_open_logs(pf: ap_HOOK_open_logs_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_open_logs' + LibSuff16;
+
+{
+ * Run the child_init functions for each module
+ * @param pchild The child pool
+ * @param s The list of server_recs in this server 
+ }
+type
+  ap_HOOK_child_init_t = procedure(pchild: Papr_pool_t; s: Pserver_rec); cdecl;
+
+procedure ap_hook_child_init(pf: ap_HOOK_child_init_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_child_init' + LibSuff16;
+
+{
+ * Run the handler functions for each module
+ * @param r The request_rec
+ * @remark non-wildcard handlers should HOOK_MIDDLE, wildcard HOOK_LAST
+ }
+type
+  ap_HOOK_handler_t = function(r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_handler(pf: ap_HOOK_handler_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_handler' + LibSuff16;
+
+{
+ * Run the quick handler functions for each module. The quick_handler
+ * is run before any other requests hooks are called (location_walk,
+ * directory_walk, access checking, et. al.). This hook was added
+ * to provide a quick way to serve content from a URI keyed cache.
+ * 
+ * @param r The request_rec
+ * @param lookup_uri Controls whether the caller actually wants content or not.
+ * lookup is set when the quick_handler is called out of 
+ * ap_sub_req_lookup_uri()
+ }
+type
+  ap_HOOK_quick_handler_t = function(r: Prequest_rec;
+    lookup_uri: Integer): Integer; cdecl;
+
+procedure ap_hook_quick_handler(pf: ap_HOOK_quick_handler_t;
+ const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_quick_handler' + LibSuff16;
+
+{
+ * Retrieve the optional functions for each module.
+ * This is run immediately before the server starts. Optional functions should
+ * be registered during the hook registration phase.
+ }
+type
+  ap_HOOK_optional_fn_retrieve_t = procedure; cdecl;
+
+procedure ap_hook_optional_fn_retrieve(pf: ap_HOOK_optional_fn_retrieve_t;
+ const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_optional_fn_retrieve' + LibSuff16;
+

+ 157 - 0
packages/base/httpd/httpd-2.0/http_connection.inc

@@ -0,0 +1,157 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{#include "apr_hooks.h"
+#include "apr_network_io.h"
+#include "apr_buckets.h"}
+
+{
+ * @package Apache connection library
+ }
+//#ifdef CORE_PRIVATE
+{
+ * This is the protocol module driver.  This calls all of the
+ * pre-connection and connection hooks for all protocol modules.
+ * @param c The connection on which the request is read
+ * @param csd The mechanism on which this connection is to be read.  
+ *            Most times this will be a socket, but it is up to the module
+ *            that accepts the request to determine the exact type.
+ * @deffunc void ap_process_connection(conn_rec *c, void *csd)
+ }
+procedure ap_process_connection(c: Pconn_rec; csd: Pointer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_process_connection' + LibSuff8;
+
+procedure ap_flush_conn(c: Pconn_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_flush_conn' + LibSuff4;
+
+{
+ * This function is responsible for the following cases:
+ * <pre>
+ * we now proceed to read from the client until we get EOF, or until
+ * MAX_SECS_TO_LINGER has passed.  the reasons for doing this are
+ * documented in a draft:
+ *
+ * http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-connection-00.txt
+ *
+ * in a nutshell -- if we don't make this effort we risk causing
+ * TCP RST packets to be sent which can tear down a connection before
+ * all the response data has been sent to the client.
+ * </pre>
+ * @param c The connection we are closing
+ }
+procedure ap_lingering_close(c: Pconn_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_lingering_close' + LibSuff4;
+
+//#endif COREPRIVATE
+
+  { Hooks }
+{
+ * create_connection is a RUN_FIRST hook which allows modules to create 
+ * connections. In general, you should not install filters with the 
+ * create_connection hook. If you require vhost configuration information 
+ * to make filter installation decisions, you must use the pre_connection
+ * or install_network_transport hook. This hook should close the connection
+ * if it encounters a fatal error condition.
+ *
+ * @param p The pool from which to allocate the connection record
+ * @param csd The socket that has been accepted
+ * @param conn_id A unique identifier for this connection.  The ID only
+ *                needs to be unique at that time, not forever.
+ * @param sbh A handle to scoreboard information for this connection.
+ * @return An allocated connection record or NULL.
+ }
+type
+  ap_HOOK_create_connection_t = function (p: Papr_pool_t; server: Pserver_rec;
+   csd: Papr_socket_t; conn_id: cLong; sbh: Pointer;
+   alloc: Papr_bucket_alloc_t): Pconn_rec; cdecl;
+
+procedure ap_hook_create_connection(pf: ap_HOOK_create_connection_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_create_connection' + LibSuff16;
+
+{
+ * This hook gives protocol modules an opportunity to set everything up
+ * before calling the protocol handler.  All pre-connection hooks are
+ * run until one returns something other than ok or decline
+ * @param c The connection on which the request has been received.
+ * @param csd The mechanism on which this connection is to be read.  
+ *            Most times this will be a socket, but it is up to the module
+ *            that accepts the request to determine the exact type.
+ * @return OK or DECLINED
+ * @deffunc int ap_run_pre_connection(conn_rec *c, void *csd)
+ }
+type
+  ap_HOOK_pre_connection_t = function (c: Pconn_rec; csd: Pointer): Integer; cdecl;
+
+procedure ap_hook_pre_connection(pf: ap_HOOK_pre_connection_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_pre_connection' + LibSuff16;
+
+{
+ * This hook implements different protocols.  After a connection has been
+ * established, the protocol module must read and serve the request.  This
+ * function does that for each protocol module.  The first protocol module
+ * to handle the request is the last module run.
+ * @param c The connection on which the request has been received.
+ * @return OK or DECLINED
+ * @deffunc int ap_run_process_connection(conn_rec *c)
+ }
+type
+  ap_HOOK_process_connection_t = function (c: Pconn_rec): Integer; cdecl;
+
+procedure ap_hook_process_connection(pf: ap_HOOK_process_connection_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_process_connection' + LibSuff16;
+
+{ End Of Connection (EOC) bucket }
+
+//AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_eoc;
+
+{
+ * Determine if a bucket is an End Of Connection (EOC) bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define AP_BUCKET_IS_EOC(e)         (e->type == &ap_bucket_type_eoc)
+
+{
+ * Make the bucket passed in an End Of Connection (EOC) bucket
+ * @param b The bucket to make into an EOC bucket
+ * @return The new bucket, or NULL if allocation failed
+ * @deffunc apr_bucket *ap_bucket_eoc_make(apr_bucket *b)
+ }
+function ap_bucket_eoc_make(b: Papr_bucket): Papr_bucket;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_bucket_eoc_make' + LibSuff4;
+
+{
+ * Create a bucket referring to an End Of Connection (EOC). This indicates
+ * that the connection will be closed.
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ * @deffunc apr_bucket *ap_bucket_eoc_create(apr_bucket_alloc_t *list)
+ }
+function ap_bucket_eoc_create(list: Papr_bucket_alloc_t): Papr_bucket;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_bucket_eoc_create' + LibSuff4;
+
+

+ 702 - 0
packages/base/httpd/httpd-2.0/http_core.inc

@@ -0,0 +1,702 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+//#include "apr.h"
+{$include apr/apr_hash.inc}
+{#include "apr_optional.h"}
+{$include util_filter.inc}
+
+{#if APR_HAVE_STRUCT_RLIMIT
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif}
+
+{
+ * @package CORE HTTP Daemon
+ }
+
+{ ****************************************************************
+ *
+ * The most basic server code is encapsulated in a single module
+ * known as the core, which is just *barely* functional enough to
+ * serve documents, though not terribly well.
+ *
+ * Largely for NCSA back-compatibility reasons, the core needs to
+ * make pieces of its config structures available to other modules.
+ * The accessors are declared here, along with the interpretation
+ * of one of them (allow_options).
+ }
+
+const
+  OPT_NONE = 0;
+  OPT_INDEXES = 1;
+  OPT_INCLUDES = 2;
+  OPT_SYM_LINKS = 4;
+  OPT_EXECCGI = 8;
+  OPT_UNSET = 16;
+  OPT_INCNOEXEC = 32;
+  OPT_SYM_OWNER = 64;
+  OPT_MULTI = 128;
+  OPT_ALL = (OPT_INDEXES or OPT_INCLUDES or OPT_SYM_LINKS or OPT_EXECCGI);
+
+{ options for get_remote_host() }
+{ REMOTE_HOST returns the hostname, or NULL if the hostname
+ * lookup fails.  It will force a DNS lookup according to the
+ * HostnameLookups setting.
+ }
+  REMOTE_HOST = (0);
+
+{ REMOTE_NAME returns the hostname, or the dotted quad if the
+ * hostname lookup fails.  It will force a DNS lookup according
+ * to the HostnameLookups setting.
+ }
+  REMOTE_NAME = (1);
+
+{ REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
+ * never forced.
+ }
+  REMOTE_NOLOOKUP = (2);
+
+{ REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
+ * a double reverse lookup, regardless of the HostnameLookups
+ * setting.  The result is the (double reverse checked) hostname,
+ * or NULL if any of the lookups fail.
+ }
+  REMOTE_DOUBLE_REV = (3);
+
+  SATISFY_ALL = 0;
+  SATISFY_ANY = 1;
+  SATISFY_NOSPEC = 2;
+
+{ Make sure we don't write less than 8000 bytes at any one time.
+ }
+  AP_MIN_BYTES_TO_WRITE  = 8000;
+
+{ default maximum of internal redirects }
+  AP_DEFAULT_MAX_INTERNAL_REDIRECTS = 10;
+
+{ default maximum subrequest nesting level }
+  AP_DEFAULT_MAX_SUBREQ_DEPTH = 10;
+
+{
+ * Retrieve the value of Options for this request
+ * @param r The current request
+ * @return the Options bitmask
+ * @deffunc int ap_allow_options(request_rec *r)
+ }
+function ap_allow_options(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_allow_options' + LibSuff4;
+
+{
+ * Retrieve the value of the AllowOverride for this request
+ * @param r The current request
+ * @return the overrides bitmask
+ * @deffunc int ap_allow_overrides(request_rec *r)
+ }
+function ap_allow_overrides(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_allow_overrides' + LibSuff4;
+
+{
+ * Retrieve the value of the DefaultType directive, or text/plain if not set
+ * @param r The current request
+ * @return The default type
+ * @deffunc const char *ap_default_type(request_rec *r)
+ }
+function ap_default_type(r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_default_type' + LibSuff4;
+
+{
+ * Retrieve the document root for this server
+ * @param r The current request
+ * @warning Don't use this!  If your request went through a Userdir, or 
+ * something like that, it'll screw you.  But it's back-compatible...
+ * @return The document root
+ * @deffunc const char *ap_document_root(request_rec *r)
+ }
+function ap_document_root(r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_document_root' + LibSuff4;
+
+{
+ * Lookup the remote client's DNS name or IP address
+ * @param conn The current connection
+ * @param dir_config The directory config vector from the request
+ * @param type The type of lookup to perform.  One of:
+ * <pre>
+ *     REMOTE_HOST returns the hostname, or NULL if the hostname
+ *                 lookup fails.  It will force a DNS lookup according to the
+ *                 HostnameLookups setting.
+ *     REMOTE_NAME returns the hostname, or the dotted quad if the
+ *                 hostname lookup fails.  It will force a DNS lookup according
+ *                 to the HostnameLookups setting.
+ *     REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
+ *                     never forced.
+ *     REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
+ *                   a double reverse lookup, regardless of the HostnameLookups
+ *                   setting.  The result is the (double reverse checked) 
+ *                   hostname, or NULL if any of the lookups fail.
+ * </pre>
+ * @param str_is_ip unless NULL is passed, this will be set to non-zero on output when an IP address 
+ *        string is returned
+ * @return The remote hostname
+ * @deffunc const char *ap_get_remote_host(conn_rec *conn, void *dir_config, int type, int *str_is_ip)
+ }
+function ap_get_remote_host(conn: Pconn_rec; dir_config: Pointer;
+  _type: Integer; str_is_ip: PInteger): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_remote_host' + LibSuff16;
+
+{
+ * Retrieve the login name of the remote user.  Undef if it could not be
+ * determined
+ * @param r The current request
+ * @return The user logged in to the client machine
+ * @deffunc const char *ap_get_remote_logname(request_rec *r)
+ }
+function ap_get_remote_logname(r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_remote_logname' + LibSuff4;
+
+{ Used for constructing self-referencing URLs, and things like SERVER_PORT,
+ * and SERVER_NAME.
+ }
+{
+ * build a fully qualified URL from the uri and information in the request rec
+ * @param p The pool to allocate the URL from
+ * @param uri The path to the requested file
+ * @param r The current request
+ * @return A fully qualified URL
+ * @deffunc char *ap_construct_url(apr_pool_t *p, const char *uri, request_rec *r)
+ }
+function ap_construct_url(p: Papr_pool_t; const uri: PChar; r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_construct_url' + LibSuff12;
+
+{
+ * Get the current server name from the request
+ * @param r The current request
+ * @return the server name
+ * @deffunc const char *ap_get_server_name(request_rec *r)
+ }
+function ap_get_server_name(r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_server_name' + LibSuff4;
+
+{
+ * Get the current server port
+ * @param The current request
+ * @return The server's port
+ * @deffunc apr_port_t ap_get_server_port(const request_rec *r)
+ }
+function ap_get_server_port(r: Prequest_rec): apr_port_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_server_port' + LibSuff4;
+
+{
+ * Return the limit on bytes in request msg body 
+ * @param r The current request
+ * @return the maximum number of bytes in the request msg body
+ * @deffunc apr_off_t ap_get_limit_req_body(const request_rec *r)
+ }
+function ap_get_limit_req_body(r: Prequest_rec): apr_off_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_limit_req_body' + LibSuff4;
+
+{
+ * Return the limit on bytes in XML request msg body
+ * @param r The current request
+ * @return the maximum number of bytes in XML request msg body
+ * @deffunc size_t ap_get_limit_xml_body(const request_rec *r)
+ }
+function ap_get_limit_xml_body(r: Prequest_rec): size_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_limit_xml_body' + LibSuff4;
+
+{
+ * Install a custom response handler for a given status
+ * @param r The current request
+ * @param status The status for which the custom response should be used
+ * @param string The custom response.  This can be a static string, a file
+ *               or a URL
+ }
+procedure ap_custom_response(r: Prequest_rec; status: Integer; const str: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_custom_response' + LibSuff12;
+
+{
+ * Check if the current request is beyond the configured max. number of redirects or subrequests
+ * @param r The current request
+ * @return true (is exceeded) or false
+ * @deffunc int ap_is_recursion_limit_exceeded(const request_rec *r)
+ }
+function ap_is_recursion_limit_exceeded(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_is_recursion_limit_exceeded' + LibSuff4;
+
+{
+ * Check for a definition from the server command line
+ * @param name The define to check for
+ * @return 1 if defined, 0 otherwise
+ * @deffunc int ap_exists_config_define(const char *name)
+ }
+function ap_exists_config_define(name: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_exists_config_define' + LibSuff4;
+
+{ FIXME! See STATUS about how }
+function ap_core_translate(r: Prequest_rec): Integer;
+ cdecl; external LibHTTPD name 'ap_core_translate';
+
+{ Authentication stuff.  This is one of the places where compatibility
+ * with the old config files *really* hurts; they don't discriminate at
+ * all between different authentication schemes, meaning that we need
+ * to maintain common state for all of them in the core, and make it
+ * available to the other modules through interfaces.
+ }
+
+{ A structure to keep track of authorization requirements }
+type
+  require_line = record
+    { Where the require line is in the config file. }
+    method_mask: apr_int64_t;
+    { The complete string from the command line }
+    requirement: PChar;
+  end;
+     
+{
+ * Return the type of authorization required for this request
+ * @param r The current request
+ * @return The authorization required
+ * @deffunc const char *ap_auth_type(request_rec *r)
+ }
+function ap_auth_type(r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_auth_type' + LibSuff4;
+
+{
+ * Return the current Authorization realm
+ * @param r The current request
+ * @return The current authorization realm
+ * @deffunc const char *ap_auth_name(request_rec *r)
+ }
+function ap_auth_name(r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_auth_name' + LibSuff4;
+
+{
+ * How the requires lines must be met.
+ * @param r The current request
+ * @return How the requirements must be met.  One of:
+ * <pre>
+ *      SATISFY_ANY    -- any of the requirements must be met.
+ *      SATISFY_ALL    -- all of the requirements must be met.
+ *      SATISFY_NOSPEC -- There are no applicable satisfy lines
+ * </pre>
+ * @deffunc int ap_satisfies(request_rec *r)
+ }
+function ap_satisfies(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_satisfies' + LibSuff4;
+
+{
+ * Retrieve information about all of the requires directives for this request
+ * @param r The current request
+ * @return An array of all requires directives for this request
+ * @deffunc const apr_array_header_t *ap_requires(request_rec *r)
+ }
+function ap_requires(p: Papr_array_header_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_requires' + LibSuff4;
+
+//#ifdef CORE_PRIVATE
+
+{
+ * Core is also unlike other modules in being implemented in more than
+ * one file... so, data structures are declared here, even though most of
+ * the code that cares really is in http_core.c.  Also, another accessor.
+ }
+
+//AP_DECLARE_DATA extern module core_module;
+
+{ Per-request configuration }
+
+type
+  core_request_config = record
+    { bucket brigade used by getline for look-ahead and
+     * ap_get_client_block for holding left-over request body }
+    bb: Papr_bucket_brigade;
+
+    { an array of per-request working data elements, accessed
+     * by ID using ap_get_request_note()
+     * (Use ap_register_request_note() during initialization
+     * to add elements)
+     }
+    notes: PPointer;
+
+    { There is a script processor installed on the output filter chain,
+     * so it needs the default_handler to deliver a (script) file into
+     * the chain so it can process it. Normally, default_handler only
+     * serves files on a GET request (assuming the file is actual content),
+     * since other methods are not content-retrieval. This flag overrides
+     * that behavior, stating that the "content" is actually a script and
+     * won't actually be delivered as the response for the non-GET method.
+     }
+    deliver_script: Integer;
+
+    { Custom response strings registered via ap_custom_response(),
+     * or NULL; check per-dir config if nothing found here
+     }
+    response_code_strings: PPChar; { from ap_custom_response(), not from
+                                   * ErrorDocument
+                                   }
+    { Should addition of charset= be suppressed for this request?
+     }
+    suppress_charset: Integer;
+  end;
+
+{ Standard entries that are guaranteed to be accessible via
+ * ap_get_request_note() for each request (additional entries
+ * can be added with ap_register_request_note())
+ }
+const
+  AP_NOTE_DIRECTORY_WALK = 0;
+  AP_NOTE_LOCATION_WALK =  1;
+  AP_NOTE_FILE_WALK =      2;
+  AP_NUM_STD_NOTES =       3;
+
+{
+ * Reserve an element in the core_request_config->notes array
+ * for some application-specific data
+ * @return An integer key that can be passed to ap_get_request_note()
+ *         during request processing to access this element for the
+ *         current request.
+ }
+function ap_register_request_note: apr_size_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_register_request_note' + LibSuff0;
+
+{
+ * Retrieve a pointer to an element in the core_request_config->notes array
+ * @param r The request
+ * @param note_num  A key for the element: either a value obtained from
+ *        ap_register_request_note() or one of the predefined AP_NOTE_*
+ *        values.
+ * @return NULL if the note_num is invalid, otherwise a pointer to the
+ *         requested note element.
+ * @remark At the start of a request, each note element is NULL.  The
+ *         handle provided by ap_get_request_note() is a pointer-to-pointer
+ *         so that the caller can point the element to some app-specific
+ *         data structure.  The caller should guarantee that any such
+ *         structure will last as long as the request itself.
+ }
+function ap_get_request_note(r: Prequest_rec; note_num: apr_size_t): PPointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_request_note' + LibSuff8;
+
+{ Per-directory configuration }
+
+type
+  allow_options_t = cuchar;
+  overrides_t = cuchar;
+
+{
+ * Bits of info that go into making an ETag for a file
+ * document.  Why a long?  Because char historically
+ * proved too short for Options, and int can be different
+ * sizes on different platforms.
+ }
+  etag_components_t = culong;
+
+const
+  ETAG_UNSET = 0;
+  ETAG_NONE  = (1 shl 0);
+  ETAG_MTIME = (1 shl 1);
+  ETAG_INODE = (1 shl 2);
+  ETAG_SIZE  = (1 shl 3);
+  ETAG_BACKWARD = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE);
+  ETAG_ALL   = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE);
+
+  { Hostname resolution etc }
+  
+  HOSTNAME_LOOKUP_OFF = 0;
+  HOSTNAME_LOOKUP_ON = 1;
+  HOSTNAME_LOOKUP_DOUBLE = 2;
+  OSTNAME_LOOKUP_UNSET = 3;
+
+  { Hostname resolution etc }
+
+  USE_CANONICAL_NAME_OFF   = (0);
+  USE_CANONICAL_NAME_ON    = (1);
+  USE_CANONICAL_NAME_DNS   = (2);
+  USE_CANONICAL_NAME_UNSET = (3);
+
+  { should we force a charset on any outgoing parameterless content-type?
+   * if so, which charset?
+   }
+  ADD_DEFAULT_CHARSET_OFF   = (0);
+  ADD_DEFAULT_CHARSET_ON    = (1);
+  ADD_DEFAULT_CHARSET_UNSET = (2);
+
+  {
+   * Run-time performance tuning
+   }
+  ENABLE_MMAP_OFF   = (0);
+  ENABLE_MMAP_ON    = (1);
+  ENABLE_MMAP_UNSET = (2);
+
+  ENABLE_SENDFILE_OFF   = (0);
+  ENABLE_SENDFILE_ON    = (1);
+  ENABLE_SENDFILE_UNSET = (2);
+
+type
+  server_signature_e = (
+    srv_sig_unset,
+    srv_sig_off,
+    srv_sig_on,
+    srv_sig_withmail
+  );
+
+  core_dir_config = record
+
+    { path of the directory/regex/etc. see also d_is_fnmatch/absolute below }
+    d: PChar;
+    { the number of slashes in d }
+    d_components: Cardinal;
+
+    { If (opts & OPT_UNSET) then no absolute assignment to options has
+     * been made.
+     * invariant: (opts_add & opts_remove) == 0
+     * Which said another way means that the last relative (options + or -)
+     * assignment made to each bit is recorded in exactly one of opts_add
+     * or opts_remove.
+     }
+    opts: allow_options_t;
+    opts_add: allow_options_t;
+    opts_remove: allow_options_t;
+    override_: overrides_t;
+    
+    { MIME typing --- the core doesn't do anything at all with this,
+     * but it does know what to slap on a request for a document which
+     * goes untyped by other mechanisms before it slips out the door...
+     }
+    
+    ap_default_type: PChar;
+  
+    { Authentication stuff.  Groan... }
+    
+    satisfy: PInteger; { for every method one }
+    ap_auth_type: PChar;
+    ap_auth_name: PChar;
+    ap_requires: Papr_array_header_t;
+
+    { Custom response config. These can contain text or a URL to redirect to.
+     * if response_code_strings is NULL then there are none in the config,
+     * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES.
+     * This lets us do quick merges in merge_core_dir_configs().
+     }
+  
+    response_code_strings: PPChar; { from ErrorDocument, not from
+                                   * ap_custom_response() }
+
+    { Hostname resolution etc }
+{    unsigned int hostname_lookups : 4; }
+
+{    signed int do_rfc1413 : 2;   }{ See if client is advertising a username? }
+
+{    signed int content_md5 : 2;  }{ calculate Content-MD5? }
+
+{    unsigned use_canonical_name : 2; }
+
+    { since is_fnmatch(conf->d) was being called so frequently in
+     * directory_walk() and its relatives, this field was created and
+     * is set to the result of that call.
+     }
+{    unsigned d_is_fnmatch : 1; }
+
+    { should we force a charset on any outgoing parameterless content-type?
+     * if so, which charset?
+     }
+{    unsigned add_default_charset : 2; }
+    add_default_charset_name: PChar;
+
+    { System Resource Control }
+{$ifdef RLIMIT_CPU}
+    limit_cpu: Prlimit;
+{$endif}
+{$if defined(RLIMIT_DATA) or defined (RLIMIT_VMEM) or defined(RLIMIT_AS)}
+    limit_mem: Prlimit;
+{$endif}
+{$ifdef RLIMIT_NPROC}
+    limit_nproc: Prlimit;
+{$endif}
+    limit_req_body: apr_off_t;      { limit on bytes in request msg body }
+    limit_xml_body: cLong;           { limit on bytes in XML request msg body }
+
+    { logging options }
+
+    server_signature: server_signature_e;
+
+    loglevel: Integer;
+    
+    { Access control }
+    sec_file: Papr_array_header_t;
+    r: Pregex_t;
+
+    mime_type: PChar;       { forced with ForceType  }
+    handler: PChar;         { forced with SetHandler }
+    output_filters: PChar;  { forced with SetOutputFilters }
+    input_filters: PChar;   { forced with SetInputFilters }
+    accept_path_info: Integer;        { forced with AcceptPathInfo }
+
+    ct_output_filters: Papr_hash_t; { added with AddOutputFilterByType }
+
+    {
+     * What attributes/data should be included in ETag generation?
+     }
+    etag_bits: etag_components_t;
+    etag_add: etag_components_t;
+    etag_remove: etag_components_t;
+
+    {
+     * Run-time performance tuning
+     }
+{    unsigned int enable_mmap : 2;  }{ whether files in this dir can be mmap'ed }
+
+{    unsigned int enable_sendfile : 2;  }{ files in this dir can be mmap'ed }
+{    unsigned int allow_encoded_slashes : 1; }{ URLs may contain %2f w/o being
+                                             * pitched indiscriminately }
+  end;
+
+{ Per-server core configuration }
+
+const
+  { TRACE control }
+
+  AP_TRACE_UNSET    = -1;
+  AP_TRACE_DISABLE  =  0;
+  AP_TRACE_ENABLE   =  1;
+  AP_TRACE_EXTENDED =  2;
+
+type
+   core_server_config = record
+  
+{$ifdef GPROF}
+    gprof_dir: PChar;
+{$endif}
+
+    { Name translations --- we want the core to be able to do *something*
+     * so it's at least a minimally functional web server on its own (and
+     * can be tested that way).  But let's keep it to the bare minimum:
+     }
+    ap_document_root: PChar;
+  
+    { Access control }
+
+    access_name: PChar;
+    sec_dir: Papr_array_header_t;
+    sec_url: Papr_array_header_t;
+
+    { recursion backstopper }
+    redirect_limit: Integer; { maximum number of internal redirects }
+    subreq_limit: Integer;   { maximum nesting level of subrequests }
+
+    { TRACE control }
+    trace_enable: Integer;
+  end;
+
+{ for AddOutputFiltersByType in core.c }
+//void ap_add_output_filters_by_type(request_rec *r);
+
+{ for http_config.c }
+//void ap_core_reorder_directories(apr_pool_t *, server_rec *);
+
+{ for mod_perl }
+{AP_CORE_DECLARE(void) ap_add_per_dir_conf(server_rec *s, void *dir_config);
+AP_CORE_DECLARE(void) ap_add_per_url_conf(server_rec *s, void *url_config);
+AP_CORE_DECLARE(void) ap_add_file_conf(core_dir_config *conf, void *url_config);
+AP_CORE_DECLARE_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy, const char *arg);}
+
+//#endif COREPRIVATE
+
+
+{ ----------------------------------------------------------------------
+ *
+ * Runtime status/management
+ }
+
+type
+  ap_mgmt_type_e = (
+    ap_mgmt_type_string,
+    ap_mgmt_type_long,
+    ap_mgmt_type_hash
+  );
+
+  ap_mgmt_value = record
+    case Integer of
+     0: (s_value: PChar);
+     1: (i_value: cLong);
+     2: (h_value: Papr_hash_t);
+  end;
+
+  ap_mgmt_item_t = record
+    description: PChar;
+    name: PChar;
+    vtype: ap_mgmt_type_e;
+    v: ap_mgmt_value;
+  end;
+
+{ Handles for core filters }
+{extern AP_DECLARE_DATA ap_filter_rec_t *ap_subreq_core_filter_handle;
+extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_output_filter_handle;
+extern AP_DECLARE_DATA ap_filter_rec_t *ap_content_length_filter_handle;
+extern AP_DECLARE_DATA ap_filter_rec_t *ap_net_time_filter_handle;
+extern AP_DECLARE_DATA ap_filter_rec_t *ap_core_input_filter_handle;}
+
+{
+ * This hook provdes a way for modules to provide metrics/statistics about
+ * their operational status.
+ *
+ * @param p A pool to use to create entries in the hash table
+ * @param val The name of the parameter(s) that is wanted. This is
+ *            tree-structured would be in the form ('*' is all the tree,
+ *            'module.*' all of the module , 'module.foo.*', or
+ *            'module.foo.bar' )
+ * @param ht The hash table to store the results. Keys are item names, and
+ *           the values point to ap_mgmt_item_t structures.
+ * @ingroup hooks
+ }
+type
+  ap_HOOK_get_mgmt_items_t = function(p: Papr_pool_t; const val: PChar;
+    ht: Papr_hash_t): Integer; cdecl;
+
+procedure ap_hook_get_mgmt_items(pf: ap_HOOK_get_mgmt_items_t;
+ const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_get_mgmt_items' + LibSuff16;
+
+{ ---------------------------------------------------------------------- }
+
+{ ----------------------------------------------------------------------
+ *
+ * I/O logging with mod_logio
+ }
+
+{APR_DECLARE_OPTIONAL_FN(void, ap_logio_add_bytes_out,
+                        (conn_rec *c, apr_off_t bytes));}
+

+ 337 - 0
packages/base/httpd/httpd-2.0/http_log.inc

@@ -0,0 +1,337 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+//#include "apr_thread_proc.h"
+
+{
+ * @package Apache logging library
+ }
+
+{#ifdef HAVE_SYSLOG
+#include <syslog.h>}
+
+const
+  LOG_PRIMASK = 7;
+
+  APLOG_EMERG	= 0;	{ system is unusable }
+  APLOG_ALERT	= 1;	{ action must be taken immediately }
+  APLOG_CRIT	= 2;	{ critical conditions }
+  APLOG_ERR	= 3;	{ error conditions }
+  APLOG_WARNING	= 4;	{ warning conditions }
+  APLOG_NOTICE	= 5;	{ normal but significant condition }
+  APLOG_INFO	= 6;	{ informational }
+  APLOG_DEBUG	= 7;	{ debug-level messages }
+
+  APLOG_LEVELMASK = 7;	{ mask off the level value }
+
+{ APLOG_NOERRNO is ignored and should not be used.  It will be
+ * removed in a future release of Apache.
+ }
+  APLOG_NOERRNO	=	(APLOG_LEVELMASK + 1);
+
+{ Use APLOG_TOCLIENT on ap_log_rerror() to give content
+ * handlers the option of including the error text in the 
+ * ErrorDocument sent back to the client. Setting APLOG_TOCLIENT
+ * will cause the error text to be saved in the request_rec->notes 
+ * table, keyed to the string "error-notes", if and only if:
+ * - the severity level of the message is APLOG_WARNING or greater
+ * - there are no other "error-notes" set in request_rec->notes
+ * Once error-notes is set, it is up to the content handler to
+ * determine whether this text should be sent back to the client.
+ * Note: Client generated text streams sent back to the client MUST 
+ * be escaped to prevent CSS attacks.
+ }
+  APLOG_TOCLIENT =         ((APLOG_LEVELMASK + 1) * 2);
+
+{ normal but significant condition on startup, usually printed to stderr }
+  APLOG_STARTUP =          ((APLOG_LEVELMASK + 1) * 4);
+
+  DEFAULT_LOGLEVEL =	APLOG_WARNING;
+
+//extern int AP_DECLARE_DATA ap_default_loglevel;
+
+//  APLOG_MARK = __FILE__,__LINE__;
+
+{
+ * Set up for logging to stderr.
+ * @param p The pool to allocate out of
+ }
+procedure ap_open_stderr_log(p: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_open_stderr_log' + LibSuff4;
+
+{
+ * Replace logging to stderr with logging to the given file.
+ * @param p The pool to allocate out of
+ * @param file Name of the file to log stderr output
+ }
+function ap_replace_stderr_log(p: Papr_pool_t;
+ file_: PChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_replace_stderr_log' + LibSuff8;
+
+{
+ * Open the error log and replace stderr with it.
+ * @param pconf Not used
+ * @param plog  The pool to allocate the logs from
+ * @param ptemp Pool used for temporary allocations
+ * @param s_main The main server
+ * @tip ap_open_logs isn't expected to be used by modules, it is
+ * an internal core function 
+ }
+{int ap_open_logs(apr_pool_t *pconf, apr_pool_t *plog,
+                 apr_pool_t *ptemp, server_rec *s_main);}
+
+//#ifdef CORE_PRIVATE
+
+{
+ * Perform special processing for piped loggers in MPM child
+ * processes.
+ * @param p Not used
+ * @param s Not used
+ * @tip ap_logs_child_init is not for use by modules; it is an
+ * internal core function
+ }
+//void ap_logs_child_init(apr_pool_t *p, server_rec *s);
+
+//#endif { CORE_PRIVATE }
+
+{
+ * The primary logging functions, ap_log_error, ap_log_rerror, ap_log_cerror,
+ * and ap_log_perror use a printf style format string to build the log message.  
+ * It is VERY IMPORTANT that you not include any raw data from the network, 
+ * such as the request-URI or request header fields, within the format 
+ * string.  Doing so makes the server vulnerable to a denial-of-service 
+ * attack and other messy behavior.  Instead, use a simple format string 
+ * like "%s", followed by the string containing the untrusted data.
+ }
+
+{
+ * ap_log_error() - log messages which are not related to a particular
+ * request or connection.  This uses a printf-like format to log messages
+ * to the error_log.
+ * @param file The file in which this function is called
+ * @param line The line number on which this function is called
+ * @param level The level of this error message
+ * @param status The status code from the previous command
+ * @param s The server on which we are logging
+ * @param fmt The format string
+ * @param ... The arguments to use to fill out fmt.
+ * @tip Use APLOG_MARK to fill out file and line
+ * @tip If a request_rec is available, use that with ap_log_rerror()
+ * in preference to calling this function.  Otherwise, if a conn_rec is
+ * available, use that with ap_log_cerror() in preference to calling
+ * this function.
+ * @warning It is VERY IMPORTANT that you not include any raw data from 
+ * the network, such as the request-URI or request header fields, within 
+ * the format string.  Doing so makes the server vulnerable to a 
+ * denial-of-service attack and other messy behavior.  Instead, use a 
+ * simple format string like "%s", followed by the string containing the 
+ * untrusted data.
+ * @deffunc void ap_log_error(const char *file, int line, int level, apr_status_t status, const server_rec *s, const char *fmt, ...) 
+ }
+procedure ap_log_error(
+ const file_: PChar; line, level: Integer;
+ status: apr_status_t; const s: Pserver_rec;
+ const fmt: PChar; others: array of const);
+ cdecl; external LibHTTPD name 'ap_log_error';
+
+//			    __attribute__((format(printf,6,7)));
+
+{
+ * ap_log_perror() - log messages which are not related to a particular
+ * request, connection, or virtual server.  This uses a printf-like
+ * format to log messages to the error_log.
+ * @param file The file in which this function is called
+ * @param line The line number on which this function is called
+ * @param level The level of this error message
+ * @param status The status code from the previous command
+ * @param p The pool which we are logging for
+ * @param fmt The format string
+ * @param ... The arguments to use to fill out fmt.
+ * @tip Use APLOG_MARK to fill out file and line
+ * @warning It is VERY IMPORTANT that you not include any raw data from 
+ * the network, such as the request-URI or request header fields, within 
+ * the format string.  Doing so makes the server vulnerable to a 
+ * denial-of-service attack and other messy behavior.  Instead, use a 
+ * simple format string like "%s", followed by the string containing the 
+ * untrusted data.
+ * @deffunc void ap_log_perror(const char *file, int line, int level, apr_status_t status, apr_pool_t *p, const char *fmt, ...) 
+ }
+procedure ap_log_perror(
+ const file_: PChar; line, level: Integer;
+ status: apr_status_t; p: Papr_pool_t;
+ const fmt: PChar; others: array of const);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name 'ap_log_perror';
+
+{		    __attribute__((format(printf,6,7)));}
+
+{
+ * ap_log_rerror() - log messages which are related to a particular
+ * request.  This uses a a printf-like format to log messages to the
+ * error_log.
+ * @param file The file in which this function is called
+ * @param line The line number on which this function is called
+ * @param level The level of this error message
+ * @param status The status code from the previous command
+ * @param r The request which we are logging for
+ * @param fmt The format string
+ * @param ... The arguments to use to fill out fmt.
+ * @tip Use APLOG_MARK to fill out file and line
+ * @warning It is VERY IMPORTANT that you not include any raw data from 
+ * the network, such as the request-URI or request header fields, within 
+ * the format string.  Doing so makes the server vulnerable to a 
+ * denial-of-service attack and other messy behavior.  Instead, use a 
+ * simple format string like "%s", followed by the string containing the 
+ * untrusted data.
+ * @deffunc void ap_log_rerror(const char *file, int line, int level, apr_status_t status, const request_rec *r, const char *fmt, ...)
+ }
+procedure ap_log_rerror(
+ const file_: PChar; line, level: Integer;
+ status: apr_status_t; const r: Prequest_rec;
+ const fmt: PChar; others: array of const);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name 'ap_log_rerror';
+
+{    __attribute__((format(printf,6,7)));}
+
+{
+ * ap_log_cerror() - log messages which are related to a particular
+ * connection.  This uses a a printf-like format to log messages to the
+ * error_log.
+ * @param file The file in which this function is called
+ * @param line The line number on which this function is called
+ * @param level The level of this error message
+ * @param status The status code from the previous command
+ * @param c The connection which we are logging for
+ * @param fmt The format string
+ * @param ... The arguments to use to fill out fmt.
+ * @tip Use APLOG_MARK to fill out file and line
+ * @tip If a request_rec is available, use that with ap_log_rerror()
+ * in preference to calling this function.
+ * @warning It is VERY IMPORTANT that you not include any raw data from 
+ * the network, such as the request-URI or request header fields, within 
+ * the format string.  Doing so makes the server vulnerable to a 
+ * denial-of-service attack and other messy behavior.  Instead, use a 
+ * simple format string like "%s", followed by the string containing the 
+ * untrusted data.
+ * @note ap_log_cerror() is available starting with Apache 2.0.55.
+ * @deffunc void ap_log_cerror(const char *file, int line, int level, apr_status_t status, const conn_rec *c, const char *fmt, ...)
+ }
+procedure ap_log_cerror(
+ const file_: PChar; line, level: Integer;
+ status: apr_status_t; const c: Pconn_rec;
+ const fmt: PChar; others: array of const);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name 'ap_log_cerror';
+
+{    __attribute__((format(printf,6,7)));}
+
+{
+ * Convert stderr to the error log
+ * @param s The current server
+ * @deffunc void ap_error_log2stderr(server_rec *s)
+ }
+procedure ap_error_log2stderr(s: Pserver_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_error_log2stderr' + LibSuff4;
+
+{
+ * Log the current pid of the parent process
+ * @param p The pool to use for logging
+ * @param fname The name of the file to log to
+ }
+procedure ap_log_pid(p: Papr_pool_t; const fname: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_log_pid' + LibSuff8;
+
+{
+ * Retrieve the pid from a pidfile.
+ * @param p The pool to use for logging
+ * @param filename The name of the file containing the pid
+ * @param mypid Pointer to pid_t (valid only if return APR_SUCCESS)
+ }
+function ap_read_pid(p: Papr_pool_t; const filename: PChar; mypid: Ppid_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_read_pid' + LibSuff12;
+
+{
+ * The piped logging structure.  Piped logs are used to move functionality
+ * out of the main server.  For example, log rotation is done with piped logs.
+ }
+type
+  piped_log = record
+    { The pool to use for the piped log }
+    p: Papr_pool_t;
+    { The pipe between the server and the logging process }
+    fds: array[0..2] of Papr_file_t;
+    { XXX - an #ifdef that needs to be eliminated from public view. Shouldn't
+     * be hard }
+{$ifdef AP_HAVE_RELIABLE_PIPED_LOGS}
+    { The name of the program the logging process is running }
+    program: PChar;
+    { The pid of the logging process }
+    pid: Papr_proc_t;
+{$endif}
+  end;
+  Ppiped_log = ^piped_log;
+{
+ * Open the piped log process
+ * @param p The pool to allocate out of
+ * @param program The program to run in the logging process
+ * @return The piped log structure
+ * @deffunc piped_log *ap_open_piped_log(apr_pool_t *p, const char *program)
+ }
+function ap_open_piped_log(p: Papr_pool_t; const program_: PChar): Ppiped_log;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_open_piped_log' + LibSuff8;
+
+{
+ * Close the piped log and kill the logging process
+ * @param pl The piped log structure
+ * @deffunc void ap_close_piped_log(piped_log *pl)
+ }
+procedure ap_close_piped_log(pl: Ppiped_log);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_close_piped_log' + LibSuff4;
+
+{
+ * A macro to access the read side of the piped log pipe
+ * @param pl The piped log structure
+ * @return The native file descriptor
+ * @deffunc ap_piped_log_read_fd(pl)
+ }
+//#define ap_piped_log_read_fd(pl)	((pl)->fds[0])
+
+{
+ * A macro to access the write side of the piped log pipe
+ * @param pl The piped log structure
+ * @return The native file descriptor
+ * @deffunc ap_piped_log_read_fd(pl)
+ }
+//#define ap_piped_log_write_fd(pl)	((pl)->fds[1])
+
+type
+  ap_HOOK_error_log_t = procedure(const _file: PChar; line: Integer;
+    level: Integer; status: apr_status_t; const s: Pserver_rec;
+    const r: Prequest_rec; p: Papr_pool_t; const errstr: PChar); cdecl;
+
+procedure ap_hook_error_log(pf: ap_HOOK_error_log_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_error_log' + LibSuff16;
+

+ 47 - 0
packages/base/httpd/httpd-2.0/http_main.inc

@@ -0,0 +1,47 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+}
+
+//#include "apr_optional.h"
+
+{ AP_SERVER_BASEARGS is the command argument list parsed by http_main.c
+ * in apr_getopt() format.  Use this for default'ing args that the MPM
+ * can safely ignore and pass on from its rewrite_args() handler.
+ }
+const
+  AP_SERVER_BASEARGS = 'C:c:D:d:E:e:f:vVlLtSh?X';
+
+{
+ * @package Command line options
+ }
+
+{ The name of the Apache executable }
+//AP_DECLARE_DATA extern const char *ap_server_argv0;
+{ The global server's ServerRoot }
+//AP_DECLARE_DATA extern const char *ap_server_root;
+
+{ for -C, -c and -D switches }
+{ An array of all -C directives.  These are processed before the server's
+ *  config file }
+//AP_DECLARE_DATA extern apr_array_header_t *ap_server_pre_read_config;
+{ An array of all -c directives.  These are processed after the server's
+ *  config file }
+//AP_DECLARE_DATA extern apr_array_header_t *ap_server_post_read_config;
+{ An array of all -D defines on the command line.  This allows people to
+ *  effect the server based on command line options }
+//AP_DECLARE_DATA extern apr_array_header_t *ap_server_config_defines;
+
+//APR_DECLARE_OPTIONAL_FN(int, ap_signal_server, (int *, apr_pool_t *));
+

+ 829 - 0
packages/base/httpd/httpd-2.0/http_protocol.inc

@@ -0,0 +1,829 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{#include "httpd.h"
+#include "apr_hooks.h"
+#include "apr_portable.h"
+#include "apr_mmap.h"
+#include "apr_buckets.h"
+#include "util_filter.h"}
+
+{
+ * @package HTTP protocol handling
+ }
+
+{
+ * This hook allows modules to insert filters for the current error response
+ * @param r the current request
+ * @ingroup hooks
+ }
+type
+  ap_HOOK_insert_error_filter_t = procedure(r: Prequest_rec); cdecl;
+
+procedure ap_hook_insert_error_filter(pf: ap_HOOK_insert_error_filter_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_insert_error_filter' + LibSuff16;
+
+{ This is an optimization.  We keep a record of the filter_rec that
+ * stores the old_write filter, so that we can avoid strcmp's later.
+ }
+//AP_DECLARE_DATA extern ap_filter_rec_t *ap_old_write_func;
+
+{
+ * Prototypes for routines which either talk directly back to the user,
+ * or control the ones that eventually do.
+ }
+
+{
+ * Read a request and fill in the fields.
+ * @param c The current connection
+ * @return The new request_rec
+ }
+//request_rec *ap_read_request(conn_rec *c);
+
+{
+ * Read the mime-encoded headers.
+ * @param r The current request
+ }
+procedure ap_get_mime_headers(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_mime_headers' + LibSuff4;
+
+{
+ * Optimized version of ap_get_mime_headers() that requires a
+ * temporary brigade to work with
+ * @param r The current request
+ * @param bb temp brigade
+ }
+procedure ap_get_mime_headers_core(r: Prequest_rec; bb: Papr_bucket_brigade);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_mime_headers_core' + LibSuff8;
+
+{ Finish up stuff after a request }
+
+{
+ * Called at completion of sending the response.  It sends the terminating
+ * protocol information.
+ * @param r The current request
+ * @deffunc void ap_finalize_request_protocol(request_rec *r)
+ }
+procedure ap_finalize_request_protocol(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_finalize_request_protocol' + LibSuff4;
+
+{
+ * Send error back to client.
+ * @param r The current request
+ * @param recursive_error last arg indicates error status in case we get 
+ *      an error in the process of trying to deal with an ErrorDocument 
+ *      to handle some other error.  In that case, we print the default 
+ *      report for the first thing that went wrong, and more briefly report 
+ *      on the problem with the ErrorDocument.
+ * @deffunc void ap_send_error_response(request_rec *r, int recursive_error)
+ }
+procedure ap_send_error_response(r: Prequest_rec; recursive_error: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_send_error_response' + LibSuff8;
+
+{ Set last modified header line from the lastmod date of the associated file.
+ * Also, set content length.
+ *
+ * May return an error status, typically HTTP_NOT_MODIFIED (that when the
+ * permit_cache argument is set to one).
+ }
+
+{
+ * Set the content length for this request
+ * @param r The current request
+ * @param length The new content length
+ * @deffunc void ap_set_content_length(request_rec *r, apr_off_t length)
+ }
+procedure ap_set_content_length(r: Prequest_rec; length: apr_off_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_set_content_length' + LibSuff12;
+
+{
+ * Set the keepalive status for this request
+ * @param r The current request
+ * @return 1 if keepalive can be set, 0 otherwise
+ * @deffunc int ap_set_keepalive(request_rec *r)
+ }
+function ap_set_keepalive(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_set_keepalive' + LibSuff4;
+
+{
+ * Return the latest rational time from a request/mtime pair.  Mtime is 
+ * returned unless it's in the future, in which case we return the current time.
+ * @param r The current request
+ * @param mtime The last modified time
+ * @return the latest rational time.
+ * @deffunc apr_time_t ap_rationalize_mtime(request_rec *r, apr_time_t mtime)
+ }
+function ap_rationalize_mtime(r: Prequest_rec; mtime: apr_time_t): apr_time_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_rationalize_mtime' + LibSuff12;
+
+{
+ * Build the content-type that should be sent to the client from the
+ * content-type specified.  The following rules are followed:
+ *    - if type is NULL, type is set to ap_default_type(r)
+ *    - if charset adding is disabled, stop processing and return type.
+ *    - then, if there are no parameters on type, add the default charset
+ *    - return type
+ * @param r The current request
+ * @return The content-type
+ * @deffunc const char *ap_make_content_type(request_rec *r, const char *type);
+ }
+function ap_make_content_type(r: Prequest_rec; type_: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_make_content_type' + LibSuff8;
+
+//#ifdef CORE_PRIVATE
+{
+ * Precompile metadata structures used by ap_make_content_type()
+ * @param r The pool to use for allocations
+ * @deffunc void ap_setup_make_content_type(apr_pool_t *pool)
+ }
+procedure ap_setup_make_content_type(pool: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_setup_make_content_type' + LibSuff4;
+
+//#endif { CORE_PRIVATE }
+
+{
+ * Construct an entity tag from the resource information.  If it's a real
+ * file, build in some of the file characteristics.
+ * @param r The current request
+ * @param force_weak Force the entity tag to be weak - it could be modified
+ *                   again in as short an interval.
+ * @return The entity tag
+ * @deffunc char *ap_make_etag(request_rec *r, int force_weak)
+ }
+function ap_make_etag(r: Prequest_rec; force_weak: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_make_etag' + LibSuff8;
+
+{
+ * Set the E-tag outgoing header
+ * @param The current request
+ * @deffunc void ap_set_etag(request_rec *r)
+ }
+procedure ap_set_etag(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_set_etag' + LibSuff4;
+
+{
+ * Set the last modified time for the file being sent
+ * @param r The current request
+ * @deffunc void ap_set_last_modified(request_rec *r)
+ }
+procedure ap_set_last_modified(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_set_last_modified' + LibSuff4;
+
+{
+ * Implements condition GET rules for HTTP/1.1 specification.  This function
+ * inspects the client headers and determines if the response fulfills 
+ * the requirements specified.
+ * @param r The current request
+ * @return OK if the response fulfills the condition GET rules, some
+ *         other status code otherwise
+ * @deffunc int ap_meets_conditions(request_rec *r)
+ }
+function ap_meets_conditions(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_meets_conditions' + LibSuff4;
+
+{ Other ways to send stuff at the client.  All of these keep track
+ * of bytes_sent automatically.  This indirection is intended to make
+ * it a little more painless to slide things like HTTP-NG packetization
+ * underneath the main body of the code later.  In the meantime, it lets
+ * us centralize a bit of accounting (bytes_sent).
+ *
+ * These also return the number of bytes written by the call.
+ * They should only be called with a timeout registered, for obvious reaasons.
+ * (Ditto the send_header stuff).
+ }
+
+{
+ * Send an entire file to the client, using sendfile if supported by the 
+ * current platform
+ * @param fd The file to send.
+ * @param r The current request
+ * @param offset Offset into the file to start sending.
+ * @param length Amount of data to send
+ * @param nbytes Amount of data actually sent
+ * @deffunc apr_status_t ap_send_fd(apr_file_t *fd, request_rec *r, apr_off_t offset, apr_size_t length, apr_size_t *nbytes);
+ }
+function ap_send_fd(fd: Papr_file_t; r: Prequest_rec; offset: apr_off_t;
+ length: apr_size_t; nbytes: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_send_fd' + LibSuff24;
+
+{$ifdef APR_HAS_MMAP}
+{
+ * Send an MMAP'ed file to the client
+ * @param mm The MMAP'ed file to send
+ * @param r The current request
+ * @param offset The offset into the MMAP to start sending
+ * @param length The amount of data to send
+ * @return The number of bytes sent
+ * @deffunc size_t ap_send_mmap(apr_mmap_t *mm, request_rec *r, size_t offset, size_t length)
+ }
+function ap_send_mmap(mm: Papr_mmap_t; r: Prequest_rec; offset, length: size_t): size_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_send_mmap' + LibSuff20;
+
+{$endif}
+
+
+{
+ * Register a new request method, and return the offset that will be
+ * associated with that method.
+ *
+ * @param p        The pool to create registered method numbers from.
+ * @param methname The name of the new method to register.
+ * @return         Ab int value representing an offset into a bitmask.
+ }
+function ap_method_register(p: Papr_pool_t; methname: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_method_register' + LibSuff8;
+
+{
+ * Initialize the method_registry and allocate memory for it.
+ *
+ * @param p Pool to allocate memory for the registry from.
+ }
+procedure ap_method_registry_init(p: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_method_registry_init' + LibSuff4;
+
+{
+ * This is a convenience macro to ease with checking a mask
+ * against a method name.
+ }
+{#define AP_METHOD_CHECK_ALLOWED(mask, methname) \
+    ((mask) & (AP_METHOD_BIT << ap_method_number_of((methname))))}
+
+{
+ * Create a new method list with the specified number of preallocated
+ * slots for extension methods.
+ *
+ * @param   p       Pointer to a pool in which the structure should be
+ *                  allocated.
+ * @param   nelts   Number of preallocated extension slots
+ * @return  Pointer to the newly created structure.
+ * @deffunc ap_method_list_t ap_make_method_list(apr_pool_t *p, int nelts)
+ }
+function ap_make_method_list(p: Papr_pool_t; nelts: Integer): Pap_method_list_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_make_method_list' + LibSuff8;
+
+procedure ap_copy_method_list(dest, src: Pap_method_list_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_copy_method_list' + LibSuff8;
+
+type
+  comp_t = procedure (urec: Pointer; const mname: PChar; mnum: Integer);
+  
+procedure ap_method_list_do(
+ comp: comp_t; rec: Pointer; ml: Pap_method_list_t; others: array of const);
+ cdecl; external LibHTTPD name 'ap_method_list_do';
+
+type
+  ap_method_list_vdo_t = function (urec: Pointer; const mname: PChar;
+   mnum: Integer): Integer; cdecl;
+
+procedure ap_method_list_vdo(comp: ap_method_list_vdo_t;
+ rec: Pointer; const ml: Pap_method_list_t; cp: va_list);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_method_list_vdo' + LibSuff16;
+
+{
+ * Search for an HTTP method name in an ap_method_list_t structure, and
+ * return true if found.
+ *
+ * @param   method  String containing the name of the method to check.
+ * @param   l       Pointer to a method list, such as cmd->methods_limited.
+ * @return  1 if method is in the list, otherwise 0
+ * @deffunc int ap_method_in_list(const char *method, ap_method_list_t *l)
+ }
+function ap_method_in_list(l: Pap_method_list_t; const method: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_method_in_list' + LibSuff8;
+
+{
+ * Add an HTTP method name to an ap_method_list_t structure if it isn't
+ * already listed.
+ *
+ * @param   method  String containing the name of the method to check.
+ * @param   l       Pointer to a method list, such as cmd->methods_limited.
+ * @return  None.
+ * @deffunc void ap_method_in_list(ap_method_list_t *l, const char *method)
+ }
+procedure ap_method_list_add(l: Pap_method_list_t; const method: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_method_list_add' + LibSuff8;
+
+{
+ * Remove an HTTP method name from an ap_method_list_t structure.
+ *
+ * @param   l       Pointer to a method list, such as cmd->methods_limited.
+ * @param   method  String containing the name of the method to remove.
+ * @return  None.
+ * @deffunc void ap_method_list_remove(ap_method_list_t *l, const char *method)
+ }
+procedure ap_method_list_remove(l: Pap_method_list_t; const method: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_method_list_remove' + LibSuff8;
+
+{
+ * Reset a method list to be completely empty.
+ *
+ * @param   l       Pointer to a method list, such as cmd->methods_limited.
+ * @return  None.
+ * @deffunc void ap_clear_method_list(ap_method_list_t *l)
+ }
+procedure ap_clear_method_list(l: Pap_method_list_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_clear_method_list' + LibSuff4;
+
+{
+ * Set the content type for this request (r->content_type). 
+ * @param r The current request
+ * @param ct The new content type
+ * @deffunc void ap_set_content_type(request_rec *r, const char* ct)
+ * @warning This function must be called to set r->content_type in order 
+ * for the AddOutputFilterByType directive to work correctly.
+ }
+procedure ap_set_content_type(r: Prequest_rec; const ct: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_set_content_type' + LibSuff8;
+
+{ Hmmm... could macrofy these for now, and maybe forever, though the
+ * definitions of the macros would get a whole lot hairier.
+ }
+
+{
+ * Output one character for this request
+ * @param c the character to output
+ * @param r the current request
+ * @return The number of bytes sent
+ * @deffunc int ap_rputc(int c, request_rec *r)
+ }
+function ap_rputc(c: Integer; r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_rputc' + LibSuff8;
+
+{
+ * Output a string for the current request
+ * @param str The string to output
+ * @param r The current request
+ * @return The number of bytes sent
+ * @deffunc int ap_rputs(const char *str, request_rec *r)
+ }
+function ap_rputs(const str: PChar; r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_rputs' + LibSuff8;
+
+{
+ * Write a buffer for the current request
+ * @param buf The buffer to write
+ * @param nbyte The number of bytes to send from the buffer
+ * @param r The current request
+ * @return The number of bytes sent
+ * @deffunc int ap_rwrite(const void *buf, int nbyte, request_rec *r)
+ }
+function ap_rwrite(const buf: Pointer; nbyte: Integer; r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_rwrite' + LibSuff12;
+
+{
+ * Write an unspecified number of strings to the request
+ * @param r The current request
+ * @param ... The strings to write
+ * @return The number of bytes sent
+ * @deffunc int ap_rvputs(request_rec *r, ...)
+ }
+function ap_rvputs(r: Prequest_rec; others: array of const): Integer;
+ cdecl; external LibHTTPD name 'ap_rvputs';
+
+//AP_DECLARE_NONSTD(int) ap_rvputs(request_rec *r,...);
+
+{
+ * Output data to the client in a printf format
+ * @param r The current request
+ * @param fmt The format string
+ * @param vlist The arguments to use to fill out the format string
+ * @return The number of bytes sent
+ * @deffunc int ap_vrprintf(request_rec *r, const char *fmt, va_list vlist)
+ }
+function ap_vrprintf(r: Prequest_rec; const fmt: PChar; vlist: va_list): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_vrprintf' + LibSuff12;
+
+{
+ * Output data to the client in a printf format
+ * @param r The current request
+ * @param fmt The format string
+ * @param ... The arguments to use to fill out the format string
+ * @return The number of bytes sent
+ * @deffunc int ap_rprintf(request_rec *r, const char *fmt, ...)
+ }
+function ap_rprintf(r: Prequest_rec; const fmt: PChar; others: array of const): Integer;
+ cdecl; external LibHTTPD name 'ap_rprintf';
+
+//AP_DECLARE_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
+//				__attribute__((format(printf,2,3)));
+
+{
+ * Flush all of the data for the current request to the client
+ * @param r The current request
+ * @return The number of bytes sent
+ * @deffunc int ap_rflush(request_rec *r)
+ }
+function ap_rflush(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_rflush' + LibSuff4;
+
+{
+ * Index used in custom_responses array for a specific error code
+ * (only use outside protocol.c is in getting them configured).
+ * @param status HTTP status code
+ * @return The index of the response
+ * @deffunc int ap_index_of_response(int status)
+ }
+function ap_index_of_response(status: Integer): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_index_of_response' + LibSuff4;
+
+{
+ * Return the Status-Line for a given status code (excluding the
+ * HTTP-Version field). If an invalid or unknown status code is
+ * passed, "500 Internal Server Error" will be returned. 
+ * @param status The HTTP status code
+ * @return The Status-Line
+ * @deffunc const char *ap_get_status_line(int status)
+ }
+function ap_get_status_line(status: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_status_line' + LibSuff4;
+
+{ Reading a block of data from the client connection (e.g., POST arg) }
+
+{
+ * Setup the client to allow Apache to read the request body.
+ * @param r The current request
+ * @param read_policy How the server should interpret a chunked 
+ *                    transfer-encoding.  One of: <pre>
+ *    REQUEST_NO_BODY          Send 413 error if message has any body
+ *    REQUEST_CHUNKED_ERROR    Send 411 error if body without Content-Length
+ *    REQUEST_CHUNKED_DECHUNK  If chunked, remove the chunks for me.
+ * </pre>
+ * @return either OK or an error code
+ * @deffunc int ap_setup_client_block(request_rec *r, int read_policy)
+ }
+function ap_setup_client_block(r: Prequest_rec; read_policy: Integer): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_setup_client_block' + LibSuff8;
+
+{
+ * Determine if the client has sent any data.  This also sends a 
+ * 100 Continue response to HTTP/1.1 clients, so modules should not be called
+ * until the module is ready to read content.
+ * @warning Never call this function more than once.
+ * @param r The current request
+ * @return 0 if there is no message to read, 1 otherwise
+ * @deffunc int ap_should_client_block(request_rec *r)
+ }
+function ap_should_client_block(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_should_client_block' + LibSuff4;
+
+{
+ * Call this in a loop.  It will put data into a buffer and return the length
+ * of the input block
+ * @param r The current request
+ * @param buffer The buffer in which to store the data
+ * @param bufsiz The size of the buffer
+ * @return Number of bytes inserted into the buffer.  When done reading, 0
+ *         if EOF, or -1 if there was an error
+ * @deffunc long ap_get_client_block(request_rec *r, char *buffer, apr_size_t bufsiz)
+ }
+function ap_get_client_block(r: Prequest_rec; buffer: PChar; bufsiz: apr_size_t): cLong;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_client_block' + LibSuff12;
+
+{
+ * In HTTP/1.1, any method can have a body.  However, most GET handlers
+ * wouldn't know what to do with a request body if they received one.
+ * This helper routine tests for and reads any message body in the request,
+ * simply discarding whatever it receives.  We need to do this because
+ * failing to read the request body would cause it to be interpreted
+ * as the next request on a persistent connection.
+ * @param r The current request
+ * @return error status if request is malformed, OK otherwise 
+ * @deffunc int ap_discard_request_body(request_rec *r)
+ }
+function ap_discard_request_body(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_discard_request_body' + LibSuff4;
+
+{
+ * Setup the output headers so that the client knows how to authenticate
+ * itself the next time, if an authentication request failed.  This function
+ * works for both basic and digest authentication
+ * @param r The current request
+ * @deffunc void ap_note_auth_failure(request_rec *r)
+ }
+procedure ap_note_auth_failure(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_note_auth_failure' + LibSuff4;
+
+{
+ * Setup the output headers so that the client knows how to authenticate
+ * itself the next time, if an authentication request failed.  This function
+ * works only for basic authentication
+ * @param r The current request
+ * @deffunc void ap_note_basic_auth_failure(request_rec *r)
+ }
+procedure ap_note_basic_auth_failure(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_note_basic_auth_failure' + LibSuff4;
+
+{
+ * Setup the output headers so that the client knows how to authenticate
+ * itself the next time, if an authentication request failed.  This function
+ * works only for digest authentication
+ * @param r The current request
+ * @deffunc void ap_note_digest_auth_failure(request_rec *r)
+ }
+procedure ap_note_digest_auth_failure(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_note_digest_auth_failure' + LibSuff4;
+
+{
+ * Get the password from the request headers
+ * @param r The current request
+ * @param pw The password as set in the headers
+ * @return 0 (OK) if it set the 'pw' argument (and assured
+ *         a correct value in r->user); otherwise it returns 
+ *         an error code, either HTTP_INTERNAL_SERVER_ERROR if things are 
+ *         really confused, HTTP_UNAUTHORIZED if no authentication at all 
+ *         seemed to be in use, or DECLINED if there was authentication but 
+ *         it wasn't Basic (in which case, the caller should presumably 
+ *         decline as well).
+ * @deffunc int ap_get_basic_auth_pw(request_rec *r, const char **pw)
+ }
+function ap_get_basic_auth_pw(r: Prequest_rec; pw: PPChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_basic_auth_pw' + LibSuff8;
+
+{
+ * parse_uri: break apart the uri
+ * @warning Side Effects: <pre>
+ *    - sets r->args to rest after '?' (or NULL if no '?')
+ *    - sets r->uri to request uri (without r->args part)
+ *    - sets r->hostname (if not set already) from request (scheme://host:port)
+ * </pre>
+ * @param r The current request
+ * @param uri The uri to break apart
+ * @deffunc void ap_parse_uri(request_rec *r, const char *uri)
+ }
+procedure ap_parse_uri(r: Prequest_rec; const uri: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_parse_uri' + LibSuff8;
+
+{
+ * Get the next line of input for the request
+ * @param s The buffer into which to read the line
+ * @param n The size of the buffer
+ * @param r The request
+ * @param fold Whether to merge continuation lines
+ * @return The length of the line, if successful
+ *         n, if the line is too big to fit in the buffer
+ *         -1 for miscellaneous errors
+ * @deffunc int ap_method_number_of(const char *method)
+ }
+function ap_getline(s: PChar; n: Integer; r: Prequest_rec; fold: Integer): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_getline' + LibSuff16;
+
+{
+ * Get the next line of input for the request
+ *
+ * Note: on ASCII boxes, ap_rgetline is a macro which simply calls 
+ *       ap_rgetline_core to get the line of input.
+ * 
+ *       on EBCDIC boxes, ap_rgetline is a wrapper function which
+ *       translates ASCII protocol lines to the local EBCDIC code page
+ *       after getting the line of input.
+ *       
+ * @param s Pointer to the pointer to the buffer into which the line
+ *          should be read; if *s==NULL, a buffer of the necessary size
+ *          to hold the data will be allocated from the request pool
+ * @param n The size of the buffer
+ * @param read The length of the line.
+ * @param r The request
+ * @param fold Whether to merge continuation lines
+ * @param bb Working brigade to use when reading buckets
+ * @return APR_SUCCESS, if successful
+ *         APR_ENOSPC, if the line is too big to fit in the buffer
+ *         Other errors where appropriate
+ }
+{#if APR_CHARSET_EBCDIC
+AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n, 
+                                     apr_size_t *read,
+                                     request_rec *r, int fold,
+                                     apr_bucket_brigade *bb);
+#else }{ ASCII box }
+{#define ap_rgetline(s, n, read, r, fold, bb) \
+        ap_rgetline_core((s), (n), (read), (r), (fold), (bb))
+#endif}
+
+{AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
+                                          apr_size_t *read,
+                                          request_rec *r, int fold,
+                                          apr_bucket_brigade *bb);}
+
+{
+ * Get the method number associated with the given string, assumed to
+ * contain an HTTP method.  Returns M_INVALID if not recognized.
+ * @param method A string containing a valid HTTP method
+ * @return The method number
+ }
+function ap_method_number_of(const method: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_method_number_of' + LibSuff4;
+
+{
+ * Get the method name associated with the given internal method
+ * number.  Returns NULL if not recognized.
+ * @param p A pool to use for temporary allocations.
+ * @param methnum An integer value corresponding to an internal method number
+ * @return The name corresponding to the method number
+ }
+function ap_method_name_of(p: Papr_pool_t; methnum: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_method_name_of' + LibSuff8;
+
+
+  { Hooks }
+  {
+   * post_read_request --- run right after read_request or internal_redirect,
+   *                  and not run during any subrequests.
+   }
+{
+ * This hook allows modules to affect the request immediately after the request
+ * has been read, and before any other phases have been processes.  This allows
+ * modules to make decisions based upon the input header fields
+ * @param r The current request
+ * @return OK or DECLINED
+ * @deffunc ap_run_post_read_request(request_rec *r)
+ }
+type
+  ap_HOOK_post_read_request_t = function(r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_post_read_request(pf: ap_HOOK_post_read_request_t;
+ const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_post_read_request' + LibSuff16;
+
+{
+ * This hook allows modules to perform any module-specific logging activities
+ * over and above the normal server things.
+ * @param r The current request
+ * @return OK, DECLINED, or HTTP_...
+ * @deffunc int ap_run_log_transaction(request_rec *r)
+ }
+type
+  ap_HOOK_log_transaction_t = function(r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_log_transaction(pf: ap_HOOK_log_transaction_t;
+ const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_log_transaction' + LibSuff16;
+
+{
+ * This hook allows modules to retrieve the http method from a request.  This
+ * allows Apache modules to easily extend the methods that Apache understands
+ * @param r The current request
+ * @return The http method from the request
+ * @deffunc const char *ap_run_http_method(const request_rec *r)
+ }
+type
+  ap_HOOK_http_method_t = function(const r: Prequest_rec): PChar; cdecl;
+
+procedure ap_hook_http_method(pf: ap_HOOK_http_method_t;
+ const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_http_method' + LibSuff16;
+
+{
+ * Return the default port from the current request
+ * @param r The current request
+ * @return The current port
+ * @deffunc apr_port_t ap_run_default_port(const request_rec *r)
+ }
+type
+  ap_HOOK_default_port_t = function(const r: Prequest_rec): apr_port_t; cdecl;
+
+procedure ap_hook_default_port(pf: ap_HOOK_default_port_t;
+ const aszPre: PPChar; const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_default_port' + LibSuff16;
+
+{
+ * A bucket referring to an HTTP error
+ * This bucket can be passed down the filter stack to indicate that an
+ * HTTP error occurred while running a filter.  In order for this bucket
+ * to be used successfully, it MUST be sent as the first bucket in the
+ * first brigade to be sent from a given filter.
+ }
+type
+  ap_bucket_error = record
+    { Number of buckets using this memory }
+    refcount: apr_bucket_refcount;
+    { The error code }
+    status: Integer;
+    { The error string }
+    data: PChar;
+  end;
+  Pap_bucket_error = ^ap_bucket_error;
+
+//AP_DECLARE_DATA extern const apr_bucket_type_t ap_bucket_type_error;
+
+{
+ * Determine if a bucket is an error bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define AP_BUCKET_IS_ERROR(e)         (e->type == &ap_bucket_type_error)
+
+{
+ * Make the bucket passed in an error bucket
+ * @param b The bucket to make into an error bucket
+ * @param error The HTTP error code to put in the bucket. 
+ * @param buf An optional error string to put in the bucket.
+ * @param p A pool to allocate out of.
+ * @return The new bucket, or NULL if allocation failed
+ * @deffunc apr_bucket *ap_bucket_error_make(apr_bucket *b, int error, const char *buf, apr_pool_t *p)
+ }
+function ap_bucket_error_make(b: Papr_bucket; error: Integer;
+ const buf: PChar; p: Papr_pool_t): Papr_bucket;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_bucket_error_make' + LibSuff16;
+
+{
+ * Create a bucket referring to an HTTP error.
+ * @param error The HTTP error code to put in the bucket. 
+ * @param buf An optional error string to put in the bucket.
+ * @param p A pool to allocate the error string out of.
+ * @param list The bucket allocator from which to allocate the bucket
+ * @return The new bucket, or NULL if allocation failed
+ * @deffunc apr_bucket *ap_bucket_error_create(int error, const char *buf, apr_pool_t *p, apr_bucket_alloc_t *list)
+ }
+function ap_bucket_error_create(error: Integer; const buf: PChar;
+ p: Papr_pool_t; list: Papr_bucket_alloc_t): Papr_bucket;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_bucket_error_create' + LibSuff16;
+
+function ap_byterange_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t;
+ cdecl; external LibHTTPD name 'ap_byterange_filter';
+
+function ap_http_header_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t;
+ cdecl; external LibHTTPD name 'ap_http_header_filter';
+
+function ap_content_length_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t;
+ cdecl; external LibHTTPD name 'ap_content_length_filter';
+
+function ap_old_write_filter(f: Pap_filter_t; b: Papr_bucket_brigade): apr_status_t;
+ cdecl; external LibHTTPD name 'ap_old_write_filter';
+
+{
+ * Setting up the protocol fields for subsidiary requests...
+ * Also, a wrapup function to keep the internal accounting straight.
+ }
+procedure ap_set_sub_req_protocol(rnew: Prequest_rec; const r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_set_sub_req_protocol' + LibSuff8;
+
+procedure ap_finalize_sub_req_protocol(sub_r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_finalize_sub_req_protocol' + LibSuff4;
+

+ 460 - 0
packages/base/httpd/httpd-2.0/http_request.inc

@@ -0,0 +1,460 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{#include "apr_hooks.h"
+#include "util_filter.h"}
+
+const
+  AP_SUBREQ_NO_ARGS = 0;
+  AP_SUBREQ_MERGE_ARGS = 1;
+
+{
+ * @file http_request.h
+ * @brief Apache Request library
+ }
+
+{ http_request.c is the code which handles the main line of request
+ * processing, once a request has been read in (finding the right per-
+ * directory configuration, building it if necessary, and calling all
+ * the module dispatch functions in the right order).
+ *
+ * The pieces here which are public to the modules, allow them to learn
+ * how the server would handle some other file or URI, or perhaps even
+ * direct the server to serve that other file instead of the one the
+ * client requested directly.
+ *
+ * There are two ways to do that.  The first is the sub_request mechanism,
+ * which handles looking up files and URIs as adjuncts to some other
+ * request (e.g., directory entries for multiviews and directory listings);
+ * the lookup functions stop short of actually running the request, but
+ * (e.g., for includes), a module may call for the request to be run
+ * by calling run_sub_req.  The space allocated to create sub_reqs can be
+ * reclaimed by calling destroy_sub_req --- be sure to copy anything you care
+ * about which was allocated in its apr_pool_t elsewhere before doing this.
+ }
+
+{
+ * An internal handler used by the ap_process_request, all subrequest mechanisms
+ * and the redirect mechanism.
+ * @param r The request, subrequest or internal redirect to pre-process
+ * @return The return code for the request
+ }
+function ap_process_request_internal(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_process_request_internal' + LibSuff4;
+
+{
+ * Create a subrequest from the given URI.  This subrequest can be
+ * inspected to find information about the requested URI
+ * @param new_uri The URI to lookup
+ * @param r The current request
+ * @param next_filter The first filter the sub_request should use.  If this is
+ *                    NULL, it defaults to the first filter for the main request
+ * @return The new request record
+ * @deffunc request_rec * ap_sub_req_lookup_uri(const char *new_uri, const request_rec *r)
+ }
+function ap_sub_req_lookup_uri(const new_uri: PChar;
+ const r: Prequest_rec; next_filter: Pap_filter_t): Prequest_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_sub_req_lookup_uri' + LibSuff12;
+
+{
+ * Create a subrequest for the given file.  This subrequest can be
+ * inspected to find information about the requested file
+ * @param new_file The file to lookup
+ * @param r The current request
+ * @param next_filter The first filter the sub_request should use.  If this is
+ *                    NULL, it defaults to the first filter for the main request
+ * @return The new request record
+ * @deffunc request_rec * ap_sub_req_lookup_file(const char *new_file, const request_rec *r)
+ }
+function ap_sub_req_lookup_file(const new_file: PChar;
+ const r: Prequest_rec; next_filter: Pap_filter_t): Prequest_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_sub_req_lookup_file' + LibSuff12;
+
+{
+ * Create a subrequest for the given apr_dir_read result.  This subrequest 
+ * can be inspected to find information about the requested file
+ * @param finfo The apr_dir_read result to lookup
+ * @param r The current request
+ * @param subtype What type of subrequest to perform, one of;
+ * <PRE>
+ *      AP_SUBREQ_NO_ARGS     ignore r->args and r->path_info
+ *      AP_SUBREQ_MERGE_ARGS  merge r->args and r->path_info
+ * </PRE>
+ * @param next_filter The first filter the sub_request should use.  If this is
+ *                    NULL, it defaults to the first filter for the main request
+ * @return The new request record
+ * @deffunc request_rec * ap_sub_req_lookup_dirent(apr_finfo_t *finfo, int subtype, const request_rec *r)
+ * @tip The apr_dir_read flags value APR_FINFO_MIN|APR_FINFO_NAME flag is the 
+ * minimum recommended query if the results will be passed to apr_dir_read.
+ * The file info passed must include the name, and must have the same relative
+ * directory as the current request.
+ }
+function ap_sub_req_lookup_dirent(const finfo: Papr_finfo_t;
+ const r: Prequest_rec; subtype: Integer; next_filter: Pap_filter_t): Prequest_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_sub_req_lookup_dirent' + LibSuff16;
+
+{
+ * Create a subrequest for the given URI using a specific method.  This
+ * subrequest can be inspected to find information about the requested URI
+ * @param method The method to use in the new subrequest
+ * @param new_uri The URI to lookup
+ * @param r The current request
+ * @param next_filter The first filter the sub_request should use.  If this is
+ *                    NULL, it defaults to the first filter for the main request
+ * @return The new request record
+ * @deffunc request_rec * ap_sub_req_method_uri(const char *method, const char *new_uri, const request_rec *r)
+ }
+function ap_sub_req_method_uri(const method, new_uri: PChar;
+ const r: Prequest_rec; next_filter: Pap_filter_t): Prequest_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_sub_req_method_uri' + LibSuff16;
+
+{
+ * An output filter to strip EOS buckets from sub-requests.  This always
+ * has to be inserted at the end of a sub-requests filter stack.
+ * @param f The current filter
+ * @param bb The brigade to filter
+ * @deffunc apr_status_t ap_sub_req_output_filter(ap_filter_t *f, apr_bucket_brigade *bb)
+ }
+function ap_sub_req_output_filter(f: Pap_filter_t;
+ bb: Papr_bucket_brigade): apr_status_t;
+ cdecl; external LibHTTPD name 'ap_sub_req_output_filter';
+
+{
+ * Run the handler for the subrequest
+ * @param r The subrequest to run
+ * @return The return code for the subrequest
+ * @deffunc int ap_run_sub_req(request_rec *r)
+ }
+function ap_run_sub_req(r: Prequest_rec): Prequest_rec;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_run_sub_req' + LibSuff4;
+
+{
+ * Free the memory associated with a subrequest
+ * @param r The subrequest to finish
+ * @deffunc void ap_destroy_sub_req(request_rec *r)
+ }
+procedure ap_destroy_sub_req(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_destroy_sub_req' + LibSuff4;
+
+{
+ * Then there's the case that you want some other request to be served
+ * as the top-level request INSTEAD of what the client requested directly.
+ * If so, call this from a handler, and then immediately return OK.
+ }
+
+{
+ * Redirect the current request to some other uri
+ * @param new_uri The URI to replace the current request with
+ * @param r The current request
+ * @deffunc void ap_internal_redirect(const char *new_uri, request_rec *r)
+ }
+procedure ap_internal_redirect(const new_uri: PChar; r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_internal_redirect' + LibSuff8;
+
+{
+ * This function is designed for things like actions or CGI scripts, when
+ * using AddHandler, and you want to preserve the content type across
+ * an internal redirect.
+ * @param new_uri The URI to replace the current request with.
+ * @param r The current request
+ * @deffunc void ap_internal_redirect_handler(const char *new_uri, request_rec *r)
+ }
+procedure ap_internal_redirect_handler(const new_uri: PChar; r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_internal_redirect_handler' + LibSuff8;
+
+{
+ * Redirect the current request to a sub_req, merging the pools
+ * @param sub_req A subrequest created from this request
+ * @param r The current request
+ * @deffunc void ap_internal_fast_redirect(request_rec *sub_req, request_rec *r)
+ * @tip the sub_req's pool will be merged into r's pool, be very careful
+ * not to destroy this subrequest, it will be destroyed with the main request!
+ }
+procedure ap_internal_fast_redirect(sub_req, r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_internal_fast_redirect' + LibSuff8;
+
+{
+ * Can be used within any handler to determine if any authentication
+ * is required for the current request
+ * @param r The current request
+ * @return 1 if authentication is required, 0 otherwise
+ * @deffunc int ap_some_auth_required(request_rec *r)
+ }
+function ap_some_auth_required(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_some_auth_required' + LibSuff4;
+
+{
+ * Determine if the current request is the main request or a subrequest
+ * @param r The current request
+ * @return 1 if this is the main request, 0 otherwise
+ * @deffunc int ap_is_initial_req(request_rec *r)
+ }
+function ap_is_initial_req(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_is_initial_req' + LibSuff4;
+
+{
+ * Function to set the r->mtime field to the specified value if it's later
+ * than what's already there.
+ * @param r The current request
+ * @param dependency_time Time to set the mtime to
+ * @deffunc void ap_update_mtime(request_rec *r, apr_time_t dependency_mtime)
+ }
+procedure ap_update_mtime(r: Prequest_rec; dependency_mtime: apr_time_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_update_mtime' + LibSuff12;
+
+{
+ * Add one or more methods to the list permitted to access the resource.
+ * Usually executed by the content handler before the response header is
+ * sent, but sometimes invoked at an earlier phase if a module knows it
+ * can set the list authoritatively.  Note that the methods are ADDED
+ * to any already permitted unless the reset flag is non-zero.  The
+ * list is used to generate the Allow response header field when it
+ * is needed.
+ * @param   r     The pointer to the request identifying the resource.
+ * @param   reset Boolean flag indicating whether this list should
+ *                completely replace any current settings.
+ * @param   ...   A NULL-terminated list of strings, each identifying a
+ *                method name to add.
+ * @return  None.
+ * @deffunc void ap_allow_methods(request_rec *r, int reset, ...)
+ }
+procedure ap_allow_methods(r: Prequest_rec; reset: Integer; others: array of const);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name 'ap_allow_methods';
+
+//AP_DECLARE(void) (request_rec *r, int reset, ...);
+
+{
+ * Add one or more methods to the list permitted to access the resource.
+ * Usually executed by the content handler before the response header is
+ * sent, but sometimes invoked at an earlier phase if a module knows it
+ * can set the list authoritatively.  Note that the methods are ADDED
+ * to any already permitted unless the reset flag is non-zero.  The
+ * list is used to generate the Allow response header field when it
+ * is needed.
+ * @param   r     The pointer to the request identifying the resource.
+ * @param   reset Boolean flag indicating whether this list should
+ *                completely replace any current settings.
+ * @param   ...   A list of method identifiers, from the "M_" series
+ *                defined in httpd.h, terminated with a value of -1
+ *                (e.g., "M_GET, M_POST, M_OPTIONS, -1")
+ * @return  None.
+ * @deffunc void ap_allow_standard_methods(request_rec *r, int reset, ...)
+ }
+procedure ap_allow_standard_methods(r: Prequest_rec; reset: Integer; others: array of const);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name 'ap_allow_standard_methods';
+
+//AP_DECLARE(void) (request_rec *r, int reset, ...);
+
+const
+  MERGE_ALLOW = 0;
+  REPLACE_ALLOW = 1;
+
+//#ifdef CORE_PRIVATE
+{ Function called by main.c to handle first-level request }
+//void ap_process_request(request_rec *);
+{
+ * Kill the current request
+ * @param type Why the request is dieing
+ * @param r The current request
+ * @deffunc void ap_die(int type, request_rec *r)
+ }
+procedure ap_die(type_: Integer; r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_die' + LibSuff8;
+
+//#endif COREPRIVATE
+
+{ Hooks }
+
+{
+ * Gives modules a chance to create their request_config entry when the
+ * request is created.
+ * @param r The current request
+ * @ingroup hooks
+ }
+type
+  ap_HOOK_create_request_t = function (r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_create_request(pf: ap_HOOK_create_request_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_create_request' + LibSuff16;
+
+{
+ * This hook allow modules an opportunity to translate the URI into an
+ * actual filename.  If no modules do anything special, the server's default
+ * rules will be followed.
+ * @param r The current request
+ * @return OK, DECLINED, or HTTP_...
+ * @ingroup hooks
+ }
+type
+  ap_HOOK_translate_name_t = function (r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_translate_name(pf: ap_HOOK_translate_name_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_translate_name' + LibSuff16;
+
+{
+ * This hook allow modules to set the per_dir_config based on their own
+ * context (such as <Proxy > sections) and responds to contextless requests 
+ * such as TRACE that need no security or filesystem mapping.
+ * based on the filesystem.
+ * @param r The current request
+ * @return DONE (or HTTP_) if this contextless request was just fulfilled 
+ * (such as TRACE), OK if this is not a file, and DECLINED if this is a file.
+ * The core map_to_storage (HOOK_RUN_REALLY_LAST) will directory_walk
+ * and file_walk the r->filename.
+ * 
+ * @ingroup hooks
+ }
+type
+  ap_HOOK_map_to_storage_t = function (r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_map_to_storage(pf: ap_HOOK_map_to_storage_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_map_to_storage' + LibSuff16;
+
+{
+ * This hook is used to analyze the request headers, authenticate the user,
+ * and set the user information in the request record (r->user and
+ * r->ap_auth_type). This hook is only run when Apache determines that
+ * authentication/authorization is required for this resource (as determined
+ * by the 'Require' directive). It runs after the access_checker hook, and
+ * before the auth_checker hook.
+ *
+ * @param r The current request
+ * @return OK, DECLINED, or HTTP_...
+ * @ingroup hooks
+ }
+type
+  ap_HOOK_check_user_id_t = function (r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_check_user_id(pf: ap_HOOK_check_user_id_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_check_user_id' + LibSuff16;
+
+{
+ * Allows modules to perform module-specific fixing of header fields.  This
+ * is invoked just before any content-handler
+ * @param r The current request
+ * @return OK, DECLINED, or HTTP_...
+ * @ingroup hooks
+ }
+type
+  ap_HOOK_fixups_t = function (r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_fixups(pf: ap_HOOK_fixups_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_fixups' + LibSuff16;
+
+{
+ * This routine is called to determine and/or set the various document type
+ * information bits, like Content-type (via r->content_type), language, et
+ * cetera.
+ * @param r the current request
+ * @return OK, DECLINED, or HTTP_...
+ * @ingroup hooks
+ }
+type
+  ap_HOOK_type_checker_t = function (r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_type_checker(pf: ap_HOOK_type_checker_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_type_checker' + LibSuff16;
+
+{
+ * This hook is used to apply additional access control to this resource.
+ * It runs *before* a user is authenticated, so this hook is really to
+ * apply additional restrictions independent of a user. It also runs
+ * independent of 'Require' directive usage.
+ *
+ * @param r the current request
+ * @return OK, DECLINED, or HTTP_...
+ * @ingroup hooks
+ }
+type
+  ap_HOOK_access_checker_t = function (r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_access_checker(pf: ap_HOOK_access_checker_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_access_checker' + LibSuff16;
+
+{
+ * This hook is used to check to see if the resource being requested
+ * is available for the authenticated user (r->user and r->ap_auth_type).
+ * It runs after the access_checker and check_user_id hooks. Note that
+ * it will *only* be called if Apache determines that access control has
+ * been applied to this resource (through a 'Require' directive).
+ *
+ * @param r the current request
+ * @return OK, DECLINED, or HTTP_...
+ * @ingroup hooks
+ }
+type
+  ap_HOOK_auth_checker_t = function (r: Prequest_rec): Integer; cdecl;
+
+procedure ap_hook_auth_checker(pf: ap_HOOK_auth_checker_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_auth_checker' + LibSuff16;
+
+{
+ * This hook allows modules to insert filters for the current request
+ * @param r the current request
+ * @ingroup hooks
+ }
+type
+  ap_HOOK_insert_filter_t = procedure (r: Prequest_rec); cdecl;
+
+procedure ap_hook_insert_filter(pf: ap_HOOK_insert_filter_t; const aszPre: PPChar;
+ const aszSucc: PPChar; nOrder: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_hook_insert_filter' + LibSuff16;
+
+function ap_location_walk(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_location_walk' + LibSuff4;
+
+function ap_directory_walk(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_directory_walk' + LibSuff4;
+
+function ap_file_walk(r: Prequest_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_file_walk' + LibSuff4;
+

+ 83 - 0
packages/base/httpd/httpd-2.0/http_vhost.inc

@@ -0,0 +1,83 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @package Virtual Host package
+ }
+
+{
+ * called before any config is read
+ * @param p Pool to allocate out of
+ }
+procedure ap_init_vhost_config(p: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_init_vhost_config' + LibSuff4;
+
+{
+ * called after the config has been read to compile the tables needed to do 
+ * the run-time vhost lookups
+ * @param p The pool to allocate out of
+ * @param main_server The start of the virtual host list
+ * @deffunc ap_fini_vhost_config(apr_pool_t *p, server_rec *main_server)
+ }
+procedure ap_fini_vhost_config(p: Papr_pool_t; main_server: Pserver_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_fini_vhost_config' + LibSuff8;
+
+{
+ * handle addresses in <VirtualHost> statement
+ * @param p The pool to allocate out of
+ * @param hostname The hostname in the VirtualHost statement
+ * @param s The list of Virtual Hosts.
+ }
+//const char *ap_parse_vhost_addrs(apr_pool_t *p, const char *hostname, server_rec *s);
+
+{ handle NameVirtualHost directive }
+//const char *ap_set_name_virtual_host (cmd_parms *cmd, void *dummy,
+//				      const char *arg);
+
+{
+ * given an ip address only, give our best guess as to what vhost it is 
+ * @param conn The current connection
+ }
+procedure ap_update_vhost_given_ip(conn: Pconn_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_update_vhost_given_ip' + LibSuff4;
+
+{
+ * ap_update_vhost_given_ip is never enough, and this is always called after 
+ * the headers have been read.  It may change r->server.
+ * @param r The current request
+ }
+procedure ap_update_vhost_from_headers(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_update_vhost_from_headers' + LibSuff4;
+
+{
+ * Match the host in the header with the hostname of the server for this
+ * request.
+ * @param r The current request
+ * @param host The hostname in the headers
+ * @param port The port from the headers
+ * @return return 1 if the host:port matches any of the aliases of r->server,
+ * return 0 otherwise
+ * @deffunc int ap_matches_request_vhost(request_rec *r, const char *host, apr_port_t port)
+ }
+function ap_matches_request_vhost(r: Prequest_rec; const host: PChar;
+ port: apr_port_t): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_matches_request_vhost' + LibSuff12;
+

+ 1758 - 0
packages/base/httpd/httpd-2.0/httpd.inc

@@ -0,0 +1,1758 @@
+{
+ * @file httpd.h
+ * @brief HTTP Daemon routines
+}
+
+{ XXX - We need to push more stuff to other .h files, or even .c files, to
+ * make this file smaller
+}
+
+// Headers in which EVERYONE has an interest...
+{$include ap_config.inc}
+{$include ap_mmn.inc}
+
+{$include ap_release.inc}
+
+{#include "apr_general.h"}
+{#include "apr_time.h"
+#include "apr_network_io.h"}
+
+{$ifdef windows}
+  {$include apr\apr_buckets.inc}
+{$else}
+  {$include apr/apr_buckets.inc}
+{$endif}
+
+{#include "os.h"}
+
+{$include pcreposix.inc}
+
+// Note: util_uri.h is also included, see below
+
+{ ----------------------------- config dir ------------------------------ }
+
+{ Define this to be the default server home dir. Most things later in this
+ * file with a relative pathname will have this added.
+}
+const
+  {$ifdef OS2}
+    { Set default for OS/2 file system }
+    HTTPD_ROOT = '/os2httpd';
+  {$else}{$ifdef WINDOWS}
+    { Set default for Windows file system }
+    HTTPD_ROOT = '/apache';
+  {$else}{$ifdef BEOS}
+    { Set the default for BeOS }
+    HTTPD_ROOT = '/boot/home/apache';
+  {$else}{$ifdef NETWARE}
+    { Set the default for NetWare }
+    HTTPD_ROOT = '/apache';
+  {$else}
+    HTTPD_ROOT = '/usr/local/apache';
+  {$endif}
+  {$endif}
+  {$endif}
+  {$endif}
+
+{
+ * --------- You shouldn't have to edit anything below this line ----------
+ *
+ * Any modifications to any defaults not defined above should be done in the
+ * respective configuration file.
+ *
+}
+const
+
+{ Default location of documents.  Can be overridden by the DocumentRoot
+ * directive.
+}
+  DOCUMENT_LOCATION = HTTPD_ROOT + '/htdocs';
+
+// Maximum number of dynamically loaded modules
+ DYNAMIC_MODULE_LIMIT = 64;
+
+// Default administrator's address
+ DEFAULT_ADMIN  = '[no address given]';
+
+// The name of the log files
+{$if defined(OS2) or defined(WINDOWS)}
+  DEFAULT_ERRORLOG = 'logs/error.log';
+{$else}
+  DEFAULT_ERRORLOG = 'logs/error_log';
+{$endif}
+
+{ Define this to be what your per-directory security files are called }
+  DEFAULT_ACCESS_FNAME = '.htaccess';
+
+{ The name of the server config file }
+  SERVER_CONFIG_FILE = 'conf/httpd.conf';
+
+{ Whether we should enable rfc1413 identity checking }
+  DEFAULT_RFC1413 = 0;
+
+{ The default path for CGI scripts if none is currently set }
+  DEFAULT_PATH = '/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin';
+
+{ The path to the suExec wrapper, can be overridden in Configuration }
+  SUEXEC_BIN  = HTTPD_ROOT + '/bin/suexec';
+
+{ The timeout for waiting for messages }
+  DEFAULT_TIMEOUT = 300 ;
+
+{ The timeout for waiting for keepalive timeout until next request }
+  DEFAULT_KEEPALIVE_TIMEOUT = 15;
+
+{ The number of requests to entertain per connection }
+  DEFAULT_KEEPALIVE = 100;
+
+{ Limits on the size of various request items.  These limits primarily
+ * exist to prevent simple denial-of-service attacks on a server based
+ * on misuse of the protocol.  The recommended values will depend on the
+ * nature of the server resources -- CGI scripts and database backends
+ * might require large values, but most servers could get by with much
+ * smaller limits than we use below.  The request message body size can
+ * be limited by the per-dir config directive LimitRequestBody.
+ *
+ * Internal buffer sizes are two bytes more than the DEFAULT_LIMIT_REQUEST_LINE
+ * and DEFAULT_LIMIT_REQUEST_FIELDSIZE below, which explains the 8190.
+ * These two limits can be lowered (but not raised) by the server config
+ * directives LimitRequestLine and LimitRequestFieldsize, respectively.
+ *
+ * DEFAULT_LIMIT_REQUEST_FIELDS can be modified or disabled (set = 0) by
+ * the server config directive LimitRequestFields.
+}
+  DEFAULT_LIMIT_REQUEST_LINE = 8190;
+
+  DEFAULT_LIMIT_REQUEST_FIELDSIZE = 8190;
+
+  DEFAULT_LIMIT_REQUEST_FIELDS = 100;
+
+
+{
+ * The default default character set name to add if AddDefaultCharset is
+ * enabled.  Overridden with AddDefaultCharsetName.
+}
+  DEFAULT_ADD_DEFAULT_CHARSET_NAME = 'iso-8859-1';
+
+{ default HTTP Server protocol }
+  AP_SERVER_PROTOCOL = 'HTTP/1.1';
+
+
+{ ------------------ stuff that modules are allowed to look at ----------- }
+
+  AP_DEFAULT_INDEX = 'index.html';
+
+
+{
+ * Define this to be what type you'd like returned for files with unknown
+ * suffixes.
+ * @warning MUST be all lower case.
+}
+  DEFAULT_CONTENT_TYPE = 'text/plain';
+
+{ The name of the MIME types file }
+  AP_TYPES_CONFIG_FILE = 'conf/mime.types';
+
+{
+ * Define the HTML doctype strings centrally.
+}
+{ HTML 2.0 Doctype }
+  DOCTYPE_HTML_2_0 = '<!DOCTYPE HTML PUBLIC "-//IETF//' +
+                          'DTD HTML 2.0//EN">' + LineEnding;
+{ HTML 3.2 Doctype }
+  DOCTYPE_HTML_3_2 = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
+                          'DTD HTML 3.2 Final//EN">' + LineEnding;
+{ HTML 4.0 Strict Doctype }
+  DOCTYPE_HTML_4_0S = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
+                          'DTD HTML 4.0//EN"' + LineEnding +
+                          '"http://www.w3.org/TR/REC-html40/strict.dtd">' + LineEnding;
+{ HTML 4.0 Transitional Doctype }
+  DOCTYPE_HTML_4_0T = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
+                          'DTD HTML 4.0 Transitional//EN"' + LineEnding +
+                          '"http://www.w3.org/TR/REC-html40/loose.dtd">' + LineEnding;
+{ HTML 4.0 Frameset Doctype }
+  DOCTYPE_HTML_4_0F = '<!DOCTYPE HTML PUBLIC "-//W3C//' +
+                          'DTD HTML 4.0 Frameset//EN"' + LineEnding +
+                          '"http://www.w3.org/TR/REC-html40/frameset.dtd">' + LineEnding;
+{ XHTML 1.0 Strict Doctype }
+  DOCTYPE_XHTML_1_0S = '<!DOCTYPE html PUBLIC "-//W3C//' +
+                           'DTD XHTML 1.0 Strict//EN"' + LineEnding +
+                           '"http://www.w3.org/TR/xhtml1/DTD/' +
+                           'xhtml1-strict.dtd\">' + LineEnding;
+{ XHTML 1.0 Transitional Doctype }
+  DOCTYPE_XHTML_1_0T = '<!DOCTYPE html PUBLIC "-//W3C//' +
+                           'DTD XHTML 1.0 Transitional//EN"' + LineEnding +
+                           '"http://www.w3.org/TR/xhtml1/DTD/' +
+                           'xhtml1-transitional.dtd">' + LineEnding;
+{ XHTML 1.0 Frameset Doctype }
+  DOCTYPE_XHTML_1_0F = '<!DOCTYPE html PUBLIC "-//W3C//' +
+                           'DTD XHTML 1.0 Frameset//EN"' + LineEnding +
+                           '"http://www.w3.org/TR/xhtml1/DTD/' +
+                           'xhtml1-frameset.dtd">' + LineEnding;
+
+{ Internal representation for a HTTP protocol number, e.g., HTTP/1.1 }
+
+function HTTP_VERSION(major, minor: Integer): Integer;
+{ Major part of HTTP protocol }
+function HTTP_VERSION_MAJOR(number: Integer): Integer;
+{ Minor part of HTTP protocol }
+function HTTP_VERSION_MINOR(number: Integer): Integer;
+
+{ -------------- Port number for server running standalone --------------- }
+
+const
+{ default HTTP Port }
+  DEFAULT_HTTP_PORT =	80;
+{ default HTTPS Port }
+  DEFAULT_HTTPS_PORT =	443;
+{
+ * Check whether @a port is the default port for the request @a r.
+ * @param port The port number
+ * @param r The request
+ * @see #ap_default_port
+}
+//#define ap_is_default_port(port,r)	((port) == ap_default_port(r))
+{
+ * Get the default port for a request (which depends on the scheme).
+ * @param r The request
+}
+//#define ap_default_port(r)	ap_run_default_port(r)
+{
+ * Get the scheme for a request.
+ * @param r The request
+ * @bug This should be called ap_http_scheme!
+}
+//#define ap_http_method(r)	ap_run_http_method(r)
+
+{ The default string lengths }
+//  MAX_STRING_LEN = HUGE_STRING_LEN;
+  HUGE_STRING_LEN = 8192;
+
+{ The size of the server's internal read-write buffers }
+  AP_IOBUFSIZE = 8192;
+
+{ The max number of regex captures that can be expanded by ap_pregsub }
+  AP_MAX_REG_MATCH = 10;
+
+{
+ * APR_HAS_LARGE_FILES introduces the problem of spliting sendfile into
+ * mutiple buckets, no greater than MAX(apr_size_t), and more granular
+ * than that in case the brigade code/filters attempt to read it directly.
+ * ### 16mb is an invention, no idea if it is reasonable.
+ }
+  AP_MAX_SENDFILE  = 16777216;  { 2^24 }
+
+{
+ * Special Apache error codes. These are basically used
+ *  in http_main.c so we can keep track of various errors.
+ *
+ }
+{ a normal exit }
+  APEXIT_OK =		$0;
+{ A fatal error arising during the server's init sequence }
+  APEXIT_INIT =		$2;
+{  The child died during its init sequence }
+  APEXIT_CHILDINIT =	$3;
+{
+ *   The child exited due to a resource shortage.
+ *   The parent should limit the rate of forking until
+ *   the situation is resolved.
+}
+  APEXIT_CHILDSICK =      $7;
+{
+ *     A fatal error, resulting in the whole server aborting.
+ *     If a child exits with this error, the parent process
+ *     considers this a server-wide fatal error and aborts.
+}
+  APEXIT_CHILDFATAL =	$f;
+
+{
+ * Stuff marked #AP_DECLARE is part of the API, and intended for use
+ * by modules. Its purpose is to allow us to add attributes that
+ * particular platforms or compilers require to every exported function.
+}
+// define AP_DECLARE(type)    type
+
+{
+ * Stuff marked #AP_DECLARE_NONSTD is part of the API, and intended for
+ * use by modules.  The difference between #AP_DECLARE and
+ * #AP_DECLARE_NONSTD is that the latter is required for any functions
+ * which use varargs or are used via indirect function call.  This
+ * is to accomodate the two calling conventions in windows dlls.
+}
+//# define AP_DECLARE_NONSTD(type)    type
+
+{$define AP_DECLARE_DATA}
+
+
+//# define AP_MODULE_DECLARE(type)    type
+//# define AP_MODULE_DECLARE_NONSTD(type)  type
+
+{$define AP_MODULE_DECLARE_DATA}
+
+{
+ * @internal
+ * modules should not used functions marked AP_CORE_DECLARE
+}
+//  AP_CORE_DECLARE =	AP_DECLARE;
+
+{
+ * @internal
+ * modules should not used functions marked AP_CORE_DECLARE_NONSTD
+}
+
+//  AP_CORE_DECLARE_NONSTD =	AP_DECLARE_NONSTD;
+
+{
+ * The numeric version information is broken out into fields within this
+ * structure.
+ }
+type
+  ap_version_t = record
+    major: Integer;              {< major number }
+    minor: Integer;              {< minor number }
+    patch: Integer;              {< patch number }
+    add_string: PChar; {< additional string like "-dev" }
+  end;
+  
+  Pap_version_t = ^ap_version_t;
+
+{
+ * Return httpd's version information in a numeric form.
+ *
+ *  @param version Pointer to a version structure for returning the version
+ *                 information.
+ }
+procedure ap_get_server_revision(version: Pap_version_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_server_revision' + LibSuff4;
+
+{
+ * Get the server version string
+ * @return The server version string
+ }
+function ap_get_server_version: PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_server_version' + LibSuff0;
+
+{
+ * Add a component to the version string
+ * @param pconf The pool to allocate the component from
+ * @param component The string to add
+}
+procedure ap_add_version_component(pconf: Papr_pool_t; const component: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_add_version_component' + LibSuff8;
+
+{
+ * Get the date a time that the server was built
+ * @return The server build time string
+}
+function ap_get_server_built: PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_server_built' + LibSuff0;
+
+const
+  DECLINED = -1;		{< Module declines to handle }
+  DONE = -2;			{< Module has served the response completely
+				 *  - it's safe to die() with no more output
+				 }
+  OK = 0;			{< Module has handled this stage. }
+
+
+{
+ * @defgroup HTTP_Status HTTP Status Codes
+ * @
+
+
+ * The size of the static array in http_protocol.c for storing
+ * all of the potential response status-lines (a sparse table).
+ * A future version should dynamically generate the apr_table_t at startup.
+}
+  RESPONSE_CODES = 57;
+
+  HTTP_CONTINUE =                      100;
+  HTTP_SWITCHING_PROTOCOLS =           101;
+  HTTP_PROCESSING =                    102;
+  HTTP_OK =                            200;
+  HTTP_CREATED =                       201;
+  HTTP_ACCEPTED =                      202;
+  HTTP_NON_AUTHORITATIVE =             203;
+  HTTP_NO_CONTENT =                    204;
+  HTTP_RESET_CONTENT =                 205;
+  HTTP_PARTIAL_CONTENT =               206;
+  HTTP_MULTI_STATUS =                  207;
+  HTTP_MULTIPLE_CHOICES =              300;
+  HTTP_MOVED_PERMANENTLY =             301;
+  HTTP_MOVED_TEMPORARILY =             302;
+  HTTP_SEE_OTHER =                     303;
+  HTTP_NOT_MODIFIED =                  304;
+  HTTP_USE_PROXY =                     305;
+  HTTP_TEMPORARY_REDIRECT =            307;
+  HTTP_BAD_REQUEST =                   400;
+  HTTP_UNAUTHORIZED =                  401;
+  HTTP_PAYMENT_REQUIRED =              402;
+  HTTP_FORBIDDEN =                     403;
+  HTTP_NOT_FOUND =                     404;
+  HTTP_METHOD_NOT_ALLOWED =            405;
+  HTTP_NOT_ACCEPTABLE =                406;
+  HTTP_PROXY_AUTHENTICATION_REQUIRED = 407;
+  HTTP_REQUEST_TIME_OUT =              408;
+  HTTP_CONFLICT =                      409;
+  HTTP_GONE =                          410;
+  HTTP_LENGTH_REQUIRED =               411;
+  HTTP_PRECONDITION_FAILED =           412;
+  HTTP_REQUEST_ENTITY_TOO_LARGE =      413;
+  HTTP_REQUEST_URI_TOO_LARGE =         414;
+  HTTP_UNSUPPORTED_MEDIA_TYPE =        415;
+  HTTP_RANGE_NOT_SATISFIABLE =         416;
+  HTTP_EXPECTATION_FAILED =            417;
+  HTTP_UNPROCESSABLE_ENTITY =          422;
+  HTTP_LOCKED =                        423;
+  HTTP_FAILED_DEPENDENCY =             424;
+  HTTP_UPGRADE_REQUIRED =              426;
+  HTTP_INTERNAL_SERVER_ERROR =         500;
+  HTTP_NOT_IMPLEMENTED =               501;
+  HTTP_BAD_GATEWAY =                   502;
+  HTTP_SERVICE_UNAVAILABLE =           503;
+  HTTP_GATEWAY_TIME_OUT =              504;
+  HTTP_VERSION_NOT_SUPPORTED =         505;
+  HTTP_VARIANT_ALSO_VARIES =           506;
+  _INSUFFICIENT_STORAGE =              507;
+  HTTP_NOT_EXTENDED =                  510;
+
+{ is the status code informational }
+//#define ap_is_HTTP_INFO(x)         (((x) >= 100)&&((x) < 200))
+{ is the status code OK ?}
+//#define ap_is_HTTP_SUCCESS(x)      (((x) >= 200)&&((x) < 300))
+{ is the status code a redirect }
+//#define ap_is_HTTP_REDIRECT(x)     (((x) >= 300)&&((x) < 400))
+{ is the status code a error (client or server) }
+//#define ap_is_HTTP_ERROR(x)        (((x) >= 400)&&((x) < 600))
+{ is the status code a client error  }
+//#define ap_is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
+{ is the status code a server error  }
+//#define ap_is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
+
+{ should the status code drop the connection }
+{#define ap_status_drops_connection(x) \
+                                   (((x) == HTTP_BAD_REQUEST)           || \
+                                    ((x) == HTTP_REQUEST_TIME_OUT)      || \
+                                    ((x) == HTTP_LENGTH_REQUIRED)       || \
+                                    ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
+                                    ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
+                                    ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
+                                    ((x) == HTTP_SERVICE_UNAVAILABLE) || \
+				    ((x) == HTTP_NOT_IMPLEMENTED))}
+{
+ * @defgroup Methods List of Methods recognized by the server
+ * @
+
+
+ * Methods recognized (but not necessarily handled) by the server.
+ * These constants are used in bit shifting masks of size int, so it is
+ * unsafe to have more methods than bits in an int.  HEAD == M_GET.
+ * This list must be tracked by the list in http_protocol.c in routine
+ * ap_method_name_of().
+}
+const
+  M_GET =                   0;       // RFC 2616: HTTP
+  M_PUT =                   1;       //  :
+  M_POST =                  2;
+  M_DELETE =                3;
+  M_CONNECT =               4;
+  M_OPTIONS =               5;
+  M_TRACE =                 6;       // RFC 2616: HTTP }
+  M_PATCH =                 7;       // no rfc(!)  ### remove this one? }
+  M_PROPFIND =              8;       // RFC 2518: WebDAV }
+  M_PROPPATCH =             9;       //  :               }
+  M_MKCOL =                 10;
+  M_COPY =                  11;
+  M_MOVE =                  12;
+  M_LOCK =                  13;
+  M_UNLOCK =                14;      // RFC 2518: WebDAV }
+  M_VERSION_CONTROL =       15;      // RFC 3253: WebDAV Versioning }
+  M_CHECKOUT =              16;      //  :                          }
+  M_UNCHECKOUT =            17;
+  M_CHECKIN =               18;
+  M_UPDATE =                19;
+  M_LABEL =                 20;
+  M_REPORT =                21;
+  M_MKWORKSPACE =           22;
+  M_MKACTIVITY =            23;
+  M_BASELINE_CONTROL =      24;
+  M_MERGE =                 25;
+  M_INVALID =               26;      // RFC 3253: WebDAV Versioning }
+
+{
+ * METHODS needs to be equal to the number of bits
+ * we are using for limit masks.
+}
+  METHODS = 64;
+
+{
+ * The method mask bit to shift for anding with a bitmask.
+}
+  AP_METHOD_BIT = apr_int64_t(1);
+
+
+{
+ * Structure for handling HTTP methods.  Methods known to the server are
+ * accessed via a bitmask shortcut; extension methods are handled by
+ * an array.
+}
+type
+  ap_method_list_t = record
+    { The bitmask used for known methods }
+    method_mask: apr_int64_t;
+    { the array used for extension methods }
+//    method_list: ^apr_array_header_t;
+  end;
+{
+ * @defgroup module_magic Module Magic mime types
+ * @
+ }
+{ Magic for mod_cgi[d] }
+const
+  CGI_MAGIC_TYPE = 'application/x-httpd-cgi';
+{ Magic for mod_include }
+  INCLUDES_MAGIC_TYPE = 'text/x-server-parsed-html';
+{ Magic for mod_include }
+  INCLUDES_MAGIC_TYPE3 = 'text/x-server-parsed-html3';
+{ Magic for mod_dir }
+  DIR_MAGIC_TYPE = 'httpd/unix-directory';
+
+{ Just in case your linefeed isn't the one the other end is expecting. }
+{ linefeed }
+  LF = 10;
+{ carrige return }
+  CR = 13;
+{ carrige return /Line Feed Combo }
+  CRLF = #015#012;
+
+{
+ * @defgroup values_request_rec_body Possible values for request_rec.read_body
+ * @
+ * Possible values for request_rec.read_body (set by handling module):
+ }
+
+{ Send 413 error if message has any body }
+  REQUEST_NO_BODY =         0;
+{ Send 411 error if body without Content-Length }
+  REQUEST_CHUNKED_ERROR =   1;
+{ If chunked, remove the chunks for me. }
+  REQUEST_CHUNKED_DECHUNK = 2;
+
+
+{
+ * @defgroup values_request_rec_used_path_info Possible values for request_rec.used_path_info
+ * @
+ * Possible values for request_rec.used_path_info:
+ }
+
+{ Accept the path_info from the request }
+  AP_REQ_ACCEPT_PATH_INFO =   0;
+{ Return a 404 error if path_info was given }
+  AP_REQ_REJECT_PATH_INFO =   1;
+{ Module may chose to use the given path_info }
+  AP_REQ_DEFAULT_PATH_INFO =  2;
+{ @}
+
+{
+ * Things which may vary per file-lookup WITHIN a request ---
+ * e.g., state of MIME config.  Basically, the name of an object, info
+ * about the object, and any other info we may ahve which may need to
+ * change as we go poking around looking for it (e.g., overridden by
+ * .htaccess files).
+ *
+ * Note how the default state of almost all these things is properly
+ * zero, so that allocating it with pcalloc does the right thing without
+ * a whole lot of hairy initialization... so long as we are willing to
+ * make the (fairly) portable assumption that the bit pattern of a NULL
+ * pointer is, in fact, zero.
+}
+
+{
+ * This represents the result of calling htaccess; these are cached for
+ * each request.
+}
+type
+  Phtaccess_result = ^htaccess_result;
+  htaccess_result = record
+    { the directory to which this applies }
+    dir: PChar;
+    { the overrides allowed for the .htaccess file }
+    override_: Integer;
+    { the configuration directives }
+    htaccess: Pap_conf_vector_t;
+    { the next one, or NULL if no more; N.B. never change this }
+    next: Phtaccess_result;
+  end;
+
+{ The following four types define a hierarchy of activities, so that
+ * given a request_rec r you can write r->connection->server->process
+ * to get to the process_rec.  While this reduces substantially the
+ * number of arguments that various hooks require beware that in
+ * threaded versions of the server you must consider multiplexing
+ * issues.  }
+
+
+{ ### would be nice to not include this from httpd.h ... }
+{ This comes after we have defined the request_rec type }
+//#include "apr_uri.h"
+
+type
+  { Forward declarations of pointer to record types}
+  Pconn_rec = ^conn_rec;
+  Prequest_rec = ^request_rec;
+  Pserver_rec = ^server_rec;
+  PPserver_rec = ^Pserver_rec;
+  Pserver_addr_rec = ^server_addr_rec;
+  Pprocess_rec = ^process_rec;
+
+  { A structure that represents one process }
+  process_rec = record
+    { Global pool. Cleared upon normal exit }
+    pool: Papr_pool_t;
+    { Configuration pool. Cleared upon restart }
+    pconf: Papr_pool_t;
+    { Number of command line arguments passed to the program }
+    argc: Integer;
+    { The command line arguments }
+    argv: PChar;
+    { The program name used to execute the program }
+    short_name: PChar;
+  end;
+
+  { A structure that represents the current request }
+  request_rec = record
+    { The pool associated with the request }
+    pool: Papr_pool_t;
+    { The connection to the client }
+    connection: Pconn_rec;
+    { The virtual host for this request }
+    server: Pserver_rec;
+
+    { Pointer to the redirected request if this is an external redirect }
+    next: Prequest_rec;
+    { Pointer to the previous request if this is an internal redirect }
+    prev: Prequest_rec;
+
+    { Pointer to the main request if this is a sub-request
+     * (see http_request.h) }
+    main: Prequest_rec;
+
+    { Info about the request itself... we begin with stuff that only
+     * protocol.c should ever touch...
+    }
+    { First line of request }
+    the_request: PChar;
+    { HTTP/0.9, "simple" request (e.g. GET /foo\n w/no headers) }
+    assbackwards: Integer;
+    { A proxy request (calculated during post_read_request/translate_name)
+     *  possible values PROXYREQ_NONE, PROXYREQ_PROXY, PROXYREQ_REVERSE,
+     *                  PROXYREQ_RESPONSE
+     }
+    proxyreq: Integer;
+    { HEAD request, as opposed to GET }
+    header_only: Integer;
+    { Protocol string, as given to us, or HTTP/0.9 }
+    protocol: PChar;
+    { Protocol version number of protocol; 1.1 = 1001 }
+    proto_num: Integer;
+    { Host, as set by full URI or Host: }
+    hostname: PChar;
+
+    { Time when the request started }
+    request_time: apr_time_t;
+
+    { Status line, if set by script }
+    status_line: PChar;
+    { Status line }
+    status: Integer;
+
+    { Request method, two ways; also, protocol, etc..  Outside of protocol.c,
+     * look, but don't touch.
+     }
+
+    { Request method (eg. GET, HEAD, POST, etc.) }
+    method: PChar;
+    { M_GET, M_POST, etc. }
+    method_number: Integer;
+
+    {
+     *  'allowed' is a bitvector of the allowed methods.
+     *
+     *  A handler must ensure that the request method is one that
+     *  it is capable of handling.  Generally modules should DECLINE
+     *  any request methods they do not handle.  Prior to aborting the
+     *  handler like this the handler should set r->allowed to the list
+     *  of methods that it is willing to handle.  This bitvector is used
+     *  to construct the "Allow:" header required for OPTIONS requests,
+     *  and HTTP_METHOD_NOT_ALLOWED and HTTP_NOT_IMPLEMENTED status codes.
+     *
+     *  Since the default_handler deals with OPTIONS, all modules can
+     *  usually decline to deal with OPTIONS.  TRACE is always allowed,
+     *  modules don't need to set it explicitly.
+     *
+     *  Since the default_handler will always handle a GET, a
+     *  module which does *not* implement GET should probably return
+     *  HTTP_METHOD_NOT_ALLOWED.  Unfortunately this means that a Script GET
+     *  handler can't be installed by mod_actions.
+     }
+    allowed: apr_int64_t;
+    { Array of extension methods }
+    allowed_xmethods: Papr_array_header_t;
+    { List of allowed methods }
+    allowed_methods: Pap_method_list_t;
+
+    { byte count in stream is for body }
+    sent_bodyct: apr_off_t;
+    { body byte count, for easy access }
+    bytes_sent: apr_off_t;
+    { Last modified time of the requested resource }
+    mtime: apr_time_t;
+
+    { HTTP/1.1 connection-level features }
+
+    { sending chunked transfer-coding }
+    chunked: Integer;
+    { The Range: header }
+    range: PChar;
+    { The "real" content length }
+    clength: apr_off_t;
+
+    { Remaining bytes left to read from the request body }
+    remaining: apr_off_t;
+    { Number of bytes that have been read  from the request body }
+    read_length: apr_off_t;
+    { Method for reading the request body
+     * (eg. REQUEST_CHUNKED_ERROR, REQUEST_NO_BODY,
+     *  REQUEST_CHUNKED_DECHUNK, etc...) }
+    read_body: Integer;
+    { reading chunked transfer-coding }
+    read_chunked: Integer;
+    { is client waiting for a 100 response? }
+    expecting_100: Cardinal;
+
+    { MIME header environments, in and out.  Also, an array containing
+     * environment variables to be passed to subprocesses, so people can
+     * write modules to add to that environment.
+     *
+     * The difference between headers_out and err_headers_out is that the
+     * latter are printed even on error, and persist across internal redirects
+     * (so the headers printed for ErrorDocument handlers will have them).
+     *
+     * The 'notes' apr_table_t is for notes from one module to another, with no
+     * other set purpose in mind...
+     }
+
+    { MIME header environment from the request }
+    headers_in: Papr_table_t;
+    { MIME header environment for the response }
+    headers_out: Papr_table_t;
+    { MIME header environment for the response, printed even on errors and
+     * persist across internal redirects }
+    err_headers_out: Papr_table_t;
+    { Array of environment variables to be used for sub processes }
+    subprocess_env: Papr_table_t;
+    { Notes from one module to another }
+    notes: Papr_table_t;
+
+    { content_type, handler, content_encoding, and all content_languages
+     * MUST be lowercased strings.  They may be pointers to static strings;
+     * they should not be modified in place.
+     }
+    { The content-type for the current request }
+    content_type: PChar;	// Break these out --- we dispatch on 'em
+    { The handler string that we use to call a handler function }
+    handler: PChar;	// What we *really* dispatch on
+
+    { How to encode the data }
+    content_encoding: PChar;
+    { Array of strings representing the content languages }
+    content_languages: Papr_array_header_t;
+
+    { variant list validator (if negotiated) }
+    vlist_validator: PChar;
+
+    { If an authentication check was made, this gets set to the user name. }
+    user: PChar;
+    { If an authentication check was made, this gets set to the auth type. }
+    ap_auth_type: PChar;
+
+    { This response can not be cached }
+    no_cache: Integer;
+    { There is no local copy of this response }
+    no_local_copy: Integer;
+
+    { What object is being requested (either directly, or via include
+     * or content-negotiation mapping).
+     }
+
+    { The URI without any parsing performed }
+    unparsed_uri: PChar;
+    { The path portion of the URI }
+    uri: PChar;
+    { The filename on disk corresponding to this response }
+    filename: PChar;
+    { XXX: What does this mean? Please define "canonicalize" -aaron }
+    { The true filename, we canonicalize r->filename if these don't match }
+    canonical_filename: PChar;
+    { The PATH_INFO extracted from this request }
+    path_info: PChar;
+    { The QUERY_ARGS extracted from this request }
+    args: PChar;
+    {  finfo.protection (st_mode) set to zero if no such file }
+    finfo: apr_finfo_t;
+    { A struct containing the components of URI }
+    parsed_uri: apr_uri_t;
+
+    {
+     * Flag for the handler to accept or reject path_info on
+     * the current request.  All modules should respect the
+     * AP_REQ_ACCEPT_PATH_INFO and AP_REQ_REJECT_PATH_INFO
+     * values, while AP_REQ_DEFAULT_PATH_INFO indicates they
+     * may follow existing conventions.  This is set to the
+     * user's preference upon HOOK_VERY_FIRST of the fixups.
+     }
+    used_path_info: Integer;
+
+    { Various other config info which may change with .htaccess files
+     * These are config vectors, with one void* pointer for each module
+     * (the thing pointed to being the module's business).
+     }
+
+    { Options set in config files, etc.}
+    per_dir_config: Pap_conf_vector_t;
+    { Notes on *this* request }
+    request_config: Pap_conf_vector_t;
+
+    {
+     * A linked list of the .htaccess configuration directives
+     * accessed by this request.
+     * N.B. always add to the head of the list, _never_ to the end.
+     * that way, a sub request's list can (temporarily) point to a parent's list
+     }
+    htaccess: Phtaccess_result;
+
+    { A list of output filters to be used for this request }
+    output_filters: Pap_filter_t;
+    { A list of input filters to be used for this request }
+    input_filters: Pap_filter_t;
+
+    { A list of protocol level output filters to be used for this
+     *  request }
+    proto_output_filters: Pap_filter_t;
+    { A list of protocol level input filters to be used for this
+     *  request }
+    proto_input_filters: Pap_filter_t;
+
+    { A flag to determine if the eos bucket has been sent yet }
+    eos_sent: Integer;
+
+{ Things placed at the end of the record to avoid breaking binary
+ * compatibility.  It would be nice to remember to reorder the entire
+ * record to improve 64bit alignment the next time we need to break
+ * binary compatibility for some other reason.
+}
+  end;
+
+{
+ * @defgroup ProxyReq Proxy request types
+ *
+ * Possible values of request_rec->proxyreq. A request could be normal,
+ *  proxied or reverse proxied. Normally proxied and reverse proxied are
+ *  grouped together as just "proxied", but sometimes it's necessary to
+ *  tell the difference between the two, such as for authentication.
+}
+
+  ap_conn_keepalive_e = (AP_CONN_UNKNOWN, AP_CONN_CLOSE, AP_CONN_KEEPALIVE);
+
+{ Structure to store things which are per connection }
+  conn_rec = record
+    { Pool associated with this connection }
+    pool: Papr_pool_t;
+    { Physical vhost this conn came in on }
+    base_server: Pserver_rec;
+    { used by http_vhost.c }
+    vhost_lookup_data: Pointer;
+
+    { Information about the connection itself }
+    { local address }
+    local_addr: Papr_sockaddr_t;
+    { remote address }
+    remote_addr: Papr_sockaddr_t;
+
+    { Client's IP address }
+    remote_ip: PChar;
+    { Client's DNS name, if known.  NULL if DNS hasn't been checked,
+     *  "" if it has and no address was found.  N.B. Only access this though
+     * get_remote_host() }
+    remote_host: PChar;
+    { Only ever set if doing rfc1413 lookups.  N.B. Only access this through
+     *  get_remote_logname() }
+    remote_logname: PChar;
+
+    { Are we still talking? }
+    flags: Cardinal;
+
+    (* Useless bitset variables to make the code obscure
+    
+     Are we still talking?
+    unsigned aborted:1;
+
+     Are we going to keep the connection alive for another request?
+     * @see ap_conn_keepalive_e
+    signed int keepalive:2;
+
+     have we done double-reverse DNS? -1 yes/failure, 0 not yet,
+     *  1 yes/success
+    signed int double_reverse:2;
+    *)
+
+    { How many times have we used it? }
+    keepalives: Integer;
+    { server IP address }
+    local_ip: PChar;
+    { used for ap_get_server_name when UseCanonicalName is set to DNS
+     *  (ignores setting of HostnameLookups) }
+    local_host: PChar;
+
+    { ID of this connection; unique at any point in time }
+    id: Integer; // long
+    { Config vector containing pointers to connections per-server
+     *  config structures. }
+    conn_config: Pap_conf_vector_t;
+    { Notes on *this* connection: send note from one module to
+     *  another. must remain valid for all requests on this conn }
+    notes: Papr_table_t;
+    { A list of input filters to be used for this connection }
+    input_filters: Pap_filter_t;
+    { A list of output filters to be used for this connection }
+    output_filters: Pap_filter_t;
+    { handle to scoreboard information for this connection }
+    sbh: Pointer;
+    { The bucket allocator to use for all bucket/brigade creations }
+    bucket_alloc: Papr_bucket_alloc_t;
+  end;
+
+
+{ Per-vhost config... }
+
+{ A structure to be used for Per-vhost config }
+  server_addr_rec = record
+    { The next server in the list }
+    next: Pserver_addr_rec;
+    { The bound address, for this server }
+    host_addr: Papr_sockaddr_t;
+    { The bound port, for this server }
+    host_port: apr_port_t;
+    { The name given in <VirtualHost> }
+    virthost: PChar;
+  end;
+
+  { A structure to store information for each virtual server }
+  server_rec = record
+    { The process this server is running in }
+    process: Pprocess_rec;
+    { The next server in the list }
+    next: Pserver_rec;
+
+    { The name of the server }
+    defn_name: PChar;
+    { The line of the config file that the server was defined on }
+    defn_line_number: Integer;
+
+    { Contact information }
+
+    { The admin's contact information }
+    server_admin: PChar;
+    { The server hostname }
+    server_hostname: PChar;
+    { for redirects, etc. }
+    port: apr_port_t;
+
+    { Log files --- note that transfer log is now in the modules... }
+
+    { The name of the error log }
+    error_fname: PChar;
+    { A file descriptor that references the error log }
+    error_log: Papr_file_t;
+    { The log level for this server }
+    loglevel: Integer;
+
+    { Module-specific configuration for server, and defaults... }
+
+    { true if this is the virtual server }
+    is_virtual: Integer;
+    { Config vector containing pointers to modules' per-server config
+     *  structures. }
+    module_config: Pap_conf_vector_t;
+    { MIME type info, etc., before we start checking per-directory info }
+    lookup_defaults: Pap_conf_vector_t;
+
+    { Transaction handling }
+
+    { I haven't got a clue }
+    addrs: Pserver_addr_rec;
+    { Timeout, as an apr interval, before we give up }
+    timeout: apr_interval_time_t;
+    { The apr interval we will wait for another request }
+    keep_alive_timeout: apr_interval_time_t;
+    { Maximum requests per connection }
+    keep_alive_max: Integer;
+    { Use persistent connections? }
+    keep_alive: Integer;
+
+    { Pathname for ServerPath }
+    path: PChar;
+    { Length of path }
+    pathlen: Integer;
+
+    { Normal names for ServerAlias servers }
+    names: Papr_array_header_t;
+    { Wildcarded names for ServerAlias servers }
+    wild_names: Papr_array_header_t;
+
+    { limit on size of the HTTP request line    }
+    limit_req_line: Integer;
+    { limit on size of any request header field }
+    limit_req_fieldsize: Integer;
+    { limit on number of request header fields  }
+    limit_req_fields: Integer;
+  end;
+
+type
+  core_output_filter_ctx = record
+    b: Papr_bucket_brigade;
+    deferred_write_pool: Papr_pool_t; { subpool of c->pool used for resources
+                                      * which may outlive the request         }
+  end;
+
+  core_filter_ctx = record
+    b: Papr_bucket_brigade;
+    tmpbb: Papr_bucket_brigade;
+  end; // core_ctx_t
+  
+  core_ctx_t = core_filter_ctx;
+
+  Pcore_ctx_t = ^core_ctx_t;
+
+type
+  core_net_rec = record
+    { Connection to the client }
+    client_socket: Papr_socket_t;
+
+    { connection record }
+    c: Pconn_rec;
+
+    out_ctx: Pcore_output_filter_ctx_t;
+    in_ctx: Pcore_ctx_t;
+  end; // core_net_rec;
+
+  Pcore_net_rec = ^core_net_rec;
+
+{
+  The constants are on the bottom because the structures need to be on the same type block
+}
+const
+  PROXYREQ_NONE = 0;		{< No proxy }
+  PROXYREQ_PROXY = 1;	{< Standard proxy }
+  PROXYREQ_REVERSE = 2;	{< Reverse proxy }
+  PROXYREQ_RESPONSE = 3; {< Origin response }
+
+{
+ * The address 255.255.255.255, when used as a virtualhost address,
+ * will become the "default" server when the ip doesn't match other vhosts.
+}
+const DEFAULT_VHOST_ADDR = $ffffffff;//ul
+
+{
+ * Examine a field value (such as a media-/content-type) string and return
+ * it sans any parameters; e.g., strip off any ';charset=foo' and the like.
+ * @param p Pool to allocate memory from
+ * @param intype The field to examine
+ * @return A copy of the field minus any parameters
+}
+function ap_field_noparam(p: Papr_pool_t; const intype: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_field_noparam' + LibSuff8;
+
+{
+ * Convert a time from an integer into a string in a specified format
+ * @param p The pool to allocate memory from
+ * @param t The time to convert
+ * @param fmt The format to use for the conversion
+ * @param gmt Convert the time for GMT?
+ * @return The string that represents the specified time
+}
+function ap_ht_time(p: Papr_pool_t; t: apr_time_t; const fmt: PChar; gmt: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_ht_time' + LibSuff20;
+
+{ String handling. The *_nc variants allow you to use non-const char **s as
+   arguments (unfortunately C won't automatically convert a char ** to a const
+   char **) }
+
+{
+ * Get the characters until the first occurance of a specified character
+ * @param p The pool to allocate memory from
+ * @param line The string to get the characters from
+ * @param stop The character to stop at
+ * @return A copy of the characters up to the first stop character
+}
+function ap_getword(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_getword' + LibSuff12;
+
+{
+ * Get the characters until the first occurance of a specified character
+ * @param p The pool to allocate memory from
+ * @param line The string to get the characters from
+ * @param stop The character to stop at
+ * @return A copy of the characters up to the first stop character
+ * @note This is the same as ap_getword(), except it doesn't use const char **.
+}
+function ap_getword_nc(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_getword_nc' + LibSuff12;
+
+{
+ * Get the first word from a given string.  A word is defined as all characters
+ * up to the first whitespace.
+ * @param p The pool to allocate memory from
+ * @param line The string to traverse
+ * @return The first word in the line
+}
+function ap_getword_white(p: Papr_pool_t; const line: PPChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_getword_white' + LibSuff8;
+
+{
+ * Get the first word from a given string.  A word is defined as all characters
+ * up to the first whitespace.
+ * @param p The pool to allocate memory from
+ * @param line The string to traverse
+ * @return The first word in the line
+ * @note The same as ap_getword_white(), except it doesn't use const char **.
+}
+function ap_getword_white_nc(p: Papr_pool_t; const line: PPChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_getword_white_nc' + LibSuff8;
+
+{
+ * Get all characters from the first occurance of @a stop to the first '\0'
+ * @param p The pool to allocate memory from
+ * @param line The line to traverse
+ * @param stop The character to start at
+ * @return A copy of all caracters after the first occurance of the specified
+ *         character
+}
+function ap_getword_nulls(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_getword_nulls' + LibSuff12;
+
+{
+ * Get all characters from the first occurance of @a stop to the first '\0'
+ * @param p The pool to allocate memory from
+ * @param line The line to traverse
+ * @param stop The character to start at
+ * @return A copy of all caracters after the first occurance of the specified
+ *         character
+ * @note The same as ap_getword_nulls(), except it doesn't use const char **.
+}
+function ap_getword_nulls_nc(p: Papr_pool_t; const line: PPChar; stop: Char): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_getword_nulls_nc' + LibSuff12;
+
+{
+ * Get the second word in the string paying attention to quoting
+ * @param p The pool to allocate from
+ * @param line The line to traverse
+ * @return A copy of the string
+}
+function ap_getword_conf(p: Papr_pool_t; const line: PPChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_getword_conf' + LibSuff8;
+
+{
+ * Get the second word in the string paying attention to quoting
+ * @param p The pool to allocate from
+ * @param line The line to traverse
+ * @return A copy of the string
+ * @note The same as ap_getword_conf(), except it doesn't use const char **.
+}
+function ap_getword_conf_nc(p: Papr_pool_t; const line: PPChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_getword_conf_nc' + LibSuff8;
+
+{
+ * Check a string for any $ENV environment variable construct and replace
+ * each them by the value of that environment variable, if it exists. If the
+ * environment value does not exist, leave the $ENV construct alone; it
+ * means something else.
+ * @param p The pool to allocate from
+ * @param word The string to check
+ * @return The string with the replaced environment variables
+}
+function ap_resolve_env(p: Papr_pool_t; const word_: PChar; accept_white: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_resolve_env' + LibSuff8;
+
+{
+ * Size an HTTP header field list item, as separated by a comma.
+ * @param field The field to size
+ * @param len The length of the field
+ * @return The return value is a pointer to the beginning of the non-empty
+ * list item within the original string (or NULL if there is none) and the
+ * address of field is shifted to the next non-comma, non-whitespace
+ * character.  len is the length of the item excluding any beginning whitespace.
+}
+function ap_size_list_item(const field: PPChar; len: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_size_list_item' + LibSuff8;
+
+{
+ * Retrieve an HTTP header field list item, as separated by a comma,
+ * while stripping insignificant whitespace and lowercasing anything not in
+ * a quoted string or comment.
+ * @param p The pool to allocate from
+ * @param field The field to retrieve
+ * @return The return value is a new string containing the converted list
+ *         item (or NULL if none) and the address pointed to by field is
+ *         shifted to the next non-comma, non-whitespace.
+}
+function ap_get_list_item(p: Papr_pool_t; const field: PPChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_list_item' + LibSuff8;
+
+{
+ * Find an item in canonical form (lowercase, no extra spaces) within
+ * an HTTP field value list.
+ * @param p The pool to allocate from
+ * @param line The field value list to search
+ * @param tok The token to search for
+ * @return 1 if found, 0 if not found.
+}
+function ap_find_list_item(p: Papr_pool_t; const line, tok: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_find_list_item' + LibSuff12;
+
+{
+ * Retrieve a token, spacing over it and returning a pointer to
+ * the first non-white byte afterwards.  Note that these tokens
+ * are delimited by semis and commas and can also be delimited
+ * by whitespace at the caller's option.
+ * @param p The pool to allocate from
+ * @param accept_line The line to retrieve the token from
+ * @param accept_white Is it delimited by whitespace
+ * @return the first non-white byte after the token
+}
+function ap_get_token(p: Papr_pool_t; const accept_line: PPChar; accept_white: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_token' + LibSuff12;
+
+{
+ * Find http tokens, see the definition of token from RFC2068
+ * @param p The pool to allocate from
+ * @param line The line to find the token
+ * @param tok The token to find
+ * @return 1 if the token is found, 0 otherwise
+}
+function ap_find_token(p: Papr_pool_t; const line, tok: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_find_token' + LibSuff12;
+
+{
+ * find http tokens from the end of the line
+ * @param p The pool to allocate from
+ * @param line The line to find the token
+ * @param tok The token to find
+ * @return 1 if the token is found, 0 otherwise
+}
+function ap_find_last_token(p: Papr_pool_t; const line, tok: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_find_last_token' + LibSuff12;
+
+{
+ * Check for an Absolute URI syntax
+ * @param u The string to check
+ * @return 1 if URI, 0 otherwise
+}
+function ap_is_url(const u: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_is_url' + LibSuff4;
+
+{
+ * Unescape a URL
+ * @param url The url to unescape
+ * @return 0 on success, non-zero otherwise
+}
+function ap_unescape_url(url: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_unescape_url' + LibSuff4;
+
+{
+ * Unescape a URL, but leaving %2f (slashes) escaped
+ * @param url The url to unescape
+ * @return 0 on success, non-zero otherwise
+}
+function ap_unescape_url_keep2f(url: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_unescape_url_keep2f' + LibSuff4;
+
+{
+ * Convert all double slashes to single slashes
+ * @param name The string to convert
+}
+procedure ap_no2slash(name: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_no2slash' + LibSuff4;
+
+{
+ * Remove all ./ and xx/../ substrings from a file name. Also remove
+ * any leading ../ or /../ substrings.
+ * @param name the file name to parse
+}
+procedure ap_getparents(name: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_getparents' + LibSuff4;
+
+{
+ * Escape a path segment, as defined in RFC 1808
+ * @param p The pool to allocate from
+ * @param s The path to convert
+ * @return The converted URL
+}
+function ap_escape_path_segment(p: Papr_pool_t; const s: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_escape_path_segment' + LibSuff8;
+
+{
+ * convert an OS path to a URL in an OS dependant way.
+ * @param p The pool to allocate from
+ * @param path The path to convert
+ * @param partial if set, assume that the path will be appended to something
+ *        with a '/' in it (and thus does not prefix "./")
+ * @return The converted URL
+}
+function ap_os_escape_path(p: Papr_pool_t; const path: PChar; partial: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_os_escape_path' + LibSuff12;
+
+{ @see ap_os_escape_path }
+function ap_escape_uri(p: Papr_pool_t; const path: PChar): PChar;
+
+{
+ * Escape an html string
+ * @param p The pool to allocate from
+ * @param s The html to escape
+ * @return The escaped string
+ }
+function ap_escape_html(p: Papr_pool_t; const s: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_escape_html' + LibSuff8;
+
+{
+ * Escape a string for logging
+ * @param p The pool to allocate from
+ * @param str The string to escape
+ * @return The escaped string
+ }
+function ap_escape_logitem(p: Papr_pool_t; const str: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_escape_logitem' + LibSuff8;
+
+{
+ * Escape a string for logging into the error log (without a pool)
+ * @param dest The buffer to write to
+ * @param source The string to escape
+ * @param buflen The buffer size for the escaped string (including \0)
+ * @return The len of the escaped string (always < maxlen)
+ }
+function ap_escape_errorlog_item(dest, source: PChar;
+ buflen: apr_size_t): apr_size_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_escape_errorlog_item' + LibSuff12;
+
+{
+ * Construct a full hostname
+ * @param p The pool to allocate from
+ * @param hostname The hostname of the server
+ * @param port The port the server is running on
+ * @param r The current request
+ * @return The server's hostname
+ }
+function ap_construct_server(p: Papr_pool_t; const hostname: PChar;
+ port: Papr_port_t; const r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_construct_server' + LibSuff16;
+
+{
+ * Escape a shell command
+ * @param p The pool to allocate from
+ * @param s The command to escape
+ * @return The escaped shell command
+ }
+function ap_escape_shell_cmd(p: Papr_pool_t; const s: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_escape_shell_cmd' + LibSuff8;
+
+{
+ * Count the number of directories in a path
+ * @param path The path to count
+ * @return The number of directories
+ }
+function ap_count_dirs(const path: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_count_dirs' + LibSuff4;
+
+{
+ * Copy at most @a n leading directories of @a s into @a d. @a d
+ * should be at least as large as @a s plus 1 extra byte
+ *
+ * @param d The location to copy to
+ * @param s The location to copy from
+ * @param n The number of directories to copy
+ * @return value is the ever useful pointer to the trailing \0 of d
+ * @note on platforms with drive letters, n = 0 returns the "/" root,
+ * whereas n = 1 returns the "d:/" root.  On all other platforms, n = 0
+ * returns the empty string.  }
+function ap_make_dirstr_prefix(const d, s: PChar; n: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_make_dirstr_prefix' + LibSuff12;
+
+{
+ * Return the parent directory name (including trailing /) of the file
+ * @a s
+ * @param p The pool to allocate from
+ * @param s The file to get the parent of
+ * @return A copy of the file's parent directory
+ }
+function ap_make_dirstr_parent(p: Papr_pool_t; const s: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_make_dirstr_parent' + LibSuff8;
+
+{
+ * Given a directory and filename, create a single path from them.  This
+ * function is smart enough to ensure that there is a sinlge '/' between the
+ * directory and file names
+ * @param a The pool to allocate from
+ * @param dir The directory name
+ * @param f The filename
+ * @return A copy of the full path
+ * @tip Never consider using this function if you are dealing with filesystem
+ * names that need to remain canonical, unless you are merging an apr_dir_read
+ * path and returned filename.  Otherwise, the result is not canonical.
+ }
+function ap_make_full_path(a: Papr_pool_t; const dir, f: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_make_full_path' + LibSuff12;
+
+{
+ * Test if the given path has an an absolute path.
+ * @param p The pool to allocate from
+ * @param dir The directory name
+ * @tip The converse is not necessarily true, some OS's (Win32/OS2/Netware) have
+ * multiple forms of absolute paths.  This only reports if the path is absolute
+ * in a canonical sense.
+ }
+function ap_os_is_path_absolute(p: Papr_pool_t; const dir: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_os_is_path_absolute' + LibSuff8;
+
+{
+ * Does the provided string contain wildcard characters?  This is useful
+ * for determining if the string should be passed to strcmp_match or to strcmp.
+ * The only wildcard characters recognized are '?' and '*'
+ * @param str The string to check
+ * @return 1 if the string has wildcards, 0 otherwise
+ }
+function ap_is_matchexp(const str: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_is_matchexp' + LibSuff4;
+
+{
+ * Determine if a string matches a patterm containing the wildcards '?' or '*'
+ * @param str The string to check
+ * @param expected The pattern to match against
+ * @return 1 if the two strings match, 0 otherwise
+ }
+function ap_strcmp_match(const str, expected: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_strcmp_match' + LibSuff8;
+
+{
+ * Determine if a string matches a patterm containing the wildcards '?' or '*',
+ * ignoring case
+ * @param str The string to check
+ * @param expected The pattern to match against
+ * @return 1 if the two strings match, 0 otherwise
+ }
+function ap_strcasecmp_match(const str, expected: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_strcasecmp_match' + LibSuff8;
+
+{
+ * Find the first occurrence of the substring s2 in s1, regardless of case
+ * @param s1 The string to search
+ * @param s2 The substring to search for
+ * @return A pointer to the beginning of the substring
+ * @remark See apr_strmatch() for a faster alternative
+ }
+function ap_strcasestr(const s1, s2: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_strcasestr' + LibSuff8;
+
+{
+ * Return a pointer to the location inside of bigstring immediately after prefix
+ * @param bigstring The input string
+ * @param prefix The prefix to strip away
+ * @return A pointer relative to bigstring after prefix
+ }
+function ap_stripprefix(const bigstring, prefix: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_stripprefix' + LibSuff8;
+
+{
+ * Decode a base64 encoded string into memory allocated from a pool
+ * @param p The pool to allocate from
+ * @param bufcoded The encoded string
+ * @return The decoded string
+ }
+function ap_pbase64decode(p: Papr_pool_t; const bufcoded: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_pbase64decode' + LibSuff8;
+
+{
+ * Encode a string into memory allocated from a pool in base 64 format
+ * @param p The pool to allocate from
+ * @param strin The plaintext string
+ * @return The encoded string
+ }
+function ap_pbase64encode(p: Papr_pool_t; string_: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_pbase64encode' + LibSuff8;
+
+{
+ * Compile a regular expression to be used later
+ * @param p The pool to allocate from
+ * @param pattern the regular expression to compile
+ * @param cflags The bitwise or of one or more of the following:
+ *   @li #REG_EXTENDED - Use POSIX extended Regular Expressions
+ *   @li #REG_ICASE    - Ignore case
+ *   @li #REG_NOSUB    - Support for substring addressing of matches
+ *       not required
+ *   @li #REG_NEWLINE  - Match-any-character operators don't match new-line
+ * @return The compiled regular expression
+ }
+function ap_pregcomp(p: Papr_pool_t; const pattern: PChar; cflags: Integer): Pregex_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_pregcomp' + LibSuff12;
+
+{
+ * Free the memory associated with a compiled regular expression
+ * @param p The pool the regex was allocated from
+ * @param reg The regular expression to free
+ }
+procedure ap_pregfree(p: Papr_pool_t; reg: Pregex_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_pregfree' + LibSuff8;
+
+{
+ * Match a null-terminated string against a pre-compiled regex.
+ * @param preg The pre-compiled regex
+ * @param string The string to match
+ * @param nmatch Provide information regarding the location of any matches
+ * @param pmatch Provide information regarding the location of any matches
+ * @param eflags Bitwise or of any of:
+ *   @li #REG_NOTBOL - match-beginning-of-line operator always
+ *     fails to match
+ *   @li #REG_NOTEOL - match-end-of-line operator always fails to match
+ * @return 0 for successful match, #REG_NOMATCH otherwise
+ }
+function ap_regexec(preg: Pregex_t; const string_: PChar;
+ nmatch: size_t; pmatch: array of regmatch_t; eflags: Integer): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_regexec' + LibSuff20;
+
+{
+ * Return the error code returned by regcomp or regexec into error messages
+ * @param errcode the error code returned by regexec or regcomp
+ * @param preg The precompiled regex
+ * @param errbuf A buffer to store the error in
+ * @param errbuf_size The size of the buffer
+}
+function ap_regerror(errcode: Integer; preg: Pregex_t;
+ errbuf: PChar; errbuf_size: size_t): size_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_regerror' + LibSuff16;
+
+{
+ * After performing a successful regex match, you may use this function to
+ * perform a series of string substitutions based on subexpressions that were
+ * matched during the call to ap_regexec
+ * @param p The pool to allocate from
+ * @param input An arbitrary string containing $1 through $9.  These are
+ *              replaced with the corresponding matched sub-expressions
+ * @param source The string that was originally matched to the regex
+ * @param nmatch the nmatch returned from ap_pregex
+ * @param pmatch the pmatch array returned from ap_pregex
+}
+function ap_pregsub(p: Papr_pool_t; const input, source: PChar;
+ nmatch: size_t; pmatch: array of regmatch_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_pregsub' + LibSuff20;
+
+{
+ * We want to downcase the type/subtype for comparison purposes
+ * but nothing else because ;parameter=foo values are case sensitive.
+ * @param s The content-type to convert to lowercase
+}
+procedure ap_content_type_tolower(s: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_content_type_tolower' + LibSuff4;
+
+{
+ * convert a string to all lowercase
+ * @param s The string to convert to lowercase
+}
+procedure ap_str_tolower(s: PChar);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_str_tolower' + LibSuff4;
+
+{
+ * Search a string from left to right for the first occurrence of a
+ * specific character
+ * @param str The string to search
+ * @param c The character to search for
+ * @return The index of the first occurrence of c in str
+}
+function ap_ind(str: PChar; c: Char): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_ind' + LibSuff8;
+
+{
+ * Search a string from right to left for the first occurrence of a
+ * specific character
+ * @param str The string to search
+ * @param c The character to search for
+ * @return The index of the first occurrence of c in str
+}
+function ap_rind(str: PChar; c: Char): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_rind' + LibSuff8;
+
+{
+ * Given a string, replace any bare " with \" .
+ * @param p The pool to allocate memory from
+ * @param instring The string to search for "
+ * @return A copy of the string with escaped quotes
+}
+function ap_escape_quotes(p: Papr_pool_t; const instring: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_escape_quotes' + LibSuff8;
+
+{ Misc system hackery }
+{
+ * Given the name of an object in the file system determine if it is a directory
+ * @param p The pool to allocate from
+ * @param name The name of the object to check
+ * @return 1 if it is a directory, 0 otherwise
+}
+function ap_is_rdirectory(p: Papr_pool_t; const name: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_is_rdirectory' + LibSuff8;
+
+{
+ * Given the name of an object in the file system determine if it is a directory - this version is symlink aware
+ * @param p The pool to allocate from
+ * @param name The name of the object to check
+ * @return 1 if it is a directory, 0 otherwise
+}
+function ap_is_directory(p: Papr_pool_t; const name: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_is_directory' + LibSuff8;
+
+{#ifdef _OSD_POSIX
+extern const char *os_set_account(apr_pool_t *p, const char *account);
+extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
+#endif} { _OSD_POSIX }
+
+{
+ * Determine the local host name for the current machine
+ * @param p The pool to allocate from
+ * @return A copy of the local host name
+}
+//char *ap_get_local_host(apr_pool_t *p);
+
+{
+ * Log an assertion to the error log
+ * @param szExp The assertion that failed
+ * @param szFile The file the assertion is in
+ * @param nLine The line the assertion is defined on
+}
+procedure ap_log_assert(szExp, szFile: PChar; nLine: Integer);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_log_assert' + LibSuff12;
+
+{ @internal }
+//#define ap_assert(exp) ((exp) ? (void)0 : ap_log_assert(#exp,__FILE__,__LINE__))
+
+{
+ * Redefine assert() to something more useful for an Apache...
+ *
+ * Use ap_assert() if the condition should always be checked.
+ * Use AP_DEBUG_ASSERT() if the condition should only be checked when AP_DEBUG
+ * is defined.
+}
+
+{#ifdef AP_DEBUG
+#define AP_DEBUG_ASSERT(exp) ap_assert(exp)
+#else
+#define AP_DEBUG_ASSERT(exp) ((void)0)
+#endif}
+
+{
+ * @defgroup stopsignal flags which indicate places where the sever should stop for debugging.
+ * @
+ * A set of flags which indicate places where the server should raise(SIGSTOP).
+ * This is useful for debugging, because you can then attach to that process
+ * with gdb and continue.  This is important in cases where one_process
+ * debugging isn't possible.
+}
+{ stop on a Detach }
+//  SIGSTOP_DETACH = 1;
+{ stop making a child process }
+//  SIGSTOP_MAKE_CHILD = 2;
+{ stop spawning a child process }
+//  SIGSTOP_SPAWN_CHILD = 4;
+{ stop spawning a child process with a piped log }
+//  SIGSTOP_PIPED_LOG_SPAWN = 8;
+{ stop spawning a CGI child process }
+//  SIGSTOP_CGI_CHILD = 16;
+
+{ Macro to get GDB started }
+{#ifdef DEBUG_SIGSTOP
+extern int raise_sigstop_flags;
+#define RAISE_SIGSTOP(x)	do begin
+	if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
+    end while (0)
+#else
+#define RAISE_SIGSTOP(x)
+#endif }
+
+{
+ * Get HTML describing the address and (optionally) admin of the server.
+ * @param prefix Text which is prepended to the return value
+ * @param r The request_rec
+ * @return HTML describing the server, allocated in @a r's pool.
+ }
+function ap_psignature(prefix: PChar; r: Prequest_rec): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_psignature' + LibSuff8;
+
+{const
+  AP_NORESTART = APR_OS_START_USEERR + 1;}
+

+ 170 - 0
packages/base/httpd/httpd-2.0/httpd.pas

@@ -0,0 +1,170 @@
+{
+ httpd.pas
+
+ Copyright (C) 2006 Felipe Monteiro de Carvalho
+
+ This unit is a pascal binding for the Apache 2.0.58 headers.
+ The headers were released under the following copyright:
+}
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+}
+unit httpd;
+
+{$ifdef fpc}
+  {$mode delphi}{$H+}
+{$endif}
+
+{$IFNDEF FPC}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$IFDEF WIN32}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$ifdef Unix}
+  {$PACKRECORDS C}
+{$endif}
+
+{$define Apache2_0}
+
+interface
+
+uses
+{$ifdef WINDOWS}
+  Windows,
+{$ELSE}
+  UnixType,
+{$ENDIF}
+  apr, aprutil, ctypes;
+
+const
+{$ifndef fpc}
+  LineEnding = #13#10;
+{$endif}
+
+{$IFDEF WINDOWS}
+  LibHTTPD = 'libhttpd.dll';
+{$ELSE}
+  LibHTTPD = '';
+{$ENDIF}
+
+{ Declarations moved here to be on top of all declarations }
+
+{ configuration vector structure }
+type
+  ap_conf_vector_t = record end;
+  Pap_conf_vector_t = ^ap_conf_vector_t;
+  PPap_conf_vector_t = ^Pap_conf_vector_t;
+
+{
+  Main httpd header files
+  
+  Note: There are more include files other then these, because some include files
+ include more files.
+}
+
+{$include ap_provider.inc}
+{$include util_cfgtree.inc}
+
+{$include httpd.inc}
+{$include http_config.inc}
+{$include http_core.inc}
+{$include http_log.inc}
+{$include http_main.inc}
+{$include http_protocol.inc}
+{$include http_request.inc}
+{$include http_connection.inc}
+{$include http_vhost.inc}
+
+{$include util_script.inc}
+{$include util_time.inc}
+{$include util_md5.inc}
+{$include ap_mpm.inc}
+
+implementation
+
+{
+  Macros transformed into functions in the translation
+}
+
+{ from httpd.inc }
+
+{ Internal representation for a HTTP protocol number, e.g., HTTP/1.1 }
+function HTTP_VERSION(major, minor: Integer): Integer;
+begin
+  Result := (1000*(major)+(minor));
+end;
+
+{ Major part of HTTP protocol }
+function HTTP_VERSION_MAJOR(number: Integer): Integer;
+begin
+  Result := number div 1000;
+end;
+
+{ Minor part of HTTP protocol }
+function HTTP_VERSION_MINOR(number: Integer): Integer;
+begin
+  Result := number mod 1000;
+end;
+
+function ap_escape_uri(p: Papr_pool_t; const path: PChar): PChar;
+begin
+  Result := ap_os_escape_path(p, path, 1);
+end;
+
+{ from http_config.inc }
+
+{ Use this in all standard modules }
+procedure STANDARD20_MODULE_STUFF(var mod_: module);
+begin
+  mod_.version := MODULE_MAGIC_NUMBER_MAJOR;
+  mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR;
+  mod_.module_index := -1;
+//  mod_.name: PChar;
+  mod_.dynamic_load_handle := nil;
+  mod_.next := nil;
+  mod_.magic := MODULE_MAGIC_COOKIE;
+  mod_.rewrite_args := nil;
+end;
+
+{ Use this only in MPMs }
+procedure MPM20_MODULE_STUFF(var mod_: module);
+begin
+  mod_.version := MODULE_MAGIC_NUMBER_MAJOR;
+  mod_.minor_version := MODULE_MAGIC_NUMBER_MINOR;
+  mod_.module_index := -1;
+//  mod_.name: PChar;
+  mod_.dynamic_load_handle := nil;
+  mod_.next := nil;
+  mod_.magic := MODULE_MAGIC_COOKIE;
+end;
+
+function ap_get_module_config(v: Pap_conf_vector_t; m: Pmodule): Pap_conf_vector_t;
+begin
+  Result := Pointer(Integer(v) + m^.module_index);
+end;
+
+procedure ap_set_module_config(v: Pap_conf_vector_t; m: Pmodule; val: Pap_conf_vector_t);
+var
+  P: PPointer;
+begin
+  P := PPointer(Integer(v) + m^.module_index);
+  P^ := val;
+end;
+
+end.
+

+ 85 - 0
packages/base/httpd/httpd-2.0/pcreposix.inc

@@ -0,0 +1,85 @@
+{*************************************************
+*       Perl-Compatible Regular Expressions      *
+*************************************************}
+
+{ Copyright (c) 1997-2000 University of Cambridge }
+
+{
+ * @file include/pcreposix.h
+ * @brief PCRE definitions
+ }
+
+{ This is the header for the POSIX wrapper interface to the PCRE Perl-
+Compatible Regular Expression library. It defines the things POSIX says should
+be there. I hope. }
+
+{ Have to include stdlib.h in order to ensure that size_t is defined. }
+
+{ Options defined by POSIX. }
+
+const
+  { Ignore case }
+  REG_ICASE    = $01;
+  { Don't match newlines with wildcards }
+  REG_NEWLINE  = $02;
+  { Don't match BOL }
+  REG_NOTBOL   = $04;
+  { Don't match EOL }
+  REG_NOTEOL   = $08;
+
+{ These are not used by PCRE, but by defining them we make it easier
+to slot PCRE into existing programs that make POSIX calls. }
+
+  { UNUSED! }
+  REG_EXTENDED = 0;
+  { UNUSED! }
+  REG_NOSUB    = 0;
+
+{ Error values. Not all these are relevant or used by the wrapper. }
+
+type
+ pc_error = (
+  REG_ASSERT = 1,  { internal error ? }
+  REG_BADBR,       { invalid repeat counts in } {}
+  REG_BADPAT,      { pattern error }
+  REG_BADRPT,      { ? * + invalid }
+  REG_EBRACE,      { unbalanced } {}
+  REG_EBRACK,      { unbalanced [] }
+  REG_ECOLLATE,    { collation error - not relevant }
+  REG_ECTYPE,      { bad class }
+  REG_EESCAPE,     { bad escape sequence }
+  REG_EMPTY,       { empty expression }
+  REG_EPAREN,      { unbalanced () }
+  REG_ERANGE,      { bad range inside [] }
+  REG_ESIZE,       { expression too big }
+  REG_ESPACE,      { failed to get memory }
+  REG_ESUBREG,     { bad back reference }
+  REG_INVARG,      { bad argument }
+  REG_NOMATCH      { match failed }
+ );
+
+
+{ The structure representing a compiled regular expression. }
+
+  regex_t = record
+    re_pcre: Pointer;
+    re_nsub, re_erroffset: size_t;
+  end;
+  
+  Pregex_t = ^regex_t;
+
+{ The structure in which a captured offset is returned. }
+
+  regoff_t = Integer;
+
+  regmatch_t = record
+    rm_so, rm_eo: regoff_t;
+  end;
+
+{ The functions }
+
+{extern int regcomp(regex_t *, const char *, int);
+extern int regexec(regex_t *, const char *, size_t, regmatch_t *, int);
+extern size_t regerror(int, const regex_t *, char *, size_t);
+extern void regfree(regex_t *);}
+

+ 77 - 0
packages/base/httpd/httpd-2.0/util_cfgtree.inc

@@ -0,0 +1,77 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+//#include "ap_config.h"
+
+{
+ * @package Config Tree Package
+ }
+
+type
+  Pap_directive_t = ^ap_directive_t;
+  PPap_directive_t = ^Pap_directive_t;
+
+{
+ * Structure used to build the config tree.  The config tree only stores
+ * the directives that will be active in the running server.  Directives
+ * that contain other directions, such as <Directory ...> cause a sub-level
+ * to be created, where the included directives are stored.  The closing
+ * directive (</Directory>) is not stored in the tree.
+ }
+  ap_directive_t = record
+    { The current directive }
+    directive: PChar;
+    { The arguments for the current directive, stored as a space
+     *  separated list }
+    args: PChar;
+    { The next directive node in the tree
+     *  @defvar ap_directive_t *next }
+    next: Pap_directive_t;
+    { The first child node of this directive
+     *  @defvar ap_directive_t *first_child }
+    first_child: Pap_directive_t;
+    { The parent node of this directive
+     *  @defvar ap_directive_t *parent }
+    parent: Pap_directive_t;
+
+    { directive's module can store add'l data here }
+    data: Pointer;
+
+    { ### these may go away in the future, but are needed for now }
+    { The name of the file this directive was found in }
+    filename: PChar;
+    { The line number the directive was on }
+    line_num: Integer;
+  end;
+
+{
+ * The root of the configuration tree
+ * @defvar ap_directive_t *conftree
+ }
+//AP_DECLARE_DATA extern ap_directive_t *ap_conftree;
+
+{
+ * Add a node to the configuration tree.
+ * @param parent The current parent node.  If the added node is a first_child,
+                 then this is changed to the current node
+ * @param current The current node
+ * @param toadd The node to add to the tree
+ * @param child Is the node to add a child node
+ * @return the added node
+ }
+//ap_directive_t *ap_add_node(ap_directive_t **parent, ap_directive_t *current,
+//                            ap_directive_t *toadd, int child);
+

+ 523 - 0
packages/base/httpd/httpd-2.0/util_filter.inc

@@ -0,0 +1,523 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{#include "apr.h"
+#include "apr_buckets.h"
+
+#include "httpd.h"
+
+#if APR_HAVE_STDARG_H
+#include <stdarg.h>
+#endif}
+
+{
+ * @file util_filter.h
+ * @brief Apache filter library
+ }
+
+const
+{ Returned by the bottom-most filter if no data was written.
+ *  @see ap_pass_brigade(). }
+  AP_NOBODY_WROTE        = -1;
+{ Returned by the bottom-most filter if no data was read.
+ *  @see ap_get_brigade(). }
+  AP_NOBODY_READ         = -2;
+{ Returned when?? @bug find out when! }
+  AP_FILTER_ERROR        = -3;
+
+{
+ * input filtering modes
+ }
+type
+  ap_input_mode_t = (
+    { The filter should return at most readbytes data. }
+    AP_MODE_READBYTES,
+    { The filter should return at most one line of CRLF data.
+     *  (If a potential line is too long or no CRLF is found, the 
+     *   filter may return partial data).
+     }
+    AP_MODE_GETLINE,
+    { The filter should implicitly eat any CRLF pairs that it sees. }
+    AP_MODE_EATCRLF,
+    { The filter read should be treated as speculative and any returned
+     *  data should be stored for later retrieval in another mode. }
+    AP_MODE_SPECULATIVE,
+    { The filter read should be exhaustive and read until it can not
+     *  read any more.
+     *  Use this mode with extreme caution.
+     }
+    AP_MODE_EXHAUSTIVE,
+    { The filter should initialize the connection if needed,
+     *  NNTP or FTP over SSL for example.
+     }
+    AP_MODE_INIT
+  );
+
+{
+ * @defgroup filter FILTER CHAIN
+ *
+ * Filters operate using a "chaining" mechanism. The filters are chained
+ * together into a sequence. When output is generated, it is passed through
+ * each of the filters on this chain, until it reaches the end (or "bottom")
+ * and is placed onto the network.
+ *
+ * The top of the chain, the code generating the output, is typically called
+ * a "content generator." The content generator's output is fed into the
+ * filter chain using the standard Apache output mechanisms: ap_rputs(),
+ * ap_rprintf(), ap_rwrite(), etc.
+ *
+ * Each filter is defined by a callback. This callback takes the output from
+ * the previous filter (or the content generator if there is no previous
+ * filter), operates on it, and passes the result to the next filter in the
+ * chain. This pass-off is performed using the ap_fc_* functions, such as
+ * ap_fc_puts(), ap_fc_printf(), ap_fc_write(), etc.
+ *
+ * When content generation is complete, the system will pass an "end of
+ * stream" marker into the filter chain. The filters will use this to flush
+ * out any internal state and to detect incomplete syntax (for example, an
+ * unterminated SSI directive).
+ }
+
+{ forward declare the filter type }
+  Pap_filter_t = ^ap_filter_t;
+
+{
+ * @name Filter callbacks
+ *
+ * This function type is used for filter callbacks. It will be passed a
+ * pointer to "this" filter, and a "bucket" containing the content to be
+ * filtered.
+ *
+ * In filter->ctx, the callback will find its context. This context is
+ * provided here, so that a filter may be installed multiple times, each
+ * receiving its own per-install context pointer.
+ *
+ * Callbacks are associated with a filter definition, which is specified
+ * by name. See ap_register_input_filter() and ap_register_output_filter()
+ * for setting the association between a name for a filter and its 
+ * associated callback (and other information).
+ *
+ * If the initialization function argument passed to the registration
+ * functions is non-NULL, it will be called iff the filter is in the input
+ * or output filter chains and before any data is generated to allow the
+ * filter to prepare for processing.
+ *
+ * The *bucket structure (and all those referenced by ->next and ->prev)
+ * should be considered "const". The filter is allowed to modify the
+ * next/prev to insert/remove/replace elements in the bucket list, but
+ * the types and values of the individual buckets should not be altered.
+ *
+ * For the input and output filters, the return value of a filter should be
+ * an APR status value.  For the init function, the return value should
+ * be an HTTP error code or OK if it was successful.
+ * 
+ * @ingroup filter
+ }
+
+  ap_out_filter_func = function (f: Pap_filter_t;
+   b: Papr_bucket_brigade): apr_status_t;
+
+  ap_in_filter_func = function (f: Pap_filter_t;
+   b: Papr_bucket_brigade; mode: ap_input_mode_t;
+   block: apr_read_type_e; readbytes: apr_off_t): apr_status_t;
+                                          
+  ap_init_filter_func = function (f: Pap_filter_t): Integer;
+
+  ap_filter_func = record
+    Case Integer of
+     0: (out_func: ap_out_filter_func);
+     1: (in_func: ap_in_filter_func);
+  end;
+
+{
+ * Filters have different types/classifications. These are used to group
+ * and sort the filters to properly sequence their operation.
+ *
+ * The types have a particular sort order, which allows us to insert them
+ * into the filter chain in a determistic order. Within a particular grouping,
+ * the ordering is equivalent to the order of calls to ap_add_*_filter().
+ }
+  ap_filter_type = (
+    { These filters are used to alter the content that is passed through
+     *  them. Examples are SSI or PHP. }
+    AP_FTYPE_RESOURCE     = 10,
+    { These filters are used to alter the content as a whole, but after all
+     *  AP_FTYPE_RESOURCE filters are executed.  These filters should not
+     *  change the content-type.  An example is deflate.  }
+    AP_FTYPE_CONTENT_SET  = 20,
+    { These filters are used to handle the protocol between server and
+     *  client.  Examples are HTTP and POP. }
+    AP_FTYPE_PROTOCOL     = 30,
+    { These filters implement transport encodings (e.g., chunking). }
+    AP_FTYPE_TRANSCODE    = 40,
+    { These filters will alter the content, but in ways that are
+     *  more strongly associated with the connection.  Examples are
+     *  splitting an HTTP connection into multiple requests and
+     *  buffering HTTP responses across multiple requests.
+     *
+     *  It is important to note that these types of filters are not
+     *  allowed in a sub-request. A sub-request's output can certainly
+     *  be filtered by ::AP_FTYPE_RESOURCE filters, but all of the "final
+     *  processing" is determined by the main request. }
+    AP_FTYPE_CONNECTION  = 50,
+    { These filters don't alter the content.  They are responsible for
+     *  sending/receiving data to/from the client. }
+    AP_FTYPE_NETWORK     = 60
+  );
+
+{
+ * This is the request-time context structure for an installed filter (in
+ * the output filter chain). It provides the callback to use for filtering,
+ * the request this filter is associated with (which is important when
+ * an output chain also includes sub-request filters), the context for this
+ * installed filter, and the filter ordering/chaining fields.
+ *
+ * Filter callbacks are free to use ->ctx as they please, to store context
+ * during the filter process. Generally, this is superior over associating
+ * the state directly with the request. A callback should not change any of
+ * the other fields.
+ }
+
+  Pap_filter_rec_t = ^ap_filter_rec_t;
+
+{
+ * This structure is used for recording information about the
+ * registered filters. It associates a name with the filter's callback
+ * and filter type.
+ *
+ * At the moment, these are simply linked in a chain, so a ->next pointer
+ * is available.
+ }
+  ap_filter_rec_t = record
+    { The registered name for this filter }
+    name: PChar;
+    { The function to call when this filter is invoked. }
+    filter_func: ap_filter_func;
+    { The function to call before the handlers are invoked. Notice
+     * that this function is called only for filters participating in
+     * the http protocol. Filters for other protocols are to be
+     * initiliazed by the protocols themselves. }
+    filter_init_func: ap_init_filter_func;
+    { The type of filter, either AP_FTYPE_CONTENT or AP_FTYPE_CONNECTION.
+     * An AP_FTYPE_CONTENT filter modifies the data based on information 
+     * found in the content.  An AP_FTYPE_CONNECTION filter modifies the 
+     * data based on the type of connection.
+     }
+    ftype: ap_filter_type;
+
+    { The next filter_rec in the list }
+    next: Pap_filter_rec_t;
+  end;
+
+{
+ * The representation of a filter chain.  Each request has a list
+ * of these structures which are called in turn to filter the data.  Sub
+ * requests get an exact copy of the main requests filter chain.
+ }
+  ap_filter_t = record
+    { The internal representation of this filter.  This includes
+     *  the filter's name, type, and the actual function pointer.
+     }
+    frec: Pap_filter_rec_t;
+
+    { A place to store any data associated with the current filter }
+    ctx: Pointer;
+
+    { The next filter in the chain }
+    next: Pap_filter_t;
+
+    { The request_rec associated with the current filter.  If a sub-request
+     *  adds filters, then the sub-request is the request associated with the
+     *  filter.
+     }
+    r: Prequest_rec;
+
+    { The conn_rec associated with the current filter.  This is analogous
+     *  to the request_rec, except that it is used for input filtering.
+     }
+    c: Pconn_rec;
+  end;
+
+{
+ * Get the current bucket brigade from the next filter on the filter
+ * stack.  The filter returns an apr_status_t value.  If the bottom-most 
+ * filter doesn't read from the network, then ::AP_NOBODY_READ is returned.
+ * The bucket brigade will be empty when there is nothing left to get.
+ * @param filter The next filter in the chain
+ * @param bucket The current bucket brigade.  The original brigade passed
+ *               to ap_get_brigade() must be empty.
+ * @param mode   The way in which the data should be read
+ * @param block  How the operations should be performed
+ *               ::APR_BLOCK_READ, ::APR_NONBLOCK_READ
+ * @param readbytes How many bytes to read from the next filter.
+ }
+function ap_get_brigade(filter: Pap_filter_t;
+ bucket: Papr_bucket_brigade; mode: ap_input_mode_t;
+ block: apr_read_type_e; readbytes: apr_off_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_brigade' + LibSuff24;
+
+{
+ * Pass the current bucket brigade down to the next filter on the filter
+ * stack.  The filter returns an apr_status_t value.  If the bottom-most 
+ * filter doesn't write to the network, then ::AP_NOBODY_WROTE is returned.
+ * The caller relinquishes ownership of the brigade.
+ * @param filter The next filter in the chain
+ * @param bucket The current bucket brigade
+ }
+function ap_pass_brigade(filter: Pap_filter_t;
+ bucket: Papr_bucket_brigade): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_pass_brigade' + LibSuff8;
+
+{
+ * This function is used to register an input filter with the system. 
+ * After this registration is performed, then a filter may be added 
+ * into the filter chain by using ap_add_input_filter() and simply 
+ * specifying the name.
+ *
+ * @param name The name to attach to the filter function
+ * @param filter_func The filter function to name
+ * @param filter_init The function to call before the filter handlers 
+                      are invoked
+ * @param ftype The type of filter function, either ::AP_FTYPE_CONTENT or
+ *              ::AP_FTYPE_CONNECTION
+ * @see add_input_filter()
+ }
+function ap_register_input_filter(const name: PChar;
+ filter_func: ap_in_filter_func; filter_init: ap_init_filter_func;
+ ftype: ap_filter_type): Pap_filter_rec_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_register_input_filter' + LibSuff16;
+
+{
+ * This function is used to register an output filter with the system. 
+ * After this registration is performed, then a filter may be added 
+ * into the filter chain by using ap_add_output_filter() and simply 
+ * specifying the name.
+ *
+ * @param name The name to attach to the filter function
+ * @param filter_func The filter function to name
+ * @param filter_init The function to call before the filter handlers 
+ *                    are invoked
+ * @param ftype The type of filter function, either ::AP_FTYPE_CONTENT or
+ *              ::AP_FTYPE_CONNECTION
+ * @see ap_add_output_filter()
+ }
+function ap_register_output_filter(const name: PChar;
+ filter_func: ap_out_filter_func; filter_init: ap_init_filter_func;
+ ftype: ap_filter_type): Pap_filter_rec_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_register_output_filter' + LibSuff16;
+
+{
+ * Adds a named filter into the filter chain on the specified request record.
+ * The filter will be installed with the specified context pointer.
+ *
+ * Filters added in this way will always be placed at the end of the filters
+ * that have the same type (thus, the filters have the same order as the
+ * calls to ap_add_filter). If the current filter chain contains filters
+ * from another request, then this filter will be added before those other
+ * filters.
+ * 
+ * To re-iterate that last comment.  This function is building a FIFO
+ * list of filters.  Take note of that when adding your filter to the chain.
+ *
+ * @param name The name of the filter to add
+ * @param ctx Context data to provide to the filter
+ * @param r The request to add this filter for (or NULL if it isn't associated with a request)
+ * @param c The connection to add the fillter for
+ }
+function ap_add_input_filter(const name: PChar; ctx: Pointer;
+ r: Prequest_rec; c: Pconn_rec): Pap_filter_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_add_input_filter' + LibSuff16;
+
+{
+ * Variant of ap_add_input_filter() that accepts a registered filter handle
+ * (as returned by ap_register_input_filter()) rather than a filter name
+ *
+ * @param f The filter handle to add
+ * @param ctx Context data to provide to the filter
+ * @param r The request to add this filter for (or NULL if it isn't associated with a request)
+ * @param c The connection to add the fillter for
+ }
+function ap_add_input_filter_handle(f: Pap_filter_t;
+ ctx: Pointer; r: Prequest_rec; c: Pconn_rec): Pap_filter_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_add_input_filter_handle' + LibSuff16;
+
+{
+ * Returns the filter handle for use with ap_add_input_filter_handle.
+ *
+ * @param name The filter name to look up
+ }
+function ap_get_input_filter_handle(const name: PChar): Pap_filter_rec_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_input_filter_handle' + LibSuff4;
+
+{
+ * Add a filter to the current request.  Filters are added in a FIFO manner.
+ * The first filter added will be the first filter called.
+ * @param name The name of the filter to add
+ * @param ctx Context data to set in the filter
+ * @param r The request to add this filter for (or NULL if it isn't associated with a request)
+ * @param c The connection to add this filter for
+ }
+function ap_add_output_filter(const name: PChar; ctx: Pointer;
+ r: Prequest_rec; c: Pconn_rec): Pap_filter_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_add_output_filter' + LibSuff16;
+
+{
+ * Variant of ap_add_output_filter() that accepts a registered filter handle
+ * (as returned by ap_register_output_filter()) rather than a filter name
+ *
+ * @param f The filter handle to add
+ * @param r The request to add this filter for (or NULL if it isn't associated with a request)
+ * @param c The connection to add the fillter for
+ }
+function ap_add_output_filter_handle(f: Pap_filter_rec_t;
+ ctx: Pointer; r: Prequest_rec; c: Pconn_rec): Pap_filter_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_add_output_filter_handle' + LibSuff16;
+
+{
+ * Returns the filter handle for use with ap_add_output_filter_handle.
+ *
+ * @param name The filter name to look up
+ }
+function ap_get_output_filter_handle(const name: PChar): Pap_filter_rec_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_get_output_filter_handle' + LibSuff4;
+
+{
+ * Remove an input filter from either the request or connection stack
+ * it is associated with.
+ * @param f The filter to remove
+ }
+procedure ap_remove_input_filter(f: Pap_filter_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_remove_input_filter' + LibSuff4;
+
+{
+ * Remove an output filter from either the request or connection stack
+ * it is associated with.
+ * @param f The filter to remove
+ }
+procedure ap_remove_output_filter(f: Pap_filter_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_remove_output_filter' + LibSuff4;
+
+{ The next two filters are for abstraction purposes only.  They could be
+ * done away with, but that would require that we break modules if we ever
+ * want to change our filter registration method.  The basic idea, is that
+ * all filters have a place to store data, the ctx pointer.  These functions
+ * fill out that pointer with a bucket brigade, and retrieve that data on
+ * the next call.  The nice thing about these functions, is that they
+ * automatically concatenate the bucket brigades together for you.  This means
+ * that if you have already stored a brigade in the filters ctx pointer, then
+ * when you add more it will be tacked onto the end of that brigade.  When
+ * you retrieve data, if you pass in a bucket brigade to the get function,
+ * it will append the current brigade onto the one that you are retrieving.
+ }
+
+{
+ * prepare a bucket brigade to be setaside.  If a different brigade was 
+ * set-aside earlier, then the two brigades are concatenated together.
+ * @param f The current filter
+ * @param save_to The brigade that was previously set-aside.  Regardless, the
+ *             new bucket brigade is returned in this location.
+ * @param b The bucket brigade to save aside.  This brigade is always empty
+ *          on return
+ * @param p Ensure that all data in the brigade lives as long as this pool
+ }
+function ap_save_brigade(f: Pap_filter_t;
+ save_to, b: PPapr_bucket_brigade; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_save_brigade' + LibSuff16;
+
+{
+ * Flush function for apr_brigade_* calls.  This calls ap_pass_brigade
+ * to flush the brigade if the brigade buffer overflows.
+ * @param bb The brigade to flush
+ * @param ctx The filter to pass the brigade to
+ * @note this function has nothing to do with FLUSH buckets. It is simply
+ * a way to flush content out of a brigade and down a filter stack.
+ }
+{AP_DECLARE_NONSTD(apr_status_t) ap_filter_flush(apr_bucket_brigade *bb,
+                                                void *ctx);}
+
+{
+ * Flush the current brigade down the filter stack.
+ * @param f The current filter
+ * @param bb The brigade to flush
+ }
+function ap_fflush(f: Pap_filter_t; bb: Papr_bucket_brigade): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_fflush' + LibSuff8;
+
+{
+ * Write a buffer for the current filter, buffering if possible.
+ * @param f the filter doing the writing
+ * @param bb The brigade to buffer into
+ * @param data The data to write
+ * @param nbyte The number of bytes in the data
+ }
+{#define ap_fwrite(f, bb, data, nbyte) \
+        apr_brigade_write(bb, ap_filter_flush, f, data, nbyte)}
+
+{
+ * Write a buffer for the current filter, buffering if possible.
+ * @param f the filter doing the writing
+ * @param bb The brigade to buffer into
+ * @param str The string to write
+ }
+{#define ap_fputs(f, bb, str) \
+        apr_brigade_puts(bb, ap_filter_flush, f, str)}
+
+{
+ * Write a character for the current filter, buffering if possible.
+ * @param f the filter doing the writing
+ * @param bb The brigade to buffer into
+ * @param c The character to write
+ }
+{#define ap_fputc(f, bb, c) \
+        apr_brigade_putc(bb, ap_filter_flush, f, c)}
+
+{
+ * Write an unspecified number of strings to the current filter
+ * @param f the filter doing the writing
+ * @param bb The brigade to buffer into
+ * @param ... The strings to write
+ }
+function ap_fputstrs(f: Pap_filter_t; bb: Papr_bucket_brigade;
+ others: array of const): apr_status_t;
+ cdecl; external LibHTTPD name 'ap_fputstrs';
+
+{
+ * Output data to the filter in printf format
+ * @param f the filter doing the writing
+ * @param bb The brigade to buffer into
+ * @param fmt The format string
+ * @param ... The argumets to use to fill out the format string
+ }
+function ap_fprintf(f: Pap_filter_t; bb: Papr_bucket_brigade;
+ const fmt: PChar; others: array of const): apr_status_t;
+ cdecl; external LibHTTPD name 'ap_fputstrs';
+
+{        __attribute__((format(printf,3,4)));}
+

+ 66 - 0
packages/base/httpd/httpd-2.0/util_md5.inc

@@ -0,0 +1,66 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @package Apache MD5 library
+ }
+
+//#include "apr_md5.h"
+
+{
+ * Create an MD5 checksum of a given string
+ * @param a Pool to allocate out of
+ * @param string String to get the checksum of
+ * @return The checksum
+ * @deffunc char *ap_md5(apr_pool_t *a, const unsigned char *string)
+ }
+function ap_md5(p: Papr_pool_t; const string_: PChar): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_md5' + LibSuff8;
+
+{
+ * Create an MD5 checksum of a string of binary data
+ * @param a Pool to allocate out of
+ * @param buf Buffer to generate checksum for
+ * @param len The length of the buffer
+ * @return The checksum
+ * @deffunc char *ap_md5_binary(apr_pool_t *a, const unsigned char *buf, int len)
+ }
+function ap_md5_binary(a: Papr_pool_t; const buf: PChar; len: Integer): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_md5_binary' + LibSuff12;
+
+{
+ * Convert an MD5 checksum into a base64 encoding
+ * @param p The pool to allocate out of
+ * @param context The context to convert
+ * @return The converted encoding
+ * @deffunc char *ap_md5contextTo64(apr_pool_t *p, apr_md5_ctx_t *context)
+ }
+function ap_md5contextTo64(a: Papr_pool_t; context: Papr_md5_ctx_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_md5contextTo64' + LibSuff8;
+
+{
+ * Create an MD5 Digest for a given file
+ * @param p The pool to allocate out of
+ * @param infile The file to create the digest for
+ * @deffunc char *ap_md5digest(apr_pool_t *p, apr_file_t *infile)
+ }
+function ap_md5digest(p: Papr_pool_t; infile: Papr_file_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_md5digest' + LibSuff8;
+

+ 140 - 0
packages/base/httpd/httpd-2.0/util_script.inc

@@ -0,0 +1,140 @@
+{ Copyright 1999-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+//#include "apr_buckets.h"
+
+{
+ * @package Apache script tools
+ }
+
+const
+  APACHE_ARG_MAX = 512;
+
+{
+ * Create an environment variable out of an Apache table of key-value pairs
+ * @param p pool to allocate out of
+ * @param t Apache table of key-value pairs
+ * @return An array containing the same key-value pairs suitable for
+ *         use with an exec call.
+ * @deffunc char **ap_create_environment(apr_pool_t *p, apr_table_t *t)
+ }
+function ap_create_environment(p: Papr_pool_t; t: Papr_table_t): PPChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_create_environment' + LibSuff8;
+
+{
+ * This "cute" little function comes about because the path info on
+ * filenames and URLs aren't always the same. So we take the two,
+ * and find as much of the two that match as possible.
+ * @param uri The uri we are currently parsing
+ * @param path_info The current path info
+ * @return The length of the path info
+ * @deffunc int ap_find_path_info(const char *uri, const char *path_info)
+ }
+function ap_find_path_info(const uri, path_info: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_find_path_info' + LibSuff8;
+
+{
+ * Add CGI environment variables required by HTTP/1.1 to the request's 
+ * environment table
+ * @param r the current request
+ * @deffunc void ap_add_cgi_vars(request_rec *r)
+ }
+procedure ap_add_cgi_vars(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_add_cgi_vars' + LibSuff4;
+
+{
+ * Add common CGI environment variables to the requests environment table
+ * @param r The current request
+ * @deffunc void ap_add_common_vars(request_rec *r)
+ }
+procedure ap_add_common_vars(r: Prequest_rec);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_add_common_vars' + LibSuff4;
+
+{
+ * Read headers output from a script, ensuring that the output is valid.  If
+ * the output is valid, then the headers are added to the headers out of the
+ * current request
+ * @param r The current request
+ * @param f The file to read from
+ * @param buffer Empty when calling the function.  On output, if there was an
+ *               error, the string that cause the error is stored here. 
+ * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
+ * @deffunc int ap_scan_script_header_err(request_rec *r, apr_file_t *f, char *buffer)
+ }
+function ap_scan_script_header_err(r: Prequest_rec;
+ f: Papr_file_t; buffer: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_scan_script_header_err' + LibSuff12;
+
+{
+ * Read headers output from a script, ensuring that the output is valid.  If
+ * the output is valid, then the headers are added to the headers out of the
+ * current request
+ * @param r The current request
+ * @param bb The brigade from which to read
+ * @param buffer Empty when calling the function.  On output, if there was an
+ *               error, the string that cause the error is stored here. 
+ * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
+ * @deffunc int ap_scan_script_header_err_brigade(request_rec *r, apr_bucket_brigade *bb, char *buffer)
+ }
+function ap_scan_script_header_err_brigade(r: Prequest_rec;
+ bb: Papr_bucket_brigade; buffer: PChar): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_scan_script_header_err_brigade' + LibSuff12;
+
+{
+ * Read headers strings from a script, ensuring that the output is valid.  If
+ * the output is valid, then the headers are added to the headers out of the
+ * current request
+ * @param r The current request
+ * @param buffer Empty when calling the function.  On output, if there was an
+ *               error, the string that cause the error is stored here. 
+ * @param termch Pointer to the last character parsed.
+ * @param termarg Pointer to an int to capture the last argument parsed.
+ * @param args   String arguments to parse consecutively for headers, 
+ *               a NULL argument terminates the list.
+ * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
+ * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
+ }
+function ap_scan_script_header_err_strs(buffer: PChar;
+ termch: PPChar; termarg: PInteger; others: array of const): Integer;
+ cdecl; external LibHTTPD name 'ap_scan_script_header_err_strs';
+
+{
+ * Read headers output from a script, ensuring that the output is valid.  If
+ * the output is valid, then the headers are added to the headers out of the
+ * current request
+ * @param r The current request
+ * @param buffer Empty when calling the function.  On output, if there was an
+ *               error, the string that cause the error is stored here. 
+ * @param getsfunc Function to read the headers from.  This function should
+                   act like gets()
+ * @param getsfunc_data The place to read from
+ * @return HTTP_OK on success, HTTP_INTERNAL_SERVER_ERROR otherwise
+ * @deffunc int ap_scan_script_header_err_core(request_rec *r, char *buffer, int (*getsfunc)(char *, int, void *), void *getsfunc_data)
+ }
+type
+  getsfunc_t = function(p1: PChar; p2: Integer; p3: Pointer): Integer;
+  
+function ap_scan_script_header_err_core(r: Prequest_rec;
+ buffer: PChar; getsfunc: getsfunc_t; getsfunc_data: Pointer): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_scan_script_header_err_core' + LibSuff16;
+

+ 78 - 0
packages/base/httpd/httpd-2.0/util_time.inc

@@ -0,0 +1,78 @@
+{ Copyright 2001-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{#include "apr.h"
+#include "apr_time.h"
+#include "httpd.h"}
+
+{
+ * @package Apache date-time handling functions
+ }
+
+{ Maximum delta from the current time, in seconds, for a past time
+ * to qualify as "recent" for use in the ap_explode_recent_*() functions:
+ * (Must be a power of two minus one!)
+ }
+const AP_TIME_RECENT_THRESHOLD = 15;
+
+{
+ * convert a recent time to its human readable components in local timezone
+ * @param tm the exploded time
+ * @param t the time to explode: MUST be within the last
+ *          AP_TIME_RECENT_THRESHOLD seconds
+ * @note This is a faster alternative to apr_explode_localtime that uses
+ *       a cache of pre-exploded time structures.  It is useful for things
+ *       that need to explode the current time multiple times per second,
+ *       like loggers.
+ * @return APR_SUCCESS iff successful
+ }
+function ap_explode_recent_localtime(tm: Papr_time_exp_t; t: apr_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_explode_recent_localtime' + LibSuff12;
+
+{
+ * convert a recent time to its human readable components in GMT timezone
+ * @param tm the exploded time
+ * @param t the time to explode: MUST be within the last
+ *          AP_TIME_RECENT_THRESHOLD seconds
+ * @note This is a faster alternative to apr_time_exp_gmt that uses
+ *       a cache of pre-exploded time structures.  It is useful for things
+ *       that need to explode the current time multiple times per second,
+ *       like loggers.
+ * @return APR_SUCCESS iff successful
+ }
+function ap_explode_recent_gmt(tm: Papr_time_exp_t; t: apr_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_explode_recent_gmt' + LibSuff12;
+
+{
+ * format a recent timestamp in the ctime() format.
+ * @param date_str String to write to.
+ * @param t the time to convert 
+ }
+function ap_recent_ctime(date_str: PChar; t: apr_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_recent_ctime' + LibSuff12;
+
+{
+ * format a recent timestamp in the RFC822 format
+ * @param date_str String to write to (must have length >= APR_RFC822_DATE_LEN)
+ * @param t the time to convert 
+ }
+function ap_recent_rfc822_date(date_str: PChar; t: apr_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_recent_rfc822_date' + LibSuff12;
+

+ 1865 - 0
packages/base/httpd/httpd-2.2/Makefile

@@ -0,0 +1,1865 @@
+#
+# Don't edit, this file is generated by FPCMake Version 2.0.0 [2006/08/20]
+#
+default: all
+MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos sparc-linux sparc-netbsd sparc-solaris x86_64-linux x86_64-freebsd x86_64-win64 arm-linux arm-palmos arm-wince arm-gba powerpc64-linux
+BSDs = freebsd netbsd openbsd darwin
+UNIXs = linux $(BSDs) solaris qnx
+LIMIT83fs = go32v2 os2 emx watcom
+FORCE:
+.PHONY: FORCE
+override PATH:=$(patsubst %/,%,$(subst \,/,$(PATH)))
+ifneq ($(findstring darwin,$(OSTYPE)),)
+inUnix=1 #darwin
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH:=$(filter-out .,$(subst :, ,$(PATH)))
+else
+SEARCHPATH:=$(subst ;, ,$(PATH))
+endif
+endif
+SEARCHPATH+=$(patsubst %/,%,$(subst \,/,$(dir $(MAKE))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
+ifeq ($(PWD),)
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
+ifeq ($(PWD),)
+$(error You need the GNU utils package to use this Makefile)
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=
+endif
+else
+PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
+endif
+ifndef inUnix
+ifeq ($(OS),Windows_NT)
+inWinNT=1
+else
+ifdef OS2_SHELL
+inOS2=1
+endif
+endif
+else
+ifneq ($(findstring cygdrive,$(PATH)),)
+inCygWin=1
+endif
+endif
+ifdef inUnix
+SRCBATCHEXT=.sh
+else
+ifdef inOS2
+SRCBATCHEXT=.cmd
+else
+SRCBATCHEXT=.bat
+endif
+endif
+ifdef inUnix
+PATHSEP=/
+else
+PATHSEP:=$(subst /,\,/)
+ifdef inCygWin
+PATHSEP=/
+endif
+endif
+ifdef PWD
+BASEDIR:=$(subst \,/,$(shell $(PWD)))
+ifdef inCygWin
+ifneq ($(findstring /cygdrive/,$(BASEDIR)),)
+BASENODIR:=$(patsubst /cygdrive%,%,$(BASEDIR))
+BASEDRIVE:=$(firstword $(subst /, ,$(BASENODIR)))
+BASEDIR:=$(subst /cygdrive/$(BASEDRIVE)/,$(BASEDRIVE):/,$(BASEDIR))
+endif
+endif
+else
+BASEDIR=.
+endif
+ifdef inOS2
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO=echo
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+endif
+override DEFAULT_FPCDIR=../../../..
+ifndef FPC
+ifdef PP
+FPC=$(PP)
+endif
+endif
+ifndef FPC
+FPCPROG:=$(strip $(wildcard $(addsuffix /fpc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(FPCPROG),)
+FPCPROG:=$(firstword $(FPCPROG))
+FPC:=$(shell $(FPCPROG) -PB)
+ifneq ($(findstring Error,$(FPC)),)
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+else
+override FPC=$(firstword $(strip $(wildcard $(addsuffix /ppc386$(SRCEXEEXT),$(SEARCHPATH)))))
+endif
+endif
+override FPC:=$(subst $(SRCEXEEXT),,$(FPC))
+override FPC:=$(subst \,/,$(FPC))$(SRCEXEEXT)
+FOUNDFPC:=$(strip $(wildcard $(FPC)))
+ifeq ($(FOUNDFPC),)
+FOUNDFPC=$(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))
+ifeq ($(FOUNDFPC),)
+$(error Compiler $(FPC) not found)
+endif
+endif
+ifndef FPC_COMPILERINFO
+FPC_COMPILERINFO:=$(shell $(FPC) -iVSPTPSOTO)
+endif
+ifndef FPC_VERSION
+FPC_VERSION:=$(word 1,$(FPC_COMPILERINFO))
+endif
+export FPC FPC_VERSION FPC_COMPILERINFO
+unexport CHECKDEPEND ALLDEPENDENCIES
+ifndef CPU_TARGET
+ifdef CPU_TARGET_DEFAULT
+CPU_TARGET=$(CPU_TARGET_DEFAULT)
+endif
+endif
+ifndef OS_TARGET
+ifdef OS_TARGET_DEFAULT
+OS_TARGET=$(OS_TARGET_DEFAULT)
+endif
+endif
+ifneq ($(words $(FPC_COMPILERINFO)),5)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTP)
+FPC_COMPILERINFO+=$(shell $(FPC) -iSO)
+FPC_COMPILERINFO+=$(shell $(FPC) -iTO)
+endif
+ifndef CPU_SOURCE
+CPU_SOURCE:=$(word 2,$(FPC_COMPILERINFO))
+endif
+ifndef CPU_TARGET
+CPU_TARGET:=$(word 3,$(FPC_COMPILERINFO))
+endif
+ifndef OS_SOURCE
+OS_SOURCE:=$(word 4,$(FPC_COMPILERINFO))
+endif
+ifndef OS_TARGET
+OS_TARGET:=$(word 5,$(FPC_COMPILERINFO))
+endif
+FULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+FULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+TARGETSUFFIX=$(OS_TARGET)
+SOURCESUFFIX=$(OS_SOURCE)
+else
+TARGETSUFFIX=$(FULL_TARGET)
+SOURCESUFFIX=$(FULL_SOURCE)
+endif
+ifneq ($(FULL_TARGET),$(FULL_SOURCE))
+CROSSCOMPILE=1
+endif
+ifeq ($(findstring makefile,$(MAKECMDGOALS)),)
+ifeq ($(findstring $(FULL_TARGET),$(MAKEFILETARGETS)),)
+$(error The Makefile doesn't support target $(FULL_TARGET), please run fpcmake first)
+endif
+endif
+ifneq ($(findstring $(OS_TARGET),$(BSDs)),)
+BSDhier=1
+endif
+ifeq ($(OS_TARGET),linux)
+linuxHier=1
+endif
+export OS_TARGET OS_SOURCE CPU_TARGET CPU_SOURCE FULL_TARGET FULL_SOURCE TARGETSUFFIX SOURCESUFFIX CROSSCOMPILE
+ifdef FPCDIR
+override FPCDIR:=$(subst \,/,$(FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+else
+override FPCDIR=wrong
+endif
+ifdef DEFAULT_FPCDIR
+ifeq ($(FPCDIR),wrong)
+override FPCDIR:=$(subst \,/,$(DEFAULT_FPCDIR))
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=wrong
+endif
+endif
+endif
+ifeq ($(FPCDIR),wrong)
+ifdef inUnix
+override FPCDIR=/usr/local/lib/fpc/$(FPC_VERSION)
+ifeq ($(wildcard $(FPCDIR)/units),)
+override FPCDIR=/usr/lib/fpc/$(FPC_VERSION)
+endif
+else
+override FPCDIR:=$(subst /$(FPC),,$(firstword $(strip $(wildcard $(addsuffix /$(FPC),$(SEARCHPATH))))))
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(FPCDIR)/..
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR:=$(BASEDIR)
+ifeq ($(wildcard $(addprefix $(FPCDIR)/,rtl units)),)
+override FPCDIR=c:/pp
+endif
+endif
+endif
+endif
+endif
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(FPCDIR)/bin/$(TARGETSUFFIX))
+endif
+ifndef BINUTILSPREFIX
+ifndef CROSSBINDIR
+ifdef CROSSCOMPILE
+BINUTILSPREFIX=$(CPU_TARGET)-$(OS_TARGET)-
+endif
+endif
+endif
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(TARGETSUFFIX))
+ifeq ($(UNITSDIR),)
+UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
+endif
+PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
+override PACKAGE_NAME=httpd-2.2
+override PACKAGE_VERSION=2.0.4
+ifeq ($(FULL_TARGET),i386-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+override TARGET_UNITS+=apr/apr apriconv/apriconv aprutil/aprutil httpd
+endif
+override INSTALL_FPCPACKAGE=y
+ifdef REQUIRE_UNITSDIR
+override UNITSDIR+=$(REQUIRE_UNITSDIR)
+endif
+ifdef REQUIRE_PACKAGESDIR
+override PACKAGESDIR+=$(REQUIRE_PACKAGESDIR)
+endif
+ifdef ZIPINSTALL
+ifneq ($(findstring $(OS_TARGET),$(UNIXs)),)
+UNIXHier=1
+endif
+else
+ifneq ($(findstring $(OS_SOURCE),$(UNIXs)),)
+UNIXHier=1
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef PREFIX
+INSTALL_PREFIX=$(PREFIX)
+endif
+endif
+ifndef INSTALL_PREFIX
+ifdef UNIXHier
+INSTALL_PREFIX=/usr/local
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=/pp
+else
+INSTALL_BASEDIR:=/$(PACKAGE_NAME)
+endif
+endif
+endif
+export INSTALL_PREFIX
+ifdef INSTALL_FPCSUBDIR
+export INSTALL_FPCSUBDIR
+endif
+ifndef DIST_DESTDIR
+DIST_DESTDIR:=$(BASEDIR)
+endif
+export DIST_DESTDIR
+ifndef COMPILER_UNITTARGETDIR
+ifdef PACKAGEDIR_MAIN
+COMPILER_UNITTARGETDIR=$(PACKAGEDIR_MAIN)/units/$(TARGETSUFFIX)
+else
+COMPILER_UNITTARGETDIR=units/$(TARGETSUFFIX)
+endif
+endif
+ifndef COMPILER_TARGETDIR
+COMPILER_TARGETDIR=.
+endif
+ifndef INSTALL_BASEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/fpc/$(FPC_VERSION)
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)/lib/$(PACKAGE_NAME)
+endif
+else
+INSTALL_BASEDIR:=$(INSTALL_PREFIX)
+endif
+endif
+ifndef INSTALL_BINDIR
+ifdef UNIXHier
+INSTALL_BINDIR:=$(INSTALL_PREFIX)/bin
+else
+INSTALL_BINDIR:=$(INSTALL_BASEDIR)/bin
+ifdef INSTALL_FPCPACKAGE
+ifdef CROSSCOMPILE
+ifdef CROSSINSTALL
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(SOURCESUFFIX)
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+else
+INSTALL_BINDIR:=$(INSTALL_BINDIR)/$(TARGETSUFFIX)
+endif
+endif
+endif
+endif
+ifndef INSTALL_UNITDIR
+INSTALL_UNITDIR:=$(INSTALL_BASEDIR)/units/$(TARGETSUFFIX)
+ifdef INSTALL_FPCPACKAGE
+ifdef PACKAGE_NAME
+INSTALL_UNITDIR:=$(INSTALL_UNITDIR)/$(PACKAGE_NAME)
+endif
+endif
+endif
+ifndef INSTALL_LIBDIR
+ifdef UNIXHier
+INSTALL_LIBDIR:=$(INSTALL_PREFIX)/lib
+else
+INSTALL_LIBDIR:=$(INSTALL_UNITDIR)
+endif
+endif
+ifndef INSTALL_SOURCEDIR
+ifdef UNIXHier
+ifdef BSDhier
+SRCPREFIXDIR=share/src
+else
+ifdef linuxHier
+SRCPREFIXDIR=share/src
+else
+SRCPREFIXDIR=src
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_PREFIX)/$(SRCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+ifdef INSTALL_FPCSUBDIR
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(INSTALL_FPCSUBDIR)/$(PACKAGE_NAME)
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source/$(PACKAGE_NAME)
+endif
+else
+INSTALL_SOURCEDIR:=$(INSTALL_BASEDIR)/source
+endif
+endif
+endif
+ifndef INSTALL_DOCDIR
+ifdef UNIXHier
+ifdef BSDhier
+DOCPREFIXDIR=share/doc
+else
+ifdef linuxHier
+DOCPREFIXDIR=share/doc
+else
+DOCPREFIXDIR=doc
+endif
+endif
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_PREFIX)/$(DOCPREFIXDIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc/$(PACKAGE_NAME)
+else
+INSTALL_DOCDIR:=$(INSTALL_BASEDIR)/doc
+endif
+endif
+endif
+ifndef INSTALL_EXAMPLEDIR
+ifdef UNIXHier
+ifdef INSTALL_FPCPACKAGE
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/fpc-$(FPC_VERSION)/$(PACKAGE_NAME)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/fpc-$(FPC_VERSION)/examples/$(PACKAGE_NAME)
+endif
+endif
+else
+ifdef BSDhier
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/share/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+ifdef linuxHier
+INSTALL_EXAMPLEDIR:=$(INSTALL_DOCDIR)/examples/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_PREFIX)/doc/$(PACKAGE_NAME)-$(PACKAGE_VERSION)
+endif
+endif
+endif
+else
+ifdef INSTALL_FPCPACKAGE
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples/$(PACKAGE_NAME)
+else
+INSTALL_EXAMPLEDIR:=$(INSTALL_BASEDIR)/examples
+endif
+endif
+endif
+ifndef INSTALL_DATADIR
+INSTALL_DATADIR=$(INSTALL_BASEDIR)
+endif
+ifndef INSTALL_SHAREDDIR
+INSTALL_SHAREDDIR=$(INSTALL_PREFIX)/lib
+endif
+ifdef CROSSCOMPILE
+ifndef CROSSBINDIR
+CROSSBINDIR:=$(wildcard $(CROSSTARGETDIR)/bin/$(SOURCESUFFIX))
+ifeq ($(CROSSBINDIR),)
+CROSSBINDIR:=$(wildcard $(INSTALL_BASEDIR)/cross/$(TARGETSUFFIX)/bin/$(FULL_SOURCE))
+endif
+endif
+else
+CROSSBINDIR=
+endif
+ifeq ($(OS_SOURCE),linux)
+ifndef GCCLIBDIR
+ifeq ($(CPU_TARGET),i386)
+ifneq ($(findstring x86_64,$(shell uname -a)),)
+ifeq ($(BINUTILSPREFIX),)
+GCCLIBDIR:=$(shell dirname `gcc -m32 -print-libgcc-file-name`)
+endif
+endif
+endif
+ifeq ($(CPU_TARGET),powerpc64)
+ifeq ($(BINUTILSPREFIX),)
+GCCLIBDIR:=$(shell dirname `gcc -m64 -print-libgcc-file-name`)
+endif
+endif
+endif
+ifndef GCCLIBDIR
+CROSSGCC=$(strip $(wildcard $(addsuffix /$(BINUTILSPREFIX)gcc$(SRCEXEEXT),$(SEARCHPATH))))
+ifneq ($(CROSSGCC),)
+GCCLIBDIR:=$(shell dirname `$(CROSSGCC) -print-libgcc-file-name`)
+endif
+endif
+ifndef OTHERLIBDIR
+OTHERLIBDIR:=$(shell grep -v "^\#" /etc/ld.so.conf | awk '{ ORS=" "; print $1 }')
+endif
+endif
+ifdef inUnix
+ifeq ($(OS_SOURCE),netbsd)
+OTHERLIBDIR+=/usr/pkg/lib
+endif
+export GCCLIBDIR OTHERLIB
+endif
+BATCHEXT=.bat
+LOADEREXT=.as
+EXEEXT=.exe
+PPLEXT=.ppl
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.so
+SHAREDLIBPREFIX=libfp
+STATICLIBPREFIX=libp
+IMPORTLIBPREFIX=libimp
+RSTEXT=.rst
+ifeq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),go32v1)
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+OEXT=.obj
+ASMEXT=.asm
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),emx)
+BATCHEXT=.cmd
+AOUTEXT=.out
+STATICLIBPREFIX=
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=emx
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),morphos)
+EXEEXT=
+SHAREDLIBEXT=.library
+SHORTSUFFIX=mos
+endif
+ifeq ($(OS_TARGET),atari)
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+EXEEXT=.nlm
+STATICLIBPREFIX=
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+ifeq ($(OS_TARGET),darwin)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=dwn
+endif
+ifeq ($(OS_TARGET),gba)
+EXEEXT=.gba
+SHAREDLIBEXT=.so
+SHORTSUFFIX=gba
+endif
+else
+ifeq ($(OS_TARGET),go32v1)
+PPUEXT=.pp1
+OEXT=.o1
+ASMEXT=.s1
+SMARTEXT=.sl1
+STATICLIBEXT=.a1
+SHAREDLIBEXT=.so1
+STATICLIBPREFIX=
+SHORTSUFFIX=v1
+endif
+ifeq ($(OS_TARGET),go32v2)
+STATICLIBPREFIX=
+SHORTSUFFIX=dos
+endif
+ifeq ($(OS_TARGET),watcom)
+STATICLIBPREFIX=
+SHORTSUFFIX=wat
+endif
+ifeq ($(OS_TARGET),linux)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=lnx
+endif
+ifeq ($(OS_TARGET),freebsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=fbs
+endif
+ifeq ($(OS_TARGET),netbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=nbs
+endif
+ifeq ($(OS_TARGET),openbsd)
+BATCHEXT=.sh
+EXEEXT=
+HASSHAREDLIB=1
+SHORTSUFFIX=obs
+endif
+ifeq ($(OS_TARGET),win32)
+PPUEXT=.ppw
+OEXT=.ow
+ASMEXT=.sw
+SMARTEXT=.slw
+STATICLIBEXT=.aw
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=w32
+endif
+ifeq ($(OS_TARGET),os2)
+BATCHEXT=.cmd
+PPUEXT=.ppo
+ASMEXT=.so2
+OEXT=.oo2
+AOUTEXT=.out
+SMARTEXT=.sl2
+STATICLIBPREFIX=
+STATICLIBEXT=.ao2
+SHAREDLIBEXT=.dll
+SHORTSUFFIX=os2
+ECHO=echo
+endif
+ifeq ($(OS_TARGET),amiga)
+EXEEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.library
+SHORTSUFFIX=amg
+endif
+ifeq ($(OS_TARGET),atari)
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=.ttp
+SHORTSUFFIX=ata
+endif
+ifeq ($(OS_TARGET),beos)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=be
+endif
+ifeq ($(OS_TARGET),solaris)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=sun
+endif
+ifeq ($(OS_TARGET),qnx)
+BATCHEXT=.sh
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+SHORTSUFFIX=qnx
+endif
+ifeq ($(OS_TARGET),netware)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nw
+endif
+ifeq ($(OS_TARGET),netwlibc)
+STATICLIBPREFIX=
+PPUEXT=.ppu
+OEXT=.o
+ASMEXT=.s
+SMARTEXT=.sl
+STATICLIBEXT=.a
+SHAREDLIBEXT=.nlm
+EXEEXT=.nlm
+SHORTSUFFIX=nwl
+endif
+ifeq ($(OS_TARGET),macos)
+BATCHEXT=
+PPUEXT=.ppu
+ASMEXT=.s
+OEXT=.o
+SMARTEXT=.sl
+STATICLIBEXT=.a
+EXEEXT=
+DEBUGSYMEXT=.xcoff
+SHORTSUFFIX=mac
+endif
+endif
+ifneq ($(findstring $(OS_SOURCE),$(LIMIT83fs)),)
+FPCMADE=fpcmade.$(SHORTSUFFIX)
+ZIPSUFFIX=$(SHORTSUFFIX)
+ZIPCROSSPREFIX=
+ZIPSOURCESUFFIX=src
+ZIPEXAMPLESUFFIX=exm
+else
+FPCMADE=fpcmade.$(TARGETSUFFIX)
+ZIPSOURCESUFFIX=.source
+ZIPEXAMPLESUFFIX=.examples
+ifdef CROSSCOMPILE
+ZIPSUFFIX=.$(SOURCESUFFIX)
+ZIPCROSSPREFIX=$(TARGETSUFFIX)-
+else
+ZIPSUFFIX=.$(TARGETSUFFIX)
+ZIPCROSSPREFIX=
+endif
+endif
+ifndef ECHO
+ECHO:=$(strip $(wildcard $(addsuffix /gecho$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO:=$(strip $(wildcard $(addsuffix /echo$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ECHO),)
+ECHO= __missing_command_ECHO
+else
+ECHO:=$(firstword $(ECHO))
+endif
+else
+ECHO:=$(firstword $(ECHO))
+endif
+endif
+export ECHO
+ifndef DATE
+DATE:=$(strip $(wildcard $(addsuffix /gdate$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE:=$(strip $(wildcard $(addsuffix /date$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(DATE),)
+DATE= __missing_command_DATE
+else
+DATE:=$(firstword $(DATE))
+endif
+else
+DATE:=$(firstword $(DATE))
+endif
+endif
+export DATE
+ifndef GINSTALL
+GINSTALL:=$(strip $(wildcard $(addsuffix /ginstall$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL:=$(strip $(wildcard $(addsuffix /install$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(GINSTALL),)
+GINSTALL= __missing_command_GINSTALL
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+else
+GINSTALL:=$(firstword $(GINSTALL))
+endif
+endif
+export GINSTALL
+ifndef CPPROG
+CPPROG:=$(strip $(wildcard $(addsuffix /cp$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(CPPROG),)
+CPPROG= __missing_command_CPPROG
+else
+CPPROG:=$(firstword $(CPPROG))
+endif
+endif
+export CPPROG
+ifndef RMPROG
+RMPROG:=$(strip $(wildcard $(addsuffix /rm$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(RMPROG),)
+RMPROG= __missing_command_RMPROG
+else
+RMPROG:=$(firstword $(RMPROG))
+endif
+endif
+export RMPROG
+ifndef MVPROG
+MVPROG:=$(strip $(wildcard $(addsuffix /mv$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MVPROG),)
+MVPROG= __missing_command_MVPROG
+else
+MVPROG:=$(firstword $(MVPROG))
+endif
+endif
+export MVPROG
+ifndef MKDIRPROG
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /gmkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG:=$(strip $(wildcard $(addsuffix /mkdir$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(MKDIRPROG),)
+MKDIRPROG= __missing_command_MKDIRPROG
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+else
+MKDIRPROG:=$(firstword $(MKDIRPROG))
+endif
+endif
+export MKDIRPROG
+ifndef ECHOREDIR
+ifndef inUnix
+ECHOREDIR=echo
+else
+ECHOREDIR=$(ECHO)
+endif
+endif
+ifndef COPY
+COPY:=$(CPPROG) -fp
+endif
+ifndef COPYTREE
+COPYTREE:=$(CPPROG) -Rfp
+endif
+ifndef MKDIRTREE
+MKDIRTREE:=$(MKDIRPROG) -p
+endif
+ifndef MOVE
+MOVE:=$(MVPROG) -f
+endif
+ifndef DEL
+DEL:=$(RMPROG) -f
+endif
+ifndef DELTREE
+DELTREE:=$(RMPROG) -rf
+endif
+ifndef INSTALL
+ifdef inUnix
+INSTALL:=$(GINSTALL) -c -m 644
+else
+INSTALL:=$(COPY)
+endif
+endif
+ifndef INSTALLEXE
+ifdef inUnix
+INSTALLEXE:=$(GINSTALL) -c -m 755
+else
+INSTALLEXE:=$(COPY)
+endif
+endif
+ifndef MKDIR
+MKDIR:=$(GINSTALL) -m 755 -d
+endif
+export ECHOREDIR COPY COPYTREE MOVE DEL DELTREE INSTALL INSTALLEXE MKDIR
+ifndef PPUMOVE
+PPUMOVE:=$(strip $(wildcard $(addsuffix /ppumove$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(PPUMOVE),)
+PPUMOVE= __missing_command_PPUMOVE
+else
+PPUMOVE:=$(firstword $(PPUMOVE))
+endif
+endif
+export PPUMOVE
+ifndef FPCMAKE
+FPCMAKE:=$(strip $(wildcard $(addsuffix /fpcmake$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(FPCMAKE),)
+FPCMAKE= __missing_command_FPCMAKE
+else
+FPCMAKE:=$(firstword $(FPCMAKE))
+endif
+endif
+export FPCMAKE
+ifndef ZIPPROG
+ZIPPROG:=$(strip $(wildcard $(addsuffix /zip$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(ZIPPROG),)
+ZIPPROG= __missing_command_ZIPPROG
+else
+ZIPPROG:=$(firstword $(ZIPPROG))
+endif
+endif
+export ZIPPROG
+ifndef TARPROG
+TARPROG:=$(strip $(wildcard $(addsuffix /gtar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG:=$(strip $(wildcard $(addsuffix /tar$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(TARPROG),)
+TARPROG= __missing_command_TARPROG
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+else
+TARPROG:=$(firstword $(TARPROG))
+endif
+endif
+export TARPROG
+ASNAME=$(BINUTILSPREFIX)as
+LDNAME=$(BINUTILSPREFIX)ld
+ARNAME=$(BINUTILSPREFIX)ar
+RCNAME=$(BINUTILSPREFIX)rc
+ifneq ($(findstring 1.0.,$(FPC_VERSION)),)
+ifeq ($(OS_TARGET),win32)
+ifeq ($(CROSSBINDIR),)
+ASNAME=asw
+LDNAME=ldw
+ARNAME=arw
+endif
+endif
+endif
+ifndef ASPROG
+ifdef CROSSBINDIR
+ASPROG=$(CROSSBINDIR)/$(ASNAME)$(SRCEXEEXT)
+else
+ASPROG=$(ASNAME)
+endif
+endif
+ifndef LDPROG
+ifdef CROSSBINDIR
+LDPROG=$(CROSSBINDIR)/$(LDNAME)$(SRCEXEEXT)
+else
+LDPROG=$(LDNAME)
+endif
+endif
+ifndef RCPROG
+ifdef CROSSBINDIR
+RCPROG=$(CROSSBINDIR)/$(RCNAME)$(SRCEXEEXT)
+else
+RCPROG=$(RCNAME)
+endif
+endif
+ifndef ARPROG
+ifdef CROSSBINDIR
+ARPROG=$(CROSSBINDIR)/$(ARNAME)$(SRCEXEEXT)
+else
+ARPROG=$(ARNAME)
+endif
+endif
+AS=$(ASPROG)
+LD=$(LDPROG)
+RC=$(RCPROG)
+AR=$(ARPROG)
+PPAS=ppas$(SRCBATCHEXT)
+ifdef inUnix
+LDCONFIG=ldconfig
+else
+LDCONFIG=
+endif
+ifdef DATE
+DATESTR:=$(shell $(DATE) +%Y%m%d)
+else
+DATESTR=
+endif
+ifndef UPXPROG
+ifeq ($(OS_TARGET),go32v2)
+UPXPROG:=1
+endif
+ifeq ($(OS_TARGET),win32)
+UPXPROG:=1
+endif
+ifdef UPXPROG
+UPXPROG:=$(strip $(wildcard $(addsuffix /upx$(SRCEXEEXT),$(SEARCHPATH))))
+ifeq ($(UPXPROG),)
+UPXPROG=
+else
+UPXPROG:=$(firstword $(UPXPROG))
+endif
+else
+UPXPROG=
+endif
+endif
+export UPXPROG
+ZIPOPT=-9
+ZIPEXT=.zip
+ifeq ($(USETAR),bz2)
+TAROPT=vj
+TAREXT=.tar.bz2
+else
+TAROPT=vz
+TAREXT=.tar.gz
+endif
+override REQUIRE_PACKAGES=rtl 
+ifeq ($(FULL_TARGET),i386-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-go32v2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-win32)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-os2)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-beos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-qnx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netware)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-openbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-wdosx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-emx)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-watcom)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-netwlibc)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),i386-wince)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-atari)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-openbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),m68k-palmos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-amiga)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-macos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-darwin)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc-morphos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-netbsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),sparc-solaris)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-freebsd)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),x86_64-win64)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-palmos)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-wince)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),arm-gba)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifeq ($(FULL_TARGET),powerpc64-linux)
+REQUIRE_PACKAGES_RTL=1
+endif
+ifdef REQUIRE_PACKAGES_RTL
+PACKAGEDIR_RTL:=$(firstword $(subst /Makefile.fpc,,$(strip $(wildcard $(addsuffix /rtl/Makefile.fpc,$(PACKAGESDIR))))))
+ifneq ($(PACKAGEDIR_RTL),)
+ifneq ($(wildcard $(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)),)
+UNITDIR_RTL=$(PACKAGEDIR_RTL)/units/$(TARGETSUFFIX)
+else
+UNITDIR_RTL=$(PACKAGEDIR_RTL)
+endif
+ifdef CHECKDEPEND
+$(PACKAGEDIR_RTL)/$(FPCMADE):
+	$(MAKE) -C $(PACKAGEDIR_RTL) $(FPCMADE)
+override ALLDEPENDENCIES+=$(PACKAGEDIR_RTL)/$(FPCMADE)
+endif
+else
+PACKAGEDIR_RTL=
+UNITDIR_RTL:=$(subst /Package.fpc,,$(strip $(wildcard $(addsuffix /rtl/Package.fpc,$(UNITSDIR)))))
+ifneq ($(UNITDIR_RTL),)
+UNITDIR_RTL:=$(firstword $(UNITDIR_RTL))
+else
+UNITDIR_RTL=
+endif
+endif
+ifdef UNITDIR_RTL
+override COMPILER_UNITDIR+=$(UNITDIR_RTL)
+endif
+endif
+ifndef NOCPUDEF
+override FPCOPTDEF=$(CPU_TARGET)
+endif
+ifneq ($(OS_TARGET),$(OS_SOURCE))
+override FPCOPT+=-T$(OS_TARGET)
+endif
+ifneq ($(CPU_TARGET),$(CPU_SOURCE))
+override FPCOPT+=-P$(CPU_TARGET)
+endif
+ifeq ($(OS_SOURCE),openbsd)
+override FPCOPT+=-FD$(NEW_BINUTILS_PATH)
+endif
+ifndef CROSSBOOTSTRAP
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-XP$(BINUTILSPREFIX) -Xc
+endif
+ifneq ($(BINUTILSPREFIX),)
+override FPCOPT+=-Xr$(RLINKPATH)
+endif
+endif
+ifdef UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(UNITDIR))
+endif
+ifdef LIBDIR
+override FPCOPT+=$(addprefix -Fl,$(LIBDIR))
+endif
+ifdef OBJDIR
+override FPCOPT+=$(addprefix -Fo,$(OBJDIR))
+endif
+ifdef INCDIR
+override FPCOPT+=$(addprefix -Fi,$(INCDIR))
+endif
+ifdef LINKSMART
+override FPCOPT+=-XX
+endif
+ifdef CREATESMART
+override FPCOPT+=-CX
+endif
+ifdef DEBUG
+override FPCOPT+=-gl
+override FPCOPTDEF+=DEBUG
+endif
+ifdef RELEASE
+ifneq ($(findstring 2.0.,$(FPC_VERSION)),)
+ifeq ($(CPU_TARGET),i386)
+FPCCPUOPT:=-OG2p3
+endif
+ifeq ($(CPU_TARGET),powerpc)
+FPCCPUOPT:=-O1r
+endif
+else
+FPCCPUOPT:=-O1r
+endif
+override FPCOPT+=-Ur -Xs $(FPCCPUOPT) -n
+override FPCOPTDEF+=RELEASE
+endif
+ifdef STRIP
+override FPCOPT+=-Xs
+endif
+ifdef OPTIMIZE
+override FPCOPT+=-O2
+endif
+ifdef VERBOSE
+override FPCOPT+=-vwni
+endif
+ifdef COMPILER_OPTIONS
+override FPCOPT+=$(COMPILER_OPTIONS)
+endif
+ifdef COMPILER_UNITDIR
+override FPCOPT+=$(addprefix -Fu,$(COMPILER_UNITDIR))
+endif
+ifdef COMPILER_LIBRARYDIR
+override FPCOPT+=$(addprefix -Fl,$(COMPILER_LIBRARYDIR))
+endif
+ifdef COMPILER_OBJECTDIR
+override FPCOPT+=$(addprefix -Fo,$(COMPILER_OBJECTDIR))
+endif
+ifdef COMPILER_INCLUDEDIR
+override FPCOPT+=$(addprefix -Fi,$(COMPILER_INCLUDEDIR))
+endif
+ifdef CROSSBINDIR
+override FPCOPT+=-FD$(CROSSBINDIR)
+endif
+ifdef COMPILER_TARGETDIR
+override FPCOPT+=-FE$(COMPILER_TARGETDIR)
+ifeq ($(COMPILER_TARGETDIR),.)
+override TARGETDIRPREFIX=
+else
+override TARGETDIRPREFIX=$(COMPILER_TARGETDIR)/
+endif
+endif
+ifdef COMPILER_UNITTARGETDIR
+override FPCOPT+=-FU$(COMPILER_UNITTARGETDIR)
+ifeq ($(COMPILER_UNITTARGETDIR),.)
+override UNITTARGETDIRPREFIX=
+else
+override UNITTARGETDIRPREFIX=$(COMPILER_UNITTARGETDIR)/
+endif
+else
+ifdef COMPILER_TARGETDIR
+override COMPILER_UNITTARGETDIR=$(COMPILER_TARGETDIR)
+override UNITTARGETDIRPREFIX=$(TARGETDIRPREFIX)
+endif
+endif
+ifdef CREATESHARED
+override FPCOPT+=-Cg
+ifeq ($(CPU_TARGET),i386)
+override FPCOPT+=-Aas
+endif
+endif
+ifdef LINKSHARED
+endif
+ifdef GCCLIBDIR
+override FPCOPT+=-Fl$(GCCLIBDIR)
+endif
+ifdef OTHERLIBDIR
+override FPCOPT+=$(addprefix -Fl,$(OTHERLIBDIR))
+endif
+ifdef OPT
+override FPCOPT+=$(OPT)
+endif
+ifdef FPCOPTDEF
+override FPCOPT+=$(addprefix -d,$(FPCOPTDEF))
+endif
+ifdef CFGFILE
+override FPCOPT+=@$(CFGFILE)
+endif
+ifdef USEENV
+override FPCEXTCMD:=$(FPCOPT)
+override FPCOPT:=!FPCEXTCMD
+export FPCEXTCMD
+endif
+override AFULL_TARGET=$(CPU_TARGET)-$(OS_TARGET)
+override AFULL_SOURCE=$(CPU_SOURCE)-$(OS_SOURCE)
+ifneq ($(AFULL_TARGET),$(AFULL_SOURCE))
+override ACROSSCOMPILE=1
+endif
+ifdef ACROSSCOMPILE
+override FPCOPT+=$(CROSSOPT)
+endif
+override COMPILER:=$(FPC) $(FPCOPT)
+ifeq (,$(findstring -s ,$(COMPILER)))
+EXECPPAS=
+else
+ifeq ($(FULL_SOURCE),$(FULL_TARGET))
+EXECPPAS:=@$(PPAS)
+endif
+endif
+.PHONY: fpc_units
+ifneq ($(TARGET_UNITS),)
+override ALLTARGET+=fpc_units
+override UNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_UNITS))
+override IMPLICITUNITPPUFILES=$(addsuffix $(PPUEXT),$(TARGET_IMPLICITUNITS))
+override INSTALLPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+override CLEANPPUFILES+=$(UNITPPUFILES) $(IMPLICITUNITPPUFILES)
+endif
+fpc_units: $(COMPILER_UNITTARGETDIR) $(UNITPPUFILES)
+ifdef TARGET_RSTS
+override RSTFILES=$(addsuffix $(RSTEXT),$(TARGET_RSTS))
+override CLEANRSTFILES+=$(RSTFILES)
+endif
+.PHONY: fpc_all fpc_smart fpc_debug fpc_release fpc_shared
+$(FPCMADE): $(ALLDEPENDENCIES) $(ALLTARGET)
+	@$(ECHOREDIR) Compiled > $(FPCMADE)
+fpc_all: $(FPCMADE)
+fpc_smart:
+	$(MAKE) all LINKSMART=1 CREATESMART=1
+fpc_debug:
+	$(MAKE) all DEBUG=1
+fpc_release:
+	$(MAKE) all RELEASE=1
+.SUFFIXES: $(EXEEXT) $(PPUEXT) $(OEXT) .pas .lpr .dpr .pp .rc .res
+$(COMPILER_UNITTARGETDIR):
+	$(MKDIRTREE) $(COMPILER_UNITTARGETDIR)
+$(COMPILER_TARGETDIR):
+	$(MKDIRTREE) $(COMPILER_TARGETDIR)
+%$(PPUEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(PPUEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pp
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.pas
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.lpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%$(EXEEXT): %.dpr
+	$(COMPILER) $<
+	$(EXECPPAS)
+%.res: %.rc
+	windres -i $< -o $@
+vpath %.pp $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.pas $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.lpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %.dpr $(COMPILER_SOURCEDIR) $(COMPILER_INCLUDEDIR)
+vpath %$(OEXT) $(COMPILER_UNITTARGETDIR)
+vpath %$(PPUEXT) $(COMPILER_UNITTARGETDIR)
+.PHONY: fpc_shared
+override INSTALLTARGET+=fpc_shared_install
+ifndef SHARED_LIBVERSION
+SHARED_LIBVERSION=$(FPC_VERSION)
+endif
+ifndef SHARED_LIBNAME
+SHARED_LIBNAME=$(PACKAGE_NAME)
+endif
+ifndef SHARED_FULLNAME
+SHARED_FULLNAME=$(SHAREDLIBPREFIX)$(SHARED_LIBNAME)-$(SHARED_LIBVERSION)$(SHAREDLIBEXT)
+endif
+ifndef SHARED_LIBUNITS
+SHARED_LIBUNITS:=$(TARGET_UNITS) $(TARGET_IMPLICITUNITS)
+override SHARED_LIBUNITS:=$(filter-out $(INSTALL_BUILDUNIT),$(SHARED_LIBUNITS))
+endif
+fpc_shared:
+ifdef HASSHAREDLIB
+	$(MAKE) all CREATESHARED=1 LINKSHARED=1 CREATESMART=1
+ifneq ($(SHARED_BUILD),n)
+	$(PPUMOVE) -q $(SHARED_LIBUNITS) -i$(COMPILER_UNITTARGETDIR) -o$(SHARED_FULLNAME) -d$(COMPILER_UNITTARGETDIR)
+endif
+else
+	@$(ECHO) Shared Libraries not supported
+endif
+fpc_shared_install:
+ifneq ($(SHARED_BUILD),n)
+ifneq ($(SHARED_LIBUNITS),)
+ifneq ($(wildcard $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME)),)
+	$(INSTALL) $(COMPILER_UNITTARGETDIR)/$(SHARED_FULLNAME) $(INSTALL_SHAREDDIR)
+endif
+endif
+endif
+.PHONY: fpc_install fpc_sourceinstall fpc_exampleinstall
+ifdef INSTALL_UNITS
+override INSTALLPPUFILES+=$(addsuffix $(PPUEXT),$(INSTALL_UNITS))
+endif
+ifdef INSTALL_BUILDUNIT
+override INSTALLPPUFILES:=$(filter-out $(INSTALL_BUILDUNIT)$(PPUEXT),$(INSTALLPPUFILES))
+endif
+ifdef INSTALLPPUFILES
+override INSTALLPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(INSTALLPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(INSTALLPPUFILES)))
+ifneq ($(UNITTARGETDIRPREFIX),)
+override INSTALLPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPUFILES)))
+override INSTALLPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(notdir $(INSTALLPPULINKFILES))))
+endif
+override INSTALL_CREATEPACKAGEFPC=1
+endif
+ifdef INSTALLEXEFILES
+ifneq ($(TARGETDIRPREFIX),)
+override INSTALLEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(notdir $(INSTALLEXEFILES)))
+endif
+endif
+fpc_install: all $(INSTALLTARGET)
+ifdef INSTALLEXEFILES
+	$(MKDIR) $(INSTALL_BINDIR)
+ifdef UPXPROG
+	-$(UPXPROG) $(INSTALLEXEFILES)
+endif
+	$(INSTALLEXE) $(INSTALLEXEFILES) $(INSTALL_BINDIR)
+endif
+ifdef INSTALL_CREATEPACKAGEFPC
+ifdef FPCMAKE
+ifdef PACKAGE_VERSION
+ifneq ($(wildcard Makefile.fpc),)
+	$(FPCMAKE) -p -T$(CPU_TARGET)-$(OS_TARGET) Makefile.fpc
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) Package.fpc $(INSTALL_UNITDIR)
+endif
+endif
+endif
+endif
+ifdef INSTALLPPUFILES
+	$(MKDIR) $(INSTALL_UNITDIR)
+	$(INSTALL) $(INSTALLPPUFILES) $(INSTALL_UNITDIR)
+ifneq ($(INSTALLPPULINKFILES),)
+	$(INSTALL) $(INSTALLPPULINKFILES) $(INSTALL_UNITDIR)
+endif
+ifneq ($(wildcard $(LIB_FULLNAME)),)
+	$(MKDIR) $(INSTALL_LIBDIR)
+	$(INSTALL) $(LIB_FULLNAME) $(INSTALL_LIBDIR)
+ifdef inUnix
+	ln -sf $(LIB_FULLNAME) $(INSTALL_LIBDIR)/$(LIB_NAME)
+endif
+endif
+endif
+ifdef INSTALL_FILES
+	$(MKDIR) $(INSTALL_DATADIR)
+	$(INSTALL) $(INSTALL_FILES) $(INSTALL_DATADIR)
+endif
+fpc_sourceinstall: distclean
+	$(MKDIR) $(INSTALL_SOURCEDIR)
+	$(COPYTREE) $(BASEDIR)/* $(INSTALL_SOURCEDIR)
+fpc_exampleinstall: $(addsuffix _distclean,$(TARGET_EXAMPLEDIRS))
+ifdef HASEXAMPLES
+	$(MKDIR) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef EXAMPLESOURCEFILES
+	$(COPY) $(EXAMPLESOURCEFILES) $(INSTALL_EXAMPLEDIR)
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(COPYTREE) $(addsuffix /*,$(TARGET_EXAMPLEDIRS)) $(INSTALL_EXAMPLEDIR)
+endif
+.PHONY: fpc_distinstall
+fpc_distinstall: install exampleinstall
+.PHONY: fpc_zipinstall fpc_zipsourceinstall fpc_zipexampleinstall
+ifndef PACKDIR
+ifndef inUnix
+PACKDIR=$(BASEDIR)/../fpc-pack
+else
+PACKDIR=/tmp/fpc-pack
+endif
+endif
+ifndef ZIPNAME
+ifdef DIST_ZIPNAME
+ZIPNAME=$(DIST_ZIPNAME)
+else
+ZIPNAME=$(PACKAGE_NAME)
+endif
+endif
+ifndef FULLZIPNAME
+FULLZIPNAME=$(ZIPCROSSPREFIX)$(ZIPPREFIX)$(ZIPNAME)$(ZIPSUFFIX)
+endif
+ifndef ZIPTARGET
+ifdef DIST_ZIPTARGET
+ZIPTARGET=DIST_ZIPTARGET
+else
+ZIPTARGET=install
+endif
+endif
+ifndef USEZIP
+ifdef inUnix
+USETAR=1
+endif
+endif
+ifndef inUnix
+USEZIPWRAPPER=1
+endif
+ifdef USEZIPWRAPPER
+ZIPPATHSEP=$(PATHSEP)
+ZIPWRAPPER=$(subst /,$(PATHSEP),$(DIST_DESTDIR)/fpczip$(SRCBATCHEXT))
+else
+ZIPPATHSEP=/
+endif
+ZIPCMD_CDPACK:=cd $(subst /,$(ZIPPATHSEP),$(PACKDIR))
+ZIPCMD_CDBASE:=cd $(subst /,$(ZIPPATHSEP),$(BASEDIR))
+ifdef USETAR
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(TAREXT)
+ZIPCMD_ZIP:=$(TARPROG) cf$(TAROPT) $(ZIPDESTFILE) *
+else
+ZIPDESTFILE:=$(DIST_DESTDIR)/$(FULLZIPNAME)$(ZIPEXT)
+ZIPCMD_ZIP:=$(subst /,$(ZIPPATHSEP),$(ZIPPROG)) -Dr $(ZIPOPT) $(ZIPDESTFILE) *
+endif
+fpc_zipinstall:
+	$(MAKE) $(ZIPTARGET) INSTALL_PREFIX=$(PACKDIR) ZIPINSTALL=1
+	$(MKDIR) $(DIST_DESTDIR)
+	$(DEL) $(ZIPDESTFILE)
+ifdef USEZIPWRAPPER
+ifneq ($(ECHOREDIR),echo)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDPACK))" > $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_ZIP))" >> $(ZIPWRAPPER)
+	$(ECHOREDIR) -e "$(subst \,\\,$(ZIPCMD_CDBASE))" >> $(ZIPWRAPPER)
+else
+	echo $(ZIPCMD_CDPACK) > $(ZIPWRAPPER)
+	echo $(ZIPCMD_ZIP) >> $(ZIPWRAPPER)
+	echo $(ZIPCMD_CDBASE) >> $(ZIPWRAPPER)
+endif
+ifdef inUnix
+	/bin/sh $(ZIPWRAPPER)
+else
+	$(ZIPWRAPPER)
+endif
+	$(DEL) $(ZIPWRAPPER)
+else
+	$(ZIPCMD_CDPACK) ; $(ZIPCMD_ZIP) ; $(ZIPCMD_CDBASE)
+endif
+	$(DELTREE) $(PACKDIR)
+fpc_zipsourceinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=sourceinstall ZIPSUFFIX=$(ZIPSOURCESUFFIX)
+fpc_zipexampleinstall:
+ifdef HASEXAMPLES
+	$(MAKE) fpc_zipinstall ZIPTARGET=exampleinstall ZIPSUFFIX=$(ZIPEXAMPLESUFFIX)
+endif
+fpc_zipdistinstall:
+	$(MAKE) fpc_zipinstall ZIPTARGET=distinstall
+.PHONY: fpc_clean fpc_cleanall fpc_distclean
+ifdef EXEFILES
+override CLEANEXEFILES:=$(addprefix $(TARGETDIRPREFIX),$(CLEANEXEFILES))
+endif
+ifdef CLEAN_UNITS
+override CLEANPPUFILES+=$(addsuffix $(PPUEXT),$(CLEAN_UNITS))
+endif
+ifdef CLEANPPUFILES
+override CLEANPPULINKFILES:=$(subst $(PPUEXT),$(OEXT),$(CLEANPPUFILES)) $(addprefix $(STATICLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES))) $(addprefix $(IMPORTLIBPREFIX),$(subst $(PPUEXT),$(STATICLIBEXT),$(CLEANPPUFILES)))
+ifdef DEBUGSYMEXT
+override CLEANPPULINKFILES+=$(subst $(PPUEXT),$(DEBUGSYMEXT),$(CLEANPPUFILES))
+endif
+override CLEANPPUFILES:=$(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPUFILES))
+override CLEANPPULINKFILES:=$(wildcard $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANPPULINKFILES)))
+endif
+fpc_clean: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+ifdef CLEAN_FILES
+	-$(DEL) $(CLEAN_FILES)
+endif
+ifdef LIB_NAME
+	-$(DEL) $(LIB_NAME) $(LIB_FULLNAME)
+endif
+	-$(DEL) $(FPCMADE) Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *$(ASMEXT) *_ppas$(BATCHEXT)
+fpc_cleanall: $(CLEANTARGET)
+ifdef CLEANEXEFILES
+	-$(DEL) $(CLEANEXEFILES)
+endif
+ifdef COMPILER_UNITTARGETDIR
+ifdef CLEANPPUFILES
+	-$(DEL) $(CLEANPPUFILES)
+endif
+ifneq ($(CLEANPPULINKFILES),)
+	-$(DEL) $(CLEANPPULINKFILES)
+endif
+ifdef CLEANRSTFILES
+	-$(DEL) $(addprefix $(UNITTARGETDIRPREFIX),$(CLEANRSTFILES))
+endif
+endif
+	-$(DELTREE) units
+	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
+ifneq ($(PPUEXT),.ppu)
+	-$(DEL) *.o *.ppu *.a
+endif
+	-$(DELTREE) *$(SMARTEXT)
+	-$(DEL) fpcmade.* Package.fpc $(PPAS) script.res link.res $(FPCEXTFILE) $(REDIRFILE)
+	-$(DEL) *_ppas$(BATCHEXT)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
+ifdef DEBUGSYMEXT
+	-$(DEL) *$(DEBUGSYMEXT)
+endif
+fpc_distclean: cleanall
+.PHONY: fpc_baseinfo
+override INFORULES+=fpc_baseinfo
+fpc_baseinfo:
+	@$(ECHO)
+	@$(ECHO)  == Package info ==
+	@$(ECHO)  Package Name..... $(PACKAGE_NAME)
+	@$(ECHO)  Package Version.. $(PACKAGE_VERSION)
+	@$(ECHO)
+	@$(ECHO)  == Configuration info ==
+	@$(ECHO)
+	@$(ECHO)  FPC.......... $(FPC)
+	@$(ECHO)  FPC Version.. $(FPC_VERSION)
+	@$(ECHO)  Source CPU... $(CPU_SOURCE)
+	@$(ECHO)  Target CPU... $(CPU_TARGET)
+	@$(ECHO)  Source OS.... $(OS_SOURCE)
+	@$(ECHO)  Target OS.... $(OS_TARGET)
+	@$(ECHO)  Full Source.. $(FULL_SOURCE)
+	@$(ECHO)  Full Target.. $(FULL_TARGET)
+	@$(ECHO)  SourceSuffix. $(SOURCESUFFIX)
+	@$(ECHO)  TargetSuffix. $(TARGETSUFFIX)
+	@$(ECHO)
+	@$(ECHO)  == Directory info ==
+	@$(ECHO)
+	@$(ECHO)  Required pkgs... $(REQUIRE_PACKAGES)
+	@$(ECHO)
+	@$(ECHO)  Basedir......... $(BASEDIR)
+	@$(ECHO)  FPCDir.......... $(FPCDIR)
+	@$(ECHO)  CrossBinDir..... $(CROSSBINDIR)
+	@$(ECHO)  UnitsDir........ $(UNITSDIR)
+	@$(ECHO)  PackagesDir..... $(PACKAGESDIR)
+	@$(ECHO)
+	@$(ECHO)  GCC library..... $(GCCLIBDIR)
+	@$(ECHO)  Other library... $(OTHERLIBDIR)
+	@$(ECHO)
+	@$(ECHO)  == Tools info ==
+	@$(ECHO)
+	@$(ECHO)  As........ $(AS)
+	@$(ECHO)  Ld........ $(LD)
+	@$(ECHO)  Ar........ $(AR)
+	@$(ECHO)  Rc........ $(RC)
+	@$(ECHO)
+	@$(ECHO)  Mv........ $(MVPROG)
+	@$(ECHO)  Cp........ $(CPPROG)
+	@$(ECHO)  Rm........ $(RMPROG)
+	@$(ECHO)  GInstall.. $(GINSTALL)
+	@$(ECHO)  Echo...... $(ECHO)
+	@$(ECHO)  Shell..... $(SHELL)
+	@$(ECHO)  Date...... $(DATE)
+	@$(ECHO)  FPCMake... $(FPCMAKE)
+	@$(ECHO)  PPUMove... $(PPUMOVE)
+	@$(ECHO)  Upx....... $(UPXPROG)
+	@$(ECHO)  Zip....... $(ZIPPROG)
+	@$(ECHO)
+	@$(ECHO)  == Object info ==
+	@$(ECHO)
+	@$(ECHO)  Target Loaders........ $(TARGET_LOADERS)
+	@$(ECHO)  Target Units.......... $(TARGET_UNITS)
+	@$(ECHO)  Target Implicit Units. $(TARGET_IMPLICITUNITS)
+	@$(ECHO)  Target Programs....... $(TARGET_PROGRAMS)
+	@$(ECHO)  Target Dirs........... $(TARGET_DIRS)
+	@$(ECHO)  Target Examples....... $(TARGET_EXAMPLES)
+	@$(ECHO)  Target ExampleDirs.... $(TARGET_EXAMPLEDIRS)
+	@$(ECHO)
+	@$(ECHO)  Clean Units......... $(CLEAN_UNITS)
+	@$(ECHO)  Clean Files......... $(CLEAN_FILES)
+	@$(ECHO)
+	@$(ECHO)  Install Units....... $(INSTALL_UNITS)
+	@$(ECHO)  Install Files....... $(INSTALL_FILES)
+	@$(ECHO)
+	@$(ECHO)  == Install info ==
+	@$(ECHO)
+	@$(ECHO)  DateStr.............. $(DATESTR)
+	@$(ECHO)  ZipName.............. $(ZIPNAME)
+	@$(ECHO)  ZipPrefix............ $(ZIPPREFIX)
+	@$(ECHO)  ZipCrossPrefix....... $(ZIPCROSSPREFIX)
+	@$(ECHO)  ZipSuffix............ $(ZIPSUFFIX)
+	@$(ECHO)  FullZipName.......... $(FULLZIPNAME)
+	@$(ECHO)  Install FPC Package.. $(INSTALL_FPCPACKAGE)
+	@$(ECHO)
+	@$(ECHO)  Install base dir..... $(INSTALL_BASEDIR)
+	@$(ECHO)  Install binary dir... $(INSTALL_BINDIR)
+	@$(ECHO)  Install library dir.. $(INSTALL_LIBDIR)
+	@$(ECHO)  Install units dir.... $(INSTALL_UNITDIR)
+	@$(ECHO)  Install source dir... $(INSTALL_SOURCEDIR)
+	@$(ECHO)  Install doc dir...... $(INSTALL_DOCDIR)
+	@$(ECHO)  Install example dir.. $(INSTALL_EXAMPLEDIR)
+	@$(ECHO)  Install data dir..... $(INSTALL_DATADIR)
+	@$(ECHO)
+	@$(ECHO)  Dist destination dir. $(DIST_DESTDIR)
+	@$(ECHO)  Dist zip name........ $(DIST_ZIPNAME)
+	@$(ECHO)
+.PHONY: fpc_info
+fpc_info: $(INFORULES)
+.PHONY: fpc_makefile fpc_makefiles fpc_makefile_sub1 fpc_makefile_sub2 \
+	fpc_makefile_dirs
+fpc_makefile:
+	$(FPCMAKE) -w -T$(OS_TARGET) Makefile.fpc
+fpc_makefile_sub1:
+ifdef TARGET_DIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_DIRS))
+endif
+ifdef TARGET_EXAMPLEDIRS
+	$(FPCMAKE) -w -T$(OS_TARGET) $(addsuffix /Makefile.fpc,$(TARGET_EXAMPLEDIRS))
+endif
+fpc_makefile_sub2: $(addsuffix _makefile_dirs,$(TARGET_DIRS) $(TARGET_EXAMPLEDIRS))
+fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
+fpc_makefiles: fpc_makefile fpc_makefile_dirs
+all: fpc_all
+debug: fpc_debug
+smart: fpc_smart
+release: fpc_release
+units: fpc_units
+examples:
+shared: fpc_shared
+install: fpc_install
+sourceinstall: fpc_sourceinstall
+exampleinstall: fpc_exampleinstall
+distinstall: fpc_distinstall
+zipinstall: fpc_zipinstall
+zipsourceinstall: fpc_zipsourceinstall
+zipexampleinstall: fpc_zipexampleinstall
+zipdistinstall: fpc_zipdistinstall
+clean: fpc_clean
+distclean: fpc_distclean
+cleanall: fpc_cleanall
+info: fpc_info
+makefiles: fpc_makefiles
+.PHONY: all debug smart release units examples shared install sourceinstall exampleinstall distinstall zipinstall zipsourceinstall zipexampleinstall zipdistinstall clean distclean cleanall info makefiles
+ifneq ($(wildcard fpcmake.loc),)
+include fpcmake.loc
+endif

+ 19 - 0
packages/base/httpd/httpd-2.2/Makefile.fpc

@@ -0,0 +1,19 @@
+#
+#  Makefile.fpc for httpd 2.2 unit
+#
+
+[package]
+name=httpd-2.2
+version=2.0.4
+
+[target]
+units=apr/apr apriconv/apriconv aprutil/aprutil httpd
+
+[require]
+libc=y
+
+[install]
+fpcpackage=y
+
+[default]
+fpcdir=../../../..

+ 255 - 0
packages/base/httpd/httpd-2.2/ap_config.inc

@@ -0,0 +1,255 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{#include "apr.h"
+#include "apr_hooks.h"
+#include "apr_optional_hooks.h"}
+
+{
+ * @file ap_config.h
+ * @brief Symbol export macros and hook functions
+ }
+
+{ Although this file doesn't declare any hooks, declare the hook group here }
+{ @defgroup hooks Apache Hooks }
+
+{$ifdef DOXYGEN}
+{ define these just so doxygen documents them }
+
+{
+ * AP_DECLARE_STATIC is defined when including Apache's Core headers,
+ * to provide static linkage when the dynamic library may be unavailable.
+ *
+ * @see AP_DECLARE_EXPORT
+ *
+ * AP_DECLARE_STATIC and AP_DECLARE_EXPORT are left undefined when
+ * including Apache's Core headers, to import and link the symbols from the
+ * dynamic Apache Core library and assure appropriate indirection and calling
+ * conventions at compile time.
+ }
+{$define AP_DECLARE_STATIC}
+{
+ * AP_DECLARE_EXPORT is defined when building the Apache Core dynamic
+ * library, so that all public symbols are exported.
+ *
+ * @see AP_DECLARE_STATIC
+ }
+{$define AP_DECLARE_EXPORT}
+
+{$endif} { def DOXYGEN }
+
+//#if !defined(WIN32)
+{
+ * Apache Core dso functions are declared with AP_DECLARE(), so they may
+ * use the most appropriate calling convention.  Hook functions and other
+ * Core functions with variable arguments must use AP_DECLARE_NONSTD().
+ * @code
+ * AP_DECLARE(rettype) ap_func(args)
+ * @endcode
+ }
+//#define AP_DECLARE(type)            type
+
+{
+ * Apache Core dso variable argument and hook functions are declared with
+ * AP_DECLARE_NONSTD(), as they must use the C language calling convention.
+ * @see AP_DECLARE
+ * @code
+ * AP_DECLARE_NONSTD(rettype) ap_func(args [...])
+ * @endcode
+ }
+//#define AP_DECLARE_NONSTD(type)     type
+
+{
+ * Apache Core dso variables are declared with AP_MODULE_DECLARE_DATA.
+ * This assures the appropriate indirection is invoked at compile time.
+ *
+ * @note AP_DECLARE_DATA extern type apr_variable; syntax is required for
+ * declarations within headers to properly import the variable.
+ * @code
+ * AP_DECLARE_DATA type apr_variable
+ * @endcode
+ }
+{#define AP_DECLARE_DATA
+
+#elif defined(AP_DECLARE_STATIC)
+#define AP_DECLARE(type)            type __stdcall
+#define AP_DECLARE_NONSTD(type)     type
+#define AP_DECLARE_DATA
+#elif defined(AP_DECLARE_EXPORT)
+#define AP_DECLARE(type)            __declspec(dllexport) type __stdcall
+#define AP_DECLARE_NONSTD(type)     __declspec(dllexport) type
+#define AP_DECLARE_DATA             __declspec(dllexport)
+#else
+#define AP_DECLARE(type)            __declspec(dllimport) type __stdcall
+#define AP_DECLARE_NONSTD(type)     __declspec(dllimport) type
+#define AP_DECLARE_DATA             __declspec(dllimport)
+#endif
+
+#if !defined(WIN32) || defined(AP_MODULE_DECLARE_STATIC)}
+{
+ * Declare a dso module's exported module structure as AP_MODULE_DECLARE_DATA.
+ *
+ * Unless AP_MODULE_DECLARE_STATIC is defined at compile time, symbols
+ * declared with AP_MODULE_DECLARE_DATA are always exported.
+ * @code
+ * module AP_MODULE_DECLARE_DATA mod_tag
+ * @endcode
+ }
+{#if defined(WIN32)
+#define AP_MODULE_DECLARE(type)            type __stdcall
+#else
+#define AP_MODULE_DECLARE(type)            type
+#endif
+#define AP_MODULE_DECLARE_NONSTD(type)     type
+#define AP_MODULE_DECLARE_DATA
+#else}
+{
+ * AP_MODULE_DECLARE_EXPORT is a no-op.  Unless contradicted by the
+ * AP_MODULE_DECLARE_STATIC compile-time symbol, it is assumed and defined.
+ *
+ * The old SHARED_MODULE compile-time symbol is now the default behavior,
+ * so it is no longer referenced anywhere with Apache 2.0.
+ }
+{#define AP_MODULE_DECLARE_EXPORT
+#define AP_MODULE_DECLARE(type)          __declspec(dllexport) type __stdcall
+#define AP_MODULE_DECLARE_NONSTD(type)   __declspec(dllexport) type
+#define AP_MODULE_DECLARE_DATA           __declspec(dllexport)
+#endif}
+
+{
+ * Declare a hook function
+ * @param ret The return type of the hook
+ * @param name The hook's name (as a literal)
+ * @param args The arguments the hook function takes, in brackets.
+ }
+{#define AP_DECLARE_HOOK(ret,name,args) \
+	APR_DECLARE_EXTERNAL_HOOK(ap,AP,ret,name,args)
+}
+{ @internal }
+{#define AP_IMPLEMENT_HOOK_BASE(name) \
+	APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ap,AP,name)
+}
+{
+ * Implement an Apache core hook that has no return code, and
+ * therefore runs all of the registered functions. The implementation
+ * is called ap_run_<i>name</i>.
+ *
+ * @param name The name of the hook
+ * @param args_decl The declaration of the arguments for the hook, for example
+ * "(int x,void *y)"
+ * @param args_use The arguments for the hook as used in a call, for example
+ * "(x,y)"
+ * @note If IMPLEMENTing a hook that is not linked into the Apache core,
+ * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_VOID.
+ }
+{#define AP_IMPLEMENT_HOOK_VOID(name,args_decl,args_use) \
+	APR_IMPLEMENT_EXTERNAL_HOOK_VOID(ap,AP,name,args_decl,args_use)
+}
+{
+ * Implement an Apache core hook that runs until one of the functions
+ * returns something other than ok or decline. That return value is
+ * then returned from the hook runner. If the hooks run to completion,
+ * then ok is returned. Note that if no hook runs it would probably be
+ * more correct to return decline, but this currently does not do
+ * so. The implementation is called ap_run_<i>name</i>.
+ *
+ * @param ret The return type of the hook (and the hook runner)
+ * @param name The name of the hook
+ * @param args_decl The declaration of the arguments for the hook, for example
+ * "(int x,void *y)"
+ * @param args_use The arguments for the hook as used in a call, for example
+ * "(x,y)"
+ * @param ok The "ok" return value
+ * @param decline The "decline" return value
+ * @return ok, decline or an error.
+ * @note If IMPLEMENTing a hook that is not linked into the Apache core,
+ * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL.
+ }
+{#define AP_IMPLEMENT_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok,decline) \
+	APR_IMPLEMENT_EXTERNAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
+                                            args_use,ok,decline)
+}
+{
+ * Implement a hook that runs until a function returns something other than
+ * decline. If all functions return decline, the hook runner returns decline.
+ * The implementation is called ap_run_<i>name</i>.
+ *
+ * @param ret The return type of the hook (and the hook runner)
+ * @param name The name of the hook
+ * @param args_decl The declaration of the arguments for the hook, for example
+ * "(int x,void *y)"
+ * @param args_use The arguments for the hook as used in a call, for example
+ * "(x,y)"
+ * @param decline The "decline" return value
+ * @return decline or an error.
+ * @note If IMPLEMENTing a hook that is not linked into the Apache core
+ * (e.g. within a dso) see APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST.
+ }
+{#define AP_IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \
+	APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap,AP,ret,name,args_decl, \
+                                              args_use,decline)
+}
+{ Note that the other optional hook implementations are straightforward but
+ * have not yet been needed
+ }
+
+{
+ * Implement an optional hook. This is exactly the same as a standard hook
+ * implementation, except the hook is optional.
+ * @see AP_IMPLEMENT_HOOK_RUN_ALL
+ }
+{#define AP_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ret,name,args_decl,args_use,ok, \
+					   decline) \
+	APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap,AP,ret,name,args_decl, \
+                                            args_use,ok,decline)
+}
+{
+ * Hook an optional hook. Unlike static hooks, this uses a macro instead of a
+ * function.
+ }
+{#define AP_OPTIONAL_HOOK(name,fn,pre,succ,order) \
+        APR_OPTIONAL_HOOK(ap,name,fn,pre,succ,order)
+
+#include "os.h"
+#if !defined(WIN32) && !defined(NETWARE)
+#include "ap_config_auto.h"
+#include "ap_config_layout.h"
+#endif
+#if defined(NETWARE)
+#define AP_NONBLOCK_WHEN_MULTI_LISTEN 1
+#endif}
+
+{ TODO - We need to put OS detection back to make all the following work }
+
+{$if defined(SUNOS) or defined(IRIX) or defined(NEXT) or defined(AUX)
+ or defined (UW) or defined(LYNXOS) or defined(TPF)}
+{ These systems don't do well with any lingering close code; I don't know
+ * why -- manoj }
+{$define NO_LINGCLOSE}
+{$endif}
+
+{ If APR has OTHER_CHILD logic, use reliable piped logs. }
+{$ifdef APR_HAS_OTHER_CHILD}
+{$define AP_HAVE_RELIABLE_PIPED_LOGS}
+{$endif}
+
+{ Presume that the compiler supports C99-style designated
+ * initializers if using GCC (but not G++), or for any other compiler
+ * which claims C99 support. }
+//#if (defined(__GNUC__) && !defined(__cplusplus))                \
+//     || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
+//#define AP_HAVE_DESIGNATED_INITIALIZER
+{.$endif}

+ 141 - 0
packages/base/httpd/httpd-2.2/ap_mmn.inc

@@ -0,0 +1,141 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @package Module Magic Number
+ }
+
+{
+ * MODULE_MAGIC_NUMBER_MAJOR
+ * Major API changes that could cause compatibility problems for older modules
+ * such as structure size changes.  No binary compatibility is possible across
+ * a change in the major version.
+ *
+ * MODULE_MAGIC_NUMBER_MINOR
+ * Minor API changes that do not cause binary compatibility problems.
+ * Should be reset to 0 when upgrading MODULE_MAGIC_NUMBER_MAJOR.
+ *
+ * See the MODULE_MAGIC_AT_LEAST macro below for an example.
+ }
+
+{
+ * 20010224 (2.0.13-dev) MODULE_MAGIC_COOKIE reset to "AP20"
+ * 20010523 (2.0.19-dev) bump for scoreboard structure reordering
+ * 20010627 (2.0.19-dev) more API changes than I can count
+ * 20010726 (2.0.22-dev) more big API changes
+ * 20010808 (2.0.23-dev) dir d_is_absolute bit introduced, bucket changes, etc
+ * 20010825 (2.0.25-dev) removed d_is_absolute, introduced map_to_storage hook
+ * 20011002 (2.0.26-dev) removed 1.3-depreciated request_rec.content_language
+ * 20011127 (2.0.29-dev) bump for postconfig hook change, and removal of socket
+ *                       from connection record
+ * 20011212 (2.0.30-dev) bump for new used_path_info member of request_rec
+ * 20011218 (2.0.30-dev) bump for new sbh member of conn_rec, different
+ *                       declarations for scoreboard, new parameter to
+ *                       create_connection hook
+ * 20020102 (2.0.30-dev) bump for changed type of limit_req_body in
+ *                       core_dir_config
+ * 20020109 (2.0.31-dev) bump for changed shm and scoreboard declarations
+ * 20020111 (2.0.31-dev) bump for ETag fields added at end of cor_dir_config
+ * 20020114 (2.0.31-dev) mod_dav changed how it asks its provider to fulfill
+ *                       a GET request
+ * 20020118 (2.0.31-dev) Input filtering split of blocking and mode
+ * 20020127 (2.0.31-dev) bump for pre_mpm hook change
+ * 20020128 (2.0.31-dev) bump for pre_config hook change
+ * 20020218 (2.0.33-dev) bump for AddOutputFilterByType directive
+ * 20020220 (2.0.33-dev) bump for scoreboard.h structure change
+ * 20020302 (2.0.33-dev) bump for protocol_filter additions.
+ * 20020306 (2.0.34-dev) bump for filter type renames.
+ * 20020318 (2.0.34-dev) mod_dav's API for REPORT generation changed
+ * 20020319 (2.0.34-dev) M_INVALID changed, plus new M_* methods for RFC 3253
+ * 20020327 (2.0.35-dev) Add parameter to quick_handler hook
+ * 20020329 (2.0.35-dev) bump for addition of freelists to bucket API
+ * 20020329.1 (2.0.36) minor bump for new arg to opt fn ap_cgi_build_command
+ * 20020506 (2.0.37-dev) Removed r->boundary in request_rec.
+ * 20020529 (2.0.37-dev) Standardized the names of some apr_pool_*_set funcs
+ * 20020602 (2.0.37-dev) Bucket API change (metadata buckets)
+ * 20020612 (2.0.38-dev) Changed server_rec->[keep_alive_]timeout to apr time
+ * 20020625 (2.0.40-dev) Changed conn_rec->keepalive to an enumeration
+ * 20020628 (2.0.40-dev) Added filter_init to filter registration functions
+ * 20020903 (2.0.41-dev) APR's error constants changed
+ * 20020903.1 (2.1.0-dev) allow_encoded_slashes added to core_dir_config
+ * 20020903.2 (2.0.46-dev) add ap_escape_logitem
+ * 20030213.1 (2.1.0-dev) changed log_writer optional fn's to return previous
+ *                        handler
+ * 20030821 (2.1.0-dev) bumped mod_include's entire API
+ * 20030821.1 (2.1.0-dev) added XHTML doctypes
+ * 20030821.2 (2.1.0-dev) added ap_escape_errorlog_item
+ * 20030821.3 (2.1.0-dev) added ap_get_server_revision / ap_version_t
+ * 20040425 (2.1.0-dev) removed ap_add_named_module API
+ *                      changed ap_add_module, ap_add_loaded_module,
+ *                      ap_setup_prelinked_modules, ap_process_resource_config
+ * 20040425.1 (2.1.0-dev) Added ap_module_symbol_t and ap_prelinked_module_symbols
+ * 20050101.0 (2.1.2-dev) Axed misnamed http_method for http_scheme (which it was!)
+ * 20050127.0 (2.1.3-dev) renamed regex_t->ap_regex_t, regmatch_t->ap_regmatch_t,
+ *                        REG_*->AP_REG_*, removed reg* in place of ap_reg*;
+ *                        added ap_regex.h
+ * 20050217.0 (2.1.3-dev) Axed find_child_by_pid, mpm_*_completion_context (winnt mpm)
+ *                        symbols from the public sector, and decorated real_exit_code
+ *                        with ap_ in the win32 os.h.
+ * 20050305.0 (2.1.4-dev) added pid and generation fields to worker_score
+ * 20050305.1 (2.1.5-dev) added ap_vhost_iterate_given_conn.
+ * 20050305.2 (2.1.5-dev) added AP_INIT_TAKE_ARGV.
+ * 20050305.3 (2.1.5-dev) added Protocol Framework.
+ * 20050701.0 (2.1.7-dev) Bump MODULE_MAGIC_COOKIE to "AP21"!
+ * 20050701.1 (2.1.7-dev) trace_enable member added to core server_config
+ * 20050708.0 (2.1.7-dev) Bump MODULE_MAGIC_COOKIE to "AP22"!
+ * 20050708.1 (2.1.7-dev) add proxy request_status hook (minor)
+ * 20051006.0 (2.1.8-dev) NET_TIME filter eliminated
+ * 20051115.0 (2.1.10-dev/2.2.0) add use_canonical_phys_port to core_dir_config
+ * 20051115.1 (2.2.1)  flush_packets and flush_wait members added to
+ *                         proxy_server (minor)
+ * 20051115.2 (2.2.2)  added inreslist member to proxy_conn_rec (minor)
+ * 20051115.3 (2.2.3)  Added server_scheme member to server_rec (minor)
+ }
+const
+
+  MODULE_MAGIC_COOKIE = $41503232; { "AP22" }
+
+  MODULE_MAGIC_NUMBER_MAJOR = 20051115; { For 2.2.3 }
+
+  MODULE_MAGIC_NUMBER_MINOR = 3;                    // 0...n
+
+{
+ * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
+ * specified value.
+ * <pre>
+ * Useful for testing for features.
+ * For example, suppose you wish to use the apr_table_overlap
+ *    function.  You can do this:
+ * 
+ * #if AP_MODULE_MAGIC_AT_LEAST(19980812,2)
+ *     ... use apr_table_overlap()
+ * #else
+ *     ... alternative code which doesn't use apr_table_overlap()
+ * #endif
+ * </pre>
+ * @param major The major module magic number
+ * @param minor The minor module magic number
+ * @deffunc AP_MODULE_MAGIC_AT_LEAST(int major, int minor)
+ }
+{#define AP_MODULE_MAGIC_AT_LEAST(major,minor)		\
+    ((major) < MODULE_MAGIC_NUMBER_MAJOR 		\
+	|| ((major) == MODULE_MAGIC_NUMBER_MAJOR 	\
+	    && (minor) <= MODULE_MAGIC_NUMBER_MINOR))}
+
+{ @deprecated present for backwards compatibility }
+  MODULE_MAGIC_NUMBER = MODULE_MAGIC_NUMBER_MAJOR;
+//#define MODULE_MAGIC_AT_LEAST old_broken_macro_we_hope_you_are_not_using
+

+ 180 - 0
packages/base/httpd/httpd-2.2/ap_mpm.inc

@@ -0,0 +1,180 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+//#include "apr_thread_proc.h"
+
+{
+ * @package Multi-Processing Module library
+ }
+
+{
+    The MPM, "multi-processing model" provides an abstraction of the
+    interface with the OS for distributing incoming connections to
+    threads/process for processing.  http_main invokes the MPM, and
+    the MPM runs until a shutdown/restart has been indicated.
+    The MPM calls out to the apache core via the ap_process_connection
+    function when a connection arrives.
+
+    The MPM may or may not be multithreaded.  In the event that it is
+    multithreaded, at any instant it guarantees a 1:1 mapping of threads
+    ap_process_connection invocations.  
+
+    Note: In the future it will be possible for ap_process_connection
+    to return to the MPM prior to finishing the entire connection; and
+    the MPM will proceed with asynchronous handling for the connection;
+    in the future the MPM may call ap_process_connection again -- but
+    does not guarantee it will occur on the same thread as the first call.
+
+    The MPM further guarantees that no asynchronous behaviour such as
+    longjmps and signals will interfere with the user code that is
+    invoked through ap_process_connection.  The MPM may reserve some
+    signals for its use (i.e. SIGUSR1), but guarantees that these signals
+    are ignored when executing outside the MPM code itself.  (This
+    allows broken user code that does not handle EINTR to function
+    properly.)
+
+    The suggested server restart and stop behaviour will be "graceful".
+    However the MPM may choose to terminate processes when the user
+    requests a non-graceful restart/stop.  When this occurs, the MPM kills
+    all threads with extreme prejudice, and destroys the pchild pool.
+    User cleanups registered in the pchild apr_pool_t will be invoked at
+    this point.  (This can pose some complications, the user cleanups
+    are asynchronous behaviour not unlike longjmp/signal... but if the
+    admin is asking for a non-graceful shutdown, how much effort should
+    we put into doing it in a nice way?)
+
+    unix/posix notes:
+    - The MPM does not set a SIGALRM handler, user code may use SIGALRM.
+	But the preferred method of handling timeouts is to use the
+	timeouts provided by the BUFF abstraction.
+    - The proper setting for SIGPIPE is SIG_IGN, if user code changes it
+        for any of their own processing, it must be restored to SIG_IGN
+	prior to executing or returning to any apache code.
+    TODO: add SIGPIPE debugging check somewhere to make sure it's SIG_IGN
+}
+
+{
+ * This is the function that MPMs must create.  This function is responsible
+ * for controlling the parent and child processes.  It will run until a 
+ * restart/shutdown is indicated.
+ * @param pconf the configuration pool, reset before the config file is read
+ * @param plog the log pool, reset after the config file is read
+ * @param server_conf the global server config.
+ * @return 1 for shutdown 0 otherwise.
+ * @deffunc int ap_mpm_run(apr_pool_t *pconf, apr_pool_t *plog, server_rec *server_conf)
+ }
+function ap_mpm_run(pconf, plog: Papr_pool_t; server_conf: Pserver_rec): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_mpm_run' + LibSuff12;
+
+{
+ * predicate indicating if a graceful stop has been requested ...
+ * used by the connection loop 
+ * @return 1 if a graceful stop has been requested, 0 otherwise
+ * @deffunc int ap_graceful_stop_signalled(*void)
+ }
+function ap_graceful_stop_signalled: Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_graceful_stop_signalled' + LibSuff0;
+
+{
+ * Spawn a process with privileges that another module has requested
+ * @param r The request_rec of the current request
+ * @param newproc The resulting process handle.
+ * @param progname The program to run 
+ * @param const_args the arguments to pass to the new program.  The first 
+ *                   one should be the program name.
+ * @param env The new environment apr_table_t for the new process.  This 
+ *            should be a list of NULL-terminated strings.
+ * @param attr the procattr we should use to determine how to create the new
+ *         process
+ * @param p The pool to use. 
+ }
+function ap_os_create_privileged_process(
+ const r: Prequest_rec;
+ newproc: Papr_proc_t;
+ const progname, args, env: PChar;
+ attr: Papr_procattr_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_os_create_privileged_process' + LibSuff28;
+
+const
+{ Subtypes/Values for AP_MPMQ_IS_THREADED and AP_MPMQ_IS_FORKED        }
+  AP_MPMQ_NOT_SUPPORTED     = 0;  { This value specifies whether }
+                                      { an MPM is capable of         }
+                                      { threading or forking.        }
+  AP_MPMQ_STATIC            = 1;  { This value specifies whether }
+                                      { an MPM is using a static #   }
+                                      { threads or daemons.          }
+  AP_MPMQ_DYNAMIC           = 2;  { This value specifies whether }
+                                      { an MPM is using a dynamic #  }
+                                      { threads or daemons.          }
+
+{ Values returned for AP_MPMQ_MPM_STATE }
+  AP_MPMQ_STARTING             = 0;
+  AP_MPMQ_RUNNING              = 1;
+  AP_MPMQ_STOPPING             = 2;
+
+  AP_MPMQ_MAX_DAEMON_USED      = 1;  { Max # of daemons used so far }
+  AP_MPMQ_IS_THREADED          = 2;  { MPM can do threading         }
+  AP_MPMQ_IS_FORKED            = 3;  { MPM can do forking           }
+  AP_MPMQ_HARD_LIMIT_DAEMONS   = 4;  { The compiled max # daemons   }
+  AP_MPMQ_HARD_LIMIT_THREADS   = 5;  { The compiled max # threads   }
+  AP_MPMQ_MAX_THREADS          = 6;  { # of threads/child by config }
+  AP_MPMQ_MIN_SPARE_DAEMONS    = 7;  { Min # of spare daemons       }
+  AP_MPMQ_MIN_SPARE_THREADS    = 8;  { Min # of spare threads       }
+  AP_MPMQ_MAX_SPARE_DAEMONS    = 9;  { Max # of spare daemons       }
+  AP_MPMQ_MAX_SPARE_THREADS   = 10;  { Max # of spare threads       }
+  AP_MPMQ_MAX_REQUESTS_DAEMON = 11;  { Max # of requests per daemon }
+  AP_MPMQ_MAX_DAEMONS         = 12;  { Max # of daemons by config   }
+  AP_MPMQ_MPM_STATE           = 13;  { starting, running, stopping  }
+  AP_MPMQ_IS_ASYNC            = 14;  { MPM can process async connections  }
+
+{
+ * Query a property of the current MPM.  
+ * @param query_code One of APM_MPMQ_*
+ * @param result A location to place the result of the query
+ * @return APR_SUCCESS or APR_ENOTIMPL
+ * @deffunc int ap_mpm_query(int query_code, int *result)
+ }
+function ap_mpm_query(query_code: Integer; result: PInteger): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_mpm_query' + LibSuff8;
+
+{ Defining GPROF when compiling uses the moncontrol() function to
+ * disable gprof profiling in the parent, and enable it only for
+ * request processing in children (or in one_process mode).  It's
+ * absolutely required to get useful gprof results under linux
+ * because the profile itimers and such are disabled across a
+ * fork().  It's probably useful elsewhere as well.
+ }
+{#ifdef GPROF
+extern void moncontrol(int);
+#define AP_MONCONTROL(x) moncontrol(x)
+#else
+#define AP_MONCONTROL(x)
+#endif}
+
+{$ifdef AP_ENABLE_EXCEPTION_HOOK}
+type
+  ap_exception_info_t = record
+    sig: Integer;
+    pid: pid_t;
+  end;
+
+AP_DECLARE_HOOK(int,fatal_exception,(ap_exception_info_t *ei))
+{$endif} {AP_ENABLE_EXCEPTION_HOOK}
+

+ 68 - 0
packages/base/httpd/httpd-2.2/ap_provider.inc

@@ -0,0 +1,68 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @package Provider API
+ }
+
+//#include "ap_config.h"
+
+type
+  ap_list_provider_names_t = record
+    provider_name: PChar;
+  end;
+
+{
+ * This function is used to register a provider with the global
+ * provider pool.
+ * @param pool The pool to create any storage from
+ * @param provider_group The group to store the provider in
+ * @param provider_name The name for this provider
+ * @param provider_version The version for this provider
+ * @param provider Opaque structure for this provider
+ * @return APR_SUCCESS if all went well
+ }
+function ap_register_provider(pool: Papr_pool_t;
+ const provider_group, provider_name, provider_version: PChar;
+ const provider: Pointer): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_register_provider' + LibSuff20;
+
+{
+ * This function is used to retrieve a provider from the global
+ * provider pool.
+ * @param provider_group The group to look for this provider in
+ * @param provider_name The name for the provider
+ * @param provider_version The version for the provider
+ * @return provider pointer to provider if found, NULL otherwise
+ }
+function ap_lookup_provider(provider_group, provider_name, provider_version: PChar): Pointer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_lookup_provider' + LibSuff12;
+
+{
+ * This function is used to retrieve a list (array) of provider
+ * names from the specified group with the specified version.
+ * @param pool The pool to create any storage from
+ * @param provider_group The group to look for this provider in
+ * @param provider_version The version for the provider
+ * @return pointer to array of ap_list_provider_names_t of provider names (could be empty)
+ }
+function ap_list_provider_names(pool: Papr_pool_t;
+ const provider_group, provider_version: PChar): Papr_array_header_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_list_provider_names' + LibSuff12;
+

+ 138 - 0
packages/base/httpd/httpd-2.2/ap_regex.inc

@@ -0,0 +1,138 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{ Derived from PCRE's pcreposix.h.
+
+            Copyright (c) 1997-2004 University of Cambridge
+
+-----------------------------------------------------------------------------
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above copyright
+      notice, this list of conditions and the following disclaimer in the
+      documentation and/or other materials provided with the distribution.
+
+    * Neither the name of the University of Cambridge nor the names of its
+      contributors may be used to endorse or promote products derived from
+      this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+-----------------------------------------------------------------------------
+}
+
+{
+ * @file ap_regex.h
+ * @brief Apache Regex defines
+ }
+
+//#include "apr.h"
+
+{ Options for ap_regexec: }
+
+const
+  AP_REG_ICASE    = $01; { use a case-insensitive match }
+  AP_REG_NEWLINE  = $02; { don't match newlines against '.' etc }
+  AP_REG_NOTBOL   = $04; { ^ will not match against start-of-string }
+  AP_REG_NOTEOL   = $08; { $ will not match against end-of-string }
+
+  AP_REG_EXTENDED = (0);  { unused }
+  AP_REG_NOSUB    = (0);  { unused }
+
+{ Error values: }
+
+  AP_REG_ASSERT  = 1;     { internal error ? }
+  AP_REG_ESPACE  = 2;     { failed to get memory }
+  AP_REG_INVARG  = 3;     { invalid argument }
+  AP_REG_NOMATCH = 4;     { match failed }
+
+{ The structure representing a compiled regular expression. }
+type
+  Pap_regex_t = ^ap_regex_t;
+  
+  ap_regex_t = record
+    re_pcre: Pointer;
+    re_nsub: apr_size_t;
+    re_erroffset: apr_size_t;
+  end;
+
+{ The structure in which a captured offset is returned. }
+  Pap_regmatch_t = ^ap_regmatch_t;
+
+  ap_regmatch_t = record
+    rm_so: Integer;
+    rm_eo: Integer;
+  end;
+
+{ The functions }
+
+{
+ * Compile a regular expression.
+ * @param preg Returned compiled regex
+ * @param regex The regular expression string
+ * @param cflags Must be zero (currently).
+ * @return Zero on success or non-zero on error
+ }
+function ap_regcomp(preg: Pap_regex_t; const regex: PChar; cflags: Integer): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_regcomp' + LibSuff12;
+
+{
+ * Match a NUL-terminated string against a pre-compiled regex.
+ * @param preg The pre-compiled regex
+ * @param string The string to match
+ * @param nmatch Provide information regarding the location of any matches
+ * @param pmatch Provide information regarding the location of any matches
+ * @param eflags Bitwise OR of any of AP_REG_* flags 
+ * @return 0 for successful match, #REG_NOMATCH otherwise
+ }
+function ap_regexec(const preg: Pap_regex_t; const string_: PChar;
+ nmatch: apr_size_t; pmatch: Pap_regmatch_t; eflags: Integer): Integer;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_regexec' + LibSuff20;
+
+{
+ * Return the error code returned by regcomp or regexec into error messages
+ * @param errcode the error code returned by regexec or regcomp
+ * @param preg The precompiled regex
+ * @param errbuf A buffer to store the error in
+ * @param errbuf_size The size of the buffer
+ }
+function ap_regerror(errcord: Integer; const preg: Pap_regex_t;
+ errbuf: PChar; errbuf_size: apr_size_t): apr_size_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_regerror' + LibSuff16;
+
+{ Destroy a pre-compiled regex.
+ * @param preg The pre-compiled regex to free.
+ }
+procedure ap_regfree(preg: Pap_regex_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibHTTPD name LibNamePrefix + 'ap_regfree' + LibSuff4;
+

+ 66 - 0
packages/base/httpd/httpd-2.2/ap_release.inc

@@ -0,0 +1,66 @@
+{ Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+//#include "apr_general.h" /* stringify */
+
+const
+  AP_SERVER_COPYRIGHT =
+    'Copyright 2006 The Apache Software Foundation.';
+
+{
+ * The below defines the base string of the Server: header. Additional
+ * tokens can be added via the ap_add_version_component() API call.
+ *
+ * The tokens are listed in order of their significance for identifying the
+ * application.
+ *
+ * "Product tokens should be short and to the point -- use of them for 
+ * advertizing or other non-essential information is explicitly forbidden."
+ *
+ * Example: "Apache/1.1.0 MrWidget/0.1-alpha" 
+ }
+  AP_SERVER_BASEVENDOR = 'Apache Software Foundation';
+  AP_SERVER_BASEPROJECT = 'Apache HTTP Server';
+  AP_SERVER_BASEPRODUCT = 'Apache';
+
+  AP_SERVER_MAJORVERSION_NUMBER = 2;
+  AP_SERVER_MINORVERSION_NUMBER = 2;
+  AP_SERVER_PATCHLEVEL_NUMBER   = 3;
+  AP_SERVER_DEVBUILD_BOOLEAN    = 0;
+  
+{$ifdef AP_SERVER_DEVBUILD_BOOLEAN}
+  AP_SERVER_ADD_STRING          = '-dev';
+{$else}
+  AP_SERVER_ADD_STRING          = '';
+{$endif}
+
+{ keep old macros as well }
+{#define AP_SERVER_MAJORVERSION APR_STRINGIFY(AP_SERVER_MAJORVERSION_NUMBER)
+#define AP_SERVER_MINORVERSION APR_STRINGIFY(AP_SERVER_MINORVERSION_NUMBER)
+#define AP_SERVER_PATCHLEVEL APR_STRINGIFY(AP_SERVER_PATCHLEVEL_NUMBER) \
+                              AP_SERVER_ADD_STRING
+
+#define AP_SERVER_MINORREVISION AP_SERVER_MAJORVERSION "." AP_SERVER_MINORVERSION
+#define AP_SERVER_BASEREVISION  AP_SERVER_MINORREVISION "." AP_SERVER_PATCHLEVEL
+#define AP_SERVER_BASEVERSION   AP_SERVER_BASEPRODUCT "/" AP_SERVER_BASEREVISION
+#define AP_SERVER_VERSION       AP_SERVER_BASEVERSION
+
+/* macro for Win32 .rc files using numeric csv representation */
+#define AP_SERVER_PATCHLEVEL_CSV AP_SERVER_MAJORVERSION_NUMBER ##, \
+                               ##AP_SERVER_MINORVERSION_NUMBER ##, \
+                               ##AP_SERVER_PATCHLEVEL_NUMBER
+}
+

+ 245 - 0
packages/base/httpd/httpd-2.2/apr/apr.pas

@@ -0,0 +1,245 @@
+{
+ apr.pas
+
+ Copyright (C) 2006 Felipe Monteiro de Carvalho
+
+ This unit is a pascal binding for the Apache 2.0.58 headers.
+ The headers were released under the following copyright:
+}
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+unit apr;
+
+interface
+
+{$ifdef fpc}
+  {$mode delphi}{$H+}
+{$endif}
+
+{$IFNDEF FPC}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$IFDEF WIN32}
+  {$DEFINE WINDOWS}
+{$ENDIF}
+
+{$ifdef Unix}
+  {$PACKRECORDS C}
+{$endif}
+
+uses
+{$ifdef WINDOWS}
+  Windows, winsock,
+{$ELSE}
+  UnixType,
+{$ENDIF}
+  SysUtils, ctypes;
+  
+const
+{$IFDEF WINDOWS}
+  LibAPR = 'libapr-1.dll';
+{$ELSE}
+  LibAPR = '';
+{$ENDIF}
+
+{$IFDEF WINDOWS}
+  LibNamePrefix = '_';
+  LibSuff0 = '@0';
+  LibSuff4 = '@4';
+  LibSuff8 = '@8';
+  LibSuff12 = '@12';
+  LibSuff16 = '@16';
+  LibSuff20 = '@20';
+  LibSuff24 = '@24';
+  LibSuff28 = '@28';
+  LibSuff32 = '@32';
+{$ELSE}
+  LibNamePrefix = '';
+  LibSuff0 = '';
+  LibSuff4 = '';
+  LibSuff8 = '';
+  LibSuff12 = '';
+  LibSuff16 = '';
+  LibSuff20 = '';
+  LibSuff24 = '';
+  LibSuff28 = '';
+  LibSuff32 = '';
+{$ENDIF}
+
+type
+  uid_t = Integer;
+  gid_t = Integer;
+  time_t = LongInt;
+  size_t = Integer;
+  pid_t = Integer;
+  Ppid_t = ^pid_t;
+  apr_uint16_t = Word;
+  apr_uint32_t = Cardinal;
+  apr_int64_t = Int64;
+  apr_uint64_t = Int64;
+  apr_socklen_t = Integer;
+  apr_byte_t = Byte;
+
+  apr_uint32_tso_handle_t = cuint;
+
+type
+  {$IFDEF WINDOWS}
+  apr_off_t = Int64;
+  {$ENDIF}
+  {$IFDEF UNIX}
+  apr_off_t = Integer;
+  {$ENDIF}
+
+  apr_int32_t = Integer;
+  Papr_int32_t = ^Integer;
+  apr_size_t = size_t;
+  Papr_size_t = ^apr_size_t;
+  apr_int16_t = SmallInt;
+  Papr_int16_t = ^SmallInt;
+
+  // Network structures
+  
+  sockaddr = record
+    sa_family: cushort;    // address family, AF_xxx
+    sa_data: array [1..14] of Char;  // (NBO) 14 bytes of protocol address
+  end;
+  
+  in_addr = record
+    s_addr: culong;        // load with inet_aton()
+  end;
+
+{$ifndef windows}
+
+  va_list = Pointer;
+
+  sockaddr_in = record
+    sin_family: cshort;    // e.g. AF_INET
+    sin_port: cushort;     // e.g. htons(3490)
+    sin_addr: in_addr;     // see struct in_addr, below
+    sin_zero: array [1..8] of Char;  // zero this if you want to
+  end;
+  
+{$endif}
+
+  in6_addr = record
+   Case Integer of
+    1: (u6_addr8: array [1..16] of Byte);
+    2: (u6_addr16: array [1..8] of Word);
+    3: (u6_addr32: array [1..4] of Cardinal);
+  end;
+//#define s6_addr      in6_u.u6_addr8
+//#define s6_addr16    in6_u.u6_addr16
+//#define s6_addr32    in6_u.u6_addr32
+
+  sockaddr_in6 = record
+   sin6_family: cushort;
+    sin6_port: Word;
+    sin6_flowinfo: Cardinal;
+    sin6_addr: in6_addr;
+    sin6_scope_id: Cardinal;
+  end;
+
+  // TEMPORARY
+  
+  Papr_xml_ns_scope = Pointer;
+
+  Pap_method_list_t = Pointer;
+  Pcore_output_filter_ctx_t = Pointer;
+  Pap_directive_t = Pointer;
+  Pap_filter_t = Pointer;
+  Papr_file_t = Pointer;
+  Papr_off_t = Pointer;
+
+  iovec = record
+    /// byte count to read/write
+    iov_len: culong;
+    /// data to be read/written
+    iov_base: PChar;
+  end;
+  
+  Piovec = ^iovec;
+
+{$include apr_errno.inc}
+{$include apr_pools.inc}
+{$include apr_general.inc}
+{$include apr_dso.inc}
+{$include apr_user.inc}
+{$include apr_time.inc}
+{$include apr_tables.inc}
+{$include apr_file_info.inc}
+{$include apr_file_io.inc}
+{$include apr_strings.inc}
+{$include apr_lib.inc}
+{$include apr_signal.inc}
+{$include apr_network_io.inc}
+{.$include apr_portable.inc}
+
+{.$include ../aprutils/apr_uri.inc}
+
+{$include apr_thread_proc.inc}
+{$include apr_version.inc}
+{$include apr_poll.inc}
+
+implementation
+
+{
+  Macros transformed into functions in the translation
+}
+
+{ apr_pools.inc }
+
+{$ifndef DOXYGEN}
+function apr_pool_create(newpool: PPapr_pool_t; parent: Papr_pool_t): apr_status_t;
+begin
+  Result := apr_pool_create_ex(newpool, parent, nil, nil);
+end;
+{$endif}
+
+function apr_pool_sub_make(newpool: PPapr_pool_t; parent: Papr_pool_t;
+ abort_fn: apr_abortfunc_t): apr_status_t;
+begin
+  Result := apr_pool_create_ex(newpool, parent, abort_fn, nil);
+end;
+
+{ apr_lib.inc }
+
+function apr_tolower(c: Char): Char;
+var
+  buf: array[0..1] of Char;
+begin
+  buf[0] := c;
+  buf[1] := #0;
+  
+  buf := StrLower(@buf[0]);
+  
+  Result := buf[0];
+end;
+
+function apr_toupper(c: Char): Char;
+var
+  buf: array[0..1] of Char;
+begin
+  buf[0] := c;
+  buf[1] := #0;
+
+  buf := StrUpper(@buf[0]);
+
+  Result := buf[0];
+end;
+
+end.
+

+ 165 - 0
packages/base/httpd/httpd-2.2/apr/apr_allocator.inc

@@ -0,0 +1,165 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_allocator.h
+ * @brief APR Internal Memory Allocation
+ }
+
+{#include "apr.h"
+#include "apr_errno.h"
+#define APR_WANT_MEMFUNC < For no good reason?
+#include "apr_want.h"}
+
+{
+ * @defgroup apr_allocator Internal Memory Allocation
+ * @ingroup APR 
+ }
+
+type
+{ the allocator structure }
+
+  apr_allocator_t = record end;
+  Papr_allocator_t = ^apr_allocator_t;
+  PPapr_allocator_t = ^Papr_allocator_t;
+
+{ the structure which holds information about the allocation }
+
+  Papr_memnode_t = ^apr_memnode_t;
+  PPapr_memnode_t = ^Papr_memnode_t;
+
+{ basic memory node structure
+ * @note The next, ref and first_avail fields are available for use by the
+ *       caller of apr_allocator_alloc(), the remaining fields are read-only.
+ *       The next field has to be used with caution and sensibly set when the
+ *       memnode is passed back to apr_allocator_free().  See apr_allocator_free()
+ *       for details.
+ *       The ref and first_avail fields will be properly restored by
+ *       apr_allocator_free().
+ }
+
+  apr_memnode_t = record
+    next: Papr_memnode_t;            {< next memnode }
+    ref: PPapr_memnode_t;            {< reference to self }
+    index: apr_uint32_t;             {< size }
+    free_index: apr_uint32_t;        {< how much free }
+    first_avail: PChar;              {< pointer to first free memory }
+    endp: PChar;                     {< pointer to end of free memory }
+  end;
+
+{ The base size of a memory node - aligned.  }
+//#define APR_MEMNODE_T_SIZE APR_ALIGN_DEFAULT(sizeof(apr_memnode_t))
+
+{ Symbolic constants }
+const
+  APR_ALLOCATOR_MAX_FREE_UNLIMITED = 0;
+
+{
+ * Create a new allocator
+ * @param allocator The allocator we have just created.
+ *
+ }
+function apr_allocator_create(allocator: PPapr_allocator_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_create' + LibSuff4;
+
+{
+ * Destroy an allocator
+ * @param allocator The allocator to be destroyed
+ * @remark Any memnodes not given back to the allocator prior to destroying
+ *         will _not_ be free()d.
+ }
+procedure apr_allocator_destroy(allocator: Papr_allocator_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_destroy' + LibSuff4;
+
+{
+ * Allocate a block of mem from the allocator
+ * @param allocator The allocator to allocate from
+ * @param size The size of the mem to allocate (excluding the
+ *        memnode structure)
+ }
+function apr_allocator_alloc(allocator: Papr_allocator_t;
+ size: apr_size_t): Papr_memnode_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_alloc' + LibSuff8;
+
+{
+ * Free a list of blocks of mem, giving them back to the allocator.
+ * The list is typically terminated by a memnode with its next field
+ * set to NULL.
+ * @param allocator The allocator to give the mem back to
+ * @param memnode The memory node to return
+ }
+procedure apr_allocator_free(allocator: Papr_allocator_t; memnode: Papr_memnode_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_free' + LibSuff8;
+
+//#include "apr_pools.h"
+
+{
+ * Set the owner of the allocator
+ * @param allocator The allocator to set the owner for
+ * @param pool The pool that is to own the allocator
+ * @remark Typically pool is the highest level pool using the allocator
+ }
+{
+ * XXX: see if we can come up with something a bit better.  Currently
+ * you can make a pool an owner, but if the pool doesn't use the allocator
+ * the allocator will never be destroyed.
+ }
+procedure apr_allocator_owner_set(allocator: Papr_allocator_t; pool: Papr_pool_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_owner_set' + LibSuff8;
+
+{
+ * Get the current owner of the allocator
+ * @param allocator The allocator to get the owner from
+ }
+function apr_allocator_owner_get(allocator: Papr_allocator_t): Papr_pool_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_owner_get' + LibSuff4;
+
+{
+ * Set the current threshold at which the allocator should start
+ * giving blocks back to the system.
+ * @param allocator The allocator the set the threshold on
+ * @param size The threshold.  0 == unlimited.
+ }
+procedure apr_allocator_max_free_set(allocator: Papr_allocator_t; size: apr_size_t);
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_allocator_max_free_set' + LibSuff8;
+
+{#include "apr_thread_mutex.h"}
+
+{$ifdef APR_HAS_THREADS}
+{
+ * Set a mutex for the allocator to use
+ * @param allocator The allocator to set the mutex for
+ * @param mutex The mutex
+ }
+APR_DECLARE(void) apr_allocator_mutex_set(apr_allocator_t *allocator,
+                                          apr_thread_mutex_t *mutex);
+
+{
+ * Get the mutex currently set for the allocator
+ * @param allocator The allocator
+ }
+APR_DECLARE(apr_thread_mutex_t *) apr_allocator_mutex_get(
+                                      apr_allocator_t *allocator);
+
+{$endif} { APR_HAS_THREADS }
+

+ 1483 - 0
packages/base/httpd/httpd-2.2/apr/apr_buckets.inc

@@ -0,0 +1,1483 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+{
+ * @file apr_buckets.h
+ * @brief APR-UTIL Buckets/Bucket Brigades
+ }
+
+{#if defined(APR_BUCKET_DEBUG) && !defined(APR_RING_DEBUG)
+#define APR_RING_DEBUG
+#endif
+
+#include "apu.h"
+#include "apr_network_io.h"
+#include "apr_file_io.h"
+#include "apr_general.h"
+#include "apr_mmap.h"
+#include "apr_errno.h"
+#include "apr_ring.h"
+#include "apr.h"
+#if APR_HAVE_SYS_UIO_H
+#include <sys/uio.h>	for struct iovec
+#endif
+#if APR_HAVE_STDARG_H
+#include <stdarg.h>
+#endif}
+
+{
+ * @defgroup APR_Util_Bucket_Brigades Bucket Brigades
+ * @ingroup APR_Util
+ }
+
+{ default bucket buffer size - 8KB minus room for memory allocator headers }
+const
+  APR_BUCKET_BUFF_SIZE = 8000;
+
+{ Determines how a bucket or brigade should be read }
+type
+  apr_read_type_e = (
+    APR_BLOCK_READ,   {< block until data becomes available }
+    APR_NONBLOCK_READ {< return immediately if no data is available }
+  );
+
+{
+ * The one-sentence buzzword-laden overview: Bucket brigades represent
+ * a complex data stream that can be passed through a layered IO
+ * system without unnecessary copying. A longer overview follows...
+ *
+ * A bucket brigade is a doubly linked list (ring) of buckets, so we
+ * aren't limited to inserting at the front and removing at the end.
+ * Buckets are only passed around as members of a brigade, although
+ * singleton buckets can occur for short periods of time.
+ *
+ * Buckets are data stores of various types. They can refer to data in
+ * memory, or part of a file or mmap area, or the output of a process,
+ * etc. Buckets also have some type-dependent accessor functions:
+ * read, split, copy, setaside, and destroy.
+ *
+ * read returns the address and size of the data in the bucket. If the
+ * data isn't in memory then it is read in and the bucket changes type
+ * so that it can refer to the new location of the data. If all the
+ * data doesn't fit in the bucket then a new bucket is inserted into
+ * the brigade to hold the rest of it.
+ *
+ * split divides the data in a bucket into two regions. After a split
+ * the original bucket refers to the first part of the data and a new
+ * bucket inserted into the brigade after the original bucket refers
+ * to the second part of the data. Reference counts are maintained as
+ * necessary.
+ *
+ * setaside ensures that the data in the bucket has a long enough
+ * lifetime. Sometimes it is convenient to create a bucket referring
+ * to data on the stack in the expectation that it will be consumed
+ * (output to the network) before the stack is unwound. If that
+ * expectation turns out not to be valid, the setaside function is
+ * called to move the data somewhere safer.
+ *
+ * copy makes a duplicate of the bucket structure as long as it's
+ * possible to have multiple references to a single copy of the
+ * data itself.  Not all bucket types can be copied.
+ *
+ * destroy maintains the reference counts on the resources used by a
+ * bucket and frees them if necessary.
+ *
+ * Note: all of the above functions have wrapper macros (apr_bucket_read(),
+ * apr_bucket_destroy(), etc), and those macros should be used rather
+ * than using the function pointers directly.
+ *
+ * To write a bucket brigade, they are first made into an iovec, so that we
+ * don't write too little data at one time.  Currently we ignore compacting the
+ * buckets into as few buckets as possible, but if we really want good
+ * performance, then we need to compact the buckets before we convert to an
+ * iovec, or possibly while we are converting to an iovec.
+ }
+
+{
+ * Forward declaration of the main types.
+ }
+
+{ @see apr_bucket_brigade }
+  Papr_bucket_brigade = ^apr_bucket_brigade;
+  PPapr_bucket_brigade = ^Papr_bucket_brigade;
+{ @see apr_bucket }
+  Papr_bucket = ^apr_bucket;
+  PPapr_bucket = ^Papr_bucket;
+{ @see apr_bucket_alloc_t }
+  apr_bucket_alloc_t = record end;
+  Papr_bucket_alloc_t = ^apr_bucket_alloc_t;
+
+{ @see apr_bucket_type_t }
+  Papr_bucket_type_t = ^apr_bucket_type_t;
+
+  is_metadata = (
+    { This bucket type represents actual data to send to the client. }
+    APR_BUCKET_DATA = 0,
+    { This bucket type represents metadata. }
+    APR_BUCKET_METADATA = 1
+  );
+  
+  destroy_t = procedure (data: Pointer);
+
+  read_t = function (b: Papr_bucket; const str: PPChar; len: Papr_size_t;
+   block: apr_read_type_e): apr_status_t;
+                         
+  setaside_t = function (e: Papr_bucket; pool: Papr_pool_t): apr_status_t;
+
+  split_t = function (e: Papr_bucket; point: apr_size_t): apr_status_t;
+
+  copy_t = function (e: Papr_bucket; c: PPapr_bucket): apr_status_t;
+{
+ * Basic bucket type
+ }
+  apr_bucket_type_t = record
+    {
+     * The name of the bucket type
+     }
+    name: PChar;
+    {
+     * The number of functions this bucket understands.  Can not be less than
+     * five.
+     }
+    num_func: Integer;
+    {
+     * Whether the bucket contains metadata (ie, information that
+     * describes the regular contents of the brigade).  The metadata
+     * is not returned by apr_bucket_read() and is not indicated by
+     * the ->length of the apr_bucket itself.  In other words, an
+     * empty bucket is safe to arbitrarily remove if and only if it
+     * contains no metadata.  In this sense, "data" is just raw bytes
+     * that are the "content" of the brigade and "metadata" describes
+     * that data but is not a proper part of it.
+     }
+
+     { Declaration moved up }
+
+    {
+     * Free the private data and any resources used by the bucket (if they
+     *  aren't shared with another bucket).  This function is required to be
+     *  implemented for all bucket types, though it might be a no-op on some
+     *  of them (namely ones that never allocate any private data structures).
+     * @param data The private data pointer from the bucket to be destroyed
+     }
+    destroy: destroy_t;
+
+    {
+     * Read the data from the bucket. This is required to be implemented
+     *  for all bucket types.
+     * @param b The bucket to read from
+     * @param str A place to store the data read.  Allocation should only be
+     *            done if absolutely necessary. 
+     * @param len The amount of data read.
+     * @param block Should this read function block if there is more data that
+     *              cannot be read immediately.
+     }
+    read: read_t;
+    
+    {
+     * Make it possible to set aside the data for at least as long as the
+     *  given pool. Buckets containing data that could potentially die before
+     *  this pool (e.g. the data resides on the stack, in a child pool of
+     *  the given pool, or in a disjoint pool) must somehow copy, shift, or
+     *  transform the data to have the proper lifetime.
+     * @param e The bucket to convert
+     * @remark Some bucket types contain data that will always outlive the
+     *         bucket itself. For example no data (EOS and FLUSH), or the data
+     *         resides in global, constant memory (IMMORTAL), or the data is on
+     *      the heap (HEAP). For these buckets, apr_bucket_setaside_noop can
+     *      be used.
+     }
+    setaside: setaside_t;
+
+    {
+     * Split one bucket in two at the specified position by duplicating
+     *  the bucket structure (not the data) and modifying any necessary
+     *  start/end/offset information.  If it's not possible to do this
+     *  for the bucket type (perhaps the length of the data is indeterminate,
+     *  as with pipe and socket buckets), then APR_ENOTIMPL is returned.
+     * @param e The bucket to split
+     * @param point The offset of the first byte in the new bucket
+     }
+    split: split_t;
+
+    {
+     * Copy the bucket structure (not the data), assuming that this is
+     *  possible for the bucket type. If it's not, APR_ENOTIMPL is returned.
+     * @param e The bucket to copy
+     * @param c Returns a pointer to the new bucket
+     }
+    copy: copy_t;
+  end;
+
+{
+ * apr_bucket structures are allocated on the malloc() heap and
+ * their lifetime is controlled by the parent apr_bucket_brigade
+ * structure. Buckets can move from one brigade to another e.g. by
+ * calling APR_BRIGADE_CONCAT(). In general the data in a bucket has
+ * the same lifetime as the bucket and is freed when the bucket is
+ * destroyed; if the data is shared by more than one bucket (e.g.
+ * after a split) the data is freed when the last bucket goes away.
+ }
+  free_t = procedure(e: Pointer);
+
+  link_t = record
+    next: Papr_bucket;
+    prev: Papr_bucket;
+  end;
+
+  apr_bucket = record
+    { Links to the rest of the brigade }
+    link: link_t;
+    
+    { The type of bucket.  }
+    type_: Papr_bucket_type_t;
+    { The length of the data in the bucket.  This could have been implemented
+     *  with a function, but this is an optimization, because the most
+     *  common thing to do will be to get the length.  If the length is unknown,
+     *  the value of this field will be (apr_size_t)(-1).
+     }
+    length: apr_size_t;
+    { The start of the data in the bucket relative to the private base
+     *  pointer.  The vast majority of bucket types allow a fixed block of
+     *  data to be referenced by multiple buckets, each bucket pointing to
+     *  a different segment of the data.  That segment starts at base+start
+     *  and ends at base+start+length.  
+     *  If the length == (apr_size_t)(-1), then start == -1.
+     }
+    start: apr_off_t;
+    { type-dependent data hangs off this pointer }
+    data: Pointer;
+    {
+     * Pointer to function used to free the bucket. This function should
+     * always be defined and it should be consistent with the memory
+     * function used to allocate the bucket. For example, if malloc() is 
+     * used to allocate the bucket, this pointer should point to free().
+     * @param e Pointer to the bucket being freed
+     }
+    free: free_t;
+    { The freelist from which this bucket was allocated }
+    list: Papr_bucket_alloc_t;
+  end;
+
+  { A list of buckets }
+  
+  apr_bucket_list = record
+    next: Papr_bucket;
+    prev: Papr_bucket;
+  end;
+
+  apr_bucket_brigade = record
+    { The pool to associate the brigade with.  The data is not allocated out
+     *  of the pool, but a cleanup is registered with this pool.  If the 
+     *  brigade is destroyed by some mechanism other than pool destruction,
+     *  the destroying function is responsible for killing the cleanup.
+     }
+    p: Papr_pool_t;
+    { The buckets in the brigade are on this list. }
+    {
+     * The apr_bucket_list structure doesn't actually need a name tag
+     * because it has no existence independent of struct apr_bucket_brigade;
+     * the ring macros are designed so that you can leave the name tag
+     * argument empty in this situation but apparently the Windows compiler
+     * doesn't like that.
+     }
+    list: apr_bucket_list;
+    { The freelist from which this bucket was allocated }
+    bucket_alloc: Papr_bucket_alloc_t;
+  end;
+
+
+{
+ * Function called when a brigade should be flushed
+ }
+  apr_brigade_flush = function (bb: Papr_bucket_brigade; ctx: Pointer): apr_status_t;
+
+{
+ * define APR_BUCKET_DEBUG if you want your brigades to be checked for
+ * validity at every possible instant.  this will slow your code down
+ * substantially but is a very useful debugging tool.
+ }
+{#ifdef APR_BUCKET_DEBUG
+
+#define APR_BRIGADE_CHECK_CONSISTENCY(b)				\
+        APR_RING_CHECK_CONSISTENCY(&(b)->list, apr_bucket, link)
+
+#define APR_BUCKET_CHECK_CONSISTENCY(e)					\
+        APR_RING_CHECK_ELEM_CONSISTENCY((e), apr_bucket, link)
+
+#else}
+{
+ * checks the ring pointers in a bucket brigade for consistency.  an
+ * abort() will be triggered if any inconsistencies are found.
+ *   note: this is a no-op unless APR_BUCKET_DEBUG is defined.
+ * @param b The brigade
+ }
+//#define APR_BRIGADE_CHECK_CONSISTENCY(b)
+{
+ * checks the brigade a bucket is in for ring consistency.  an
+ * abort() will be triggered if any inconsistencies are found.
+ *   note: this is a no-op unless APR_BUCKET_DEBUG is defined.
+ * @param e The bucket
+ }
+//#define APR_BUCKET_CHECK_CONSISTENCY(e)
+//#endif
+
+
+{
+ * Wrappers around the RING macros to reduce the verbosity of the code
+ * that handles bucket brigades.
+ }
+{
+ * The magic pointer value that indicates the head of the brigade
+ * @remark This is used to find the beginning and end of the brigade, eg:
+ * <pre>
+ *      while (e != APR_BRIGADE_SENTINEL(b)) (
+ *          ...
+ *          e = APR_BUCKET_NEXT(e);
+ *      )
+ * </pre>
+ * @param  b The brigade
+ * @return The magic pointer value
+ }
+//#define APR_BRIGADE_SENTINEL(b)	APR_RING_SENTINEL(&(b)->list, apr_bucket, link)
+
+{
+ * Determine if the bucket brigade is empty
+ * @param b The brigade to check
+ * @return true or false
+ }
+//#define APR_BRIGADE_EMPTY(b)	APR_RING_EMPTY(&(b)->list, apr_bucket, link)
+
+{
+ * Return the first bucket in a brigade
+ * @param b The brigade to query
+ * @return The first bucket in the brigade
+ }
+//#define APR_BRIGADE_FIRST(b)	APR_RING_FIRST(&(b)->list)
+{
+ * Return the last bucket in a brigade
+ * @param b The brigade to query
+ * @return The last bucket in the brigade
+ }
+//#define APR_BRIGADE_LAST(b)	APR_RING_LAST(&(b)->list)
+
+{
+ * Insert a list of buckets at the front of a brigade
+ * @param b The brigade to add to
+ * @param e The first bucket in a list of buckets to insert
+ }
+{#define APR_BRIGADE_INSERT_HEAD(b, e) do (				\
+	apr_bucket *ap__b = (e);                                        \
+	APR_RING_INSERT_HEAD(&(b)->list, ap__b, apr_bucket, link);	\
+        APR_BRIGADE_CHECK_CONSISTENCY((b));				\
+    ) while (0)}
+
+{
+ * Insert a list of buckets at the end of a brigade
+ * @param b The brigade to add to
+ * @param e The first bucket in a list of buckets to insert
+ }
+{#define APR_BRIGADE_INSERT_TAIL(b, e) do begin				\
+	apr_bucket *ap__b = (e);					\
+	APR_RING_INSERT_TAIL(&(b)->list, ap__b, apr_bucket, link);	\
+        APR_BRIGADE_CHECK_CONSISTENCY((b));				\
+    end while (0)}
+
+{
+ * Concatenate brigade b onto the end of brigade a, leaving brigade b empty
+ * @param a The first brigade
+ * @param b The second brigade
+ }
+{#define APR_BRIGADE_CONCAT(a, b) do begin
+        APR_RING_CONCAT(&(a)->list, &(b)->list, apr_bucket, link);	\
+        APR_BRIGADE_CHECK_CONSISTENCY((a));				\
+    end while (0);}
+
+{
+ * Prepend brigade b onto the beginning of brigade a, leaving brigade b empty
+ * @param a The first brigade
+ * @param b The second brigade
+ }
+{#define APR_BRIGADE_PREPEND(a, b) do begin
+        APR_RING_PREPEND(&(a)->list, &(b)->list, apr_bucket, link);	\
+        APR_BRIGADE_CHECK_CONSISTENCY((a));				\
+    end while (0)}
+
+{
+ * Insert a list of buckets before a specified bucket
+ * @param a The bucket to insert before
+ * @param b The buckets to insert
+ }
+{#define APR_BUCKET_INSERT_BEFORE(a, b) do begin
+	apr_bucket *ap__a = (a), *ap__b = (b);				\
+	APR_RING_INSERT_BEFORE(ap__a, ap__b, link);			\
+        APR_BUCKET_CHECK_CONSISTENCY(ap__a);				\
+    end while (0)}
+
+{
+ * Insert a list of buckets after a specified bucket
+ * @param a The bucket to insert after
+ * @param b The buckets to insert
+ }
+{#define APR_BUCKET_INSERT_AFTER(a, b) do begin
+	apr_bucket *ap__a = (a), *ap__b = (b);				\
+	APR_RING_INSERT_AFTER(ap__a, ap__b, link);			\
+        APR_BUCKET_CHECK_CONSISTENCY(ap__a);				\
+    end while (0)}
+
+{
+ * Get the next bucket in the list
+ * @param e The current bucket
+ * @return The next bucket
+ }
+//#define APR_BUCKET_NEXT(e)	APR_RING_NEXT((e), link)
+{
+ * Get the previous bucket in the list
+ * @param e The current bucket
+ * @return The previous bucket
+ }
+//#define APR_BUCKET_PREV(e)	APR_RING_PREV((e), link)
+
+{
+ * Remove a bucket from its bucket brigade
+ * @param e The bucket to remove
+ }
+//#define APR_BUCKET_REMOVE(e)	APR_RING_REMOVE((e), link)
+
+{
+ * Initialize a new bucket's prev/next pointers
+ * @param e The bucket to initialize
+ }
+//#define APR_BUCKET_INIT(e)	APR_RING_ELEM_INIT((e), link)
+
+{
+ * Determine if a bucket contains metadata.  An empty bucket is
+ * safe to arbitrarily remove if and only if this is false.
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_METADATA(e)    ((e)->type->is_metadata)
+
+{
+ * Determine if a bucket is a FLUSH bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_FLUSH(e)       ((e)->type == &apr_bucket_type_flush)
+{
+ * Determine if a bucket is an EOS bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_EOS(e)         ((e)->type == &apr_bucket_type_eos)
+{
+ * Determine if a bucket is a FILE bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_FILE(e)        ((e)->type == &apr_bucket_type_file)
+{
+ * Determine if a bucket is a PIPE bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_PIPE(e)        ((e)->type == &apr_bucket_type_pipe)
+{
+ * Determine if a bucket is a SOCKET bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_SOCKET(e)      ((e)->type == &apr_bucket_type_socket)
+{
+ * Determine if a bucket is a HEAP bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_HEAP(e)        ((e)->type == &apr_bucket_type_heap)
+{
+ * Determine if a bucket is a TRANSIENT bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_TRANSIENT(e)   ((e)->type == &apr_bucket_type_transient)
+{
+ * Determine if a bucket is a IMMORTAL bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_IMMORTAL(e)    ((e)->type == &apr_bucket_type_immortal)
+//#if APR_HAS_MMAP
+{
+ * Determine if a bucket is a MMAP bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_MMAP(e)        ((e)->type == &apr_bucket_type_mmap)
+//#endif
+{
+ * Determine if a bucket is a POOL bucket
+ * @param e The bucket to inspect
+ * @return true or false
+ }
+//#define APR_BUCKET_IS_POOL(e)        ((e)->type == &apr_bucket_type_pool)
+
+{
+ * General-purpose reference counting for the various bucket types.
+ *
+ * Any bucket type that keeps track of the resources it uses (i.e.
+ * most of them except for IMMORTAL, TRANSIENT, and EOS) needs to
+ * attach a reference count to the resource so that it can be freed
+ * when the last bucket that uses it goes away. Resource-sharing may
+ * occur because of bucket splits or buckets that refer to globally
+ * cached data. }
+
+{ @see apr_bucket_refcount }
+  Papr_bucket_refcount = ^apr_bucket_refcount;
+{
+ * The structure used to manage the shared resource must start with an
+ * apr_bucket_refcount which is updated by the general-purpose refcount
+ * code. A pointer to the bucket-type-dependent private data structure
+ * can be cast to a pointer to an apr_bucket_refcount and vice versa.
+ }
+  apr_bucket_refcount = record
+    { The number of references to this bucket }
+    refcount: Integer;
+  end;
+
+{  *****  Reference-counted bucket types  *****  }
+
+{ @see apr_bucket_heap }
+  Papr_bucket_heap = ^apr_bucket_heap;
+{
+ * A bucket referring to data allocated off the heap.
+ }
+  free_func_t = procedure (data: Pointer);
+
+  apr_bucket_heap = record
+    { Number of buckets using this memory }
+    refcount: apr_bucket_refcount;
+    { The start of the data actually allocated.  This should never be
+     * modified, it is only used to free the bucket.
+     }
+    base: PChar;
+    { how much memory was allocated }
+    alloc_len: apr_size_t;
+    { function to use to delete the data }
+    free_func: free_func_t;
+  end;
+
+{ @see apr_bucket_pool }
+  Papr_bucket_pool = ^apr_bucket_pool;
+{
+ * A bucket referring to data allocated from a pool
+ }
+  apr_bucket_pool = record
+    { The pool bucket must be able to be easily morphed to a heap
+     * bucket if the pool gets cleaned up before all references are
+     * destroyed.  This apr_bucket_heap structure is populated automatically
+     * when the pool gets cleaned up, and subsequent calls to pool_read()
+     * will result in the apr_bucket in question being morphed into a
+     * regular heap bucket.  (To avoid having to do many extra refcount
+     * manipulations and b->data manipulations, the apr_bucket_pool
+     * struct actually *contains* the apr_bucket_heap struct that it
+     * will become as its first element; the two share their
+     * apr_bucket_refcount members.)
+     }
+    heap: apr_bucket_heap;
+    { The block of data actually allocated from the pool.
+     * Segments of this block are referenced by adjusting
+     * the start and length of the apr_bucket accordingly.
+     * This will be NULL after the pool gets cleaned up.
+     }
+    base: PChar;
+    { The pool the data was allocated from.  When the pool
+     * is cleaned up, this gets set to NULL as an indicator
+     * to pool_read() that the data is now on the heap and
+     * so it should morph the bucket into a regular heap
+     * bucket before continuing.
+     }
+    pool: Papr_pool_t;
+    { The freelist this structure was allocated from, which is
+     * needed in the cleanup phase in order to allocate space on the heap
+     }
+    list: Papr_bucket_alloc_t;
+  end;
+
+{$ifdef APR_HAS_MMAP}
+{ @see apr_bucket_mmap }
+  Papr_bucket_mmap = ^apr_bucket_mmap;
+{
+ * A bucket referring to an mmap()ed file
+ }
+  apr_bucket_mmap = record
+    { Number of buckets using this memory }
+    refcount: apr_bucket_refcount;
+    { The mmap this sub_bucket refers to }
+    mmap: Papr_mmap_t;
+  end;
+{$endif}
+
+{ @see apr_bucket_file }
+  Papr_bucket_file = ^apr_bucket_file;
+{
+ * A bucket referring to an file
+ }
+  apr_bucket_file = record
+    { Number of buckets using this memory }
+    refcount: apr_bucket_refcount;
+    { The file this bucket refers to }
+    fd: Papr_file_t;
+    { The pool into which any needed structures should
+     *  be created while reading from this file bucket }
+    readpool: Papr_pool_t;
+{$ifdef APR_HAS_MMAP}
+    { Whether this bucket should be memory-mapped if
+     *  a caller tries to read from it }
+    can_mmap: Integer;
+{$endif} { APR_HAS_MMAP }
+  end;
+
+{ @see apr_bucket_structs }
+  Papr_bucket_structs = ^apr_bucket_structs;
+{
+ * A union of all bucket structures so we know what
+ * the max size is.
+ }
+  apr_bucket_structs = record
+    case Integer of
+     0: (b: apr_bucket);      {< Bucket }
+     1: (heap: apr_bucket_heap);   {< Heap }
+     2: (pool: apr_bucket_pool);   {< Pool }
+{$ifdef APR_HAS_MMAP}
+     3: (mmap: apr_bucket_mmap);   {< MMap }
+{$endif}
+     4: (file_: apr_bucket_file);   {< File }
+  end;
+
+{
+ * The amount that apr_bucket_alloc() should allocate in the common case.
+ * Note: this is twice as big as apr_bucket_structs to allow breathing
+ * room for third-party bucket types.
+ }
+//#define APR_BUCKET_ALLOC_SIZE  APR_ALIGN_DEFAULT(2*sizeof(apr_bucket_structs))
+
+{  *****  Bucket Brigade Functions  *****  }
+{
+ * Create a new bucket brigade.  The bucket brigade is originally empty.
+ * @param p The pool to associate with the brigade.  Data is not allocated out
+ *          of the pool, but a cleanup is registered.
+ * @param list The bucket allocator to use
+ * @return The empty bucket brigade
+ }
+//APU_DECLARE(apr_bucket_brigade *) apr_brigade_create(apr_pool_t *p,
+//                                                     apr_bucket_alloc_t *list);
+
+{
+ * destroy an entire bucket brigade.  This includes destroying all of the
+ * buckets within the bucket brigade's bucket list. 
+ * @param b The bucket brigade to destroy
+ }
+//APU_DECLARE(apr_status_t) apr_brigade_destroy(apr_bucket_brigade *b);
+
+{
+ * empty out an entire bucket brigade.  This includes destroying all of the
+ * buckets within the bucket brigade's bucket list.  This is similar to
+ * apr_brigade_destroy(), except that it does not deregister the brigade's
+ * pool cleanup function.
+ * @param data The bucket brigade to clean up
+ * @remark Generally, you should use apr_brigade_destroy().  This function
+ *         can be useful in situations where you have a single brigade that
+ *         you wish to reuse many times by destroying all of the buckets in
+ *         the brigade and putting new buckets into it later.
+ }
+//APU_DECLARE(apr_status_t) apr_brigade_cleanup(void *data);
+
+{
+ * Split a bucket brigade into two, such that the given bucket is the
+ * first in the new bucket brigade. This function is useful when a
+ * filter wants to pass only the initial part of a brigade to the next
+ * filter.
+ * @param b The brigade to split
+ * @param e The first element of the new brigade
+ * @return The new brigade
+ }
+//APU_DECLARE(apr_bucket_brigade *) apr_brigade_split(apr_bucket_brigade *b,
+//                                                    apr_bucket *e);
+
+{
+ * Partition a bucket brigade at a given offset (in bytes from the start of
+ * the brigade).  This is useful whenever a filter wants to use known ranges
+ * of bytes from the brigade; the ranges can even overlap.
+ * @param b The brigade to partition
+ * @param point The offset at which to partition the brigade
+ * @param after_point Returns a pointer to the first bucket after the partition
+ * @return APR_SUCCESS on success, APR_INCOMPLETE if the contents of the
+ * brigade were shorter than @a point, or an error code.
+ * @remark if APR_INCOMPLETE is returned, @a after_point will be set to
+ * the brigade sentinel.
+ }
+//APU_DECLARE(apr_status_t) apr_brigade_partition(apr_bucket_brigade *b,
+//                                                apr_off_t point,
+//                                                apr_bucket **after_point);
+
+{
+ * Return the total length of the brigade.
+ * @param bb The brigade to compute the length of
+ * @param read_all Read unknown-length buckets to force a size
+ * @param length Returns the length of the brigade, or -1 if the brigade has
+ *               buckets of indeterminate length and read_all is 0.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_length(apr_bucket_brigade *bb,
+                                             int read_all,
+                                             apr_off_t *length);
+}
+{
+ * Take a bucket brigade and store the data in a flat char*
+ * @param bb The bucket brigade to create the char* from
+ * @param c The char* to write into
+ * @param len The maximum length of the char array. On return, it is the
+ *            actual length of the char array.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_flatten(apr_bucket_brigade *bb,
+                                              char *c,
+                                              apr_size_t *len);
+}
+{
+ * Creates a pool-allocated string representing a flat bucket brigade
+ * @param bb The bucket brigade to create the char array from
+ * @param c On return, the allocated char array
+ * @param len On return, the length of the char array.
+ * @param pool The pool to allocate the string from.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_pflatten(apr_bucket_brigade *bb,
+                                               char **c,
+                                               apr_size_t *len,
+                                               apr_pool_t *pool);
+}
+{
+ * Split a brigade to represent one LF line.
+ * @param bbOut The bucket brigade that will have the LF line appended to.
+ * @param bbIn The input bucket brigade to search for a LF-line.
+ * @param block The blocking mode to be used to split the line.
+ * @param maxbytes The maximum bytes to read.  If this many bytes are seen
+ *                 without a LF, the brigade will contain a partial line.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_split_line(apr_bucket_brigade *bbOut,
+                                                 apr_bucket_brigade *bbIn,
+                                                 apr_read_type_e block,
+                                                 apr_off_t maxbytes);
+}
+{
+ * create an iovec of the elements in a bucket_brigade... return number 
+ * of elements used.  This is useful for writing to a file or to the
+ * network efficiently.
+ * @param b The bucket brigade to create the iovec from
+ * @param vec The iovec to create
+ * @param nvec The number of elements in the iovec. On return, it is the
+ *             number of iovec elements actually filled out.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_to_iovec(apr_bucket_brigade *b,
+                                               struct iovec *vec, int *nvec);
+}
+{
+ * This function writes a list of strings into a bucket brigade. 
+ * @param b The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param va A list of strings to add
+ * @return APR_SUCCESS or error code.
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_vputstrs(apr_bucket_brigade *b,
+                                               apr_brigade_flush flush,
+                                               void *ctx,
+                                               va_list va);
+}
+{
+ * This function writes a string into a bucket brigade.
+ * @param b The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param str The string to add
+ * @param nbyte The number of bytes to write
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_write(apr_bucket_brigade *b,
+                                            apr_brigade_flush flush, void *ctx,
+                                            const char *str, apr_size_t nbyte);
+}
+{
+ * This function writes multiple strings into a bucket brigade.
+ * @param b The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param vec The strings to add (address plus length for each)
+ * @param nvec The number of entries in iovec
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_writev(apr_bucket_brigade *b,
+                                             apr_brigade_flush flush,
+                                             void *ctx,
+                                             const struct iovec *vec,
+                                             apr_size_t nvec);
+}
+{
+ * This function writes a string into a bucket brigade.
+ * @param bb The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param str The string to add
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_puts(apr_bucket_brigade *bb,
+                                           apr_brigade_flush flush, void *ctx,
+                                           const char *str);
+}
+{
+ * This function writes a character into a bucket brigade.
+ * @param b The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param c The character to add
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_putc(apr_bucket_brigade *b,
+                                           apr_brigade_flush flush, void *ctx,
+                                           const char c);
+}
+{
+ * This function writes an unspecified number of strings into a bucket brigade.
+ * @param b The bucket brigade to add to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param ... The strings to add
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_brigade_putstrs(apr_bucket_brigade *b,
+                                                     apr_brigade_flush flush,
+                                                     void *ctx, ...);
+}
+{
+ * Evaluate a printf and put the resulting string at the end 
+ * of the bucket brigade.
+ * @param b The brigade to write to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param fmt The format of the string to write
+ * @param ... The arguments to fill out the format
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_brigade_printf(apr_bucket_brigade *b,
+                                                    apr_brigade_flush flush,
+                                                    void *ctx,
+                                                    const char *fmt, ...)
+        __attribute__((format(printf,4,5)));
+}
+{
+ * Evaluate a printf and put the resulting string at the end 
+ * of the bucket brigade.
+ * @param b The brigade to write to
+ * @param flush The flush function to use if the brigade is full
+ * @param ctx The structure to pass to the flush function
+ * @param fmt The format of the string to write
+ * @param va The arguments to fill out the format
+ * @return APR_SUCCESS or error code
+ }
+{APU_DECLARE(apr_status_t) apr_brigade_vprintf(apr_bucket_brigade *b,
+                                              apr_brigade_flush flush,
+                                              void *ctx,
+                                              const char *fmt, va_list va);
+}
+
+{
+ * Utility function to insert a file (or a segment of a file) onto the
+ * end of the brigade.  The file is split into multiple buckets if it
+ * is larger than the maximum size which can be represented by a
+ * single bucket.
+ * @param bb the brigade to insert into
+ * @param f the file to insert
+ * @param start the offset of the start of the segment
+ * @param len the length of the segment of the file to insert
+ * @param p pool from which file buckets are allocated
+ * @return the last bucket inserted
+ }
+{APU_DECLARE(apr_bucket *) apr_brigade_insert_file(apr_bucket_brigade *bb,
+                                                  apr_file_t *f,
+                                                  apr_off_t start,
+                                                  apr_off_t len,
+                                                  apr_pool_t *p);}
+
+{  *****  Bucket freelist functions *****  }
+{
+ * Create a bucket allocator.
+ * @param p This pool's underlying apr_allocator_t is used to allocate memory
+ *          for the bucket allocator.  When the pool is destroyed, the bucket
+ *          allocator's cleanup routine will free all memory that has been
+ *          allocated from it.
+ * @remark  The reason the allocator gets its memory from the pool's
+ *          apr_allocator_t rather than from the pool itself is because
+ *          the bucket allocator will free large memory blocks back to the
+ *          allocator when it's done with them, thereby preventing memory
+ *          footprint growth that would occur if we allocated from the pool.
+ * @warning The allocator must never be used by more than one thread at a time.
+ }
+//APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create(apr_pool_t *p);
+
+{
+ * Create a bucket allocator.
+ * @param allocator This apr_allocator_t is used to allocate both the bucket
+ *          allocator and all memory handed out by the bucket allocator.  The
+ *          caller is responsible for destroying the bucket allocator and the
+ *          apr_allocator_t -- no automatic cleanups will happen.
+ * @warning The allocator must never be used by more than one thread at a time.
+ }
+//APU_DECLARE_NONSTD(apr_bucket_alloc_t *) apr_bucket_alloc_create_ex(apr_allocator_t *allocator);
+
+{
+ * Destroy a bucket allocator.
+ * @param list The allocator to be destroyed
+ }
+//APU_DECLARE_NONSTD(void) apr_bucket_alloc_destroy(apr_bucket_alloc_t *list);
+
+{
+ * Allocate memory for use by the buckets.
+ * @param size The amount to allocate.
+ * @param list The allocator from which to allocate the memory.
+ }
+//APU_DECLARE_NONSTD(void *) apr_bucket_alloc(apr_size_t size, apr_bucket_alloc_t *list);
+
+{
+ * Free memory previously allocated with apr_bucket_alloc().
+ * @param block The block of memory to be freed.
+ }
+//APU_DECLARE_NONSTD(void) apr_bucket_free(void *block);
+
+
+{  *****  Bucket Functions  *****  }
+{
+ * Free the resources used by a bucket. If multiple buckets refer to
+ * the same resource it is freed when the last one goes away.
+ * @see apr_bucket_delete()
+ * @param e The bucket to destroy
+ }
+{#define apr_bucket_destroy(e) do begin
+        (e)->type->destroy((e)->data);					\
+        (e)->free(e);							\
+    end while (0)}
+
+{
+ * Delete a bucket by removing it from its brigade (if any) and then
+ * destroying it.
+ * @remark This mainly acts as an aid in avoiding code verbosity.  It is
+ * the preferred exact equivalent to:
+ * <pre>
+ *      APR_BUCKET_REMOVE(e);
+ *      apr_bucket_destroy(e);
+ * </pre>
+ * @param e The bucket to delete
+ }
+{#define apr_bucket_delete(e) do begin
+        APR_BUCKET_REMOVE(e);						\
+        apr_bucket_destroy(e);						\
+    end while (0)}
+
+{
+ * read the data from the bucket
+ * @param e The bucket to read from
+ * @param str The location to store the data in
+ * @param len The amount of data read
+ * @param block Whether the read function blocks
+ }
+//#define apr_bucket_read(e,str,len,block) (e)->type->read(e, str, len, block)
+
+{
+ * Setaside data so that stack data is not destroyed on returning from
+ * the function
+ * @param e The bucket to setaside
+ * @param p The pool to setaside into
+ }
+//#define apr_bucket_setaside(e,p) (e)->type->setaside(e,p)
+
+{
+ * Split one bucket in two.
+ * @param e The bucket to split
+ * @param point The offset to split the bucket at
+ }
+//#define apr_bucket_split(e,point) (e)->type->split(e, point)
+
+{
+ * Copy a bucket.
+ * @param e The bucket to copy
+ * @param c Returns a pointer to the new bucket
+ }
+//#define apr_bucket_copy(e,c) (e)->type->copy(e, c)
+
+{ Bucket type handling }
+
+{
+ * This function simply returns APR_SUCCESS to denote that the bucket does
+ * not require anything to happen for its setaside() function. This is
+ * appropriate for buckets that have "immortal" data -- the data will live
+ * at least as long as the bucket.
+ * @param data The bucket to setaside
+ * @param pool The pool defining the desired lifetime of the bucket data
+ * @return APR_SUCCESS
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_noop(apr_bucket *data,
+                                                          apr_pool_t *pool);
+}
+{
+ * A place holder function that signifies that the setaside function was not
+ * implemented for this bucket
+ * @param data The bucket to setaside
+ * @param pool The pool defining the desired lifetime of the bucket data
+ * @return APR_ENOTIMPL
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_setaside_notimpl(apr_bucket *data,
+                                                             apr_pool_t *pool);
+}
+{
+ * A place holder function that signifies that the split function was not
+ * implemented for this bucket
+ * @param data The bucket to split
+ * @param point The location to split the bucket
+ * @return APR_ENOTIMPL
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_split_notimpl(apr_bucket *data,
+                                                          apr_size_t point);
+}
+{
+ * A place holder function that signifies that the copy function was not
+ * implemented for this bucket
+ * @param e The bucket to copy
+ * @param c Returns a pointer to the new bucket
+ * @return APR_ENOTIMPL
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_copy_notimpl(apr_bucket *e,
+                                                         apr_bucket **c);
+}
+{
+ * A place holder function that signifies that this bucket does not need
+ * to do anything special to be destroyed.  That's only the case for buckets
+ * that either have no data (metadata buckets) or buckets whose data pointer
+ * points to something that's not a bucket-type-specific structure, as with
+ * simple buckets where data points to a string and pipe buckets where data
+ * points directly to the apr_file_t.
+ * @param data The bucket data to destroy
+ }
+//APU_DECLARE_NONSTD(void) apr_bucket_destroy_noop(void *data);
+
+{
+ * There is no apr_bucket_destroy_notimpl, because destruction is required
+ * to be implemented (it could be a noop, but only if that makes sense for
+ * the bucket type)
+ }
+
+{ There is no apr_bucket_read_notimpl, because it is a required function
+ }
+
+
+{ All of the bucket types implemented by the core }
+{
+ * The flush bucket type.  This signifies that all data should be flushed to
+ * the next filter.  The flush bucket should be sent with the other buckets.
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_flush;
+{
+ * The EOS bucket type.  This signifies that there will be no more data, ever.
+ * All filters MUST send all data to the next filter when they receive a
+ * bucket of this type
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_eos;
+{
+ * The FILE bucket type.  This bucket represents a file on disk
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_file;
+{
+ * The HEAP bucket type.  This bucket represents a data allocated from the
+ * heap.
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_heap;
+//#if APR_HAS_MMAP
+{
+ * The MMAP bucket type.  This bucket represents an MMAP'ed file
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_mmap;
+//#endif
+{
+ * The POOL bucket type.  This bucket represents a data that was allocated
+ * from a pool.  IF this bucket is still available when the pool is cleared,
+ * the data is copied on to the heap.
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pool;
+{
+ * The PIPE bucket type.  This bucket represents a pipe to another program.
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_pipe;
+{
+ * The IMMORTAL bucket type.  This bucket represents a segment of data that
+ * the creator is willing to take responsibility for.  The core will do
+ * nothing with the data in an immortal bucket
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_immortal;
+{
+ * The TRANSIENT bucket type.  This bucket represents a data allocated off
+ * the stack.  When the setaside function is called, this data is copied on
+ * to the heap
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_transient;
+{
+ * The SOCKET bucket type.  This bucket represents a socket to another machine
+ }
+//APU_DECLARE_DATA extern const apr_bucket_type_t apr_bucket_type_socket;
+
+
+{  *****  Simple buckets  *****  }
+
+{
+ * Split a simple bucket into two at the given point.  Most non-reference
+ * counting buckets that allow multiple references to the same block of
+ * data (eg transient and immortal) will use this as their split function
+ * without any additional type-specific handling.
+ * @param b The bucket to be split
+ * @param point The offset of the first byte in the new bucket
+ * @return APR_EINVAL if the point is not within the bucket;
+ *         APR_ENOMEM if allocation failed;
+ *         or APR_SUCCESS
+ }
+//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_split(apr_bucket *b,
+//                                                         apr_size_t point);
+
+{
+ * Copy a simple bucket.  Most non-reference-counting buckets that allow
+ * multiple references to the same block of data (eg transient and immortal)
+ * will use this as their copy function without any additional type-specific
+ * handling.
+ * @param a The bucket to copy
+ * @param b Returns a pointer to the new bucket
+ * @return APR_ENOMEM if allocation failed;
+ *         or APR_SUCCESS
+ }
+{APU_DECLARE_NONSTD(apr_status_t) apr_bucket_simple_copy(apr_bucket *a,
+                                                        apr_bucket **b);
+
+}
+{  *****  Shared, reference-counted buckets  *****  }
+
+{
+ * Initialize a bucket containing reference-counted data that may be
+ * shared. The caller must allocate the bucket if necessary and
+ * initialize its type-dependent fields, and allocate and initialize
+ * its own private data structure. This function should only be called
+ * by type-specific bucket creation functions.
+ * @param b The bucket to initialize
+ * @param data A pointer to the private data structure
+ *             with the reference count at the start
+ * @param start The start of the data in the bucket
+ *              relative to the private base pointer
+ * @param length The length of the data in the bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_shared_make(apr_bucket *b, void *data,
+				                 apr_off_t start, 
+                                                 apr_size_t length);
+}
+{
+ * Decrement the refcount of the data in the bucket. This function
+ * should only be called by type-specific bucket destruction functions.
+ * @param data The private data pointer from the bucket to be destroyed
+ * @return TRUE or FALSE; TRUE if the reference count is now
+ *         zero, indicating that the shared resource itself can
+ *         be destroyed by the caller.
+ }
+//APU_DECLARE(int) apr_bucket_shared_destroy(void *data);
+
+{
+ * Split a bucket into two at the given point, and adjust the refcount
+ * to the underlying data. Most reference-counting bucket types will
+ * be able to use this function as their split function without any
+ * additional type-specific handling.
+ * @param b The bucket to be split
+ * @param point The offset of the first byte in the new bucket
+ * @return APR_EINVAL if the point is not within the bucket;
+ *         APR_ENOMEM if allocation failed;
+ *         or APR_SUCCESS
+ }
+//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_split(apr_bucket *b,
+//                                                         apr_size_t point);
+
+{
+ * Copy a refcounted bucket, incrementing the reference count. Most
+ * reference-counting bucket types will be able to use this function
+ * as their copy function without any additional type-specific handling.
+ * @param a The bucket to copy
+ * @param b Returns a pointer to the new bucket
+ * @return APR_ENOMEM if allocation failed;
+           or APR_SUCCESS
+ }
+//APU_DECLARE_NONSTD(apr_status_t) apr_bucket_shared_copy(apr_bucket *a,
+//                                                        apr_bucket **b);
+
+
+{  *****  Functions to Create Buckets of varying types  *****  }
+{
+ * Each bucket type foo has two initialization functions:
+ * apr_bucket_foo_make which sets up some already-allocated memory as a
+ * bucket of type foo; and apr_bucket_foo_create which allocates memory
+ * for the bucket, calls apr_bucket_make_foo, and initializes the
+ * bucket's list pointers. The apr_bucket_foo_make functions are used
+ * inside the bucket code to change the type of buckets in place;
+ * other code should call apr_bucket_foo_create. All the initialization
+ * functions change nothing if they fail.
+ }
+
+{
+ * Create an End of Stream bucket.  This indicates that there is no more data
+ * coming from down the filter stack.  All filters should flush at this point.
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+//APU_DECLARE(apr_bucket *) apr_bucket_eos_create(apr_bucket_alloc_t *list);
+
+{
+ * Make the bucket passed in an EOS bucket.  This indicates that there is no 
+ * more data coming from down the filter stack.  All filters should flush at 
+ * this point.
+ * @param b The bucket to make into an EOS bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+//APU_DECLARE(apr_bucket *) apr_bucket_eos_make(apr_bucket *b);
+
+{
+ * Create a flush  bucket.  This indicates that filters should flush their
+ * data.  There is no guarantee that they will flush it, but this is the
+ * best we can do.
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+//APU_DECLARE(apr_bucket *) apr_bucket_flush_create(apr_bucket_alloc_t *list);
+
+{
+ * Make the bucket passed in a FLUSH  bucket.  This indicates that filters 
+ * should flush their data.  There is no guarantee that they will flush it, 
+ * but this is the best we can do.
+ * @param b The bucket to make into a FLUSH bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+//APU_DECLARE(apr_bucket *) apr_bucket_flush_make(apr_bucket *b);
+
+{
+ * Create a bucket referring to long-lived data.
+ * @param buf The data to insert into the bucket
+ * @param nbyte The size of the data to insert.
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_immortal_create(const char *buf,
+                                                     apr_size_t nbyte,
+                                                     apr_bucket_alloc_t *list);
+}
+{
+ * Make the bucket passed in a bucket refer to long-lived data
+ * @param b The bucket to make into a IMMORTAL bucket
+ * @param buf The data to insert into the bucket
+ * @param nbyte The size of the data to insert.
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_immortal_make(apr_bucket *b,
+                                                   const char *buf, 
+                                                   apr_size_t nbyte);
+}
+{
+ * Create a bucket referring to data on the stack.
+ * @param buf The data to insert into the bucket
+ * @param nbyte The size of the data to insert.
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_transient_create(const char *buf,
+                                                      apr_size_t nbyte,
+                                                      apr_bucket_alloc_t *list);
+}
+{
+ * Make the bucket passed in a bucket refer to stack data
+ * @param b The bucket to make into a TRANSIENT bucket
+ * @param buf The data to insert into the bucket
+ * @param nbyte The size of the data to insert.
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_transient_make(apr_bucket *b,
+                                                    const char *buf,
+                                                    apr_size_t nbyte);
+}
+{
+ * Create a bucket referring to memory on the heap. If the caller asks
+ * for the data to be copied, this function always allocates 4K of
+ * memory so that more data can be added to the bucket without
+ * requiring another allocation. Therefore not all the data may be put
+ * into the bucket. If copying is not requested then the bucket takes
+ * over responsibility for free()ing the memory.
+ * @param buf The buffer to insert into the bucket
+ * @param nbyte The size of the buffer to insert.
+ * @param free_func Function to use to free the data; NULL indicates that the
+ *                  bucket should make a copy of the data
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_heap_create(const char *buf,
+                                                 apr_size_t nbyte,
+                                                 void ( *free_func)(void *data),
+                                                 apr_bucket_alloc_t *list);}
+{
+ * Make the bucket passed in a bucket refer to heap data
+ * @param b The bucket to make into a HEAP bucket
+ * @param buf The buffer to insert into the bucket
+ * @param nbyte The size of the buffer to insert.
+ * @param free_func Function to use to free the data; NULL indicates that the
+ *                  bucket should make a copy of the data
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_heap_make(apr_bucket *b, const char *buf,
+                                               apr_size_t nbyte,
+                                               void ( *free_func)(void *data));}
+
+{
+ * Create a bucket referring to memory allocated from a pool.
+ *
+ * @param buf The buffer to insert into the bucket
+ * @param length The number of bytes referred to by this bucket
+ * @param pool The pool the memory was allocated from
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_pool_create(const char *buf,
+                                                 apr_size_t length,
+                                                 apr_pool_t *pool,
+                                                 apr_bucket_alloc_t *list);}
+
+{
+ * Make the bucket passed in a bucket refer to pool data
+ * @param b The bucket to make into a pool bucket
+ * @param buf The buffer to insert into the bucket
+ * @param length The number of bytes referred to by this bucket
+ * @param pool The pool the memory was allocated from
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_pool_make(apr_bucket *b, const char *buf,
+                                               apr_size_t length, 
+                                               apr_pool_t *pool);}
+
+//#if APR_HAS_MMAP
+{
+ * Create a bucket referring to mmap()ed memory.
+ * @param mm The mmap to insert into the bucket
+ * @param start The offset of the first byte in the mmap
+ *              that this bucket refers to
+ * @param length The number of bytes referred to by this bucket
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_mmap_create(apr_mmap_t *mm,
+                                                 apr_off_t start,
+                                                 apr_size_t length,
+                                                 apr_bucket_alloc_t *list);
+}
+{
+ * Make the bucket passed in a bucket refer to an MMAP'ed file
+ * @param b The bucket to make into a MMAP bucket
+ * @param mm The mmap to insert into the bucket
+ * @param start The offset of the first byte in the mmap
+ *              that this bucket refers to
+ * @param length The number of bytes referred to by this bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_mmap_make(apr_bucket *b, apr_mmap_t *mm,
+                                               apr_off_t start, 
+                                               apr_size_t length);
+#endif}
+
+{
+ * Create a bucket referring to a socket.
+ * @param thissock The socket to put in the bucket
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_socket_create(apr_socket_t *thissock,
+                                                   apr_bucket_alloc_t *list);}
+{
+ * Make the bucket passed in a bucket refer to a socket
+ * @param b The bucket to make into a SOCKET bucket
+ * @param thissock The socket to put in the bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_socket_make(apr_bucket *b,
+                                                 apr_socket_t *thissock);}
+
+{
+ * Create a bucket referring to a pipe.
+ * @param thispipe The pipe to put in the bucket
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_pipe_create(apr_file_t *thispipe,
+                                                 apr_bucket_alloc_t *list);}
+
+{
+ * Make the bucket passed in a bucket refer to a pipe
+ * @param b The bucket to make into a PIPE bucket
+ * @param thispipe The pipe to put in the bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_pipe_make(apr_bucket *b,
+                                               apr_file_t *thispipe);}
+
+{
+ * Create a bucket referring to a file.
+ * @param fd The file to put in the bucket
+ * @param offset The offset where the data of interest begins in the file
+ * @param len The amount of data in the file we are interested in
+ * @param p The pool into which any needed structures should be created
+ *          while reading from this file bucket
+ * @param list The freelist from which this bucket should be allocated
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_file_create(apr_file_t *fd,
+                                                 apr_off_t offset,
+                                                 apr_size_t len, 
+                                                 apr_pool_t *p,
+                                                 apr_bucket_alloc_t *list);
+}
+{
+ * Make the bucket passed in a bucket refer to a file
+ * @param b The bucket to make into a FILE bucket
+ * @param fd The file to put in the bucket
+ * @param offset The offset where the data of interest begins in the file
+ * @param len The amount of data in the file we are interested in
+ * @param p The pool into which any needed structures should be created
+ *          while reading from this file bucket
+ * @return The new bucket, or NULL if allocation failed
+ }
+{APU_DECLARE(apr_bucket *) apr_bucket_file_make(apr_bucket *b, apr_file_t *fd,
+                                               apr_off_t offset,
+                                               apr_size_t len, apr_pool_t *p);
+}
+{
+ * Enable or disable memory-mapping for a FILE bucket (default is enabled)
+ * @param b The bucket
+ * @param enabled Whether memory-mapping should be enabled
+ * @return APR_SUCCESS normally, or an error code if the operation fails
+ }
+{APU_DECLARE(apr_status_t) apr_bucket_file_enable_mmap(apr_bucket *b,
+                                                      int enabled);}
+

+ 95 - 0
packages/base/httpd/httpd-2.2/apr/apr_dso.inc

@@ -0,0 +1,95 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_dso.h
+ * @brief APR Dynamic Object Handling Routines
+ }
+
+{#include "apr.h"
+#include "apr_pools.h"
+#include "apr_errno.h"}
+
+{
+ * @defgroup apr_dso Dynamic Object Handling
+ * @ingroup APR 
+ }
+
+{$define APR_HAS_DSO}
+
+{$if defined(APR_HAS_DSO) or defined(DOXYGEN)}
+
+{
+ * Structure for referencing dynamic objects
+ }
+type
+  apr_dso_handle_t  = record
+  end;
+  Papr_dso_handle_t = ^apr_dso_handle_t;
+  PPapr_dso_handle_t = ^Papr_dso_handle_t;
+
+{
+ * Structure for referencing symbols from dynamic objects
+ }
+  apr_dso_handle_sym_t = Pointer;
+  Papr_dso_handle_sym_t = ^apr_dso_handle_sym_t;
+  PPapr_dso_handle_sym_t = ^Papr_dso_handle_sym_t;
+
+{
+ * Load a DSO library.
+ * @param res_handle Location to store new handle for the DSO.
+ * @param path Path to the DSO library
+ * @param ctx Pool to use.
+ * @bug We aught to provide an alternative to RTLD_GLOBAL, which
+ * is the only supported method of loading DSOs today.
+ }
+function apr_dso_load(res_handle: PPapr_dso_handle_t; const path: PChar;
+ ctx: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dso_load' + LibSuff12;
+
+{
+ * Close a DSO library.
+ * @param handle handle to close.
+ }
+function apr_dso_unload(handle: Papr_dso_handle_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dso_unload' + LibSuff4;
+
+{
+ * Load a symbol from a DSO handle.
+ * @param ressym Location to store the loaded symbol
+ * @param handle handle to load the symbol from.
+ * @param symname Name of the symbol to load.
+ }
+function apr_dso_sym(ressym: Papr_dso_handle_t; handle: Papr_dso_handle_t;
+ const symname: PChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dso_sym' + LibSuff12;
+
+{
+ * Report more information when a DSO function fails.
+ * @param dso The dso handle that has been opened
+ * @param buf Location to store the dso error
+ * @param bufsize The size of the provided buffer
+ }
+function apr_dso_error(dso: Papr_dso_handle_t; buf: PChar;
+ bufsize: apr_size_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dso_error' + LibSuff12;
+
+{$endif}
+

+ 1205 - 0
packages/base/httpd/httpd-2.2/apr/apr_errno.inc

@@ -0,0 +1,1205 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_errno.h
+ * @brief APR Error Codes
+ }
+
+{#include "apr.h"
+
+#if APR_HAVE_ERRNO_H
+#include <errno.h>
+#endif}
+
+{
+ * @defgroup apr_errno Error Codes
+ * @ingroup APR 
+ }
+
+{
+ * Type for specifying an error or status code.
+ }
+type
+  apr_status_t = Integer;
+  Papr_status_t = ^apr_status_t;
+
+{
+ * Return a human readable string describing the specified error.
+ * @param statcode The error code the get a string for.
+ * @param buf A buffer to hold the error string.
+ * @param bufsize Size of the buffer to hold the string.
+ }
+function apr_strerror(statcode: apr_status_t; buf: PChar; bufsize: apr_size_t): PChar;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_strerror' + LibSuff12;
+
+{$ifdef DOXYGEN)}
+{
+ * @def APR_FROM_OS_ERROR(os_err_type syserr)
+ * Fold a platform specific error into an apr_status_t code.
+ * @return apr_status_t
+ * @param e The platform os error code.
+ * @warning  macro implementation; the syserr argument may be evaluated
+ *      multiple times.
+ }
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+
+{
+ * @def APR_TO_OS_ERROR(apr_status_t statcode)
+ * @return os_err_type
+ * Fold an apr_status_t code back to the native platform defined error.
+ * @param e The apr_status_t folded platform os error code.
+ * @warning  macro implementation; the statcode argument may be evaluated
+ *      multiple times.  If the statcode was not created by apr_get_os_error 
+ *      or APR_FROM_OS_ERROR, the results are undefined.
+ }
+#define APR_TO_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+{ @def apr_get_os_error()
+ * @return apr_status_t the last platform error, folded into apr_status_t, on most platforms
+ * @remark This retrieves errno, or calls a GetLastError() style function, and
+ *      folds it with APR_FROM_OS_ERROR.  Some platforms (such as OS2) have no
+ *      such mechanism, so this call may be unsupported.  Do NOT use this
+ *      call for socket errors from socket, send, recv etc!
+ }
+
+{ @def apr_set_os_error(e)
+ * Reset the last platform error, unfolded from an apr_status_t, on some platforms
+ * @param e The OS error folded in a prior call to APR_FROM_OS_ERROR()
+ * @warning This is a macro implementation; the statcode argument may be evaluated
+ *      multiple times.  If the statcode was not created by apr_get_os_error
+ *      or APR_FROM_OS_ERROR, the results are undefined.  This macro sets
+ *      errno, or calls a SetLastError() style function, unfolding statcode
+ *      with APR_TO_OS_ERROR.  Some platforms (such as OS2) have no such
+ *      mechanism, so this call may be unsupported.
+ }
+
+{ @def apr_get_netos_error()
+ * Return the last socket error, folded into apr_status_t, on all platforms
+ * @remark This retrieves errno or calls a GetLastSocketError() style function,
+ *      and folds it with APR_FROM_OS_ERROR.
+ }
+
+{ @def apr_set_netos_error(e)
+ * Reset the last socket error, unfolded from an apr_status_t
+ * @param e The socket error folded in a prior call to APR_FROM_OS_ERROR()
+ * @warning This is a macro implementation; the statcode argument may be evaluated
+ *      multiple times.  If the statcode was not created by apr_get_os_error
+ *      or APR_FROM_OS_ERROR, the results are undefined.  This macro sets
+ *      errno, or calls a WSASetLastError() style function, unfolding 
+ *      socketcode with APR_TO_OS_ERROR.
+ }
+
+{$endif} { defined(DOXYGEN) }
+
+const
+{
+ * APR_OS_START_ERROR is where the APR specific error values start.
+ }
+  APR_OS_START_ERROR =    20000;
+{
+ * APR_OS_ERRSPACE_SIZE is the maximum number of errors you can fit
+ *    into one of the error/status ranges below -- except for
+ *    APR_OS_START_USERERR, which see.
+ }
+  APR_OS_ERRSPACE_SIZE = 50000;
+{
+ * APR_OS_START_STATUS is where the APR specific status codes start.
+ }
+  APR_OS_START_STATUS =   (APR_OS_START_ERROR + APR_OS_ERRSPACE_SIZE);
+{
+ * APR_OS_START_USERERR are reserved for applications that use APR that
+ *     layer their own error codes along with APR's.  Note that the
+ *     error immediately following this one is set ten times farther
+ *     away than usual, so that users of apr have a lot of room in
+ *     which to declare custom error codes.
+ }
+  APR_OS_START_USERERR =   (APR_OS_START_STATUS + APR_OS_ERRSPACE_SIZE);
+{
+ * APR_OS_START_USEERR is obsolete, defined for compatibility only.
+ * Use APR_OS_START_USERERR instead.
+ }
+  APR_OS_START_USEERR =    APR_OS_START_USERERR;
+{
+ * APR_OS_START_CANONERR is where APR versions of errno values are defined
+ *     on systems which don't have the corresponding errno.
+ }
+  APR_OS_START_CANONERR = (APR_OS_START_USERERR + (APR_OS_ERRSPACE_SIZE * 10));
+{
+ * APR_OS_START_EAIERR folds EAI_ error codes from getaddrinfo() into 
+ *     apr_status_t values.
+ }
+  APR_OS_START_EAIERR =   (APR_OS_START_CANONERR + APR_OS_ERRSPACE_SIZE);
+{
+ * APR_OS_START_SYSERR folds platform-specific system error values into 
+ *     apr_status_t values.
+ }
+  APR_OS_START_SYSERR =   (APR_OS_START_EAIERR + APR_OS_ERRSPACE_SIZE);
+
+{ no error. @see APR_STATUS_IS_SUCCESS }
+  APR_SUCCESS = 0;
+
+{
+ * @defgroup APR_Error APR Error Values
+ * <PRE>
+ * <b>APR ERROR VALUES</b>
+ * APR_ENOSTAT      APR was unable to perform a stat on the file 
+ * APR_ENOPOOL      APR was not provided a pool with which to allocate memory
+ * APR_EBADDATE     APR was given an invalid date 
+ * APR_EINVALSOCK   APR was given an invalid socket
+ * APR_ENOPROC      APR was not given a process structure
+ * APR_ENOTIME      APR was not given a time structure
+ * APR_ENODIR       APR was not given a directory structure
+ * APR_ENOLOCK      APR was not given a lock structure
+ * APR_ENOPOLL      APR was not given a poll structure
+ * APR_ENOSOCKET    APR was not given a socket
+ * APR_ENOTHREAD    APR was not given a thread structure
+ * APR_ENOTHDKEY    APR was not given a thread key structure
+ * APR_ENOSHMAVAIL  There is no more shared memory available
+ * APR_EDSOOPEN     APR was unable to open the dso object.  For more 
+ *                  information call apr_dso_error().
+ * APR_EGENERAL     General failure (specific information not available)
+ * APR_EBADIP       The specified IP address is invalid
+ * APR_EBADMASK     The specified netmask is invalid
+ * APR_ESYMNOTFOUND Could not find the requested symbol
+ * </PRE>
+ *
+ * <PRE>
+ * <b>APR STATUS VALUES</b>
+ * APR_INCHILD        Program is currently executing in the child
+ * APR_INPARENT       Program is currently executing in the parent
+ * APR_DETACH         The thread is detached
+ * APR_NOTDETACH      The thread is not detached
+ * APR_CHILD_DONE     The child has finished executing
+ * APR_CHILD_NOTDONE  The child has not finished executing
+ * APR_TIMEUP         The operation did not finish before the timeout
+ * APR_INCOMPLETE     The operation was incomplete although some processing
+ *                    was performed and the results are partially valid
+ * APR_BADCH          Getopt found an option not in the option string
+ * APR_BADARG         Getopt found an option that is missing an argument 
+ *                    and an argument was specified in the option string
+ * APR_EOF            APR has encountered the end of the file
+ * APR_NOTFOUND       APR was unable to find the socket in the poll structure
+ * APR_ANONYMOUS      APR is using anonymous shared memory
+ * APR_FILEBASED      APR is using a file name as the key to the shared memory
+ * APR_KEYBASED       APR is using a shared key as the key to the shared memory
+ * APR_EINIT          Ininitalizer value.  If no option has been found, but 
+ *                    the status variable requires a value, this should be used
+ * APR_ENOTIMPL       The APR function has not been implemented on this 
+ *                    platform, either because nobody has gotten to it yet, 
+ *                    or the function is impossible on this platform.
+ * APR_EMISMATCH      Two passwords do not match.
+ * APR_EABSOLUTE      The given path was absolute.
+ * APR_ERELATIVE      The given path was relative.
+ * APR_EINCOMPLETE    The given path was neither relative nor absolute.
+ * APR_EABOVEROOT     The given path was above the root path.
+ * APR_EBUSY          The given lock was busy.
+ * APR_EPROC_UNKNOWN  The given process wasn't recognized by APR
+ * </PRE>
+ }
+{ @see APR_STATUS_IS_ENOSTAT }
+  APR_ENOSTAT =       (APR_OS_START_ERROR + 1);
+{ @see APR_STATUS_IS_ENOPOOL }
+  APR_ENOPOOL =       (APR_OS_START_ERROR + 2);
+{ empty slot: +3 }
+{ @see APR_STATUS_IS_EBADDATE }
+  APR_EBADDATE =      (APR_OS_START_ERROR + 4);
+{ @see APR_STATUS_IS_EINVALSOCK }
+  APR_EINVALSOCK =    (APR_OS_START_ERROR + 5);
+{ @see APR_STATUS_IS_ENOPROC }
+  APR_ENOPROC =       (APR_OS_START_ERROR + 6);
+{ @see APR_STATUS_IS_ENOTIME }
+  APR_ENOTIME =       (APR_OS_START_ERROR + 7);
+{ @see APR_STATUS_IS_ENODIR }
+  APR_ENODIR  =       (APR_OS_START_ERROR + 8);
+{ @see APR_STATUS_IS_ENOLOCK }
+  APR_ENOLOCK =       (APR_OS_START_ERROR + 9);
+{ @see APR_STATUS_IS_ENOPOLL }
+  APR_ENOPOLL =       (APR_OS_START_ERROR + 10);
+{ @see APR_STATUS_IS_ENOSOCKET }
+  APR_ENOSOCKET =     (APR_OS_START_ERROR + 11);
+{ @see APR_STATUS_IS_ENOTHREAD }
+  APR_ENOTHREAD =     (APR_OS_START_ERROR + 12);
+{ @see APR_STATUS_IS_ENOTHDKEY }
+  APR_ENOTHDKEY =     (APR_OS_START_ERROR + 13);
+{ @see APR_STATUS_IS_EGENERAL }
+  APR_EGENERAL =      (APR_OS_START_ERROR + 14);
+{ @see APR_STATUS_IS_ENOSHMAVAIL }
+  APR_ENOSHMAVAIL =   (APR_OS_START_ERROR + 15);
+{ @see APR_STATUS_IS_EBADIP }
+  APR_EBADIP =        (APR_OS_START_ERROR + 16);
+{ @see APR_STATUS_IS_EBADMASK }
+  APR_EBADMASK =      (APR_OS_START_ERROR + 17);
+{ empty slot: +18 }
+{ @see APR_STATUS_IS_EDSOPEN }
+  APR_EDSOOPEN =      (APR_OS_START_ERROR + 19);
+{ @see APR_STATUS_IS_EABSOLUTE }
+  APR_EABSOLUTE =     (APR_OS_START_ERROR + 20);
+{ @see APR_STATUS_IS_ERELATIVE }
+  APR_ERELATIVE =     (APR_OS_START_ERROR + 21);
+{ @see APR_STATUS_IS_EINCOMPLETE }
+  APR_EINCOMPLETE =   (APR_OS_START_ERROR + 22);
+{ @see APR_STATUS_IS_EABOVEROOT }
+  APR_EABOVEROOT =    (APR_OS_START_ERROR + 23);
+{ @see APR_STATUS_IS_EBADPATH }
+ APR_EBADPATH =      (APR_OS_START_ERROR + 24);
+{ @see APR_STATUS_IS_EPATHWILD }
+  APR_EPATHWILD =     (APR_OS_START_ERROR + 25);
+{ @see APR_STATUS_IS_ESYMNOTFOUND }
+  APR_ESYMNOTFOUND =  (APR_OS_START_ERROR + 26);
+{ @see APR_STATUS_IS_EPROC_UNKNOWN }
+  APR_EPROC_UNKNOWN = (APR_OS_START_ERROR + 27);
+{ @see APR_STATUS_IS_ENOTENOUGHENTROPY }
+  APR_ENOTENOUGHENTROPY = (APR_OS_START_ERROR + 28);
+
+{
+ * @defgroup APR_STATUS_IS Status Value Tests
+ * @warning For any particular error condition, more than one of these tests
+ *      may match. This is because platform-specific error codes may not
+ *      always match the semantics of the POSIX codes these tests (and the
+ *      corresponding APR error codes) are named after. A notable example
+ *      are the APR_STATUS_IS_ENOENT and APR_STATUS_IS_ENOTDIR tests on
+ *      Win32 platforms. The programmer should always be aware of this and
+ *      adjust the order of the tests accordingly.
+ }
+{
+ * APR was unable to perform a stat on the file 
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_ENOSTAT(s)        ((s) == APR_ENOSTAT)
+{
+ * APR was not provided a pool with which to allocate memory 
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_ENOPOOL(s)        ((s) == APR_ENOPOOL)
+{ APR was given an invalid date  }
+//#define APR_STATUS_IS_EBADDATE(s)       ((s) == APR_EBADDATE)
+{ APR was given an invalid socket }
+//#define APR_STATUS_IS_EINVALSOCK(s)     ((s) == APR_EINVALSOCK)
+{ APR was not given a process structure }
+//#define APR_STATUS_IS_ENOPROC(s)        ((s) == APR_ENOPROC)
+{ APR was not given a time structure }
+//#define APR_STATUS_IS_ENOTIME(s)        ((s) == APR_ENOTIME)
+{ APR was not given a directory structure }
+//#define APR_STATUS_IS_ENODIR(s)         ((s) == APR_ENODIR)
+{ APR was not given a lock structure }
+//#define APR_STATUS_IS_ENOLOCK(s)        ((s) == APR_ENOLOCK)
+{ APR was not given a poll structure }
+//#define APR_STATUS_IS_ENOPOLL(s)        ((s) == APR_ENOPOLL)
+{ APR was not given a socket }
+//#define APR_STATUS_IS_ENOSOCKET(s)      ((s) == APR_ENOSOCKET)
+{ APR was not given a thread structure }
+//#define APR_STATUS_IS_ENOTHREAD(s)      ((s) == APR_ENOTHREAD)
+{ APR was not given a thread key structure }
+//#define APR_STATUS_IS_ENOTHDKEY(s)      ((s) == APR_ENOTHDKEY)
+{ Generic Error which can not be put into another spot }
+//#define APR_STATUS_IS_EGENERAL(s)       ((s) == APR_EGENERAL)
+{ There is no more shared memory available }
+//#define APR_STATUS_IS_ENOSHMAVAIL(s)    ((s) == APR_ENOSHMAVAIL)
+{ The specified IP address is invalid }
+//#define APR_STATUS_IS_EBADIP(s)         ((s) == APR_EBADIP)
+{ The specified netmask is invalid }
+//#define APR_STATUS_IS_EBADMASK(s)       ((s) == APR_EBADMASK)
+{ empty slot: +18 }
+{
+ * APR was unable to open the dso object.  
+ * For more information call apr_dso_error().
+ }
+//#if defined(WIN32)
+//#define APR_STATUS_IS_EDSOOPEN(s)       ((s) == APR_EDSOOPEN \
+//                       || APR_TO_OS_ERROR(s) == ERROR_MOD_NOT_FOUND)
+//#else
+//#define APR_STATUS_IS_EDSOOPEN(s)       ((s) == APR_EDSOOPEN)
+//#endif
+{ The given path was absolute. }
+//#define APR_STATUS_IS_EABSOLUTE(s)      ((s) == APR_EABSOLUTE)
+{ The given path was relative. }
+//#define APR_STATUS_IS_ERELATIVE(s)      ((s) == APR_ERELATIVE)
+{ The given path was neither relative nor absolute. }
+//#define APR_STATUS_IS_EINCOMPLETE(s)    ((s) == APR_EINCOMPLETE)
+{ The given path was above the root path. }
+//#define APR_STATUS_IS_EABOVEROOT(s)     ((s) == APR_EABOVEROOT)
+{ The given path was bad. }
+//#define APR_STATUS_IS_EBADPATH(s)       ((s) == APR_EBADPATH)
+{ The given path contained wildcards. }
+//#define APR_STATUS_IS_EPATHWILD(s)      ((s) == APR_EPATHWILD)
+{ Could not find the requested symbol.
+ * For more information call apr_dso_error().
+ }
+//#if defined(WIN32)
+//#define APR_STATUS_IS_ESYMNOTFOUND(s)   ((s) == APR_ESYMNOTFOUND \
+//                       || APR_TO_OS_ERROR(s) == ERROR_PROC_NOT_FOUND)
+//#else
+//#define APR_STATUS_IS_ESYMNOTFOUND(s)   ((s) == APR_ESYMNOTFOUND)
+//#endif
+{ The given process was not recognized by APR. }
+//#define APR_STATUS_IS_EPROC_UNKNOWN(s)  ((s) == APR_EPROC_UNKNOWN)
+
+{ APR could not gather enough entropy to continue. }
+//#define APR_STATUS_IS_ENOTENOUGHENTROPY(s) ((s) == APR_ENOTENOUGHENTROPY)
+
+{
+ * @addtogroup APR_Error
+ }
+{ @see APR_STATUS_IS_INCHILD }
+  APR_INCHILD       = (APR_OS_START_STATUS + 1);
+{ @see APR_STATUS_IS_INPARENT }
+  APR_INPARENT      = (APR_OS_START_STATUS + 2);
+{ @see APR_STATUS_IS_DETACH }
+  APR_DETACH        = (APR_OS_START_STATUS + 3);
+{ @see APR_STATUS_IS_NOTDETACH }
+  APR_NOTDETACH     = (APR_OS_START_STATUS + 4);
+{ @see APR_STATUS_IS_CHILD_DONE }
+  APR_CHILD_DONE    = (APR_OS_START_STATUS + 5);
+{ @see APR_STATUS_IS_CHILD_NOTDONE }
+  APR_CHILD_NOTDONE = (APR_OS_START_STATUS + 6);
+{ @see APR_STATUS_IS_TIMEUP }
+  APR_TIMEUP        = (APR_OS_START_STATUS + 7);
+{ @see APR_STATUS_IS_INCOMPLETE }
+  APR_INCOMPLETE    = (APR_OS_START_STATUS + 8);
+{ empty slot: +9 }
+{ empty slot: +10 }
+{ empty slot: +11 }
+{ @see APR_STATUS_IS_BADCH }
+  APR_BADCH         = (APR_OS_START_STATUS + 12);
+{ @see APR_STATUS_IS_BADARG }
+  APR_BADARG        = (APR_OS_START_STATUS + 13);
+{ @see APR_STATUS_IS_EOF }
+  APR_EOF           = (APR_OS_START_STATUS + 14);
+{ @see APR_STATUS_IS_NOTFOUND }
+  APR_NOTFOUND      = (APR_OS_START_STATUS + 15);
+{ empty slot: +16 }
+{ empty slot: +17 }
+{ empty slot: +18 }
+{ @see APR_STATUS_IS_ANONYMOUS }
+  APR_ANONYMOUS     = (APR_OS_START_STATUS + 19);
+{ @see APR_STATUS_IS_FILEBASED }
+  APR_FILEBASED     = (APR_OS_START_STATUS + 20);
+{ @see APR_STATUS_IS_KEYBASED }
+  APR_KEYBASED      = (APR_OS_START_STATUS + 21);
+{ @see APR_STATUS_IS_EINIT }
+  APR_EINIT         = (APR_OS_START_STATUS + 22);
+{ @see APR_STATUS_IS_ENOTIMPL }
+  APR_ENOTIMPL      = (APR_OS_START_STATUS + 23);
+{ @see APR_STATUS_IS_EMISMATCH }
+  APR_EMISMATCH     = (APR_OS_START_STATUS + 24);
+{ @see APR_STATUS_IS_EBUSY }
+  APR_EBUSY         = (APR_OS_START_STATUS + 25);
+
+{
+ * @addtogroup APR_STATUS_IS
+ }
+{
+ * Program is currently executing in the child 
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code }
+//#define APR_STATUS_IS_INCHILD(s)        ((s) == APR_INCHILD)
+{
+ * Program is currently executing in the parent 
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_INPARENT(s)       ((s) == APR_INPARENT)
+{
+ * The thread is detached 
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_DETACH(s)         ((s) == APR_DETACH)
+{
+ * The thread is not detached 
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_NOTDETACH(s)      ((s) == APR_NOTDETACH)
+{
+ * The child has finished executing
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_CHILD_DONE(s)     ((s) == APR_CHILD_DONE)
+{
+ * The child has not finished executing
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_CHILD_NOTDONE(s)  ((s) == APR_CHILD_NOTDONE)
+{
+ * The operation did not finish before the timeout
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP)
+{
+ * The operation was incomplete although some processing was performed
+ * and the results are partially valid.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_INCOMPLETE(s)     ((s) == APR_INCOMPLETE)
+{ empty slot: +9 }
+{ empty slot: +10 }
+{ empty slot: +11 }
+{
+ * Getopt found an option not in the option string
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_BADCH(s)          ((s) == APR_BADCH)
+{
+ * Getopt found an option not in the option string and an argument was 
+ * specified in the option string
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_BADARG(s)         ((s) == APR_BADARG)
+{
+ * APR has encountered the end of the file
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_EOF(s)            ((s) == APR_EOF)
+{
+ * APR was unable to find the socket in the poll structure
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_NOTFOUND(s)       ((s) == APR_NOTFOUND)
+{ empty slot: +16 }
+{ empty slot: +17 }
+{ empty slot: +18 }
+{
+ * APR is using anonymous shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_ANONYMOUS(s)      ((s) == APR_ANONYMOUS)
+{
+ * APR is using a file name as the key to the shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_FILEBASED(s)      ((s) == APR_FILEBASED)
+{
+ * APR is using a shared key as the key to the shared memory
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_KEYBASED(s)       ((s) == APR_KEYBASED)
+{
+ * Ininitalizer value.  If no option has been found, but 
+ * the status variable requires a value, this should be used
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_EINIT(s)          ((s) == APR_EINIT)
+{
+ * The APR function has not been implemented on this 
+ * platform, either because nobody has gotten to it yet, 
+ * or the function is impossible on this platform.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_ENOTIMPL(s)       ((s) == APR_ENOTIMPL)
+{
+ * Two passwords do not match.
+ * @warning
+ * always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_EMISMATCH(s)      ((s) == APR_EMISMATCH)
+{
+ * The given lock was busy
+ * @warning always use this test, as platform-specific variances may meet this
+ * more than one error code 
+ }
+//#define APR_STATUS_IS_EBUSY(s)          ((s) == APR_EBUSY)
+
+{
+ * @addtogroup APR_Error APR Error Values
+ }
+{ APR CANONICAL ERROR VALUES }
+{ @see APR_STATUS_IS_EACCES }
+{#ifdef EACCES
+#define APR_EACCES EACCES
+#else
+#define APR_EACCES         (APR_OS_START_CANONERR + 1)
+#endif
+}
+{ @see APR_STATUS_IS_EXIST }
+{#ifdef EEXIST
+#define APR_EEXIST EEXIST
+#else
+#define APR_EEXIST         (APR_OS_START_CANONERR + 2)
+#endif
+}
+{ @see APR_STATUS_IS_ENAMETOOLONG }
+{#ifdef ENAMETOOLONG
+#define APR_ENAMETOOLONG ENAMETOOLONG
+#else
+#define APR_ENAMETOOLONG   (APR_OS_START_CANONERR + 3)
+#endif
+}
+{ @see APR_STATUS_IS_ENOENT }
+{#ifdef ENOENT
+#define APR_ENOENT ENOENT
+#else
+#define APR_ENOENT         (APR_OS_START_CANONERR + 4)
+#endif
+}
+{ @see APR_STATUS_IS_ENOTDIR }
+{#ifdef ENOTDIR
+#define APR_ENOTDIR ENOTDIR
+#else
+#define APR_ENOTDIR        (APR_OS_START_CANONERR + 5)
+#endif
+}
+{ @see APR_STATUS_IS_ENOSPC }
+{#ifdef ENOSPC
+#define APR_ENOSPC ENOSPC
+#else
+#define APR_ENOSPC         (APR_OS_START_CANONERR + 6)
+#endif
+}
+{ @see APR_STATUS_IS_ENOMEM }
+{#ifdef ENOMEM
+#define APR_ENOMEM ENOMEM
+#else
+#define APR_ENOMEM         (APR_OS_START_CANONERR + 7)
+#endif
+}
+{ @see APR_STATUS_IS_EMFILE }
+{#ifdef EMFILE
+#define APR_EMFILE EMFILE
+#else
+#define APR_EMFILE         (APR_OS_START_CANONERR + 8)
+#endif
+}
+{ @see APR_STATUS_IS_ENFILE }
+{#ifdef ENFILE
+#define APR_ENFILE ENFILE
+#else
+#define APR_ENFILE         (APR_OS_START_CANONERR + 9)
+#endif
+}
+{ @see APR_STATUS_IS_EBADF }
+{#ifdef EBADF
+#define APR_EBADF EBADF
+#else
+#define APR_EBADF          (APR_OS_START_CANONERR + 10)
+#endif
+}
+{ @see APR_STATUS_IS_EINVAL }
+{#ifdef EINVAL
+#define APR_EINVAL EINVAL
+#else
+#define APR_EINVAL         (APR_OS_START_CANONERR + 11)
+#endif
+}
+{ @see APR_STATUS_IS_ESPIPE }
+{#ifdef ESPIPE
+#define APR_ESPIPE ESPIPE
+#else
+#define APR_ESPIPE         (APR_OS_START_CANONERR + 12)
+#endif
+}
+{
+ * @see APR_STATUS_IS_EAGAIN 
+ * @warning use APR_STATUS_IS_EAGAIN instead of just testing this value
+ }
+{#ifdef EAGAIN
+#define APR_EAGAIN EAGAIN
+#elif defined(EWOULDBLOCK)
+#define APR_EAGAIN EWOULDBLOCK
+#else
+#define APR_EAGAIN         (APR_OS_START_CANONERR + 13)
+#endif
+}
+{ @see APR_STATUS_IS_EINTR }
+{#ifdef EINTR
+#define APR_EINTR EINTR
+#else
+#define APR_EINTR          (APR_OS_START_CANONERR + 14)
+#endif
+}
+{ @see APR_STATUS_IS_ENOTSOCK }
+{#ifdef ENOTSOCK
+#define APR_ENOTSOCK ENOTSOCK
+#else
+#define APR_ENOTSOCK       (APR_OS_START_CANONERR + 15)
+#endif
+}
+{ @see APR_STATUS_IS_ECONNREFUSED }
+{#ifdef ECONNREFUSED
+#define APR_ECONNREFUSED ECONNREFUSED
+#else
+#define APR_ECONNREFUSED   (APR_OS_START_CANONERR + 16)
+#endif
+}
+{ @see APR_STATUS_IS_EINPROGRESS }
+{#ifdef EINPROGRESS
+#define APR_EINPROGRESS EINPROGRESS
+#else
+#define APR_EINPROGRESS    (APR_OS_START_CANONERR + 17)
+#endif
+}
+{
+ * @see APR_STATUS_IS_ECONNABORTED
+ * @warning use APR_STATUS_IS_ECONNABORTED instead of just testing this value
+ }
+
+{#ifdef ECONNABORTED
+#define APR_ECONNABORTED ECONNABORTED
+#else
+#define APR_ECONNABORTED   (APR_OS_START_CANONERR + 18)
+#endif
+}
+{ @see APR_STATUS_IS_ECONNRESET }
+{#ifdef ECONNRESET
+#define APR_ECONNRESET ECONNRESET
+#else
+#define APR_ECONNRESET     (APR_OS_START_CANONERR + 19)
+#endif
+}
+{* @see APR_STATUS_IS_ETIMEDOUT
+ * @deprecated}
+{#ifdef ETIMEDOUT
+#define APR_ETIMEDOUT ETIMEDOUT
+#else
+#define APR_ETIMEDOUT      (APR_OS_START_CANONERR + 20)
+#endif
+}
+{ @see APR_STATUS_IS_EHOSTUNREACH }
+{#ifdef EHOSTUNREACH
+#define APR_EHOSTUNREACH EHOSTUNREACH
+#else
+#define APR_EHOSTUNREACH   (APR_OS_START_CANONERR + 21)
+#endif
+}
+{ @see APR_STATUS_IS_ENETUNREACH }
+{#ifdef ENETUNREACH
+#define APR_ENETUNREACH ENETUNREACH
+#else
+#define APR_ENETUNREACH    (APR_OS_START_CANONERR + 22)
+#endif
+}
+{ @see APR_STATUS_IS_EFTYPE }
+{#ifdef EFTYPE
+#define APR_EFTYPE EFTYPE
+#else
+#define APR_EFTYPE        (APR_OS_START_CANONERR + 23)
+#endif
+}
+{ @see APR_STATUS_IS_EPIPE }
+{#ifdef EPIPE
+#define APR_EPIPE EPIPE
+#else
+#define APR_EPIPE         (APR_OS_START_CANONERR + 24)
+#endif
+}
+{ @see APR_STATUS_IS_EXDEV }
+{#ifdef EXDEV
+#define APR_EXDEV EXDEV
+#else
+#define APR_EXDEV         (APR_OS_START_CANONERR + 25)
+#endif
+}
+{ @see APR_STATUS_IS_ENOTEMPTY }
+{#ifdef ENOTEMPTY
+#define APR_ENOTEMPTY ENOTEMPTY
+#else
+#define APR_ENOTEMPTY     (APR_OS_START_CANONERR + 26)
+#endif
+
+#if defined(OS2) && !defined(DOXYGEN)
+
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define INCL_DOSERRORS
+#define INCL_DOS
+}
+{ Leave these undefined.
+ * OS2 doesn't rely on the errno concept.
+ * The API calls always return a result codes which
+ * should be filtered through APR_FROM_OS_ERROR().
+ *
+ * #define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
+ * #define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))
+ }
+
+{ A special case, only socket calls require this;
+ }
+{#define apr_get_netos_error()   (APR_FROM_OS_ERROR(errno))
+#define apr_set_netos_error(e)  (errno = APR_TO_OS_ERROR(e))
+}
+{ And this needs to be greped away for good:
+ }
+{#define APR_OS2_STATUS(e) (APR_FROM_OS_ERROR(e))
+
+}
+{ These can't sit in a private header, so in spite of the extra size,
+ * they need to be made available here.
+ }
+  SOCBASEERR             = 10000;
+  SOCEPERM               = (SOCBASEERR+1);             { Not owner }
+  SOCESRCH               = (SOCBASEERR+3);             { No such process }
+  SOCEINTR               = (SOCBASEERR+4);             { Interrupted system call }
+  SOCENXIO               = (SOCBASEERR+6);             { No such device or address }
+  SOCEBADF               = (SOCBASEERR+9);             { Bad file number }
+  SOCEACCES              = (SOCBASEERR+13);            { Permission denied }
+  SOCEFAULT              = (SOCBASEERR+14);            { Bad address }
+  SOCEINVAL              = (SOCBASEERR+22);            { Invalid argument }
+  SOCEMFILE              = (SOCBASEERR+24);            { Too many open files }
+  SOCEPIPE               = (SOCBASEERR+32);            { Broken pipe }
+  SOCEOS2ERR             = (SOCBASEERR+100);           { OS/2 Error }
+  SOCEWOULDBLOCK         = (SOCBASEERR+35);            { Operation would block }
+  SOCEINPROGRESS         = (SOCBASEERR+36);            { Operation now in progress }
+  SOCEALREADY            = (SOCBASEERR+37);            { Operation already in progress }
+  SOCENOTSOCK            = (SOCBASEERR+38);            { Socket operation on non-socket }
+  SOCEDESTADDRREQ        = (SOCBASEERR+39);            { Destination address required }
+  SOCEMSGSIZE            = (SOCBASEERR+40);            { Message too long }
+  SOCEPROTOTYPE          = (SOCBASEERR+41);            { Protocol wrong type for socket }
+  SOCENOPROTOOPT         = (SOCBASEERR+42);            { Protocol not available }
+  SOCEPROTONOSUPPORT     = (SOCBASEERR+43);            { Protocol not supported }
+  SOCESOCKTNOSUPPORT     = (SOCBASEERR+44);            { Socket type not supported }
+  SOCEOPNOTSUPP          = (SOCBASEERR+45);            { Operation not supported on socket }
+  SOCEPFNOSUPPORT        = (SOCBASEERR+46);            { Protocol family not supported }
+  SOCEAFNOSUPPORT        = (SOCBASEERR+47);            { Address family not supported by protocol family }
+  SOCEADDRINUSE          = (SOCBASEERR+48);            { Address already in use }
+  SOCEADDRNOTAVAIL       = (SOCBASEERR+49);            { Can't assign requested address }
+  SOCENETDOWN            = (SOCBASEERR+50);            { Network is down }
+  SOCENETUNREACH         = (SOCBASEERR+51);            { Network is unreachable }
+  SOCENETRESET           = (SOCBASEERR+52);            { Network dropped connection on reset }
+  SOCECONNABORTED        = (SOCBASEERR+53);            { Software caused connection abort }
+  SOCECONNRESET          = (SOCBASEERR+54);            { Connection reset by peer }
+  SOCENOBUFS             = (SOCBASEERR+55);            { No buffer space available }
+  SOCEISCONN             = (SOCBASEERR+56);            { Socket is already connected }
+  SOCENOTCONN            = (SOCBASEERR+57);            { Socket is not connected }
+  SOCESHUTDOWN           = (SOCBASEERR+58);            { Can't send after socket shutdown }
+  SOCETOOMANYREFS        = (SOCBASEERR+59);            { Too many references: can't splice }
+  SOCETIMEDOUT           = (SOCBASEERR+60);            { Connection timed out }
+  SOCECONNREFUSED        = (SOCBASEERR+61);            { Connection refused }
+  SOCELOOP               = (SOCBASEERR+62);            { Too many levels of symbolic links }
+  SOCENAMETOOLONG        = (SOCBASEERR+63);            { File name too long }
+  SOCEHOSTDOWN           = (SOCBASEERR+64);            { Host is down }
+  SOCEHOSTUNREACH        = (SOCBASEERR+65);            { No route to host }
+  SOCENOTEMPTY           = (SOCBASEERR+66);            { Directory not empty }
+
+{ APR CANONICAL ERROR TESTS }
+{#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES \
+                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
+                || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
+#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST \
+                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
+                || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS \
+                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
+#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
+                || (s) == APR_OS_START_SYSERR + SOCENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
+                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+                || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES \
+                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED)
+#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
+#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC \
+                || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
+#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
+#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE \
+                || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
+#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE)
+#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION)
+#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
+                || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
+                || (s) == APR_OS_START_SYSERR + SOCEWOULDBLOCK \
+                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION)
+#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
+                || (s) == APR_OS_START_SYSERR + SOCEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
+                || (s) == APR_OS_START_SYSERR + SOCENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
+                || (s) == APR_OS_START_SYSERR + SOCECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
+                || (s) == APR_OS_START_SYSERR + SOCEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
+                || (s) == APR_OS_START_SYSERR + SOCECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
+                || (s) == APR_OS_START_SYSERR + SOCECONNRESET)
+/* XXX deprecated */
+#define APR_STATUS_IS_ETIMEDOUT(s)         ((s) == APR_ETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
+#undef APR_STATUS_IS_TIMEUP
+#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP \
+                || (s) == APR_OS_START_SYSERR + SOCETIMEDOUT)
+#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
+                || (s) == APR_OS_START_SYSERR + SOCEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
+                || (s) == APR_OS_START_SYSERR + SOCENETUNREACH)
+#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE)
+#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE \
+                || (s) == APR_OS_START_SYSERR + SOCEPIPE)
+#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV \
+                || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
+#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY \
+                || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY \
+                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED)
+}
+{
+    Sorry, too tired to wrap this up for OS2... feel free to
+    fit the following into their best matches.
+
+    ( ERROR_NO_SIGNAL_SENT,     ESRCH           ),
+    ( SOCEALREADY,              EALREADY        ),
+    ( SOCEDESTADDRREQ,          EDESTADDRREQ    ),
+    ( SOCEMSGSIZE,              EMSGSIZE        ),
+    ( SOCEPROTOTYPE,            EPROTOTYPE      ),
+    ( SOCENOPROTOOPT,           ENOPROTOOPT     ),
+    ( SOCEPROTONOSUPPORT,       EPROTONOSUPPORT ),
+    ( SOCESOCKTNOSUPPORT,       ESOCKTNOSUPPORT ),
+    ( SOCEOPNOTSUPP,            EOPNOTSUPP      ),
+    ( SOCEPFNOSUPPORT,          EPFNOSUPPORT    ),
+    ( SOCEAFNOSUPPORT,          EAFNOSUPPORT    ),
+    ( SOCEADDRINUSE,            EADDRINUSE      ),
+    ( SOCEADDRNOTAVAIL,         EADDRNOTAVAIL   ),
+    ( SOCENETDOWN,              ENETDOWN        ),
+    ( SOCENETRESET,             ENETRESET       ),
+    ( SOCENOBUFS,               ENOBUFS         ),
+    ( SOCEISCONN,               EISCONN         ),
+    ( SOCENOTCONN,              ENOTCONN        ),
+    ( SOCESHUTDOWN,             ESHUTDOWN       ),
+    ( SOCETOOMANYREFS,          ETOOMANYREFS    ),
+    ( SOCELOOP,                 ELOOP           ),
+    ( SOCEHOSTDOWN,             EHOSTDOWN       ),
+    ( SOCENOTEMPTY,             ENOTEMPTY       ),
+    ( SOCEPIPE,                 EPIPE           )
+}
+
+//#elif defined(WIN32) && !defined(DOXYGEN) { !defined(OS2) }
+
+{#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define apr_get_os_error()   (APR_FROM_OS_ERROR(GetLastError()))
+#define apr_set_os_error(e)  (SetLastError(APR_TO_OS_ERROR(e)))}
+
+{ A special case, only socket calls require this:
+ }
+{#define apr_get_netos_error()   (APR_FROM_OS_ERROR(WSAGetLastError()))
+#define apr_set_netos_error(e)   (WSASetLastError(APR_TO_OS_ERROR(e)))
+
+}
+{ APR CANONICAL ERROR TESTS }
+{#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES \
+                || (s) == APR_OS_START_SYSERR + ERROR_ACCESS_DENIED \
+                || (s) == APR_OS_START_SYSERR + ERROR_CANNOT_MAKE \
+                || (s) == APR_OS_START_SYSERR + ERROR_CURRENT_DIRECTORY \
+                || (s) == APR_OS_START_SYSERR + ERROR_DRIVE_LOCKED \
+                || (s) == APR_OS_START_SYSERR + ERROR_FAIL_I24 \
+                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
+                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_FAILED \
+                || (s) == APR_OS_START_SYSERR + ERROR_NOT_LOCKED \
+                || (s) == APR_OS_START_SYSERR + ERROR_NETWORK_ACCESS_DENIED \
+                || (s) == APR_OS_START_SYSERR + ERROR_SHARING_VIOLATION)
+#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILE_EXISTS \
+                || (s) == APR_OS_START_SYSERR + ERROR_ALREADY_EXISTS)
+#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILENAME_EXCED_RANGE \
+                || (s) == APR_OS_START_SYSERR + WSAENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILE_NOT_FOUND \
+                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+                || (s) == APR_OS_START_SYSERR + ERROR_OPEN_FAILED \
+                || (s) == APR_OS_START_SYSERR + ERROR_NO_MORE_FILES)
+#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR \
+                || (s) == APR_OS_START_SYSERR + ERROR_PATH_NOT_FOUND \
+                || (s) == APR_OS_START_SYSERR + ERROR_BAD_NETPATH \
+                || (s) == APR_OS_START_SYSERR + ERROR_BAD_NET_NAME \
+                || (s) == APR_OS_START_SYSERR + ERROR_BAD_PATHNAME \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DRIVE)
+#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC \
+                || (s) == APR_OS_START_SYSERR + ERROR_DISK_FULL)
+#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM \
+                || (s) == APR_OS_START_SYSERR + ERROR_ARENA_TRASHED \
+                || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_MEMORY \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_BLOCK \
+                || (s) == APR_OS_START_SYSERR + ERROR_NOT_ENOUGH_QUOTA \
+                || (s) == APR_OS_START_SYSERR + ERROR_OUTOFMEMORY)
+#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE \
+                || (s) == APR_OS_START_SYSERR + ERROR_TOO_MANY_OPEN_FILES)
+#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_TARGET_HANDLE)
+#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_ACCESS \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DATA \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_FUNCTION \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_HANDLE \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_PARAMETER \
+                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_SEEK_ON_DEVICE \
+                || (s) == APR_OS_START_SYSERR + ERROR_NEGATIVE_SEEK)
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
+                || (s) == APR_OS_START_SYSERR + ERROR_NO_DATA \
+                || (s) == APR_OS_START_SYSERR + ERROR_NO_PROC_SLOTS \
+                || (s) == APR_OS_START_SYSERR + ERROR_NESTING_NOT_ALLOWED \
+                || (s) == APR_OS_START_SYSERR + ERROR_MAX_THRDS_REACHED \
+                || (s) == APR_OS_START_SYSERR + ERROR_LOCK_VIOLATION \
+                || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
+#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
+                || (s) == APR_OS_START_SYSERR + WSAEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
+                || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
+                || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
+                || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
+                || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
+                || (s) == APR_OS_START_SYSERR + ERROR_NETNAME_DELETED \
+                || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
+/* XXX deprecated */
+#define APR_STATUS_IS_ETIMEDOUT(s)         ((s) == APR_ETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#undef APR_STATUS_IS_TIMEUP
+#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP \
+                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
+                || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
+                || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
+#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_EXE_MACHINE_TYPE_MISMATCH \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_DLL \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_MODULETYPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_BAD_EXE_FORMAT \
+                || (s) == APR_OS_START_SYSERR + ERROR_INVALID_EXE_SIGNATURE \
+                || (s) == APR_OS_START_SYSERR + ERROR_FILE_CORRUPT \
+                || (s) == APR_OS_START_SYSERR + ERROR_BAD_FORMAT)
+#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE \
+                || (s) == APR_OS_START_SYSERR + ERROR_BROKEN_PIPE)
+#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV \
+                || (s) == APR_OS_START_SYSERR + ERROR_NOT_SAME_DEVICE)
+#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY \
+                || (s) == APR_OS_START_SYSERR + ERROR_DIR_NOT_EMPTY)
+}
+//#elif defined(NETWARE) && defined(USE_WINSOCK) && !defined(DOXYGEN) { !defined(OS2) && !defined(WIN32) }
+{
+#define APR_FROM_OS_ERROR(e) (e == 0 ? APR_SUCCESS : e + APR_OS_START_SYSERR)
+#define APR_TO_OS_ERROR(e)   (e == 0 ? APR_SUCCESS : e - APR_OS_START_SYSERR)
+
+#define apr_get_os_error()    (errno)
+#define apr_set_os_error(e)   (errno = (e))
+}
+{ A special case, only socket calls require this: }
+{#define apr_get_netos_error()   (APR_FROM_OS_ERROR(WSAGetLastError()))
+#define apr_set_netos_error(e)  (WSASetLastError(APR_TO_OS_ERROR(e)))
+
+}
+{ APR CANONICAL ERROR TESTS }
+{#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES)
+#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST)
+#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG)
+#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT)
+#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
+#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC)
+#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
+#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE)
+#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
+#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF)
+#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL)
+#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE)
+
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
+                || (s) ==                       EWOULDBLOCK \
+                || (s) == APR_OS_START_SYSERR + WSAEWOULDBLOCK)
+#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR \
+                || (s) == APR_OS_START_SYSERR + WSAEINTR)
+#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK \
+                || (s) == APR_OS_START_SYSERR + WSAENOTSOCK)
+#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED \
+                || (s) == APR_OS_START_SYSERR + WSAECONNREFUSED)
+#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS \
+                || (s) == APR_OS_START_SYSERR + WSAEINPROGRESS)
+#define APR_STATUS_IS_ECONNABORTED(s)   ((s) == APR_ECONNABORTED \
+                || (s) == APR_OS_START_SYSERR + WSAECONNABORTED)
+#define APR_STATUS_IS_ECONNRESET(s)     ((s) == APR_ECONNRESET \
+                || (s) == APR_OS_START_SYSERR + WSAECONNRESET)
+/* XXX deprecated */
+#define APR_STATUS_IS_ETIMEDOUT(s)       ((s) == APR_ETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#undef APR_STATUS_IS_TIMEUP
+#define APR_STATUS_IS_TIMEUP(s)         ((s) == APR_TIMEUP \
+                || (s) == APR_OS_START_SYSERR + WSAETIMEDOUT \
+                || (s) == APR_OS_START_SYSERR + WAIT_TIMEOUT)
+#define APR_STATUS_IS_EHOSTUNREACH(s)   ((s) == APR_EHOSTUNREACH \
+                || (s) == APR_OS_START_SYSERR + WSAEHOSTUNREACH)
+#define APR_STATUS_IS_ENETUNREACH(s)    ((s) == APR_ENETUNREACH \
+                || (s) == APR_OS_START_SYSERR + WSAENETUNREACH)
+#define APR_STATUS_IS_ENETDOWN(s)       ((s) == APR_OS_START_SYSERR + WSAENETDOWN)
+#define APR_STATUS_IS_EFTYPE(s)         ((s) == APR_EFTYPE)
+#define APR_STATUS_IS_EPIPE(s)          ((s) == APR_EPIPE)
+#define APR_STATUS_IS_EXDEV(s)          ((s) == APR_EXDEV)
+#define APR_STATUS_IS_ENOTEMPTY(s)      ((s) == APR_ENOTEMPTY)
+}
+//#else { !defined(NETWARE) && !defined(OS2) && !defined(WIN32) }
+
+{
+ *  os error codes are clib error codes
+ }
+{#define APR_FROM_OS_ERROR(e)  (e)
+#define APR_TO_OS_ERROR(e)    (e)
+
+#define apr_get_os_error()    (errno)
+#define apr_set_os_error(e)   (errno = (e))
+}
+{ A special case, only socket calls require this:
+ }
+//#define apr_get_netos_error() (errno)
+//#define apr_set_netos_error(e) (errno = (e))
+
+{
+ * @addtogroup APR_STATUS_IS
+ }
+
+{ permission denied }
+//#define APR_STATUS_IS_EACCES(s)         ((s) == APR_EACCES)
+{ file exists }
+//#define APR_STATUS_IS_EEXIST(s)         ((s) == APR_EEXIST)
+{ path name is too long }
+//#define APR_STATUS_IS_ENAMETOOLONG(s)   ((s) == APR_ENAMETOOLONG)
+{
+ * no such file or directory
+ * @remark
+ * EMVSCATLG can be returned by the automounter on z/OS for
+ * paths which do not exist.
+ }
+{#ifdef EMVSCATLG
+#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT \
+                                      || (s) == EMVSCATLG)
+#else
+#define APR_STATUS_IS_ENOENT(s)         ((s) == APR_ENOENT)
+#endif}
+{ not a directory }
+//#define APR_STATUS_IS_ENOTDIR(s)        ((s) == APR_ENOTDIR)
+{ no space left on device }
+//#define APR_STATUS_IS_ENOSPC(s)         ((s) == APR_ENOSPC)
+{ not enough memory }
+//#define APR_STATUS_IS_ENOMEM(s)         ((s) == APR_ENOMEM)
+{ too many open files }
+//#define APR_STATUS_IS_EMFILE(s)         ((s) == APR_EMFILE)
+{ file table overflow }
+//#define APR_STATUS_IS_ENFILE(s)         ((s) == APR_ENFILE)
+{ bad file # }
+//#define APR_STATUS_IS_EBADF(s)          ((s) == APR_EBADF)
+{ invalid argument }
+//#define APR_STATUS_IS_EINVAL(s)         ((s) == APR_EINVAL)
+{ illegal seek }
+//#define APR_STATUS_IS_ESPIPE(s)         ((s) == APR_ESPIPE)
+
+{ operation would block }
+{#if !defined(EWOULDBLOCK) || !defined(EAGAIN)
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN)
+#elif (EWOULDBLOCK == EAGAIN)
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN)
+#else
+#define APR_STATUS_IS_EAGAIN(s)         ((s) == APR_EAGAIN \
+                                      || (s) == EWOULDBLOCK)
+#endif
+}
+{ interrupted system call }
+//#define APR_STATUS_IS_EINTR(s)          ((s) == APR_EINTR)
+{ socket operation on a non-socket }
+//#define APR_STATUS_IS_ENOTSOCK(s)       ((s) == APR_ENOTSOCK)
+{ Connection Refused }
+//#define APR_STATUS_IS_ECONNREFUSED(s)   ((s) == APR_ECONNREFUSED)
+{ operation now in progress }
+//#define APR_STATUS_IS_EINPROGRESS(s)    ((s) == APR_EINPROGRESS)
+
+{
+ * Software caused connection abort 
+ * @remark
+ * EPROTO on certain older kernels really means ECONNABORTED, so we need to 
+ * ignore it for them.  See discussion in new-httpd archives nh.9701 & nh.9603
+ *
+ * There is potentially a bug in Solaris 2.x x<6, and other boxes that 
+ * implement tcp sockets in userland (i.e. on top of STREAMS).  On these
+ * systems, EPROTO can actually result in a fatal loop.  See PR#981 for 
+ * example.  It's hard to handle both uses of EPROTO.
+ }
+{#ifdef EPROTO
+#define APR_STATUS_IS_ECONNABORTED(s)    ((s) == APR_ECONNABORTED \
+                                       || (s) == EPROTO)
+#else
+#define APR_STATUS_IS_ECONNABORTED(s)    ((s) == APR_ECONNABORTED)
+#endif
+}
+{ Connection Reset by peer }
+//#define APR_STATUS_IS_ECONNRESET(s)      ((s) == APR_ECONNRESET)
+{* Operation timed out
+ * @deprecated}
+//#define APR_STATUS_IS_ETIMEDOUT(s)       ((s) == APR_ETIMEDOUT)
+{ no route to host }
+//#define APR_STATUS_IS_EHOSTUNREACH(s)    ((s) == APR_EHOSTUNREACH)
+{ network is unreachable }
+//#define APR_STATUS_IS_ENETUNREACH(s)     ((s) == APR_ENETUNREACH)
+{ inappropiate file type or format }
+//#define APR_STATUS_IS_EFTYPE(s)          ((s) == APR_EFTYPE)
+{ broken pipe }
+//#define APR_STATUS_IS_EPIPE(s)           ((s) == APR_EPIPE)
+{ cross device link }
+//#define APR_STATUS_IS_EXDEV(s)           ((s) == APR_EXDEV)
+{ Directory Not Empty }
+//#define APR_STATUS_IS_ENOTEMPTY(s)       ((s) == APR_ENOTEMPTY || \
+//                                          (s) == APR_EEXIST)
+
+//#endif { !defined(NETWARE) && !defined(OS2) && !defined(WIN32) }
+

+ 433 - 0
packages/base/httpd/httpd-2.2/apr/apr_file_info.inc

@@ -0,0 +1,433 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_file_info.h
+ * @brief APR File Information
+ }
+
+{#include "apr.h"
+#include "apr_user.h"
+#include "apr_pools.h"
+#include "apr_tables.h"
+#include "apr_time.h"
+#include "apr_errno.h"
+
+#if APR_HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif}
+
+{
+ * @defgroup apr_file_info File Information
+ * @ingroup APR 
+ }
+
+{ Many applications use the type member to determine the
+ * existance of a file or initialization of the file info,
+ * so the APR_NOFILE value must be distinct from APR_UNKFILE.
+ }
+
+{ apr_filetype_e values for the filetype member of the
+ * apr_file_info_t structure
+ * @warning: Not all of the filetypes below can be determined.
+ * For example, a given platform might not correctly report 
+ * a socket descriptor as APR_SOCK if that type isn't 
+ * well-identified on that platform.  In such cases where
+ * a filetype exists but cannot be described by the recognized
+ * flags below, the filetype will be APR_UNKFILE.  If the
+ * filetype member is not determined, the type will be APR_NOFILE.
+ }
+
+type
+  apr_filetype_e = (
+    APR_NOFILE = 0,     {< no file type determined }
+    APR_REG,            {< a regular file }
+    APR_DIR,            {< a directory }
+    APR_CHR,            {< a character device }
+    APR_BLK,            {< a block device }
+    APR_PIPE,           {< a FIFO / pipe }
+    APR_LNK,            {< a symbolic link }
+    APR_SOCK,           {< a [unix domain] socket }
+    APR_UNKFILE = 127   {< a file of some other unknown type }
+  );
+
+{
+ * @defgroup apr_file_permissions File Permissions flags 
+ * @
+ }
+
+const
+  APR_FPROT_USETID     = $8000; {< Set user id }
+  APR_FPROT_UREAD      = $0400; {< Read by user }
+  APR_FPROT_UWRITE     = $0200; {< Write by user }
+  APR_FPROT_UEXECUTE   = $0100; {< Execute by user }
+
+  APR_FPROT_GSETID     = $4000; {< Set group id }
+  APR_FPROT_GREAD      = $0040; {< Read by group }
+  APR_FPROT_GWRITE     = $0020; {< Write by group }
+  APR_FPROT_GEXECUTE   = $0010; {< Execute by group }
+
+  APR_FPROT_WSTICKY    = $2000; {< Sticky bit }
+  APR_FPROT_WREAD      = $0004; {< Read by others }
+  APR_FPROT_WWRITE     = $0002; {< Write by others }
+  APR_FPROT_WEXECUTE   = $0001; {< Execute by others }
+
+  APR_FPROT_OS_DEFAULT = $0FFF; {< use OS's default permissions }
+
+{ additional permission flags for apr_file_copy  and apr_file_append }
+  APR_FPROT_FILE_SOURCE_PERMS = $1000; {< Copy source file's permissions }
+
+{ backcompat }
+  APR_USETID    = APR_FPROT_USETID;     {< @deprecated @see APR_FPROT_USETID     }
+  APR_UREAD     = APR_FPROT_UREAD;      {< @deprecated @see APR_FPROT_UREAD      }
+  APR_UWRITE    = APR_FPROT_UWRITE;     {< @deprecated @see APR_FPROT_UWRITE     }
+  APR_UEXECUTE  = APR_FPROT_UEXECUTE;   {< @deprecated @see APR_FPROT_UEXECUTE   }
+  APR_GSETID    = APR_FPROT_GSETID;     {< @deprecated @see APR_FPROT_GSETID     }
+  APR_GREAD     = APR_FPROT_GREAD;      {< @deprecated @see APR_FPROT_GREAD      }
+  APR_GWRITE    = APR_FPROT_GWRITE;     {< @deprecated @see APR_FPROT_GWRITE     }
+  APR_GEXECUTE  = APR_FPROT_GEXECUTE;   {< @deprecated @see APR_FPROT_GEXECUTE   }
+  APR_WSTICKY   = APR_FPROT_WSTICKY;    {< @deprecated @see APR_FPROT_WSTICKY    }
+  APR_WREAD     = APR_FPROT_WREAD;      {< @deprecated @see APR_FPROT_WREAD      }
+  APR_WWRITE    = APR_FPROT_WWRITE;     {< @deprecated @see APR_FPROT_WWRITE     }
+  APR_WEXECUTE  = APR_FPROT_WEXECUTE;   {< @deprecated @see APR_FPROT_WEXECUTE   }
+  APR_OS_DEFAULT= APR_FPROT_OS_DEFAULT; {< @deprecated @see APR_FPROT_OS_DEFAULT }
+  APR_FILE_SOURCE_PERMS = APR_FPROT_FILE_SOURCE_PERMS; {< @deprecated @see APR_FPROT_FILE_SOURCE_PERMS }
+
+{
+ * Structure for referencing directories.
+ }
+type
+  apr_dir_t = record end;
+  Papr_dir_t = ^apr_dir_t;
+  PPapr_dir_t = ^Papr_dir_t;
+  
+{
+ * Structure for determining file permissions.
+ }
+  apr_fileperms_t = apr_int32_t;
+
+{$if defined(WIN32) or defined(NETWARE)}
+{
+ * Structure for determining the inode of the file.
+ }
+  apr_ino_t = apr_uint64_t;
+{
+ * Structure for determining the device the file is on.
+ }
+  apr_dev_t = apr_uint32_t;
+{$else}
+{ The inode of the file. }
+  apr_ino_t = ino_t;
+{
+ * Structure for determining the device the file is on.
+ }
+  apr_dev_t = dev_t;
+{$endif}
+
+{
+ * @defgroup apr_file_stat Stat Functions
+ * @
+ }
+
+const
+  APR_FINFO_LINK =  $00000001; {< Stat the link not the file itself if it is a link }
+  APR_FINFO_MTIME = $00000010; {< Modification Time }
+  APR_FINFO_CTIME = $00000020; {< Creation Time }
+  APR_FINFO_ATIME = $00000040; {< Access Time }
+  APR_FINFO_SIZE =  $00000100; {< Size of the file }
+  APR_FINFO_CSIZE = $00000200; {< Storage size consumed by the file }
+  APR_FINFO_DEV =   $00001000; {< Device }
+  APR_FINFO_INODE = $00002000; {< Inode }
+  APR_FINFO_NLINK = $00004000; {< Number of links }
+  APR_FINFO_TYPE =  $00008000; {< Type }
+  APR_FINFO_USER =  $00010000; {< User }
+  APR_FINFO_GROUP = $00020000; {< Group }
+  APR_FINFO_UPROT = $00100000; {< User protection bits }
+  APR_FINFO_GPROT = $00200000; {< Group protection bits }
+  APR_FINFO_WPROT = $00400000; {< World protection bits }
+  APR_FINFO_ICASE = $01000000; {< if dev is case insensitive }
+  APR_FINFO_NAME =  $02000000; {< ->name in proper case }
+
+  APR_FINFO_MIN =   $00008170; {< type, mtime, ctime, atime, size }
+  APR_FINFO_IDENT = $00003000; {< dev and inode }
+  APR_FINFO_OWNER = $00030000; {< user and group }
+  APR_FINFO_PROT =  $00700000; {<  all protections }
+  APR_FINFO_NORM =  $0073b170; {<  an atomic unix apr_stat() }
+  APR_FINFO_DIRENT = $02000000; {<  an atomic unix apr_dir_read() }
+
+{
+ * The file information structure.  This is analogous to the POSIX
+ * stat structure.
+ }
+type
+  apr_finfo_t = record
+    { Allocates memory and closes lingering handles in the specified pool }
+    pool: Papr_pool_t;
+    { The bitmask describing valid fields of this apr_finfo_t structure
+     *  including all available 'wanted' fields and potentially more }
+    valid: apr_int32_t;
+    { The access permissions of the file.  Mimics Unix access rights. }
+    protection: apr_fileperms_t;
+    { The type of file.  One of APR_REG, APR_DIR, APR_CHR, APR_BLK, APR_PIPE,
+     * APR_LNK or APR_SOCK.  If the type is undetermined, the value is APR_NOFILE.
+     * If the type cannot be determined, the value is APR_UNKFILE.
+     }
+    filetype: apr_filetype_e;
+    { The user id that owns the file }
+    user: apr_uid_t;
+    { The group id that owns the file }
+    group: apr_gid_t;
+    { The inode of the file. }
+    inode: apr_ino_t;
+    { The id of the device the file is on. }
+    device: apr_dev_t;
+    { The number of hard links to the file. }
+    nlink: apr_int32_t;
+    { The size of the file }
+    size: apr_off_t;
+    { The storage size consumed by the file }
+    csize: apr_off_t;
+    { The time the file was last accessed }
+    atime: apr_time_t;
+    { The time the file was last modified }
+    mtime: apr_time_t;
+    { The time the file was last changed }
+    ctime: apr_time_t;
+    { The pathname of the file (possibly unrooted) }
+    fname: PChar;
+    { The file's name (no path) in filesystem case }
+    name: PChar;
+    { The file's handle, if accessed (can be submitted to apr_duphandle) }
+    filehand: Papr_file_t;
+  end;
+  
+  Papr_finfo_t = ^apr_finfo_t;
+
+{
+ * get the specified file's stats.  The file is specified by filename, 
+ * instead of using a pre-opened file.
+ * @param finfo Where to store the information about the file, which is
+ * never touched if the call fails.
+ * @param fname The name of the file to stat.
+ * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_
+                 values 
+ * @param pool the pool to use to allocate the new file.
+ *
+ * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may
+ *       not be filled in, and you need to check the @c finfo->valid bitmask
+ *       to verify that what you're looking for is there.
+ }
+function apr_stat(finfo: Papr_finfo_t; const fname: PChar;
+ wanted: apr_int32_t; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_stat' + LibSuff16;
+
+{
+ * @defgroup apr_dir Directory Manipulation Functions
+ }
+
+{
+ * Open the specified directory.
+ * @param new_dir The opened directory descriptor.
+ * @param dirname The full path to the directory (use / on all systems)
+ * @param pool The pool to use.
+ }
+function apr_dir_open(new_dir: PPapr_dir_t; const dirname: PChar;
+ pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_open' + LibSuff12;
+
+{
+ * close the specified directory. 
+ * @param thedir the directory descriptor to close.
+ }
+function apr_dir_close(thedir: Papr_dir_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_close' + LibSuff4;
+
+{
+ * Read the next entry from the specified directory. 
+ * @param finfo the file info structure and filled in by apr_dir_read
+ * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_
+                 values 
+ * @param thedir the directory descriptor returned from apr_dir_open
+ * @remark No ordering is guaranteed for the entries read.
+ *
+ * @note If @c APR_INCOMPLETE is returned all the fields in @a finfo may
+ *       not be filled in, and you need to check the @c finfo->valid bitmask
+ *       to verify that what you're looking for is there.
+ }
+function apr_dir_read(finfo: Papr_finfo_t; wanted: apr_int32_t;
+ thedir: Papr_dir_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_read' + LibSuff12;
+
+{
+ * Rewind the directory to the first entry.
+ * @param thedir the directory descriptor to rewind.
+ }
+function apr_dir_rewind(thedir: Papr_dir_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_rewind' + LibSuff4;
+
+{
+ * @defgroup apr_filepath Filepath Manipulation Functions
+ }
+
+const
+  { Cause apr_filepath_merge to fail if addpath is above rootpath }
+  APR_FILEPATH_NOTABOVEROOT =  $01;
+
+{ internal: Only meaningful with APR_FILEPATH_NOTABOVEROOT }
+  APR_FILEPATH_SECUREROOTTEST =$02;
+
+{ Cause apr_filepath_merge to fail if addpath is above rootpath,
+ * even given a rootpath /foo/bar and an addpath ../bar/bash
+ }
+  APR_FILEPATH_SECUREROOT =    $03;
+
+{ Fail apr_filepath_merge if the merged path is relative }
+  APR_FILEPATH_NOTRELATIVE =   $04;
+
+{ Fail apr_filepath_merge if the merged path is absolute }
+  APR_FILEPATH_NOTABSOLUTE =   $08;
+
+{ Return the file system's native path format (e.g. path delimiters
+ * of ':' on MacOS9, '\' on Win32, etc.) }
+  APR_FILEPATH_NATIVE =        $10;
+
+{ Resolve the true case of existing directories and file elements
+ * of addpath, (resolving any aliases on Win32) and append a proper 
+ * trailing slash if a directory
+ }
+  APR_FILEPATH_TRUENAME =      $20;
+
+{
+ * Extract the rootpath from the given filepath
+ * @param rootpath the root file path returned with APR_SUCCESS or APR_EINCOMPLETE
+ * @param filepath the pathname to parse for its root component
+ * @param flags the desired rules to apply, from
+ * <PRE>
+ *      APR_FILEPATH_NATIVE    Use native path seperators (e.g. '\' on Win32)
+ *      APR_FILEPATH_TRUENAME  Tests that the root exists, and makes it proper
+ * </PRE>
+ * @param p the pool to allocate the new path string from
+ * @remark on return, filepath points to the first non-root character in the
+ * given filepath.  In the simplest example, given a filepath of "/foo", 
+ * returns the rootpath of "/" and filepath points at "foo".  This is far 
+ * more complex on other platforms, which will canonicalize the root form
+ * to a consistant format, given the APR_FILEPATH_TRUENAME flag, and also
+ * test for the validity of that root (e.g., that a drive d:/ or network 
+ * share //machine/foovol/). 
+ * The function returns APR_ERELATIVE if filepath isn't rooted (an
+ * error), APR_EINCOMPLETE if the root path is ambigious (but potentially
+ * legitimate, e.g. "/" on Windows is incomplete because it doesn't specify
+ * the drive letter), or APR_EBADPATH if the root is simply invalid.
+ * APR_SUCCESS is returned if filepath is an absolute path.
+ }
+function apr_filepath_root(const rootpath, filepath: PPChar;
+ flags: apr_int32_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_root' + LibSuff16;
+
+{
+ * Merge additional file path onto the previously processed rootpath
+ * @param newpath the merged paths returned
+ * @param rootpath the root file path (NULL uses the current working path)
+ * @param addpath the path to add to the root path
+ * @param flags the desired APR_FILEPATH_ rules to apply when merging
+ * @param p the pool to allocate the new path string from
+ * @remark if the flag APR_FILEPATH_TRUENAME is given, and the addpath 
+ * contains wildcard characters ('*', '?') on platforms that don't support 
+ * such characters within filenames, the paths will be merged, but the 
+ * result code will be APR_EPATHWILD, and all further segments will not
+ * reflect the true filenames including the wildcard and following segments.
+ }
+function apr_filepath_merge(newpath: PPChar; const rootpath, addpath: PPChar;
+ flags: apr_int32_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_merge' + LibSuff20;
+
+{
+ * Split a search path into separate components
+ * @param pathelts the returned components of the search path
+ * @param liststr the search path (e.g., <tt>getenv("PATH")</tt>)
+ * @param p the pool to allocate the array and path components from
+ * @remark empty path componenta do not become part of @a pathelts.
+ * @remark the path separator in @a liststr is system specific;
+ * e.g., ':' on Unix, ';' on Windows, etc.
+ }
+function apr_filepath_list_split(pathelts: PPapr_array_header_t;
+ const liststr: PChar; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_list_split' + LibSuff12;
+
+{
+ * Merge a list of search path components into a single search path
+ * @param liststr the returned search path; may be NULL if @a pathelts is empty
+ * @param pathelts the components of the search path
+ * @param p the pool to allocate the search path from
+ * @remark emtpy strings in the source array are ignored.
+ * @remark the path separator in @a liststr is system specific;
+ * e.g., ':' on Unix, ';' on Windows, etc.
+ }
+function apr_filepath_list_merge(liststr: PPChar;
+ pathelts: Papr_array_header_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_list_merge' + LibSuff12;
+
+{
+ * Return the default file path (for relative file names)
+ * @param path the default path string returned
+ * @param flags optional flag APR_FILEPATH_NATIVE to retrieve the
+ *              default file path in os-native format.
+ * @param p the pool to allocate the default path string from
+ }
+function apr_filepath_get(path: PPChar; flags: apr_int32_t;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_get' + LibSuff12;
+
+{
+ * Set the default file path (for relative file names)
+ * @param path the default path returned
+ * @param p the pool to allocate any working storage
+ }
+function apr_filepath_set(const path: PChar; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_set' + LibSuff8;
+
+const
+  { The FilePath character encoding is unknown }
+  APR_FILEPATH_ENCODING_UNKNOWN = 0;
+
+  { The FilePath character encoding is locale-dependent }
+  APR_FILEPATH_ENCODING_LOCALE =  1;
+
+  { The FilePath character encoding is UTF-8 }
+  APR_FILEPATH_ENCODING_UTF8 =    2;
+
+{
+ * Determine the encoding used internally by the FilePath functions
+ * @param style points to a variable which receives the encoding style flag
+ * @param p the pool to allocate any working storage
+ * @remark Use @c apr_os_locale_encoding and/or @c apr_os_default_encoding
+ * to get the name of the path encoding if it's not UTF-8.
+ }
+function apr_filepath_encoding(style: PInteger; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_filepath_encoding' + LibSuff8;
+

+ 842 - 0
packages/base/httpd/httpd-2.2/apr/apr_file_io.inc

@@ -0,0 +1,842 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_file_io.h
+ * @brief APR File I/O Handling
+ }
+
+{#include "apr.h"
+#include "apr_pools.h"
+#include "apr_time.h"
+#include "apr_errno.h"}
+{.$include apr_file_info.inc}
+{#include "apr_inherit.h"}
+
+//#define APR_WANT_STDIO          {< for SEEK_* }
+//#define APR_WANT_IOVEC          {< for apr_file_writev }
+//#include "apr_want.h"
+
+{
+ * @defgroup apr_file_io File I/O Handling Functions
+ * @ingroup APR 
+ }
+
+{
+ * @defgroup apr_file_open_flags File Open Flags/Routines
+ }
+
+{ Note to implementors: Values in the range 0x00100000--0x80000000
+   are reserved for platform-specific values. }
+
+const
+  APR_FOPEN_READ      = $00001;  {< Open the file for reading }
+  APR_FOPEN_WRITE     = $00002;  {< Open the file for writing }
+  APR_FOPEN_CREATE    = $00004;  {< Create the file if not there }
+  APR_FOPEN_APPEND    = $00008;  {< Append to the end of the file }
+  APR_FOPEN_TRUNCATE  = $00010;  {< Open the file and truncate
+                                         to 0 length }
+  APR_FOPEN_BINARY    = $00020;  {< Open the file in binary mode }
+  APR_FOPEN_EXCL      = $00040;  {< Open should fail if APR_CREATE
+                                         and file exists. }
+  APR_FOPEN_BUFFERED  = $00080;  {< Open the file for buffered I/O }
+  APR_FOPEN_DELONCLOSE= $00100;  {< Delete the file after close }
+  APR_FOPEN_XTHREAD   = $00200;  {< Platform dependent tag to open
+                                         the file for use across multiple
+                                         threads }
+  APR_FOPEN_SHARELOCK = $00400;  {< Platform dependent support for
+                                         higher level locked read/write
+                                         access to support writes across
+                                         process/machines }
+  APR_FOPEN_NOCLEANUP = $00800;  {< Do not register a cleanup
+                                         when the file is opened }
+  APR_FOPEN_SENDFILE_ENABLED = $01000; {< Advisory flag that this
+                                             file should support
+                                             apr_socket_sendfile operation }
+  APR_FOPEN_LARGEFILE = $04000;  {< Platform dependent flag to enable
+                                         large file support; WARNING see
+                                         below. }
+{ backcompat }
+  APR_READ            = APR_FOPEN_READ;       {< @deprecated @see APR_FOPEN_READ }
+  APR_WRITE           = APR_FOPEN_WRITE;      {< @deprecated @see APR_FOPEN_WRITE }
+  APR_CREATE          = APR_FOPEN_CREATE;     {< @deprecated @see APR_FOPEN_CREATE }
+  APR_APPEND          = APR_FOPEN_APPEND;     {< @deprecated @see APR_FOPEN_APPEND }
+  APR_TRUNCATE        = APR_FOPEN_TRUNCATE;   {< @deprecated @see APR_FOPEN_TRUNCATE }
+  APR_BINARY          = APR_FOPEN_BINARY;     {< @deprecated @see APR_FOPEN_BINARY }
+  APR_EXCL            = APR_FOPEN_EXCL;       {< @deprecated @see APR_FOPEN_EXCL }
+  APR_BUFFERED        = APR_FOPEN_BUFFERED;   {< @deprecated @see APR_FOPEN_BUFFERED }
+  APR_DELONCLOSE      = APR_FOPEN_DELONCLOSE; {< @deprecated @see APR_FOPEN_DELONCLOSE }
+  APR_XTHREAD         = APR_FOPEN_XTHREAD;    {< @deprecated @see APR_FOPEN_XTHREAD }
+  APR_SHARELOCK       = APR_FOPEN_SHARELOCK;  {< @deprecated @see APR_FOPEN_SHARELOCK }
+  APR_FILE_NOCLEANUP  = APR_FOPEN_NOCLEANUP;  {< @deprecated @see APR_FOPEN_NOCLEANUP }
+  APR_SENDFILE_ENABLED= APR_FOPEN_SENDFILE_ENABLED; {< @deprecated @see APR_FOPEN_SENDFILE_ENABLED }
+  APR_LARGEFILE       = APR_FOPEN_LARGEFILE;  {< @deprecated @see APR_FOPEN_LARGEFILE }
+
+{ @warning The APR_LARGEFILE flag only has effect on some platforms
+ * where sizeof(apr_off_t) == 4.  Where implemented, it allows opening
+ * and writing to a file which exceeds the size which can be
+ * represented by apr_off_t (2 gigabytes).  When a file's size does
+ * exceed 2Gb, apr_file_info_get() will fail with an error on the
+ * descriptor, likewise apr_stat()/apr_lstat() will fail on the
+ * filename.  apr_dir_read() will fail with APR_INCOMPLETE on a
+ * directory entry for a large file depending on the particular
+ * APR_FINFO_* flags.  Generally, it is not recommended to use this
+ * flag. }
+
+{
+ * @defgroup apr_file_seek_flags File Seek Flags
+ }
+
+{
+ * @defgroup apr_file_attrs_set_flags File Attribute Flags
+ }
+
+{ flags for apr_file_attrs_set }
+  APR_FILE_ATTR_READONLY =  $01;          {< File is read-only }
+  APR_FILE_ATTR_EXECUTABLE =$02;          {< File is executable }
+  APR_FILE_ATTR_HIDDEN =    $04;          {< File is hidden }
+
+{
+ * @defgroup apr_file_writev(_full) max iovec size
+ }
+{$ifdef DOXYGEN}
+  APR_MAX_IOVEC_SIZE = 1024;                {< System dependent maximum
+                                                    size of an iovec array }
+{#elif defined(IOV_MAX)
+#define APR_MAX_IOVEC_SIZE IOV_MAX
+#elif defined(MAX_IOVEC)
+#define APR_MAX_IOVEC_SIZE MAX_IOVEC}
+{$else}
+  APR_MAX_IOVEC_SIZE = 1024;
+{$endif}
+
+{ File attributes }
+type
+  apr_fileattrs_t = apr_uint32_t;
+
+{ Type to pass as whence argument to apr_file_seek. }
+  apr_seek_where_t = Integer;
+
+{
+ * Structure for referencing files.
+ }
+  apr_file_t = record end;
+//  Papr_file_t = ^apr_file_t;
+  PPapr_file_t = ^Papr_file_t;
+
+{ File lock types/flags }
+{
+ * @defgroup apr_file_lock_types File Lock Types
+ }
+
+const
+  APR_FLOCK_SHARED =       1;       {< Shared lock. More than one process
+                                           or thread can hold a shared lock
+                                           at any given time. Essentially,
+                                           this is a "read lock", preventing
+                                           writers from establishing an
+                                           exclusive lock. }
+  APR_FLOCK_EXCLUSIVE =    2;       {< Exclusive lock. Only one process
+                                           may hold an exclusive lock at any
+                                           given time. This is analogous to
+                                           a "write lock". }
+
+  APR_FLOCK_TYPEMASK =     $000F;  {< mask to extract lock type }
+  APR_FLOCK_NONBLOCK =     $0010;  {< do not block while acquiring the
+                                           file lock }
+{
+ * Open the specified file.
+ * @param newf The opened file descriptor.
+ * @param fname The full path to the file (using / on all systems)
+ * @param flag Or'ed value of:
+ * <PRE>
+ *         APR_READ              open for reading
+ *         APR_WRITE             open for writing
+ *         APR_CREATE            create the file if not there
+ *         APR_APPEND            file ptr is set to end prior to all writes
+ *         APR_TRUNCATE          set length to zero if file exists
+ *         APR_BINARY            not a text file (This flag is ignored on 
+ *                               UNIX because it has no meaning)
+ *         APR_BUFFERED          buffer the data.  Default is non-buffered
+ *         APR_EXCL              return error if APR_CREATE and file exists
+ *         APR_DELONCLOSE        delete the file after closing.
+ *         APR_XTHREAD           Platform dependent tag to open the file
+ *                               for use across multiple threads
+ *         APR_SHARELOCK         Platform dependent support for higher
+ *                               level locked read/write access to support
+ *                               writes across process/machines
+ *         APR_FILE_NOCLEANUP    Do not register a cleanup with the pool 
+ *                               passed in on the <EM>pool</EM> argument (see below).
+ *                               The apr_os_file_t handle in apr_file_t will not
+ *                               be closed when the pool is destroyed.
+ *         APR_SENDFILE_ENABLED  Open with appropriate platform semantics
+ *                               for sendfile operations.  Advisory only,
+ *                               apr_socket_sendfile does not check this flag.
+ * </PRE>
+ * @param perm Access permissions for file.
+ * @param pool The pool to use.
+ * @remark If perm is APR_OS_DEFAULT and the file is being created, appropriate 
+ *      default permissions will be used.  *arg1 must point to a valid file_t, 
+ *      or NULL (in which case it will be allocated)
+ }
+function apr_file_open(newf: PPapr_file_t; const fname: PChar;
+ flag: apr_int32_t; perm: apr_fileperms_t;
+ pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_open' + LibSuff20;
+
+{
+ * Close the specified file.
+ * @param file The file descriptor to close.
+ }
+function apr_file_close(file_: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_close' + LibSuff4;
+
+{
+ * delete the specified file.
+ * @param path The full path to the file (using / on all systems)
+ * @param pool The pool to use.
+ * @remark If the file is open, it won't be removed until all instances are closed.
+ }
+function apr_file_remove(const path: PChar; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_remove' + LibSuff8;
+
+{
+ * rename the specified file.
+ * @param from_path The full path to the original file (using / on all systems)
+ * @param to_path The full path to the new file (using / on all systems)
+ * @param pool The pool to use.
+ * @warning If a file exists at the new location, then it will be overwritten.  
+ *      Moving files or directories across devices may not be possible.
+ }
+function apr_file_rename(const from_path, to_path: PChar; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_rename' + LibSuff12;
+
+{
+ * copy the specified file to another file.
+ * @param from_path The full path to the original file (using / on all systems)
+ * @param to_path The full path to the new file (using / on all systems)
+ * @param perms Access permissions for the new file if it is created.
+ *     In place of the usual or'd combination of file permissions, the
+ *     value APR_FILE_SOURCE_PERMS may be given, in which case the source
+ *     file's permissions are copied.
+ * @param pool The pool to use.
+ * @remark The new file does not need to exist, it will be created if required.
+ * @warning If the new file already exists, its contents will be overwritten.
+ }
+function apr_file_copy(const from_path, to_path: PChar;
+ perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_copy' + LibSuff16;
+
+{
+ * append the specified file to another file.
+ * @param from_path The full path to the source file (using / on all systems)
+ * @param to_path The full path to the destination file (using / on all systems)
+ * @param perms Access permissions for the destination file if it is created.
+ *     In place of the usual or'd combination of file permissions, the
+ *     value APR_FILE_SOURCE_PERMS may be given, in which case the source
+ *     file's permissions are copied.
+ * @param pool The pool to use.
+ * @remark The new file does not need to exist, it will be created if required.
+ }
+function apr_file_append(const from_path, to_path: PChar;
+ perms: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_append' + LibSuff16;
+
+{
+ * Are we at the end of the file
+ * @param fptr The apr file we are testing.
+ * @remark Returns APR_EOF if we are at the end of file, APR_SUCCESS otherwise.
+ }
+function apr_file_eof(fptr: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_eof' + LibSuff4;
+
+{
+ * open standard error as an apr file pointer.
+ * @param thefile The apr file to use as stderr.
+ * @param pool The pool to allocate the file out of.
+ * 
+ * @remark The only reason that the apr_file_open_std* functions exist
+ * is that you may not always have a stderr/out/in on Windows.  This
+ * is generally a problem with newer versions of Windows and services.
+ * 
+ * The other problem is that the C library functions generally work
+ * differently on Windows and Unix.  So, by using apr_file_open_std*
+ * functions, you can get a handle to an APR struct that works with
+ * the APR functions which are supposed to work identically on all
+ * platforms.
+ }
+function apr_file_open_stderr(thefile: PPapr_file_t;
+ pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_open_stderr' + LibSuff8;
+
+{
+ * open standard output as an apr file pointer.
+ * @param thefile The apr file to use as stdout.
+ * @param pool The pool to allocate the file out of.
+ *
+ * @remark See remarks for apr_file_open_stdout.
+ }
+function apr_file_open_stdout(thefile: PPapr_file_t;
+ pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_open_stdout' + LibSuff8;
+
+{
+ * open standard input as an apr file pointer.
+ * @param thefile The apr file to use as stdin.
+ * @param pool The pool to allocate the file out of.
+ *
+ * @remark See remarks for apr_file_open_stdout.
+ }
+function apr_file_open_stdin(thefile: PPapr_file_t;
+ pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_open_stdin' + LibSuff8;
+
+{
+ * Read data from the specified file.
+ * @param thefile The file descriptor to read from.
+ * @param buf The buffer to store the data to.
+ * @param nbytes On entry, the number of bytes to read; on exit, the number
+ * of bytes read.
+ *
+ * @remark apr_file_read will read up to the specified number of
+ * bytes, but never more.  If there isn't enough data to fill that
+ * number of bytes, all of the available data is read.  The third
+ * argument is modified to reflect the number of bytes read.  If a
+ * char was put back into the stream via ungetc, it will be the first
+ * character returned.
+ *
+ * @remark It is not possible for both bytes to be read and an APR_EOF
+ * or other error to be returned.  APR_EINTR is never returned.
+ }
+function apr_file_read(thefile: Papr_file_t; buf: Pointer;
+ nbytes: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_read' + LibSuff12;
+
+{
+ * Write data to the specified file.
+ * @param thefile The file descriptor to write to.
+ * @param buf The buffer which contains the data.
+ * @param nbytes On entry, the number of bytes to write; on exit, the number
+ *               of bytes written.
+ *
+ * @remark apr_file_write will write up to the specified number of
+ * bytes, but never more.  If the OS cannot write that many bytes, it
+ * will write as many as it can.  The third argument is modified to
+ * reflect the * number of bytes written.
+ *
+ * @remark It is possible for both bytes to be written and an error to
+ * be returned.  APR_EINTR is never returned.
+ }
+function apr_file_write(thefile: Papr_file_t; buf: Pointer;
+ nbytes: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_write' + LibSuff12;
+
+{
+ * Write data from iovec array to the specified file.
+ * @param thefile The file descriptor to write to.
+ * @param vec The array from which to get the data to write to the file.
+ * @param nvec The number of elements in the struct iovec array. This must
+ *             be smaller than APR_MAX_IOVEC_SIZE.  If it isn't, the function
+ *             will fail with APR_EINVAL.
+ * @param nbytes The number of bytes written.
+ *
+ * @remark It is possible for both bytes to be written and an error to
+ * be returned.  APR_EINTR is never returned.
+ *
+ * @remark apr_file_writev is available even if the underlying
+ * operating system doesn't provide writev().
+ }
+function apr_file_writev(thefile: Papr_file_t; const vec: Piovec;
+ nvec: apr_size_t; nbytes: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_writev' + LibSuff16;
+
+{
+ * Read data from the specified file, ensuring that the buffer is filled
+ * before returning.
+ * @param thefile The file descriptor to read from.
+ * @param buf The buffer to store the data to.
+ * @param nbytes The number of bytes to read.
+ * @param bytes_read If non-NULL, this will contain the number of bytes read.
+ *
+ * @remark apr_file_read will read up to the specified number of
+ * bytes, but never more.  If there isn't enough data to fill that
+ * number of bytes, then the process/thread will block until it is
+ * available or EOF is reached.  If a char was put back into the
+ * stream via ungetc, it will be the first character returned.
+ *
+ * @remark It is possible for both bytes to be read and an error to be
+ * returned.  And if *bytes_read is less than nbytes, an accompanying
+ * error is _always_ returned.
+ *
+ * @remark APR_EINTR is never returned.
+ }
+function apr_file_read_full(thefile: Papr_file_t; buf: Pointer;
+ nbytes: apr_size_t; bytes_read: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_read_full' + LibSuff16;
+
+{
+ * Write data to the specified file, ensuring that all of the data is
+ * written before returning.
+ * @param thefile The file descriptor to write to.
+ * @param buf The buffer which contains the data.
+ * @param nbytes The number of bytes to write.
+ * @param bytes_written If non-NULL, set to the number of bytes written.
+ *
+ * @remark apr_file_write will write up to the specified number of
+ * bytes, but never more.  If the OS cannot write that many bytes, the
+ * process/thread will block until they can be written. Exceptional
+ * error such as "out of space" or "pipe closed" will terminate with
+ * an error.
+ *
+ * @remark It is possible for both bytes to be written and an error to
+ * be returned.  And if *bytes_written is less than nbytes, an
+ * accompanying error is _always_ returned.
+ *
+ * @remark APR_EINTR is never returned.
+ }
+function apr_file_write_full(thefile: Papr_file_t; buf: Pointer;
+ nbytes: apr_size_t; bytes_written: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_write_full' + LibSuff16;
+
+{
+ * Write data from iovec array to the specified file, ensuring that all of the
+ * data is written before returning.
+ * @param thefile The file descriptor to write to.
+ * @param vec The array from which to get the data to write to the file.
+ * @param nvec The number of elements in the struct iovec array. This must
+ *             be smaller than APR_MAX_IOVEC_SIZE.  If it isn't, the function
+ *             will fail with APR_EINVAL.
+ * @param nbytes The number of bytes written.
+ *
+ * @remark apr_file_writev_full is available even if the underlying
+ * operating system doesn't provide writev().
+ }
+function apr_file_writev_full(thefile: Papr_file_t; const vec: Piovec;
+ nvec: apr_size_t; nbytes: Papr_size_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_writev_full' + LibSuff16;
+
+{
+ * Write a character into the specified file.
+ * @param ch The character to write.
+ * @param thefile The file descriptor to write to
+ }
+function apr_file_putc(ch: Char; thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_putc' + LibSuff8;
+
+{
+ * get a character from the specified file.
+ * @param ch The character to read into
+ * @param thefile The file descriptor to read from
+ }
+function apr_file_getc(ch: PChar; thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_getc' + LibSuff8;
+
+{
+ * put a character back onto a specified stream.
+ * @param ch The character to write.
+ * @param thefile The file descriptor to write to
+ }
+function apr_file_ungetc(ch: Char; thefile: PPapr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_ungetc' + LibSuff8;
+
+{
+ * Get a string from a specified file.
+ * @param str The buffer to store the string in. 
+ * @param len The length of the string
+ * @param thefile The file descriptor to read from
+ * @remark The buffer will be '\0'-terminated if any characters are stored.
+ }
+function apr_file_gets(str: PChar; len: Integer;
+ thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_gets' + LibSuff12;
+
+{
+ * Put the string into a specified file.
+ * @param str The string to write. 
+ * @param thefile The file descriptor to write to
+ }
+function apr_file_puts(const str: PChar; thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_puts' + LibSuff8;
+
+{
+ * Flush the file's buffer.
+ * @param thefile The file descriptor to flush
+ }
+function apr_file_flush(thefile: PPapr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_flush' + LibSuff4;
+
+{
+ * duplicate the specified file descriptor.
+ * @param new_file The structure to duplicate into. 
+ * @param old_file The file to duplicate.
+ * @param p The pool to use for the new file.
+ * @remark *new_file must point to a valid apr_file_t, or point to NULL
+ }
+function apr_file_dup(new_file: PPapr_file_t; old_file: PPapr_file_t;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_dup' + LibSuff12;
+
+{
+ * duplicate the specified file descriptor and close the original
+ * @param new_file The old file that is to be closed and reused
+ * @param old_file The file to duplicate
+ * @param p        The pool to use for the new file
+ *
+ * @remark new_file MUST point at a valid apr_file_t. It cannot be NULL
+ }
+function apr_file_dup2(new_file: PPapr_file_t; old_file: PPapr_file_t;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_dup2' + LibSuff12;
+
+{
+ * move the specified file descriptor to a new pool
+ * @param new_file Pointer in which to return the new apr_file_t
+ * @param old_file The file to move
+ * @param p        The pool to which the descriptor is to be moved
+ * @remark Unlike apr_file_dup2(), this function doesn't do an
+ *         OS dup() operation on the underlying descriptor; it just
+ *         moves the descriptor's apr_file_t wrapper to a new pool.
+ * @remark The new pool need not be an ancestor of old_file's pool.
+ * @remark After calling this function, old_file may not be used
+ }
+function apr_file_setaside(new_file: PPapr_file_t; old_file: PPapr_file_t;
+ p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_setaside' + LibSuff12;
+
+{
+ * Move the read/write file offset to a specified byte within a file.
+ * @param thefile The file descriptor
+ * @param where How to move the pointer, one of:
+ * <PRE>
+ *            APR_SET  --  set the offset to offset
+ *            APR_CUR  --  add the offset to the current position 
+ *            APR_END  --  add the offset to the current file size 
+ * </PRE>
+ * @param offset The offset to move the pointer to.
+ * @remark The third argument is modified to be the offset the pointer
+          was actually moved to.
+ }
+function apr_file_seek(thefile: Papr_file_t;
+ where: apr_seek_where_t; offset: Papr_off_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_seek' + LibSuff12;
+
+{
+ * Create an anonymous pipe.
+ * @param in The file descriptor to use as input to the pipe.
+ * @param out The file descriptor to use as output from the pipe.
+ * @param pool The pool to operate on.
+ }
+function apr_file_pipe_create(in_: PPapr_file_t; out_: PPapr_file_t;
+ pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_pipe_create' + LibSuff12;
+
+{
+ * Create a named pipe.
+ * @param filename The filename of the named pipe
+ * @param perm The permissions for the newly created pipe.
+ * @param pool The pool to operate on.
+ }
+function apr_file_namedpipe_create(const filename: PChar;
+ perm: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_namedpipe_create' + LibSuff12;
+
+{
+ * Get the timeout value for a pipe or manipulate the blocking state.
+ * @param thepipe The pipe we are getting a timeout for.
+ * @param timeout The current timeout value in microseconds. 
+ }
+function apr_file_pipe_timeout_get(thepipe: Papr_file_t;
+ timeout: Papr_interval_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_get' + LibSuff8;
+
+{
+ * Set the timeout value for a pipe or manipulate the blocking state.
+ * @param thepipe The pipe we are setting a timeout on.
+ * @param timeout The timeout value in microseconds.  Values < 0 mean wait 
+ *        forever, 0 means do not wait at all.
+ }
+function apr_file_pipe_timeout_set(thepipe: Papr_file_t;
+ timeout: apr_interval_time_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_pipe_timeout_set' + LibSuff12;
+
+{ file (un)locking functions. }
+
+{
+ * Establish a lock on the specified, open file. The lock may be advisory
+ * or mandatory, at the discretion of the platform. The lock applies to
+ * the file as a whole, rather than a specific range. Locks are established
+ * on a per-thread/process basis; a second lock by the same thread will not
+ * block.
+ * @param thefile The file to lock.
+ * @param type The type of lock to establish on the file.
+ }
+function apr_file_lock(thefile: Papr_file_t; type_: Integer): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_lock' + LibSuff8;
+
+{
+ * Remove any outstanding locks on the file.
+ * @param thefile The file to unlock.
+ }
+function apr_file_unlock(thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_unlock' + LibSuff4;
+
+{accessor and general file_io functions. }
+
+{
+ * return the file name of the current file.
+ * @param new_path The path of the file.  
+ * @param thefile The currently open file.
+ }
+function apr_file_name_get(const newpath: PPChar; thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_name_get' + LibSuff8;
+
+{
+ * Return the data associated with the current file.
+ * @param data The user data associated with the file.  
+ * @param key The key to use for retreiving data associated with this file.
+ * @param file The currently open file.
+ }
+function apr_file_data_get(data: PPointer; const key: PChar;
+ file_: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_data_get' + LibSuff12;
+
+{
+ * Set the data associated with the current file.
+ * @param file The currently open file.
+ * @param data The user data to associate with the file.  
+ * @param key The key to use for assocaiteing data with the file.
+ * @param cleanup The cleanup routine to use when the file is destroyed.
+ }
+//function apr_file_data_set(ch: Char; thefile: PPapr_file_t): apr_status_t;
+// {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+// external LibAPR name LibNamePrefix + 'apr_file_data_set' + LibSuff4;
+//APR_DECLARE(apr_status_t) (apr_file_t *file, void *data,
+//                                           const char *key,
+//                                           apr_status_t (*cleanup)(void *));
+
+{
+ * Write a string to a file using a printf format.
+ * @param fptr The file to write to.
+ * @param format The format string
+ * @param ... The values to substitute in the format string
+ * @return The number of bytes written
+ }
+function apr_file_printf(fptr: Papr_file_t; const format: PChar;
+ othres: array of const): Integer;
+ cdecl; external LibAPR name 'apr_file_printf';
+
+{
+ * set the specified file's permission bits.
+ * @param fname The file (name) to apply the permissions to.
+ * @param perms The permission bits to apply to the file.
+ * @warning Some platforms may not be able to apply all of the available 
+ *      permission bits; APR_INCOMPLETE will be returned if some permissions 
+ *      are specified which could not be set.
+ *
+ *      Platforms which do not implement this feature will return APR_ENOTIMPL.
+ }
+function apr_file_perms_set(const fname: PChar;
+ perms: apr_fileperms_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_perms_set' + LibSuff8;
+
+{
+ * Set attributes of the specified file.
+ * @param fname The full path to the file (using / on all systems)
+ * @param attributes Or'd combination of
+ * <PRE>
+ *            APR_FILE_ATTR_READONLY   - make the file readonly
+ *            APR_FILE_ATTR_EXECUTABLE - make the file executable
+ *            APR_FILE_ATTR_HIDDEN     - make the file hidden
+ * </PRE>
+ * @param attr_mask Mask of valid bits in attributes.
+ * @param pool the pool to use.
+ * @remark This function should be used in preference to explict manipulation
+ *      of the file permissions, because the operations to provide these
+ *      attributes are platform specific and may involve more than simply
+ *      setting permission bits.
+ * @warning Platforms which do not implement this feature will return
+ *      APR_ENOTIMPL.
+ }
+function apr_file_attrs_set(const fname: PChar;
+ attributes, attr_mask: apr_fileattrs_t;
+ pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_attrs_set' + LibSuff16;
+
+{
+ * Set the mtime of the specified file.
+ * @param fname The full path to the file (using / on all systems)
+ * @param mtime The mtime to apply to the file.
+ * @param pool The pool to use.
+ * @warning Platforms which do not implement this feature will return
+ *      APR_ENOTIMPL.
+ }
+function apr_file_mtime_set(const fname: PChar;
+ mtime: apr_time_t; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_mtime_set' + LibSuff16;
+
+{
+ * Create a new directory on the file system.
+ * @param path the path for the directory to be created.  (use / on all systems)
+ * @param perm Permissions for the new direcoty.
+ * @param pool the pool to use.
+ }
+function apr_dir_make(const path: PChar; perm: apr_fileperms_t;
+ pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_make' + LibSuff12;
+
+{ Creates a new directory on the file system, but behaves like
+ * 'mkdir -p'. Creates intermediate directories as required. No error
+ * will be reported if PATH already exists.
+ * @param path the path for the directory to be created.  (use / on all systems)
+ * @param perm Permissions for the new direcoty.
+ * @param pool the pool to use.
+ }
+function apr_dir_make_recursive(const path: PChar;
+ perm: apr_fileperms_t; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_make_recursive' + LibSuff12;
+
+{
+ * Remove directory from the file system.
+ * @param path the path for the directory to be removed.  (use / on all systems)
+ * @param pool the pool to use.
+ }
+function apr_dir_remove(const path: PChar; pool: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_dir_remove' + LibSuff8;
+
+{
+ * get the specified file's stats.
+ * @param finfo Where to store the information about the file.
+ * @param wanted The desired apr_finfo_t fields, as a bit flag of APR_FINFO_ values 
+ * @param thefile The file to get information about.
+ }
+function apr_file_info_get(finfo: Papr_finfo_t;
+ wanted: apr_int32_t; thefile: Papr_file_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_info_get' + LibSuff12;
+
+{
+ * Truncate the file's length to the specified offset
+ * @param fp The file to truncate
+ * @param offset The offset to truncate to.
+ }
+function apr_file_trunc(fp: Papr_file_t; offset: apr_off_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_trunc' + LibSuff12;
+
+{
+ * Retrieve the flags that were passed into apr_file_open()
+ * when the file was opened.
+ * @return apr_int32_t the flags
+ }
+function apr_file_flags_get(f: Papr_file_t): apr_int32_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_flags_get' + LibSuff4;
+
+{
+ * Get the pool used by the file.
+ }
+{APR_POOL_DECLARE_ACCESSOR(file);
+}
+{
+ * Set a file to be inherited by child processes.
+ *
+ }
+{APR_DECLARE_INHERIT_SET(file);
+}
+
+{
+ * Unset a file from being inherited by child processes.
+ }
+{APR_DECLARE_INHERIT_UNSET(file);
+}
+
+{
+ * Open a temporary file
+ * @param fp The apr file to use as a temporary file.
+ * @param templ The template to use when creating a temp file.
+ * @param flags The flags to open the file with. If this is zero,
+ *              the file is opened with 
+ *              APR_CREATE | APR_READ | APR_WRITE | APR_EXCL | APR_DELONCLOSE
+ * @param p The pool to allocate the file out of.
+ * @remark   
+ * This function  generates  a unique temporary file name from template.  
+ * The last six characters of template must be XXXXXX and these are replaced 
+ * with a string that makes the filename unique. Since it will  be  modified,
+ * template must not be a string constant, but should be declared as a character
+ * array.  
+ *
+ }
+function apr_file_mktemp(fp: PPapr_file_t; templ: PChar;
+ flags: apr_int32_t; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_file_mktemp' + LibSuff16;
+
+{
+ * Find an existing directory suitable as a temporary storage location.
+ * @param temp_dir The temp directory.
+ * @param p The pool to use for any necessary allocations.
+ * @remark   
+ * This function uses an algorithm to search for a directory that an
+ * an application can use for temporary storage.  Once such a
+ * directory is found, that location is cached by the library.  Thus,
+ * callers only pay the cost of this algorithm once if that one time
+ * is successful.
+ *
+ }
+function apr_temp_dir_get(const temp_dir: PPChar; p: Papr_pool_t): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_temp_dir_get' + LibSuff8;
+

+ 219 - 0
packages/base/httpd/httpd-2.2/apr/apr_general.inc

@@ -0,0 +1,219 @@
+{ Copyright 2000-2005 The Apache Software Foundation or its licensors, as
+ * applicable.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ }
+
+{
+ * @file apr_general.h
+ * This is collection of oddballs that didn't fit anywhere else,
+ * and might move to more appropriate headers with the release
+ * of APR 1.0.
+ * @brief APR Miscellaneous library routines
+ }
+
+{#include "apr.h"
+#include "apr_pools.h"
+#include "apr_errno.h"
+
+#if APR_HAVE_SIGNAL_H
+#include <signal.h>
+#endif}
+
+{
+ * @defgroup apr_general Miscellaneous library routines
+ * @ingroup APR 
+ * This is collection of oddballs that didn't fit anywhere else,
+ * and might move to more appropriate headers with the release
+ * of APR 1.0.
+ }
+
+const
+{ a space }
+  APR_ASCII_BLANK = #040;
+{ a carrige return }
+  APR_ASCII_CR    = #015;
+{ a line feed }
+  APR_ASCII_LF    = #012;
+{ a tab }
+  APR_ASCII_TAB   = #011;
+
+{ signal numbers typedef }
+type
+  apr_signum_t = Integer;
+
+{
+ * Finding offsets of elements within structures.
+ * Taken from the X code... they've sweated portability of this stuff
+ * so we don't have to.  Sigh...
+ * @param p_type pointer type name
+ * @param field  data field within the structure pointed to
+ * @return offset
+ }
+
+{#if defined(CRAY) || (defined(__arm) && !defined(LINUX))
+#ifdef __STDC__
+#define APR_OFFSET(p_type,field) _Offsetof(p_type,field)
+#else
+#ifdef CRAY2
+#define APR_OFFSET(p_type,field) \
+        (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
+
+#else} { !CRAY2 }
+
+{#define APR_OFFSET(p_type,field) ((unsigned int)&(((p_type)NULL)->field))
+
+#endif} { !CRAY2 }
+//#endif { __STDC__ }
+//#else { ! (CRAY || __arm) }
+
+//#define APR_OFFSET(p_type,field) \
+//        ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
+
+//#endif { !CRAY }
+
+{
+ * Finding offsets of elements within structures.
+ * @param s_type structure type name
+ * @param field  data field within the structure
+ * @return offset
+ }
+{#if defined(offsetof) && !defined(__cplusplus)
+#define APR_OFFSETOF(s_type,field) offsetof(s_type,field)
+#else
+#define APR_OFFSETOF(s_type,field) APR_OFFSET(s_type*,field)
+#endif}
+
+{$ifndef DOXYGEN}
+
+{ A couple of prototypes for functions in case some platform doesn't
+ * have it
+ }
+{#if (!APR_HAVE_STRCASECMP) && (APR_HAVE_STRICMP)
+#define strcasecmp(s1, s2) stricmp(s1, s2)
+#elif (!APR_HAVE_STRCASECMP)
+int strcasecmp(const char *a, const char *b);
+#endif
+
+#if (!APR_HAVE_STRNCASECMP) && (APR_HAVE_STRNICMP)
+#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
+#elif (!APR_HAVE_STRNCASECMP)
+int strncasecmp(const char *a, const char *b, size_t n);
+#endif}
+
+{$endif}
+
+{
+ * Alignment macros
+ }
+
+{ APR_ALIGN() is only to be used to align on a power of 2 boundary }
+{#define APR_ALIGN(size, boundary) \
+    (((size) + ((boundary) - 1)) & ~((boundary) - 1))}
+
+{ Default alignment }
+//#define APR_ALIGN_DEFAULT(size) APR_ALIGN(size, 8)
+
+
+{
+ * String and memory functions
+ }
+
+{ APR_STRINGIFY is defined here, and also in apr_release.h, so wrap it }
+{$ifndef APR_STRINGIFY}
+{ Properly quote a value as a string in the C preprocessor }
+//#define APR_STRINGIFY(n) APR_STRINGIFY_HELPER(n)
+{ Helper macro for APR_STRINGIFY }
+{#define APR_STRINGIFY_HELPER(n) #n}
+{$endif}
+
+{#if (!APR_HAVE_MEMMOVE)
+#define memmove(a,b,c) bcopy(b,a,c)
+#endif
+
+#if (!APR_HAVE_MEMCHR)
+void *memchr(const void *s, int c, size_t n);
+#endif}
+
+{
+ * @defgroup apr_library Library initialization and termination
+ }
+
+{
+ * Setup any APR internal data structures.  This MUST be the first function 
+ * called for any APR library.
+ * @remark See apr_app_initialize if this is an application, rather than
+ * a library consumer of apr.
+ }
+function apr_initialize: apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_initialize' + LibSuff0;
+
+{
+ * Set up an application with normalized argc, argv (and optionally env) in
+ * order to deal with platform-specific oddities, such as Win32 services,
+ * code pages and signals.  This must be the first function called for any
+ * APR program.
+ * @param argc Pointer to the argc that may be corrected
+ * @param argv Pointer to the argv that may be corrected
+ * @param env Pointer to the env that may be corrected, may be NULL
+ * @remark See apr_initialize if this is a library consumer of apr.
+ * Otherwise, this call is identical to apr_initialize, and must be closed
+ * with a call to apr_terminate at the end of program execution.
+ }
+function apr_app_initialize(argc: PInteger; argv, env: PPChar): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_app_initialize' + LibSuff12;
+
+{
+ * Tear down any APR internal data structures which aren't torn down 
+ * automatically.
+ * @remark An APR program must call this function at termination once it 
+ *         has stopped using APR services.  The APR developers suggest using
+ *         atexit to ensure this is called.  When using APR from a language
+ *         other than C that has problems with the calling convention, use
+ *         apr_terminate2() instead.
+ }
+procedure apr_terminate;
+ cdecl; external LibAPR name 'apr_terminate';
+
+{
+ * Tear down any APR internal data structures which aren't torn down 
+ * automatically, same as apr_terminate
+ * @remark An APR program must call either the apr_terminate or apr_terminate2 
+ *         function once it it has finished using APR services.  The APR 
+ *         developers suggest using atexit(apr_terminate) to ensure this is done.
+ *         apr_terminate2 exists to allow non-c language apps to tear down apr, 
+ *         while apr_terminate is recommended from c language applications.
+ }
+procedure apr_terminate2;
+ cdecl; external LibAPR name LibNamePrefix + 'apr_terminate2' + LibSuff0;
+
+{
+ * @defgroup apr_random Random Functions
+ }
+
+{$if defined(APR_HAS_RANDOM) or defined(DOXYGEN)}
+
+{ TODO: I'm not sure this is the best place to put this prototype...}
+{
+ * Generate random bytes.
+ * @param buf Buffer to fill with random bytes
+ * @param length Length of buffer in bytes (becomes apr_size_t in APR 1.0)
+ }
+function apr_generate_random_bytes(buf: PChar; length: Integer): apr_status_t;
+ {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF}
+ external LibAPR name LibNamePrefix + 'apr_generate_random_bytes' + LibSuff8;
+
+{$endif}
+

Some files were not shown because too many files changed in this diff