summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author(no author) <(no author)@unknown>2000-02-21 07:35:35 +0000
committer(no author) <(no author)@unknown>2000-02-21 07:35:35 +0000
commit112247a193653c8a4a24da700199449b282a8873 (patch)
treefd8bdf24c053b8e91a62e8f8059be580fe023394
parent4cdb8a376e350b9430c83fd8321d31080e3e50bd (diff)
downloadhttpd-112247a193653c8a4a24da700199449b282a8873.tar.gz
This commit was manufactured by cvs2svn to create tag1.3.12
'APACHE_1_3_12'. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/tags/1.3.12@84655 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--.gdbinit33
-rw-r--r--Announcement95
-rw-r--r--Apache.dsp109
-rw-r--r--ApacheCore.def396
-rw-r--r--ApacheCore.dsp413
-rw-r--r--KEYS518
-rw-r--r--LICENSE59
-rw-r--r--Makefile.in73
-rw-r--r--STATUS181
-rw-r--r--acinclude.m4351
-rwxr-xr-xbuild/MakeEtags39
-rwxr-xr-xbuild/PrintPath105
-rw-r--r--build/build-modules-c.awk56
-rw-r--r--build/build.mk64
-rw-r--r--build/build2.mk78
-rwxr-xr-xbuild/buildcheck.sh43
-rwxr-xr-xbuild/config-stubs8
-rwxr-xr-xbuild/cvsclean3
-rwxr-xr-xbuild/fastgen.sh53
-rwxr-xr-xbuild/install.sh112
-rw-r--r--build/library.mk42
-rw-r--r--build/ltlib.mk31
-rw-r--r--build/mkdep.perl91
-rwxr-xr-xbuild/mkdir.sh35
-rw-r--r--build/program.mk30
-rw-r--r--build/rules.mk132
-rwxr-xr-xbuild/snapshot5
-rw-r--r--build/special.mk45
-rwxr-xr-xbuildconf3
-rw-r--r--configure.in163
-rw-r--r--docs/cgi-examples/printenv7
-rw-r--r--docs/cgi-examples/test-cgi31
-rw-r--r--docs/conf/highperformance.conf52
-rw-r--r--docs/conf/httpd-std.conf859
-rw-r--r--docs/conf/httpd-win.conf781
-rw-r--r--docs/conf/magic371
-rw-r--r--docs/conf/mime.types373
-rw-r--r--docs/docroot/apache_pb.gifbin2326 -> 0 bytes
-rw-r--r--docs/icons/README158
-rw-r--r--docs/icons/a.gifbin246 -> 0 bytes
-rw-r--r--docs/icons/alert.black.gifbin242 -> 0 bytes
-rw-r--r--docs/icons/alert.red.gifbin247 -> 0 bytes
-rw-r--r--docs/icons/apache_pb.gifbin2326 -> 0 bytes
-rw-r--r--docs/icons/back.gifbin216 -> 0 bytes
-rw-r--r--docs/icons/ball.gray.gifbin233 -> 0 bytes
-rw-r--r--docs/icons/ball.red.gifbin205 -> 0 bytes
-rw-r--r--docs/icons/binary.gifbin246 -> 0 bytes
-rw-r--r--docs/icons/binhex.gifbin246 -> 0 bytes
-rw-r--r--docs/icons/blank.gifbin148 -> 0 bytes
-rw-r--r--docs/icons/bomb.gifbin308 -> 0 bytes
-rw-r--r--docs/icons/box1.gifbin251 -> 0 bytes
-rw-r--r--docs/icons/box2.gifbin268 -> 0 bytes
-rw-r--r--docs/icons/broken.gifbin247 -> 0 bytes
-rw-r--r--docs/icons/burst.gifbin235 -> 0 bytes
-rw-r--r--docs/icons/c.gifbin242 -> 0 bytes
-rw-r--r--docs/icons/comp.blue.gifbin251 -> 0 bytes
-rw-r--r--docs/icons/comp.gray.gifbin246 -> 0 bytes
-rw-r--r--docs/icons/compressed.gifbin1038 -> 0 bytes
-rw-r--r--docs/icons/continued.gifbin214 -> 0 bytes
-rw-r--r--docs/icons/dir.gifbin225 -> 0 bytes
-rw-r--r--docs/icons/down.gifbin163 -> 0 bytes
-rw-r--r--docs/icons/dvi.gifbin238 -> 0 bytes
-rw-r--r--docs/icons/f.gifbin236 -> 0 bytes
-rw-r--r--docs/icons/folder.gifbin225 -> 0 bytes
-rw-r--r--docs/icons/folder.open.gifbin242 -> 0 bytes
-rw-r--r--docs/icons/folder.sec.gifbin243 -> 0 bytes
-rw-r--r--docs/icons/forward.gifbin219 -> 0 bytes
-rw-r--r--docs/icons/generic.gifbin221 -> 0 bytes
-rw-r--r--docs/icons/generic.red.gifbin220 -> 0 bytes
-rw-r--r--docs/icons/generic.sec.gifbin249 -> 0 bytes
-rw-r--r--docs/icons/hand.right.gifbin217 -> 0 bytes
-rw-r--r--docs/icons/hand.up.gifbin223 -> 0 bytes
-rw-r--r--docs/icons/icon.sheet.gifbin11977 -> 0 bytes
-rw-r--r--docs/icons/image1.gifbin274 -> 0 bytes
-rw-r--r--docs/icons/image2.gifbin309 -> 0 bytes
-rw-r--r--docs/icons/image3.gifbin286 -> 0 bytes
-rw-r--r--docs/icons/index.gifbin268 -> 0 bytes
-rw-r--r--docs/icons/layout.gifbin276 -> 0 bytes
-rw-r--r--docs/icons/left.gifbin172 -> 0 bytes
-rw-r--r--docs/icons/link.gifbin249 -> 0 bytes
-rw-r--r--docs/icons/movie.gifbin243 -> 0 bytes
-rw-r--r--docs/icons/p.gifbin237 -> 0 bytes
-rw-r--r--docs/icons/patch.gifbin251 -> 0 bytes
-rw-r--r--docs/icons/pdf.gifbin249 -> 0 bytes
-rw-r--r--docs/icons/pie0.gifbin188 -> 0 bytes
-rw-r--r--docs/icons/pie1.gifbin198 -> 0 bytes
-rw-r--r--docs/icons/pie2.gifbin198 -> 0 bytes
-rw-r--r--docs/icons/pie3.gifbin191 -> 0 bytes
-rw-r--r--docs/icons/pie4.gifbin193 -> 0 bytes
-rw-r--r--docs/icons/pie5.gifbin189 -> 0 bytes
-rw-r--r--docs/icons/pie6.gifbin186 -> 0 bytes
-rw-r--r--docs/icons/pie7.gifbin185 -> 0 bytes
-rw-r--r--docs/icons/pie8.gifbin173 -> 0 bytes
-rw-r--r--docs/icons/portal.gifbin254 -> 0 bytes
-rw-r--r--docs/icons/ps.gifbin244 -> 0 bytes
-rw-r--r--docs/icons/quill.gifbin267 -> 0 bytes
-rw-r--r--docs/icons/right.gifbin172 -> 0 bytes
-rw-r--r--docs/icons/screw1.gifbin258 -> 0 bytes
-rw-r--r--docs/icons/screw2.gifbin263 -> 0 bytes
-rw-r--r--docs/icons/script.gifbin242 -> 0 bytes
-rw-r--r--docs/icons/small/README.txt6
-rw-r--r--docs/icons/small/back.gifbin129 -> 0 bytes
-rw-r--r--docs/icons/small/binary.gifbin134 -> 0 bytes
-rw-r--r--docs/icons/small/binhex.gifbin131 -> 0 bytes
-rw-r--r--docs/icons/small/blank.gifbin55 -> 0 bytes
-rw-r--r--docs/icons/small/broken.gifbin139 -> 0 bytes
-rw-r--r--docs/icons/small/burst.gifbin128 -> 0 bytes
-rw-r--r--docs/icons/small/comp1.gifbin130 -> 0 bytes
-rw-r--r--docs/icons/small/comp2.gifbin131 -> 0 bytes
-rw-r--r--docs/icons/small/compressed.gifbin128 -> 0 bytes
-rw-r--r--docs/icons/small/continued.gifbin114 -> 0 bytes
-rw-r--r--docs/icons/small/dir.gifbin132 -> 0 bytes
-rw-r--r--docs/icons/small/dir2.gifbin122 -> 0 bytes
-rw-r--r--docs/icons/small/doc.gifbin191 -> 0 bytes
-rw-r--r--docs/icons/small/forward.gifbin125 -> 0 bytes
-rw-r--r--docs/icons/small/generic.gifbin116 -> 0 bytes
-rw-r--r--docs/icons/small/generic2.gifbin127 -> 0 bytes
-rw-r--r--docs/icons/small/generic3.gifbin113 -> 0 bytes
-rw-r--r--docs/icons/small/image.gifbin126 -> 0 bytes
-rw-r--r--docs/icons/small/image2.gifbin138 -> 0 bytes
-rw-r--r--docs/icons/small/index.gifbin145 -> 0 bytes
-rw-r--r--docs/icons/small/key.gifbin187 -> 0 bytes
-rw-r--r--docs/icons/small/movie.gifbin134 -> 0 bytes
-rw-r--r--docs/icons/small/patch.gifbin182 -> 0 bytes
-rw-r--r--docs/icons/small/ps.gifbin184 -> 0 bytes
-rw-r--r--docs/icons/small/rainbow.gifbin3811 -> 0 bytes
-rw-r--r--docs/icons/small/sound.gifbin130 -> 0 bytes
-rw-r--r--docs/icons/small/sound2.gifbin119 -> 0 bytes
-rw-r--r--docs/icons/small/tar.gifbin132 -> 0 bytes
-rw-r--r--docs/icons/small/text.gifbin128 -> 0 bytes
-rw-r--r--docs/icons/small/transfer.gifbin124 -> 0 bytes
-rw-r--r--docs/icons/small/unknown.gifbin131 -> 0 bytes
-rw-r--r--docs/icons/small/uu.gifbin125 -> 0 bytes
-rw-r--r--docs/icons/sound1.gifbin248 -> 0 bytes
-rw-r--r--docs/icons/sound2.gifbin221 -> 0 bytes
-rw-r--r--docs/icons/sphere1.gifbin285 -> 0 bytes
-rw-r--r--docs/icons/sphere2.gifbin264 -> 0 bytes
-rw-r--r--docs/icons/tar.gifbin219 -> 0 bytes
-rw-r--r--docs/icons/tex.gifbin251 -> 0 bytes
-rw-r--r--docs/icons/text.gifbin229 -> 0 bytes
-rw-r--r--docs/icons/transfer.gifbin242 -> 0 bytes
-rw-r--r--docs/icons/unknown.gifbin245 -> 0 bytes
-rw-r--r--docs/icons/up.gifbin164 -> 0 bytes
-rw-r--r--docs/icons/uu.gifbin236 -> 0 bytes
-rw-r--r--docs/icons/uuencoded.gifbin236 -> 0 bytes
-rw-r--r--docs/icons/world1.gifbin228 -> 0 bytes
-rw-r--r--docs/icons/world2.gifbin261 -> 0 bytes
-rw-r--r--docs/man/ab.8209
-rw-r--r--docs/man/apachectl.8133
-rw-r--r--docs/man/apxs.8459
-rw-r--r--docs/man/dbmmanage.1171
-rw-r--r--docs/man/htdigest.197
-rw-r--r--docs/man/htpasswd.1213
-rw-r--r--docs/man/httpd.8211
-rw-r--r--docs/man/logresolve.887
-rw-r--r--docs/man/rotatelogs.883
-rw-r--r--docs/man/suexec.870
-rw-r--r--docs/manual/bind.html.en135
-rw-r--r--docs/manual/cgi_path.html.en93
-rw-r--r--docs/manual/content-negotiation.html.en588
-rw-r--r--docs/manual/custom-error.html.en177
-rw-r--r--docs/manual/developer/API.html1153
-rw-r--r--docs/manual/developer/hooks.html202
-rw-r--r--docs/manual/developer/index.html19
-rw-r--r--docs/manual/developer/modules.html200
-rw-r--r--docs/manual/developer/modules.html.en200
-rw-r--r--docs/manual/dso.html.en393
-rw-r--r--docs/manual/handler.html.en195
-rw-r--r--docs/manual/index.html31
-rw-r--r--docs/manual/index.html.en31
-rw-r--r--docs/manual/install.html.en270
-rw-r--r--docs/manual/invoking.html.en220
-rw-r--r--docs/manual/mod/directive-dict.html.en265
-rw-r--r--docs/manual/mpm.html96
-rw-r--r--docs/manual/mpm.html.en96
-rw-r--r--docs/manual/new_features_2_0.html51
-rw-r--r--docs/manual/new_features_2_0.html.en51
-rw-r--r--docs/manual/platform/netware.html278
-rw-r--r--docs/manual/platform/perf-bsd44.html254
-rw-r--r--docs/manual/platform/perf-dec.html285
-rw-r--r--docs/manual/platform/perf-hp.html122
-rw-r--r--docs/manual/platform/perf.html175
-rw-r--r--docs/manual/platform/readme-tpf.html208
-rw-r--r--docs/manual/platform/unixware.html62
-rw-r--r--docs/manual/platform/windows.html572
-rw-r--r--docs/manual/sections.html.en170
-rw-r--r--docs/manual/stopping.html.en183
-rw-r--r--docs/manual/suexec.html.en518
-rw-r--r--docs/manual/vhosts/fd-limits.html.en59
-rw-r--r--docs/manual/vhosts/index.html.en65
-rw-r--r--docs/manual/vhosts/name-based.html.en164
-rw-r--r--emacs-style10
-rw-r--r--httpd.dsp413
-rw-r--r--include/.cvsignore2
-rw-r--r--include/.indent.pro54
-rw-r--r--include/ap_config.h1480
-rw-r--r--include/ap_listen.h90
-rw-r--r--include/ap_mmn.h256
-rw-r--r--include/ap_mpm.h176
-rw-r--r--include/http_conf_globals.h76
-rw-r--r--include/http_config.h380
-rw-r--r--include/http_connection.h86
-rw-r--r--include/http_core.h302
-rw-r--r--include/http_log.h159
-rw-r--r--include/http_main.h77
-rw-r--r--include/http_protocol.h238
-rw-r--r--include/http_request.h127
-rw-r--r--include/http_vhost.h95
-rw-r--r--include/httpd.h1063
-rw-r--r--include/mpm_status.h131
-rw-r--r--include/rfc1413.h71
-rw-r--r--include/util_date.h80
-rw-r--r--include/util_md5.h76
-rw-r--r--include/util_script.h89
-rw-r--r--include/util_uri.h128
-rw-r--r--libhttpd.def396
-rw-r--r--modules/.cvsignore1
-rw-r--r--modules/Makefile.in10
-rw-r--r--modules/README30
-rw-r--r--modules/aaa/.cvsignore10
-rw-r--r--modules/aaa/.indent.pro54
-rw-r--r--modules/aaa/Makefile.in8
-rw-r--r--modules/aaa/config.m460
-rw-r--r--modules/aaa/mod_access.c407
-rw-r--r--modules/aaa/mod_access.exp1
-rw-r--r--modules/aaa/mod_auth.c333
-rw-r--r--modules/aaa/mod_auth.exp1
-rw-r--r--modules/aaa/mod_auth_anon.c307
-rw-r--r--modules/aaa/mod_auth_anon.dsp113
-rw-r--r--modules/aaa/mod_auth_anon.exp1
-rw-r--r--modules/aaa/mod_auth_db.c349
-rw-r--r--modules/aaa/mod_auth_db.module36
-rw-r--r--modules/aaa/mod_auth_dbm.c328
-rw-r--r--modules/aaa/mod_auth_dbm.exp1
-rw-r--r--modules/aaa/mod_auth_digest.c1970
-rw-r--r--modules/arch/win32/mod_isapi.c569
-rw-r--r--modules/cache/.indent.pro54
-rw-r--r--modules/echo/.indent.pro54
-rw-r--r--modules/echo/mod_echo.c75
-rw-r--r--modules/experimental/.cvsignore3
-rw-r--r--modules/experimental/.indent.pro54
-rw-r--r--modules/experimental/README53
-rw-r--r--modules/experimental/mod_example.c1146
-rw-r--r--modules/filters/.indent.pro54
-rw-r--r--modules/filters/mod_include.c2488
-rw-r--r--modules/filters/mod_include.exp1
-rw-r--r--modules/generators/.indent.pro54
-rw-r--r--modules/generators/mod_asis.c138
-rw-r--r--modules/generators/mod_asis.exp1
-rw-r--r--modules/generators/mod_autoindex.c1678
-rw-r--r--modules/generators/mod_autoindex.exp1
-rw-r--r--modules/generators/mod_cgi.c669
-rw-r--r--modules/generators/mod_cgi.exp1
-rw-r--r--modules/generators/mod_cgid.c1010
-rw-r--r--modules/generators/mod_info.c688
-rw-r--r--modules/generators/mod_info.dsp112
-rw-r--r--modules/generators/mod_info.exp1
-rw-r--r--modules/generators/mod_status.c139
-rw-r--r--modules/generators/mod_status.dsp113
-rw-r--r--modules/generators/mod_status.exp1
-rw-r--r--modules/http/.indent.pro54
-rw-r--r--modules/http/http_core.c2651
-rw-r--r--modules/http/http_protocol.c2797
-rw-r--r--modules/http/http_request.c1384
-rw-r--r--modules/http/mod_mime.c402
-rw-r--r--modules/http/mod_mime.exp1
-rw-r--r--modules/loggers/.indent.pro54
-rw-r--r--modules/loggers/mod_log_config.c1160
-rw-r--r--modules/loggers/mod_log_config.exp1
-rw-r--r--modules/mappers/.indent.pro54
-rw-r--r--modules/mappers/mod_actions.c222
-rw-r--r--modules/mappers/mod_actions.exp1
-rw-r--r--modules/mappers/mod_alias.c417
-rw-r--r--modules/mappers/mod_alias.exp1
-rw-r--r--modules/mappers/mod_dir.c235
-rw-r--r--modules/mappers/mod_dir.exp1
-rw-r--r--modules/mappers/mod_imap.c912
-rw-r--r--modules/mappers/mod_imap.exp1
-rw-r--r--modules/mappers/mod_negotiation.c2754
-rw-r--r--modules/mappers/mod_negotiation.exp1
-rw-r--r--modules/mappers/mod_rewrite.c4321
-rw-r--r--modules/mappers/mod_rewrite.dsp117
-rw-r--r--modules/mappers/mod_rewrite.exp1
-rw-r--r--modules/mappers/mod_rewrite.h504
-rw-r--r--modules/mappers/mod_so.c354
-rw-r--r--modules/mappers/mod_speling.c565
-rw-r--r--modules/mappers/mod_speling.dsp113
-rw-r--r--modules/mappers/mod_speling.exp1
-rw-r--r--modules/mappers/mod_userdir.c356
-rw-r--r--modules/mappers/mod_userdir.exp1
-rw-r--r--modules/mappers/mod_vhost_alias.c476
-rw-r--r--modules/metadata/.indent.pro54
-rw-r--r--modules/metadata/mod_cern_meta.c393
-rw-r--r--modules/metadata/mod_cern_meta.dsp113
-rw-r--r--modules/metadata/mod_cern_meta.exp1
-rw-r--r--modules/metadata/mod_env.c270
-rw-r--r--modules/metadata/mod_env.exp1
-rw-r--r--modules/metadata/mod_expires.c508
-rw-r--r--modules/metadata/mod_expires.dsp113
-rw-r--r--modules/metadata/mod_expires.exp1
-rw-r--r--modules/metadata/mod_headers.c258
-rw-r--r--modules/metadata/mod_headers.dsp113
-rw-r--r--modules/metadata/mod_headers.exp1
-rw-r--r--modules/metadata/mod_mime_magic.c2509
-rw-r--r--modules/metadata/mod_mime_magic.exp1
-rw-r--r--modules/metadata/mod_setenvif.c420
-rw-r--r--modules/metadata/mod_setenvif.exp1
-rw-r--r--modules/metadata/mod_unique_id.c411
-rw-r--r--modules/metadata/mod_unique_id.exp1
-rw-r--r--modules/metadata/mod_usertrack.c318
-rw-r--r--modules/metadata/mod_usertrack.dsp113
-rw-r--r--modules/metadata/mod_usertrack.exp1
-rw-r--r--modules/proxy/.cvsignore12
-rw-r--r--modules/proxy/.indent.pro55
-rw-r--r--modules/proxy/Makefile.libdir4
-rw-r--r--modules/proxy/libproxy.exp1
-rw-r--r--modules/proxy/mod_proxy.c903
-rw-r--r--modules/proxy/mod_proxy.dsp133
-rw-r--r--modules/proxy/mod_proxy.h316
-rw-r--r--modules/proxy/proxy_connect.c288
-rw-r--r--modules/proxy/proxy_ftp.c1242
-rw-r--r--modules/proxy/proxy_http.c532
-rw-r--r--modules/proxy/proxy_util.c1283
-rw-r--r--modules/ssl/.indent.pro54
-rw-r--r--modules/test/.cvsignore3
-rw-r--r--modules/test/.indent.pro54
-rw-r--r--modules/test/README3
-rw-r--r--modules/test/mod_rndchunk.c179
-rw-r--r--modules/test/mod_test_util_uri.c354
-rw-r--r--os/.cvsignore1
-rw-r--r--os/.indent.pro54
-rw-r--r--os/Makefile.in9
-rw-r--r--os/beos/Makefile.in10
-rw-r--r--os/beos/beosd.c217
-rw-r--r--os/beos/beosd.h106
-rw-r--r--os/beos/config.m43
-rw-r--r--os/beos/os.c59
-rw-r--r--os/beos/os.h102
-rw-r--r--os/bs2000/.cvsignore1
-rw-r--r--os/bs2000/bs2login.c297
-rw-r--r--os/bs2000/ebcdic.c252
-rw-r--r--os/bs2000/ebcdic.h8
-rw-r--r--os/bs2000/os-inline.c31
-rw-r--r--os/bs2000/os.c103
-rw-r--r--os/bs2000/os.h51
-rw-r--r--os/config.m418
-rw-r--r--os/os2/.cvsignore1
-rw-r--r--os/os2/Makefile.in10
-rw-r--r--os/os2/config.m44
-rw-r--r--os/os2/os-inline.c34
-rw-r--r--os/os2/os.h57
-rw-r--r--os/os2/util_os2.c192
-rw-r--r--os/tpf/TPFExport7
-rw-r--r--os/tpf/ebcdic.c221
-rw-r--r--os/tpf/ebcdic.h8
-rw-r--r--os/tpf/os-inline.c31
-rw-r--r--os/tpf/os.c414
-rw-r--r--os/tpf/os.h108
-rw-r--r--os/tpf/samples/linkdll.jcl121
-rw-r--r--os/tpf/samples/loadset.jcl58
-rw-r--r--os/unix/.cvsignore5
-rw-r--r--os/unix/Makefile.in10
-rw-r--r--os/unix/config.m49
-rw-r--r--os/unix/os-inline.c32
-rw-r--r--os/unix/os.h153
-rw-r--r--os/unix/unixd.c393
-rw-r--r--os/unix/unixd.h125
-rw-r--r--os/win32/.cvsignore27
-rw-r--r--os/win32/MakeModuleMak.cpp59
-rw-r--r--os/win32/Module.mak.tmpl230
-rw-r--r--os/win32/apache.icobin766 -> 0 bytes
-rw-r--r--os/win32/apache.rc84
-rw-r--r--os/win32/mod_isapi.c569
-rw-r--r--os/win32/modules.c75
-rw-r--r--os/win32/os.h209
-rw-r--r--os/win32/resource.h17
-rw-r--r--os/win32/util_win32.c594
-rw-r--r--server/.cvsignore17
-rw-r--r--server/.indent.pro54
-rw-r--r--server/Makefile.in32
-rw-r--r--server/buildmark.c70
-rw-r--r--server/config.c1438
-rw-r--r--server/config.m455
-rw-r--r--server/connection.c302
-rw-r--r--server/gen_test_char.c63
-rw-r--r--server/gen_test_char.dsp105
-rw-r--r--server/gen_uri_delims.c31
-rw-r--r--server/gen_uri_delims.dsp105
-rw-r--r--server/listen.c315
-rw-r--r--server/log.c742
-rw-r--r--server/main.c414
-rw-r--r--server/mpm/.cvsignore1
-rw-r--r--server/mpm/MPM.NAMING34
-rw-r--r--server/mpm/Makefile.in9
-rw-r--r--server/mpm/config.m475
-rw-r--r--server/mpm/dexter/.cvsignore3
-rw-r--r--server/mpm/dexter/Makefile.in10
-rw-r--r--server/mpm/dexter/Makefile.libdir4
-rw-r--r--server/mpm/dexter/config.m410
-rw-r--r--server/mpm/dexter/dexter.c1719
-rw-r--r--server/mpm/dexter/mpm_default.h138
-rw-r--r--server/mpm/dexter/scoreboard.c595
-rw-r--r--server/mpm/dexter/scoreboard.h108
-rw-r--r--server/mpm/mpmt_beos/Makefile.in10
-rw-r--r--server/mpm/mpmt_beos/Makefile.libdir4
-rw-r--r--server/mpm/mpmt_beos/config.m48
-rw-r--r--server/mpm/mpmt_beos/mpm_default.h140
-rw-r--r--server/mpm/mpmt_beos/mpmt_beos.c1430
-rw-r--r--server/mpm/mpmt_beos/mpmt_beos.h68
-rw-r--r--server/mpm/mpmt_beos/poll.c139
-rw-r--r--server/mpm/mpmt_beos/poll.h89
-rw-r--r--server/mpm/mpmt_beos/scoreboard.c169
-rw-r--r--server/mpm/mpmt_beos/scoreboard.h102
-rw-r--r--server/mpm/mpmt_pthread/.cvsignore5
-rw-r--r--server/mpm/mpmt_pthread/Makefile.in10
-rw-r--r--server/mpm/mpmt_pthread/Makefile.libdir4
-rw-r--r--server/mpm/mpmt_pthread/config.m415
-rw-r--r--server/mpm/mpmt_pthread/mpm_default.h150
-rw-r--r--server/mpm/mpmt_pthread/mpmt_pthread.c1733
-rw-r--r--server/mpm/mpmt_pthread/scoreboard.c285
-rw-r--r--server/mpm/mpmt_pthread/scoreboard.h239
-rw-r--r--server/mpm/prefork/.cvsignore3
-rw-r--r--server/mpm/prefork/Makefile.in10
-rw-r--r--server/mpm/prefork/Makefile.libdir4
-rw-r--r--server/mpm/prefork/config.m413
-rw-r--r--server/mpm/prefork/mpm_default.h126
-rw-r--r--server/mpm/prefork/prefork.c2604
-rw-r--r--server/mpm/prefork/scoreboard.h217
-rw-r--r--server/mpm/spmt_os2/.cvsignore1
-rw-r--r--server/mpm/spmt_os2/Makefile.in10
-rw-r--r--server/mpm/spmt_os2/Makefile.libdir4
-rw-r--r--server/mpm/spmt_os2/config.m46
-rw-r--r--server/mpm/spmt_os2/mpm_default.h116
-rw-r--r--server/mpm/spmt_os2/scoreboard.h208
-rw-r--r--server/mpm/spmt_os2/spmt_os2.c1795
-rw-r--r--server/mpm/winnt/mpm_default.h133
-rw-r--r--server/mpm/winnt/mpm_winnt.c1879
-rw-r--r--server/mpm/winnt/mpm_winnt.h81
-rw-r--r--server/mpm/winnt/registry.c554
-rw-r--r--server/mpm/winnt/service.c523
-rw-r--r--server/rfc1413.c240
-rw-r--r--server/util.c2031
-rw-r--r--server/util_date.c286
-rw-r--r--server/util_md5.c233
-rw-r--r--server/util_script.c685
-rw-r--r--server/util_uri.c600
-rw-r--r--server/vhost.c951
-rw-r--r--srclib/.cvsignore2
-rw-r--r--srclib/Makefile.in9
-rw-r--r--srclib/expat-lite/.cvsignore1
-rw-r--r--srclib/expat-lite/CHANGES41
-rw-r--r--srclib/expat-lite/Makefile.in33
-rw-r--r--srclib/expat-lite/asciitab.h62
-rw-r--r--srclib/expat-lite/expat.html73
-rw-r--r--srclib/expat-lite/hashtable.c151
-rw-r--r--srclib/expat-lite/hashtable.h69
-rw-r--r--srclib/expat-lite/iasciitab.h63
-rw-r--r--srclib/expat-lite/latin1tab.h62
-rw-r--r--srclib/expat-lite/nametab.h150
-rw-r--r--srclib/expat-lite/utf8tab.h63
-rw-r--r--srclib/expat-lite/xmldef.h63
-rw-r--r--srclib/expat-lite/xmlparse.c3256
-rw-r--r--srclib/expat-lite/xmlparse.h482
-rw-r--r--srclib/expat-lite/xmlrole.c1113
-rw-r--r--srclib/expat-lite/xmlrole.h111
-rw-r--r--srclib/expat-lite/xmltok.c1527
-rw-r--r--srclib/expat-lite/xmltok.h307
-rw-r--r--srclib/expat-lite/xmltok_impl.c1746
-rw-r--r--srclib/expat-lite/xmltok_impl.h71
-rw-r--r--srclib/expat-lite/xmltok_ns.c96
-rw-r--r--support/.cvsignore11
-rw-r--r--support/.indent.pro54
-rw-r--r--support/README62
-rw-r--r--support/SHA1/README.sha134
-rw-r--r--support/SHA1/convert-sha1.pl36
-rw-r--r--support/SHA1/htpasswd-sha1.pl22
-rw-r--r--support/SHA1/ldif-sha1.example19
-rw-r--r--support/ab.c1128
-rw-r--r--support/apxs.in658
-rw-r--r--support/dbmmanage189
-rw-r--r--support/htdigest.c275
-rw-r--r--support/htdigest.dsp103
-rw-r--r--support/htpasswd.c592
-rw-r--r--support/htpasswd.dsp119
-rw-r--r--support/httpd.exp411
-rw-r--r--support/log_server_status118
-rw-r--r--support/logresolve.c350
-rw-r--r--support/logresolve.pl264
-rw-r--r--support/phf_abuse_log.cgi21
-rw-r--r--support/rotatelogs.c85
-rw-r--r--support/rotatelogs.dsp89
-rw-r--r--support/split-logfile103
-rw-r--r--support/suexec.c566
-rw-r--r--support/suexec.h143
-rw-r--r--test/.cvsignore11
-rw-r--r--test/.indent.pro54
-rw-r--r--test/README3
-rw-r--r--test/check_chunked42
-rw-r--r--test/cls.c166
-rw-r--r--test/tcpdumpscii.txt50
-rw-r--r--test/test-writev.c85
-rw-r--r--test/test_date.c180
-rw-r--r--test/test_find.c62
-rw-r--r--test/test_limits.c200
-rw-r--r--test/test_parser.c59
-rw-r--r--test/test_select.c30
-rw-r--r--test/time-sem.c572
-rw-r--r--test/zb.c567
508 files changed, 0 insertions, 112104 deletions
diff --git a/.gdbinit b/.gdbinit
deleted file mode 100644
index 4ab8336971..0000000000
--- a/.gdbinit
+++ /dev/null
@@ -1,33 +0,0 @@
-# gdb macros which may be useful for folks using gdb to debug
-# apache. Delete it if it bothers you.
-
-define dump_table
- set $t = (table_entry *)((array_header *)$arg0)->elts
- set $n = ((array_header *)$arg0)->nelts
- set $i = 0
- while $i < $n
- printf "[%u] '%s'='%s'\n", $i, $t[$i].key, $t[$i].val
- set $i = $i + 1
- end
-end
-document dump_table
- Print the key/value pairs in a table.
-end
-
-
-define rh
- run -f /home/dgaudet/ap2/conf/mpm.conf
-end
-
-define dump_string_array
- set $a = (char **)((array_header *)$arg0)->elts
- set $n = (int)((array_header *)$arg0)->nelts
- set $i = 0
- while $i < $n
- printf "[%u] '%s'\n", $i, $a[$i]
- set $i = $i + 1
- end
-end
-document dump_string_array
- Print all of the elements in an array of strings.
-end
diff --git a/Announcement b/Announcement
deleted file mode 100644
index 4c9996294e..0000000000
--- a/Announcement
+++ /dev/null
@@ -1,95 +0,0 @@
-Apache 1.3.6 Released
-=====================
-
-The Apache Group is pleased to announce the release of version
-1.3.6 of the Apache HTTP server.
-
-This new Apache version incorporates over 60 significant improvements
-to the server. Apart from portability and security fixes, documentation
-enhancements, performance improvements, and assorted other minor
-features or fixes notable changes are:
-
- - mod_log_config now supports conditional logging based upon
- environment variables and support for multiline entries.
-
- - New CustomLog directive %V: This logs the hostname according to the
- UseCanonicalName setting (this is the pre-1.3.4 behaviour of %v).
-
- - Enhanced mod_rewrite's mapfile handling: The in-core cache for text
- and DBM format mapfiles now uses a hash table with LRU functionality.
- Furthermore map lookups for non-existent keys are now cached as well.
- The changes drastically improve the performance when large rewrite
- maps are in use.
-
- - Ability to handle DES or MD5 authentication passwords.
-
- - New <LimitExcept> directive to allow the user to assign authentication
- control to any HTTP method that is *not* given in the argument list;
- i.e., the logical negation of the <Limit> directive.
-
- - Improved content negotiation.
-
- - New ScriptInterpreterSource directive to enable searching the
- Win32 registry for script interpreters.
-
- - The FAQ document was reorganised.
-
- - Overhauled ApacheBench benchmark program.
-
- - Several new API functions have been added.
-
-A complete listing with detailed descriptions is provided in the
-src/CHANGES file.
-
-We consider Apache 1.3.6 to be the best version of Apache available and
-we strongly recommend that users of older versions, especially of the
-1.1.x and 1.2.x family, upgrade as soon as possible. No further releases
-will be made in the 1.2.x family.
-
-
-Apache 1.3.6 is available for download from
-
- http://www.apache.org/dist/
-
-Please see the CHANGES_1.3 file in the same directory for a full
-list of changes.
-
-Binary distributions are available from
-
- http://www.apache.org/dist/binaries/
-
-As of Apache 1.3.6 binary distributions contain all standard Apache
-modules as shared objects (if supported by the platform) and include
-full source code. Installation is easily done by executing the
-included install script. See the README.bindist and INSTALL.bindist
-files for a complete explanation. Please note that the binary
-distributions are only provided for your convenience and current
-distributions for specific platforms are not always available.
-
-The source and binary distributions are also available via any of the
-mirrors listed at
-
- http://www.apache.org/mirrors/
-
-For an overview of new features in 1.3 please see
-
- http://www.apache.org/docs/new_features_1_3.html
-
-In general, Apache 1.3 offers several substantial improvements
-over version 1.2, including better performance, reliability and a
-wider range of supported platforms, including Windows 95/98 and NT
-(which fall under the "Win32" label).
-
-Apache is the most popular web server in the known universe; over
-half of the servers on the Internet are running Apache or one of
-its variants.
-
-IMPORTANT NOTE FOR WIN32 USERS: Over the years, many users have
-come to trust Apache as a secure and stable server. It must
-be realized that the current Win32 code has not yet reached these
-levels and should still be considered to be of beta quality. Any
-Win32 stability or security problems do not impact, in any way,
-Apache on other platforms. With the continued donation of time
-and resources by individuals and companies, we hope that the Win32
-version of Apache will grow stronger through the 1.3.x release cycle.
-
diff --git a/Apache.dsp b/Apache.dsp
deleted file mode 100644
index c199b60dcd..0000000000
--- a/Apache.dsp
+++ /dev/null
@@ -1,109 +0,0 @@
-# Microsoft Developer Studio Project File - Name="Apache" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=Apache - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "Apache.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "Apache.mak" CFG="Apache - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "Apache - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "Apache - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "Apache - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\ApacheLa"
-# PROP BASE Intermediate_Dir ".\ApacheLa"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\ApacheR"
-# PROP Intermediate_Dir ".\ApacheR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "./include" /I "./lib/apr/include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "WIN32_LEAN_AND_MEAN" /YX /FD /c
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 lib\apr\Release\aprlib.lib CoreR\ApacheCore.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "Apache - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\ApacheL0"
-# PROP BASE Intermediate_Dir ".\ApacheL0"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\ApacheD"
-# PROP Intermediate_Dir ".\ApacheD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "./include" /I "./lib/apr/include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "WIN32_LEAN_AND_MEAN" /YX /FD /c
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
-# ADD LINK32 lib\apr\debug\aprlib.lib CoreD\ApacheCore.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:console /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "Apache - Win32 Release"
-# Name "Apache - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=.\os\win32\main_win32.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# Begin Source File
-
-SOURCE=.\os\win32\apache.ico
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\apache.rc
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/ApacheCore.def b/ApacheCore.def
deleted file mode 100644
index 312311533f..0000000000
--- a/ApacheCore.def
+++ /dev/null
@@ -1,396 +0,0 @@
-; apachecore.def :
-
-LIBRARY ApacheCore
-DESCRIPTION ''
-
-EXPORTS
- ; Add new API calls to the end of this list.
-; ap_MD5Final @1
-; ap_MD5Init @2
-; ap_MD5Update @3
-; ap_acquire_mutex @4
- ap_add_cgi_vars @5
- ap_add_common_vars @6
- ap_add_loaded_module @7
- ap_add_module @8
- ap_add_named_module @9
- ap_add_per_dir_conf @10
- ap_add_per_url_conf @11
- ;ap_add_version_component @12
- ap_allow_options @13
- ap_allow_overrides @14
-; ap_append_arrays @15
-; ap_array_cat @16
- ap_auth_name @17
- ap_auth_type @18
- ap_basic_http_header @19
- ap_bclose @20
- ap_bcreate @21
- ap_bfilbuf @22
- ;ap_bfileno @23
- ap_bflsbuf @24
- ap_bflush @25
- ap_bgetopt @26
- ap_bgets @27
- ;ap_bhalfduplex @28
- ;ap_block_alarms @29
- ap_blookc @30
- ;ap_bnonblock @31
- ap_bonerror @32
- ;ap_bpushfd @33
- ;ap_bpushh @34
- ap_bputs @35
- ap_bread @36
- ap_bsetflag @37
- ap_bsetopt @38
- ;ap_bskiplf @39
-; ap_bspawn_child @40
- ap_bwrite @41
- ;ap_bytes_in_free_blocks @42
- ;ap_bytes_in_pool @43
-; ap_call_exec @44
- ;ap_can_exec @45
- ap_cfg_closefile @46
- ap_cfg_getc @47
- ap_cfg_getline @48
- ap_chdir_file @49
- ;ap_check_alarm @50
- ap_check_cmd_context @51
- ap_checkmask @52
-; ap_cleanup_for_exec @53
- ap_clear_module_list @54
-; ap_clear_pool @55
-; ap_clear_table @56
- ap_close_piped_log @57
- ap_construct_server @58
- ap_construct_url @59
- ap_content_type_tolower @60
-; ap_copy_array @61
-; ap_copy_array_hdr @62
-; ap_copy_table @63
- ap_count_dirs @64
-; ap_cpystrn @65
- ap_create_environment @66
-; ap_create_mutex @67
- ap_create_per_dir_config @68
- ap_custom_response @69
- ap_default_port_for_request @70
- ap_default_port_for_scheme @71
- ap_default_type @72
-; ap_destroy_mutex @73
-; ap_destroy_pool @74
- ap_destroy_sub_req @75
- ap_die @76
- ap_discard_request_body @77
- ap_document_root @78
- ap_each_byterange @79
- ap_error_log2stderr @80
- ap_escape_html @81
- ap_escape_path_segment @82
- ap_escape_quotes @83
- ap_escape_shell_cmd @84
- ;ap_exists_scoreboard_image @85
- ap_finalize_request_protocol @86
- ap_find_command @87
- ap_find_command_in_modules @88
- ap_find_last_token @89
- ap_find_linked_module @90
- ap_find_module_name @91
- ap_find_path_info @92
- ap_find_token @93
- ap_get_basic_auth_pw @94
- ap_get_client_block @95
-; ap_get_gmtoff @96
- ap_get_limit_req_body @97
- ap_get_remote_host @98
- ap_get_remote_logname @99
- ap_get_server_built @100
- ap_get_server_name @101
- ap_get_server_port @102
- ;ap_get_server_version @103
-; ap_get_time @104
- ap_get_token @105
- ap_getparents @106
- ap_getword @107
- ap_getword_conf @108
- ap_getword_conf_nc @109
- ap_getword_nc @110
- ap_getword_nulls @111
- ap_getword_nulls_nc @112
- ap_getword_white @113
- ap_getword_white_nc @114
-; ap_gm_timestr_822 @115
- ap_gname2id @116
- ap_handle_command @117
- ;ap_hard_timeout @118
- ap_ht_time @119
- ap_ind @120
- ap_index_of_response @121
- ap_init_virtual_host @122
- ap_internal_redirect @123
- ap_internal_redirect_handler @124
- ap_is_directory @125
-; ap_is_fnmatch @126
- ap_is_initial_req @127
- ap_is_matchexp @128
- ap_is_url @129
-; ap_kill_cleanup @130
-; ap_kill_cleanups_for_fd @131
-; ap_kill_cleanups_for_socket @132
- ;ap_kill_timeout @133
- ap_log_assert @134
- ap_log_error_old @135
- ap_log_reason @136
- ap_log_unixerr @137
-; ap_make_array @138
- ap_make_dirstr @139
- ap_make_dirstr_parent @140
- ap_make_dirstr_prefix @141
- ap_make_full_path @142
-; ap_make_sub_pool @143
-; ap_make_table @144
- ap_matches_request_vhost @145
- ap_md5 @146
- ap_md5_binary @147
- ap_md5contextTo64 @148
- ap_md5digest @149
- ap_meets_conditions @150
- ap_no2slash @151
- ap_note_auth_failure @152
- ap_note_basic_auth_failure @153
-; ap_note_cleanups_for_fd @154
-; ap_note_cleanups_for_file @155
-; ap_note_cleanups_for_h @156
-; ap_note_cleanups_for_socket @157
- ap_note_digest_auth_failure @158
-; ap_note_subprocess @159
-; ap_open_mutex @160
- ap_open_piped_log @161
- ap_os_canonical_filename @162
- ap_os_escape_path @163
-; ap_overlap_tables @164
-; ap_overlay_tables @165
-; ap_palloc @166
- ap_parseHTTPdate @167
- ap_parse_hostinfo_components @168
- ap_parse_uri @169
- ap_parse_uri_components @170
-; ap_pcalloc @171
- ap_pcfg_open_custom @172
- ap_pcfg_openfile @173
-; ap_pclosedir @174
-; ap_pclosef @175
-; ap_pcloseh @176
-; ap_pclosesocket @177
- ap_pduphostent @178
-; ap_pfclose @179
-; ap_pfdopen @180
-; ap_pfopen @181
- ap_pgethostbyname @182
-; ap_popendir @183
-; ap_popenf @184
- ap_pregcomp @185
- ap_pregfree @186
- ap_pregsub @187
- ap_psignature @188
-; ap_psocket @189
-; ap_pstrdup @190
-; ap_pstrndup @191
-; ap_push_array @192
-; ap_pvsprintf @193
- ap_rationalize_mtime @194
-; ap_register_cleanup @195
-; ap_release_mutex @196
- ap_remove_loaded_module @197
- ap_remove_module @198
- ap_requires @199
- ;ap_reset_timeout @200
- ap_rflush @201
- ap_rind @202
- ap_rputc @203
- ap_rputs @204
-; ap_run_cleanup @205
- ap_run_sub_req @206
- ap_rwrite @207
- ap_satisfies @208
- ap_scan_script_header_err @209
- ap_scan_script_header_err_buff @210
- ap_scan_script_header_err_core @211
- ;ap_send_fb @212
- ;ap_send_fb_length @213
- ap_send_fd @214
- ap_send_fd_length @215
- ap_send_http_header @216
- ap_send_http_trace @217
-; ap_send_mmap @218
- ap_send_size @219
- ap_server_root_relative @220
- ap_set_byterange @221
- ap_set_content_length @222
- ap_set_etag @223
- ap_set_keepalive @224
- ap_set_last_modified @225
- ap_setup_client_block @226
- ap_should_client_block @227
- ;ap_soft_timeout @228
- ap_some_auth_required @229
-; ap_spawn_child @230
- ap_srm_command_loop @231
- ap_str_tolower @232
- ap_strcasecmp_match @233
- ap_strcmp_match @234
- ap_sub_req_lookup_file @235
- ap_sub_req_lookup_uri @236
- ;ap_sync_scoreboard_image @237
-; ap_table_add @238
-; ap_table_addn @239
-; ap_table_get @240
-; ap_table_merge @241
-; ap_table_mergen @242
-; ap_table_set @243
-; ap_table_setn @244
-; ap_table_unset @245
-; ap_tm2sec @246
- ap_uname2id @247
- ;ap_unblock_alarms @248
- ap_unescape_url @249
- ap_unparse_uri_components @250
- ap_update_mtime @251
- ap_uudecode @252
- ap_uuencode @253
- ap_vbprintf @254
-; ap_vformatter @255
-; ap_vsnprintf @256
- closedir @257
- opendir @258
-; os_spawnv @259
-; os_spawnve @260
- os_stat @261
- readdir @262
- regcomp @263
- regexec @264
- regfree @265
- access_module @266
- alias_module @267
- ap_bprintf @268
- ap_bvputs @269
-; ap_day_snames @270
- ;ap_extended_status @271
- ap_limit_section @272
- ap_loaded_modules @273
- ap_log_error @274
- ap_log_printf @275
- ap_log_rerror @276
-; ap_month_snames @277
-; ap_null_cleanup @278
-; ap_psprintf @279
-; ap_pstrcat @280
- ;ap_restart_time @281
- ap_rprintf @282
- ap_rvputs @283
- ;ap_scoreboard_image @284
- ap_send_header_field @285
- ap_server_argv0 @286
- ap_server_root @287
- ap_set_file_slot @288
- ap_set_flag_slot @289
- ap_set_string_slot @290
- ap_set_string_slot_lower @291
-; ap_snprintf @292
- ;ap_suexec_enabled @293
-; ap_table_do @294
- apache_main @295
- asis_module @296
- auth_module @297
- autoindex_module @298
- ;cgi_module @299
- config_log_module @300
- core_module @301
- dir_module @302
- env_module @303
- imap_module @304
- ;includes_module @305
- mime_module @306
- negotiation_module @307
-; os_spawnle @308
- setenvif_module @309
- ;so_module @310
- top_module @311
-; ap_fnmatch @312
- ap_method_number_of @313
- ap_exists_config_define @314
- ap_single_module_configure @315
- ap_make_etag @317
-; ap_array_pstrcat @318
- ap_os_is_filename_valid @319
- ap_find_list_item @320
-; ap_MD5Encode @321
-; ap_validate_password @322
- ap_size_list_item @323
- ap_get_list_item @324
- ;ap_scoreboard_fname @325
- ;ap_pid_fname @326
- ;ap_excess_requests_per_child @327
- ;ap_threads_per_child @328
- ;ap_max_requests_per_child @329
- ;ap_daemons_to_start @330
- ;ap_daemons_min_free @331
- ;ap_daemons_max_free @332
- ;ap_daemons_limit @333
- ;ap_user_name @334
- ;ap_user_id @335
- ;ap_group_id @336
- ;ap_standalone @337
- ;ap_server_confname @338
- ap_sub_req_method_uri @339
- ap_regerror @341
- ap_regexec @342
- ap_field_noparam @343
- ap_pbase64decode @344
- ap_pbase64encode @345
- ap_base64encode @346
- ap_base64encode_binary @347
- ap_base64encode_len @348
- ap_base64decode @349
- ap_base64decode_binary @350
- ap_base64decode_len @351
- ap_SHA1Init @352
- ap_SHA1Update_binary @353
- ap_SHA1Update @354
- ap_SHA1Final @355
- ap_sha1_base64 @356
- ap_show_hook @357
- ap_hook_sort_register @358
- ap_hook_process_connection @359
- ap_process_http_connection @360
- ap_hook_check_user_id @361
- ap_hook_auth_checker @362
- ap_hook_fixups @363
- regerror @364
- ap_send_error_response @365
- ap_start_shutdown @366
- send_signal_to_service @367
- ap_read_config @368
- ap_server_pre_read_config @369
- ap_server_post_read_config @370
- ap_setup_prelinked_modules @371
- RemoveService @372
- InstallService @373
- isValidService @374
- service_main @375
- isProcessService @376
- ap_registry_get_server_root @377
- ap_registry_get_service_conf @378
- ap_hook_pre_connection @379
- ap_hook_post_read_request @380
- ap_hook_log_transaction @381
- ap_hook_http_method @382
- ap_hook_default_port @383
- ap_hook_translate_name @384
- ap_hook_type_checker @385
- ap_hook_access_checker @386
- ap_hook_header_parser @387
- ap_hook_pre_config @388
- ap_hook_post_config @389
- ap_hook_open_logs @390
- ap_hook_child_init @391
diff --git a/ApacheCore.dsp b/ApacheCore.dsp
deleted file mode 100644
index 2247eeb72f..0000000000
--- a/ApacheCore.dsp
+++ /dev/null
@@ -1,413 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheCore" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheCore - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheCore.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheCore.mak" CFG="ApacheCore - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheCore - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheCore - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheCore - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\ApacheCo"
-# PROP BASE Intermediate_Dir ".\ApacheCo"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\CoreR"
-# PROP Intermediate_Dir ".\CoreR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I ".\include" /I ".\lib\apr\include" /I ".\os\win32" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "WIN32_LEAN_AND_MEAN" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 lib\apr\Release\aprlib.lib os\win32\ApacheOSR\ApacheOS.lib regex\release\regex.lib ap\Release\ap.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheCore - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\ApacheC0"
-# PROP BASE Intermediate_Dir ".\ApacheC0"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\CoreD"
-# PROP Intermediate_Dir ".\CoreD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I ".\include" /I ".\lib\apr\include" /I ".\os\win32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "WIN32_LEAN_AND_MEAN" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 lib\apr\debug\aprlib.lib regex\debug\regex.lib os\win32\ApacheOSD\ApacheOS.lib ap\Debug\ap.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# SUBTRACT LINK32 /map
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheCore - Win32 Release"
-# Name "ApacheCore - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=.\ApacheCore.def
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\buff.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\buildmark.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_config.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_connection.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_core.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_log.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_main.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_protocol.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_request.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_vhost.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\iol_file.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\iol_socket.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\listen.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_access.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_actions.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_alias.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_asis.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_auth.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_autoindex.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_cgi.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_dir.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_env.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_imap.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_include.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_log_config.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_mime.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_negotiation.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_setenvif.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_so.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_userdir.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\modules.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\registry.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\rfc1413.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\service.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\util.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\util_date.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\util_md5.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\util_script.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\util_uri.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\util_win32.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\mpm\winnt\winnt.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\include\ap.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\ap_hooks.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\ap_iol.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\ap_listen.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\ap_md5.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\buff.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\conf.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\explain.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\fnmatch.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\hsregex.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_conf_globals.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_config.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_connection.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_core.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_log.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_main.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_protocol.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_request.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_vhost.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\httpd.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\iol_socket.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_mime.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\mpm\winnt\mpm_default.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\os.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\registry.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\rfc1413.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\service.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\util_date.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\util_md5.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\util_script.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\util_uri.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\mpm\winnt\winnt.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# Begin Group "Generated Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\main\test_char.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\uri_delims.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/KEYS b/KEYS
deleted file mode 100644
index 6d0c7823f3..0000000000
--- a/KEYS
+++ /dev/null
@@ -1,518 +0,0 @@
-This file contains the PGP keys of various Apache developers.
-Please don't use them for email unless you have to. Their main
-purpose is code signing.
-
-Apache users: pgp < KEYS
-Apache developers: pgp -kxa <your name> and append it to this file.
-
-
-Type Bits/KeyID Date User ID
-pub 1024/2719AF35 1995/05/13 Ben Laurie <ben@algroup.co.uk>
- Ben Laurie <ben@gonzo.ben.algroup.co.uk>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.3ia
-
-mQCNAi+0jQEAAAEEAK7oX0FeNncaHfa1v+V7SMUviAm8qB8orWG0zvja4ZtSrHVg
-/PMwppUh44t5ERA9lltRBdHu30+YSh8a1dYt1XOD83nknzj9rhtpFAPqyywlLVhN
-VY3PVLyMbULw27aEAGc+StFqrDoUQ0+j9QU/YH/IyVN9rBaJyhsIDEUnGa81AAUR
-tB5CZW4gTGF1cmllIDxiZW5AYWxncm91cC5jby51az6JARUDBRAyb2Doc3AsNzyk
-Yh0BARa6CACUBnsP9Vb+T/PvNYKVQBIODz+90tz5GozWwCVfPVSaRd8Dz+oF1sFs
-YCz/KuxqBhL5PkiCuSMfOVlPA5nirjoktMF/af5saZqhPr5rvr67Z1OzZnVDvWe4
-DhFrn8EoLrY5YNJhUwfINnZqyKaQu8TW6p4caLkTCW0KM+4ztTe74xRG9NeE+K0+
-0RMpAF3jEY36LGRjq6miazt2bVZQDTl6CuWE+gAaFlX2ojV7e1xdxVvpBIEc34MP
-g9ORJ0evx1QilMt1VyGcS/pe4IQgjdJqjU/4fzqFZkT2nntQMbV9kQyNe2+qfqP7
-giTryIanmBAfd3oOCTsRz2VKPfdhCqCRiQB1AwUQMRdzEEyr2GZv4ALJAQEuhAL6
-A8I84BR+87uNAHD0ZJkTM73WdyMEGvAKBvrZK/g0VLYj0NtgkSuRJfrXnGkuh27I
-ZrjfL952Q/mXgMtHhJHJ9YfenGFWSEDHnolNzKOzTQJpE01IZ3nWv7ezA9N1LZVC
-iQCVAgUQMROrdRsIDEUnGa81AQEUNgQAlvyjt534RDQd2AYGoZriaFzjaL7dTCRH
-4b1zxuWBNWf3pI4W0iwU02Q5rEWEmY5DLl6/ie+vcQKOWSqXVgnM/s6EARdKEN56
-d6PzkwszgfEybDYrcAxReJcTCcV8ItJer/iqpBLgtaxyUpI77NvKcDGHp6BgYpnv
-1lNkH0FISK+JAJUDBRAwtzlWdGx7qH+PTVkBARFWA/99NTCMihlOZS7LmHDVic/q
-H1K1DVdMcv0iL39+7Pq4+AA/ET8dWIgcjaIreSqAZTpjwU1pMPaWgecDD1rEMCYX
-R+JoofLJ24BLcSlpXJ/gWMifYNxqdDeMRkw/aW/kaXQJWIz+oDYNuOyi5VvB6faF
-6Lm7P5cw1mX0I5rYc3woh7QoQmVuIExhdXJpZSA8YmVuQGdvbnpvLmJlbi5hbGdy
-b3VwLmNvLnVrPokAlQIFEDEXgCUbCAxFJxmvNQEBiL8D/3MLjfHGvuByqP1VFQrF
-QeMNd2aIQuC7ys3lkDvrLkkPJQANua0/MdDaZk6F5pCGcTmmmaJOjcOcCheD7FU5
-w9zxkQGR3Swr3opFHSr/CkEl83jRy3oq1MFydWoGajQjIr/c23X8zr+XntPyO6VX
-q5He4RrTiXeAEFBzz+J+R+EQ
-=zh1u
------END PGP PUBLIC KEY BLOCK-----
-
-
-Type Bits/KeyID Date User ID
-pub 1024/A99F75DD 1997/01/24 Rodent of Unusual Size <Ken.Coar@Golux.Com>
- Rodent of Unusual Size <coar@Apache.Org>
- Rodent of Unusual Size <Coar@Raleigh.IBM.Com>
- Rodent of Unusual Size <Coar@DECUS.Org>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.3a
-
-mQCNAzLpIyUAAAEEAN9KC8CxTeozPYJjsnhFpJ14d4Hhf2M6OTgqPQFRHOswM/3j
-B7IW0s+HwVyQ5/SjIlo+8ur9X7yaj1FS2GQmKD1x9LKeHRAoosBIs33okRtoeDRy
-ufTaTyQTwLklxClWm3JEef4xZioun1mtWbpz0yVEOCSZcRvtnJrNPMCpn3XdAAUR
-tCtSb2RlbnQgb2YgVW51c3VhbCBTaXplIDxLZW4uQ29hckBHb2x1eC5Db20+iQCV
-AwUQNiiZ2JrNPMCpn3XdAQGlgwP+JLlZvNV/fJ2azKIwjibDa4n2LUDxa7ofKboU
-QL+D7FD24zQcmzmkBQm/BL/FSUtxZasJkvdVbU98N3G4h3C4AyErfQOFcrepyGAB
-M88onQ1DbQ6tiUA3gw9gIB+2l1C5R8wBOtlwoRJM4GFvjjtRp+KaQqvN3f+lLMMt
-hKYB70m0KFJvZGVudCBvZiBVbnVzdWFsIFNpemUgPGNvYXJAQXBhY2hlLk9yZz6J
-AJUDBRA2KJmIms08wKmfdd0BAT3yBADEDHAn++77n7bLA/u9QYM2LBQHnXdw5Is8
-YGHpHcNZVDA8CtRTOdub8rhe9qgsid/jEry0hT9Sygfx/ry5ntjmF12ltnxBDPdZ
-uU2DaHaIh/zBUAv0hyaQeAXEYiV9J75GrDkTj5Jrrnd623uyIRoMZPKYb+oqsZ4H
-jIe/w+CDfrQtUm9kZW50IG9mIFVudXN1YWwgU2l6ZSA8Q29hckBSYWxlaWdoLklC
-TS5Db20+iQCVAwUQNiiiaZrNPMCpn3XdAQFnMwP/cX21KHwg6ID7NoGzEKxsfZE/
-dEgRGHFp5T6vznI9fO9WZZ2HmISWjEjri5zAAmXvQG2nWEYFVcF1oWph/ndLgLws
-PfIsZiPXpj1LD7oon5PEXvJlkFfpHDqiG4xOORbbGWBcv1sqkx6djkpfyXLoMD36
-5YazFuKurHpWPwAQRJK0J1JvZGVudCBvZiBVbnVzdWFsIFNpemUgPENvYXJAREVD
-VVMuT3JnPg==
-=kWdi
------END PGP PUBLIC KEY BLOCK-----
-
-Type Bits/KeyID Date User ID
-pub 768/A0BB71C1 1997/06/03 Jim Jagielski <jim@jaguNET.com>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.3
-
-mQBtAzOUkNMAAAEDANZdTUJQPwrFI9526Qf+DEWL8dXgfhWW8o6CzewdcCoHYEpu
-9CiOMD3f9bgo1VozOPceGzCu/9FF2hMLUvVsTAZkzC3rre5TtPo/vOf5HJ+ac9M7
-aqxW+gRu2/90oLtxwQAFEbQfSmltIEphZ2llbHNraSA8amltQGphZ3VORVQuY29t
-PokAdQMFEDOUkNRu2/90oLtxwQEB8iEC/i9Qo55TlT8bRpcqeM3lzNDqzU9cqKRf
-9X8pGJIVE5m2JPm99qPLs8RPeepLChi8ZZ+2hSfb7ldQhvVLgNqQqLpsjGtJjJOU
-C+MrKDeSk2WAicg6Uo0FWCsEHxrssw139A==
-=pwim
------END PGP PUBLIC KEY BLOCK-----
-
-Type Bits KeyID Created Expires Algorithm Use
-sec 1024 0x08C975E5 1999-04-14 ---------- DSS Sign & Encrypt
-sub 2048 0x4CCDB430 1999-04-14 ---------- Diffie-Hellman
-uid Jim Jagielski <jim@apache.org>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: PGPfreeware 5.5.3i
-
-mQGiBDcUl9QRBADl5tF8kOD0uddlnl9qsaG70/hwujGTsSXATnqoLseTsWORoVXf
-oBklokEAGmT2+Cl8XIXZ31Wh+GaJ3CTbEv8Ok1vapOt+ltPgOKzZEB4uP25EbhC2
-LWf+lUoafcd2Xi0KBV4fqXqEEuDGP1TAdZ6k7NVqgpjvbJ5TdqL0LrWOOwCg/0b4
-+/p/avQr+uZRU2rdmYu/b/0D/2LnjcEqUjsslh2e9m0OgAu+gnYAmQH6Dbnp+iKl
-jffWPChwIMFZd/7FnGOzYDzoqnzTFyA4VE5PHWL61V2lpHJWB21K9D6rbEcx0iYB
-AHHxZQEmxSBU6PmGnbF+2P7vC0Jz9gZ5dCbjtGboYxd00/XQlZwCs8jHueTpSfx9
-n7dYBACFpW+v2pSlG0ReiS6Ult3gaGWiw81D0nFVvCp5BlxgQDymyF1MS6FbCj/g
-FGILosMhlsIHTFaC0DD0LSXyN1rm0ykPvi+vULIlKNJwW7fCi+33j1Azx+zfMNeO
-T5vqAfF6cvsZ6qPb9CcYvU4jEKvkovA1U3jMFehqcGkTV5sfvbQeSmltIEphZ2ll
-bHNraSA8amltQGFwYWNoZS5vcmc+iQBLBBARAgALBQI3FJfUBAsDAgEACgkQizpg
-HwjJdeU/8ACg3mtYerA7QN/8Okp2IgGr+ge4yKgAn09RX5UR8DyZ1/Q8OFasE6T6
-Tg2UuQINBDcUl9UQCAD2Qle3CH8IF3KiutapQvMF6PlTETlPtvFuuUs4INoBp1aj
-FOmPQFXz0AfGy0OplK33TGSGSfgMg71l6RfUodNQ+PVZX9x2Uk89PY3bzpnhV5JZ
-zf24rnRPxfx2vIPFRzBhznzJZv8V+bv9kV7HAarTW56NoKVyOtQa8L9GAFgr5fSI
-/VhOSdvNILSd5JEHNmszbDgNRR0PfIizHHxbLY7288kjwEPwpVsYjY67VYy4XTjT
-NP18F1dDox0YbN4zISy1Kv884bEpQBgRjXyEpwpy1obEAxnIByl6ypUM2Zafq9AK
-UJsCRtMIPWakXUGfnHy9iUsiGSa6q6Jew1XpMgs7AAICCACEhzcRGEc3y3/4YNaG
-89FmtIRpFU5zoaZxxDrmUiS1HdhqFykv8ozaTyjfImCuhq8i6DG15oGudxPma7Ey
-sCcA/qmQEBVrXFK2DYTFW3UnPyqiE822plo0d45u1csKzPvGpHYVGC4HOEKCghRy
-/54nH0fsKV3VSlIXAhRG3LIstzAtslrSYELW1Lov53GK+YZpRDJTbLAxjIYB8kEY
-hiQYzHm/cbBeRpjG9BpoBQh54dNOj22CU8HC4KvZSnDcLAzmDyrQFXFfffvJtQ7+
-HH2iIWKMFOjpRHh2ZK6uhJb03Yo/v+admKs1HSEFdV5VJUCkqymhKT0OiWnXmNHq
-QUfliQBGBBgRAgAGBQI3FJfVAAoJEIs6YB8IyXXlME4AniogMeV3YLNf6C1Y2+k8
-F3rt0S/OAKDHF+wfxLDzCxsoQbwesIUAKgb7Hg==
-=mrXV
------END PGP PUBLIC KEY BLOCK-----
-
-Type Bits/KeyID Date User ID
-pub 2048/DD919C31 1996/12/24 sameer@c2.net
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.3ia
-
-mQENAzK/QZIAAAEIALrsEjuGlt6wkHy8fx2wPSkH7paAqJHDCbO1W/GMVs41BsH1
-xpyBi9lOtUXHsDC8Obx/TES4/xVPSsFKPQLa9Q/OsxjXmEPBvQ5PZdOXJ5zmRMI1
-1cfUp2s8w6i+IS68IWRKdPMshGWFGar1YUPM1UpVME7U+uGD3wgdC4DrVJHzS5Eh
-gEDyQ9FPb+8CpsRO3AvUPzsZGG8Iy/9GiLzmaJG34zZ5fv5X7sr89xiWJ21ehk+X
-ePO9kvq+nzfOCCK6a3GZD4g3KJX/Pm3oKeaXeL8WSCCPzpNbtRJk3ofeN7Zm1K0L
-yChPiyui+OO063/WASv52bxUIlmzbX82a92RnDEABRG0DXNhbWVlckBjMi5uZXSJ
-ARUDBRAyv0GTbX82a92RnDEBAfqVB/9GSzADIVqY0faFOLN6+E3qqg3hPRLBvjgC
-5cvTlwT7W64zI+aiSZuN+xAXq+3lnKtmzn45F3hD7gBxRPJbSKsObn2zU4UcqW/o
-qoiYEnO9EhoBomwPUbVy8C00CWvDLfeF4L5r+2oXgilTsCojSaWJX0QoPCwRQao1
-YwZ6CqAA78vdbBNkmA0WrPsVqwd3ijgFapcX671AqiT+pDbvK646I6uGPXJzN3ZU
-vFuDim9D2uNk9CfvPhKGscr4qqP40TnNn5fjSsmrFyFxYsdwo7I4TFpnsEPOw226
-GU+TR7zdwnByP72AxPEBJ/F22LwNyreuph+fRpWCnCf+9gVW9Heh
-=jS5Z
------END PGP PUBLIC KEY BLOCK-----
-
- ===========================
-Rob Hartill <robh@imdb.com>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.2
-
-mQCNAzG6VfMAAAEEAOvtvphFG/D02vGLENBl5OVPgEJgP9E1xhUgKTZnJstv30kD
-h1IqeIBkEAy5bpKapCbvvxukyQErhB0efTi2v5yTAlz5pVjgWM5Sa8CyTXJmXPHH
-EuOfy1DqaiQSmZ6KWX0ygw3gKDZMiNMf06UURLLYtRlGKSYY3WVj2u2UCmS9AAUR
-tB5Sb2JlcnQgSGFydGlsbCA8cm9iaEBpbWRiLmNvbT6JAJUDBRAx5eIAZWPa7ZQK
-ZL0BAU2XBACXfopMzC8kW3KEqq+N9W9fkGNgy//8XqQ77FmfPQPbO4X7Zn3cyO46
-MxvPP+92zSyN3dyj/xWZYoRLwll+ync9d4KUFwKw45DALAvz1CKHMOpQPD7dIWdE
-9poJQrcbKeOqLcGZTu/hY90gWBUZ++9umR8X8lyh/WEgcUolfgYHew==
-=upYh
------END PGP PUBLIC KEY BLOCK-----
-
-Type Bits/KeyID Date User ID
-pub 1024/631B5749 1996/06/21 Randy Terbush <randy@zyzzyva.com>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.3
-
-mQCNAzHLBS8AAAEEANGFXb9o0NPVfVjSLvQh1j3fN6cMeVNA5BGUJ6HZGP/NDxTE
-i8hwejJqakkU4ux/g6Kqckrx3h8WR7OXZZ+R8CsA0bg9Sr42ndEQCUISgArg+lXZ
-gRUniARPPA7tamTSq8v1mnxqy9s26Ht2rAG2D6IiK/7v0JlezKirDeBjG1dJAAUR
-tCFSYW5keSBUZXJidXNoIDxyYW5keUB6eXp6eXZhLmNvbT6JAJUDBRAxywUwqKsN
-4GMbV0kBAegnA/sH63WyfwMFmn3nWe8T/5IXO/QkMYoMGLS1i7IxMY9O8BVvKQM+
-oxEcJdFAG7zPZkpgKzTBxmExz5hMZ9hwJ42XhrslWoP7JVvADJcdthrUAYW9W+jx
-GcDYAW3qW5DpKsQchfvXq9QOBDxP+Kbbe2B8xGEyGUhLkacISFTrIhhQSg==
-=8P8s
------END PGP PUBLIC KEY BLOCK-----
-
-Type Bits/KeyID Date User ID
-pub 1024/49A563D9 1997/02/24 Mark Cox <mark@awe.com>
- Mark Cox <mcox@c2.net>
- Mark Cox <mark@ukweb.com>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.3ia
-
-mQCNAzMRY/IAAAEEAOloTOU0f4w7FDRMM6kA/6XazXxJ/HH8dsmb6E7RuYfVlXsd
-kCwxUBOkyW+AYhkHbYUwnB5qBoFUyLrbLGuwKHW1KnAwgbeZLTH5nqQLpA0RLGVZ
-v3tzImKUdyyxBphZWC4IeEgUbl9cc+piOsEJ8QzF7gnqwWo/Ku6tTP1JpWPZAAUR
-tBdNYXJrIENveCA8bWFya0Bhd2UuY29tPokAlQMFEDQvYTHurUz9SaVj2QEB/hMD
-/ix6pAa+4ZgFQNRAc7fC+I4uGWvXoI8N8wtgiJi//8Kc1vjtvTylLPKVBDsy1ihs
-bVOjD3NUEkH95TNI3QhVeCwJPl2e3GgFl253hj8Jai9snHj75pXjQXq0NxQ/JRSr
-EAqrFM7+yRLPs7zDwsMoc2Ox5emq4joVa3syZUEwW7LxtBZNYXJrIENveCA8bWNv
-eEBjMi5uZXQ+iQCVAwUQNHKlBO6tTP1JpWPZAQEA8QP9HSjVMLohfOVO0tHcLRDB
-eDfnRnBxgTeF7P2u8qB+eOeLqBzHNmE/gROWuZXOpkxeCqT0GG3oXqmSEmVOtDsJ
-K92sKvtTdJOAGq95UQI3t1Ix6iNHkVJfo11RkJyU2iL6XFR1953nS33xKGdbU6v7
-5KVCu3JTe1kDEDOyMVDdRmW0GU1hcmsgQ294IDxtYXJrQHVrd2ViLmNvbT6JAJUD
-BRAzEWPy7q1M/UmlY9kBAfN5A/43SdANs/NZ6ouyxAvKEWSPDnNkHI3rSPynbn7o
-kSrtFeCQ3Vwe0B0fkszBEAZ9zbnx/s/1LKnriUfyzhdZhJfkZfxgDwy6s6smagYW
-smz/LFaeDzG3Ej20VSe6ghseqcPscJL06PUg13LJC4LFlgYcCDEeGl81Nm37fe0x
-IUhlNA==
-=k8vP
------END PGP PUBLIC KEY BLOCK-----
-
-Type Bits/KeyID Date User ID
-pub 1024/2F90A69D 1997/02/24 Paul Sutton <paul@ukweb.com>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.3ia
-
-mQCNAzMRsB0AAAEEAKj2XYYEGcZhT69x4gskQ3xz+KMTLn7gKSqqcyyeinJ0ZjLl
-6AJjb1/68nGsF+IIY+IJS+5smq8do1qpC3UZcmw423Sg8F71GeqDO4HZXOAOieVy
-rpVs6S5TaXlJOcrC7zZCx+iql97+xJFjUGkkS7j/jIkx1AajzMNkSr0vkKadAAUR
-tBxQYXVsIFN1dHRvbiA8cGF1bEB1a3dlYi5jb20+iQCVAwUQMxGwHcNkSr0vkKad
-AQGrigP9F43zbiOigYel+JCMiB0HK/UdqSrf3xWxHIKWKNhQNjhnyeF+jKQwFld6
-7KQYsqZIpHsWLWmSk0AmKQOUIw+DxclDxBL2dT4p+CjgTgIAcbvPpahWkBAw/E+c
-EGTiYbe+Y3sHJhhP+d0TOLmsETG9tpi7gFZ6FfNcWPxFMdxGrf4=
-=0jQW
------END PGP PUBLIC KEY BLOCK-----
-
-Type bits/keyID Date User ID
-pub 1024/BA20321D 1997/06/05 Chuck Murcko <chuck@topsail.org>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.2
-
-mQCNAzOW7moAAAEEAMYZlNOxWCjLR/PosadbG+xsrB2unid2LiYoakTFiDIBaZjx
-bu6hNmVZPYfKOXQcqrCu0EY3uVLP/L89bST5pfIZOzz8GTm33zrETgfzpXYyFdbX
-eZ5vc6aa3+7zmI7h/aU567P9ruB2C/RBLl1A59wmPRRVvjEIAkI4bAO6IDIdAAUR
-tCBDaHVjayBNdXJja28gPGNodWNrQHRvcHNhaWwub3JnPg==
-=vUdL
------END PGP PUBLIC KEY BLOCK-----
-
-Type Bits/KeyID Date User ID
-pub 1024/26BB437D 1997/04/28 Ralf S. Engelschall <rse@engelschall.com>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.3ia
-
-mQCNAzNko/QAAAEEANZ2kpN/oMkz4tqzxvKPZws/XwsD0Y+E5/y7P2DIw4uHS/4N
-syQbgkdrZhPBlXDv68DQioHXWsb904qyr7iZB1LC5ItK9MgqlK+Z2mvPqsGbHM8J
-+oYib8kf2zJ6HvrYrP7NYB0tN9YYum2ICtx+hIi6aKGXdB1ATA5erwYmu0N9AAUR
-tClSYWxmIFMuIEVuZ2Vsc2NoYWxsIDxyc2VAZW5nZWxzY2hhbGwuY29tPokAlQMF
-EDNko/QOXq8GJrtDfQEBKVoD/2K/+4pcwhxok+FkuLwC5Pnuh/1oeOYHiKYwx0Z3
-p09RLvDtNldr6VD+aL9JltxdPTARzZ8M50UqoF9jMr25GifheFYhilww41OVZA3e
-cLXlLgda1+t0vWs3Eg/i2b0arQQDaIq7PeRdjdEDgwnG4xBaqaAqfgxwOXJ+LPWF
-hiXZ
-=K7lL
------END PGP PUBLIC KEY BLOCK-----
-
-Type bits/keyID Date User ID
-pub 1024/45B91DF1 1996/03/02 Doug MacEachern <dougm@osf.org>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.2
-
-mQCNAzE4lesAAAEEAKJYS1vL2iB3owwiZdCxp3JyvSNaC7h1p2jQXcJvY10gqyZm
-VffDwFoSvJM1JdCx3o1mb3JpZ2OTV4SrDDkzcSpTXelgyh7k9O3HB7oG6pHTML9g
-Dq9ZKydShMIvIJos7KuLWoM/eeeejtkv7r/gWsGHAyKbT8fs3r7nlmxFuR3xAAUX
-tB9Eb3VnIE1hY0VhY2hlcm4gPGRvdWdtQG9zZi5vcmc+
-=yaR9
------END PGP PUBLIC KEY BLOCK-----
-
-Type Bits/KeyID Date User ID
-pub 1023/163751F5 1997/08/18 Dean Gaudet <dgaudet@arctic.org>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.3a
-
-mQCNAzP30QgAAAED/1k8hPKsJj8Il/TfhP1JIRGwnXuzfQ/etv+MZJMzeNeKa8OX
-Kw0d4e1S/KdJ+AZwWQp3ZMDoX2ghZ79X4DDDLEAc/Fmy0Gg8t89CP+xJk7b4EHjk
-F7HX69BRJp3On4aRTXRND3WviqEmn5ppzbBkTenF9WWudLRbqrc4NnoWN1H1AAUR
-tCBEZWFuIEdhdWRldCA8ZGdhdWRldEBhcmN0aWMub3JnPokAlQMFEDP30Qm3ODZ6
-FjdR9QEB9VQD/0+zumFj1zzYZ1+bS9Az36gijDUb8rlEVf/lBShx4VEvha8fsRRy
-vkwnmJyupYvGtrSIYAwB0VK+GZPZa7XfZvUCM83AZY9vGpE0LwW2Vcz9kWZdJ0t+
-B7zJElmBUrmj9aW6ICmSNbOBwVo1Y7hg6lPSFFMOOECFpT1WuTXXYpNA
-=KWcF
------END PGP PUBLIC KEY BLOCK-----
-
-
-Type bits/keyID Date User ID
-pub 1024/EE65E321 1998/10/22 Martin Kraemer <martin@apache.org>
-sig BB1D9F6D ct magazine CERTIFICATE <pgpCA@ct.heise.de>
-sig E2449019 Martin Kraemer <Martin.Kraemer@Mch.SNI.De>
-sig EE65E321 Martin Kraemer <martin@apache.org>
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.2
-
-mQCNAzYvawcAAAEEAO/lLOQVYsUS+l7yan+Rzr0ehfWRqlgeNsV4DQ0xTuQewD9K
-5lm7ujRwutxlNaf5dXjE24mlsiRN8KDp+fKwm7Wtqv490xmhzS/6y8ekwB02P4fi
-/JJNX1PbLS0cL6+bz2dFqLDhh03Ovz3G16Y9he5mrJ2PNOWa9Dfj9F/uZeMhAAUR
-tCJNYXJ0aW4gS3JhZW1lciA8bWFydGluQGFwYWNoZS5vcmc+iQCVAwUQNkcAbUS4
-3da7HZ9tAQFUnAP+PrKa3YFKp9XTrANmORex4kOyNpM1adS8zM6bTcHyIkH4WitB
-b2nRbqOdOuSwbh655aSStluIxY66CValeL+6E7MCEqQ/UlzzMVmdbMyWSYwDlkV3
-gQkg3vE6bgFlWlLLr2HnkllY3ISEChDWh8x7fRKLy+8ZBGW89ZXOGkhIb9mJAJUD
-BRA2L2ueKwLDReJEkBkBAbeGBACKM1FCmQC583/IHyw7rDlvnsZKeKvdbbLGSnmJ
-NWOyf4VgkC8OCKmwPnWLOOIK44/JsT2Yonih2r+04FBqYo6SsMgBqOBJqKktHvtx
-bD3VfUUkkV8kZ4ituecWTx0zj1Oa0QiCiv8HHvdsmQB0mj07mWQz1CamXPSwHYn+
-t+fJOIkAlQMFEDYva2c34/Rf7mXjIQEBcNQEAOrt4+o2LwcCiJp3bOF9WZMirpMQ
-QJISqXBnom3r2eB+k1a/Jig1sePSzPxneW9EgWIrWg0EfK+u2kMgvTJynDUux9zL
-4qnECmZT+ESEm+P8rPKeecOfUHgDjQlTUCneOX5p0TbdvJm+TcJVjXjoVrYv6hZg
-InYw+jlvF5e/sdI8
-=03LU
------END PGP PUBLIC KEY BLOCK-----
-
-
-Type Bits/KeyID Date User ID
-pub 1024/EC140B81 1997/04/10 Dirk-Willem van Gulik <dirkx@webweaving.org>
- Dirk-Willem van Gulik <Dirk.vanGulik@jrc.it>
- Dirk-Willem van Gulik <dirkx@webweaving.nl>
- Dirk-Willem van Gulik <dirkx@dds.nl>
- Dirk-Willem van Gulik <dirkx@bigfoot.com>
- Dirk-Willem van Gulik <dirkx@technologist.com>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.3i
-
-mQCNAzNNOsMAAAEEAJmwazRhNJB4mQkvp0rrxLkeOAxR9fGBXgJNa6HHdLv7YHwx
-mwMorHYDCAMypO1yuznNTaMVT1z3cS+yqhOkTVxwNI1mxW6Zts1kOJB9pWuU33sk
-sUuCkLHXMgyvP9cms6gcYgB5g3UP6M/aQ4T017+Gk/7crlH87DGmPZbsFAuBAAUR
-tCxEaXJrLVdpbGxlbSB2YW4gR3VsaWsgPGRpcmt4QHdlYndlYXZpbmcub3JnPokA
-lQMFEDRZ5+0xpj2W7BQLgQEB/KAD/1xniFNLHp+jxIVrEL6HcI06QZUYPvRuarWq
-3aI2gdeXej59Ry96MOo2MU3MsuQ+wW+6gEJAuyCp2jyYfzF/8winNcFWc738s/hX
-fRYCJe4bvtMcnhBV7GAlTgyw00fcrnaJaQ811+QwKnZvXXWb+QuoXC4ddTon25w4
-XHLjtDZHtCxEaXJrLVdpbGxlbSB2YW4gR3VsaWsgPERpcmsudmFuR3VsaWtAanJj
-Lml0PokAlQMFEDNNOsMxpj2W7BQLgQEBzW8EAItAEaeuIzPIVlKOk1LnHlYc4FyW
-aiNJC2+rRmftYu2bIp/JFuXu3xC0U0byyHu0p+Y1pcAnt2YrqmYUfM0d2cx1b4+L
-8RQR4SGKhq9jWKS3icfKoyMnGiD2CeI8/Xx8V6b8Xg0QqsdlS0kz//qGCDWMz0vi
-oxzasVEvFjqAse03tCtEaXJrLVdpbGxlbSB2YW4gR3VsaWsgPGRpcmt4QHdlYndl
-YXZpbmcubmw+iQCVAwUQNFnn1DGmPZbsFAuBAQE0vAP/aOb/rXsE256tpi0+CRp6
-cd9b1oBmw894UK+Cf4DeNHWehPWJog4y0eNFUcAMdLIdubDzc6Kfxw5QyJt2EAXr
-05XuJ2DJdG24S/aPzGq+6VzL7Nq7pylXuhrACTgeesaceEpUd/NeOCOyzNR7i8qM
-zbGFtU7fH1ipfJjN6fXLo5K0JERpcmstV2lsbGVtIHZhbiBHdWxpayA8ZGlya3hA
-ZGRzLm5sPokAlQMFEDRZ58Expj2W7BQLgQEBGRwD/jdUjCJXFcAbjx3Y2pWUkR7C
-hwJTohM2TvhFp80Ffbhh1xT961XGuHL5l41fRAIg9FEHjQKNVfXeisLH68Qh73cF
-5xuNE6c1x1VSqfDLl9fXZ6TA35qt0G599T67jmVai4F/LjHWDI1O6UvPRuZE3O7m
-eRaCfbPLAJ1ztFujtS3btClEaXJrLVdpbGxlbSB2YW4gR3VsaWsgPGRpcmt4QGJp
-Z2Zvb3QuY29tPokAlQMFEDRZ56Qxpj2W7BQLgQEBvOED/1LhhPP5OkeCCEMVnmyZ
-jZexzv6XOH2I5qH0iuozsI987sSK+zfv8O0wEBwjUOQqBuzlvjKImYQ/oqR89egQ
-AinPc4z1b3kgeGyqrmtea6ScmpKufcWUBbhH0qsXF41eU3ArKY4kB9znV+/PacCe
-VrOD8roFaxIDZ2nW9FS0mriOtC5EaXJrLVdpbGxlbSB2YW4gR3VsaWsgPGRpcmt4
-QHRlY2hub2xvZ2lzdC5jb20+iQCVAwUQNFnnjTGmPZbsFAuBAQEaHwP/Q2Rs6MIu
-z8all/xildFOPfRAX73InwBeInr1O4UU4l6yWRvuLkg+m6O8eJSHo21SNZBCu9gM
-FoQsd0jVOitUr8+w2WkypBlJo5wl1nCw/1sLU4AxtBb0jyADvJzxFCeje/FkxEvs
-6Y3eLxpJRBylbg6KFOsmSY46DyGc49B6cZo=
-=xUw/
------END PGP PUBLIC KEY BLOCK-----
-
-Type Bits KeyID Created Expires Algorithm Use
-sec+ 1024 0xF08E012A 1998-02-19 ---------- DSS Sign & Encrypt
-sub 2048 0xD8F8125A 1998-02-19 ---------- Diffie-Hellman
-uid Dean Gaudet <dgaudet@arctic.org>
-uid Dean Gaudet <dgaudet-djg20@arctic.org>
-uid Dean Gaudet <dgaudet@apache.org>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: PGPfreeware 5.0i for non-commercial use
-
-mQGiBDTsCJkRBADJmDUiJL0xUaxg0yw7+VqqFUL6sjWxZeZ7kQZs4dyN3R1ilBUG
-KmOXE6qSfb6Pi0qEmgCz1K7g1KaglMRrpANY4h1CjziEVmTH5s3ocxe77w2uaou1
-gHJERIqQuC4/z0DwFqq61ZVf5dUQTD8OmfOwG4pFs51Si9WS03ueVEFQFwCg/9Z2
-j6UzCLyUABpWeV1v4m0w82kEAK96GyKDcT20TymKJnMKuwya+ZwqrULH3Sdi2Mwi
-1GOH7aomG2fK4D2yxWx5xTiYhmYNnRoopgu/Kv5a4x43tOKS3zeADMnHIw9dMSn9
-4Kba8vfKbZnlOgt9veV+iWZv7N2aS2z7w/i53Y6LAlV1hAIMvGJ3zLfmShZs0LDI
-Ya18A/wNcdJazUk9mLGIoycCYOk5YhWL9sCaCBdmdfDPu++rLnqROSWkmfYkOTt+
-pG9SPnvv3XrX/SEwM8gYfpbZwrFDJFI9W63lc9hdSosFD+8xiRl6h2gKRwWvc1Ry
-xIt3+gUrZxovNxBOv98BoSf/j3lkldU+ZjDGlCplRHSndxlN/bQgRGVhbiBHYXVk
-ZXQgPGRnYXVkZXRAYXJjdGljLm9yZz6JAEsEEBECAAsFAjTsCJkECwMBAgAKCRB9
-bb/R8I4BKqqzAKDc/4H9iOXJxVE0yCEHeTQ2gAHfhgCg7VSq7eNhiJhBgblQav/R
-XOhaHj20JkRlYW4gR2F1ZGV0IDxkZ2F1ZGV0LWRqZzIwQGFyY3RpYy5vcmc+iQBL
-BBARAgALBQI07AjSBAsDAQIACgkQfW2/0fCOASoWOACfb+8OVvy6FCqN2MxdCqp6
-gffNbYgAoOxlTa4NjCUUO9dfLFFYpDfGrRy7tCBEZWFuIEdhdWRldCA8ZGdhdWRl
-dEBhcGFjaGUub3JnPokASwQQEQIACwUCNOwI/gQLAwECAAoJEH1tv9HwjgEqiC8A
-oJDu1HTuGOfChFSJJ31XvV8tnlo5AKCFceck4veIMP8pDC0f5UBGGC3mZLkCDQQ0
-7AiZEAgA9kJXtwh/CBdyorrWqULzBej5UxE5T7bxbrlLOCDaAadWoxTpj0BV89AH
-xstDqZSt90xkhkn4DIO9ZekX1KHTUPj1WV/cdlJPPT2N286Z4VeSWc39uK50T8X8
-dryDxUcwYc58yWb/Ffm7/ZFexwGq01uejaClcjrUGvC/RgBYK+X0iP1YTknbzSC0
-neSRBzZrM2w4DUUdD3yIsxx8Wy2O9vPJI8BD8KVbGI2Ou1WMuF040zT9fBdXQ6Md
-GGzeMyEstSr/POGxKUAYEY18hKcKctaGxAMZyAcpesqVDNmWn6vQClCbAkbTCD1m
-pF1Bn5x8vYlLIhkmuquiXsNV6TILOwACAggAhb3cBmR67H4+9Rj4FeTwJ8kflX6I
-pp2AeXXZiffiPVBv5cGzGn2RkGPAZqbp2AkrCb4TrJH//1GPdR8VmPeEGsm6u0uT
-0M404l/4IW1FFQ4JBpTENPn4NYBHkKBNkPcls/ip0lSjlmLGVQVOtDOaFD7n44xV
-hT4WpptCripg/5kymDmK9c8hv6rPUvNoVrDdWR4//MCvNAZvGq2bZGdFTyd5Tn6D
-AmwbvL/UwgiDnm95qBBfCZtmGkkFaoOePtBevWFaviFZM2pErPRcjY8A/1cZsycj
-JPMFYqBKGDIk76ulDSjU0Q8dqhCEDf0o2oQEg6msjDtetVFEDw9yJe0AGIkAPwMF
-GDTsCJl9bb/R8I4BKhECBKgAoNRtRaRMdYNwajSO7056eKazCGSDAKDShamaRjAe
-ThQ1KefmJKyzfcosZQ==
-=25Cv
------END PGP PUBLIC KEY BLOCK-----
-
-
-Type Bits/KeyID Date User ID
-pub 999/F88341D9 1994/11/08 Lars Eilebrecht <sfx@unix-ag.org>
- Lars Eilebrecht <Lars.Eilebrecht@unix-ag.org>
- Lars `SFX' Eilebrecht <SFX@unix-ag.uni-siegen.de>
- Lars `SFX' Eilebrecht <SFX@appl2.hrz.uni-siegen.de>
- Lars `SFX' Eilebrecht <SFX@appl1.hrz.uni-siegen.de>
-
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: 2.6.3a
-
-mQCKAi6+wOsAAAED53PJgrIYS7iHbZn0ycrnzS03fwvwsDpoAVouoqqBSVNoVXH+
-lL+8HzX/fADvNyk1lYi5kTiYR2meKB1p0qpvj4bQ8ZEmcBemhV0FbESJ4CxIgy6V
-euxOD3v9gauyf1u4lkfyLIsCepuJqpkH+aOviE9VhTcE/D6Pt/L4g0HZAAURtCFM
-YXJzIEVpbGVicmVjaHQgPHNmeEB1bml4LWFnLm9yZz6JAJUDBRA2KRwZms08wKmf
-dd0BASoSA/9ZwyAWilXJNMWsV0KfyUeHZ7CsFA9/KQixLtpSH8ij4raLasr6rurc
-Sckrd+OiQKPQG0/TSXSAEP7suatV6XTTLEFHJbmqchTZXMSapwxFWGLxdG+buCiO
-uVxbpop4ZoKz2xb+GtdeyeDr+//gFL+wbEqlZMXfvwgzBCxcOM/tZYkAkgMFEDPN
-Dtg+j7fy+INB2QEBxpcD527wocmN2jHxCkmImID+YMVF8g1Rij3CEy+oLAZiiNWS
-Rxj2lWTHhsVZXtzF53+AD79rJqrFhZUCx+W6vG46uLMuu3/VpnEfq2QsD0d6zIUv
-SDFIxsy/s4knyvgfMeXczHmb7vjGbGsyP9mqjAyN7MUcqgBBANH4HX9CSRN8tC1M
-YXJzIEVpbGVicmVjaHQgPExhcnMuRWlsZWJyZWNodEB1bml4LWFnLm9yZz6JAJID
-BRAzzQwFPo+38viDQdkBAa31A+dPvsRw1zWvyMDp2aQwqIawIi2wiFl56lYfpkwW
-WjsdftuK0HHe+gek0aJ1vLwJFlrivroEukF1JaK3kS/ob2u/TNIZ4MKWjfhbkJW4
-0Y7gCKCUJPzh6hDw1nYfc4N9XKnwubiRVdW2ig1HVoKZUN9Ad034m30jMHEzqXbO
-4LQxTGFycyBgU0ZYJyBFaWxlYnJlY2h0IDxTRlhAdW5peC1hZy51bmktc2llZ2Vu
-LmRlPokAdQMFEDMR9XVLXCU0Hmjw3QEBftADALeK5boLfjNzxZ7g1VPHw6k6QwSU
-ESwiPJCmGTIT5f941YhHqohgwN5kGR9XDxWCCJAqQfFvbxhiZv0zu4HvQ7FYLVLO
-2zwZrVvOfR259jvGDFpPqRBq1ccxTNXuvf2a44kAlQIFEDD5Hn++gkWXZmzJrQEB
-WVYD/R4XFxImsJxzpaykt8Hl4kpQNWYWHd5ae81QFla/vfIplBqeVWr299pUbO1x
-Bt4EFPi5aya8CGwXs8uRsHKn3u711jfTri1mKpiMBWt149BsUk5lFCnE9gVo5UxY
-cpM2vb1I5DKeo/8/DuYz1FQhXwOxGqBqIr+ggQ1fN7Q0v5qziQEVAwUQMSxVdPCJ
-hGMAVxgRAQFafAf+OZxiZqpgeA3iMZzbOr17v4YjL/J4N3phrcy8ssh0rmTBbNHW
-OfRR0yzGlAXespCSLzBnSQMph2MXc3Al51LK4z487iAQxpu5k/ZKrg5ahZI7X5ok
-viTcRjmXkpbbXp+sMs6J3ZOOjxO1tWytSXW5/3lKwbjzaURlbUbBA9QQSGAYPnsw
-Z+CPKRNuUsk2EI3y4DWVjuabOcCeNy4TLfB9UIY81oXfXOyT+i2FwZ0f1befeZuu
-PICGQIxlEFi3Hd3hDEAgNJ8Hu9C6XACnYieT7dVYtlYH14UTk6/CLKkbWNhd/I5S
-QMPbijKK2zU5U3vPcolA1UalSBckftDQ2iTmmYkAlQMFEDD5QYseKXCPGoSZUQEB
-yFYD/jqPx2u8D1aQzKHvZqS9PUYSsPMTgn10FR/tp2c9Ch60f+BQ96fOUCzmRt94
-Iq1iMZsJ0oTyLLf6wf/Mdb1LhvsGf7rXFATh25OUpPx1qPUWstSToHSn0+Zf8e1B
-0p6PJ96duI6rimoc8NKppOwSmRvqAD3ATCKpMiOSwWe9+mBZiQBVAwUQMPl9Sgk0
-Yuy5gjk9AQEX2AIAlCphj4JI/yvodYIlpC2MPOs+hfTvaMPVhSCZZ0EVfZgTZpLQ
-XQDiUolYBvTHJnjBZyXZozln/df4MBHQgKWwmIkAVQIFEDD5RPk+NMzsOfhZGwEB
-5EoCAINMQWZZn+12r2nFScCScf5TaKpm+Y6MfEsvVg0trveEJ74ibbFDo8ABZ2g6
-FgzfDxAMbxNsUQaMrhh0TaSC9EyJAJUCBRAw+O6OHdm2eHD917EBAfj1A/4/cYEE
-a7jN8+ptmxZKsfZ0xOP2dxsPnicDT4VR16MHN6rkVrto782XSiRx3ZUsd9RjUmfH
-ZA3mHoJIGo6JRFVOeyjg3LEASSSfZr4YFkhutnf0lDlJOeEKhqvIw/dSO7MDwdLx
-hOqAFv9UzAlpOm4GLx9p1N61xDl1dIYEnY9cOIkAlQIFEDD5QnyFat0badac6QEB
-CCMEAKV60AedWZyXWokcwWIbW/PLgNTCh8JL1vijXGnBvT2PuA0L7/rCXPhbb20A
-rrq+P6xbGFxi42iWieeU2T5zN5IlPObT6cPeRWJkxPnaSf8ZD33Y1almcuhhYMUc
-7lkL7yqSo1J8TRVCSxjQ4W0+QDUFIEvrigb5Scd7zYHGOqoSiQBVAgUQMPjN2pva
-UYPwhBsRAQGNhQH/Z6IlBI4hdGb8teelMgY2kf3Iq08NByyygJAI48HqTe0cKIW6
-BPcBkJqMooJtRJTX6Rkt8fRKe/IPGeHGqyW3eIkA7gMFEDDhUR6K3WTWEs11KQEB
-TnkGwQEgJMk8SHR+2iBmOJQ2x+kv4LVmPp8hdaKCBdfvJDmrSpuEgrBWFI9PDpSw
-F7NWLPqESPnWo5dd8YeynzYz3aCiIXAOUB0rG8tujF1dSn/kFUCMqgqvbPOU3sSv
-6tVlECIAh67GTNHn61IIhLM0KG4v9elo0Lk/SpWwRRPJZW/ltQBApjtR+juFOiq6
-86+eE9kKBCImCIthBeE/cf6JfwuS4+1ui+MmkkqrnO8+07bdjbkWTSzTL3l12v/t
-M2p8Fwqps41y+3nIEOzq7Isf4zBjfw2ZKeXbEXq0M0xhcnMgYFNGWCcgRWlsZWJy
-ZWNodCA8U0ZYQGFwcGwyLmhyei51bmktc2llZ2VuLmRlPokAlQIFEDD5Hv6+gkWX
-ZmzJrQEBD9QD/iIIvOUqyKRBWjHgJD7zoskxDQH/YVhJu59zoCEOJGwXFPLlT3ce
-meMCaVLa5XvoDnLYWZ/bfI5nFd9vF9GwwbmP8/x39Z3N2xKfJpD8eH5inu5AwtIs
-kfXjmcZhSfDgv2XpAaFigz3wIBt+XbkPRxJJxfqD5oJ1ys0qNe0U6jjyiQEVAwUQ
-MSxVrvCJhGMAVxgRAQHLVgf/cW6FlzmOeIvJ/3yB7vhSOlpivnY00iKnzzCpWLOa
-saC4NPazhqNIewBa01KSuamIicYkzXk8MeaTq5EaQfJyA+NtdWSm/3/ivKWoO4Ka
-qJbVPnxaDnB2KBH+2mq0BJ4rS4i2jVZuopbtMAHV+lQUHaVH826YaFPa+425A/H+
-Oaqn2EdkL80fpIJsACsudYPDGCKS3zcMjspVK1cXqNRDzIOZ8I/XtyNEJpw1yRGf
-t4jrn4lj9jU4y0v6sFOt6jpuvAmyRN/pebwjYJw1Ye697MMkn0nEafH55Et+XfdB
-OYNm3Sb/J2g8j2JVVhN6JKuFYyM1kvK13Rky3SiLPUzD94kAlQIFEDD5QqqFat0b
-adac6QEB6HsD/RooPR6pFnSisCerTlPhSvDI2gl2HUMFw0CZJ5JKVlj5GFDZp5jl
-0yhgCFCweFuE7RUgMOkvGeEoEPZeyipacsrVIcO26aCQyerLTQd6JTgOuCEeEvkj
-BwiqOrVNSEPM5TWPzQc7Q7IDtKTsCT+xNGtO6Pi2+ArZaodZTtp4tXkCiQBVAgUQ
-MPjOC5vaUYPwhBsRAQHdVAH/eIgCk6fo3/Mvxu7IESdDLM/ozh14yvZz6FvC/VKt
-Sp51goqsV5jI9wKANIjonLeO7GJubjO+lqHvsEVsGQ+wpIkA7gMFEDDhUjOK3WTW
-Es11KQEBgTUGwQGH8Ic7zNaUlRmYm5J8R375iP8CrJ/xILbET69VsR2aDG2MA2z8
-NBBkV1ARrAC2YWa9sO91yCyf3NAI6I1oqtbv/09Im/s0bTu66dWrqRAiuTB3Ou+g
-HJ0fc85gTWcBd9/xS/mNlZb1/ZXjkBaYdl0Bzm72c3+HqZjHzT3nlxVY5HCi15J4
-iDgCuCPzeo1r8QgGmsbP7fD+0Hka7tlXb87WxPZt+nkjGS9xmLrNHw5/vJpcN4+f
-zevzhTQD8IcsUr0QcZUH9jZpm6xWpibPF5z7FzXTorguf+W0M0xhcnMgYFNGWCcg
-RWlsZWJyZWNodCA8U0ZYQGFwcGwxLmhyei51bmktc2llZ2VuLmRlPokAlQIFEDD5
-Htq+gkWXZmzJrQEBjswD/1Nwm7yoV6sj7qTiKaW9S3DQD3LKXtweiDdYF0lp961I
-WkuyBur4aYBNROQK82zFQqKNKfsm+FXu+N6AYQ2zEUJEUkT9RQgmsrfU1q067Zoo
-+dck5T2zuH+/kqmF9t28Gv4jjxVTit6C92NEhciutNO48kK32BT2mgX2w7tds6G4
-iQEVAwUQMSxVvPCJhGMAVxgRAQFUKgf/Y4Djeo18+ZAfr0BKl14P29dKK3p8OLcn
-qXh6juBfTRiWnFJtrQfGH9w3pQvpi2RRuDZTTQzhO4eOq2g5gy9MytU1htLRVpVw
-BnmmjLRWz0WGqr4y4ZULbg3ha5NsfBppdgHKk5Y+BptvIL/37ZBkztkiBXfs0Zbc
-3fZR4bSU1xDOE+HS0BofOxubqfZrCZvAjMCC5NJ4R13H8xnYg6NKQCAqOfeCOVWk
-Gnc/BK7VArMXjC8o/9nQDzY2fRPINPnCb4f/4PunwOrEza6zLxXfgNraQJ19boPb
-/o9DBlvNOWkq9gSmVnTEkqrEMtiXd31KAU/LVCRH/70mx7XZkF5/N4kAVQMFEDD5
-fY4JNGLsuYI5PQEBW0kB/0s9AqawHqJ/0rO9jsMhk3vuHNgwVF4DoKTL5EDIORET
-ccAf4UZVJo+JzmjYxc1f2RkwkMkk/N9afKZmcNSYzteJAFUCBRAw+UUZPjTM7Dn4
-WRsBAah7AgCIWR/HNt+V20bDueCO9mhwGirq5E7TJU+C9xT+3BeZXmyy/AR7tWJd
-KnC6laGDLnMko3CWr/XRKD+rC050nNsriQCVAgUQMPju3R3Ztnhw/dexAQF0awP/
-cXwIBaEAj4D/ShzMna3NQ/EM4aTniAHdVIH4d6Uh2RwDCoYt6HwEP11xfBwI6bDW
-lQhdUgDzGOXmOxKxv/Xti4viHOwO1KqjRtHOyDf4hI/ou2p0bntXMZ5yVv0WakyW
-7kYd7KxTbYd/CTKe8HB+8wkj8h1pb31JJoXzWsgmwXiJAJUCBRAw+ULYhWrdG2nW
-nOkBAQUwA/9AUqFQsXW9kMi5RooITiQbRynunPh2aqadVnuLZoAhxp16c+EQYpc4
-Qi6jLPBVemHdS4PW8vJegF1pJtDZ4VfLNwwkIxj7Y0hU8A4BcHUIfFdOER7SwbW/
-i7QTU8u3vNHfmgIodv19D7rFxEzqqPxMHRpIs8/IOG9L3zc3kV8rnYkAVQIFEDD4
-ziyb2lGD8IQbEQEBg6kCANj9mr20gcYRZ4eDfnuTSkSvtjvKox0EtM+UnAAgihxU
-q5vNCZDEeohZSZBR/p2pktcSu+cdk5bBFHtzkaNTt82JAFUCBRAv0u2cmTVOo2j9
-/00BAdubAgCcmQl3gvdeQuA2zSmqHNrCEXdmjIIltOWc8WFCPJjDt6c2cBdmuwoO
-YknWWGDMKXvTlh6lPgIVx3fhlhobxxFKiQCVAgUQL9M+R0axifvg3qptAQF7tAP7
-B78y93gaojDMC8NwfiNKh7l5cBh0ONA+W1g3O7YLE5W7Z/fOg4H3pOujnqU7H3Ns
-ChmDxtBKQIIiZXpnNg4Nt3F765t8EPrMmjjQJ4a6+8CHfmXmfNSWqPMdjgJW4ykM
-nUasGhgF1Z8flNNkfH5gfW9Gr8UcClgKqa5xvkhC5cyJAFUDBRAv0zvKQwZ3Rx/t
-AzsBAVs0Af91cEjH3oZPIaydSZxPUjF1SE3p93NnY6A3mKZR1vkewG6sRqVa4MO4
-lw8w8AU7ge2rvwupF3weF1Z9DG2bauGmiQCVAgUQL9M4SuXLhgyrRKDJAQH/vQQA
-jGM370MwcIfmtQ9e/0j0nztQwQ18dXMA+dMyNHiGrc+JC71u5zjxwmO7R1Vv7ZSA
-af9PslF/118wS6fFg9BP+LO5T4D44wMJTfiMMv30Q4Sfxn9DX9N3iYzL1PTHmlCO
-fCQQqvC451XbcXECqmqWHEqII8//4w/h9yrl/5F/uXmJAFUCBRAv0lcf/ZhK+bLW
-8KUBAc/rAf9rmJ56O40QVD803+bU1zSiSE1x+FURt+ceAsozqo9taFoRIGXTa8Mp
-swStyALnJKpyDkGEnTfRdARVQtcEzYJniQBVAgUQL9JDvxEZCRz6lM9/AQG2xwH+
-IQAJZEvldNHzeikez18Txy12EnJ9k+za2rjPVnlX7+teIY3VNO1homUgwqjoOHpZ
-kdGgdOdmufOglT3Rqrk5FYkAlQIFEC/Rt+1JSaYsE52Q4QEBzUYEAMonc3UFNjGo
-n8F/omc0PPA3rfH2IS6G31FN6fRarW1Pwk7CWlx3wgHm6gO9xfV5lDjBJ+lVmbmL
-z/1MZhg646eFRbugtBYbOXwE6zmNrKBhchVueVONzwWPIA8BZtR2Lw6CikAOhKgl
-4ndg8PO8UUg8gh0VUKGTPDK0MKR7ZCpGiQBVAgUQL9IXPnmMGAx7t12JAQGpIAH/
-Zrl16ULw3/gl7T11EbnbA9T3LjXuD4TG3IGeEV3z1wbRp227yN12a3PbavEKJj1m
-fWrZaT89Xt1smYBaIwX4aokAlQIFEC8YGepIX6svI9kr4wEBnO0D/1R4HlUM43CU
-jxdinzcijOJxRNe7ieXpp7xNn9SuJotDVeCLDRFSpmF2EFb0KDyoX2bY18xPT9sW
-tIMYv4XigSBwfuR+Sp+J1CLdP+zzmIZbZBc+3G5xM6nipvaKl1DkhSlLqedW4dmg
-1rKgCOXYKHdzHUcaneNE4rkoWlVwG5rhiQCVAgUQLs1+vx4pcI8ahJlRAQHwXAP8
-CKLDWFLJ7Fc3JZ0MnuPxW79M9nRQwL2TI/Vd4lCUSiDOUdEvjU45MLmLgU+4OZNP
-eXaBSLkN4z8PUkxGEEvSeCFE7u04VNq1GJ2aC+fHVFzuWbp0LsezqDSnm6xvBxz4
-0yEaZnkXu3+66kXZV/E4BNIkCaB5V2qXxrBIg0D10iCJAJQCBRAux7auD0cvWzTX
-TcEBATNVA/jU+bTUqnlZdrf6KgCv+hDOs6VO538cExQNsBl7x82Djbp8Q5t21YEV
-8LiFN1imuLYqHXqDEHt7qtroNaBYXgnR24QjI3urel+kYMibZWxGrq382C2apRea
-EDmQ1qtEzP+kXexaawAzKMo8VKWMnXjQYBLZohuUqfciE9A7OQF1iQBFAgUQLr7F
-rZXTi1FmcalVAQFOLQF/WCuTfcsEc7z1WK5BMQltCgnNvuz0himNP2FxPl4g5rq3
-u8i03dqPbuVwfrxSzy+m
-=tg0D
------END PGP PUBLIC KEY BLOCK-----
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 6ac6538b3c..0000000000
--- a/LICENSE
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-
-
diff --git a/Makefile.in b/Makefile.in
deleted file mode 100644
index 7892c08c00..0000000000
--- a/Makefile.in
+++ /dev/null
@@ -1,73 +0,0 @@
-
-DEPTH = .
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-SUBDIRS = ap lib main modules os $(REGEX_DIR)
-
-PROGRAM_NAME = apache
-PROGRAM_SOURCES = modules.c buildmark.c
-PROGRAM_LDADD = $(EXTRA_LDFLAGS) $(PROGRAM_DEPENDENCIES) $(EXTRA_LIBS)
-PROGRAM_DEPENDENCIES = \
- $(BUILTIN_LIBS) \
- $(MPM_LIB) \
- main/libmain.la \
- $(OS_DIR)/libos.la \
- ap/libap.la \
- lib/apr/libapr.a \
- $(REGEX_LIB)
-
-PROGRAMS = $(PROGRAM_NAME)
-targets = $(PROGRAMS)
-phony_targets = buildmark.c
-install_targets = install-conf install-htdocs install-icons install-other \
- install-cgi install-include
-
-include $(topsrcdir)/build/rules.mk
-include $(topsrcdir)/build/program.mk
-
-install-conf:
- @echo Installing configuration files
- @test -d $(sysconfdir) || $(mkinstalldirs) $(sysconfdir)
- @cd $(srcdir)/../conf; \
- for i in mime.types magic; do \
- $(INSTALL_DATA) $$i $(sysconfdir); \
- done; \
- for i in *-dist; do \
- sed -e 's#@@ServerRoot@@#$(prefix)#g' \
- < $$i > $(sysconfdir)/$$i; \
- chmod 0644 $(sysconfdir)/$$i; \
- file=`echo $$i|sed s/-dist//`; \
- if test "$$file" != "$$i" && test ! -f $(sysconfdir)/$$file; then \
- $(INSTALL_DATA) $(sysconfdir)/$$i $(sysconfdir)/$$file; \
- fi; \
- done
-
-install-htdocs:
- @echo Installing HTML documents
- @test -d $(htdocsdir) || $(mkinstalldirs) $(htdocsdir)
- @cp -rp $(srcdir)/../htdocs/* $(htdocsdir)
-
-install-icons:
- @echo Installing icons
- @test -d $(iconsdir) || $(mkinstalldirs) $(iconsdir)
- @cp -rp $(srcdir)/../icons/* $(iconsdir)
-
-install-cgi:
- @echo Installing CGIs
- @test -d $(cgidir) || $(mkinstalldirs) $(cgidir)
- @cp -rp $(srcdir)/../cgi-bin/* $(cgidir)
-
-install-other:
- @test -d $(logdir) || $(mkinstalldirs) $(logdir)
-
-install-include:
- @echo Installing header files
- @test -d $(includedir) || $(mkinstalldirs) $(includedir)
- @test -d $(includedir)/xml || $(mkinstalldirs) $(includedir)/xml
- @test -d $(includedir)/apr || $(mkinstalldirs) $(includedir)/apr
- @cp include/*.h $(srcdir)/include/*.h $(includedir)
- @cp $(srcdir)/lib/expat-lite/*.h $(includedir)/xml
- @cp lib/apr/include/*.h $(srcdir)/lib/apr/include/*.h $(includedir)/apr
- @chmod 644 $(includedir)/*.h $(includedir)/xml/*.h $(includedir)/apr/*.h
diff --git a/STATUS b/STATUS
deleted file mode 100644
index 1974cf3a6f..0000000000
--- a/STATUS
+++ /dev/null
@@ -1,181 +0,0 @@
-Apache 2.0 STATUS:
-Last modified at [$Date: 2000/02/16 18:29:20 $]
-
-Release:
-
- Vague plan, assuming more features aren't demanded for the 2.0 release
- 2.0a1/b1: January 2000
- 2.0 : later in 2000
-
-RELEASE SHOWSTOPPERS:
- * Reliable piped logs look broken everywhere. Each MPM includes essentially
- identical code to ap_register_other_child(), etc. Most of this code can
- be moved out of the MPMs and into some common file (http_core.c?).
-
- * DSO hooks registered during the preflight call to ap_read_config
- are not 'unregistered' during the preflight clean-up. Thus, when
- Apache comes up, the hook tables contain two entries for each DSO hook,
- one of which is bogus, leftover from the preflight.
-
- * Pipes to CGI scripts are not being timed out
- Status: code has been added to APR to support timing out pipes.
- This needs to be used in Apache now.
-
- * Put back resource limit code
-
- * Port mod_rewrite
- Status: Paul Reder <rederpj@raleigh.ibm.com> is working on this.
-
- * suEXEC doesn't work
- Status: Manoj has posted an patch to fix this.
- <19991103003605.A20612@samosa.mindspring.com>
-
- * Win32: Fix Win9* specific code in the winnt MPM
- Status:
-
- * Win32: Test access logging with multiple threads. Will the
- native file I/O calls serialize automagically like the
- CRT calls or do we need to add region locking each time
- we access the logs?
- Status:
-
- * Win32: Smoke test all ported modules to make sure they work
- correctly under Windows.
- Status:
-
- * Current 2.0 code is not tested on many Unix platforms. Make 2.0
- work on most, if not all the systems 1.3 did
- Status: Autoconf and APR will get us most of the way there.
-
- * The module API is a weird combination of the old table and the new
- hook system. Switch completely to the new hook system
- Status: Ben Laurie is working on this.
-
- * Modules. Which modules do not work yet, can we get a list?
-
- * We need a thread-safe resolver, at least on Unix.
- Status: The best known candidate would be something from BIND
- (v8 or v9?) The only other option would be to mutex all the
- resolver calls,
-
-RELEASE NON-SHOWSTOPPERS BUT WOULD BE REAL NICE TO WRAP THESE UP:
-
- * Win32: Enable the winnt MPM to use the new scoreboard API
-
- * Win32: Non-blocking CGI pipes
-
- * Win32: Graceful restart of a service is broken (code does shutdown then start)
-
- * Dynamically loadable MPMs
- Enable users of the binary distributions of Apache to be able to
- dynamically load the MPM.
-
- * Platforms that do not support fork (primarily Win32 and AS/400)
- Consider introducing HAVE_FORK feature macro. Architect start-up code
- that avoids initializing all the modules in the parent process on
- platforms that do not support fork.
-
- * Clean the code. There are a lot of places we used APR but didn't
- remove the hacks that were required for the cross-platform code in
- 1.3. We need to make the code look like APR was supposed to be there.
-
- * Go throught the Bug DB and research the bugs marked "suspended". People
- were told these would be considered for inclusion in Apache 2.0, it
- would be nice to actually do so.
-
- * Win32: Migrate the MPM over to use APR thread/process calls. This
- would eliminate some code in the Win32 branch that essentially
- duplicates what is in APR.
- Status: Bill <stoddard@raleigh.ibm.com> is working on this.
-
- * Move I/O layering into APR.
-
- * There are still a number of places in the code where we are
- loosing error status (i.e. throwing away the error returned by a
- system call and replacing it with a generic error code)
-
- * Win32: Implement reliable piped logs on Windows
- Status: Bill <stoddard@raleigh.ibm.com> has prototype code (not
- reliable) in 1.3. Should be much cleaner with APR in 2.0.
-
- * Switch to autoconf, et al. for configuration.
- Status: Manoj has placed an initial version into the 2.0
- repository. Todos include:
-
- - "make install" should work
- - a tool to simplfy third-party module building should be
- written. Something like apxs
- - Add a lot more checks to satisfy the various platforms, e.g.
- for threading
-
- * Use APR to get rid of more platform dependancies.
- Status: Ryan Bloom <rbb@raleigh.ibm.com> is working on this.
-
- * The connection status table is not very efficient. Also, very few stats
- are exported to the connection status table (easy to fix), and mod_status
- is ugly.
-
-Other bugs that need fixing:
-
- * MaxRequestsPerChild measures connections, not requests.
- Until someone has a better way, we'll probably just rename it
- "MaxConnectionsPerChild".
-
- * Regex containers don't work in an intutive way
- Status: No one has come up with an efficient way to fix this
- behavior. Dean has suggested getting rid of regex containers
- completely.
-
- * SIGSEGV on Linux (glibc 2.1.2) isn't caught properly by a
- sigwaiting thread. We need to work around this, perhaps unless
- there is hope soon for a fixed glibc.
-
-Other features that need writing:
-
- * Finish infrastructure in core for async MPMs
- Status: ?
-
- * TODO in source -- just do an egrep on "TODO" and see what's there
-
- * Work on other MPMs. Possible MPMs discussed or in progress include:
-
- - Dean Gaudet's async MPM
- Status: dean is unlikely to begin work on this any time soon...
- has lots of ideas he'll share with folks willing to begin
- tackling the issues. this is apache 2.1 material.
-
- - Zach Brown's <zab@zabbo.net> Linux siginfo MPM
- Status: ?
-
-Documentation that needs writing:
-
- * The concept of MPMs, especially if we ship more than one MPM for a
- given platform
-
- * New directives in the various MPMs
-
- * API documentation
- Status: Ben Laurie has written some hooks documentation
- (apache-2.0/htdocs/hooks.html)
-
- * Changes since 1.3.9 can be more easily seen in the commitlog file
- dev.apache.org:/home/cvs/CVSROOT/commitlogs/apache-2.0
- which includes some of Roy's comments when the changes were
- committed in rough change-sets by purpose. Note that the commitlog
- does not show the contents of new files until later.
-
-Available Patches:
-
- * Mike Abbott's <mja@trudge.engr.sgi.com> patches to improve
- performance
- Status: These were written for 1.3, and are awaiting a port to
- 2.0
-
-Open issues:
-
- * What do we do about mod_proxy?
-
- * Which MPMs will be included with Apache 2.0?
-
- * Is conf/highperformance.conf-dist obsolete? It looks obsolete.
-
diff --git a/acinclude.m4 b/acinclude.m4
deleted file mode 100644
index c664aa305d..0000000000
--- a/acinclude.m4
+++ /dev/null
@@ -1,351 +0,0 @@
-
-AC_DEFUN(APACHE_PASSTHRU,[
- unset ac_cv_pass_$1
- AC_CACHE_VAL(ac_cv_pass_$1, [ac_cv_pass_$1=$$1])
-])
-
-dnl APACHE_SUBST(VARIABLE)
-dnl Makes VARIABLE available in generated files
-dnl (do not use @variable@ in Makefiles, but $(variable))
-AC_DEFUN(APACHE_SUBST,[
- APACHE_VAR_SUBST="$APACHE_VAR_SUBST $1"
- AC_SUBST($1)
-])
-
-dnl APACHE_FAST_OUTPUT(FILENAME)
-dnl Perform substitutions on FILENAME (Makefiles only)
-AC_DEFUN(APACHE_FAST_OUTPUT,[
- APACHE_FAST_OUTPUT_FILES="$APACHE_FAST_OUTPUT_FILES $1"
-])
-
-dnl APACHE_MKDIR_P_CHECK
-dnl checks whether mkdir -p works
-AC_DEFUN(APACHE_MKDIR_P_CHECK,[
- AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
- test -d conftestdir && rm -rf conftestdir
- mkdir -p conftestdir/somedir >/dev/null 2>&1
- if test -d conftestdir/somedir; then
- ac_cv_mkdir_p=yes
- else
- ac_cv_mkdir_p=no
- fi
- rm -rf conftestdir
- ])
-])
-
-dnl APACHE_FAST_GENERATE
-dnl Creates Makefiles and config_vars.mk
-AC_DEFUN(APACHE_FAST_GENERATE,[
- APACHE_SUBST(abs_srcdir)
- APACHE_SUBST(bindir)
- APACHE_SUBST(cgidir)
- APACHE_SUBST(logdir)
- APACHE_SUBST(exec_prefix)
- APACHE_SUBST(libexecdir)
- APACHE_SUBST(htdocsdir)
- APACHE_SUBST(includedir)
- APACHE_SUBST(iconsdir)
- APACHE_SUBST(sysconfdir)
- APACHE_SUBST(prefix)
- APACHE_SUBST(CC)
- APACHE_SUBST(CFLAGS)
- APACHE_SUBST(CPPFLAGS)
- APACHE_SUBST(LTFLAGS)
- APACHE_SUBST(LDFLAGS)
- APACHE_SUBST(DEFS)
- APACHE_SUBST(LIBTOOL)
- APACHE_SUBST(SHELL)
- APACHE_SUBST(MODULE_DIRS)
-
- abs_srcdir="`(cd $srcdir && pwd)`"
-
- APACHE_MKDIR_P_CHECK
- echo creating config_vars.mk
- > config_vars.mk
- for i in $APACHE_VAR_SUBST; do
- eval echo "$i = \$$i" >> config_vars.mk
- done
- $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $APACHE_FAST_OUTPUT_FILES
-])
-
-AC_DEFUN(APACHE_LIBTOOL_SILENT,[
- LIBTOOL='$(SHELL) $(top_builddir)/libtool --silent'
-])
-
-
-dnl ## APACHE_OUTPUT(file)
-dnl ## adds "file" to the list of files generated by AC_OUTPUT
-dnl ## This macro can be used several times.
-AC_DEFUN(APACHE_OUTPUT, [
- APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
-])
-
-dnl
-dnl AC_ADD_LIBRARY(library)
-dnl
-dnl add a library to the link line
-dnl
-AC_DEFUN(AC_ADD_LIBRARY,[
- APACHE_ONCE(LIBRARY, $1, [
- EXTRA_LIBS="$EXTRA_LIBS -l$1"
- ])
-])
-
-dnl
-dnl AC_CHECK_DEFINE(macro, headerfile)
-dnl
-dnl checks for the macro in the header file
-dnl
-AC_DEFUN(AC_CHECK_DEFINE,[
- AC_CACHE_CHECK(for $1 in $2, ac_cv_define_$1,
- AC_EGREP_CPP([YES_IS_DEFINED], [
-#include <$2>
-#ifdef $1
-YES_IS_DEFINED
-#endif
- ], ac_cv_define_$1=yes, ac_cv_define_$1=no))
- if test "$ac_cv_define_$1" = "yes" ; then
- AC_DEFINE(HAVE_$1,,
- [Define if the macro "$1" is defined on this system])
- fi
-])
-
-dnl
-dnl AC_TYPE_RLIM_T
-dnl
-dnl If rlim_t is not defined, define it to int
-dnl
-AC_DEFUN(AC_TYPE_RLIM_T, [
- AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
- AC_TRY_COMPILE([#include <sys/resource.h>], [rlim_t spoon;], [
- ac_cv_type_rlim_t=yes
- ],[ac_cv_type_rlim_t=no
- ])
- ])
- if test "$ac_ac_type_rlim_t" = "no" ; then
- AC_DEFINE(rlim_t, int,
- [Define to 'int' if <sys/resource.h> doesn't define it for us])
- fi
-])
-
-dnl
-dnl APACHE_ONCE(namespace, variable, code)
-dnl
-dnl execute code, if variable is not set in namespace
-dnl
-AC_DEFUN(APACHE_ONCE,[
- unique=`echo $ac_n "$2$ac_c" | tr -cd a-zA-Z0-9`
- cmd="echo $ac_n \"\$$1$unique$ac_c\""
- if test -n "$unique" && test "`eval $cmd`" = "" ; then
- eval "$1$unique=set"
- $3
- fi
-])
-
-sinclude(lib/apr/threads.m4)
-
-dnl
-dnl APACHE_INADDR_NONE
-dnl
-dnl checks for missing INADDR_NONE macro
-dnl
-AC_DEFUN(APACHE_INADDR_NONE,[
- AC_CACHE_CHECK(whether system defines INADDR_NONE, ac_cv_inaddr_none,[
- AC_TRY_COMPILE([
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-],[
-unsigned long foo = INADDR_NONE;
-],[
- ac_cv_inaddr_none=yes
-],[
- ac_cv_inaddr_none=no
-])])
- if test "$ac_cv_inaddr_none" = "no"; then
- AC_DEFINE(INADDR_NONE, ((unsigned int) 0xffffffff), [ ])
- fi
-])
-
-AC_DEFUN(APACHE_CHECK_SHM_RW,[
- AC_CACHE_CHECK([whether system defines SHM_R,SHM_W],ac_cv_shm_rw,[
- AC_TRY_COMPILE([
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-],[
- int x = SHM_R | SHM_W;
-],[
- ac_cv_shm_rw=yes
-],[
- ac_cv_shm_rw=no
-])])
- if test "$ac_cv_shm_rw" = "no"; then
- AC_DEFINE(SHM_R, 0x400, [ ])
- AC_DEFINE(SHM_W, 0x200, [ ])
- fi
-])
-
-
-dnl APACHE_MODPATH_INIT(modpath)
-AC_DEFUN(APACHE_MODPATH_INIT,[
- modpath_current=modules/$1
- modpath_static=
- modpath_shared=
- test -d $1 || $srcdir/helpers/mkdir.sh $modpath_current
- > $modpath_current/modules.mk
- MODULE_DIRS="$MODULE_DIRS $1"
-])dnl
-dnl
-AC_DEFUN(APACHE_MODPATH_FINISH,[
- echo "static = $modpath_static" >> $modpath_current/modules.mk
- echo "shared = $modpath_shared" >> $modpath_current/modules.mk
- APACHE_FAST_OUTPUT($modpath_current/Makefile)
-])dnl
-dnl
-dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
-AC_DEFUN(APACHE_MODPATH_ADD,[
- if test -z "$3"; then
- objects="mod_$1.lo"
- else
- objects="$3"
- fi
-
- if test -z "$module_standalone"; then
- if test -z "$2"; then
- libname="libapachemod_$1.la"
- BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
- modpath_static="$modpath_static $libname"
- cat >>$modpath_current/modules.mk<<EOF
-$libname: $objects
- \$(LINK) $objects
-EOF
- else
- apache_need_shared=yes
- libname="mod_$1.la"
- shobjects=`echo $objects | sed 's/\.lo/.slo/'`
- modpath_shared="$modpath_shared $libname"
- cat >>$modpath_current/modules.mk<<EOF
-$libname: $shobjects
- \$(SHLINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
-EOF
- fi
- fi
-])dnl
-dnl
-dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
-AC_DEFUN(APACHE_MODULE,[
- AC_MSG_CHECKING(whether to enable mod_$1)
- AC_ARG_ENABLE(translit($1,_,-),[ --]ifelse($5,yes,disable,enable)[-]translit($1,_,-),,enable_$1=ifelse($5,,no,$5))
- AC_MSG_RESULT($enable_$1)
- if test "$enable_$1" != "no"; then
- case "$enable_$1" in
- shared*)
- enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
- sharedobjs=yes
- shared=yes;;
- *)
- MODLIST="$MODLIST ifelse($4,,$1,$4)"
- shared="";;
- esac
- ifelse($6,,:,$6)
- APACHE_MODPATH_ADD($1, $shared, $3)
- fi
-])dnl
-dnl
-dnl APACHE_LAYOUT(configlayout, layoutname)
-AC_DEFUN(APACHE_LAYOUT,[
- pldconf=config.pld
- changequote({,})
- sed -e "1,/[ ]*<[lL]ayout[ ]*$2[ ]*>[ ]*/d" \
- -e '/[ ]*<\/Layout>[ ]*/,$d' \
- -e "s/^[ ]*//g" \
- -e "s/:[ ]*/=\'/g" \
- -e "s/[ ]*$/'/g" \
- $1 > $pldconf
- changequote([,])
- layout_name=$name
- . $pldconf
- rm $pldconf
- for var in prefix exec_prefix bindir sbindir libexecdir mandir \
- sysconfdir datadir iconsdir htdocsdir cgidir includedir \
- localstatedir runtimedir logfiledir proxycachedir; do
- eval "val=\"\$$var\""
- case $val in
- *+)
- val=`echo $val | sed -e 's;\+$;;'`
- eval "$var=\"\$val\""
- autosuffix=yes
- ;;
- *)
- autosuffix=no
- ;;
- esac
- val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
- if test "$autosuffix" = "yes"; then
- if echo $val | grep apache >/dev/null; then
- addtarget=no
- else
- addtarget=yes
- fi
- if test "$addtarget" = "yes"; then
- val="$val/apache"
- fi
- fi
- eval "$var=\"$val\""
- done
-])dnl
-dnl
-dnl APACHE_ENABLE_LAYOUT
-dnl
-AC_DEFUN(APACHE_ENABLE_LAYOUT,[
-AC_ARG_ENABLE(layout,
-[ --enable-layout=LAYOUT],[
- LAYOUT=$enableval
-])
-
-if test -z "$LAYOUT"; then
- htdocsdir='$(prefix)/htdocs'
- iconsdir='$(prefix)/icons'
- cgidir='$(prefix)/cgi-bin'
- logdir='$(prefix)/logs'
- sysconfdir='$(prefix)/conf'
- layout_name=Apache
-else
- APACHE_LAYOUT($srcdir/../config.layout, $LAYOUT)
-fi
-
-AC_MSG_CHECKING(for chosen layout)
-AC_MSG_RESULT($layout_name)
-])dnl
-dnl
-dnl APACHE_ENABLE_SHARED
-dnl
-AC_DEFUN(APACHE_ENABLE_SHARED,[
-AC_ARG_ENABLE(shared,
-[ --enable-shared=MODULE-LIST],[
- for i in $enableval; do
- eval "enable_$i=shared"
- done
-])
-])dnl
-dnl
-dnl APACHE_ENABLE_MODULES
-dnl
-AC_DEFUN(APACHE_ENABLE_MODULES,[
-AC_ARG_ENABLE(modules,
-[ --enable-modules=MODULE-LIST],[
- for i in $enableval; do
- eval "enable_$i=yes"
- done
-])
-])dnl
diff --git a/build/MakeEtags b/build/MakeEtags
deleted file mode 100755
index 25f6bdab17..0000000000
--- a/build/MakeEtags
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/sh
-
-# This file illustrates how to generate a useful TAGS file via etags
-# for emacs. This should be invoked from the src directory i.e.:
-# > helpers/MakeEtags
-# and will create a TAGS file in the src directory.
-
-# This script falls under the Apache License.
-# See http://www.apache.org/docs/LICENSE
-
-# Once you have created src/TAGS in emacs you'll need to setup
-# tag-table-alist with an entry to assure it finds the single src/TAGS
-# file from the many source directories. Something along these lines:
-# (setq tag-table-alist
-# '(("/home/me/work/apache-1.3/src/"
-# . "/home/me/work/apache-1.3/src/")
-# ))
-
-# This requires a special version of etags, i.e. the
-# one called "Exuberant ctags" available at:
-# http://fly.hiwaay.net/~darren/ctags/
-# Once that is setup you'll need to point to the
-# executable here:
-
-etags=~/local/bin/etags
-
-# Exuberant etags is necessary since it can ignore some defined symbols
-# that obscure the function signatures.
-
-ignore=API_EXPORT,API_EXPORT_NONSTD,__declspec
-
-# Create an etags file at the root of the source
-# tree, then create symbol links to it from each
-# directory in the source tree. By passing etags
-# absolute pathnames we get a tag file that is
-# NOT portable when we move the directory tree.
-
-find . -name '*.[ch]' -print | $etags -I "$ignore" -L -
-
diff --git a/build/PrintPath b/build/PrintPath
deleted file mode 100755
index 908d274008..0000000000
--- a/build/PrintPath
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/bin/sh
-# Look for program[s] somewhere in $PATH.
-#
-# Options:
-# -s
-# Do not print out full pathname. (silent)
-# -pPATHNAME
-# Look in PATHNAME instead of $PATH
-#
-# Usage:
-# PrintPath [-s] [-pPATHNAME] program [program ...]
-#
-# Initially written by Jim Jagielski for the Apache configuration mechanism
-# (with kudos to Kernighan/Pike)
-#
-# This script falls under the Apache License.
-# See http://www.apache.org/docs/LICENSE
-
-##
-# Some "constants"
-##
-pathname=$PATH
-echo="yes"
-
-##
-# Find out what OS we are running for later on
-##
-os=`(uname) 2>/dev/null`
-
-##
-# Parse command line
-##
-for args in $*
-do
- case $args in
- -s ) echo="no" ;;
- -p* ) pathname="`echo $args | sed 's/^..//'`" ;;
- * ) programs="$programs $args" ;;
- esac
-done
-
-##
-# Now we make the adjustments required for OS/2 and everyone
-# else :)
-#
-# First of all, all OS/2 programs have the '.exe' extension.
-# Next, we adjust PATH (or what was given to us as PATH) to
-# be whitespace seperated directories.
-# Finally, we try to determine the best flag to use for
-# test/[] to look for an executable file. OS/2 just has '-r'
-# but with other OSs, we do some funny stuff to check to see
-# if test/[] knows about -x, which is the prefered flag.
-##
-
-if [ "x$os" = "xOS/2" ]
-then
- ext=".exe"
- pathname=`echo -E $pathname |
- sed 's/^;/.;/
- s/;;/;.;/g
- s/;$/;./
- s/;/ /g
- s/\\\\/\\//g' `
- test_exec_flag="-r"
-else
- ext="" # No default extensions
- pathname=`echo $pathname |
- sed 's/^:/.:/
- s/::/:.:/g
- s/:$/:./
- s/:/ /g' `
- # Here is how we test to see if test/[] can handle -x
- testfile="pp.t.$$"
-
- cat > $testfile <<ENDTEST
-#!/bin/sh
-if [ -x / ] || [ -x /bin ] || [ -x /bin/ls ]; then
- exit 0
-fi
-exit 1
-ENDTEST
-
- if `/bin/sh $testfile 2>/dev/null`; then
- test_exec_flag="-x"
- else
- test_exec_flag="-r"
- fi
- rm -f $testfile
-fi
-
-for program in $programs
-do
- for path in $pathname
- do
- if [ $test_exec_flag $path/${program}${ext} ] && \
- [ ! -d $path/${program}${ext} ]; then
- if [ "x$echo" = "xyes" ]; then
- echo $path/${program}${ext}
- fi
- exit 0
- fi
- done
-done
-exit 1
-
diff --git a/build/build-modules-c.awk b/build/build-modules-c.awk
deleted file mode 100644
index 15ff82ccfb..0000000000
--- a/build/build-modules-c.awk
+++ /dev/null
@@ -1,56 +0,0 @@
-BEGIN {
- RS = " "
- modules[n++] = "core"
- pmodules[pn++] = "core"
-}
-{
- modules[n] = $1;
- pmodules[pn] = $1;
- gsub("\n","",modules[n]);
- gsub("\n","",pmodules[pn]);
- ++n;
- ++pn;
-}
-END {
- print "/*"
- print " * modules.c --- automatically generated by Apache"
- print " * configuration script. DO NOT HAND EDIT!!!!!"
- print " */"
- print ""
- print "#include \"ap_config.h\""
- print "#include \"httpd.h\""
- print "#include \"http_config.h\""
- print ""
- for (i = 0; i < pn; ++i) {
- printf ("extern module %s_module;\n", pmodules[i])
- }
- print ""
- print "/*"
- print " * Modules which implicitly form the"
- print " * list of activated modules on startup,"
- print " * i.e. these are the modules which are"
- print " * initially linked into the Apache processing"
- print " * [extendable under run-time via AddModule]"
- print " */"
- print "module *ap_prelinked_modules[] = {"
- for (i = 0; i < n; ++i) {
- printf " &%s_module,\n", modules[i]
- }
- print " NULL"
- print "};"
- print ""
- print "/*"
- print " * Modules which initially form the"
- print " * list of available modules on startup,"
- print " * i.e. these are the modules which are"
- print " * initially loaded into the Apache process"
- print " * [extendable under run-time via LoadModule]"
- print " */"
- print "module *ap_preloaded_modules[] = {"
- for (i = 0; i < pn; ++i) {
- printf " &%s_module,\n", pmodules[i]
- }
- print " NULL"
- print "};"
- print ""
-}
diff --git a/build/build.mk b/build/build.mk
deleted file mode 100644
index b4e8ee363b..0000000000
--- a/build/build.mk
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright (c) 1999, 2000 Sascha Schumann. 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.
-#
-# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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 SASCHA SCHUMANN 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.
-#
-##############################################################################
-# $Id: build.mk,v 1.4 2000/02/07 17:16:57 dreid Exp $
-#
-# Makefile to generate build tools
-#
-
-STAMP = buildmk.stamp
-
-all: $(STAMP) generated_lists
- @$(MAKE) AMFLAGS=$(AMFLAGS) -s -f build/build2.mk
-
-generated_lists:
- @echo config_m4_files = `find . -name config.m4` > $@
- @n=`helpers/PrintPath libtool`; echo libtool_prefix = `dirname $$n`/.. >> $@
-
-$(STAMP): build/buildcheck.sh
- @build/buildcheck.sh && touch $(STAMP)
-
-snapshot:
- distname='$(DISTNAME)'; \
- if test -z "$$distname"; then \
- distname='apache2-snapshot'; \
- fi; \
- cd ..; \
- myname=`basename \`pwd\`` ; \
- cd .. && cp -rp $$myname $$distname; \
- cd $$distname/src; \
- find . -type l -exec rm {} \; ; \
- $(MAKE) AMFLAGS=--copy -f build/build.mk; \
- cd ../..; \
- tar cf $$distname.tar $$distname; \
- rm -rf $$distname $$distname.tar.*; \
- bzip2 -9 $$distname.tar; \
- bzip2 -t $$distname.tar.bz2
-
-cvsclean:
- @for i in `find . -name .cvsignore`; do \
- (cd `dirname $$i` 2>/dev/null && rm -rf `cat .cvsignore` *.o *.a || true); \
- done
- @rm -f $(SUBDIRS) 2>/dev/null || true
-
-.PHONY: generated_lists snapshot cvsclean
diff --git a/build/build2.mk b/build/build2.mk
deleted file mode 100644
index 87fae8ca4c..0000000000
--- a/build/build2.mk
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright (c) 1999, 2000 Sascha Schumann. 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.
-#
-# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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 SASCHA SCHUMANN 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.
-#
-##############################################################################
-# $Id: build2.mk,v 1.4 2000/01/16 20:00:48 sascha Exp $
-
-include generated_lists
-
-TOUCH_FILES = mkinstalldirs install-sh missing
-
-LT_TARGETS = ltconfig ltmain.sh config.guess config.sub
-
-config_h_in = include/ap_config_auto.h.in
-apr_config_h_in = lib/apr/include/apr_config.h.in
-apr_configure = lib/apr/configure
-
-APACHE_TARGETS = $(TOUCH_FILES) $(LT_TARGETS) configure $(config_h_in)
-
-APR_TARGETS = $(apr_configure) $(apr_config_h_in)
-
-targets = .deps aclocal.m4 $(APACHE_TARGETS) $(APR_TARGETS)
-
-all: $(targets)
-
-.deps:
- touch $@
-
-libtool_m4 = $(libtool_prefix)/share/aclocal/libtool.m4
-
-aclocal.m4: acinclude.m4 $(libtool_m4)
- @echo rebuilding $@
- @cat acinclude.m4 $(libtool_m4) > $@
-
-$(LT_TARGETS):
- libtoolize $(AMFLAGS) --force
-
-$(config_h_in): configure
-# explicitly remove target since autoheader does not seem to work
-# correctly otherwise (timestamps are not updated)
- @echo rebuilding $@
- @rm -f $@
- autoheader
-
-$(TOUCH_FILES):
- touch $(TOUCH_FILES)
-
-configure: aclocal.m4 configure.in $(config_m4_files)
- @echo rebuilding $@
- rm -f config.cache
- autoconf
-
-$(apr_config_h_in): $(apr_configure) lib/apr/acconfig.h
- @echo rebuilding $@
- @rm -f $@
- (cd lib/apr && autoheader)
-
-$(apr_configure): lib/apr/aclocal.m4 lib/apr/configure.in lib/apr/threads.m4
- @echo rebuilding $@
- (cd lib/apr && autoconf)
diff --git a/build/buildcheck.sh b/build/buildcheck.sh
deleted file mode 100755
index 091a17be33..0000000000
--- a/build/buildcheck.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#! /bin/sh
-
-echo "buildconf: checking installation..."
-
-# autoconf 2.13 or newer
-ac_version=`autoconf --version 2>/dev/null|head -1|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
-if test -z "$ac_version"; then
-echo "buildconf: autoconf not found."
-echo " You need autoconf version 2.13 or newer installed"
-echo " to build Apache from CVS."
-exit 1
-fi
-IFS=.; set $ac_version; IFS=' '
-if test "$1" = "2" -a "$2" -lt "13" || test "$1" -lt "2"; then
-echo "buildconf: autoconf version $ac_version found."
-echo " You need autoconf version 2.13 or newer installed"
-echo " to build Apache from CVS."
-exit 1
-else
-echo "buildconf: autoconf version $ac_version (ok)"
-fi
-
-# libtool 1.3.3 or newer
-lt_pversion=`libtool --version 2>/dev/null|sed -e 's/^[^0-9]*//' -e 's/[- ].*//'`
-if test "$lt_pversion" = ""; then
-echo "buildconf: libtool not found."
-echo " You need libtool version 1.3 or newer installed"
-echo " to build Apache from CVS."
-exit 1
-fi
-lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'`
-IFS=.; set $lt_version; IFS=' '
-if test "$1" -gt "1" || test "$2" -gt "3" || test "$2" = "3" -a "$3" -ge "3"
-then
-echo "buildconf: libtool version $lt_pversion (ok)"
-else
-echo "buildconf: libtool version $lt_pversion found."
-echo " You need libtool version 1.3.3 or newer installed"
-echo " to build Apache from CVS."
-exit 1
-fi
-
-exit 0
diff --git a/build/config-stubs b/build/config-stubs
deleted file mode 100755
index aff00a57d4..0000000000
--- a/build/config-stubs
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-dir=$1
-for stubdir in `find $dir -type d`; do
- if [ -r $stubdir/config.m4 ]; then
- echo "sinclude($stubdir/config.m4)"
- fi
-done
diff --git a/build/cvsclean b/build/cvsclean
deleted file mode 100755
index e98ec49b76..0000000000
--- a/build/cvsclean
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /bin/sh
-
-${MAKE:-make} -f build/build.mk cvsclean
diff --git a/build/fastgen.sh b/build/fastgen.sh
deleted file mode 100755
index 9a59ab7949..0000000000
--- a/build/fastgen.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#! /bin/sh
-#
-# Copyright (c) 1999, 2000 Sascha Schumann. 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.
-#
-# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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 SASCHA SCHUMANN 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.
-#
-##############################################################################
-# $Id: fastgen.sh,v 1.1 2000/01/11 13:10:58 sascha Exp $
-#
-
-srcdir=$1
-shift
-
-topsrcdir=`(cd $srcdir; pwd)`
-
-mkdir_p=$1
-shift
-
-if test "$mkdir_p" = "yes"; then
- mkdir_p="mkdir -p"
-else
- mkdir_p="$topsrcdir/helpers/mkdir.sh"
-fi
-
-base="\$(DEPTH)/$srcdir"
-
-for i in $@ ; do
- echo "creating $i"
- dir=`dirname $i`
- $mkdir_p $dir
- sed \
- -e s#@topsrcdir@#$base# \
- -e s#@srcdir@#$base/$dir# \
- < $topsrcdir/$i.in > $i
-done
diff --git a/build/install.sh b/build/install.sh
deleted file mode 100755
index 9a8821fa29..0000000000
--- a/build/install.sh
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/bin/sh
-##
-## install.sh -- install a program, script or datafile
-##
-## Based on `install-sh' from the X Consortium's X11R5 distribution
-## as of 89/12/18 which is freely available.
-## Cleaned up for Apache's Autoconf-style Interface (APACI)
-## by Ralf S. Engelschall <rse@apache.org>
-##
-#
-# This script falls under the Apache License.
-# See http://www.apache.org/docs/LICENSE
-
-
-#
-# put in absolute paths if you don't have them in your path;
-# or use env. vars.
-#
-mvprog="${MVPROG-mv}"
-cpprog="${CPPROG-cp}"
-chmodprog="${CHMODPROG-chmod}"
-chownprog="${CHOWNPROG-chown}"
-chgrpprog="${CHGRPPROG-chgrp}"
-stripprog="${STRIPPROG-strip}"
-rmprog="${RMPROG-rm}"
-
-#
-# parse argument line
-#
-instcmd="$mvprog"
-chmodcmd=""
-chowncmd=""
-chgrpcmd=""
-stripcmd=""
-rmcmd="$rmprog -f"
-mvcmd="$mvprog"
-ext=""
-src=""
-dst=""
-while [ "x$1" != "x" ]; do
- case $1 in
- -c) instcmd="$cpprog"
- shift; continue
- ;;
- -m) chmodcmd="$chmodprog $2"
- shift; shift; continue
- ;;
- -o) chowncmd="$chownprog $2"
- shift; shift; continue
- ;;
- -g) chgrpcmd="$chgrpprog $2"
- shift; shift; continue
- ;;
- -s) stripcmd="$stripprog"
- shift; continue
- ;;
- -S) stripcmd="$stripprog $2"
- shift; shift; continue
- ;;
- -e) ext="$2"
- shift; shift; continue
- ;;
- *) if [ "x$src" = "x" ]; then
- src=$1
- else
- dst=$1
- fi
- shift; continue
- ;;
- esac
-done
-if [ "x$src" = "x" ]; then
- echo "install.sh: no input file specified"
- exit 1
-fi
-if [ "x$dst" = "x" ]; then
- echo "install.sh: no destination specified"
- exit 1
-fi
-
-#
-# If destination is a directory, append the input filename; if
-# your system does not like double slashes in filenames, you may
-# need to add some logic
-#
-if [ -d $dst ]; then
- dst="$dst/`basename $src`"
-fi
-
-# Add a possible extension (such as ".exe") to src and dst
-src="$src$ext"
-dst="$dst$ext"
-
-# Make a temp file name in the proper directory.
-dstdir=`dirname $dst`
-dsttmp=$dstdir/#inst.$$#
-
-# Move or copy the file name to the temp name
-$instcmd $src $dsttmp
-
-# And set any options; do chmod last to preserve setuid bits
-if [ "x$chowncmd" != "x" ]; then $chowncmd $dsttmp; fi
-if [ "x$chgrpcmd" != "x" ]; then $chgrpcmd $dsttmp; fi
-if [ "x$stripcmd" != "x" ]; then $stripcmd $dsttmp; fi
-if [ "x$chmodcmd" != "x" ]; then $chmodcmd $dsttmp; fi
-
-# Now rename the file to the real destination.
-$rmcmd $dst
-$mvcmd $dsttmp $dst
-
-exit 0
-
diff --git a/build/library.mk b/build/library.mk
deleted file mode 100644
index abadb6340c..0000000000
--- a/build/library.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright (c) 1999, 2000 Sascha Schumann. 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.
-#
-# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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 SASCHA SCHUMANN 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.
-#
-##############################################################################
-# $Id: library.mk,v 1.1 2000/01/11 13:10:58 sascha Exp $
-#
-
-LTLIBRARY_OBJECTS = $(LTLIBRARY_SOURCES:.c=.lo)
-
-$(LTLIBRARY_NAME): $(LTLIBRARY_OBJECTS) $(LTLIBRARY_DEPENDENCIES)
- $(LINK) $(LTLIBRARY_LDFLAGS) $(LTLIBRARY_OBJECTS) $(LTLIBRARY_LIBADD)
-
-$(LTLIBRARY_SHARED_NAME): $(LTLIBRARY_OBJECTS) $(LTLIBRARY_DEPENDENCIES)
- @test -d $(phplibdir) || $(mkinstalldirs) $(phplibdir)
- $(LINK) -avoid-version -module -rpath $(phplibdir) $(LTLIBRARY_LDFLAGS) $(LTLIBRARY_OBJECTS) $(LTLIBRARY_SHARED_LIBADD)
- $(SHLIBTOOL) --mode=install install $@ $(phplibdir)
-
-shared:
- @if test '$(SHLIBTOOL)' != '$(LIBTOOL)'; then \
- $(MAKE) 'LIBTOOL=$(SHLIBTOOL)' $(LTLIBRARY_SHARED_NAME); \
- else \
- $(MAKE) $(LTLIBRARY_SHARED_NAME); \
- fi; \
diff --git a/build/ltlib.mk b/build/ltlib.mk
deleted file mode 100644
index 42bbb7cb1b..0000000000
--- a/build/ltlib.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (c) 1999, 2000 Sascha Schumann. 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.
-#
-# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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 SASCHA SCHUMANN 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.
-#
-##############################################################################
-# $Id: ltlib.mk,v 1.1 2000/01/11 13:10:58 sascha Exp $
-#
-
-targets = $(LTLIBRARY_NAME)
-
-include $(topsrcdir)/build/rules.mk
-include $(topsrcdir)/build/library.mk
-
diff --git a/build/mkdep.perl b/build/mkdep.perl
deleted file mode 100644
index f9e06ea041..0000000000
--- a/build/mkdep.perl
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/perl
-#
-# $Id: mkdep.perl,v 1.1 2000/01/11 13:10:59 sascha Exp $
-#
-# Created: Thu Aug 15 11:57:33 1996 too
-# Last modified: Mon Dec 27 09:23:56 1999 too
-#
-# Copyright (c) 1996-1999 Tomi Ollila. 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.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
-
-die "Usage: mkdep CPP-command [CPP options] file1 [file2...]\n"
- if ($#ARGV < 1);
-
-$cmdl = shift(@ARGV);
-
-$cmdl = "$cmdl " . shift (@ARGV) while ($ARGV[0] =~ /^-[A-Z]/);
-
-while ($file = shift(@ARGV))
-{
- $file =~ s/\.o$/.c/;
-
- open(F, "$cmdl $file|");
-
- &parseout;
-
- close(F);
-}
-
-
-sub initinit
-{
- %used = ();
- $of = $file;
- $of =~ s/\.c$/.lo/;
- $str = "$of:\t$file";
- $len = length $str;
-}
-
-sub initstr
-{
- $str = "\t";
- $len = length $str;
-}
-
-sub parseout
-{
- &initinit;
- while (<F>)
- {
- next unless (/^# [0-9]* "(.*\.h)"/);
-
- next if ($1 =~ /^\//);
-
- next if $used{$1};
-
- $used{$1} = 1;
-
- $nlen = length($1) + 1;
-
- if ($len + $nlen > 72)
- {
- print $str, "\\\n";
- &initstr;
- $str = $str . $1;
- }
- else { $str = $str . " " . $1; }
-
- $len += $nlen;
-
- }
- print $str, "\n";
-}
diff --git a/build/mkdir.sh b/build/mkdir.sh
deleted file mode 100755
index 4cd33c5671..0000000000
--- a/build/mkdir.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/sh
-##
-## mkdir.sh -- make directory hierarchy
-##
-## Based on `mkinstalldirs' from Noah Friedman <friedman@prep.ai.mit.edu>
-## as of 1994-03-25, which was placed in the Public Domain.
-## Cleaned up for Apache's Autoconf-style Interface (APACI)
-## by Ralf S. Engelschall <rse@apache.org>
-##
-#
-# This script falls under the Apache License.
-# See http://www.apache.org/docs/LICENSE
-
-
-umask 022
-errstatus=0
-for file in ${1+"$@"} ; do
- set fnord `echo ":$file" |\
- sed -e 's/^:\//%/' -e 's/^://' -e 's/\// /g' -e 's/^%/\//'`
- shift
- pathcomp=
- for d in ${1+"$@"}; do
- pathcomp="$pathcomp$d"
- case "$pathcomp" in
- -* ) pathcomp=./$pathcomp ;;
- esac
- if test ! -d "$pathcomp"; then
- echo "mkdir $pathcomp" 1>&2
- mkdir "$pathcomp" || errstatus=$?
- fi
- pathcomp="$pathcomp/"
- done
-done
-exit $errstatus
-
diff --git a/build/program.mk b/build/program.mk
deleted file mode 100644
index bb52d8832c..0000000000
--- a/build/program.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright (c) 1999, 2000 Sascha Schumann. 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.
-#
-# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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 SASCHA SCHUMANN 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.
-#
-##############################################################################
-# $Id: program.mk,v 1.1 2000/01/11 13:10:59 sascha Exp $
-#
-
-PROGRAM_OBJECTS = $(PROGRAM_SOURCES:.c=.lo)
-
-$(PROGRAM_NAME): $(PROGRAM_DEPENDENCIES) $(PROGRAM_OBJECTS)
- $(LINK) $(PROGRAM_LDFLAGS) $(PROGRAM_OBJECTS) $(PROGRAM_LDADD)
diff --git a/build/rules.mk b/build/rules.mk
deleted file mode 100644
index 08967f003c..0000000000
--- a/build/rules.mk
+++ /dev/null
@@ -1,132 +0,0 @@
-# Copyright (c) 1999, 2000 Sascha Schumann. 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.
-#
-# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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 SASCHA SCHUMANN 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.
-#
-##############################################################################
-# $Id: rules.mk,v 1.3 2000/02/17 22:32:29 rbb Exp $
-#
-
-include $(DEPTH)/config_vars.mk
-
-
-SHLIB_SUFFIX = so
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
-LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
-CCLD = $(CC)
-LINK = $(LIBTOOL) --mode=link $(CCLD) $(LTFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@
-mkinstalldirs = $(abs_srcdir)/helpers/mkdir.sh
-INSTALL = $(abs_srcdir)/helpers/install.sh -c
-INSTALL_DATA = $(INSTALL) -m 644
-INSTALL_PROGRAM = $(INSTALL) -m 755
-SHLIBTOOL = $(SHELL) $(DEPTH)/shlibtool --silent
-APACHE_COMPILE = $(COMPILE) -c $< && touch $@
-APACHE_SH_COMPILE = $(SHLIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) -c $< && touch $@
-SHLINK = $(SHLIBTOOL) --mode=link $(CCLD) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@
-
-DEFS = -DHAVE_CONFIG_H -I. -I$(srcdir) -I$(DEPTH)
-
-top_srcdir = $(topsrcdir)
-top_builddir = $(DEPTH)
-
-.SUFFIXES:
-.SUFFIXES: .S .c .lo .o .s .y .l .slo
-
-.c.o:
- $(COMPILE) -c $<
-
-.s.o:
- $(COMPILE) -c $<
-
-.S.o:
- $(COMPILE) -c $<
-
-.c.lo:
- $(APACHE_COMPILE)
-
-.s.lo:
- $(APACHE_COMPILE)
-
-.S.lo:
- $(APACHE_COMPILE)
-
-.c.slo:
- $(APACHE_SH_COMPILE)
-
-.y.c:
- $(YACC) $(YFLAGS) $< && mv y.tab.c $*.c
- if test -f y.tab.h; then \
- if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
- else :; fi
-
-.l.c:
- $(LEX) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
-
-
-all: all-recursive
-install: install-recursive
-
-distclean-recursive depend-recursive clean-recursive all-recursive install-recursive:
- @otarget=`echo $@|sed s/-recursive//`; \
- if test '$(NO_RECURSION)' != "$$otarget"; then \
- list='$(SUBDIRS)'; for i in $$list; do \
- target="$$otarget"; \
- echo "Making $$target in $$i"; \
- if test "$$i" = "."; then \
- ok=yes; \
- target="$$target-p"; \
- fi; \
- if test ! -f $$i/.deps; then touch $$i/.deps; fi; \
- (cd $$i && $(MAKE) $$target) || exit 1; \
- done; \
- if test "$$otarget" = "all" && test -z '$(targets)'; then ok=yes; fi;\
- if test "$$ok" != "yes"; then $(MAKE) "$$otarget-p" || exit 1; fi;\
- fi
-
-all-p: $(targets)
-install-p: $(targets) $(install_targets)
- @if test -n '$(PROGRAMS)'; then \
- test -d $(bindir) || $(mkinstalldirs) $(bindir); \
- for i in "$(PROGRAMS)"; do \
- $(INSTALL_PROGRAM) $$i $(bindir); \
- done; \
- fi
-
-distclean-p depend-p clean-p:
-
-depend: depend-recursive
- test "`echo *.c`" = '*.c' || perl $(top_srcdir)/build/mkdep.perl $(CPP) $(INCLUDES) $(EXTRA_INCLUDES) *.c > .deps
-
-clean: clean-recursive clean-x
-
-clean-x:
- rm -f $(targets) *.slo *.lo *.la *.o $(CLEANFILES)
- rm -rf .libs
-
-distclean: distclean-recursive clean-x
- rm -f config.cache config.log config.status config_vars.mk libtool \
- stamp-h Makefile shlibtool
-
-include $(srcdir)/.deps
-
-.PHONY: all-recursive clean-recursive install-recursive \
-$(install_targets) install all clean depend depend-recursive shared \
-distclean-recursive distclean clean-x all-p install-p distclean-p \
-depend-p clean-p $(phony_targets)
diff --git a/build/snapshot b/build/snapshot
deleted file mode 100755
index 9553a753f9..0000000000
--- a/build/snapshot
+++ /dev/null
@@ -1,5 +0,0 @@
-#! /bin/sh
-
-test -n "$1" && ARG="DISTNAME='$1'"
-
-${MAKE:-make} $ARG -f build/build.mk snapshot
diff --git a/build/special.mk b/build/special.mk
deleted file mode 100644
index 0068836ff3..0000000000
--- a/build/special.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright (c) 1999, 2000 Sascha Schumann. 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.
-#
-# THIS SOFTWARE IS PROVIDED BY SASCHA SCHUMANN ``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 SASCHA SCHUMANN 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.
-#
-##############################################################################
-# $Id: special.mk,v 1.1 2000/01/11 13:10:59 sascha Exp $
-#
-
-
-
-all: all-recursive
-
-include modules.mk
-targets = $(static) $(shared)
-install_targets = install-modules
-
-install-modules:
- @shared='$(shared)'; \
- if test -n "$$shared"; then \
- $(mkinstalldirs) $(libexecdir); \
- for i in $$shared; do \
- $(SHLIBTOOL) --mode=install cp $$i $(libexecdir); \
- done; \
- fi
-
-include $(topsrcdir)/build/rules.mk
-
diff --git a/buildconf b/buildconf
deleted file mode 100755
index 273eabd9e8..0000000000
--- a/buildconf
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /bin/sh
-
-${MAKE:-make} -f build/build.mk
diff --git a/configure.in b/configure.in
deleted file mode 100644
index e8818d26ca..0000000000
--- a/configure.in
+++ /dev/null
@@ -1,163 +0,0 @@
-dnl ## Process this file with autoconf to produce a configure script
-
-AC_PREREQ(2.13)
-AC_INIT(acinclude.m4)
-
-dnl ## This is the central place where Apache's version should be kept.
-dnl AM_INIT_AUTOMAKE(apache, 2.0-dev)
-
-VERSION="apache-2.0-dev"
-
-AC_CONFIG_HEADER(include/ap_config_auto.h)
-
-APACHE_VERSION=$VERSION
-APACHE_SUBST(APACHE_VERSION)
-
-test "$exec_prefix" = "NONE" && exec_prefix='${prefix}'
-test "$prefix" = "NONE" && prefix='/usr/local'
-
-dnl We want this one before the checks, so the checks can modify CFLAGS
-test -z "$CFLAGS" && auto_cflags=1
-
-dnl Needed for APACHE_MODULE() to work
-cwd=`pwd`
-
-dnl ## Run configure for packages Apache uses
-AC_CONFIG_SUBDIRS(lib/apr)
-
-dnl ## Check for programs
-
-AC_PROG_AWK
-AC_PROG_CC
-AC_PROG_CPP
-AC_PROG_INSTALL
-dnl AC_PROG_RANLIB
-dnl AC_PATH_PROG(PERL_PATH, perl)
-
-dnl various OS checks that apparently set required flags
-AC_AIX
-AC_ISC_POSIX
-AC_MINIX
-
-dnl ## Check for libraries
-
-dnl ## Check for header files
-
-dnl I think these are just used all over the place, so just check for
-dnl them at the base of the tree. If some are specific to a single
-dnl directory, they should be moved (Comment #Spoon)
-
-AC_HEADER_STDC
-AC_CHECK_HEADERS( \
-unistd.h \
-sys/stat.h \
-sys/time.h \
-sys/types.h \
-sys/socket.h \
-netinet/in.h \
-arpa/inet.h \
-netdb.h \
-pwd.h \
-grp.h \
-)
-AC_HEADER_SYS_WAIT
-
-dnl ## Check for C preprocessor symbols
-
-AC_CHECK_DEFINE(EAGAIN, errno.h)
-
-dnl ## Check for typedefs, structures, and compiler characteristics.
-
-AC_C_CONST
-AC_C_INLINE
-AC_TYPE_PID_T
-
-dnl ## Check for library functions
-
-dnl See Comment #Spoon
-
-AC_CHECK_FUNCS( \
-strdup \
-strcasecmp \
-strncasecmp \
-strstr \
-strerror \
-initgroups \
-waitpid \
-gettimeofday \
-memmove \
-bzero \
-)
-
-AC_CHECK_LIB(nsl, gethostbyname)
-AC_CHECK_LIB(socket, socket)
-
-AC_CHECK_FUNCS(inet_addr inet_network, break, [
- AC_MSG_ERROR(inet_addr function not found)
-])
-
-APACHE_INADDR_NONE
-
-REENTRANCY_FLAGS
-
-AC_FUNC_SELECT_ARGTYPES
-
-dnl Check if we'll actually need to cast select args all the time
-if test "$ac_cv_func_select_arg1" != "int" \
- -o "$ac_cv_func_select_arg234" != "fd_set *" \
- -o "$ac_cv_func_select_arg5" != "struct timeval *" ; then
-
- AC_DEFINE(SELECT_NEEDS_CAST,,
- [Define if arguments to select() aren't what we expect])
-fi
-
-dnl ## Checking command-line options
-test -n "$GCC" && test "$USE_MAINTAINER_MODE" = "yes" && \
- CFLAGS="$CFLAGS -g -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations"
-
-APACHE_ENABLE_LAYOUT
-APACHE_ENABLE_MODULES
-APACHE_ENABLE_SHARED
-
-INCLUDES="-I\$(top_srcdir)/include -I\$(top_srcdir)/lib/apr/include"
-APACHE_SUBST(INCLUDES)
-
-dnl reading config stubs
-esyscmd(./helpers/config-stubs .)
-
-INCLUDES="$INCLUDES -I\$(top_srcdir)/\$(OS_DIR)"
-EXTRA_LIBS="$EXTRA_LIBS $LIBS"
-EXTRA_LDFLAGS="$LDFLAGS"
-LIBS=""
-LDFLAGS=""
-APACHE_SUBST(EXTRA_LDFLAGS)
-APACHE_SUBST(EXTRA_LIBS)
-APACHE_SUBST(REGEX_DIR)
-APACHE_SUBST(REGEX_LIB)
-APACHE_SUBST(MPM_LIB)
-APACHE_SUBST(OS)
-APACHE_SUBST(OS_DIR)
-APACHE_SUBST(BUILTIN_LIBS)
-
-AM_DISABLE_SHARED
-AM_PROG_LIBTOOL
-APACHE_LIBTOOL_SILENT
-
-if test "$apache_need_shared" = "yes"; then
- $SHELL $srcdir/ltconfig --output=shlibtool --disable-static --srcdir=$srcdir --cache-file=./config.cache $srcdir/ltmain.sh
-fi
-
-CFLAGS="$CFLAGS \`\$(abs_srcdir)/apaci\`"
-
-APACHE_FAST_OUTPUT(apaci Makefile ap/Makefile lib/Makefile main/Makefile
- modules/Makefile os/Makefile)
-APACHE_FAST_GENERATE
-
-dnl ## Build modules.c
-rm -f $srcdir/modules.c
-echo $MODLIST | $AWK -f $srcdir/helpers/build-modules-c.awk > $srcdir/modules.c
-
-AC_SUBST(prefix)
-
-AC_OUTPUT($APACHE_OUTPUT_FILES apaci)
-chmod 744 apaci
diff --git a/docs/cgi-examples/printenv b/docs/cgi-examples/printenv
deleted file mode 100644
index 7d389e0ac5..0000000000
--- a/docs/cgi-examples/printenv
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/local/bin/perl
-
-print "Content-type: text/html\n\n";
-while (($key, $val) = each %ENV) {
- print "$key = $val<BR>\n";
-}
-
diff --git a/docs/cgi-examples/test-cgi b/docs/cgi-examples/test-cgi
deleted file mode 100644
index a85631e3aa..0000000000
--- a/docs/cgi-examples/test-cgi
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/sh
-
-# disable filename globbing
-set -f
-
-echo Content-type: text/plain
-echo
-
-echo CGI/1.0 test script report:
-echo
-
-echo argc is $#. argv is "$*".
-echo
-
-echo SERVER_SOFTWARE = $SERVER_SOFTWARE
-echo SERVER_NAME = $SERVER_NAME
-echo GATEWAY_INTERFACE = $GATEWAY_INTERFACE
-echo SERVER_PROTOCOL = $SERVER_PROTOCOL
-echo SERVER_PORT = $SERVER_PORT
-echo REQUEST_METHOD = $REQUEST_METHOD
-echo HTTP_ACCEPT = "$HTTP_ACCEPT"
-echo PATH_INFO = "$PATH_INFO"
-echo PATH_TRANSLATED = "$PATH_TRANSLATED"
-echo SCRIPT_NAME = "$SCRIPT_NAME"
-echo QUERY_STRING = "$QUERY_STRING"
-echo REMOTE_HOST = $REMOTE_HOST
-echo REMOTE_ADDR = $REMOTE_ADDR
-echo REMOTE_USER = $REMOTE_USER
-echo AUTH_TYPE = $AUTH_TYPE
-echo CONTENT_TYPE = $CONTENT_TYPE
-echo CONTENT_LENGTH = $CONTENT_LENGTH
diff --git a/docs/conf/highperformance.conf b/docs/conf/highperformance.conf
deleted file mode 100644
index 2745d724c5..0000000000
--- a/docs/conf/highperformance.conf
+++ /dev/null
@@ -1,52 +0,0 @@
-# Ha, you're reading this config file looking for the easy way out!
-# "how do I make my apache server go really really fast??"
-# Well you could start by reading the htdocs/manual/misc/perf-tuning.html
-# page. But, we'll give you a head start.
-#
-# This config file is small, it is probably not what you'd expect on a
-# full featured internet webserver with multiple users. But it's
-# probably a good starting point for any folks interested in testing
-# performance.
-#
-# To run this config you'll need to use something like:
-# httpd -f @@ServerRoot@@/conf/highperformance.conf
-
-Port 80
-ServerRoot @@ServerRoot@@
-DocumentRoot @@ServerRoot@@/htdocs
-MaxClients 8
-StartServers 5
-MinSpareServers 5
-MaxSpareServers 10
-# Assume no memory leaks at all
-MaxRequestsPerChild 0
-
-# this is a True Config File
-# see http://www.apache.org/info/three-config-files.html
-ResourceConfig /dev/null
-AccessConfig /dev/null
-
-# it's always nice to know the server has started
-ErrorLog logs/error_log
-
-# Some benchmarks require logging, which is a good requirement. Uncomment
-# this if you need logging.
-#TransferLog logs/access_log
-
-# Disable symlink protection and htaccess files, they chew far too much.
-<Directory />
- AllowOverride none
- Options FollowSymLinks
- # If this was a real internet server you'd probably want to
- # uncomment these:
- #order deny,allow
- #deny from all
-</Directory>
-
-# If this was a real internet server you'd probably want to uncomment this:
-#<Directory "@@ServerRoot@@/htdocs">
-# order allow,deny
-# allow from all
-#</Directory>
-
-# OK that's enough hints. Read the documentation if you want more.
diff --git a/docs/conf/httpd-std.conf b/docs/conf/httpd-std.conf
deleted file mode 100644
index ecc0f4b4f8..0000000000
--- a/docs/conf/httpd-std.conf
+++ /dev/null
@@ -1,859 +0,0 @@
-#
-# Based upon the NCSA server configuration files originally by Rob McCool.
-#
-# This is the main Apache server configuration file. It contains the
-# configuration directives that give the server its instructions.
-# See <URL:http://www.apache.org/docs/> for detailed information about
-# the directives.
-#
-# Do NOT simply read the instructions in here without understanding
-# what they do. They're here only as hints or reminders. If you are unsure
-# consult the online docs. You have been warned.
-#
-# After this file is processed, the server will look for and process
-# @@ServerRoot@@/conf/srm.conf and then @@ServerRoot@@/conf/access.conf
-# unless you have overridden these with ResourceConfig and/or
-# AccessConfig directives here.
-#
-# The configuration directives are grouped into three basic sections:
-# 1. Directives that control the operation of the Apache server process as a
-# whole (the 'global environment').
-# 2. Directives that define the parameters of the 'main' or 'default' server,
-# which responds to requests that aren't handled by a virtual host.
-# These directives also provide default values for the settings
-# of all virtual hosts.
-# 3. Settings for virtual hosts, which allow Web requests to be sent to
-# different IP addresses or hostnames and have them handled by the
-# same Apache server process.
-#
-# Configuration and logfile names: If the filenames you specify for many
-# of the server's control files begin with "/" (or "drive:/" for Win32), the
-# server will use that explicit path. If the filenames do *not* begin
-# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
-# with ServerRoot set to "/usr/local/apache" will be interpreted by the
-# server as "/usr/local/apache/logs/foo.log".
-#
-
-### Section 1: Global Environment
-#
-# The directives in this section affect the overall operation of Apache,
-# such as the number of concurrent requests it can handle or where it
-# can find its configuration files.
-#
-
-#
-# ServerType is either inetd, or standalone. Inetd mode is only supported on
-# Unix platforms.
-#
-#ServerType standalone
-
-#
-# ServerRoot: The top of the directory tree under which the server's
-# configuration, error, and log files are kept.
-#
-# NOTE! If you intend to place this on an NFS (or otherwise network)
-# mounted filesystem then please read the LockFile documentation
-# (available at <URL:http://www.apache.org/docs/mod/core.html#lockfile>);
-# you will save yourself a lot of trouble.
-#
-# Do NOT add a slash at the end of the directory path.
-#
-ServerRoot "@@ServerRoot@@"
-
-#
-# The LockFile directive sets the path to the lockfile used when Apache
-# is compiled with either USE_FCNTL_SERIALIZED_ACCEPT or
-# USE_FLOCK_SERIALIZED_ACCEPT. This directive should normally be left at
-# its default value. The main reason for changing it is if the logs
-# directory is NFS mounted, since the lockfile MUST BE STORED ON A LOCAL
-# DISK. The PID of the main server process is automatically appended to
-# the filename.
-#
-#LockFile logs/accept.lock
-
-#
-# PidFile: The file in which the server should record its process
-# identification number when it starts.
-#
-PidFile logs/httpd.pid
-
-#
-# ScoreBoardFile: File used to store internal server process information.
-# Not all architectures require this. But if yours does (you'll know because
-# this file will be created when you run Apache) then you *must* ensure that
-# no two invocations of Apache share the same scoreboard file.
-#
-<IfModule !dexter.c>
-ScoreBoardFile logs/apache_runtime_status
-</IfModule>
-
-#
-# In the standard configuration, the server will process this file,
-# srm.conf, and access.conf in that order. The latter two files are
-# now distributed empty, as it is recommended that all directives
-# be kept in a single file for simplicity. The commented-out values
-# below are the built-in defaults. You can have the server ignore
-# these files altogether by using "/dev/null" (for Unix) or
-# "nul" (for Win32) for the arguments to the directives.
-#
-#ResourceConfig conf/srm.conf
-#AccessConfig conf/access.conf
-
-#
-# Timeout: The number of seconds before receives and sends time out.
-#
-Timeout 300
-
-#
-# KeepAlive: Whether or not to allow persistent connections (more than
-# one request per connection). Set to "Off" to deactivate.
-#
-KeepAlive On
-
-#
-# MaxKeepAliveRequests: The maximum number of requests to allow
-# during a persistent connection. Set to 0 to allow an unlimited amount.
-# We recommend you leave this number high, for maximum performance.
-#
-MaxKeepAliveRequests 100
-
-#
-# KeepAliveTimeout: Number of seconds to wait for the next request from the
-# same client on the same connection.
-#
-KeepAliveTimeout 15
-
-##
-## Server-Pool Size Regulation (MPM specific)
-##
-
-# prefork MPM
-# StartServers ......... number of server processes to start
-# MinSpareServers ...... minimum number of server processes which are kept spare
-# MaxSpareServers ...... maximum number of server processes which are kept spare
-# MaxClients ........... maximum number of server processes allowed to start
-# MaxRequestsPerChild .. maximum number of requests a server process serves
-<IfModule prefork.c>
-StartServers 5
-MinSpareServers 5
-MaxSpareServers 10
-MaxClients 20
-MaxRequestsPerChild 0
-</IfModule>
-
-# pthread MPM
-# StartServers ......... initial number of server processes to start
-# MaxClients ........... maximum number of server processes allowed to start
-# MinSpareThreads ...... minimum number of worker threads which are kept spare
-# MaxSpareThreads ...... maximum number of worker threads which are kept spare
-# ThreadsPerChild ...... constant number of worker threads in each server process
-# MaxRequestsPerChild .. maximum number of requests a server process serves
-<IfModule mpmt_pthread.c>
-StartServers 5
-MaxClients 8
-MinSpareThreads 5
-MaxSpareThreads 10
-ThreadsPerChild 20
-MaxRequestsPerChild 0
-</IfModule>
-
-# dexter MPM
-# NumServers ........... constant number of server processes
-# StartThreads ......... initial number of worker threads in each server process
-# MinSpareThreads ...... minimum number of worker threads which are kept spare
-# MaxSpareThreads ...... maximum number of worker threads which are kept spare
-# MaxThreadsPerChild ... maximum number of worker threads in each server process
-# MaxRequestsPerChild .. maximum number of connections per server process (then it dies)
-<IfModule dexter.c>
-NumServers 5
-StartThreads 5
-MinSpareThreads 5
-MaxSpareThreads 10
-MaxThreadsPerChild 20
-MaxRequestsPerChild 0
-</IfModule>
-
-#
-# Listen: Allows you to bind Apache to specific IP addresses and/or
-# ports, in addition to the default. See also the <VirtualHost>
-# directive.
-#
-#Listen 3000
-#Listen 12.34.56.78:80
-
-#
-# BindAddress: You can support virtual hosts with this option. This directive
-# is used to tell the server which IP address to listen to. It can either
-# contain "*", an IP address, or a fully qualified Internet domain name.
-# See also the <VirtualHost> and Listen directives.
-#
-#BindAddress *
-
-#
-# Dynamic Shared Object (DSO) Support
-#
-# To be able to use the functionality of a module which was built as a DSO you
-# have to place corresponding `LoadModule' lines at this location so the
-# directives contained in it are actually available _before_ they are used.
-# Please read the file README.DSO in the Apache 1.3 distribution for more
-# details about the DSO mechanism and run `httpd -l' for the list of already
-# built-in (statically linked and thus always available) modules in your httpd
-# binary.
-#
-# Note: The order is which modules are loaded is important. Don't change
-# the order below without expert advice.
-#
-# Example:
-# LoadModule foo_module libexec/mod_foo.so
-
-#
-# ExtendedStatus controls whether Apache will generate "full" status
-# information (ExtendedStatus On) or just basic information (ExtendedStatus
-# Off) when the "server-status" handler is called. The default is Off.
-#
-#ExtendedStatus On
-
-### Section 2: 'Main' server configuration
-#
-# The directives in this section set up the values used by the 'main'
-# server, which responds to any requests that aren't handled by a
-# <VirtualHost> definition. These values also provide defaults for
-# any <VirtualHost> containers you may define later in the file.
-#
-# All of these directives may appear inside <VirtualHost> containers,
-# in which case these default settings will be overridden for the
-# virtual host being defined.
-#
-
-#
-# If your ServerType directive (set earlier in the 'Global Environment'
-# section) is set to "inetd", the next few directives don't have any
-# effect since their settings are defined by the inetd configuration.
-# Skip ahead to the ServerAdmin directive.
-#
-
-#
-# Port: The port to which the standalone server listens. For
-# ports < 1023, you will need httpd to be run as root initially.
-#
-Port 80
-
-#
-# If you wish httpd to run as a different user or group, you must run
-# httpd as root initially and it will switch.
-#
-# User/Group: The name (or #number) of the user/group to run httpd as.
-# . On SCO (ODT 3) use "User nouser" and "Group nogroup".
-# . On HPUX you may not be able to use shared memory as nobody, and the
-# suggested workaround is to create a user www and use that user.
-# NOTE that some kernels refuse to setgid(Group) or semctl(IPC_SET)
-# when the value of (unsigned)Group is above 60000;
-# don't use Group #-1 on these systems!
-#
-User nobody
-Group #-1
-
-#
-# ServerAdmin: Your address, where problems with the server should be
-# e-mailed. This address appears on some server-generated pages, such
-# as error documents.
-#
-ServerAdmin you@your.address
-
-#
-# ServerName allows you to set a host name which is sent back to clients for
-# your server if it's different than the one the program would get (i.e., use
-# "www" instead of the host's real name).
-#
-# Note: You cannot just invent host names and hope they work. The name you
-# define here must be a valid DNS name for your host. If you don't understand
-# this, ask your network administrator.
-# If your host doesn't have a registered DNS name, enter its IP address here.
-# You will have to access it by its address (e.g., http://123.45.67.89/)
-# anyway, and this will make redirections work in a sensible way.
-#
-#ServerName new.host.name
-
-#
-# DocumentRoot: The directory out of which you will serve your
-# documents. By default, all requests are taken from this directory, but
-# symbolic links and aliases may be used to point to other locations.
-#
-DocumentRoot "@@ServerRoot@@/htdocs"
-
-#
-# Each directory to which Apache has access, can be configured with respect
-# to which services and features are allowed and/or disabled in that
-# directory (and its subdirectories).
-#
-# First, we configure the "default" to be a very restrictive set of
-# permissions.
-#
-<Directory />
- Options FollowSymLinks
- AllowOverride None
-</Directory>
-
-#
-# Note that from this point forward you must specifically allow
-# particular features to be enabled - so if something's not working as
-# you might expect, make sure that you have specifically enabled it
-# below.
-#
-
-#
-# This should be changed to whatever you set DocumentRoot to.
-#
-<Directory "@@ServerRoot@@/htdocs">
-
-#
-# This may also be "None", "All", or any combination of "Indexes",
-# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
-#
-# Note that "MultiViews" must be named *explicitly* --- "Options All"
-# doesn't give it to you.
-#
- Options Indexes FollowSymLinks
-
-#
-# This controls which options the .htaccess files in directories can
-# override. Can also be "All", or any combination of "Options", "FileInfo",
-# "AuthConfig", and "Limit"
-#
- AllowOverride None
-
-#
-# Controls who can get stuff from this server.
-#
- Order allow,deny
- Allow from all
-</Directory>
-
-#
-# UserDir: The name of the directory which is appended onto a user's home
-# directory if a ~user request is received.
-#
-UserDir public_html
-
-#
-# Control access to UserDir directories. The following is an example
-# for a site where these directories are restricted to read-only.
-#
-#<Directory /home/*/public_html>
-# AllowOverride FileInfo AuthConfig Limit
-# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
-# <Limit GET POST OPTIONS PROPFIND>
-# Order allow,deny
-# Allow from all
-# </Limit>
-# <Limit PUT DELETE PATCH PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
-# Order deny,allow
-# Deny from all
-# </Limit>
-#</Directory>
-
-#
-# DirectoryIndex: Name of the file or files to use as a pre-written HTML
-# directory index. Separate multiple entries with spaces.
-#
-DirectoryIndex index.html
-
-#
-# AccessFileName: The name of the file to look for in each directory
-# for access control information.
-#
-AccessFileName .htaccess
-
-#
-# The following lines prevent .htaccess files from being viewed by
-# Web clients. Since .htaccess files often contain authorization
-# information, access is disallowed for security reasons. Comment
-# these lines out if you want Web visitors to see the contents of
-# .htaccess files. If you change the AccessFileName directive above,
-# be sure to make the corresponding changes here.
-#
-# Also, folks tend to use names such as .htpasswd for password
-# files, so this will protect those as well.
-#
-<Files ~ "^\.ht">
- Order allow,deny
- Deny from all
-</Files>
-
-#
-# CacheNegotiatedDocs: By default, Apache sends "Pragma: no-cache" with each
-# document that was negotiated on the basis of content. This asks proxy
-# servers not to cache the document. Uncommenting the following line disables
-# this behavior, and proxies will be allowed to cache the documents.
-#
-#CacheNegotiatedDocs
-
-#
-# UseCanonicalName: (new for 1.3) With this setting turned on, whenever
-# Apache needs to construct a self-referencing URL (a URL that refers back
-# to the server the response is coming from) it will use ServerName and
-# Port to form a "canonical" name. With this setting off, Apache will
-# use the hostname:port that the client supplied, when possible. This
-# also affects SERVER_NAME and SERVER_PORT in CGI scripts.
-#
-UseCanonicalName On
-
-#
-# TypesConfig describes where the mime.types file (or equivalent) is
-# to be found.
-#
-TypesConfig conf/mime.types
-
-#
-# DefaultType is the default MIME type the server will use for a document
-# if it cannot otherwise determine one, such as from filename extensions.
-# If your server contains mostly text or HTML documents, "text/plain" is
-# a good value. If most of your content is binary, such as applications
-# or images, you may want to use "application/octet-stream" instead to
-# keep browsers from trying to display binary files as though they are
-# text.
-#
-DefaultType text/plain
-
-#
-# The mod_mime_magic module allows the server to use various hints from the
-# contents of the file itself to determine its type. The MIMEMagicFile
-# directive tells the module where the hint definitions are located.
-# mod_mime_magic is not part of the default server (you have to add
-# it yourself with a LoadModule [see the DSO paragraph in the 'Global
-# Environment' section], or recompile the server and include mod_mime_magic
-# as part of the configuration), so it's enclosed in an <IfModule> container.
-# This means that the MIMEMagicFile directive will only be processed if the
-# module is part of the server.
-#
-<IfModule mod_mime_magic.c>
- MIMEMagicFile conf/magic
-</IfModule>
-
-#
-# HostnameLookups: Log the names of clients or just their IP addresses
-# e.g., www.apache.org (on) or 204.62.129.132 (off).
-# The default is off because it'd be overall better for the net if people
-# had to knowingly turn this feature on, since enabling it means that
-# each client request will result in AT LEAST one lookup request to the
-# nameserver.
-#
-HostnameLookups Off
-
-#
-# ErrorLog: The location of the error log file.
-# If you do not specify an ErrorLog directive within a <VirtualHost>
-# container, error messages relating to that virtual host will be
-# logged here. If you *do* define an error logfile for a <VirtualHost>
-# container, that host's errors will be logged there and not here.
-#
-ErrorLog logs/error_log
-
-#
-# LogLevel: Control the number of messages logged to the error_log.
-# Possible values include: debug, info, notice, warn, error, crit,
-# alert, emerg.
-#
-LogLevel warn
-
-#
-# The following directives define some format nicknames for use with
-# a CustomLog directive (see below).
-#
-LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
-LogFormat "%h %l %u %t \"%r\" %>s %b" common
-LogFormat "%{Referer}i -> %U" referer
-LogFormat "%{User-agent}i" agent
-
-#
-# The location and format of the access logfile (Common Logfile Format).
-# If you do not define any access logfiles within a <VirtualHost>
-# container, they will be logged here. Contrariwise, if you *do*
-# define per-<VirtualHost> access logfiles, transactions will be
-# logged therein and *not* in this file.
-#
-CustomLog logs/access_log common
-
-#
-# If you would like to have agent and referer logfiles, uncomment the
-# following directives.
-#
-#CustomLog logs/referer_log referer
-#CustomLog logs/agent_log agent
-
-#
-# If you prefer a single logfile with access, agent, and referer information
-# (Combined Logfile Format) you can use the following directive.
-#
-#CustomLog logs/access_log combined
-
-#
-# Optionally add a line containing the server version and virtual host
-# name to server-generated pages (error documents, FTP directory listings,
-# mod_status and mod_info output etc., but not CGI generated documents).
-# Set to "EMail" to also include a mailto: link to the ServerAdmin.
-# Set to one of: On | Off | EMail
-#
-ServerSignature On
-
-#
-# Aliases: Add here as many aliases as you need (with no limit). The format is
-# Alias fakename realname
-#
-# Note that if you include a trailing / on fakename then the server will
-# require it to be present in the URL. So "/icons" isn't aliased in this
-# example, only "/icons/"..
-#
-Alias /icons/ "@@ServerRoot@@/icons/"
-
-<Directory "@@ServerRoot@@/icons">
- Options Indexes MultiViews
- AllowOverride None
- Order allow,deny
- Allow from all
-</Directory>
-
-#
-# ScriptAlias: This controls which directories contain server scripts.
-# ScriptAliases are essentially the same as Aliases, except that
-# documents in the realname directory are treated as applications and
-# run by the server when requested rather than as documents sent to the client.
-# The same rules about trailing "/" apply to ScriptAlias directives as to
-# Alias.
-#
-ScriptAlias /cgi-bin/ "@@ServerRoot@@/cgi-bin/"
-
-#
-# "@@ServerRoot@@/cgi-bin" should be changed to whatever your ScriptAliased
-# CGI directory exists, if you have that configured.
-#
-<Directory "@@ServerRoot@@/cgi-bin">
- AllowOverride None
- Options None
- Order allow,deny
- Allow from all
-</Directory>
-
-#
-# Redirect allows you to tell clients about documents which used to exist in
-# your server's namespace, but do not anymore. This allows you to tell the
-# clients where to look for the relocated document.
-# Format: Redirect old-URI new-URL
-#
-
-#
-# Directives controlling the display of server-generated directory listings.
-#
-
-#
-# FancyIndexing is whether you want fancy directory indexing or standard
-#
-IndexOptions FancyIndexing
-
-#
-# AddIcon* directives tell the server which icon to show for different
-# files or filename extensions. These are only displayed for
-# FancyIndexed directories.
-#
-AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
-
-AddIconByType (TXT,/icons/text.gif) text/*
-AddIconByType (IMG,/icons/image2.gif) image/*
-AddIconByType (SND,/icons/sound2.gif) audio/*
-AddIconByType (VID,/icons/movie.gif) video/*
-
-AddIcon /icons/binary.gif .bin .exe
-AddIcon /icons/binhex.gif .hqx
-AddIcon /icons/tar.gif .tar
-AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
-AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
-AddIcon /icons/a.gif .ps .ai .eps
-AddIcon /icons/layout.gif .html .shtml .htm .pdf
-AddIcon /icons/text.gif .txt
-AddIcon /icons/c.gif .c
-AddIcon /icons/p.gif .pl .py
-AddIcon /icons/f.gif .for
-AddIcon /icons/dvi.gif .dvi
-AddIcon /icons/uuencoded.gif .uu
-AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
-AddIcon /icons/tex.gif .tex
-AddIcon /icons/bomb.gif core
-
-AddIcon /icons/back.gif ..
-AddIcon /icons/hand.right.gif README
-AddIcon /icons/folder.gif ^^DIRECTORY^^
-AddIcon /icons/blank.gif ^^BLANKICON^^
-
-#
-# DefaultIcon is which icon to show for files which do not have an icon
-# explicitly set.
-#
-DefaultIcon /icons/unknown.gif
-
-#
-# AddDescription allows you to place a short description after a file in
-# server-generated indexes. These are only displayed for FancyIndexed
-# directories.
-# Format: AddDescription "description" filename
-#
-#AddDescription "GZIP compressed document" .gz
-#AddDescription "tar archive" .tar
-#AddDescription "GZIP compressed tar archive" .tgz
-
-#
-# ReadmeName is the name of the README file the server will look for by
-# default, and append to directory listings.
-#
-# HeaderName is the name of a file which should be prepended to
-# directory indexes.
-#
-# The server will first look for name.html and include it if found.
-# If name.html doesn't exist, the server will then look for name.txt
-# and include it as plaintext if found.
-#
-ReadmeName README
-HeaderName HEADER
-
-#
-# IndexIgnore is a set of filenames which directory indexing should ignore
-# and not include in the listing. Shell-style wildcarding is permitted.
-#
-IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
-
-#
-# AddEncoding allows you to have certain browsers (Mosaic/X 2.1+) uncompress
-# information on the fly. Note: Not all browsers support this.
-# Despite the name similarity, the following Add* directives have nothing
-# to do with the FancyIndexing customization directives above.
-#
-AddEncoding x-compress Z
-AddEncoding x-gzip gz tgz
-
-#
-# AddLanguage allows you to specify the language of a document. You can
-# then use content negotiation to give a browser a file in a language
-# it can understand. Note that the suffix does not have to be the same
-# as the language keyword --- those with documents in Polish (whose
-# net-standard language code is pl) may wish to use "AddLanguage pl .po"
-# to avoid the ambiguity with the common suffix for perl scripts.
-#
-AddLanguage en .en
-AddLanguage fr .fr
-AddLanguage de .de
-AddLanguage da .da
-AddLanguage el .el
-AddLanguage it .it
-
-#
-# LanguagePriority allows you to give precedence to some languages
-# in case of a tie during content negotiation.
-# Just list the languages in decreasing order of preference.
-#
-LanguagePriority en fr de
-
-#
-# AddType allows you to tweak mime.types without actually editing it, or to
-# make certain files to be certain types.
-#
-# For example, the PHP3 module (not part of the Apache distribution - see
-# http://www.php.net) will typically use:
-#
-#AddType application/x-httpd-php3 .php3
-#AddType application/x-httpd-php3-source .phps
-
-AddType application/x-tar .tgz
-
-#
-# AddHandler allows you to map certain file extensions to "handlers",
-# actions unrelated to filetype. These can be either built into the server
-# or added with the Action command (see below)
-#
-# If you want to use server side includes, or CGI outside
-# ScriptAliased directories, uncomment the following lines.
-#
-# To use CGI scripts:
-#
-#AddHandler cgi-script .cgi
-
-#
-# To use server-parsed HTML files
-#
-#AddType text/html .shtml
-#AddHandler server-parsed .shtml
-
-#
-# Uncomment the following line to enable Apache's send-asis HTTP file
-# feature
-#
-#AddHandler send-as-is asis
-
-#
-# If you wish to use server-parsed imagemap files, use
-#
-#AddHandler imap-file map
-
-#
-# To enable type maps, you might want to use
-#
-#AddHandler type-map var
-
-#
-# Action lets you define media types that will execute a script whenever
-# a matching file is called. This eliminates the need for repeated URL
-# pathnames for oft-used CGI file processors.
-# Format: Action media/type /cgi-script/location
-# Format: Action handler-name /cgi-script/location
-#
-
-#
-# MetaDir: specifies the name of the directory in which Apache can find
-# meta information files. These files contain additional HTTP headers
-# to include when sending the document
-#
-#MetaDir .web
-
-#
-# MetaSuffix: specifies the file name suffix for the file containing the
-# meta information.
-#
-#MetaSuffix .meta
-
-#
-# Customizable error response (Apache style)
-# these come in three flavors
-#
-# 1) plain text
-#ErrorDocument 500 "The server made a boo boo.
-# n.b. the (") marks it as text, it does not get output
-#
-# 2) local redirects
-#ErrorDocument 404 /missing.html
-# to redirect to local URL /missing.html
-#ErrorDocument 404 /cgi-bin/missing_handler.pl
-# N.B.: You can redirect to a script or a document using server-side-includes.
-#
-# 3) external redirects
-#ErrorDocument 402 http://some.other_server.com/subscription_info.html
-# N.B.: Many of the environment variables associated with the original
-# request will *not* be available to such a script.
-
-#
-# The following directives modify normal HTTP response behavior.
-# The first directive disables keepalive for Netscape 2.x and browsers that
-# spoof it. There are known problems with these browser implementations.
-# The second directive is for Microsoft Internet Explorer 4.0b2
-# which has a broken HTTP/1.1 implementation and does not properly
-# support keepalive when it is used on 301 or 302 (redirect) responses.
-#
-BrowserMatch "Mozilla/2" nokeepalive
-BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
-
-#
-# The following directive disables HTTP/1.1 responses to browsers which
-# are in violation of the HTTP/1.0 spec by not being able to grok a
-# basic 1.1 response.
-#
-BrowserMatch "RealPlayer 4\.0" force-response-1.0
-BrowserMatch "Java/1\.0" force-response-1.0
-BrowserMatch "JDK/1\.0" force-response-1.0
-
-#
-# Allow server status reports, with the URL of http://servername/server-status
-# Change the ".your_domain.com" to match your domain to enable.
-#
-#<Location /server-status>
-# SetHandler server-status
-# Order deny,allow
-# Deny from all
-# Allow from .your_domain.com
-#</Location>
-
-#
-# Allow remote server configuration reports, with the URL of
-# http://servername/server-info (requires that mod_info.c be loaded).
-# Change the ".your_domain.com" to match your domain to enable.
-#
-#<Location /server-info>
-# SetHandler server-info
-# Order deny,allow
-# Deny from all
-# Allow from .your_domain.com
-#</Location>
-
-#
-# There have been reports of people trying to abuse an old bug from pre-1.1
-# days. This bug involved a CGI script distributed as a part of Apache.
-# By uncommenting these lines you can redirect these attacks to a logging
-# script on phf.apache.org. Or, you can record them yourself, using the script
-# support/phf_abuse_log.cgi.
-#
-#<Location /cgi-bin/phf*>
-# Deny from all
-# ErrorDocument 403 http://phf.apache.org/phf_abuse_log.cgi
-#</Location>
-
-#
-# Proxy Server directives. Uncomment the following lines to
-# enable the proxy server:
-#
-#<IfModule mod_proxy.c>
-#ProxyRequests On
-#
-#<Directory proxy:*>
-# Order deny,allow
-# Deny from all
-# Allow from .your_domain.com
-#</Directory>
-
-#
-# Enable/disable the handling of HTTP/1.1 "Via:" headers.
-# ("Full" adds the server version; "Block" removes all outgoing Via: headers)
-# Set to one of: Off | On | Full | Block
-#
-#ProxyVia On
-
-#
-# To enable the cache as well, edit and uncomment the following lines:
-# (no cacheing without CacheRoot)
-#
-#CacheRoot "@@ServerRoot@@/proxy"
-#CacheSize 5
-#CacheGcInterval 4
-#CacheMaxExpire 24
-#CacheLastModifiedFactor 0.1
-#CacheDefaultExpire 1
-#NoCache a_domain.com another_domain.edu joes.garage_sale.com
-
-#</IfModule>
-# End of proxy directives.
-
-### Section 3: Virtual Hosts
-#
-# VirtualHost: If you want to maintain multiple domains/hostnames on your
-# machine you can setup VirtualHost containers for them.
-# Please see the documentation at <URL:http://www.apache.org/docs/vhosts/>
-# for further details before you try to setup virtual hosts.
-# You may use the command line option '-S' to verify your virtual host
-# configuration.
-
-#
-# If you want to use name-based virtual hosts you need to define at
-# least one IP address (and port number) for them.
-#
-#NameVirtualHost 12.34.56.78:80
-#NameVirtualHost 12.34.56.78
-
-#
-# VirtualHost example:
-# Almost any Apache directive may go into a VirtualHost container.
-#
-#<VirtualHost ip.address.of.host.some_domain.com>
-# ServerAdmin webmaster@host.some_domain.com
-# DocumentRoot /www/docs/host.some_domain.com
-# ServerName host.some_domain.com
-# ErrorLog logs/host.some_domain.com-error_log
-# CustomLog logs/host.some_domain.com-access_log common
-#</VirtualHost>
-
-#<VirtualHost _default_:*>
-#</VirtualHost>
diff --git a/docs/conf/httpd-win.conf b/docs/conf/httpd-win.conf
deleted file mode 100644
index 3eca7ef3de..0000000000
--- a/docs/conf/httpd-win.conf
+++ /dev/null
@@ -1,781 +0,0 @@
-#
-# Based upon the NCSA server configuration files originally by Rob McCool.
-#
-# This is the main Apache server configuration file. It contains the
-# configuration directives that give the server its instructions.
-# See <URL:http://www.apache.org/docs/> for detailed information about
-# the directives.
-#
-# Do NOT simply read the instructions in here without understanding
-# what they do. They're here only as hints or reminders. If you are unsure
-# consult the online docs. You have been warned.
-#
-# After this file is processed, the server will look for and process
-# @@ServerRoot@@/conf/srm.conf and then @@ServerRoot@@/conf/access.conf
-# unless you have overridden these with ResourceConfig and/or
-# AccessConfig directives here.
-#
-# The configuration directives are grouped into three basic sections:
-# 1. Directives that control the operation of the Apache server process as a
-# whole (the 'global environment').
-# 2. Directives that define the parameters of the 'main' or 'default' server,
-# which responds to requests that aren't handled by a virtual host.
-# These directives also provide default values for the settings
-# of all virtual hosts.
-# 3. Settings for virtual hosts, which allow Web requests to be sent to
-# different IP addresses or hostnames and have them handled by the
-# same Apache server process.
-#
-# Configuration and logfile names: If the filenames you specify for many
-# of the server's control files begin with "/" (or "drive:/" for Win32), the
-# server will use that explicit path. If the filenames do *not* begin
-# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
-# with ServerRoot set to "/usr/local/apache" will be interpreted by the
-# server as "/usr/local/apache/logs/foo.log".
-#
-# NOTE: Where filenames are specified, you must use forward slashes
-# instead of backslashes (e.g., "c:/apache" instead of "c:\apache").
-# If a drive letter is omitted, the drive on which Apache.exe is located
-# will be used by default. It is recommended that you always supply
-# an explicit drive letter in absolute paths, however, to avoid
-# confusion.
-#
-
-### Section 1: Global Environment
-#
-# The directives in this section affect the overall operation of Apache,
-# such as the number of concurrent requests it can handle or where it
-# can find its configuration files.
-#
-
-#
-# ServerType is either inetd, or standalone. Inetd mode is only supported on
-# Unix platforms.
-#
-ServerType standalone
-
-#
-# ServerRoot: The top of the directory tree under which the server's
-# configuration, error, and log files are kept.
-#
-# Do NOT add a slash at the end of the directory path.
-#
-ServerRoot "@@ServerRoot@@"
-
-#
-# PidFile: The file in which the server should record its process
-# identification number when it starts.
-#
-PidFile logs/httpd.pid
-
-#
-# ScoreBoardFile: File used to store internal server process information.
-# Not all architectures require this. But if yours does (you'll know because
-# this file will be created when you run Apache) then you *must* ensure that
-# no two invocations of Apache share the same scoreboard file.
-#
-ScoreBoardFile logs/apache_status
-
-#
-# In the standard configuration, the server will process httpd.conf,
-# srm.conf, and access.conf in that order. The latter two files are
-# now distributed empty, as it is recommended that all directives
-# be kept in a single file for simplicity. The commented-out values
-# below are the built-in defaults. You can have the server ignore
-# these files altogether by using "/dev/null" (for Unix) or
-# "nul" (for Win32) for the arguments to the directives.
-#
-#ResourceConfig conf/srm.conf
-#AccessConfig conf/access.conf
-
-#
-# Timeout: The number of seconds before receives and sends time out.
-#
-Timeout 300
-
-#
-# KeepAlive: Whether or not to allow persistent connections (more than
-# one request per connection). Set to "Off" to deactivate.
-#
-KeepAlive On
-
-#
-# MaxKeepAliveRequests: The maximum number of requests to allow
-# during a persistent connection. Set to 0 to allow an unlimited amount.
-# We reccomend you leave this number high, for maximum performance.
-#
-MaxKeepAliveRequests 100
-
-#
-# KeepAliveTimeout: Number of seconds to wait for the next request from the
-# same client on the same connection.
-#
-KeepAliveTimeout 15
-
-#
-# Apache on Win32 always creates one child process to handle requests. If it
-# dies, another child process is created automatically. Within the child
-# process multiple threads handle incoming requests. The next two
-# directives control the behaviour of the threads and processes.
-#
-
-#
-# MaxRequestsPerChild: the number of requests each child process is
-# allowed to process before the child dies. The child will exit so
-# as to avoid problems after prolonged use when Apache (and maybe the
-# libraries it uses) leak memory or other resources. On most systems, this
-# isn't really needed, but a few (such as Solaris) do have notable leaks
-# in the libraries. For Win32, set this value to zero (unlimited)
-# unless advised otherwise.
-#
-MaxRequestsPerChild 0
-
-#
-# Number of concurrent threads (i.e., requests) the server will allow.
-# Set this value according to the responsiveness of the server (more
-# requests active at once means they're all handled more slowly) and
-# the amount of system resources you'll allow the server to consume.
-#
-ThreadsPerChild 50
-
-#
-# Listen: Allows you to bind Apache to specific IP addresses and/or
-# ports, in addition to the default. See also the <VirtualHost>
-# directive.
-#
-#Listen 3000
-#Listen 12.34.56.78:80
-
-#
-# BindAddress: You can support virtual hosts with this option. This directive
-# is used to tell the server which IP address to listen to. It can either
-# contain "*", an IP address, or a fully qualified Internet domain name.
-# See also the <VirtualHost> and Listen directives.
-#
-#BindAddress *
-
-#
-# Dynamic Shared Object (DSO) Support
-#
-# To be able to use the functionality of a module which was built as a DSO you
-# have to place corresponding `LoadModule' lines at this location so the
-# directives contained in it are actually available _before_ they are used.
-# Please read the file README.DSO in the Apache 1.3 distribution for more
-# details about the DSO mechanism and run `apache -l' for the list of already
-# built-in (statically linked and thus always available) modules in your Apache
-# binary.
-#
-# Note: The order in which modules are loaded is important. Don't change
-# the order below without expert advice.
-#
-#LoadModule anon_auth_module modules/ApacheModuleAuthAnon.dll
-#LoadModule cern_meta_module modules/ApacheModuleCERNMeta.dll
-#LoadModule digest_module modules/ApacheModuleDigest.dll
-#LoadModule expires_module modules/ApacheModuleExpires.dll
-#LoadModule headers_module modules/ApacheModuleHeaders.dll
-#LoadModule proxy_module modules/ApacheModuleProxy.dll
-#LoadModule rewrite_module modules/ApacheModuleRewrite.dll
-#LoadModule speling_module modules/ApacheModuleSpeling.dll
-#LoadModule status_module modules/ApacheModuleStatus.dll
-#LoadModule usertrack_module modules/ApacheModuleUserTrack.dll
-
-#
-# ExtendedStatus controls whether Apache will generate "full" status
-# information (ExtendedStatus On) or just basic information (ExtendedStatus
-# Off) when the "server-status" handler is called. The default is Off.
-#
-#ExtendedStatus On
-
-### Section 2: 'Main' server configuration
-#
-# The directives in this section set up the values used by the 'main'
-# server, which responds to any requests that aren't handled by a
-# <VirtualHost> definition. These values also provide defaults for
-# any <VirtualHost> containers you may define later in the file.
-#
-# All of these directives may appear inside <VirtualHost> containers,
-# in which case these default settings will be overridden for the
-# virtual host being defined.
-#
-
-#
-# If your ServerType directive (set earlier in the 'Global Environment'
-# section) is set to "inetd", the next few directives don't have any
-# effect since their settings are defined by the inetd configuration.
-# Skip ahead to the ServerAdmin directive.
-#
-
-#
-# Port: The port to which the standalone server listens.
-#
-Port 80
-
-#
-# ServerAdmin: Your address, where problems with the server should be
-# e-mailed. This address appears on some server-generated pages, such
-# as error documents.
-#
-ServerAdmin you@your.address
-
-#
-# ServerName allows you to set a host name which is sent back to clients for
-# your server if it's different than the one the program would get (i.e., use
-# "www" instead of the host's real name).
-#
-# Note: You cannot just invent host names and hope they work. The name you
-# define here must be a valid DNS name for your host. If you don't understand
-# this, ask your network administrator.
-# If your host doesn't have a registered DNS name, enter its IP address here.
-# You will have to access it by its address (e.g., http://123.45.67.89/)
-# anyway, and this will make redirections work in a sensible way.
-#
-#ServerName new.host.name
-
-#
-# DocumentRoot: The directory out of which you will serve your
-# documents. By default, all requests are taken from this directory, but
-# symbolic links and aliases may be used to point to other locations.
-#
-DocumentRoot "@@ServerRoot@@/htdocs"
-
-#
-# Each directory to which Apache has access, can be configured with respect
-# to which services and features are allowed and/or disabled in that
-# directory (and its subdirectories).
-#
-# First, we configure the "default" to be a very restrictive set of
-# permissions.
-#
-<Directory />
- Options FollowSymLinks
- AllowOverride None
-</Directory>
-
-#
-# Note that from this point forward you must specifically allow
-# particular features to be enabled - so if something's not working as
-# you might expect, make sure that you have specifically enabled it
-# below.
-#
-
-#
-# This should be changed to whatever you set DocumentRoot to.
-#
-<Directory "@@ServerRoot@@/htdocs">
-
-#
-# This may also be "None", "All", or any combination of "Indexes",
-# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
-#
-# Note that "MultiViews" must be named *explicitly* --- "Options All"
-# doesn't give it to you.
-#
- Options Indexes FollowSymLinks
-
-#
-# This controls which options the .htaccess files in directories can
-# override. Can also be "All", or any combination of "Options", "FileInfo",
-# "AuthConfig", and "Limit"
-#
- AllowOverride None
-
-#
-# Controls who can get stuff from this server.
-#
- Order allow,deny
- Allow from all
-</Directory>
-
-#
-# UserDir: The name of the directory which is appended onto a user's home
-# directory if a ~user request is received.
-#
-# Under Win32, we do not currently try to determine the home directory of
-# a Windows login, so a format such as that below needs to be used. See
-# the UserDir documentation for details.
-#
-UserDir "@@ServerRoot@@/users/"
-
-#
-# DirectoryIndex: Name of the file or files to use as a pre-written HTML
-# directory index. Separate multiple entries with spaces.
-#
-DirectoryIndex index.html
-
-#
-# AccessFileName: The name of the file to look for in each directory
-# for access control information.
-#
-AccessFileName .htaccess
-
-#
-# The following lines prevent .htaccess files from being viewed by
-# Web clients. Since .htaccess files often contain authorization
-# information, access is disallowed for security reasons. Comment
-# these lines out if you want Web visitors to see the contents of
-# .htaccess files. If you change the AccessFileName directive above,
-# be sure to make the corresponding changes here.
-#
-<Files .htaccess>
- Order allow,deny
- Deny from all
-</Files>
-
-#
-# CacheNegotiatedDocs: By default, Apache sends "Pragma: no-cache" with each
-# document that was negotiated on the basis of content. This asks proxy
-# servers not to cache the document. Uncommenting the following line disables
-# this behavior, and proxies will be allowed to cache the documents.
-#
-#CacheNegotiatedDocs
-
-#
-# UseCanonicalName: (new for 1.3) With this setting turned on, whenever
-# Apache needs to construct a self-referencing URL (a URL that refers back
-# to the server the response is coming from) it will use ServerName and
-# Port to form a "canonical" name. With this setting off, Apache will
-# use the hostname:port that the client supplied, when possible. This
-# also affects SERVER_NAME and SERVER_PORT in CGI scripts.
-#
-UseCanonicalName On
-
-#
-# TypesConfig describes where the mime.types file (or equivalent) is
-# to be found.
-#
-TypesConfig conf/mime.types
-
-#
-# DefaultType is the default MIME type the server will use for a document
-# if it cannot otherwise determine one, such as from filename extensions.
-# If your server contains mostly text or HTML documents, "text/plain" is
-# a good value. If most of your content is binary, such as applications
-# or images, you may want to use "application/octet-stream" instead to
-# keep browsers from trying to display binary files as though they are
-# text.
-#
-DefaultType text/plain
-
-#
-# The mod_mime_magic module allows the server to use various hints from the
-# contents of the file itself to determine its type. The MIMEMagicFile
-# directive tells the module where the hint definitions are located.
-# mod_mime_magic is not part of the default server (you have to add
-# it yourself with a LoadModule [see the DSO paragraph in the 'Global
-# Environment' section], or recompile the server and include mod_mime_magic
-# as part of the configuration), so it's enclosed in an <IfModule> container.
-# This means that the MIMEMagicFile directive will only be processed if the
-# module is part of the server.
-#
-<IfModule mod_mime_magic.c>
- MIMEMagicFile conf/magic
-</IfModule>
-
-#
-# HostnameLookups: Log the names of clients or just their IP addresses
-# e.g., www.apache.org (on) or 204.62.129.132 (off).
-# The default is off because it'd be overall better for the net if people
-# had to knowingly turn this feature on, since enabling it means that
-# each client request will result in AT LEAST one lookup request to the
-# nameserver.
-#
-HostnameLookups Off
-
-#
-# ErrorLog: The location of the error log file.
-# If you do not specify an ErrorLog directive within a <VirtualHost>
-# container, error messages relating to that virtual host will be
-# logged here. If you *do* define an error logfile for a <VirtualHost>
-# container, that host's errors will be logged there and not here.
-#
-ErrorLog logs/error.log
-
-#
-# LogLevel: Control the number of messages logged to the error.log.
-# Possible values include: debug, info, notice, warn, error, crit,
-# alert, emerg.
-#
-LogLevel warn
-
-#
-# The following directives define some format nicknames for use with
-# a CustomLog directive (see below).
-#
-LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
-LogFormat "%h %l %u %t \"%r\" %>s %b" common
-LogFormat "%{Referer}i -> %U" referer
-LogFormat "%{User-agent}i" agent
-
-#
-# The location and format of the access logfile (Common Logfile Format).
-# If you do not define any access logfiles within a <VirtualHost>
-# container, they will be logged here. Contrariwise, if you *do*
-# define per-<VirtualHost> access logfiles, transactions will be
-# logged therein and *not* in this file.
-#
-CustomLog logs/access.log common
-
-#
-# If you would like to have agent and referer logfiles, uncomment the
-# following directives.
-#
-#CustomLog logs/referer.log referer
-#CustomLog logs/agent.log agent
-
-#
-# If you prefer a single logfile with access, agent, and referer information
-# (Combined Logfile Format) you can use the following directive.
-#
-#CustomLog logs/access.log combined
-
-#
-# Optionally add a line containing the server version and virtual host
-# name to server-generated pages (error documents, FTP directory listings,
-# mod_status and mod_info output etc., but not CGI generated documents).
-# Set to "EMail" to also include a mailto: link to the ServerAdmin.
-# Set to one of: On | Off | EMail
-#
-ServerSignature On
-
-#
-# Aliases: Add here as many aliases as you need (with no limit). The format is
-# Alias fakename realname
-#
-# Note that if you include a trailing / on fakename then the server will
-# require it to be present in the URL. So "/icons" isn't aliased in this
-# example, only "/icons/"..
-#
-Alias /icons/ "@@ServerRoot@@/icons/"
-
-#
-# ScriptAlias: This controls which directories contain server scripts.
-# ScriptAliases are essentially the same as Aliases, except that
-# documents in the realname directory are treated as applications and
-# run by the server when requested rather than as documents sent to the client.
-# The same rules about trailing "/" apply to ScriptAlias directives as to
-# Alias.
-#
-ScriptAlias /cgi-bin/ "@@ServerRoot@@/cgi-bin/"
-
-#
-# "@@ServerRoot@@/cgi-bin" should be changed to whatever your ScriptAliased
-# CGI directory exists, if you have that configured.
-#
-<Directory "@@ServerRoot@@/cgi-bin">
- AllowOverride None
- Options None
-</Directory>
-
-#
-# Redirect allows you to tell clients about documents which used to exist in
-# your server's namespace, but do not anymore. This allows you to tell the
-# clients where to look for the relocated document.
-# Format: Redirect old-URI new-URL
-#
-
-#
-# Directives controlling the display of server-generated directory listings.
-#
-
-#
-# FancyIndexing is whether you want fancy directory indexing or standard
-#
-IndexOptions FancyIndexing
-
-#
-# AddIcon* directives tell the server which icon to show for different
-# files or filename extensions. These are only displayed for
-# FancyIndexed directories.
-#
-AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
-
-AddIconByType (TXT,/icons/text.gif) text/*
-AddIconByType (IMG,/icons/image2.gif) image/*
-AddIconByType (SND,/icons/sound2.gif) audio/*
-AddIconByType (VID,/icons/movie.gif) video/*
-
-AddIcon /icons/binary.gif .bin .exe
-AddIcon /icons/binhex.gif .hqx
-AddIcon /icons/tar.gif .tar
-AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
-AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
-AddIcon /icons/a.gif .ps .ai .eps
-AddIcon /icons/layout.gif .html .shtml .htm .pdf
-AddIcon /icons/text.gif .txt
-AddIcon /icons/c.gif .c
-AddIcon /icons/p.gif .pl .py
-AddIcon /icons/f.gif .for
-AddIcon /icons/dvi.gif .dvi
-AddIcon /icons/uuencoded.gif .uu
-AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
-AddIcon /icons/tex.gif .tex
-AddIcon /icons/bomb.gif core
-
-AddIcon /icons/back.gif ..
-AddIcon /icons/hand.right.gif README
-AddIcon /icons/folder.gif ^^DIRECTORY^^
-AddIcon /icons/blank.gif ^^BLANKICON^^
-
-#
-# DefaultIcon is which icon to show for files which do not have an icon
-# explicitly set.
-#
-DefaultIcon /icons/unknown.gif
-
-#
-# AddDescription allows you to place a short description after a file in
-# server-generated indexes. These are only displayed for FancyIndexed
-# directories.
-# Format: AddDescription "description" filename
-#
-#AddDescription "GZIP compressed document" .gz
-#AddDescription "tar archive" .tar
-#AddDescription "GZIP compressed tar archive" .tgz
-
-#
-# ReadmeName is the name of the README file the server will look for by
-# default, and append to directory listings.
-#
-# HeaderName is the name of a file which should be prepended to
-# directory indexes.
-#
-# The server will first look for name.html and include it if found.
-# If name.html doesn't exist, the server will then look for name.txt
-# and include it as plaintext if found.
-#
-ReadmeName README
-HeaderName HEADER
-
-#
-# IndexIgnore is a set of filenames which directory indexing should ignore
-# and not include in the listing. Shell-style wildcarding is permitted.
-#
-IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
-
-#
-# AddEncoding allows you to have certain browsers (Mosaic/X 2.1+) uncompress
-# information on the fly. Note: Not all browsers support this.
-# Despite the name similarity, the following Add* directives have nothing
-# to do with the FancyIndexing customisation directives above.
-#
-AddEncoding x-compress Z
-AddEncoding x-gzip gz tgz
-
-#
-# AddLanguage allows you to specify the language of a document. You can
-# then use content negotiation to give a browser a file in a language
-# it can understand. Note that the suffix does not have to be the same
-# as the language keyword --- those with documents in Polish (whose
-# net-standard language code is pl) may wish to use "AddLanguage pl .po"
-# to avoid the ambiguity with the common suffix for perl scripts.
-#
-AddLanguage en .en
-AddLanguage fr .fr
-AddLanguage de .de
-AddLanguage da .da
-AddLanguage el .el
-AddLanguage it .it
-
-#
-# LanguagePriority allows you to give precedence to some languages
-# in case of a tie during content negotiation.
-# Just list the languages in decreasing order of preference.
-#
-LanguagePriority en fr de
-
-#
-# AddType allows you to tweak mime.types without actually editing it, or to
-# make certain files to be certain types.
-#
-# For example, the PHP3 module (not part of the Apache distribution)
-# will typically use:
-#
-#AddType application/x-httpd-php3 .phtml
-#AddType application/x-httpd-php3-source .phps
-
-AddType application/x-tar .tgz
-
-#
-# AddHandler allows you to map certain file extensions to "handlers",
-# actions unrelated to filetype. These can be either built into the server
-# or added with the Action command (see below)
-#
-# If you want to use server side includes, or CGI outside
-# ScriptAliased directories, uncomment the following lines.
-#
-# To use CGI scripts:
-#
-#AddHandler cgi-script .cgi
-
-#
-# To use server-parsed HTML files
-#
-#AddType text/html .shtml
-#AddHandler server-parsed .shtml
-
-#
-# Uncomment the following line to enable Apache's send-asis HTTP file
-# feature
-#
-#AddHandler send-as-is asis
-
-#
-# If you wish to use server-parsed imagemap files, use
-#
-#AddHandler imap-file map
-
-#
-# To enable type maps, you might want to use
-#
-#AddHandler type-map var
-
-#
-# Action lets you define media types that will execute a script whenever
-# a matching file is called. This eliminates the need for repeated URL
-# pathnames for oft-used CGI file processors.
-# Format: Action media/type /cgi-script/location
-# Format: Action handler-name /cgi-script/location
-#
-
-#
-# MetaDir: specifies the name of the directory in which Apache can find
-# meta information files. These files contain additional HTTP headers
-# to include when sending the document
-#
-#MetaDir .web
-
-#
-# MetaSuffix: specifies the file name suffix for the file containing the
-# meta information.
-#
-#MetaSuffix .meta
-
-#
-# Customizable error response (Apache style)
-# these come in three flavors
-#
-# 1) plain text
-#ErrorDocument 500 "The server made a boo boo.
-# n.b. the (") marks it as text, it does not get output
-#
-# 2) local redirects
-#ErrorDocument 404 /missing.html
-# to redirect to local URL /missing.html
-#ErrorDocument 404 /cgi-bin/missing_handler.pl
-# N.B.: You can redirect to a script or a document using server-side-includes.
-#
-# 3) external redirects
-#ErrorDocument 402 http://some.other_server.com/subscription_info.html
-# N.B.: Many of the environment variables associated with the original
-# request will *not* be available to such a script.
-
-#
-# The following directives disable keepalives and HTTP header flushes.
-# The first directive disables it for Netscape 2.x and browsers which
-# spoof it. There are known problems with these.
-# The second directive is for Microsoft Internet Explorer 4.0b2
-# which has a broken HTTP/1.1 implementation and does not properly
-# support keepalive when it is used on 301 or 302 (redirect) responses.
-#
-BrowserMatch "Mozilla/2" nokeepalive
-BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
-
-#
-# The following directive disables HTTP/1.1 responses to browsers which
-# are in violation of the HTTP/1.0 spec by not being able to grok a
-# basic 1.1 response.
-#
-BrowserMatch "RealPlayer 4\.0" force-response-1.0
-BrowserMatch "Java/1\.0" force-response-1.0
-BrowserMatch "JDK/1\.0" force-response-1.0
-
-#
-# Allow server status reports, with the URL of http://servername/server-status
-# Change the ".your_domain.com" to match your domain to enable.
-#
-#<Location /server-status>
-# SetHandler server-status
-# Order deny,allow
-# Deny from all
-# Allow from .your_domain.com
-#</Location>
-
-#
-# Allow remote server configuration reports, with the URL of
-# http://servername/server-info (requires that mod_info.c be loaded).
-# Change the ".your_domain.com" to match your domain to enable.
-#
-#<Location /server-info>
-# SetHandler server-info
-# Order deny,allow
-# Deny from all
-# Allow from .your_domain.com
-#</Location>
-
-#
-# There have been reports of people trying to abuse an old bug from pre-1.1
-# days. This bug involved a CGI script distributed as a part of Apache.
-# By uncommenting these lines you can redirect these attacks to a logging
-# script on phf.apache.org. Or, you can record them yourself, using the script
-# support/phf_abuse_log.cgi.
-#
-#<Location /cgi-bin/phf*>
-# Deny from all
-# ErrorDocument 403 http://phf.apache.org/phf_abuse_log.cgi
-#</Location>
-
-#
-# Proxy Server directives. Uncomment the following line to
-# enable the proxy server:
-#
-#ProxyRequests On
-
-#
-# Enable/disable the handling of HTTP/1.1 "Via:" headers.
-# ("Full" adds the server version; "Block" removes all outgoing Via: headers)
-# Set to one of: Off | On | Full | Block
-#
-#ProxyVia On
-
-#
-# To enable the cache as well, edit and uncomment the following lines:
-# (no cacheing without CacheRoot)
-#
-#CacheRoot "@@ServerRoot@@/proxy"
-#CacheSize 5
-#CacheGcInterval 4
-#CacheMaxExpire 24
-#CacheLastModifiedFactor 0.1
-#CacheDefaultExpire 1
-#NoCache a_domain.com another_domain.edu joes.garage_sale.com
-
-### Section 3: Virtual Hosts
-#
-# VirtualHost: If you want to maintain multiple domains/hostnames on your
-# machine you can setup VirtualHost containers for them.
-# Please see the documentation at <URL:http://www.apache.org/docs/vhosts/>
-# for further details before you try to setup virtual hosts.
-# You may use the command line option '-S' to verify your virtual host
-# configuration.
-
-#
-# If you want to use name-based virtual hosts you need to define at
-# least one IP address (and port number) for them.
-#
-#NameVirtualHost 12.34.56.78:80
-#NameVirtualHost 12.34.56.78
-
-#
-# VirtualHost example:
-# Almost any Apache directive may go into a VirtualHost container.
-#
-#<VirtualHost ip.address.of.host.some_domain.com>
-# ServerAdmin webmaster@host.some_domain.com
-# DocumentRoot /www/docs/host.some_domain.com
-# ServerName host.some_domain.com
-# ErrorLog logs/host.some_domain.com-error_log
-# CustomLog logs/host.some_domain.com-access_log common
-#</VirtualHost>
-
-#<VirtualHost _default_:*>
-#</VirtualHost>
diff --git a/docs/conf/magic b/docs/conf/magic
deleted file mode 100644
index 885b793aec..0000000000
--- a/docs/conf/magic
+++ /dev/null
@@ -1,371 +0,0 @@
-# Magic data for mod_mime_magic Apache module (originally for file(1) command)
-# The module is described in htdocs/manual/mod/mod_mime_magic.html
-#
-# The format is 4-5 columns:
-# Column #1: byte number to begin checking from, ">" indicates continuation
-# Column #2: type of data to match
-# Column #3: contents of data to match
-# Column #4: MIME type of result
-# Column #5: MIME encoding of result (optional)
-
-#------------------------------------------------------------------------------
-# Localstuff: file(1) magic for locally observed files
-# Add any locally observed files here.
-
-#------------------------------------------------------------------------------
-# end local stuff
-#------------------------------------------------------------------------------
-
-#------------------------------------------------------------------------------
-# Java
-
-0 short 0xcafe
->2 short 0xbabe application/java
-
-#------------------------------------------------------------------------------
-# audio: file(1) magic for sound formats
-#
-# from Jan Nicolai Langfeldt <janl@ifi.uio.no>,
-#
-
-# Sun/NeXT audio data
-0 string .snd
->12 belong 1 audio/basic
->12 belong 2 audio/basic
->12 belong 3 audio/basic
->12 belong 4 audio/basic
->12 belong 5 audio/basic
->12 belong 6 audio/basic
->12 belong 7 audio/basic
-
->12 belong 23 audio/x-adpcm
-
-# DEC systems (e.g. DECstation 5000) use a variant of the Sun/NeXT format
-# that uses little-endian encoding and has a different magic number
-# (0x0064732E in little-endian encoding).
-0 lelong 0x0064732E
->12 lelong 1 audio/x-dec-basic
->12 lelong 2 audio/x-dec-basic
->12 lelong 3 audio/x-dec-basic
->12 lelong 4 audio/x-dec-basic
->12 lelong 5 audio/x-dec-basic
->12 lelong 6 audio/x-dec-basic
->12 lelong 7 audio/x-dec-basic
-# compressed (G.721 ADPCM)
->12 lelong 23 audio/x-dec-adpcm
-
-# Bytes 0-3 of AIFF, AIFF-C, & 8SVX audio files are "FORM"
-# AIFF audio data
-8 string AIFF audio/x-aiff
-# AIFF-C audio data
-8 string AIFC audio/x-aiff
-# IFF/8SVX audio data
-8 string 8SVX audio/x-aiff
-
-# Creative Labs AUDIO stuff
-# Standard MIDI data
-0 string MThd audio/unknown
-#>9 byte >0 (format %d)
-#>11 byte >1 using %d channels
-# Creative Music (CMF) data
-0 string CTMF audio/unknown
-# SoundBlaster instrument data
-0 string SBI audio/unknown
-# Creative Labs voice data
-0 string Creative\ Voice\ File audio/unknown
-## is this next line right? it came this way...
-#>19 byte 0x1A
-#>23 byte >0 - version %d
-#>22 byte >0 \b.%d
-
-# [GRR 950115: is this also Creative Labs? Guessing that first line
-# should be string instead of unknown-endian long...]
-#0 long 0x4e54524b MultiTrack sound data
-#0 string NTRK MultiTrack sound data
-#>4 long x - version %ld
-
-# Microsoft WAVE format (*.wav)
-# [GRR 950115: probably all of the shorts and longs should be leshort/lelong]
-# Microsoft RIFF
-0 string RIFF audio/unknown
-# - WAVE format
->8 string WAVE audio/x-wav
-
-#------------------------------------------------------------------------------
-# c-lang: file(1) magic for C programs or various scripts
-#
-
-# XPM icons (Greg Roelofs, newt@uchicago.edu)
-# ideally should go into "images", but entries below would tag XPM as C source
-0 string /*\ XPM image/x-xbm 7bit
-
-# this first will upset you if you're a PL/1 shop... (are there any left?)
-# in which case rm it; ascmagic will catch real C programs
-# C or REXX program text
-0 string /* text/plain
-# C++ program text
-0 string // text/plain
-
-#------------------------------------------------------------------------------
-# compress: file(1) magic for pure-compression formats (no archives)
-#
-# compress, gzip, pack, compact, huf, squeeze, crunch, freeze, yabba, whap, etc.
-#
-# Formats for various forms of compressed data
-# Formats for "compress" proper have been moved into "compress.c",
-# because it tries to uncompress it to figure out what's inside.
-
-# standard unix compress
-0 string \037\235 application/octet-stream x-compress
-
-# gzip (GNU zip, not to be confused with [Info-ZIP/PKWARE] zip archiver)
-0 string \037\213 application/octet-stream x-gzip
-
-# According to gzip.h, this is the correct byte order for packed data.
-0 string \037\036 application/octet-stream
-#
-# This magic number is byte-order-independent.
-#
-0 short 017437 application/octet-stream
-
-# XXX - why *two* entries for "compacted data", one of which is
-# byte-order independent, and one of which is byte-order dependent?
-#
-# compacted data
-0 short 0x1fff application/octet-stream
-0 string \377\037 application/octet-stream
-# huf output
-0 short 0145405 application/octet-stream
-
-# Squeeze and Crunch...
-# These numbers were gleaned from the Unix versions of the programs to
-# handle these formats. Note that I can only uncrunch, not crunch, and
-# I didn't have a crunched file handy, so the crunch number is untested.
-# Keith Waclena <keith@cerberus.uchicago.edu>
-#0 leshort 0x76FF squeezed data (CP/M, DOS)
-#0 leshort 0x76FE crunched data (CP/M, DOS)
-
-# Freeze
-#0 string \037\237 Frozen file 2.1
-#0 string \037\236 Frozen file 1.0 (or gzip 0.5)
-
-# lzh?
-#0 string \037\240 LZH compressed data
-
-#------------------------------------------------------------------------------
-# frame: file(1) magic for FrameMaker files
-#
-# This stuff came on a FrameMaker demo tape, most of which is
-# copyright, but this file is "published" as witness the following:
-#
-0 string \<MakerFile application/x-frame
-0 string \<MIFFile application/x-frame
-0 string \<MakerDictionary application/x-frame
-0 string \<MakerScreenFon application/x-frame
-0 string \<MML application/x-frame
-0 string \<Book application/x-frame
-0 string \<Maker application/x-frame
-
-#------------------------------------------------------------------------------
-# html: file(1) magic for HTML (HyperText Markup Language) docs
-#
-# from Daniel Quinlan <quinlan@yggdrasil.com>
-# and Anna Shergold <anna@inext.co.uk>
-#
-0 string \<!DOCTYPE\ HTML text/html
-0 string \<!doctype\ html text/html
-0 string \<HEAD text/html
-0 string \<head text/html
-0 string \<TITLE text/html
-0 string \<title text/html
-0 string \<html text/html
-0 string \<HTML text/html
-0 string \<!-- text/html
-0 string \<h1 text/html
-0 string \<H1 text/html
-
-#------------------------------------------------------------------------------
-# images: file(1) magic for image formats (see also "c-lang" for XPM bitmaps)
-#
-# originally from jef@helios.ee.lbl.gov (Jef Poskanzer),
-# additions by janl@ifi.uio.no as well as others. Jan also suggested
-# merging several one- and two-line files into here.
-#
-# XXX - byte order for GIF and TIFF fields?
-# [GRR: TIFF allows both byte orders; GIF is probably little-endian]
-#
-
-# [GRR: what the hell is this doing in here?]
-#0 string xbtoa btoa'd file
-
-# PBMPLUS
-# PBM file
-0 string P1 image/x-portable-bitmap 7bit
-# PGM file
-0 string P2 image/x-portable-greymap 7bit
-# PPM file
-0 string P3 image/x-portable-pixmap 7bit
-# PBM "rawbits" file
-0 string P4 image/x-portable-bitmap
-# PGM "rawbits" file
-0 string P5 image/x-portable-greymap
-# PPM "rawbits" file
-0 string P6 image/x-portable-pixmap
-
-# NIFF (Navy Interchange File Format, a modification of TIFF)
-# [GRR: this *must* go before TIFF]
-0 string IIN1 image/x-niff
-
-# TIFF and friends
-# TIFF file, big-endian
-0 string MM image/tiff
-# TIFF file, little-endian
-0 string II image/tiff
-
-# possible GIF replacements; none yet released!
-# (Greg Roelofs, newt@uchicago.edu)
-#
-# GRR 950115: this was mine ("Zip GIF"):
-# ZIF image (GIF+deflate alpha)
-0 string GIF94z image/unknown
-#
-# GRR 950115: this is Jeremy Wohl's Free Graphics Format (better):
-# FGF image (GIF+deflate beta)
-0 string FGF95a image/unknown
-#
-# GRR 950115: this is Thomas Boutell's Portable Bitmap Format proposal
-# (best; not yet implemented):
-# PBF image (deflate compression)
-0 string PBF image/unknown
-
-# GIF
-0 string GIF image/gif
-
-# JPEG images
-0 beshort 0xffd8 image/jpeg
-
-# PC bitmaps (OS/2, Windoze BMP files) (Greg Roelofs, newt@uchicago.edu)
-0 string BM image/bmp
-#>14 byte 12 (OS/2 1.x format)
-#>14 byte 64 (OS/2 2.x format)
-#>14 byte 40 (Windows 3.x format)
-#0 string IC icon
-#0 string PI pointer
-#0 string CI color icon
-#0 string CP color pointer
-#0 string BA bitmap array
-
-
-#------------------------------------------------------------------------------
-# lisp: file(1) magic for lisp programs
-#
-# various lisp types, from Daniel Quinlan (quinlan@yggdrasil.com)
-0 string ;; text/plain 8bit
-# Emacs 18 - this is always correct, but not very magical.
-0 string \012( application/x-elc
-# Emacs 19
-0 string ;ELC\023\000\000\000 application/x-elc
-
-#------------------------------------------------------------------------------
-# mail.news: file(1) magic for mail and news
-#
-# There are tests to ascmagic.c to cope with mail and news.
-0 string Relay-Version: message/rfc822 7bit
-0 string #!\ rnews message/rfc822 7bit
-0 string N#!\ rnews message/rfc822 7bit
-0 string Forward\ to message/rfc822 7bit
-0 string Pipe\ to message/rfc822 7bit
-0 string Return-Path: message/rfc822 7bit
-0 string Path: message/news 8bit
-0 string Xref: message/news 8bit
-0 string From: message/rfc822 7bit
-0 string Article message/news 8bit
-#------------------------------------------------------------------------------
-# msword: file(1) magic for MS Word files
-#
-# Contributor claims:
-# Reversed-engineered MS Word magic numbers
-#
-
-0 string \376\067\0\043 application/msword
-0 string \333\245-\0\0\0 application/msword
-
-# disable this one because it applies also to other
-# Office/OLE documents for which msword is not correct. See PR#2608.
-#0 string \320\317\021\340\241\261 application/msword
-
-
-
-#------------------------------------------------------------------------------
-# printer: file(1) magic for printer-formatted files
-#
-
-# PostScript
-0 string %! application/postscript
-0 string \004%! application/postscript
-
-# Acrobat
-# (due to clamen@cs.cmu.edu)
-0 string %PDF- application/pdf
-
-#------------------------------------------------------------------------------
-# sc: file(1) magic for "sc" spreadsheet
-#
-38 string Spreadsheet application/x-sc
-
-#------------------------------------------------------------------------------
-# tex: file(1) magic for TeX files
-#
-# XXX - needs byte-endian stuff (big-endian and little-endian DVI?)
-#
-# From <conklin@talisman.kaleida.com>
-
-# Although we may know the offset of certain text fields in TeX DVI
-# and font files, we can't use them reliably because they are not
-# zero terminated. [but we do anyway, christos]
-0 string \367\002 application/x-dvi
-#0 string \367\203 TeX generic font data
-#0 string \367\131 TeX packed font data
-#0 string \367\312 TeX virtual font data
-#0 string This\ is\ TeX, TeX transcript text
-#0 string This\ is\ METAFONT, METAFONT transcript text
-
-# There is no way to detect TeX Font Metric (*.tfm) files without
-# breaking them apart and reading the data. The following patterns
-# match most *.tfm files generated by METAFONT or afm2tfm.
-#2 string \000\021 TeX font metric data
-#2 string \000\022 TeX font metric data
-#>34 string >\0 (%s)
-
-# Texinfo and GNU Info, from Daniel Quinlan (quinlan@yggdrasil.com)
-#0 string \\input\ texinfo Texinfo source text
-#0 string This\ is\ Info\ file GNU Info text
-
-# correct TeX magic for Linux (and maybe more)
-# from Peter Tobias (tobias@server.et-inf.fho-emden.de)
-#
-0 leshort 0x02f7 application/x-dvi
-
-# RTF - Rich Text Format
-0 string {\\rtf application/rtf
-
-#------------------------------------------------------------------------------
-# animation: file(1) magic for animation/movie formats
-#
-# animation formats, originally from vax@ccwf.cc.utexas.edu (VaX#n8)
-# MPEG file
-0 string \000\000\001\263 video/mpeg
-#
-# The contributor claims:
-# I couldn't find a real magic number for these, however, this
-# -appears- to work. Note that it might catch other files, too,
-# so BE CAREFUL!
-#
-# Note that title and author appear in the two 20-byte chunks
-# at decimal offsets 2 and 22, respectively, but they are XOR'ed with
-# 255 (hex FF)! DL format SUCKS BIG ROCKS.
-#
-# DL file version 1 , medium format (160x100, 4 images/screen)
-0 byte 1 video/unknown
-0 byte 2 video/unknown
-
diff --git a/docs/conf/mime.types b/docs/conf/mime.types
deleted file mode 100644
index 0e6ccc4d11..0000000000
--- a/docs/conf/mime.types
+++ /dev/null
@@ -1,373 +0,0 @@
-# This is a comment. I love comments.
-
-# This file controls what Internet media types are sent to the client for
-# given file extension(s). Sending the correct media type to the client
-# is important so they know how to handle the content of the file.
-# Extra types can either be added here or by using an AddType directive
-# in your config files. For more information about Internet media types,
-# please read RFC 2045, 2046, 2047, 2048, and 2077. The Internet media type
-# registry is at <ftp://ftp.iana.org/in-notes/iana/assignments/media-types/>.
-
-# MIME type Extension
-application/EDI-Consent
-application/EDI-X12
-application/EDIFACT
-application/activemessage
-application/andrew-inset ez
-application/applefile
-application/atomicmail
-application/batch-smtp
-application/cals-1840
-application/commonground
-application/cybercash
-application/dca-rft
-application/dec-dx
-application/eshop
-application/http
-application/hyperstudio
-application/iges
-application/index
-application/index.cmd
-application/index.obj
-application/index.response
-application/index.vnd
-application/ipp
-application/mac-binhex40 hqx
-application/mac-compactpro cpt
-application/macwriteii
-application/marc
-application/mathematica
-application/mathematica-old
-application/msword doc
-application/news-message-id
-application/news-transmission
-application/ocsp-request
-application/ocsp-response
-application/octet-stream bin dms lha lzh exe class
-application/oda oda
-application/pdf pdf
-application/pgp-encrypted
-application/pgp-keys
-application/pgp-signature
-application/pkcs10
-application/pkcs7-mime
-application/pkcs7-signature
-application/pkix-cert
-application/pkix-crl
-application/pkixcmp
-application/postscript ai eps ps
-application/prs.alvestrand.titrax-sheet
-application/prs.cww
-application/prs.nprend
-application/remote-printing
-application/riscos
-application/rtf rtf
-application/sdp
-application/set-payment
-application/set-payment-initiation
-application/set-registration
-application/set-registration-initiation
-application/sgml
-application/sgml-open-catalog
-application/slate
-application/smil smi smil
-application/vemmi
-application/vnd.3M.Post-it-Notes
-application/vnd.FloGraphIt
-application/vnd.accpac.simply.aso
-application/vnd.accpac.simply.imp
-application/vnd.acucobol
-application/vnd.anser-web-certificate-issue-initiation
-application/vnd.anser-web-funds-transfer-initiation
-application/vnd.audiograph
-application/vnd.businessobjects
-application/vnd.claymore
-application/vnd.commerce-battelle
-application/vnd.commonspace
-application/vnd.comsocaller
-application/vnd.cosmocaller
-application/vnd.cups-postscript
-application/vnd.cups-raster
-application/vnd.cups-raw
-application/vnd.cybank
-application/vnd.dna
-application/vnd.dpgraph
-application/vnd.dxr
-application/vnd.ecdis-update
-application/vnd.ecowin.chart
-application/vnd.ecowin.filerequest
-application/vnd.ecowin.fileupdate
-application/vnd.ecowin.series
-application/vnd.ecowin.seriesrequest
-application/vnd.ecowin.seriesupdate
-application/vnd.enliven
-application/vnd.epson.msf
-application/vnd.epson.quickanime
-application/vnd.epson.salt
-application/vnd.epson.ssf
-application/vnd.fdf
-application/vnd.ffsns
-application/vnd.framemaker
-application/vnd.fujitsu.oasys
-application/vnd.fujitsu.oasys2
-application/vnd.fujitsu.oasys3
-application/vnd.fujitsu.oasysgp
-application/vnd.fujitsu.oasysprs
-application/vnd.fujixerox.docuworks
-application/vnd.fut-misnet
-application/vnd.hp-HPGL
-application/vnd.hp-PCL
-application/vnd.hp-PCLXL
-application/vnd.hp-hpid
-application/vnd.hp-hps
-application/vnd.ibm.MiniPay
-application/vnd.ibm.modcap
-application/vnd.intercon.formnet
-application/vnd.intertrust.digibox
-application/vnd.intertrust.nncp
-application/vnd.intu.qbo
-application/vnd.intu.qfx
-application/vnd.is-xpr
-application/vnd.japannet-directory-service
-application/vnd.japannet-jpnstore-wakeup
-application/vnd.japannet-payment-wakeup
-application/vnd.japannet-registration
-application/vnd.japannet-registration-wakeup
-application/vnd.japannet-setstore-wakeup
-application/vnd.japannet-verification
-application/vnd.japannet-verification-wakeup
-application/vnd.koan
-application/vnd.lotus-1-2-3
-application/vnd.lotus-approach
-application/vnd.lotus-freelance
-application/vnd.lotus-notes
-application/vnd.lotus-organizer
-application/vnd.lotus-screencam
-application/vnd.lotus-wordpro
-application/vnd.mediastation.cdkey
-application/vnd.meridian-slingshot
-application/vnd.mif mif
-application/vnd.minisoft-hp3000-save
-application/vnd.mitsubishi.misty-guard.trustweb
-application/vnd.mobius.daf
-application/vnd.mobius.dis
-application/vnd.mobius.msl
-application/vnd.mobius.plc
-application/vnd.mobius.txf
-application/vnd.motorola.flexsuite
-application/vnd.motorola.flexsuite.adsi
-application/vnd.motorola.flexsuite.fis
-application/vnd.motorola.flexsuite.gotap
-application/vnd.motorola.flexsuite.kmr
-application/vnd.motorola.flexsuite.ttc
-application/vnd.motorola.flexsuite.wem
-application/vnd.ms-artgalry
-application/vnd.ms-asf
-application/vnd.ms-excel xls
-application/vnd.ms-powerpoint ppt
-application/vnd.ms-project
-application/vnd.ms-tnef
-application/vnd.ms-works
-application/vnd.music-niff
-application/vnd.musician
-application/vnd.netfpx
-application/vnd.noblenet-directory
-application/vnd.noblenet-sealer
-application/vnd.noblenet-web
-application/vnd.novadigm.EDM
-application/vnd.novadigm.EDX
-application/vnd.novadigm.EXT
-application/vnd.osa.netdeploy
-application/vnd.pg.format
-application/vnd.pg.osasli
-application/vnd.powerbuilder6
-application/vnd.powerbuilder6-s
-application/vnd.powerbuilder7
-application/vnd.powerbuilder7-s
-application/vnd.powerbuilder75
-application/vnd.powerbuilder75-s
-application/vnd.previewsystems.box
-application/vnd.publishare-delta-tree
-application/vnd.rapid
-application/vnd.seemail
-application/vnd.shana.informed.formdata
-application/vnd.shana.informed.formtemplate
-application/vnd.shana.informed.interchange
-application/vnd.shana.informed.package
-application/vnd.street-stream
-application/vnd.svd
-application/vnd.swiftview-ics
-application/vnd.triscape.mxs
-application/vnd.truedoc
-application/vnd.ufdl
-application/vnd.uplanet.alert
-application/vnd.uplanet.alert-wbxml
-application/vnd.uplanet.bearer-choi-wbxml
-application/vnd.uplanet.bearer-choice
-application/vnd.uplanet.cacheop
-application/vnd.uplanet.cacheop-wbxml
-application/vnd.uplanet.channel
-application/vnd.uplanet.channel-wbxml
-application/vnd.uplanet.list
-application/vnd.uplanet.list-wbxml
-application/vnd.uplanet.listcmd
-application/vnd.uplanet.listcmd-wbxml
-application/vnd.uplanet.signal
-application/vnd.vcx
-application/vnd.visio
-application/vnd.wap.wbxml
-application/vnd.wap.wmlc
-application/vnd.wap.wmlscriptc
-application/vnd.webturbo
-application/vnd.wrq-hp3000-labelled
-application/vnd.wt.stf
-application/vnd.xara
-application/vnd.xfdl
-application/vnd.yellowriver-custom-menu
-application/wita
-application/wordperfect5.1
-application/x-bcpio bcpio
-application/x-cdlink vcd
-application/x-chess-pgn pgn
-application/x-compress
-application/x-cpio cpio
-application/x-csh csh
-application/x-director dcr dir dxr
-application/x-dvi dvi
-application/x-futuresplash spl
-application/x-gtar gtar
-application/x-gzip
-application/x-hdf hdf
-application/x-javascript js
-application/x-koan skp skd skt skm
-application/x-latex latex
-application/x-netcdf nc cdf
-application/x-sh sh
-application/x-shar shar
-application/x-shockwave-flash swf
-application/x-stuffit sit
-application/x-sv4cpio sv4cpio
-application/x-sv4crc sv4crc
-application/x-tar tar
-application/x-tcl tcl
-application/x-tex tex
-application/x-texinfo texinfo texi
-application/x-troff t tr roff
-application/x-troff-man man
-application/x-troff-me me
-application/x-troff-ms ms
-application/x-ustar ustar
-application/x-wais-source src
-application/x400-bp
-application/xml
-application/zip zip
-audio/32kadpcm
-audio/basic au snd
-audio/l16
-audio/midi mid midi kar
-audio/mpeg mpga mp2 mp3
-audio/vnd.cns.anp1
-audio/vnd.cns.inf1
-audio/vnd.digital-winds
-audio/vnd.lucent.voice
-audio/vnd.nortel.vbk
-audio/vnd.octel.sbc
-audio/vnd.qcelp
-audio/vnd.rhetorex.32kadpcm
-audio/vnd.vmx.cvsd
-audio/x-aiff aif aiff aifc
-audio/x-pn-realaudio ram rm
-audio/x-pn-realaudio-plugin rpm
-audio/x-realaudio ra
-audio/x-wav wav
-chemical/x-pdb pdb xyz
-image/bmp bmp
-image/cgm
-image/g3fax
-image/gif gif
-image/ief ief
-image/jpeg jpeg jpg jpe
-image/naplps
-image/png png
-image/prs.btif
-image/prs.pti
-image/tiff tiff tif
-image/vnd.cns.inf2
-image/vnd.dwg
-image/vnd.dxf
-image/vnd.fastbidsheet
-image/vnd.fpx
-image/vnd.mix
-image/vnd.net-fpx
-image/vnd.svf
-image/vnd.wap.wbmp
-image/vnd.xiff
-image/x-cmu-raster ras
-image/x-portable-anymap pnm
-image/x-portable-bitmap pbm
-image/x-portable-graymap pgm
-image/x-portable-pixmap ppm
-image/x-rgb rgb
-image/x-xbitmap xbm
-image/x-xpixmap xpm
-image/x-xwindowdump xwd
-message/delivery-status
-message/disposition-notification
-message/external-body
-message/http
-message/news
-message/partial
-message/rfc822
-message/s-http
-model/iges igs iges
-model/mesh msh mesh silo
-model/vnd.dwf
-model/vnd.flatland.3dml
-model/vnd.gtw
-model/vrml wrl vrml
-multipart/alternative
-multipart/appledouble
-multipart/byteranges
-multipart/digest
-multipart/encrypted
-multipart/form-data
-multipart/header-set
-multipart/mixed
-multipart/parallel
-multipart/related
-multipart/report
-multipart/signed
-multipart/voice-message
-text/calendar
-text/css css
-text/directory
-text/enriched
-text/html html htm
-text/plain asc txt
-text/prs.lines.tag
-text/rfc822-headers
-text/richtext rtx
-text/rtf rtf
-text/sgml sgml sgm
-text/tab-separated-values tsv
-text/uri-list
-text/vnd.abc
-text/vnd.flatland.3dml
-text/vnd.fly
-text/vnd.fmi.flexstor
-text/vnd.in3d.3dml
-text/vnd.in3d.spot
-text/vnd.latex-z
-text/vnd.motorola.reflex
-text/vnd.wap.wml
-text/vnd.wap.wmlscript
-text/x-setext etx
-text/xml xml
-video/mpeg mpeg mpg mpe
-video/quicktime qt mov
-video/vnd.motorola.video
-video/vnd.motorola.videop
-video/vnd.vivo
-video/x-msvideo avi
-video/x-sgi-movie movie
-x-conference/x-cooltalk ice
diff --git a/docs/docroot/apache_pb.gif b/docs/docroot/apache_pb.gif
deleted file mode 100644
index 3a1c139fc4..0000000000
--- a/docs/docroot/apache_pb.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/README b/docs/icons/README
deleted file mode 100644
index 74b2970b9e..0000000000
--- a/docs/icons/README
+++ /dev/null
@@ -1,158 +0,0 @@
-Public Domain Icons
-
- These icons were originally made for Mosaic for X and have been
- included in the NCSA httpd and Apache server distributions in the
- past. They are in the public domain and may be freely included in any
- application. The originals were done by Kevin Hughes
- (kevinh@kevcom.com).
-
- Many thanks to Andy Polyakov for tuning the icon colors and adding a
- few new images. If you'd like to contribute additions or ideas to
- this set, please let me know.
-
- Almost all of these icons are 20x22 pixels in size. There are
- alternative icons in the "small" directory that are 16x16 in size,
- provided by Mike Brown (mike@hyperreal.org).
-
-Suggested Uses
-
-The following are a few suggestions, to serve as a starting point for ideas.
-Please feel free to tweak and rename the icons as you like.
-
- a.gif
- This might be used to represent PostScript or text layout
- languages.
-
- alert.black.gif, alert.red.gif
- These can be used to highlight any important items, such as a
- README file in a directory.
-
- back.gif, forward.gif
- These can be used as links to go to previous and next areas.
-
- ball.gray.gif, ball.red.gif
- These might be used as bullets.
-
- binary.gif
- This can be used to represent binary files.
-
- binhex.gif
- This can represent BinHex-encoded data.
-
- blank.gif
- This can be used as a placeholder or a spacing element.
-
- bomb.gif
- This can be used to repreesnt core files.
-
- box1.gif, box2.gif
- These icons can be used to represent generic 3D applications and
- related files.
-
- broken.gif
- This can represent corrupted data.
-
- burst.gif
- This can call attention to new and important items.
-
- c.gif
- This might represent C source code.
-
- comp.blue.gif, comp.red.gif
- These little computer icons can stand for telnet or FTP
- sessions.
-
- compressed.gif
- This may represent compressed data.
-
- continued.gif
- This can be a link to a continued listing of a directory.
-
- down.gif, up.gif, left.gif, right.gif
- These can be used to scroll up, down, left and right in a
- listing or may be used to denote items in an outline.
-
- dvi.gif
- This can represent DVI files.
-
- f.gif
- This might represent FORTRAN or Forth source code.
-
- folder.gif, folder.open.gif, folder.sec.gif
- The folder can represent directories. There is also a version
- that can represent secure directories or directories that cannot
- be viewed.
-
- generic.gif, generic.sec.gif, generic.red.gif
- These can represent generic files, secure files, and important
- files, respectively.
-
- hand.right.gif, hand.up.gif
- These can point out important items (pun intended).
-
- image1.gif, image2.gif, image3.gif
- These can represent image formats of various types.
-
- index.gif
- This might represent a WAIS index or search facility.
-
- layout.gif
- This might represent files and formats that contain graphics as
- well as text layout, such as HTML and PDF files.
-
- link.gif
- This might represent files that are symbolic links.
-
- movie.gif
- This can represent various movie formats.
-
- p.gif
- This may stand for Perl or Python source code.
-
- pie0.gif ... pie8.gif
- These icons can be used in applications where a list of
- documents is returned from a search. The little pie chart images
- can denote how relevant the documents may be to your search
- query.
-
- patch.gif
- This may stand for patches and diff files.
-
- portal.gif
- This might be a link to an online service or a 3D world.
-
- ps.gif, quill.gif
- These may represent PostScript files.
-
- screw1.gif, screw2.gif
- These may represent CAD or engineering data and formats.
-
- script.gif
- This can represent any of various interpreted languages, such as
- Perl, python, TCL, and shell scripts, as well as server
- configuration files.
-
- sound1.gif, sound2.gif
- These can represent sound files.
-
- sphere1.gif, sphere2.gif
- These can represent 3D worlds or rendering applications and
- formats.
-
- tex.gif
- This can represent TeX files.
-
- text.gif
- This can represent generic (plain) text files.
-
- transfer.gif
- This can represent FTP transfers or uploads/downloads.
-
- unknown.gif
- This may represent a file of an unknown type.
-
- uuencoded.gif
- This can stand for uuencoded data.
-
- world1.gif, world2.gif
- These can represent 3D worlds or other 3D formats.
diff --git a/docs/icons/a.gif b/docs/icons/a.gif
deleted file mode 100644
index bb23d971f4..0000000000
--- a/docs/icons/a.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/alert.black.gif b/docs/icons/alert.black.gif
deleted file mode 100644
index eaecd2172a..0000000000
--- a/docs/icons/alert.black.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/alert.red.gif b/docs/icons/alert.red.gif
deleted file mode 100644
index a423894043..0000000000
--- a/docs/icons/alert.red.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/apache_pb.gif b/docs/icons/apache_pb.gif
deleted file mode 100644
index 3a1c139fc4..0000000000
--- a/docs/icons/apache_pb.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/back.gif b/docs/icons/back.gif
deleted file mode 100644
index a694ae1ec3..0000000000
--- a/docs/icons/back.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/ball.gray.gif b/docs/icons/ball.gray.gif
deleted file mode 100644
index eb84268c4c..0000000000
--- a/docs/icons/ball.gray.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/ball.red.gif b/docs/icons/ball.red.gif
deleted file mode 100644
index a8425cb574..0000000000
--- a/docs/icons/ball.red.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/binary.gif b/docs/icons/binary.gif
deleted file mode 100644
index 9a15cbae04..0000000000
--- a/docs/icons/binary.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/binhex.gif b/docs/icons/binhex.gif
deleted file mode 100644
index 62d0363108..0000000000
--- a/docs/icons/binhex.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/blank.gif b/docs/icons/blank.gif
deleted file mode 100644
index 0ccf01e198..0000000000
--- a/docs/icons/blank.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/bomb.gif b/docs/icons/bomb.gif
deleted file mode 100644
index 270fdb1c06..0000000000
--- a/docs/icons/bomb.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/box1.gif b/docs/icons/box1.gif
deleted file mode 100644
index 65dcd002ea..0000000000
--- a/docs/icons/box1.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/box2.gif b/docs/icons/box2.gif
deleted file mode 100644
index c43bc4faec..0000000000
--- a/docs/icons/box2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/broken.gif b/docs/icons/broken.gif
deleted file mode 100644
index 9f8cbe9f76..0000000000
--- a/docs/icons/broken.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/burst.gif b/docs/icons/burst.gif
deleted file mode 100644
index fbdcf575f7..0000000000
--- a/docs/icons/burst.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/c.gif b/docs/icons/c.gif
deleted file mode 100644
index 7555b6c164..0000000000
--- a/docs/icons/c.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/comp.blue.gif b/docs/icons/comp.blue.gif
deleted file mode 100644
index f8d76a8c23..0000000000
--- a/docs/icons/comp.blue.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/comp.gray.gif b/docs/icons/comp.gray.gif
deleted file mode 100644
index 7664cd0364..0000000000
--- a/docs/icons/comp.gray.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/compressed.gif b/docs/icons/compressed.gif
deleted file mode 100644
index 39e732739f..0000000000
--- a/docs/icons/compressed.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/continued.gif b/docs/icons/continued.gif
deleted file mode 100644
index b0ffb7e0cc..0000000000
--- a/docs/icons/continued.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/dir.gif b/docs/icons/dir.gif
deleted file mode 100644
index 48264601ae..0000000000
--- a/docs/icons/dir.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/down.gif b/docs/icons/down.gif
deleted file mode 100644
index a354c871cd..0000000000
--- a/docs/icons/down.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/dvi.gif b/docs/icons/dvi.gif
deleted file mode 100644
index 791be33105..0000000000
--- a/docs/icons/dvi.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/f.gif b/docs/icons/f.gif
deleted file mode 100644
index fbe353c282..0000000000
--- a/docs/icons/f.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/folder.gif b/docs/icons/folder.gif
deleted file mode 100644
index 48264601ae..0000000000
--- a/docs/icons/folder.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/folder.open.gif b/docs/icons/folder.open.gif
deleted file mode 100644
index 30979cb528..0000000000
--- a/docs/icons/folder.open.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/folder.sec.gif b/docs/icons/folder.sec.gif
deleted file mode 100644
index 75332d9e59..0000000000
--- a/docs/icons/folder.sec.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/forward.gif b/docs/icons/forward.gif
deleted file mode 100644
index b2959b4c85..0000000000
--- a/docs/icons/forward.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/generic.gif b/docs/icons/generic.gif
deleted file mode 100644
index de60b2940f..0000000000
--- a/docs/icons/generic.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/generic.red.gif b/docs/icons/generic.red.gif
deleted file mode 100644
index 94743981d9..0000000000
--- a/docs/icons/generic.red.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/generic.sec.gif b/docs/icons/generic.sec.gif
deleted file mode 100644
index 88d5240c3c..0000000000
--- a/docs/icons/generic.sec.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/hand.right.gif b/docs/icons/hand.right.gif
deleted file mode 100644
index 5cdbc7206d..0000000000
--- a/docs/icons/hand.right.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/hand.up.gif b/docs/icons/hand.up.gif
deleted file mode 100644
index 85a5d68317..0000000000
--- a/docs/icons/hand.up.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/icon.sheet.gif b/docs/icons/icon.sheet.gif
deleted file mode 100644
index ad1686e448..0000000000
--- a/docs/icons/icon.sheet.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/image1.gif b/docs/icons/image1.gif
deleted file mode 100644
index 01e442bfa9..0000000000
--- a/docs/icons/image1.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/image2.gif b/docs/icons/image2.gif
deleted file mode 100644
index 751faeea36..0000000000
--- a/docs/icons/image2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/image3.gif b/docs/icons/image3.gif
deleted file mode 100644
index 4f30484ff6..0000000000
--- a/docs/icons/image3.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/index.gif b/docs/icons/index.gif
deleted file mode 100644
index 162478fb3a..0000000000
--- a/docs/icons/index.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/layout.gif b/docs/icons/layout.gif
deleted file mode 100644
index c96338a152..0000000000
--- a/docs/icons/layout.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/left.gif b/docs/icons/left.gif
deleted file mode 100644
index 279e6710d4..0000000000
--- a/docs/icons/left.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/link.gif b/docs/icons/link.gif
deleted file mode 100644
index c5b6889a76..0000000000
--- a/docs/icons/link.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/movie.gif b/docs/icons/movie.gif
deleted file mode 100644
index 0035183774..0000000000
--- a/docs/icons/movie.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/p.gif b/docs/icons/p.gif
deleted file mode 100644
index 7b917b4e91..0000000000
--- a/docs/icons/p.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/patch.gif b/docs/icons/patch.gif
deleted file mode 100644
index 39bc90e795..0000000000
--- a/docs/icons/patch.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/pdf.gif b/docs/icons/pdf.gif
deleted file mode 100644
index c88fd777c4..0000000000
--- a/docs/icons/pdf.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/pie0.gif b/docs/icons/pie0.gif
deleted file mode 100644
index 6f7a0ae7a7..0000000000
--- a/docs/icons/pie0.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/pie1.gif b/docs/icons/pie1.gif
deleted file mode 100644
index 03aa6be71e..0000000000
--- a/docs/icons/pie1.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/pie2.gif b/docs/icons/pie2.gif
deleted file mode 100644
index b04c5e0908..0000000000
--- a/docs/icons/pie2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/pie3.gif b/docs/icons/pie3.gif
deleted file mode 100644
index 4db9d023ed..0000000000
--- a/docs/icons/pie3.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/pie4.gif b/docs/icons/pie4.gif
deleted file mode 100644
index 93471fdd88..0000000000
--- a/docs/icons/pie4.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/pie5.gif b/docs/icons/pie5.gif
deleted file mode 100644
index 57aee93f07..0000000000
--- a/docs/icons/pie5.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/pie6.gif b/docs/icons/pie6.gif
deleted file mode 100644
index 0dc327b569..0000000000
--- a/docs/icons/pie6.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/pie7.gif b/docs/icons/pie7.gif
deleted file mode 100644
index 8661337f06..0000000000
--- a/docs/icons/pie7.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/pie8.gif b/docs/icons/pie8.gif
deleted file mode 100644
index 59ddb34ce0..0000000000
--- a/docs/icons/pie8.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/portal.gif b/docs/icons/portal.gif
deleted file mode 100644
index 0e6e506e00..0000000000
--- a/docs/icons/portal.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/ps.gif b/docs/icons/ps.gif
deleted file mode 100644
index 0f565bc1db..0000000000
--- a/docs/icons/ps.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/quill.gif b/docs/icons/quill.gif
deleted file mode 100644
index 818a5cdc7e..0000000000
--- a/docs/icons/quill.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/right.gif b/docs/icons/right.gif
deleted file mode 100644
index b256e5f75f..0000000000
--- a/docs/icons/right.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/screw1.gif b/docs/icons/screw1.gif
deleted file mode 100644
index af6ba2b097..0000000000
--- a/docs/icons/screw1.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/screw2.gif b/docs/icons/screw2.gif
deleted file mode 100644
index 06dccb3e44..0000000000
--- a/docs/icons/screw2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/script.gif b/docs/icons/script.gif
deleted file mode 100644
index d8a853bc58..0000000000
--- a/docs/icons/script.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/README.txt b/docs/icons/small/README.txt
deleted file mode 100644
index deb96702b7..0000000000
--- a/docs/icons/small/README.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-
-These icons are provided as an alternative to the standard Apache
-icon graphics. All graphics in this directory, with the exception
-of rainbow.gif, are 16x16 pixels in size, rather than the 20x22
-dimension icons which are the normal defaults for Apache and are
-in the parent directory of this one.
diff --git a/docs/icons/small/back.gif b/docs/icons/small/back.gif
deleted file mode 100644
index e331454726..0000000000
--- a/docs/icons/small/back.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/binary.gif b/docs/icons/small/binary.gif
deleted file mode 100644
index 995f79b9b1..0000000000
--- a/docs/icons/small/binary.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/binhex.gif b/docs/icons/small/binhex.gif
deleted file mode 100644
index 3d54a5458e..0000000000
--- a/docs/icons/small/binhex.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/blank.gif b/docs/icons/small/blank.gif
deleted file mode 100644
index 606787a839..0000000000
--- a/docs/icons/small/blank.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/broken.gif b/docs/icons/small/broken.gif
deleted file mode 100644
index 1bcc57f25c..0000000000
--- a/docs/icons/small/broken.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/burst.gif b/docs/icons/small/burst.gif
deleted file mode 100644
index d882ceba9c..0000000000
--- a/docs/icons/small/burst.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/comp1.gif b/docs/icons/small/comp1.gif
deleted file mode 100644
index 712f36afdb..0000000000
--- a/docs/icons/small/comp1.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/comp2.gif b/docs/icons/small/comp2.gif
deleted file mode 100644
index 7759eb11f9..0000000000
--- a/docs/icons/small/comp2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/compressed.gif b/docs/icons/small/compressed.gif
deleted file mode 100644
index d3b156072a..0000000000
--- a/docs/icons/small/compressed.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/continued.gif b/docs/icons/small/continued.gif
deleted file mode 100644
index e1c9f2cfa6..0000000000
--- a/docs/icons/small/continued.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/dir.gif b/docs/icons/small/dir.gif
deleted file mode 100644
index 7b37b09917..0000000000
--- a/docs/icons/small/dir.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/dir2.gif b/docs/icons/small/dir2.gif
deleted file mode 100644
index 425d6e4b77..0000000000
--- a/docs/icons/small/dir2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/doc.gif b/docs/icons/small/doc.gif
deleted file mode 100644
index 0fcf18db2a..0000000000
--- a/docs/icons/small/doc.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/forward.gif b/docs/icons/small/forward.gif
deleted file mode 100644
index 2997466eb4..0000000000
--- a/docs/icons/small/forward.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/generic.gif b/docs/icons/small/generic.gif
deleted file mode 100644
index f8da6ff92c..0000000000
--- a/docs/icons/small/generic.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/generic2.gif b/docs/icons/small/generic2.gif
deleted file mode 100644
index 992f13331b..0000000000
--- a/docs/icons/small/generic2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/generic3.gif b/docs/icons/small/generic3.gif
deleted file mode 100644
index 85aa275e25..0000000000
--- a/docs/icons/small/generic3.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/image.gif b/docs/icons/small/image.gif
deleted file mode 100644
index dc3d95ced7..0000000000
--- a/docs/icons/small/image.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/image2.gif b/docs/icons/small/image2.gif
deleted file mode 100644
index a5c40f1550..0000000000
--- a/docs/icons/small/image2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/index.gif b/docs/icons/small/index.gif
deleted file mode 100644
index 526df6b064..0000000000
--- a/docs/icons/small/index.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/key.gif b/docs/icons/small/key.gif
deleted file mode 100644
index 8dfd6c09de..0000000000
--- a/docs/icons/small/key.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/movie.gif b/docs/icons/small/movie.gif
deleted file mode 100644
index 7b4a42e7a0..0000000000
--- a/docs/icons/small/movie.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/patch.gif b/docs/icons/small/patch.gif
deleted file mode 100644
index 100484e598..0000000000
--- a/docs/icons/small/patch.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/ps.gif b/docs/icons/small/ps.gif
deleted file mode 100644
index fa4bcfce30..0000000000
--- a/docs/icons/small/ps.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/rainbow.gif b/docs/icons/small/rainbow.gif
deleted file mode 100644
index 8216b89bad..0000000000
--- a/docs/icons/small/rainbow.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/sound.gif b/docs/icons/small/sound.gif
deleted file mode 100644
index a7a89ffd9e..0000000000
--- a/docs/icons/small/sound.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/sound2.gif b/docs/icons/small/sound2.gif
deleted file mode 100644
index 07706e07b8..0000000000
--- a/docs/icons/small/sound2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/tar.gif b/docs/icons/small/tar.gif
deleted file mode 100644
index 59c3ffb9a5..0000000000
--- a/docs/icons/small/tar.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/text.gif b/docs/icons/small/text.gif
deleted file mode 100644
index 66ceefbc8c..0000000000
--- a/docs/icons/small/text.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/transfer.gif b/docs/icons/small/transfer.gif
deleted file mode 100644
index d460d3fffe..0000000000
--- a/docs/icons/small/transfer.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/unknown.gif b/docs/icons/small/unknown.gif
deleted file mode 100644
index 7bf0bbc10a..0000000000
--- a/docs/icons/small/unknown.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/small/uu.gif b/docs/icons/small/uu.gif
deleted file mode 100644
index 8c793f8a7f..0000000000
--- a/docs/icons/small/uu.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/sound1.gif b/docs/icons/sound1.gif
deleted file mode 100644
index 8efb49f55d..0000000000
--- a/docs/icons/sound1.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/sound2.gif b/docs/icons/sound2.gif
deleted file mode 100644
index 48e6a7fb2f..0000000000
--- a/docs/icons/sound2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/sphere1.gif b/docs/icons/sphere1.gif
deleted file mode 100644
index 7067070da2..0000000000
--- a/docs/icons/sphere1.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/sphere2.gif b/docs/icons/sphere2.gif
deleted file mode 100644
index a9e462a377..0000000000
--- a/docs/icons/sphere2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/tar.gif b/docs/icons/tar.gif
deleted file mode 100644
index 4032c1bd3d..0000000000
--- a/docs/icons/tar.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/tex.gif b/docs/icons/tex.gif
deleted file mode 100644
index 45e43233b8..0000000000
--- a/docs/icons/tex.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/text.gif b/docs/icons/text.gif
deleted file mode 100644
index 4c623909fb..0000000000
--- a/docs/icons/text.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/transfer.gif b/docs/icons/transfer.gif
deleted file mode 100644
index 33697dbb66..0000000000
--- a/docs/icons/transfer.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/unknown.gif b/docs/icons/unknown.gif
deleted file mode 100644
index 32b1ea23fb..0000000000
--- a/docs/icons/unknown.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/up.gif b/docs/icons/up.gif
deleted file mode 100644
index 6d6d6d1ebf..0000000000
--- a/docs/icons/up.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/uu.gif b/docs/icons/uu.gif
deleted file mode 100644
index 4387d529f6..0000000000
--- a/docs/icons/uu.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/uuencoded.gif b/docs/icons/uuencoded.gif
deleted file mode 100644
index 4387d529f6..0000000000
--- a/docs/icons/uuencoded.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/world1.gif b/docs/icons/world1.gif
deleted file mode 100644
index 05b4ec2058..0000000000
--- a/docs/icons/world1.gif
+++ /dev/null
Binary files differ
diff --git a/docs/icons/world2.gif b/docs/icons/world2.gif
deleted file mode 100644
index e3203f7a88..0000000000
--- a/docs/icons/world2.gif
+++ /dev/null
Binary files differ
diff --git a/docs/man/ab.8 b/docs/man/ab.8
deleted file mode 100644
index 62da21cf83..0000000000
--- a/docs/man/ab.8
+++ /dev/null
@@ -1,209 +0,0 @@
-.TH ab 1 "March 1998"
-.\" Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" 4. The names "Apache Server" and "Apache Group" must not be used to
-.\" endorse or promote products derived from this software without
-.\" prior written permission.
-.\"
-.\" 5. Products derived from this software may not be called "Apache"
-.\" nor may "Apache" appear in their names without prior written
-.\" permission of the Apache Group.
-.\"
-.\" 6. Redistributions of any form whatsoever must retain the following
-.\" acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-.\" EXPRESSED 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 APACHE GROUP OR
-.\" ITS 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.
-.\" ====================================================================
-.\"
-.\" This software consists of voluntary contributions made by many
-.\" individuals on behalf of the Apache Group and was originally based
-.\" on public domain software written at the National Center for
-.\" Supercomputing Applications, University of Illinois, Urbana-Champaign.
-.\" For more information on the Apache Group and the Apache HTTP server
-.\" project, please see <http://www.apache.org/>.
-.SH NAME
-ab \- Apache HTTP server benchmarking tool
-.SH SYNOPSIS
-.B ab
-[
-.B \-k
-] [
-.BI \-n " requests"
-] [
-.BI \-t " timelimit"
-] [
-.BI \-c " concurrency"
-] [
-.BI \-p " POST file"
-] [
-.BI \-A " Authenticate username:password"
-] [
-.BI \-P " Proxy Authenticate username:password"
-] [
-.BI \-H " Custom header"
-] [
-.BI \-C " Cookie name=value"
-] [
-.BI \-T " content-type"
-] [
-.BI \-v " verbosity"
-]
-] [
-.BI \-w " output HTML"
-]
-] [
-.BI \-x " <table> attributes"
-]
-] [
-.BI \-y " <tr> attributes"
-]
-] [
-.BI \-z " <td> attributes"
-]
-.I [http://]hostname[:port]/path
-
-.B ab
-[
-.B \-V
-] [
-.B \-h
-]
-.PP
-.SH DESCRIPTION
-.B ab
-is a tool for benchmarking your Apache HyperText Transfer Protocol (HTTP)
-server. It is designed to give you an impression on how performant is your
-current Apache installation. This especially shows you how much requests per
-time your Apache installation is capable to serve.
-.PP
-.SH OPTIONS
-.TP 12
-.B \-k
-Enable the HTTP KeepAlive feature, i.e. perform multiple requests within one
-HTTP session instead. Default is no KeepAlive.
-.TP 12
-.BI \-n " requests"
-Number of requests to perform for the benchmarking session. The default is to
-just perform one single request which usually leads to not very representative
-benchmarking results.
-.TP 12
-.BI \-t " timelimit"
-Seconds to max. spend for benchmarking. This implies
-a
-.B \-n
-.B 50000
-internally. Use this to benchmark the server within a fixed total amount of
-time. Per default there is no timelimit.
-.TP 12
-.BI \-c " concurrency"
-Number of multiple requests per time to perform.
-Default is one request per time.
-
-.TP 12
-.BI \-p " POST file"
-File containing data to POST.
-
-.TP 12
-.BI \-A " Authorization username:password"
-Supply BASIC Authentification credentials to the server. The username
-and password are separated by a single ':' and send on the wire uuencoded.
-The string is send regardless of wether the server needs it; (i.e. has
-send an 401. Authentifcation needed).
-
-.TP 12
-.BI \-p " Proxy-Authorization username:password"
-Supply BASIC Authentification credentials to a proxy en-route. The username
-and password are separated by a single ':' and send on the wire uuencoded.
-The string is send regardless of wether the proxy needs it; (i.e. has
-send an 407 Proxy authentifcation needed).
-
-.TP 12
-.BI \-C " Cookie name=value"
-Add a 'Cookie:' line to the request. The argument is typically in the form
-of a 'name=value' pair. This field is repeatable.
-
-.TP 12
-.BI \-p " Header string"
-Postfix extra headers to the request. The argument is typically in the form
-of a valid header line; containing a colon separated field value pair. (i.e.
-'Accept-Encoding: zip/zop;8bit').
-
-.TP 12
-.BI \-T " content-type"
-Content-type header to use for POST data.
-
-.TP 12
-.B \-v
-Set verbosity level - 4 and above prints information on headers, 3 and
-above prints response codes (404, 200, etc.), 2 and above prints
-warnings and info.
-
-.TP 12
-.BI \-w
-Print out results in HTML tables. Default table is two columns wide,
-with a white background.
-.TP 12
-.BI \-x " attributes"
-String to use as attributes for <table>. Attributes are inserted
-<table
-.B here
->
-.TP 12
-.BI \-y " attributes"
-String to use as attributes for <tr>.
-.TP 12
-.BI \-z " attributes"
-String to use as attributes for <td>.
-.TP 12
-.B \-V
-Display version number and exit.
-.TP 12
-.B \-h
-Display usage information.
-.PD
-.SH BUGS
-There are various statically declared buffers of fixed length. Combined
-with the lazy parsing of the command line arguments, the response headers
-from the server and other external inputs this might bite you.
-.P
-It does not implement HTTP/1.x fully; only accepts some 'expected' forms
-of responses. The rather heavy use of
-.BR strstr(3)
-shows up top in profile,
-which might indicate a performance problem; i.e. you would measure the
-.BR ab
-performance rather than the server's.
-
-.SH SEE ALSO
-.BR httpd(8)
-.
diff --git a/docs/man/apachectl.8 b/docs/man/apachectl.8
deleted file mode 100644
index 72300eb98b..0000000000
--- a/docs/man/apachectl.8
+++ /dev/null
@@ -1,133 +0,0 @@
-.TH apachectl 1 "September 1997"
-.\" Copyright (c) 1997-1999 The Apache Group. 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 acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" 4. The names "Apache Server" and "Apache Group" must not be used to
-.\" endorse or promote products derived from this software without
-.\" prior written permission.
-.\"
-.\" 5. Products derived from this software may not be called "Apache"
-.\" nor may "Apache" appear in their names without prior written
-.\" permission of the Apache Group.
-.\"
-.\" 6. Redistributions of any form whatsoever must retain the following
-.\" acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-.\" EXPRESSED 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 APACHE GROUP OR
-.\" ITS 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.
-.\" ====================================================================
-.\"
-.\" This software consists of voluntary contributions made by many
-.\" individuals on behalf of the Apache Group and was originally based
-.\" on public domain software written at the National Center for
-.\" Supercomputing Applications, University of Illinois, Urbana-Champaign.
-.\" For more information on the Apache Group and the Apache HTTP server
-.\" project, please see <http://www.apache.org/>.
-.SH NAME
-apachectl \- Apache HTTP server control interface
-.SH SYNOPSIS
-.B apachectl
-\fIcommand\fP [...]
-.SH DESCRIPTION
-.B apachectl
-is a front end to the Apache HyperText Transfer Protocol (HTTP)
-server. It is designed to help the administrator control the
-functioning of the Apache
-.B httpd
-daemon.
-.PP
-.B NOTE:
-If your Apache installation uses non-standard paths, you will need to
-edit the
-.B apachectl
-script to set the appropriate paths to your PID file and your
-.B httpd
-binary. See the comments in the script for details.
-.PP
-The
-.B apachectl
-script returns a 0 exit value on success, and >0 if an error
-occurs. For more details, view the comments in the script.
-.PP
-Full documentation for Apache is available at
-.B http://www.apache.org/
-.
-.SH OPTIONS
-The \fIcommand\fP can be any one or more of the following options:
-.TP 12
-.BI start
-Start the Apache daemon. Gives an error if it is already running.
-.TP
-.BI stop
-Stops the Apache daemon.
-.TP
-.BI restart
-Restarts the Apache daemon by sending it a SIGHUP. If the daemon
-is not running, it is started.
-This command automatically checks the configuration files via
-.BI configtest
-before initiating the restart to make sure Apache doesn't die.
-.TP
-.BI fullstatus
-Displays a full status report from
-.B mod_status.
-For this to work, you need to have mod_status enabled on your server
-and a text-based browser such as \fIlynx\fP available on your system. The
-URL used to access the status report can be set by editing the
-.B STATUSURL
-variable in the script.
-.TP
-.BI status
-Displays a brief status report. Similar to the fullstatus option,
-except that the list of requests currently being served is omitted.
-.TP
-.BI graceful
-Gracefully restarts the Apache daemon by sending it a SIGUSR1. If
-the daemon is not running, it is started. This differs from a
-normal restart in that currently open connections are not aborted.
-A side effect is that old log files will not be closed immediately.
-This means that if used in a log rotation script, a substantial delay may be
-necessary to ensure that the old log files are closed before processing them.
-This command automatically checks the configuration files via
-.BI configtest
-before initiating the restart to make sure Apache doesn't die.
-.TP
-.BI configtest
-Run a configuration file syntax test. It parses the configuration
-files and either reports
-.B "Syntax Ok"
-or detailed information about the particular syntax error.
-.TP
-.BI help
-Displays a short help message.
-.SH SEE ALSO
-.BR httpd(8)
-.
diff --git a/docs/man/apxs.8 b/docs/man/apxs.8
deleted file mode 100644
index 464766c75f..0000000000
--- a/docs/man/apxs.8
+++ /dev/null
@@ -1,459 +0,0 @@
-.TH apxs 8 "April 1998"
-.\" Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" 4. The names "Apache Server" and "Apache Group" must not be used to
-.\" endorse or promote products derived from this software without
-.\" prior written permission.
-.\"
-.\" 5. Products derived from this software may not be called "Apache"
-.\" nor may "Apache" appear in their names without prior written
-.\" permission of the Apache Group.
-.\"
-.\" 6. Redistributions of any form whatsoever must retain the following
-.\" acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-.\" EXPRESSED 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 APACHE GROUP OR
-.\" ITS 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.
-.\" ====================================================================
-.\"
-.\" This software consists of voluntary contributions made by many
-.\" individuals on behalf of the Apache Group and was originally based
-.\" on public domain software written at the National Center for
-.\" Supercomputing Applications, University of Illinois, Urbana-Champaign.
-.\" For more information on the Apache Group and the Apache HTTP server
-.\" project, please see <http://www.apache.org/>.
-.SH NAME
-apxs \- APache eXtenSion tool
-.SH SYNOPSIS
-.B apxs
-.B \-g
-[
-.BI \-S " name=value
-]
-.BI \-n " modname"
-
-.B apxs
-.B \-q
-[
-.BI \-S " name=value
-]
-.IR query " ..."
-
-.B apxs
-.B \-c
-[
-.BI \-S " name=value
-]
-[
-.BI \-o " dsofile"
-]
-[
-.BI \-I " incdir"
-]
-[
-.BI \-D " name=value"
-]
-[
-.BI \-L " libdir"
-]
-[
-.BI \-l " libname"
-]
-[
-.BI \-Wc, "compiler-flags"
-]
-[
-.BI \-Wl, "linker-flags"
-]
-.IR files " ..."
-
-.B apxs
-.B \-i
-[
-.BI \-S " name=value
-]
-[
-.BI \-n " modname"
-]
-[
-.B \-a
-]
-[
-.B \-A
-]
-.IR dsofile " ..."
-
-.B apxs
-.B \-e
-[
-.BI \-S " name=value
-]
-[
-.BI \-n " modname"
-]
-[
-.B \-a
-]
-[
-.B \-A
-]
-.IR dsofile " ..."
-.PP
-.SH DESCRIPTION
-.B apxs
-is a tool for building and installing extension modules for the Apache
-HyperText Transfer Protocol (HTTP) server. This is achieved by building a
-dynamic shared object (DSO) from one or more source or object
-.I files
-which then can be loaded into
-the Apache server under runtime via the
-.B LoadModule
-directive from
-.BR mod_so.
-
-So to use this extension mechanism your platform has
-to support the DSO feature and your
-Apache
-.B httpd
-binary has to be built with the
-.B mod_so
-module.
-The
-.B apxs
-tool automatically complains if this is not the case.
-You can check this yourself by manually running the command
-
-.nf
- $ httpd -l
-.fi
-
-The module
-.B mod_so
-should be part of the displayed list.
-If these requirements are fulfilled you can easily extend
-your Apache server's functionality by installing your own
-modules with the DSO mechanism by the help of this
-.B apxs
-tool:
-
-.nf
- $ apxs -i -a -c mod_foo.c
- gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c
- ld -Bshareable -o mod_foo.so mod_foo.o
- cp mod_foo.so /path/to/apache/libexec/mod_foo.so
- chmod 755 /path/to/apache/libexec/mod_foo.so
- [activating module `foo' in /path/to/apache/etc/httpd.conf]
- $ apachectl restart
- /path/to/apache/sbin/apachectl restart: httpd not running, trying to start
- [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module
- /path/to/apache/sbin/apachectl restart: httpd started
- $ _
-.fi
-
-The arguments
-.I files
-can be any C source file (.c), a object file (.o) or
-even a library archive (.a). The
-.B apxs
-tool automatically recognizes these extensions and automtaically used the C
-source files for compilation while just using the object and archive files for
-the linking phase. But when using such pre-compiled objects make sure they are
-compiled for position independend code (PIC) to be able to use them for a
-dynamically loaded shared object.
-For instance with GCC you always just have to use
-.BR -fpic .
-For other
-C compilers consult its manual
-page or at watch for the flags
-.B apxs
-uses to compile the object files.
-
-For more details about DSO support in Apache read the documentation
-of
-.B mod_so
-or perhaps even read the
-.B src/modules/standard/mod_so.c
-source file.
-
-.PP
-.SH OPTIONS
-Common options:
-.TP 12
-.BI \-n " modname"
-This explicitly sets the module name for the
-.B \-i
-(install)
-and
-.B \-g
-(template generation) option. Use this to explicitly specify the module name.
-For option
-.B \-g
-this is required, for option
-.B \-i
-the
-.B apxs
-tool tries to determine the name from the source or (as a fallback) at least
-by guessing it from the filename.
-.PP
-Query options:
-.TP 12
-.B \-q
-Performs a query for
-.BR apxs 's
-knowledge about certain settings. The
-.I query
-parameters can be one or more of the following strings:
-.nf
- CC TARGET
- CFLAGS SBINDIR
- CFLAGS_SHLIB INCLUDEDIR
- LD_SHLIB LIBEXECDIR
- LDFLAGS_SHLIB SYSCONFDIR
- LIBS_SHLIB
-.fi
-Use this for manually determining settings. For instance use
-.nf
- INC=-I`apxs -q INCLUDEDIR`
-.fi
-inside your own Makefiles if you need manual access
-to Apache's C header files.
-.PP
-Configuration options:
-.TP 12
-.BI \-S " name=value"
-This option changes the apxs settings described above.
-.PP
-Template Generation options:
-.TP 12
-.B \-g
-This generates a subdirectory
-.I name
-(see option
-.BR \-n ")"
-and there two files: A sample module source file named
-.BI mod_ name.c
-which can be used as a template for creating your own modules or
-as a quick start for playing with the APXS mechanism.
-And a corresponding
-.B Makefile
-for even easier build and installing of this module.
-.PP
-DSO compilation options:
-.TP 12
-.B \-c
-This indicates the compilation operation. It first compiles the C source
-files (.c) of
-.I files
-into corresponding object files (.o) and then builds a dynamically shared object in
-.I dsofile
-by linking these object files plus the remaining
-object files (.o and .a) of
-.I files
-If no
-.B \-o
-option is specified
-the output file is guessed from the first filename in
-.I files
-and thus usually defaults to
-.BI mod_ name.so
-.TP 12
-.BI \-o " dsofile"
-Explicitly specifies the filename of the created dynamically shared object. If
-not specified and the name cannot be guessed from the
-.I files
-list, the fallback name
-.B mod_unknown.so
-is used.
-.TP 12
-.BI \-D " name=value"
-This option is directly passed through to the compilation command(s).
-Use this to add your own defines to the build process.
-.TP 12
-.BI \-I " incdir"
-This option is directly passed through to the compilation command(s).
-Use this to add your own include directories to search to the build process.
-.TP 12
-.BI \-L " libdir"
-This option is directly passed through to the linker command.
-Use this to add your own library directories to search to the build process.
-.TP 12
-.BI \-l " libname"
-This option is directly passed through to the linker command.
-Use this to add your own libraries to search to the build process.
-.TP 12
-.BI \-Wc, "compiler-flags"
-This option passes
-.I compiler-flags
-as additional flags to the compiler command.
-Use this to add local compiler-specific options.
-.TP 12
-.BI \-Wl, "linker-flags"
-This option passes
-.I linker-flags
-as additional flags to the linker command.
-Use this to add local linker-specific options.
-.PP
-DSO installation and configuration options:
-.TP 12
-.B \-i
-This indicates the installation operation and installs one or more
-dynamically shared objects into the
-server's
-.I libexec
-directory.
-.TP 12
-.B \-a
-This activates the module by automatically adding a corresponding
-.B LoadModule
-line to Apache's
-.B httpd.conf
-configuration file, or by enabling it if it already exists.
-.TP 12
-.B \-A
-Same as option
-.B \-a
-but the created
-.B LoadModule
-directive is prefixed with a hash sign (#), i.e. the module is
-just prepared for later activation but initially disabled.
-.TP 12
-.B \-e
-This indicates the editing operation, which can be used with the
-.B \-a
-and
-.B \-A
-options similarly to the
-.B \-i
-operation to edit Apache's
-.B httpd.conf
-configuration file without attempting to install the module.
-.PD
-.SH EXAMPLES
-Assume you have an Apache module named mod_foo.c available which should extend
-Apache's server functionality. To accomplish this you first have to compile
-the C source into a shared object suitable for loading into the Apache server
-under runtime via the following command:
-
-.nf
- $ apxs -c mod_foo.c
- gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c
- ld -Bshareable -o mod_foo.so mod_foo.o
- $ _
-.fi
-
-Then you have to update the Apache configuration by making sure a
-.B LoadModule
-directive is present to load this shared object. To simplify this
-step
-.B apxs
-provides an automatic way to install the shared object in its
-"libexec" directory and updating the
-.B httpd.conf
-file accordingly. This can be achieved by running:
-
-.nf
- $ apxs -i -a mod_foo.c
- cp mod_foo.so /path/to/apache/libexec/mod_foo.so
- chmod 755 /path/to/apache/libexec/mod_foo.so
- [activating module `foo' in /path/to/apache/etc/httpd.conf]
- $ _
-.fi
-
-This way a line named
-
-.nf
- LoadModule foo_module libexec/mod_foo.so
-.fi
-
-is added to the configuration file if still not present.
-If you want to have this this disabled per default use the
-.B \-A
-option, i.e.
-
-.nf
- $ apxs -i -A mod_foo.c
-.fi
-
-For a quick test of the APXS mechanism you can create a sample Apache module
-template plus a corresponding Makefile via:
-
-.nf
- $ apxs -g -n foo
- Creating [DIR] foo
- Creating [FILE] foo/Makefile
- Creating [FILE] foo/mod_foo.c
- $ _
-.fi
-
-Then you can immediately compile this sample module into a shared object and
-load it into the Apache server:
-
-.nf
- $ cd foo
- $ make all reload
- apxs -c mod_foo.c
- gcc -fpic -DSHARED_MODULE -I/path/to/apache/include -c mod_foo.c
- ld -Bshareable -o mod_foo.so mod_foo.o
- apxs -i -a -n "foo" mod_foo.so
- cp mod_foo.so /path/to/apache/libexec/mod_foo.so
- chmod 755 /path/to/apache/libexec/mod_foo.so
- [activating module `foo' in /path/to/apache/etc/httpd.conf]
- apachectl restart
- /path/to/apache/sbin/apachectl restart: httpd not running, trying to start
- [Tue Mar 31 11:27:55 1998] [debug] mod_so.c(303): loaded module foo_module
- /path/to/apache/sbin/apachectl restart: httpd started
- $ _
-.fi
-
-You can even use
-.B apxs
-to compile complex modules outside the Apache source tree, like PHP3:
-
-.nf
- $ cd php3
- $ ./configure --with-shared-apache=../apache-1.3
- $ apxs -c -o libphp3.so mod_php3.c libmodphp3-so.a
- gcc -fpic -DSHARED_MODULE -I/tmp/apache/include -c mod_php3.c
- ld -Bshareable -o libphp3.so mod_php3.o libmodphp3-so.a
- $ _
-.fi
-
-because
-.B apxs
-automatically recognized C source files and object files. Only C source files
-are compiled while remaining object files are used for the linking phase.
-
-.PD
-.SH SEE ALSO
-.BR apachectl(1),
-.BR httpd(8).
-.
diff --git a/docs/man/dbmmanage.1 b/docs/man/dbmmanage.1
deleted file mode 100644
index 06380ff0f5..0000000000
--- a/docs/man/dbmmanage.1
+++ /dev/null
@@ -1,171 +0,0 @@
-.TH dbmmanage 1 "March 1998"
-.\" Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" 4. The names "Apache Server" and "Apache Group" must not be used to
-.\" endorse or promote products derived from this software without
-.\" prior written permission.
-.\"
-.\" 5. Products derived from this software may not be called "Apache"
-.\" nor may "Apache" appear in their names without prior written
-.\" permission of the Apache Group.
-.\"
-.\" 6. Redistributions of any form whatsoever must retain the following
-.\" acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-.\" EXPRESSED 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 APACHE GROUP OR
-.\" ITS 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.
-.\" ====================================================================
-.\"
-.\" This software consists of voluntary contributions made by many
-.\" individuals on behalf of the Apache Group and was originally based
-.\" on public domain software written at the National Center for
-.\" Supercomputing Applications, University of Illinois, Urbana-Champaign.
-.\" For more information on the Apache Group and the Apache HTTP server
-.\" project, please see <http://www.apache.org/>.
-.SH NAME
-dbmmanage \- Create and update user authentication files in DBM format
-.SH SYNOPSIS
-.B dbmmanage
-.I filename
-[
-.I command
-] [
-.I username
-[
-.I encpasswd
-] ]
-.PP
-.SH DESCRIPTION
-.B dbmmanage
-is used to create and update the DBM format files used to store
-usernames and password for basic authentication of HTTP users.
-Resources available from the
-.B httpd
-Apache web server can be restricted to just the users listed
-in the files created by
-.B dbmmanage.
-This program can only be used
-when the usernames are stored in a DBM file. To use a
-flat-file database see
-\fBhtpasswd\fP.
-.PP
-This manual page only lists the command line arguments. For details of
-the directives necessary to configure user authentication in
-.B httpd
-see
-the Apache manual, which is part of the Apache distribution or can be
-found at http://www.apache.org/.
-.SH OPTIONS
-.IP \fB\fIfilename\fP
-The filename of the DBM format file. Usually without the
-extension .db, .pag, or .dir.
-.IP \fB\fIcommand\fP
-This selects the operation to perform:
-.TP 12
-.B add
-Adds an entry for \fIusername\fP to \fIfilename\fP using the encrypted
-password \fIencpassword\fP.
-.TP 12
-.B adduser
-Asks for a password and then adds an entry for \fIusername\fP to
-\fIfilename\fP .
-.TP 12
-.B check
-Asks for a password and then checks if
-\fIusername\fP is in \fIfilename\fP and if it's password matches
-the specified one.
-.TP 12
-.B delete
-Deletes the \fIusername\fP entry from \fIfilename\fP.
-.TP 12
-.B import
-Reads username:password entries (one per line) from STDIN and adds them to
-\fIfilename\fP. The passwords already has to be crypted.
-.TP 12
-.B update
-Same as the "adduser" command, except that it makes sure \fIusername\fP
-already exists in \fIfilename\fP.
-.TP 12
-.B view
-Just displays the complete contents of the DBM file.
-.IP \fB\fIusername\fP
-The user for which the update operation is performed.
-.PD
-.SH BUGS
-.PP
-One should be aware that there are a number of different DBM file
-formats in existance, and with all likelihood, libraries for more than
-one format may exist on your system. The three primary examples are
-NDBM, the GNU project's GDBM, and Berkeley DB 2. Unfortunately, all
-these libraries use different file formats, and you must make sure
-that the file format used by
-.I filename
-is the same format that
-.B dbmmanage
-expects to see.
-.B dbmmanage
-currently has no way of determining what type of DBM file it is
-looking at. If used against the wrong format,
-.dbmmanage
-will simply return nothing, or may create a different DBM file with a
-different name, or at worst, it may corrupt the DBM file if you were
-attempting to write to it.
-.PP
-.B dbmmanage
-has a list of DBM format preferences, defined by the
-.B @AnyDBM::ISA
-array near the beginning of the program. Since we prefer the Berkeley
-DB 2 file format, the order in which
-.B dbmmanage
-will look for system libraries is Berkeley DB 2, then NDBM, and then
-GDBM. The first library found will be the library
-.B dbmmanage
-will attempt to use for all DBM file transactions. This ordering is
-slightly different than the standard
-.B @AnyDBM::ISA
-ordering in perl, as well as the ordering used by the simple dbmopen()
-call in Perl, so if you use any other utilities to manage your DBM
-files, they must also follow this preference ordering. Similar care
-must be taken if using programs in other languages, like C, to
-access these files.
-.PP
-Apache's
-.B mod_auth_db.c
-module corresponds to Berkeley DB 2 library, while
-.B mod_auth_dbm.c
-corresponds to the NDBM library. Also, one can usually use the
-.B file
-program supplied with most Unix systems to see what format a DBM file is in.
-.PD
-.SH SEE ALSO
-.BR httpd(8)
-.
diff --git a/docs/man/htdigest.1 b/docs/man/htdigest.1
deleted file mode 100644
index c719e456ce..0000000000
--- a/docs/man/htdigest.1
+++ /dev/null
@@ -1,97 +0,0 @@
-.TH htdigest 1 "March 1998"
-.\" Copyright (c) 1997-1999 The Apache Group. 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 acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" 4. The names "Apache Server" and "Apache Group" must not be used to
-.\" endorse or promote products derived from this software without
-.\" prior written permission. For written permission, please contact
-.\" apache@apache.org.
-.\"
-.\" 5. Products derived from this software may not be called "Apache"
-.\" nor may "Apache" appear in their names without prior written
-.\" permission of the Apache Group.
-.\"
-.\" 6. Redistributions of any form whatsoever must retain the following
-.\" acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-.\" EXPRESSED 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 APACHE GROUP OR
-.\" ITS 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.
-.\" ====================================================================
-.\"
-.\" This software consists of voluntary contributions made by many
-.\" individuals on behalf of the Apache Group and was originally based
-.\" on public domain software written at the National Center for
-.\" Supercomputing Applications, University of Illinois, Urbana-Champaign.
-.\" For more information on the Apache Group and the Apache HTTP server
-.\" project, please see <http://www.apache.org/>.
-.SH NAME
-htdigest \- Create and update user authentication files
-.SH SYNOPSIS
-.B htdigest
-[
-.B \-c
-]
-.I passwdfile
-.I realm
-.I username
-.SH DESCRIPTION
-.B htdigest
-is used to create and update the flat-files used to store
-usernames, realm and password for digest authentication of HTTP users.
-Resources available from the
-.B httpd
-Apache web server can be restricted to just the users listed
-in the files created by
-.B htdigest.
-.PP
-This manual page only lists the command line arguments. For details of
-the directives necessary to configure digest authentication in
-.B httpd
-see
-the Apache manual, which is part of the Apache distribution or can be
-found at http://www.apache.org/.
-.SH OPTIONS
-.IP \-c
-Create the \fIpasswdfile\fP. If \fIpasswdfile\fP already exists, it
-is deleted first.
-.IP \fB\fIpasswdfile\fP
-Name of the file to contain the username, realm and password. If \-c
-is given, this file is created if it does not already exist,
-or deleted and recreated if it does exist.
-.IP \fB\fIrealm\fP
-The realm name to which the user name belongs to.
-.IP \fB\fIusername\fP
-The user name to create or update in \fBpasswdfile\fP. If
-\fIusername\fP does not exist is this file, an entry is added. If it
-does exist, the password is changed.
-.SH SEE ALSO
-.BR httpd(8)
-.
diff --git a/docs/man/htpasswd.1 b/docs/man/htpasswd.1
deleted file mode 100644
index 1687cde41c..0000000000
--- a/docs/man/htpasswd.1
+++ /dev/null
@@ -1,213 +0,0 @@
-.TH htpasswd 1 "February 1997"
-.\" Copyright (c) 1997-1999 The Apache Group. 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 acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" 4. The names "Apache Server" and "Apache Group" must not be used to
-.\" endorse or promote products derived from this software without
-.\" prior written permission. For written permission, please contact
-.\" apache@apache.org.
-.\"
-.\" 5. Products derived from this software may not be called "Apache"
-.\" nor may "Apache" appear in their names without prior written
-.\" permission of the Apache Group.
-.\"
-.\" 6. Redistributions of any form whatsoever must retain the following
-.\" acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-.\" EXPRESSED 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 APACHE GROUP OR
-.\" ITS 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.
-.\" ====================================================================
-.\"
-.\" This software consists of voluntary contributions made by many
-.\" individuals on behalf of the Apache Group and was originally based
-.\" on public domain software written at the National Center for
-.\" Supercomputing Applications, University of Illinois, Urbana-Champaign.
-.\" For more information on the Apache Group and the Apache HTTP server
-.\" project, please see <http://www.apache.org/>.
-.SH NAME
-htpasswd \- Create and update user authentication files
-.SH SYNOPSIS
-.B htpasswd
-[
-.B \-c
-]
-[
-.B \-m
-]
-.I passwdfile
-.I username
-.br
-.B htpasswd
-.B \-b
-[
-.B \-c
-]
-[
-.B \-m
-.B \-d
-.B \-p
-.B \-s
-]
-.I passwdfile
-.I username
-.I password
-.SH DESCRIPTION
-.B htpasswd
-is used to create and update the flat-files used to store
-usernames and password for basic authentication of HTTP users.
-If
-.B htpasswd
-cannot access a file, such as not being able to write to the output
-file or not being able to read the file in order to update it,
-it returns an error status and makes no changes.
-.PP
-Resources available from the
-.B httpd
-Apache web server can be restricted to just the users listed
-in the files created by
-.B htpasswd.
-This program can only be used
-when the usernames are stored in a flat-file. To use a
-DBM database see
-\fBdbmmanage\fP.
-.PP
-.B htpasswd
-encrypts passwords using either a version of MD5 modified for Apache,
-or the system's \fIcrypt()\fP routine. Files managed by
-.B htpasswd
-may contain both types of passwords; some user records may have
-MD5-encrypted passwords while others in the same file may have passwords
-encrypted with \fIcrypt()\fP.
-.PP
-This manual page only lists the command line arguments. For details of
-the directives necessary to configure user authentication in
-.B httpd
-see
-the Apache manual, which is part of the Apache distribution or can be
-found at <URL:http://www.apache.org/>.
-.SH OPTIONS
-.IP \-b
-Use batch mode; \fIi.e.\fP, get the password from the command line
-rather than prompting for it. \fBThis option should be used with
-extreme care, since the password is clearly visible on the command
-line.\fP
-.IP \-c
-Create the \fIpasswdfile\fP. If \fIpasswdfile\fP already exists, it
-is rewritten and truncated.
-.IP \-m
-Use MD5 encryption for passwords. On Windows and TPF, this is the default.
-.IP \-d
-Use crypt() encryption for passwords. The default on all platforms but
-Windows and TPF. Though possibly supported by
-.B htpasswd
-onm all platforms, it is not supported by the
-.B httpd
-server on Windows and TPF.
-.IP \-s
-Use SHA encryption for passwords. Faciliates migration from/to Netscape
-servers using the LDAP Directory Interchange Format (ldif).
-.IP \-p
-Use plaintext passwords. Though
-.B htpasswd
-will support creation on all platofrms, the
-.B httpd
-deamon will only accept plain text passwords on Windows and TPF.
-.IP \fB\fIpasswdfile\fP
-Name of the file to contain the user name and password. If \-c
-is given, this file is created if it does not already exist,
-or rewritten and truncated if it does exist.
-.IP \fB\fIusername\fP
-The username to create or update in \fBpasswdfile\fP. If
-\fIusername\fP does not exist in this file, an entry is added. If it
-does exist, the password is changed.
-.IP \fB\fIpassword\fP
-The plaintext password to be encrypted and stored in the file. Only used
-with the \fI-b\fP flag.
-.SH EXIT STATUS
-.B htpasswd
-returns a zero status ("true") if the username and password have
-been successfully added or updated in the \fIpasswdfile\fP.
-.B htpasswd
-returns 1 if it encounters some problem accessing files, 2 if there
-was a syntax problem with the command line, 3 if the password was
-entered interactively and the verification entry didn't match, 4 if
-its operation was interrupted, 5 if a value is too long (username,
-filename, password, or final computed record), and 6 if the username
-contains illegal characters (see the \fBRESTRICTIONS\fP section).
-.SH EXAMPLES
-\fBhtpasswd /usr/local/etc/apache/.htpasswd-users jsmith\fP
-.IP
-Adds or modifies the password for user \fIjsmith\fP.
-The user is prompted for the password. If executed
-on a Windows system, the password will be encrypted using the
-modified Apache MD5 algorithm; otherwise, the system's
-\fIcrypt()\fP routine will be used. If the file does not
-exist,
-.B htpasswd
-will do nothing except return an error.
-.LP
-\fBhtpasswd -c /home/doe/public_html/.htpasswd jane\fP
-.IP
-Creates a new file and stores a record in it for user \fIjane\fP.
-The user is prompted for the password.
-If the file exists and cannot be read, or cannot be written,
-it is not altered and
-.B htpasswd
-will display a message and return an error status.
-.LP
-\fBhtpasswd -mb /usr/web/.htpasswd-all jones Pwd4Steve\fP
-.IP
-Encrypts the password from the command line (\fIPwd4Steve\fP) using
-the MD5 algorithm, and stores it in the specified file.
-.LP
-.SH SECURITY CONSIDERATIONS
-Web password files such as those managed by
-.B htpasswd
-should \fBnot\fP be within the Web server's URI space -- that is,
-they should not be fetchable with a browser.
-.PP
-The use of the \fI-b\fP option is discouraged, since when it is
-used the unencrypted password appears on the command line.
-.SH RESTRICTIONS
-On the Windows and MPE platforms, passwords encrypted with
-.B htpasswd
-are limited to no more than 255 characters in length. Longer
-passwords will be truncated to 255 characters.
-.PP
-The MD5 algorithm used by
-.B htpasswd
-is specific to the Apache software; passwords encrypted using it will not be
-usable with other Web servers.
-.PP
-Usernames are limited to 255 bytes and may not include the character ':'.
-.SH SEE ALSO
-.BR httpd(8)
-and the scripts in support/SHA1 which come with the distribution.
diff --git a/docs/man/httpd.8 b/docs/man/httpd.8
deleted file mode 100644
index ae320bad2a..0000000000
--- a/docs/man/httpd.8
+++ /dev/null
@@ -1,211 +0,0 @@
-.TH httpd 8 "February 1997"
-.\" Copyright (c) 1995-1997 David Robinson. All rights reserved.
-.\" Copyright (c) 1997-1999 The Apache Group. 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 acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" 4. The names "Apache Server" and "Apache Group" must not be used to
-.\" endorse or promote products derived from this software without
-.\" prior written permission. For written permission, please contact
-.\" apache@apache.org.
-.\"
-.\" 5. Products derived from this software may not be called "Apache"
-.\" nor may "Apache" appear in their names without prior written
-.\" permission of the Apache Group.
-.\"
-.\" 6. Redistributions of any form whatsoever must retain the following
-.\" acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-.\" EXPRESSED 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 APACHE GROUP OR
-.\" ITS 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.
-.\" ====================================================================
-.\"
-.\" This software consists of voluntary contributions made by many
-.\" individuals on behalf of the Apache Group and was originally based
-.\" on public domain software written at the National Center for
-.\" Supercomputing Applications, University of Illinois, Urbana-Champaign.
-.\" For more information on the Apache Group and the Apache HTTP server
-.\" project, please see <http://www.apache.org/>.
-.SH NAME
-httpd \- Apache hypertext transfer protocol server
-.SH SYNOPSIS
-.B httpd
-[
-.B \-X
-] [
-.BI \-R " libexecdir"
-] [
-.BI \-d " serverroot"
-] [
-.BI \-f " config"
-] [
-.BI \-C " directive"
-] [
-.BI \-c " directive"
-] [
-.BI \-D " parameter"
-]
-
-.B httpd
-[
-.B \-h
-]
-[
-.B \-l
-]
-[
-.B \-L
-]
-[
-.B \-v
-]
-[
-.B \-V
-]
-[
-.B \-S
-]
-[
-.B \-t
-]
-[
-.B \-T
-]
-
-.SH DESCRIPTION
-.B httpd
-is the Apache HyperText Transfer Protocol (HTTP) server program. It is
-designed to be run as a standalone daemon process. When used like this
-it will create a pool of child processes to handle requests. To stop
-it, send a TERM signal to the initial (parent) process. The PID of
-this process is written to a file as given in the configuration file.
-Alternatively
-.B httpd
-may be invoked by the Internet daemon inetd(8) each
-time a connection to the HTTP service is made.
-.PP
-This manual page only lists the command line arguments. For details
-of the directives necessary to configure
-.B httpd
-see the Apache manual,
-which is part of the Apache distribution or can be found at
-http://www.apache.org/. Paths in this manual may not reflect those
-compiled into
-.B httpd.
-.SH OPTIONS
-.TP 12
-.BI \-R " libexecdir"
-This option is only available if Apache was built with
-the
-.I SHARED_CORE
-rule enabled which forces the Apache core code to be
-placed into a dynamic shared object (DSO) file. This file
-is searched in a hardcoded path under ServerRoot per default. Use this
-option if you want to override it.
-.TP 12
-.BI \-d " serverroot"
-Set the initial value for the ServerRoot directive to \fIserverroot\fP. This
-can be overridden by the ServerRoot command in the configuration file. The
-default is \fB/usr/local/apache\fP.
-.TP
-.BI \-f " config"
-Execute the commands in the file \fIconfig\fP on startup. If \fIconfig\fP
-does not begin with a /, then it is taken to be a path relative to
-the ServerRoot. The default is \fBconf/httpd.conf\fP.
-.TP
-.BI \-C " directive"
-Process the configuration \fIdirective\fP before reading config files.
-.TP
-.BI \-c " directive"
-Process the configuration \fIdirective\fP after reading config files.
-.TP
-.BI \-D " parameter"
-Sets a configuration \fIparameter\fP which can be used with
-<IfDefine>...</IfDefine> sections in the configuration files
-to conditionally skip or process commands.
-.TP
-.B \-h
-Output a short summary of available command line options.
-.TP
-.B \-l
-Output a list of modules compiled into the server.
-.TP
-.B \-L
-Output a list of directives together with expected arguments and
-places where the directive is valid.
-.TP
-.B \-S
-Show the settings as parsed from the config file (currently only shows the
-virtualhost settings).
-.TP
-.B \-t
-Run syntax tests for configuration files only. The program immediately exits
-after these syntax parsing with either a return code of 0 (Syntax OK) or
-return code not equal to 0 (Syntax Error).
-.TP
-.B \-T
-Same as option
-.B \-t
-but does not check the configured document roots.
-.TP
-.B \-X
-Run in single-process mode, for internal debugging purposes only; the daemon
-does not detach from the terminal or fork any children. Do NOT use this mode
-to provide ordinary web service.
-.TP
-.B \-v
-Print the version of
-.B httpd
-, and then exit.
-.TP
-.B \-V
-Print the version and build parameters of
-.B httpd
-, and then exit.
-.SH FILES
-.PD 0
-.B /usr/local/apache/conf/httpd.conf
-.br
-.B /usr/local/apache/conf/srm.conf
-.br
-.B /usr/local/apache/conf/access.conf
-.br
-.B /usr/local/apache/conf/mime.types
-.br
-.B /usr/local/apache/conf/magic
-.br
-.B /usr/local/apache/logs/error_log
-.br
-.B /usr/local/apache/logs/access_log
-.br
-.B /usr/local/apache/logs/httpd.pid
-.PD
-.SH SEE ALSO
-.BR inetd (8).
diff --git a/docs/man/logresolve.8 b/docs/man/logresolve.8
deleted file mode 100644
index 4851269ad6..0000000000
--- a/docs/man/logresolve.8
+++ /dev/null
@@ -1,87 +0,0 @@
-.TH logresolve 8 "March 1998"
-.\" Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" 4. The names "Apache Server" and "Apache Group" must not be used to
-.\" endorse or promote products derived from this software without
-.\" prior written permission.
-.\"
-.\" 5. Products derived from this software may not be called "Apache"
-.\" nor may "Apache" appear in their names without prior written
-.\" permission of the Apache Group.
-.\"
-.\" 6. Redistributions of any form whatsoever must retain the following
-.\" acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-.\" EXPRESSED 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 APACHE GROUP OR
-.\" ITS 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.
-.\" ====================================================================
-.\"
-.\" This software consists of voluntary contributions made by many
-.\" individuals on behalf of the Apache Group and was originally based
-.\" on public domain software written at the National Center for
-.\" Supercomputing Applications, University of Illinois, Urbana-Champaign.
-.\" For more information on the Apache Group and the Apache HTTP server
-.\" project, please see <http://www.apache.org/>.
-.SH NAME
-logresolve \- resolve hostnames for IP-adresses in Apache logfiles
-.SH SYNOPSIS
-.B logresolve
-[
-.BI \-s " filename"
-] [
-.B \-c
-] <
-.I access_log
->
-.I access_log.new
-.PP
-.SH DESCRIPTION
-.B logresolve
-is a post-processing program to resolve IP-adresses in Apache's access
-logfiles. To minimize impact on your nameserver, logresolve has its very own
-internal hash-table cache. This means that each IP number will only be looked
-up the first time it is found in the log file.
-.SH OPTIONS
-.TP 12
-.BI \-s " filename"
-Specifies a filename to record statistics.
-.TP 12
-.B \-c
-This causes
-.B logresolve
-to apply some DNS checks: after finding the hostname from the IP address, it
-looks up the IP addresses for the hostname and checks that one of these
-matches the original address.
-.PD
-.SH SEE ALSO
-.BR httpd(8)
-.
diff --git a/docs/man/rotatelogs.8 b/docs/man/rotatelogs.8
deleted file mode 100644
index aee02e11ec..0000000000
--- a/docs/man/rotatelogs.8
+++ /dev/null
@@ -1,83 +0,0 @@
-.TH rotatelogs 8 "March 1998"
-.\" Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" 4. The names "Apache Server" and "Apache Group" must not be used to
-.\" endorse or promote products derived from this software without
-.\" prior written permission.
-.\"
-.\" 5. Products derived from this software may not be called "Apache"
-.\" nor may "Apache" appear in their names without prior written
-.\" permission of the Apache Group.
-.\"
-.\" 6. Redistributions of any form whatsoever must retain the following
-.\" acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-.\" EXPRESSED 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 APACHE GROUP OR
-.\" ITS 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.
-.\" ====================================================================
-.\"
-.\" This software consists of voluntary contributions made by many
-.\" individuals on behalf of the Apache Group and was originally based
-.\" on public domain software written at the National Center for
-.\" Supercomputing Applications, University of Illinois, Urbana-Champaign.
-.\" For more information on the Apache Group and the Apache HTTP server
-.\" project, please see <http://www.apache.org/>.
-.SH NAME
-rotatelogs \- rotate Apache logs without having to kill the server
-.SH SYNOPSIS
-.B rotatelogs
-.I logfile
-.I rotationtime
-.PP
-.SH DESCRIPTION
-.B rotatelogs
-is a simple program for use in conjunction with Apache's piped logfile
-feature which can be used like this:
-
-.fi
- TransferLog "|rotatelogs /path/to/logs/access_log 86400"
-.mf
-
-This creates the files /path/to/logs/access_log.nnnn where nnnn is the system
-time at which the log nominally starts (this time will always be a multiple of
-the rotation time, so you can synchronize cron scripts with it). At the end
-of each rotation time (here after 24 hours) a new log is started.
-.SH OPTIONS
-.IP \fB\fIlogfile\fP
-The path plus basename of the logfile. The suffix .nnnn is automatically
-added.
-.IP \fB\fIrotationtime\fP
-The rotation time in seconds.
-.PD
-.SH SEE ALSO
-.BR httpd(8)
-.
diff --git a/docs/man/suexec.8 b/docs/man/suexec.8
deleted file mode 100644
index 801d7abce9..0000000000
--- a/docs/man/suexec.8
+++ /dev/null
@@ -1,70 +0,0 @@
-.TH suexec 8 "March 1998"
-.\" Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" 4. The names "Apache Server" and "Apache Group" must not be used to
-.\" endorse or promote products derived from this software without
-.\" prior written permission.
-.\"
-.\" 5. Products derived from this software may not be called "Apache"
-.\" nor may "Apache" appear in their names without prior written
-.\" permission of the Apache Group.
-.\"
-.\" 6. Redistributions of any form whatsoever must retain the following
-.\" acknowledgment:
-.\" "This product includes software developed by the Apache Group
-.\" for use in the Apache HTTP server project (http://www.apache.org/)."
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-.\" EXPRESSED 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 APACHE GROUP OR
-.\" ITS 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.
-.\" ====================================================================
-.\"
-.\" This software consists of voluntary contributions made by many
-.\" individuals on behalf of the Apache Group and was originally based
-.\" on public domain software written at the National Center for
-.\" Supercomputing Applications, University of Illinois, Urbana-Champaign.
-.\" For more information on the Apache Group and the Apache HTTP server
-.\" project, please see <http://www.apache.org/>.
-.SH NAME
-suexec \- Switch User For Exec
-.SH SYNOPSIS
-No synopsis for usage, because this program
-is used internally by Apache only.
-.PP
-.SH DESCRIPTION
-.B suexec
-is the "wrapper" support program for the suEXEC behaviour for Apache.
-It is run from within Apache automatically to switch the user when
-an external program has to be run under a different user. For more
-information about suEXEC see the document `Apache suEXEC Support'
-under http://www.apache.org/docs/suexec.html .
-.PD
-.SH SEE ALSO
-.BR httpd(8)
-.
diff --git a/docs/manual/bind.html.en b/docs/manual/bind.html.en
deleted file mode 100644
index 75bacbb253..0000000000
--- a/docs/manual/bind.html.en
+++ /dev/null
@@ -1,135 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML><HEAD>
-<TITLE>Setting which addresses and ports Apache uses</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Setting which addresses and ports Apache uses</H1>
-
-<HR>
-
-When Apache starts, it connects to some port and address on the
-local machine and waits for incoming requests. By default, it
-listens to all addresses on the machine, and to the port
-as specified by the <TT>Port</TT> directive in the server configuration.
-However, it can be told to listen to more the one port, or to listen
-to only selected addresses, or a combination. This is often combined
-with the Virtual Host feature which determines how Apache
-responds to different IP addresses, hostnames and ports.<P>
-
-There are two directives used to restrict or specify which addresses
-and ports Apache listens to.
-
-<UL>
-<LI><A HREF="#bindaddress">BindAddress</A> is used to restrict the server to
- listening to
- a single address, and can be used to permit multiple Apache servers
- on the same machine listening to different IP addresses.
-<LI><A HREF="#listen">Listen</A> can be used to make a single Apache server
- listen
- to more than one address and/or port.
-</UL>
-
-<H3><A NAME="bindaddress">BindAddress</A></H3>
-<A
- HREF="mod/directive-dict.html#Syntax"
- REL="Help"
-><STRONG>Syntax:</STRONG></A> BindAddress <EM>[ * | IP-address
- | hostname ]</EM><BR>
-<A
- HREF="mod/directive-dict.html#Default"
- REL="Help"
-><STRONG>Default:</STRONG></A> <CODE>BindAddress *</CODE><BR>
-<A
- HREF="mod/directive-dict.html#Context"
- REL="Help"
-><STRONG>Context:</STRONG></A> server config<BR>
-<A
- HREF="mod/directive-dict.html#Status"
- REL="Help"
-><STRONG>Status:</STRONG></A> Core<P>
-
-Makes the server listen to just the specified address. If the argument
-is *, the server listens to all addresses. The port listened to
-is set with the <TT>Port</TT> directive. Only one BindAddress
-should be used.
-
-<H3><A NAME="listen">Listen</A></H3>
-<A
- HREF="mod/directive-dict.html#Syntax"
- REL="Help"
-><STRONG>Syntax:</STRONG></A> Listen <EM>[ port | IP-address:port ]</EM><BR>
-<A
- HREF="mod/directive-dict.html#Default"
- REL="Help"
-><STRONG>Default:</STRONG></A> <CODE>none</CODE><BR>
-<A
- HREF="mod/directive-dict.html#Context"
- REL="Help"
-><STRONG>Context:</STRONG></A> server config<BR>
-<A
- HREF="mod/directive-dict.html#Status"
- REL="Help"
-><STRONG>Status:</STRONG></A> Core<P>
-
-<TT>Listen</TT> can be used instead of <TT>BindAddress</TT> and
-<TT>Port</TT>. It tells the server to accept incoming requests on the
-specified port or address-and-port combination. If the first format is
-used, with a port number only, the server listens to the given port on
-all interfaces, instead of the port given by the <TT>Port</TT>
-directive. If an IP address is given as well as a port, the server
-will listen on the given port and interface. <P> Multiple Listen
-directives may be used to specify a number of addresses and ports to
-listen to. The server will respond to requests from any of the listed
-addresses and ports.<P>
-
-For example, to make the server accept connections on both port
-80 and port 8000, use:
-<PRE>
- Listen 80
- Listen 8000
-</PRE>
-
-To make the server accept connections on two specified
-interfaces and port numbers, use
-<PRE>
- Listen 192.170.2.1:80
- Listen 192.170.2.5:8000
-</PRE>
-
-<H2>How this works with Virtual Hosts</H2>
-
-BindAddress and Listen do not implement Virtual Hosts. They tell the
-main server what addresses and ports to listen to. If no
-&lt;VirtualHost&gt; directives are used, the server will behave the
-same for all accepted requests. However, &lt;VirtualHost&gt; can be
-used to specify a different behavior for one or more of the addresses
-and ports. To implement a VirtualHost, the server must first be told
-to listen to the address and port to be used. Then a
-&lt;VirtualHost&gt; section should be created for a specified address
-and port to set the behavior of this virtual host. Note that if the
-&lt;VirtualHost&gt; is set for an address and port that the server is
-not listening to, it cannot be accessed.
-
-<H2>See also</H2>
-
-See also the documentation on
-<A HREF="vhosts/index.html">Virtual Hosts</A>,
-<A HREF="mod/core.html#bindaddress">BindAddress directive</A>,
-<A HREF="mod/core.html#port">Port directive</A>,
-<A HREF="dns-caveats.html">DNS Issues</A>
-and
-<A HREF="mod/core.html#virtualhost">&lt;VirtualHost&gt; section</A>.
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
-
diff --git a/docs/manual/cgi_path.html.en b/docs/manual/cgi_path.html.en
deleted file mode 100644
index 2b7bd963b1..0000000000
--- a/docs/manual/cgi_path.html.en
+++ /dev/null
@@ -1,93 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML><HEAD>
-<TITLE>PATH_INFO Changes in the CGI Environment</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">PATH_INFO Changes in the CGI Environment</H1>
-
-<HR>
-
-<H2><A NAME="over">Overview</A></H2>
-
-<P>As implemented in Apache 1.1.1 and earlier versions, the method
-Apache used to create PATH_INFO in the CGI environment was
-counterintuitive, and could result in crashes in certain cases. In
-Apache 1.2 and beyond, this behavior has changed. Although this
-results in some compatibility problems with certain legacy CGI
-applications, the Apache 1.2 behavior is still compatible with the
-CGI/1.1 specification, and CGI scripts can be easily modified (<A
-HREF="#compat">see below</A>).
-
-<H2><A NAME="prob">The Problem</A></H2>
-
-<P>Apache 1.1.1 and earlier implemented the PATH_INFO and SCRIPT_NAME
-environment variables by looking at the filename, not the URL. While
-this resulted in the correct values in many cases, when the filesystem
-path was overloaded to contain path information, it could result in
-errant behavior. For example, if the following appeared in a config
-file:
-<PRE>
- Alias /cgi-ralph /usr/local/httpd/cgi-bin/user.cgi/ralph
-</PRE>
-<P>In this case, <CODE>user.cgi</CODE> is the CGI script, the "/ralph"
-is information to be passed onto the CGI. If this configuration was in
-place, and a request came for "<CODE>/cgi-ralph/script/</CODE>", the
-code would set PATH_INFO to "<CODE>/ralph/script</CODE>", and
-SCRIPT_NAME to "<CODE>/cgi-</CODE>". Obviously, the latter is
-incorrect. In certain cases, this could even cause the server to
-crash.</P>
-
-<H2><A NAME="solution">The Solution</A></H2>
-
-<P>Apache 1.2 and later now determine SCRIPT_NAME and PATH_INFO by
-looking directly at the URL, and determining how much of the URL is
-client-modifiable, and setting PATH_INFO to it. To use the above
-example, PATH_INFO would be set to "<CODE>/script</CODE>", and
-SCRIPT_NAME to "<CODE>/cgi-ralph</CODE>". This makes sense and results
-in no server behavior problems. It also permits the script to be
-guaranteed that
-"<CODE>http://$SERVER_NAME:$SERVER_PORT$SCRIPT_NAME$PATH_INFO</CODE>"
-will always be an accessible URL that points to the current script,
-something which was not necessarily true with previous versions of
-Apache.
-
-<P>However, the "<CODE>/ralph</CODE>"
-information from the <CODE>Alias</CODE> directive is lost. This is
-unfortunate, but we feel that using the filesystem to pass along this
-sort of information is not a recommended method, and a script making
-use of it "deserves" not to work. Apache 1.2b3 and later, however, do
-provide <A HREF="#compat">a workaround.</A>
-
-<H2><A NAME="compat">Compatibility with Previous Servers</A></H2>
-
-<P>It may be necessary for a script that was designed for earlier
-versions of Apache or other servers to need the information that the
-old PATH_INFO variable provided. For this purpose, Apache 1.2 (1.2b3
-and later) sets an additional variable, FILEPATH_INFO. This
-environment variable contains the value that PATH_INFO would have had
-with Apache 1.1.1.</P>
-
-<P>A script that wishes to work with both Apache 1.2 and earlier
-versions can simply test for the existence of FILEPATH_INFO, and use
-it if available. Otherwise, it can use PATH_INFO. For example, in
-Perl, one might use:
-<PRE>
- $path_info = $ENV{'FILEPATH_INFO'} || $ENV{'PATH_INFO'};
-</PRE>
-
-<P>By doing this, a script can work with all servers supporting the
-CGI/1.1 specification, including all versions of Apache.</P>
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
-
diff --git a/docs/manual/content-negotiation.html.en b/docs/manual/content-negotiation.html.en
deleted file mode 100644
index 7bfaee5afa..0000000000
--- a/docs/manual/content-negotiation.html.en
+++ /dev/null
@@ -1,588 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Apache Content Negotiation</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Content Negotiation</H1>
-
-<P>
-Apache's support for content negotiation has been updated to meet the
-HTTP/1.1 specification. It can choose the best representation of a
-resource based on the browser-supplied preferences for media type,
-languages, character set and encoding. It is also implements a
-couple of features to give more intelligent handling of requests from
-browsers which send incomplete negotiation information. <P>
-
-Content negotiation is provided by the
-<A HREF="mod/mod_negotiation.html">mod_negotiation</A> module,
-which is compiled in by default.
-
-<HR>
-
-<H2>About Content Negotiation</H2>
-
-<P>
-A resource may be available in several different representations. For
-example, it might be available in different languages or different
-media types, or a combination. One way of selecting the most
-appropriate choice is to give the user an index page, and let them
-select. However it is often possible for the server to choose
-automatically. This works because browsers can send as part of each
-request information about what representations they prefer. For
-example, a browser could indicate that it would like to see
-information in French, if possible, else English will do. Browsers
-indicate their preferences by headers in the request. To request only
-French representations, the browser would send
-
-<PRE>
- Accept-Language: fr
-</PRE>
-
-<P>
-Note that this preference will only be applied when there is a choice
-of representations and they vary by language.
-<P>
-
-As an example of a more complex request, this browser has been
-configured to accept French and English, but prefer French, and to
-accept various media types, preferring HTML over plain text or other
-text types, and preferring GIF or JPEG over other media types, but also
-allowing any other media type as a last resort:
-
-<PRE>
- Accept-Language: fr; q=1.0, en; q=0.5
- Accept: text/html; q=1.0, text/*; q=0.8, image/gif; q=0.6,
- image/jpeg; q=0.6, image/*; q=0.5, */*; q=0.1
-</PRE>
-
-Apache 1.2 supports 'server driven' content negotiation, as defined in
-the HTTP/1.1 specification. It fully supports the Accept,
-Accept-Language, Accept-Charset and Accept-Encoding request headers.
-Apache 1.3.4 also supports 'transparent' content negotiation, which is
-an experimental negotiation protocol defined in RFC 2295 and RFC 2296.
-It does not offer support for 'feature negotiation' as defined in
-these RFCs.
-<P>
-
-A <STRONG>resource</STRONG> is a conceptual entity identified by a URI
-(RFC 2396). An HTTP server like Apache provides access to
-<STRONG>representations</STRONG> of the resource(s) within its namespace,
-with each representation in the form of a sequence of bytes with a
-defined media type, character set, encoding, etc. Each resource may be
-associated with zero, one, or more than one representation
-at any given time. If multiple representations are available,
-the resource is referred to as <STRONG>negotiable</STRONG> and each of its
-representations is termed a <STRONG>variant</STRONG>. The ways in which the
-variants for a negotiable resource vary are called the
-<STRONG>dimensions</STRONG> of negotiation.
-
-<H2>Negotiation in Apache</H2>
-
-<P>
-In order to negotiate a resource, the server needs to be given
-information about each of the variants. This is done in one of two
-ways:
-
-<UL>
- <LI> Using a type map (<EM>i.e.</EM>, a <CODE>*.var</CODE> file) which
- names the files containing the variants explicitly, or
- <LI> Using a 'MultiViews' search, where the server does an implicit
- filename pattern match and chooses from among the results.
-</UL>
-
-<H3>Using a type-map file</H3>
-
-<P>
-A type map is a document which is associated with the handler
-named <CODE>type-map</CODE> (or, for backwards-compatibility with
-older Apache configurations, the mime type
-<CODE>application/x-type-map</CODE>). Note that to use this feature,
-you must have a handler set in the configuration that defines a
-file suffix as <CODE>type-map</CODE>; this is best done with a
-
-<PRE>
- AddHandler type-map var
-</PRE>
-
-in the server configuration file. See the comments in the sample config
-file for more details. <P>
-
-Type map files have an entry for each available variant; these entries
-consist of contiguous HTTP-format header lines. Entries for
-different variants are separated by blank lines. Blank lines are
-illegal within an entry. It is conventional to begin a map file with
-an entry for the combined entity as a whole (although this
-is not required, and if present will be ignored). An example
-map file is:
-
-<PRE>
- URI: foo
-
- URI: foo.en.html
- Content-type: text/html
- Content-language: en
-
- URI: foo.fr.de.html
- Content-type: text/html;charset=iso-8859-2
- Content-language: fr, de
-</PRE>
-
-If the variants have different source qualities, that may be indicated
-by the "qs" parameter to the media type, as in this picture (available
-as jpeg, gif, or ASCII-art):
-
-<PRE>
- URI: foo
-
- URI: foo.jpeg
- Content-type: image/jpeg; qs=0.8
-
- URI: foo.gif
- Content-type: image/gif; qs=0.5
-
- URI: foo.txt
- Content-type: text/plain; qs=0.01
-</PRE>
-<P>
-
-qs values can vary in the range 0.000 to 1.000. Note that any variant with
-a qs value of 0.000 will never be chosen. Variants with no 'qs'
-parameter value are given a qs factor of 1.0. The qs parameter indicates
-the relative 'quality' of this variant compared to the other available
-variants, independent of the client's capabilities. For example, a jpeg
-file is usually of higher source quality than an ascii file if it is
-attempting to represent a photograph. However, if the resource being
-represented is an original ascii art, then an ascii representation would
-have a higher source quality than a jpeg representation. A qs value
-is therefore specific to a given variant depending on the nature of
-the resource it represents.
-
-<P>
-The full list of headers recognized is:
-
-<DL>
- <DT> <CODE>URI:</CODE>
- <DD> uri of the file containing the variant (of the given media
- type, encoded with the given content encoding). These are
- interpreted as URLs relative to the map file; they must be on
- the same server (!), and they must refer to files to which the
- client would be granted access if they were to be requested
- directly.
- <DT> <CODE>Content-Type:</CODE>
- <DD> media type --- charset, level and "qs" parameters may be given. These
- are often referred to as MIME types; typical media types are
- <CODE>image/gif</CODE>, <CODE>text/plain</CODE>, or
- <CODE>text/html;&nbsp;level=3</CODE>.
- <DT> <CODE>Content-Language:</CODE>
- <DD> The languages of the variant, specified as an Internet standard
- language tag from RFC 1766 (<EM>e.g.</EM>, <CODE>en</CODE> for English,
- <CODE>kr</CODE> for Korean, <EM>etc.</EM>).
- <DT> <CODE>Content-Encoding:</CODE>
- <DD> If the file is compressed, or otherwise encoded, rather than
- containing the actual raw data, this says how that was done.
- Apache only recognizes encodings that are defined by an
- <A HREF="mod/mod_mime.html#addencoding">AddEncoding</A> directive.
- This normally includes the encodings <CODE>x-compress</CODE>
- for compress'd files, and <CODE>x-gzip</CODE> for gzip'd files.
- The <CODE>x-</CODE> prefix is ignored for encoding comparisons.
- <DT> <CODE>Content-Length:</CODE>
- <DD> The size of the file. Specifying content
- lengths in the type-map allows the server to compare file sizes
- without checking the actual files.
- <DT> <CODE>Description:</CODE>
- <DD> A human-readable textual description of the variant. If Apache cannot
- find any appropriate variant to return, it will return an error
- response which lists all available variants instead. Such a variant
- list will include the human-readable variant descriptions.
-</DL>
-
-<H3>Multiviews</H3>
-
-<P>
-<CODE>MultiViews</CODE> is a per-directory option, meaning it can be set with
-an <CODE>Options</CODE> directive within a <CODE>&lt;Directory&gt;</CODE>,
-<CODE>&lt;Location&gt;</CODE> or <CODE>&lt;Files&gt;</CODE>
-section in <CODE>access.conf</CODE>, or (if <CODE>AllowOverride</CODE>
-is properly set) in <CODE>.htaccess</CODE> files. Note that
-<CODE>Options All</CODE> does not set <CODE>MultiViews</CODE>; you
-have to ask for it by name.
-
-<P>
-The effect of <CODE>MultiViews</CODE> is as follows: if the server
-receives a request for <CODE>/some/dir/foo</CODE>, if
-<CODE>/some/dir</CODE> has <CODE>MultiViews</CODE> enabled, and
-<CODE>/some/dir/foo</CODE> does <EM>not</EM> exist, then the server reads the
-directory looking for files named foo.*, and effectively fakes up a
-type map which names all those files, assigning them the same media
-types and content-encodings it would have if the client had asked for
-one of them by name. It then chooses the best match to the client's
-requirements.
-
-<P>
-<CODE>MultiViews</CODE> may also apply to searches for the file named by the
-<CODE>DirectoryIndex</CODE> directive, if the server is trying to
-index a directory. If the configuration files specify
-
-<PRE>
- DirectoryIndex index
-</PRE>
-
-then the server will arbitrate between <CODE>index.html</CODE>
-and <CODE>index.html3</CODE> if both are present. If neither are
-present, and <CODE>index.cgi</CODE> is there, the server will run it.
-
-<P>
-If one of the files found when reading the directive is a CGI script,
-it's not obvious what should happen. The code gives that case
-special treatment --- if the request was a POST, or a GET with
-QUERY_ARGS or PATH_INFO, the script is given an extremely high quality
-rating, and generally invoked; otherwise it is given an extremely low
-quality rating, which generally causes one of the other views (if any)
-to be retrieved.
-
-<H2>The Negotiation Methods</H2>
-
-After Apache has obtained a list of the variants for a given resource,
-either from a type-map file or from the filenames in the directory, it
-invokes one of two methods to decide on the 'best' variant to
-return, if any. It is not necessary to know any of the details of how
-negotiation actually takes place in order to use Apache's content
-negotiation features. However the rest of this document explains the
-methods used for those interested.
-<P>
-
-There are two negotiation methods:
-
-<OL>
-
-<LI><STRONG>Server driven negotiation with the Apache
-algorithm</STRONG> is used in the normal case. The Apache algorithm is
-explained in more detail below. When this algorithm is used, Apache
-can sometimes 'fiddle' the quality factor of a particular dimension to
-achieve a better result. The ways Apache can fiddle quality factors is
-explained in more detail below.
-
-<LI><STRONG>Transparent content negotiation</STRONG> is used when the
-browser specifically requests this through the mechanism defined in RFC
-2295. This negotiation method gives the browser full control over
-deciding on the 'best' variant, the result is therefore dependent on
-the specific algorithms used by the browser. As part of the
-transparent negotiation process, the browser can ask Apache to run the
-'remote variant selection algorithm' defined in RFC 2296. </UL>
-
-
-<H3>Dimensions of Negotiation</H3>
-
-<TABLE>
-<TR valign="top">
-<TH>Dimension
-<TH>Notes
-<TR valign="top">
-<TD>Media Type
-<TD>Browser indicates preferences with the Accept header field. Each item
-can have an associated quality factor. Variant description can also
-have a quality factor (the "qs" parameter).
-<TR valign="top">
-<TD>Language
-<TD>Browser indicates preferences with the Accept-Language header field.
-Each item can have a quality factor. Variants can be associated with none, one
-or more than one language.
-<TR valign="top">
-<TD>Encoding
-<TD>Browser indicates preference with the Accept-Encoding header field.
-Each item can have a quality factor.
-<TR valign="top">
-<TD>Charset
-<TD>Browser indicates preference with the Accept-Charset header field.
-Each item can have a quality factor.
-Variants can indicate a charset as a parameter of the media type.
-</TABLE>
-
-<H3>Apache Negotiation Algorithm</H3>
-
-<P>
-Apache can use the following algorithm to select the 'best' variant
-(if any) to return to the browser. This algorithm is not
-further configurable. It operates as follows:
-
-<OL>
-<LI>First, for each dimension of the negotiation, check the appropriate
-<EM>Accept*</EM> header field and assign a quality to each
-variant. If the <EM>Accept*</EM> header for any dimension implies that this
-variant is not acceptable, eliminate it. If no variants remain, go
-to step 4.
-
-<LI>Select the 'best' variant by a process of elimination. Each of the
-following tests is applied in order. Any variants not selected at each
-test are eliminated. After each test, if only one variant remains,
-select it as the best match and proceed to step 3. If more than one
-variant remains, move on to the next test.
-
-<OL>
-<LI>Multiply the quality factor from the Accept header with the
- quality-of-source factor for this variant's media type, and select
- the variants with the highest value.
-
-<LI>Select the variants with the highest language quality factor.
-
-<LI>Select the variants with the best language match, using either the
- order of languages in the Accept-Language header (if present), or else
- else the order of languages in the <CODE>LanguagePriority</CODE>
- directive (if present).
-
-<LI>Select the variants with the highest 'level' media parameter
- (used to give the version of text/html media types).
-
-<LI>Select variants with the best charset media parameters,
- as given on the Accept-Charset header line. Charset ISO-8859-1
- is acceptable unless explicitly excluded. Variants with a
- <CODE>text/*</CODE> media type but not explicitly associated
- with a particular charset are assumed to be in ISO-8859-1.
-
-<LI>Select those variants which have associated
- charset media parameters that are <EM>not</EM> ISO-8859-1.
- If there are no such variants, select all variants instead.
-
-<LI>Select the variants with the best encoding. If there are
- variants with an encoding that is acceptable to the user-agent,
- select only these variants. Otherwise if there is a mix of encoded
- and non-encoded variants, select only the unencoded variants.
- If either all variants are encoded or all variants are not encoded,
- select all variants.
-
-<LI>Select the variants with the smallest content length.
-
-<LI>Select the first variant of those remaining. This will be either the
- first listed in the type-map file, or when variants are read from
- the directory, the one whose file name comes first when sorted using
- ASCII code order.
-
-</OL>
-
-<LI>The algorithm has now selected one 'best' variant, so return
- it as the response. The HTTP response header Vary is set to indicate the
- dimensions of negotiation (browsers and caches can use this
- information when caching the resource). End.
-
-<LI>To get here means no variant was selected (because none are acceptable
- to the browser). Return a 406 status (meaning "No acceptable representation")
- with a response body consisting of an HTML document listing the
- available variants. Also set the HTTP Vary header to indicate the
- dimensions of variance.
-
-</OL>
-
-<H2><A NAME="better">Fiddling with Quality Values</A></H2>
-
-<P>
-Apache sometimes changes the quality values from what would be
-expected by a strict interpretation of the Apache negotiation
-algorithm above. This is to get a better result from the algorithm for
-browsers which do not send full or accurate information. Some of the
-most popular browsers send Accept header information which would
-otherwise result in the selection of the wrong variant in many
-cases. If a browser sends full and correct information these fiddles
-will not be applied.
-<P>
-
-<H3>Media Types and Wildcards</H3>
-
-<P>
-The Accept: request header indicates preferences for media types. It
-can also include 'wildcard' media types, such as "image/*" or "*/*"
-where the * matches any string. So a request including:
-<PRE>
- Accept: image/*, */*
-</PRE>
-
-would indicate that any type starting "image/" is acceptable,
-as is any other type (so the first "image/*" is redundant). Some
-browsers routinely send wildcards in addition to explicit types they
-can handle. For example:
-<PRE>
- Accept: text/html, text/plain, image/gif, image/jpeg, */*
-</PRE>
-
-The intention of this is to indicate that the explicitly
-listed types are preferred, but if a different representation is
-available, that is ok too. However under the basic algorithm, as given
-above, the */* wildcard has exactly equal preference to all the other
-types, so they are not being preferred. The browser should really have
-sent a request with a lower quality (preference) value for *.*, such
-as:
-<PRE>
- Accept: text/html, text/plain, image/gif, image/jpeg, */*; q=0.01
-</PRE>
-
-The explicit types have no quality factor, so they default to a
-preference of 1.0 (the highest). The wildcard */* is given
-a low preference of 0.01, so other types will only be returned if
-no variant matches an explicitly listed type.
-<P>
-
-If the Accept: header contains <EM>no</EM> q factors at all, Apache sets
-the q value of "*/*", if present, to 0.01 to emulate the desired
-behavior. It also sets the q value of wildcards of the format
-"type/*" to 0.02 (so these are preferred over matches against
-"*/*". If any media type on the Accept: header contains a q factor,
-these special values are <EM>not</EM> applied, so requests from browsers
-which send the correct information to start with work as expected.
-
-<H3>Variants with no Language</H3>
-
-<P>
-If some of the variants for a particular resource have a language
-attribute, and some do not, those variants with no language
-are given a very low language quality factor of 0.001.<P>
-
-The reason for setting this language quality factor for
-variant with no language to a very low value is to allow
-for a default variant which can be supplied if none of the
-other variants match the browser's language preferences.
-
-For example, consider the situation with three variants:
-
-<UL>
-<LI>foo.en.html, language en
-<LI>foo.fr.html, language en
-<LI>foo.html, no language
-</UL>
-
-<P>
-The meaning of a variant with no language is that it is
-always acceptable to the browser. If the request Accept-Language
-header includes either en or fr (or both) one of foo.en.html
-or foo.fr.html will be returned. If the browser does not list
-either en or fr as acceptable, foo.html will be returned instead.
-
-<H2>Extensions to Transparent Content Negotiation</H2>
-
-Apache extends the transparent content negotiation protocol (RFC 2295)
-as follows. A new <CODE> {encoding ..}</CODE> element is used in
-variant lists to label variants which are available with a specific
-content-encoding only. The implementation of the
-RVSA/1.0 algorithm (RFC 2296) is extended to recognize encoded
-variants in the list, and to use them as candidate variants whenever
-their encodings are acceptable according to the Accept-Encoding
-request header. The RVSA/1.0 implementation does not round computed
-quality factors to 5 decimal places before choosing the best variant.
-
-<H2>Note on hyperlinks and naming conventions</H2>
-
-<P>
-If you are using language negotiation you can choose between
-different naming conventions, because files can have more than one
-extension, and the order of the extensions is normally irrelevant
-(see <A HREF="mod/mod_mime.html">mod_mime</A> documentation for details).
-<P>
-A typical file has a MIME-type extension (<EM>e.g.</EM>, <SAMP>html</SAMP>),
-maybe an encoding extension (<EM>e.g.</EM>, <SAMP>gz</SAMP>), and of course a
-language extension (<EM>e.g.</EM>, <SAMP>en</SAMP>) when we have different
-language variants of this file.
-
-<P>
-Examples:
-<UL>
-<LI>foo.en.html
-<LI>foo.html.en
-<LI>foo.en.html.gz
-</UL>
-
-<P>
-Here some more examples of filenames together with valid and invalid
-hyperlinks:
-</P>
-
-<TABLE BORDER=1 CELLPADDING=8 CELLSPACING=0>
-<TR>
- <TH>Filename</TH>
- <TH>Valid hyperlink</TH>
- <TH>Invalid hyperlink</TH>
-</TR>
-<TR>
- <TD><EM>foo.html.en</EM></TD>
- <TD>foo<BR>
- foo.html</TD>
- <TD>-</TD>
-</TR>
-<TR>
- <TD><EM>foo.en.html</EM></TD>
- <TD>foo</TD>
- <TD>foo.html</TD>
-</TR>
-<TR>
- <TD><EM>foo.html.en.gz</EM></TD>
- <TD>foo<BR>
- foo.html</TD>
- <TD>foo.gz<BR>
- foo.html.gz</TD>
-</TR>
-<TR>
- <TD><EM>foo.en.html.gz</EM></TD>
- <TD>foo</TD>
- <TD>foo.html<BR>
- foo.html.gz<BR>
- foo.gz</TD>
-</TR>
-<TR>
- <TD><EM>foo.gz.html.en</EM></TD>
- <TD>foo<BR>
- foo.gz<BR>
- foo.gz.html</TD>
- <TD>foo.html</TD>
-</TR>
-<TR>
- <TD><EM>foo.html.gz.en</EM></TD>
- <TD>foo<BR>
- foo.html<BR>
- foo.html.gz</TD>
- <TD>foo.gz</TD>
-</TR>
-</TABLE>
-
-<P>
-Looking at the table above you will notice that it is always possible to
-use the name without any extensions in an hyperlink (<EM>e.g.</EM>, <SAMP>foo</SAMP>).
-The advantage is that you can hide the actual type of a
-document rsp. file and can change it later, <EM>e.g.</EM>, from <SAMP>html</SAMP>
-to <SAMP>shtml</SAMP> or <SAMP>cgi</SAMP> without changing any
-hyperlink references.
-
-<P>
-If you want to continue to use a MIME-type in your hyperlinks (<EM>e.g.</EM>
-<SAMP>foo.html</SAMP>) the language extension (including an encoding extension
-if there is one) must be on the right hand side of the MIME-type extension
-(<EM>e.g.</EM>, <SAMP>foo.html.en</SAMP>).
-
-
-<H2>Note on Caching</H2>
-
-<P>
-When a cache stores a representation, it associates it with the request URL.
-The next time that URL is requested, the cache can use the stored
-representation. But, if the resource is negotiable at the server,
-this might result in only the first requested variant being cached and
-subsequent cache hits might return the wrong response. To prevent this,
-Apache normally marks all responses that are returned after content negotiation
-as non-cacheable by HTTP/1.0 clients. Apache also supports the HTTP/1.1
-protocol features to allow caching of negotiated responses. <P>
-
-For requests which come from a HTTP/1.0 compliant client (either a
-browser or a cache), the directive <TT>CacheNegotiatedDocs</TT> can be
-used to allow caching of responses which were subject to negotiation.
-This directive can be given in the server config or virtual host, and
-takes no arguments. It has no effect on requests from HTTP/1.1 clients.
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
diff --git a/docs/manual/custom-error.html.en b/docs/manual/custom-error.html.en
deleted file mode 100644
index 09604ea972..0000000000
--- a/docs/manual/custom-error.html.en
+++ /dev/null
@@ -1,177 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Custom error responses</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Custom error responses</H1>
-
-<DL>
-
-<DT>Purpose
-
- <DD>Additional functionality. Allows webmasters to configure the response of
- Apache to some error or problem.
-
- <P>Customizable responses can be defined to be activated in the
- event of a server detected error or problem.
-
- <P>e.g. if a script crashes and produces a "500 Server Error"
- response, then this response can be replaced with either some
- friendlier text or by a redirection to another URL (local or
- external).
- <P>
-
-<DT>Old behavior
-
- <DD>NCSA httpd 1.3 would return some boring old error/problem message
- which would often be meaningless to the user, and would provide no
- means of logging the symptoms which caused it.<BR>
-
- <P>
-
-<DT>New behavior
-
- <DD>The server can be asked to;
- <OL>
- <LI>Display some other text, instead of the NCSA hard coded messages, or
- <LI>redirect to a local URL, or
- <LI>redirect to an external URL.
- </OL>
-
- <P>Redirecting to another URL can be useful, but only if some information
- can be passed which can then be used to explain and/or log the
- error/problem
- more clearly.
-
- <P>To achieve this, Apache will define new CGI-like environment
- variables, <EM>e.g.</EM>
-
- <BLOCKQUOTE><CODE>
-REDIRECT_HTTP_ACCEPT=*/*, image/gif, image/x-xbitmap, image/jpeg <BR>
-REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX A.09.05 9000/712) <BR>
-REDIRECT_PATH=.:/bin:/usr/local/bin:/etc <BR>
-REDIRECT_QUERY_STRING= <BR>
-REDIRECT_REMOTE_ADDR=121.345.78.123 <BR>
-REDIRECT_REMOTE_HOST=ooh.ahhh.com <BR>
-REDIRECT_SERVER_NAME=crash.bang.edu <BR>
-REDIRECT_SERVER_PORT=80 <BR>
-REDIRECT_SERVER_SOFTWARE=Apache/0.8.15 <BR>
-REDIRECT_URL=/cgi-bin/buggy.pl <BR>
- </CODE></BLOCKQUOTE>
-
- <P>note the <CODE>REDIRECT_</CODE> prefix.
-
- <P>At least <CODE>REDIRECT_URL</CODE> and <CODE>REDIRECT_QUERY_STRING</CODE>
- will
- be passed to the new URL (assuming it's a cgi-script or a cgi-include).
- The
- other variables will exist only if they existed prior to the
- error/problem.
- <STRONG>None</STRONG> of these will be set if your ErrorDocument is an
- <EM>external</EM> redirect (<EM>i.e.</EM>, anything starting with a
- scheme name
- like <CODE>http:</CODE>, even if it refers to the same host as the
- server).<P>
-
-<DT>Configuration
-
- <DD> Use of "ErrorDocument" is enabled for .htaccess files when the
- <A HREF="mod/core.html#allowoverride">"FileInfo" override</A> is
- allowed.
-
- <P>Here are some examples...
-
- <BLOCKQUOTE><CODE>
-ErrorDocument 500 /cgi-bin/crash-recover <BR>
-ErrorDocument 500 "Sorry, our script crashed. Oh dear<BR>
-ErrorDocument 500 http://xxx/ <BR>
-ErrorDocument 404 /Lame_excuses/not_found.html <BR>
-ErrorDocument 401 /Subscription/how_to_subscribe.html
- </CODE></BLOCKQUOTE>
-
- <P>The syntax is,
-
- <P><CODE><A HREF="mod/core.html#errordocument">ErrorDocument</A></CODE>
-&lt;3-digit-code&gt; action
-
- <P>where the action can be,
-
- <OL>
- <LI>Text to be displayed. Prefix the text with a quote (&quot;). Whatever
- follows the quote is displayed. <EM>Note: the (&quot;) prefix isn't
- displayed.</EM>
-
- <LI>An external URL to redirect to.
-
- <LI>A local URL to redirect to.
-
- </OL>
-</DL>
-
-<P><HR><P>
-
-<H2>Custom error responses and redirects</H2>
-
-<DL>
-
-<DT>Purpose
-
- <DD>Apache's behavior to redirected URLs has been modified so that additional
- environment variables are available to a script/server-include.<P>
-
-<DT>Old behavior
-
- <DD>Standard CGI vars were made available to a script which has been
- redirected to. No indication of where the redirection came from was
- provided.
-
- <P>
-
-<DT>New behavior
- <DD>
-
-A new batch of environment variables will be initialized for use by a
-script which has been redirected to. Each new variable will have the
-prefix <CODE>REDIRECT_</CODE>. <CODE>REDIRECT_</CODE> environment
-variables are created from the CGI environment variables which existed
-prior to the redirect, they are renamed with a <CODE>REDIRECT_</CODE>
-prefix, <EM>i.e.</EM>, <CODE>HTTP_USER_AGENT</CODE> becomes
-<CODE>REDIRECT_HTTP_USER_AGENT</CODE>. In addition to these new
-variables, Apache will define <CODE>REDIRECT_URL</CODE> and
-<CODE>REDIRECT_STATUS</CODE> to help the script trace its origin.
-Both the original URL and the URL being redirected to can be logged in
-the access log.
-
-</DL>
-<P>
-If the ErrorDocument specifies a local redirect to a CGI script, the script
-should include a "<SAMP>Status:</SAMP>" header field in its output
-in order to ensure the propagation all the way back to the client
-of the error condition that caused it to be invoked. For instance, a Perl
-ErrorDocument script might include the following:
-</P>
-<PRE>
- :
- print "Content-type: text/html\n";
- printf "Status: %s Condition Intercepted\n", $ENV{"REDIRECT_STATUS"};
- :
-</PRE>
-<P>
-If the script is dedicated to handling a particular error condition, such as
-<SAMP>404&nbsp;Not&nbsp;Found</SAMP>, it can use the specific code and
-error text instead.
-</P>
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
diff --git a/docs/manual/developer/API.html b/docs/manual/developer/API.html
deleted file mode 100644
index bf0fb77d7a..0000000000
--- a/docs/manual/developer/API.html
+++ /dev/null
@@ -1,1153 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML><HEAD>
-<TITLE>Apache API notes</TITLE>
-</HEAD>
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Apache API notes</H1>
-
-These are some notes on the Apache API and the data structures you
-have to deal with, <EM>etc.</EM> They are not yet nearly complete, but
-hopefully, they will help you get your bearings. Keep in mind that
-the API is still subject to change as we gain experience with it.
-(See the TODO file for what <EM>might</EM> be coming). However,
-it will be easy to adapt modules to any changes that are made.
-(We have more modules to adapt than you do).
-<P>
-
-A few notes on general pedagogical style here. In the interest of
-conciseness, all structure declarations here are incomplete --- the
-real ones have more slots that I'm not telling you about. For the
-most part, these are reserved to one component of the server core or
-another, and should be altered by modules with caution. However, in
-some cases, they really are things I just haven't gotten around to
-yet. Welcome to the bleeding edge.<P>
-
-Finally, here's an outline, to give you some bare idea of what's
-coming up, and in what order:
-
-<UL>
-<LI> <A HREF="#basics">Basic concepts.</A>
-<MENU>
- <LI> <A HREF="#HMR">Handlers, Modules, and Requests</A>
- <LI> <A HREF="#moduletour">A brief tour of a module</A>
-</MENU>
-<LI> <A HREF="#handlers">How handlers work</A>
-<MENU>
- <LI> <A HREF="#req_tour">A brief tour of the <CODE>request_rec</CODE></A>
- <LI> <A HREF="#req_orig">Where request_rec structures come from</A>
- <LI> <A HREF="#req_return">Handling requests, declining, and returning error
- codes</A>
- <LI> <A HREF="#resp_handlers">Special considerations for response handlers</A>
- <LI> <A HREF="#auth_handlers">Special considerations for authentication
- handlers</A>
- <LI> <A HREF="#log_handlers">Special considerations for logging handlers</A>
-</MENU>
-<LI> <A HREF="#pools">Resource allocation and resource pools</A>
-<LI> <A HREF="#config">Configuration, commands and the like</A>
-<MENU>
- <LI> <A HREF="#per-dir">Per-directory configuration structures</A>
- <LI> <A HREF="#commands">Command handling</A>
- <LI> <A HREF="#servconf">Side notes --- per-server configuration,
- virtual servers, <EM>etc</EM>.</A>
-</MENU>
-</UL>
-
-<H2><A NAME="basics">Basic concepts.</A></H2>
-
-We begin with an overview of the basic concepts behind the
-API, and how they are manifested in the code.
-
-<H3><A NAME="HMR">Handlers, Modules, and Requests</A></H3>
-
-Apache breaks down request handling into a series of steps, more or
-less the same way the Netscape server API does (although this API has
-a few more stages than NetSite does, as hooks for stuff I thought
-might be useful in the future). These are:
-
-<UL>
- <LI> URI -&gt; Filename translation
- <LI> Auth ID checking [is the user who they say they are?]
- <LI> Auth access checking [is the user authorized <EM>here</EM>?]
- <LI> Access checking other than auth
- <LI> Determining MIME type of the object requested
- <LI> `Fixups' --- there aren't any of these yet, but the phase is
- intended as a hook for possible extensions like
- <CODE>SetEnv</CODE>, which don't really fit well elsewhere.
- <LI> Actually sending a response back to the client.
- <LI> Logging the request
-</UL>
-
-These phases are handled by looking at each of a succession of
-<EM>modules</EM>, looking to see if each of them has a handler for the
-phase, and attempting invoking it if so. The handler can typically do
-one of three things:
-
-<UL>
- <LI> <EM>Handle</EM> the request, and indicate that it has done so
- by returning the magic constant <CODE>OK</CODE>.
- <LI> <EM>Decline</EM> to handle the request, by returning the magic
- integer constant <CODE>DECLINED</CODE>. In this case, the
- server behaves in all respects as if the handler simply hadn't
- been there.
- <LI> Signal an error, by returning one of the HTTP error codes.
- This terminates normal handling of the request, although an
- ErrorDocument may be invoked to try to mop up, and it will be
- logged in any case.
-</UL>
-
-Most phases are terminated by the first module that handles them;
-however, for logging, `fixups', and non-access authentication
-checking, all handlers always run (barring an error). Also, the
-response phase is unique in that modules may declare multiple handlers
-for it, via a dispatch table keyed on the MIME type of the requested
-object. Modules may declare a response-phase handler which can handle
-<EM>any</EM> request, by giving it the key <CODE>*/*</CODE> (<EM>i.e.</EM>, a
-wildcard MIME type specification). However, wildcard handlers are
-only invoked if the server has already tried and failed to find a more
-specific response handler for the MIME type of the requested object
-(either none existed, or they all declined).<P>
-
-The handlers themselves are functions of one argument (a
-<CODE>request_rec</CODE> structure. vide infra), which returns an
-integer, as above.<P>
-
-<H3><A NAME="moduletour">A brief tour of a module</A></H3>
-
-At this point, we need to explain the structure of a module. Our
-candidate will be one of the messier ones, the CGI module --- this
-handles both CGI scripts and the <CODE>ScriptAlias</CODE> config file
-command. It's actually a great deal more complicated than most
-modules, but if we're going to have only one example, it might as well
-be the one with its fingers in every place.<P>
-
-Let's begin with handlers. In order to handle the CGI scripts, the
-module declares a response handler for them. Because of
-<CODE>ScriptAlias</CODE>, it also has handlers for the name
-translation phase (to recognize <CODE>ScriptAlias</CODE>ed URIs), the
-type-checking phase (any <CODE>ScriptAlias</CODE>ed request is typed
-as a CGI script).<P>
-
-The module needs to maintain some per (virtual)
-server information, namely, the <CODE>ScriptAlias</CODE>es in effect;
-the module structure therefore contains pointers to a functions which
-builds these structures, and to another which combines two of them (in
-case the main server and a virtual server both have
-<CODE>ScriptAlias</CODE>es declared).<P>
-
-Finally, this module contains code to handle the
-<CODE>ScriptAlias</CODE> command itself. This particular module only
-declares one command, but there could be more, so modules have
-<EM>command tables</EM> which declare their commands, and describe
-where they are permitted, and how they are to be invoked. <P>
-
-A final note on the declared types of the arguments of some of these
-commands: a <CODE>pool</CODE> is a pointer to a <EM>resource pool</EM>
-structure; these are used by the server to keep track of the memory
-which has been allocated, files opened, <EM>etc.</EM>, either to service a
-particular request, or to handle the process of configuring itself.
-That way, when the request is over (or, for the configuration pool,
-when the server is restarting), the memory can be freed, and the files
-closed, <EM>en masse</EM>, without anyone having to write explicit code to
-track them all down and dispose of them. Also, a
-<CODE>cmd_parms</CODE> structure contains various information about
-the config file being read, and other status information, which is
-sometimes of use to the function which processes a config-file command
-(such as <CODE>ScriptAlias</CODE>).
-
-With no further ado, the module itself:
-
-<PRE>
-/* Declarations of handlers. */
-
-int translate_scriptalias (request_rec *);
-int type_scriptalias (request_rec *);
-int cgi_handler (request_rec *);
-
-/* Subsidiary dispatch table for response-phase handlers, by MIME type */
-
-handler_rec cgi_handlers[] = {
-{ "application/x-httpd-cgi", cgi_handler },
-{ NULL }
-};
-
-/* Declarations of routines to manipulate the module's configuration
- * info. Note that these are returned, and passed in, as void *'s;
- * the server core keeps track of them, but it doesn't, and can't,
- * know their internal structure.
- */
-
-void *make_cgi_server_config (pool *);
-void *merge_cgi_server_config (pool *, void *, void *);
-
-/* Declarations of routines to handle config-file commands */
-
-extern char *script_alias(cmd_parms *, void *per_dir_config, char *fake,
- char *real);
-
-command_rec cgi_cmds[] = {
-{ "ScriptAlias", script_alias, NULL, RSRC_CONF, TAKE2,
- "a fakename and a realname"},
-{ NULL }
-};
-
-module cgi_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- NULL, /* dir config creator */
- NULL, /* dir merger --- default is to override */
- make_cgi_server_config, /* server config */
- merge_cgi_server_config, /* merge server config */
- cgi_cmds, /* command table */
- cgi_handlers, /* handlers */
- translate_scriptalias, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- type_scriptalias, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL /* header parser */
-};
-</PRE>
-
-<H2><A NAME="handlers">How handlers work</A></H2>
-
-The sole argument to handlers is a <CODE>request_rec</CODE> structure.
-This structure describes a particular request which has been made to
-the server, on behalf of a client. In most cases, each connection to
-the client generates only one <CODE>request_rec</CODE> structure.<P>
-
-<H3><A NAME="req_tour">A brief tour of the <CODE>request_rec</CODE></A></H3>
-
-The <CODE>request_rec</CODE> contains pointers to a resource pool
-which will be cleared when the server is finished handling the
-request; to structures containing per-server and per-connection
-information, and most importantly, information on the request itself.<P>
-
-The most important such information is a small set of character
-strings describing attributes of the object being requested, including
-its URI, filename, content-type and content-encoding (these being filled
-in by the translation and type-check handlers which handle the
-request, respectively). <P>
-
-Other commonly used data items are tables giving the MIME headers on
-the client's original request, MIME headers to be sent back with the
-response (which modules can add to at will), and environment variables
-for any subprocesses which are spawned off in the course of servicing
-the request. These tables are manipulated using the
-<CODE>ap_table_get</CODE> and <CODE>ap_table_set</CODE> routines. <P>
-<BLOCKQUOTE>
- Note that the <SAMP>Content-type</SAMP> header value <EM>cannot</EM> be
- set by module content-handlers using the <SAMP>ap_table_*()</SAMP>
- routines. Rather, it is set by pointing the <SAMP>content_type</SAMP>
- field in the <SAMP>request_rec</SAMP> structure to an appropriate
- string. <EM>E.g.</EM>,
- <PRE>
- r-&gt;content_type = "text/html";
- </PRE>
-</BLOCKQUOTE>
-Finally, there are pointers to two data structures which, in turn,
-point to per-module configuration structures. Specifically, these
-hold pointers to the data structures which the module has built to
-describe the way it has been configured to operate in a given
-directory (via <CODE>.htaccess</CODE> files or
-<CODE>&lt;Directory&gt;</CODE> sections), for private data it has
-built in the course of servicing the request (so modules' handlers for
-one phase can pass `notes' to their handlers for other phases). There
-is another such configuration vector in the <CODE>server_rec</CODE>
-data structure pointed to by the <CODE>request_rec</CODE>, which
-contains per (virtual) server configuration data.<P>
-
-Here is an abridged declaration, giving the fields most commonly used:<P>
-
-<PRE>
-struct request_rec {
-
- pool *pool;
- conn_rec *connection;
- server_rec *server;
-
- /* What object is being requested */
-
- char *uri;
- char *filename;
- char *path_info;
- char *args; /* QUERY_ARGS, if any */
- struct stat finfo; /* Set by server core;
- * st_mode set to zero if no such file */
-
- char *content_type;
- char *content_encoding;
-
- /* 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).
- */
-
- table *headers_in;
- table *headers_out;
- table *err_headers_out;
- table *subprocess_env;
-
- /* Info about the request itself... */
-
- int header_only; /* HEAD request, as opposed to GET */
- char *protocol; /* Protocol, as given to us, or HTTP/0.9 */
- char *method; /* GET, HEAD, POST, <EM>etc.</EM> */
- int method_number; /* M_GET, M_POST, <EM>etc.</EM> */
-
- /* Info for logging */
-
- char *the_request;
- int bytes_sent;
-
- /* A flag which modules can set, to indicate that the data being
- * returned is volatile, and clients should be told not to cache it.
- */
-
- int no_cache;
-
- /* 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).
- */
-
- void *per_dir_config; /* Options set in config files, <EM>etc.</EM> */
- void *request_config; /* Notes on *this* request */
-
-};
-
-</PRE>
-
-<H3><A NAME="req_orig">Where request_rec structures come from</A></H3>
-
-Most <CODE>request_rec</CODE> structures are built by reading an HTTP
-request from a client, and filling in the fields. However, there are
-a few exceptions:
-
-<UL>
- <LI> If the request is to an imagemap, a type map (<EM>i.e.</EM>, a
- <CODE>*.var</CODE> file), or a CGI script which returned a
- local `Location:', then the resource which the user requested
- is going to be ultimately located by some URI other than what
- the client originally supplied. In this case, the server does
- an <EM>internal redirect</EM>, constructing a new
- <CODE>request_rec</CODE> for the new URI, and processing it
- almost exactly as if the client had requested the new URI
- directly. <P>
-
- <LI> If some handler signaled an error, and an
- <CODE>ErrorDocument</CODE> is in scope, the same internal
- redirect machinery comes into play.<P>
-
- <LI> Finally, a handler occasionally needs to investigate `what
- would happen if' some other request were run. For instance,
- the directory indexing module needs to know what MIME type
- would be assigned to a request for each directory entry, in
- order to figure out what icon to use.<P>
-
- Such handlers can construct a <EM>sub-request</EM>, using the
- functions <CODE>ap_sub_req_lookup_file</CODE>,
- <CODE>ap_sub_req_lookup_uri</CODE>, and
- <CODE>ap_sub_req_method_uri</CODE>; these construct a new
- <CODE>request_rec</CODE> structure and processes it as you
- would expect, up to but not including the point of actually
- sending a response. (These functions skip over the access
- checks if the sub-request is for a file in the same directory
- as the original request).<P>
-
- (Server-side includes work by building sub-requests and then
- actually invoking the response handler for them, via the
- function <CODE>ap_run_sub_req</CODE>).
-</UL>
-
-<H3><A NAME="req_return">Handling requests, declining, and returning error
- codes</A></H3>
-
-As discussed above, each handler, when invoked to handle a particular
-<CODE>request_rec</CODE>, has to return an <CODE>int</CODE> to
-indicate what happened. That can either be
-
-<UL>
- <LI> OK --- the request was handled successfully. This may or may
- not terminate the phase.
- <LI> DECLINED --- no erroneous condition exists, but the module
- declines to handle the phase; the server tries to find another.
- <LI> an HTTP error code, which aborts handling of the request.
-</UL>
-
-Note that if the error code returned is <CODE>REDIRECT</CODE>, then
-the module should put a <CODE>Location</CODE> in the request's
-<CODE>headers_out</CODE>, to indicate where the client should be
-redirected <EM>to</EM>. <P>
-
-<H3><A NAME="resp_handlers">Special considerations for response
- handlers</A></H3>
-
-Handlers for most phases do their work by simply setting a few fields
-in the <CODE>request_rec</CODE> structure (or, in the case of access
-checkers, simply by returning the correct error code). However,
-response handlers have to actually send a request back to the client. <P>
-
-They should begin by sending an HTTP response header, using the
-function <CODE>ap_send_http_header</CODE>. (You don't have to do
-anything special to skip sending the header for HTTP/0.9 requests; the
-function figures out on its own that it shouldn't do anything). If
-the request is marked <CODE>header_only</CODE>, that's all they should
-do; they should return after that, without attempting any further
-output. <P>
-
-Otherwise, they should produce a request body which responds to the
-client as appropriate. The primitives for this are <CODE>ap_rputc</CODE>
-and <CODE>ap_rprintf</CODE>, for internally generated output, and
-<CODE>ap_send_fd</CODE>, to copy the contents of some <CODE>FILE *</CODE>
-straight to the client. <P>
-
-At this point, you should more or less understand the following piece
-of code, which is the handler which handles <CODE>GET</CODE> requests
-which have no more specific handler; it also shows how conditional
-<CODE>GET</CODE>s can be handled, if it's desirable to do so in a
-particular response handler --- <CODE>ap_set_last_modified</CODE> checks
-against the <CODE>If-modified-since</CODE> value supplied by the
-client, if any, and returns an appropriate code (which will, if
-nonzero, be USE_LOCAL_COPY). No similar considerations apply for
-<CODE>ap_set_content_length</CODE>, but it returns an error code for
-symmetry.<P>
-
-<PRE>
-int default_handler (request_rec *r)
-{
- int errstatus;
- FILE *f;
-
- if (r-&gt;method_number != M_GET) return DECLINED;
- if (r-&gt;finfo.st_mode == 0) return NOT_FOUND;
-
- if ((errstatus = ap_set_content_length (r, r-&gt;finfo.st_size))
- || (errstatus = ap_set_last_modified (r, r-&gt;finfo.st_mtime)))
- return errstatus;
-
- f = fopen (r-&gt;filename, "r");
-
- if (f == NULL) {
- log_reason("file permissions deny server access",
- r-&gt;filename, r);
- return FORBIDDEN;
- }
-
- register_timeout ("send", r);
- ap_send_http_header (r);
-
- if (!r-&gt;header_only) send_fd (f, r);
- ap_pfclose (r-&gt;pool, f);
- return OK;
-}
-</PRE>
-
-Finally, if all of this is too much of a challenge, there are a few
-ways out of it. First off, as shown above, a response handler which
-has not yet produced any output can simply return an error code, in
-which case the server will automatically produce an error response.
-Secondly, it can punt to some other handler by invoking
-<CODE>ap_internal_redirect</CODE>, which is how the internal redirection
-machinery discussed above is invoked. A response handler which has
-internally redirected should always return <CODE>OK</CODE>. <P>
-
-(Invoking <CODE>ap_internal_redirect</CODE> from handlers which are
-<EM>not</EM> response handlers will lead to serious confusion).
-
-<H3><A NAME="auth_handlers">Special considerations for authentication
- handlers</A></H3>
-
-Stuff that should be discussed here in detail:
-
-<UL>
- <LI> Authentication-phase handlers not invoked unless auth is
- configured for the directory.
- <LI> Common auth configuration stored in the core per-dir
- configuration; it has accessors <CODE>ap_auth_type</CODE>,
- <CODE>ap_auth_name</CODE>, and <CODE>ap_requires</CODE>.
- <LI> Common routines, to handle the protocol end of things, at least
- for HTTP basic authentication (<CODE>ap_get_basic_auth_pw</CODE>,
- which sets the <CODE>connection-&gt;user</CODE> structure field
- automatically, and <CODE>ap_note_basic_auth_failure</CODE>, which
- arranges for the proper <CODE>WWW-Authenticate:</CODE> header
- to be sent back).
-</UL>
-
-<H3><A NAME="log_handlers">Special considerations for logging handlers</A></H3>
-
-When a request has internally redirected, there is the question of
-what to log. Apache handles this by bundling the entire chain of
-redirects into a list of <CODE>request_rec</CODE> structures which are
-threaded through the <CODE>r-&gt;prev</CODE> and <CODE>r-&gt;next</CODE>
-pointers. The <CODE>request_rec</CODE> which is passed to the logging
-handlers in such cases is the one which was originally built for the
-initial request from the client; note that the bytes_sent field will
-only be correct in the last request in the chain (the one for which a
-response was actually sent).
-
-<H2><A NAME="pools">Resource allocation and resource pools</A></H2>
-<P>
-One of the problems of writing and designing a server-pool server is
-that of preventing leakage, that is, allocating resources (memory,
-open files, <EM>etc.</EM>), without subsequently releasing them. The resource
-pool machinery is designed to make it easy to prevent this from
-happening, by allowing resource to be allocated in such a way that
-they are <EM>automatically</EM> released when the server is done with
-them.
-</P>
-<P>
-The way this works is as follows: the memory which is allocated, file
-opened, <EM>etc.</EM>, to deal with a particular request are tied to a
-<EM>resource pool</EM> which is allocated for the request. The pool
-is a data structure which itself tracks the resources in question.
-</P>
-<P>
-When the request has been processed, the pool is <EM>cleared</EM>. At
-that point, all the memory associated with it is released for reuse,
-all files associated with it are closed, and any other clean-up
-functions which are associated with the pool are run. When this is
-over, we can be confident that all the resource tied to the pool have
-been released, and that none of them have leaked.
-</P>
-<P>
-Server restarts, and allocation of memory and resources for per-server
-configuration, are handled in a similar way. There is a
-<EM>configuration pool</EM>, which keeps track of resources which were
-allocated while reading the server configuration files, and handling
-the commands therein (for instance, the memory that was allocated for
-per-server module configuration, log files and other files that were
-opened, and so forth). When the server restarts, and has to reread
-the configuration files, the configuration pool is cleared, and so the
-memory and file descriptors which were taken up by reading them the
-last time are made available for reuse.
-</P>
-<P>
-It should be noted that use of the pool machinery isn't generally
-obligatory, except for situations like logging handlers, where you
-really need to register cleanups to make sure that the log file gets
-closed when the server restarts (this is most easily done by using the
-function <CODE><A HREF="#pool-files">ap_pfopen</A></CODE>, which also
-arranges for the underlying file descriptor to be closed before any
-child processes, such as for CGI scripts, are <CODE>exec</CODE>ed), or
-in case you are using the timeout machinery (which isn't yet even
-documented here). However, there are two benefits to using it:
-resources allocated to a pool never leak (even if you allocate a
-scratch string, and just forget about it); also, for memory
-allocation, <CODE>ap_palloc</CODE> is generally faster than
-<CODE>malloc</CODE>.
-</P>
-<P>
-We begin here by describing how memory is allocated to pools, and then
-discuss how other resources are tracked by the resource pool
-machinery.
-</P>
-<H3>Allocation of memory in pools</H3>
-<P>
-Memory is allocated to pools by calling the function
-<CODE>ap_palloc</CODE>, which takes two arguments, one being a pointer to
-a resource pool structure, and the other being the amount of memory to
-allocate (in <CODE>char</CODE>s). Within handlers for handling
-requests, the most common way of getting a resource pool structure is
-by looking at the <CODE>pool</CODE> slot of the relevant
-<CODE>request_rec</CODE>; hence the repeated appearance of the
-following idiom in module code:
-</P>
-<PRE>
-int my_handler(request_rec *r)
-{
- struct my_structure *foo;
- ...
-
- foo = (foo *)ap_palloc (r-&gt;pool, sizeof(my_structure));
-}
-</PRE>
-<P>
-Note that <EM>there is no <CODE>ap_pfree</CODE></EM> ---
-<CODE>ap_palloc</CODE>ed memory is freed only when the associated
-resource pool is cleared. This means that <CODE>ap_palloc</CODE> does not
-have to do as much accounting as <CODE>malloc()</CODE>; all it does in
-the typical case is to round up the size, bump a pointer, and do a
-range check.
-</P>
-<P>
-(It also raises the possibility that heavy use of <CODE>ap_palloc</CODE>
-could cause a server process to grow excessively large. There are
-two ways to deal with this, which are dealt with below; briefly, you
-can use <CODE>malloc</CODE>, and try to be sure that all of the memory
-gets explicitly <CODE>free</CODE>d, or you can allocate a sub-pool of
-the main pool, allocate your memory in the sub-pool, and clear it out
-periodically. The latter technique is discussed in the section on
-sub-pools below, and is used in the directory-indexing code, in order
-to avoid excessive storage allocation when listing directories with
-thousands of files).
-</P>
-<H3>Allocating initialized memory</H3>
-<P>
-There are functions which allocate initialized memory, and are
-frequently useful. The function <CODE>ap_pcalloc</CODE> has the same
-interface as <CODE>ap_palloc</CODE>, but clears out the memory it
-allocates before it returns it. The function <CODE>ap_pstrdup</CODE>
-takes a resource pool and a <CODE>char *</CODE> as arguments, and
-allocates memory for a copy of the string the pointer points to,
-returning a pointer to the copy. Finally <CODE>ap_pstrcat</CODE> is a
-varargs-style function, which takes a pointer to a resource pool, and
-at least two <CODE>char *</CODE> arguments, the last of which must be
-<CODE>NULL</CODE>. It allocates enough memory to fit copies of each
-of the strings, as a unit; for instance:
-</P>
-<PRE>
- ap_pstrcat (r-&gt;pool, "foo", "/", "bar", NULL);
-</PRE>
-<P>
-returns a pointer to 8 bytes worth of memory, initialized to
-<CODE>"foo/bar"</CODE>.
-</P>
-<H3><A NAME="pools-used">Commonly-used pools in the Apache Web server</A></H3>
-<P>
-A pool is really defined by its lifetime more than anything else. There
-are some static pools in http_main which are passed to various
-non-http_main functions as arguments at opportune times. Here they are:
-</P>
-<DL COMPACT>
- <DT>permanent_pool
- </DT>
- <DD>
- <UL>
- <LI>never passed to anything else, this is the ancestor of all pools
- </LI>
- </UL>
- </DD>
- <DT>pconf
- </DT>
- <DD>
- <UL>
- <LI>subpool of permanent_pool
- </LI>
- <LI>created at the beginning of a config "cycle"; exists until the
- server is terminated or restarts; passed to all config-time
- routines, either via cmd-&gt;pool, or as the "pool *p" argument on
- those which don't take pools
- </LI>
- <LI>passed to the module init() functions
- </LI>
- </UL>
- </DD>
- <DT>ptemp
- </DT>
- <DD>
- <UL>
- <LI>sorry I lie, this pool isn't called this currently in 1.3, I
- renamed it this in my pthreads development. I'm referring to
- the use of ptrans in the parent... contrast this with the later
- definition of ptrans in the child.
- </LI>
- <LI>subpool of permanent_pool
- </LI>
- <LI>created at the beginning of a config "cycle"; exists until the
- end of config parsing; passed to config-time routines <EM>via</EM>
- cmd-&gt;temp_pool. Somewhat of a "bastard child" because it isn't
- available everywhere. Used for temporary scratch space which
- may be needed by some config routines but which is deleted at
- the end of config.
- </LI>
- </UL>
- </DD>
- <DT>pchild
- </DT>
- <DD>
- <UL>
- <LI>subpool of permanent_pool
- </LI>
- <LI>created when a child is spawned (or a thread is created); lives
- until that child (thread) is destroyed
- </LI>
- <LI>passed to the module child_init functions
- </LI>
- <LI>destruction happens right after the child_exit functions are
- called... (which may explain why I think child_exit is redundant
- and unneeded)
- </LI>
- </UL>
- </DD>
- <DT>ptrans
- <DT>
- <DD>
- <UL>
- <LI>should be a subpool of pchild, but currently is a subpool of
- permanent_pool, see above
- </LI>
- <LI>cleared by the child before going into the accept() loop to receive
- a connection
- </LI>
- <LI>used as connection-&gt;pool
- </LI>
- </UL>
- </DD>
- <DT>r-&gt;pool
- </DT>
- <DD>
- <UL>
- <LI>for the main request this is a subpool of connection-&gt;pool; for
- subrequests it is a subpool of the parent request's pool.
- </LI>
- <LI>exists until the end of the request (<EM>i.e.</EM>,
- ap_destroy_sub_req, or
- in child_main after process_request has finished)
- </LI>
- <LI>note that r itself is allocated from r-&gt;pool; <EM>i.e.</EM>,
- r-&gt;pool is
- first created and then r is the first thing palloc()d from it
- </LI>
- </UL>
- </DD>
-</DL>
-<P>
-For almost everything folks do, r-&gt;pool is the pool to use. But you
-can see how other lifetimes, such as pchild, are useful to some
-modules... such as modules that need to open a database connection once
-per child, and wish to clean it up when the child dies.
-</P>
-<P>
-You can also see how some bugs have manifested themself, such as setting
-connection-&gt;user to a value from r-&gt;pool -- in this case
-connection exists
-for the lifetime of ptrans, which is longer than r-&gt;pool (especially if
-r-&gt;pool is a subrequest!). So the correct thing to do is to allocate
-from connection-&gt;pool.
-</P>
-<P>
-And there was another interesting bug in mod_include/mod_cgi. You'll see
-in those that they do this test to decide if they should use r-&gt;pool
-or r-&gt;main-&gt;pool. In this case the resource that they are registering
-for cleanup is a child process. If it were registered in r-&gt;pool,
-then the code would wait() for the child when the subrequest finishes.
-With mod_include this could be any old #include, and the delay can be up
-to 3 seconds... and happened quite frequently. Instead the subprocess
-is registered in r-&gt;main-&gt;pool which causes it to be cleaned up when
-the entire request is done -- <EM>i.e.</EM>, after the output has been sent to
-the client and logging has happened.
-</P>
-<H3><A NAME="pool-files">Tracking open files, etc.</A></H3>
-<P>
-As indicated above, resource pools are also used to track other sorts
-of resources besides memory. The most common are open files. The
-routine which is typically used for this is <CODE>ap_pfopen</CODE>, which
-takes a resource pool and two strings as arguments; the strings are
-the same as the typical arguments to <CODE>fopen</CODE>, <EM>e.g.</EM>,
-</P>
-<PRE>
- ...
- FILE *f = ap_pfopen (r-&gt;pool, r-&gt;filename, "r");
-
- if (f == NULL) { ... } else { ... }
-</PRE>
-<P>
-There is also a <CODE>ap_popenf</CODE> routine, which parallels the
-lower-level <CODE>open</CODE> system call. Both of these routines
-arrange for the file to be closed when the resource pool in question
-is cleared.
-</P>
-<P>
-Unlike the case for memory, there <EM>are</EM> functions to close
-files allocated with <CODE>ap_pfopen</CODE>, and <CODE>ap_popenf</CODE>,
-namely <CODE>ap_pfclose</CODE> and <CODE>ap_pclosef</CODE>. (This is
-because, on many systems, the number of files which a single process
-can have open is quite limited). It is important to use these
-functions to close files allocated with <CODE>ap_pfopen</CODE> and
-<CODE>ap_popenf</CODE>, since to do otherwise could cause fatal errors on
-systems such as Linux, which react badly if the same
-<CODE>FILE*</CODE> is closed more than once.
-</P>
-<P>
-(Using the <CODE>close</CODE> functions is not mandatory, since the
-file will eventually be closed regardless, but you should consider it
-in cases where your module is opening, or could open, a lot of files).
-</P>
-<H3>Other sorts of resources --- cleanup functions</H3>
-<BLOCKQUOTE>
-More text goes here. Describe the the cleanup primitives in terms of
-which the file stuff is implemented; also, <CODE>spawn_process</CODE>.
-</BLOCKQUOTE>
-<P>
-Pool cleanups live until clear_pool() is called: clear_pool(a) recursively
-calls destroy_pool() on all subpools of a; then calls all the cleanups for a;
-then releases all the memory for a. destroy_pool(a) calls clear_pool(a)
-and then releases the pool structure itself. <EM>i.e.</EM>, clear_pool(a) doesn't
-delete a, it just frees up all the resources and you can start using it
-again immediately.
-</P>
-<H3>Fine control --- creating and dealing with sub-pools, with a note
-on sub-requests</H3>
-
-On rare occasions, too-free use of <CODE>ap_palloc()</CODE> and the
-associated primitives may result in undesirably profligate resource
-allocation. You can deal with such a case by creating a
-<EM>sub-pool</EM>, allocating within the sub-pool rather than the main
-pool, and clearing or destroying the sub-pool, which releases the
-resources which were associated with it. (This really <EM>is</EM> a
-rare situation; the only case in which it comes up in the standard
-module set is in case of listing directories, and then only with
-<EM>very</EM> large directories. Unnecessary use of the primitives
-discussed here can hair up your code quite a bit, with very little
-gain). <P>
-
-The primitive for creating a sub-pool is <CODE>ap_make_sub_pool</CODE>,
-which takes another pool (the parent pool) as an argument. When the
-main pool is cleared, the sub-pool will be destroyed. The sub-pool
-may also be cleared or destroyed at any time, by calling the functions
-<CODE>ap_clear_pool</CODE> and <CODE>ap_destroy_pool</CODE>, respectively.
-(The difference is that <CODE>ap_clear_pool</CODE> frees resources
-associated with the pool, while <CODE>ap_destroy_pool</CODE> also
-deallocates the pool itself. In the former case, you can allocate new
-resources within the pool, and clear it again, and so forth; in the
-latter case, it is simply gone). <P>
-
-One final note --- sub-requests have their own resource pools, which
-are sub-pools of the resource pool for the main request. The polite
-way to reclaim the resources associated with a sub request which you
-have allocated (using the <CODE>ap_sub_req_...</CODE> functions)
-is <CODE>ap_destroy_sub_req</CODE>, which frees the resource pool.
-Before calling this function, be sure to copy anything that you care
-about which might be allocated in the sub-request's resource pool into
-someplace a little less volatile (for instance, the filename in its
-<CODE>request_rec</CODE> structure). <P>
-
-(Again, under most circumstances, you shouldn't feel obliged to call
-this function; only 2K of memory or so are allocated for a typical sub
-request, and it will be freed anyway when the main request pool is
-cleared. It is only when you are allocating many, many sub-requests
-for a single main request that you should seriously consider the
-<CODE>ap_destroy_...</CODE> functions).
-
-<H2><A NAME="config">Configuration, commands and the like</A></H2>
-
-One of the design goals for this server was to maintain external
-compatibility with the NCSA 1.3 server --- that is, to read the same
-configuration files, to process all the directives therein correctly,
-and in general to be a drop-in replacement for NCSA. On the other
-hand, another design goal was to move as much of the server's
-functionality into modules which have as little as possible to do with
-the monolithic server core. The only way to reconcile these goals is
-to move the handling of most commands from the central server into the
-modules. <P>
-
-However, just giving the modules command tables is not enough to
-divorce them completely from the server core. The server has to
-remember the commands in order to act on them later. That involves
-maintaining data which is private to the modules, and which can be
-either per-server, or per-directory. Most things are per-directory,
-including in particular access control and authorization information,
-but also information on how to determine file types from suffixes,
-which can be modified by <CODE>AddType</CODE> and
-<CODE>DefaultType</CODE> directives, and so forth. In general, the
-governing philosophy is that anything which <EM>can</EM> be made
-configurable by directory should be; per-server information is
-generally used in the standard set of modules for information like
-<CODE>Alias</CODE>es and <CODE>Redirect</CODE>s which come into play
-before the request is tied to a particular place in the underlying
-file system. <P>
-
-Another requirement for emulating the NCSA server is being able to
-handle the per-directory configuration files, generally called
-<CODE>.htaccess</CODE> files, though even in the NCSA server they can
-contain directives which have nothing at all to do with access
-control. Accordingly, after URI -&gt; filename translation, but before
-performing any other phase, the server walks down the directory
-hierarchy of the underlying filesystem, following the translated
-pathname, to read any <CODE>.htaccess</CODE> files which might be
-present. The information which is read in then has to be
-<EM>merged</EM> with the applicable information from the server's own
-config files (either from the <CODE>&lt;Directory&gt;</CODE> sections
-in <CODE>access.conf</CODE>, or from defaults in
-<CODE>srm.conf</CODE>, which actually behaves for most purposes almost
-exactly like <CODE>&lt;Directory /&gt;</CODE>).<P>
-
-Finally, after having served a request which involved reading
-<CODE>.htaccess</CODE> files, we need to discard the storage allocated
-for handling them. That is solved the same way it is solved wherever
-else similar problems come up, by tying those structures to the
-per-transaction resource pool. <P>
-
-<H3><A NAME="per-dir">Per-directory configuration structures</A></H3>
-
-Let's look out how all of this plays out in <CODE>mod_mime.c</CODE>,
-which defines the file typing handler which emulates the NCSA server's
-behavior of determining file types from suffixes. What we'll be
-looking at, here, is the code which implements the
-<CODE>AddType</CODE> and <CODE>AddEncoding</CODE> commands. These
-commands can appear in <CODE>.htaccess</CODE> files, so they must be
-handled in the module's private per-directory data, which in fact,
-consists of two separate <CODE>table</CODE>s for MIME types and
-encoding information, and is declared as follows:
-
-<PRE>
-typedef struct {
- table *forced_types; /* Additional AddTyped stuff */
- table *encoding_types; /* Added with AddEncoding... */
-} mime_dir_config;
-</PRE>
-
-When the server is reading a configuration file, or
-<CODE>&lt;Directory&gt;</CODE> section, which includes one of the MIME
-module's commands, it needs to create a <CODE>mime_dir_config</CODE>
-structure, so those commands have something to act on. It does this
-by invoking the function it finds in the module's `create per-dir
-config slot', with two arguments: the name of the directory to which
-this configuration information applies (or <CODE>NULL</CODE> for
-<CODE>srm.conf</CODE>), and a pointer to a resource pool in which the
-allocation should happen. <P>
-
-(If we are reading a <CODE>.htaccess</CODE> file, that resource pool
-is the per-request resource pool for the request; otherwise it is a
-resource pool which is used for configuration data, and cleared on
-restarts. Either way, it is important for the structure being created
-to vanish when the pool is cleared, by registering a cleanup on the
-pool if necessary). <P>
-
-For the MIME module, the per-dir config creation function just
-<CODE>ap_palloc</CODE>s the structure above, and a creates a couple of
-<CODE>table</CODE>s to fill it. That looks like this:
-
-<PRE>
-void *create_mime_dir_config (pool *p, char *dummy)
-{
- mime_dir_config *new =
- (mime_dir_config *) ap_palloc (p, sizeof(mime_dir_config));
-
- new-&gt;forced_types = ap_make_table (p, 4);
- new-&gt;encoding_types = ap_make_table (p, 4);
-
- return new;
-}
-</PRE>
-
-Now, suppose we've just read in a <CODE>.htaccess</CODE> file. We
-already have the per-directory configuration structure for the next
-directory up in the hierarchy. If the <CODE>.htaccess</CODE> file we
-just read in didn't have any <CODE>AddType</CODE> or
-<CODE>AddEncoding</CODE> commands, its per-directory config structure
-for the MIME module is still valid, and we can just use it.
-Otherwise, we need to merge the two structures somehow. <P>
-
-To do that, the server invokes the module's per-directory config merge
-function, if one is present. That function takes three arguments:
-the two structures being merged, and a resource pool in which to
-allocate the result. For the MIME module, all that needs to be done
-is overlay the tables from the new per-directory config structure with
-those from the parent:
-
-<PRE>
-void *merge_mime_dir_configs (pool *p, void *parent_dirv, void *subdirv)
-{
- mime_dir_config *parent_dir = (mime_dir_config *)parent_dirv;
- mime_dir_config *subdir = (mime_dir_config *)subdirv;
- mime_dir_config *new =
- (mime_dir_config *)ap_palloc (p, sizeof(mime_dir_config));
-
- new-&gt;forced_types = ap_overlay_tables (p, subdir-&gt;forced_types,
- parent_dir-&gt;forced_types);
- new-&gt;encoding_types = ap_overlay_tables (p, subdir-&gt;encoding_types,
- parent_dir-&gt;encoding_types);
-
- return new;
-}
-</PRE>
-
-As a note --- if there is no per-directory merge function present, the
-server will just use the subdirectory's configuration info, and ignore
-the parent's. For some modules, that works just fine (<EM>e.g.</EM>, for the
-includes module, whose per-directory configuration information
-consists solely of the state of the <CODE>XBITHACK</CODE>), and for
-those modules, you can just not declare one, and leave the
-corresponding structure slot in the module itself <CODE>NULL</CODE>.<P>
-
-<H3><A NAME="commands">Command handling</A></H3>
-
-Now that we have these structures, we need to be able to figure out
-how to fill them. That involves processing the actual
-<CODE>AddType</CODE> and <CODE>AddEncoding</CODE> commands. To find
-commands, the server looks in the module's <CODE>command table</CODE>.
-That table contains information on how many arguments the commands
-take, and in what formats, where it is permitted, and so forth. That
-information is sufficient to allow the server to invoke most
-command-handling functions with pre-parsed arguments. Without further
-ado, let's look at the <CODE>AddType</CODE> command handler, which
-looks like this (the <CODE>AddEncoding</CODE> command looks basically
-the same, and won't be shown here):
-
-<PRE>
-char *add_type(cmd_parms *cmd, mime_dir_config *m, char *ct, char *ext)
-{
- if (*ext == '.') ++ext;
- ap_table_set (m-&gt;forced_types, ext, ct);
- return NULL;
-}
-</PRE>
-
-This command handler is unusually simple. As you can see, it takes
-four arguments, two of which are pre-parsed arguments, the third being
-the per-directory configuration structure for the module in question,
-and the fourth being a pointer to a <CODE>cmd_parms</CODE> structure.
-That structure contains a bunch of arguments which are frequently of
-use to some, but not all, commands, including a resource pool (from
-which memory can be allocated, and to which cleanups should be tied),
-and the (virtual) server being configured, from which the module's
-per-server configuration data can be obtained if required.<P>
-
-Another way in which this particular command handler is unusually
-simple is that there are no error conditions which it can encounter.
-If there were, it could return an error message instead of
-<CODE>NULL</CODE>; this causes an error to be printed out on the
-server's <CODE>stderr</CODE>, followed by a quick exit, if it is in
-the main config files; for a <CODE>.htaccess</CODE> file, the syntax
-error is logged in the server error log (along with an indication of
-where it came from), and the request is bounced with a server error
-response (HTTP error status, code 500). <P>
-
-The MIME module's command table has entries for these commands, which
-look like this:
-
-<PRE>
-command_rec mime_cmds[] = {
-{ "AddType", add_type, NULL, OR_FILEINFO, TAKE2,
- "a mime type followed by a file extension" },
-{ "AddEncoding", add_encoding, NULL, OR_FILEINFO, TAKE2,
- "an encoding (<EM>e.g.</EM>, gzip), followed by a file extension" },
-{ NULL }
-};
-</PRE>
-
-The entries in these tables are:
-
-<UL>
- <LI> The name of the command
- <LI> The function which handles it
- <LI> a <CODE>(void *)</CODE> pointer, which is passed in the
- <CODE>cmd_parms</CODE> structure to the command handler ---
- this is useful in case many similar commands are handled by the
- same function.
- <LI> A bit mask indicating where the command may appear. There are
- mask bits corresponding to each <CODE>AllowOverride</CODE>
- option, and an additional mask bit, <CODE>RSRC_CONF</CODE>,
- indicating that the command may appear in the server's own
- config files, but <EM>not</EM> in any <CODE>.htaccess</CODE>
- file.
- <LI> A flag indicating how many arguments the command handler wants
- pre-parsed, and how they should be passed in.
- <CODE>TAKE2</CODE> indicates two pre-parsed arguments. Other
- options are <CODE>TAKE1</CODE>, which indicates one pre-parsed
- argument, <CODE>FLAG</CODE>, which indicates that the argument
- should be <CODE>On</CODE> or <CODE>Off</CODE>, and is passed in
- as a boolean flag, <CODE>RAW_ARGS</CODE>, which causes the
- server to give the command the raw, unparsed arguments
- (everything but the command name itself). There is also
- <CODE>ITERATE</CODE>, which means that the handler looks the
- same as <CODE>TAKE1</CODE>, but that if multiple arguments are
- present, it should be called multiple times, and finally
- <CODE>ITERATE2</CODE>, which indicates that the command handler
- looks like a <CODE>TAKE2</CODE>, but if more arguments are
- present, then it should be called multiple times, holding the
- first argument constant.
- <LI> Finally, we have a string which describes the arguments that
- should be present. If the arguments in the actual config file
- are not as required, this string will be used to help give a
- more specific error message. (You can safely leave this
- <CODE>NULL</CODE>).
-</UL>
-
-Finally, having set this all up, we have to use it. This is
-ultimately done in the module's handlers, specifically for its
-file-typing handler, which looks more or less like this; note that the
-per-directory configuration structure is extracted from the
-<CODE>request_rec</CODE>'s per-directory configuration vector by using
-the <CODE>ap_get_module_config</CODE> function.
-
-<PRE>
-int find_ct(request_rec *r)
-{
- int i;
- char *fn = ap_pstrdup (r-&gt;pool, r-&gt;filename);
- mime_dir_config *conf = (mime_dir_config *)
- ap_get_module_config(r-&gt;per_dir_config, &amp;mime_module);
- char *type;
-
- if (S_ISDIR(r-&gt;finfo.st_mode)) {
- r-&gt;content_type = DIR_MAGIC_TYPE;
- return OK;
- }
-
- if((i=ap_rind(fn,'.')) &lt; 0) return DECLINED;
- ++i;
-
- if ((type = ap_table_get (conf-&gt;encoding_types, &amp;fn[i])))
- {
- r-&gt;content_encoding = type;
-
- /* go back to previous extension to try to use it as a type */
-
- fn[i-1] = '\0';
- if((i=ap_rind(fn,'.')) &lt; 0) return OK;
- ++i;
- }
-
- if ((type = ap_table_get (conf-&gt;forced_types, &amp;fn[i])))
- {
- r-&gt;content_type = type;
- }
-
- return OK;
-}
-
-</PRE>
-
-<H3><A NAME="servconf">Side notes --- per-server configuration, virtual
- servers, <EM>etc</EM>.</A></H3>
-
-The basic ideas behind per-server module configuration are basically
-the same as those for per-directory configuration; there is a creation
-function and a merge function, the latter being invoked where a
-virtual server has partially overridden the base server configuration,
-and a combined structure must be computed. (As with per-directory
-configuration, the default if no merge function is specified, and a
-module is configured in some virtual server, is that the base
-configuration is simply ignored). <P>
-
-The only substantial difference is that when a command needs to
-configure the per-server private module data, it needs to go to the
-<CODE>cmd_parms</CODE> data to get at it. Here's an example, from the
-alias module, which also indicates how a syntax error can be returned
-(note that the per-directory configuration argument to the command
-handler is declared as a dummy, since the module doesn't actually have
-per-directory config data):
-
-<PRE>
-char *add_redirect(cmd_parms *cmd, void *dummy, char *f, char *url)
-{
- server_rec *s = cmd-&gt;server;
- alias_server_conf *conf = (alias_server_conf *)
- ap_get_module_config(s-&gt;module_config,&amp;alias_module);
- alias_entry *new = ap_push_array (conf-&gt;redirects);
-
- if (!ap_is_url (url)) return "Redirect to non-URL";
-
- new-&gt;fake = f; new-&gt;real = url;
- return NULL;
-}
-</PRE>
-<!--#include virtual="footer.html" -->
-</BODY></HTML>
diff --git a/docs/manual/developer/hooks.html b/docs/manual/developer/hooks.html
deleted file mode 100644
index 39f4e8bad1..0000000000
--- a/docs/manual/developer/hooks.html
+++ /dev/null
@@ -1,202 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<title>Apache 2.0 Hook Functions</title>
-</head>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-
-<H1 align="center">Apache Hook Functions</H1>
-
-<P>In general, a hook function is one that Apache will call at some
-point during the processing of a request. Modules can provide
-functions that are called, and specify when they get called in
-comparison to other modules.</P>
-
-<H2>Creating a hook function</H2>
-
-<P>In order to create a new hook, four things need to be done:</P>
-
-<H3>Declare the hook function</H3>
-
-<P>Use the DECLARE_HOOK macro, which needs to be given the name of the
-hook, the return type of the hook function and the arguments. For
-example, if the hook returns an <TT>int</TT> and takes a
-<TT>request_rec *</TT> and an <TT>int</TT> and is called
-"do_something", then declare it like this:</P>
-
-<TT>DECLARE_HOOK(int,do_something,(request_rec *r,int n))</TT>
-
-<P>This should go in a header which modules will include if they want
-to use the hook.</P>
-
-<H3>Create the hook structure</H3>
-
-<P>Each source file that exports a hook has a private structure which
-is used to record the module functions that use the hook. This is
-declared as follows:</P>
-
-<PRE>
-HOOK_STRUCT(
- HOOK_LINK(do_something)
- ...
- )
-</PRE>
-
-<H3>Implement the hook caller</H3>
-
-<P>The source file that exports the hook has to implement a function
-that will call the hook. There are currently three possible ways to do
-this. In all cases, the calling function is called
-<TT>ap_run_<I>hookname</I>()</TT>.</P>
-
-<H4>Void hooks</H4>
-
-<P>If the return value of a hook is <TT>void</TT>, then all the hooks are
-called, and the caller is implemented like this:</P>
-
-<TT>IMPLEMENT_HOOK_VOID(do_something,(request_rec *r,int
-n),(r,n))</TT>
-
-<P>The second and third arguments are the dummy argument declaration and
-the dummy arguments as they will be used when calling the hook. In
-other words, this macro expands to something like this:</P>
-
-<PRE>
-void ap_run_do_something(request_rec *r,int n)
-{
- ...
- do_something(r,n);
-}
-</PRE>
-
-<H4>Hooks that return a value</H4>
-
-<P>If the hook returns a value, then it can either be run until the first
-hook that does something interesting, like so:</P>
-
-<TT>IMPLEMENT_HOOK_RUN_FIRST(int,do_something,(request_rec *r,int n),(r,n),DECLINED)</TT>
-
-<P>The first hook that <I>doesn't</I> return <TT>DECLINED</TT> stops
-the loop and its return value is returned from the hook caller. Note
-that <TT>DECLINED</TT> is the tradition Apache hook return meaning "I
-didn't do anything", but it can be whatever suits you.</P>
-
-<P>Alternatively, all hooks can be run until an error occurs. This
-boils down to permitting <I>two</I> return values, one of which means
-"I did something, and it was OK" and the other meaning "I did
-nothing". The first function that returns a value other than one of
-those two stops the loop, and its return is the return value. Declare
-these like so:</P>
-
-<TT>IMPLEMENT_HOOK_RUN_ALL(int,do_something,(request_rec *r,int
-n),(r,n),OK,DECLINED)</TT>
-
-<P>Again, <TT>OK</TT> and <TT>DECLINED</TT> are the traditional
-values. You can use what you want.</P>
-
-<H3>Call the hook callers</H3>
-
-<P>At appropriate moments in the code, call the hook caller, like
-so:</P>
-
-<PRE>
- int n,ret;
- request_rec *r;
-
- ret=ap_run_do_something(r,n);
-</PRE>
-
-<H2>Hooking the hook</H2>
-
-<P>A module that wants a hook to be called needs to do two
-things.</P>
-
-<H3>Implement the hook function</H3>
-
-<P>Include the appropriate header, and define a static function of the
-correct type:</P>
-
-<PRE>
-static int my_something_doer(request_rec *r,int n)
-{
- ...
- return OK;
-}
-</PRE>
-
-<H3>Add a hook registering function</H3>
-
-<P>During initialisation, Apache will call each modules hook
-registering function, which is included in the module structure:</P>
-
-<PRE>
-static void my_register_hooks()
-{
- ap_hook_do_something(my_something_doer,NULL,NULL,HOOK_MIDDLE);
-}
-
-mode MODULE_VAR_EXPORT my_module =
-{
- ...
- my_register_hooks /* register hooks */
-};
-</PRE>
-
-<H3>Controlling hook calling order</H3>
-
-<P>In the example above, we didn't use the three arguments in the hook
-registration function that control calling order. There are two
-mechanisms for doing this. The first, rather crude, method, allows us
-to specify roughly where the hook is run relative to other
-modules. The final argument control this. There are three possible
-values:</P>
-
-<PRE>
-HOOK_FIRST
-HOOK_MIDDLE
-HOOK_LAST
-</PRE>
-
-<P>All modules using any particular value may be run in any order
-relative to each other, but, of course, all modules using
-<TT>HOOK_FIRST</TT> will be run before <TT>HOOK_MIDDLE</TT> which are
-before <TT>HOOK_LAST</TT>. Modules that don't care when they are run
-should use <TT>HOOK_MIDDLE</TT>. <I>(I spaced these out so people
-could do stuff like <TT>HOOK_FIRST-2</TT> to get in slightly earlier,
-but is this wise? - Ben)</I></P>
-
-<P>Note that there are two more values, <TT>HOOK_REALLY_FIRST</TT> and
-<TT>HOOK_REALLY_LAST</TT>. These should only be used by the hook
-exporter.</P>
-
-<P>The other method allows finer control. When a module knows that it
-must be run before (or after) some other modules, it can specify them
-by name. The second (third) argument is a NULL-terminated array of
-strings consisting of the names of modules that must be run before
-(after) the current module. For example, suppose we want "mod_xyz.c"
-and "mod_abc.c" to run before we do, then we'd hook as follows:</P>
-
-<PRE>
-static void register_hooks()
-{
- static const char * const aszPre[]={ "mod_xyz.c", "mod_abc.c", NULL };
-
- ap_hook_do_something(my_something_doer,aszPre,NULL,HOOK_MIDDLE);
-}
-</PRE>
-
-<P>Note that the sort used to achieve this is stable, so ordering set
-by <TT>HOOK_<I>ORDER</I></TT> is preserved, as far as is
-possible.</P>
-
-<I>Ben Laurie, 15th August 1999</I>
-</body>
-</html>
diff --git a/docs/manual/developer/index.html b/docs/manual/developer/index.html
deleted file mode 100644
index a72dd44b21..0000000000
--- a/docs/manual/developer/index.html
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<title>Apache-2.0 Developer Documentation</title>
-</head>
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<h2 align="center">Developer Documentation for Apache-2.0</h2>
-<p><a href="hooks.html">Apache Hook Functions</a></p>
-<p><a href="modules.html">Converting Apache 1.3 Modules to Apache 2.0</a></p>
-<p><a href="../user/mpm.html">MPM listing</a></p>
-</body>
-</html>
diff --git a/docs/manual/developer/modules.html b/docs/manual/developer/modules.html
deleted file mode 100644
index b066223466..0000000000
--- a/docs/manual/developer/modules.html
+++ /dev/null
@@ -1,200 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Converting Modules from Apache 1.3 to Apache 2.0</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-
-<H1 ALIGN="CENTER">From Apache 1.3 to Apache 2.0<br>Modules</H1>
-
-<p>
-This is a first attempt at writing the lessons I learned when trying to convert the mod_mmap_static module to Apache 2.0. It's by no means definitive and probably won't even be correct in some ways, but it's a start.
-</p>
-<hr>
-<h2>The easier changes...
-</h2>
-
-<h3>Cleanup Routines</h3>
-<p>
-These now need to be of type ap_status_t and return a value of that type. Normally the return value will be APR_SUCCESS unless there is some need to signal an error in the cleanup. Be aware that even though you signal an error not all code yet checks and acts upon the error.
-</p>
-
-<h3>Initialisation Routines</h3>
-
-<p>
-These should now be renamed to better signify where they sit in the overall process. So the name gets a small change from mmap_init to mmap_post_config. The arguments passed have undergone a radical change and now look like
-</p>
-<ul style="list-style:none">
-<li>ap_context_t *p,</li>
-<li>ap_context_t *plog,</li>
-<li>ap_context_t *ptemp,</li>
-<li>server_rec *s</li>
-</ul>
-<p>
-Throughout Apache the old pools have been replced by the ap_context_t, though their use remains remarkably similar.
-</p>
-
-<h3>Data Types</h3>
-<p>
-A lot of the data types have been moved into the APR. This means that some have had a name change, such as the one shown above. The following is a brief list of some of the changes that you are likely to have to make.
-<ul style="list-style:none">
-<li>pool becomes ap_context_t</li>
-<li>table becomes ap_table_t</li>
-</ul>
-<hr>
-
-<h2>
-The <em>messier</em> changes...
-</h2>
-<h3>Register Hooks</h3>
-<p>
-The new architecture uses a series of hooks to provide for calling your functions. These you'll need to add to your module by way of a new function, static void register_hooks(void). The function is really reasonably straightforward once you understand what needs to be done. Each function that needs calling at some stage in the processing of a request needs to be registered, handlers do not. There are a number of phases where functions can be added, and for each you can specify with a high degree of control the relative order that the function will be called in.
-</p>
-<p>
-This is the code that was added to mod_mmap_static
-</p>
-<pre>
-static void register_hooks(void)
-{
- static const char * const aszPre[]={ "http_core.c",NULL };
- ap_hook_post_config(mmap_post_config,NULL,NULL,HOOK_MIDDLE);
- ap_hook_translate_name(mmap_static_xlat,aszPre,NULL,HOOK_LAST);
-};
-</pre>
-<p>
-This registers 2 functions that need to be called, one in the post_config stage (virtually every module will need this one) and one for the translate_name phase. note that while there are different function names the format of each is identical. So what is the format?
-</p>
-<p><strong>
-ap_hook_[phase_name](function_name, predecessors, successors, position);
-</strong></p>
-<p>
-There are 3 hook positions defined...
-</p>
-<ul style="list-style:none">
-<li>HOOK_FIRST</li>
-<li>HOOK_MIDDLE</li>
-<li>HOOK_LAST</li>
-</ul>
-<p>
-To define the position you use the position and then modify it with the predecessors and successors. each of the modifiers can be a list of functions that should be called, either before the function is run (predecessors) or after the function has run (successors).
-</p>
-<p>
-In the mod_mmap_static case I didn't care about the post_config stage, but the mmap_static_xlat MUST be called after the core module had done it's name translation, hence the use of the aszPre to define a modifier to the position HOOK_LAST.
-</p>
-<h3>Module Definition</h3>
-
-<p>
-There are now a lot fewer stages to worry about when creating your module definition. The old defintion looked like
-</p>
-<pre>
-module MODULE_VAR_EXPORT [module_name]_module =
-{
- STANDARD_MODULE_STUFF,
- /* initializer */
- /* dir config creater */
- /* dir merger --- default is to override */
- /* server config */
- /* merge server config */
- /* command handlers */
- /* handlers */
- /* filename translation */
- /* check_user_id */
- /* check auth */
- /* check access */
- /* type_checker */
- /* fixups */
- /* logger */
- /* header parser */
- /* child_init */
- /* child_exit */
- /* post read-request */
-};
-</pre>
-<p>
-The new structure is a great deal simpler...
-</p>
-<pre>
-module MODULE_VAR_EXPORT [module_name]_module =
-{
- STANDARD20_MODULE_STUFF,
- /* create per-directory config structures */
- /* merge per-directory config structures */
- /* create per-server config structures */
- /* merge per-server config structures */
- /* command handlers */
- /* handlers */
- /* register hooks */
- };
-</pre>
-<p>
-Some of these read directly across, some don't. I'll try to summarise what should be done below.
-</p>
-<p>
-The stages that read directly across :
-</p>
-<ul style="list-style:none">
-<li>
-/* dir config creater */ ==> /* create per-directory config structures */
-</li>
-<li>
-/* server config */ ==> /* create per-server config structures */
-</li>
-<li>
-/* dir merger */ ==> /* merge per-directory config structures */
-</li>
-<li>
-/* merge server config */ ==> /* merge per-server config structures */
-</li>
-<li>
-/* command table */ ==> /* command ap_table_t */
-</li>
-<li>
-/* handlers */ ==> /* handlers */
-</li>
-</ul>
-<P>
-The remainder of the old functions should be registered as hooks. There are the following hook stages defined so far...
-</P>
-
-<ul style="list-style:none">
-<li>
-ap_hook_post_config <em>(this is where the old _init routines get registered)</em>
-</li>
-<li>
-ap_hook_http_method
-</li>
-<li>
-ap_hook_open_logs
-</li>
-<li>
-ap_hook_auth_checker
-</li>
-<li>
-ap_hook_default_port
-</li>
-<li>
-ap_hook_access_checker
-</li>
-<li>
-ap_hook_process_connection
-</li>
-<li>
-ap_hook_child_init_hook
-</li>
-
-
-</body>
-</html>
-
-
-
-
-
diff --git a/docs/manual/developer/modules.html.en b/docs/manual/developer/modules.html.en
deleted file mode 100644
index b066223466..0000000000
--- a/docs/manual/developer/modules.html.en
+++ /dev/null
@@ -1,200 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Converting Modules from Apache 1.3 to Apache 2.0</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-
-<H1 ALIGN="CENTER">From Apache 1.3 to Apache 2.0<br>Modules</H1>
-
-<p>
-This is a first attempt at writing the lessons I learned when trying to convert the mod_mmap_static module to Apache 2.0. It's by no means definitive and probably won't even be correct in some ways, but it's a start.
-</p>
-<hr>
-<h2>The easier changes...
-</h2>
-
-<h3>Cleanup Routines</h3>
-<p>
-These now need to be of type ap_status_t and return a value of that type. Normally the return value will be APR_SUCCESS unless there is some need to signal an error in the cleanup. Be aware that even though you signal an error not all code yet checks and acts upon the error.
-</p>
-
-<h3>Initialisation Routines</h3>
-
-<p>
-These should now be renamed to better signify where they sit in the overall process. So the name gets a small change from mmap_init to mmap_post_config. The arguments passed have undergone a radical change and now look like
-</p>
-<ul style="list-style:none">
-<li>ap_context_t *p,</li>
-<li>ap_context_t *plog,</li>
-<li>ap_context_t *ptemp,</li>
-<li>server_rec *s</li>
-</ul>
-<p>
-Throughout Apache the old pools have been replced by the ap_context_t, though their use remains remarkably similar.
-</p>
-
-<h3>Data Types</h3>
-<p>
-A lot of the data types have been moved into the APR. This means that some have had a name change, such as the one shown above. The following is a brief list of some of the changes that you are likely to have to make.
-<ul style="list-style:none">
-<li>pool becomes ap_context_t</li>
-<li>table becomes ap_table_t</li>
-</ul>
-<hr>
-
-<h2>
-The <em>messier</em> changes...
-</h2>
-<h3>Register Hooks</h3>
-<p>
-The new architecture uses a series of hooks to provide for calling your functions. These you'll need to add to your module by way of a new function, static void register_hooks(void). The function is really reasonably straightforward once you understand what needs to be done. Each function that needs calling at some stage in the processing of a request needs to be registered, handlers do not. There are a number of phases where functions can be added, and for each you can specify with a high degree of control the relative order that the function will be called in.
-</p>
-<p>
-This is the code that was added to mod_mmap_static
-</p>
-<pre>
-static void register_hooks(void)
-{
- static const char * const aszPre[]={ "http_core.c",NULL };
- ap_hook_post_config(mmap_post_config,NULL,NULL,HOOK_MIDDLE);
- ap_hook_translate_name(mmap_static_xlat,aszPre,NULL,HOOK_LAST);
-};
-</pre>
-<p>
-This registers 2 functions that need to be called, one in the post_config stage (virtually every module will need this one) and one for the translate_name phase. note that while there are different function names the format of each is identical. So what is the format?
-</p>
-<p><strong>
-ap_hook_[phase_name](function_name, predecessors, successors, position);
-</strong></p>
-<p>
-There are 3 hook positions defined...
-</p>
-<ul style="list-style:none">
-<li>HOOK_FIRST</li>
-<li>HOOK_MIDDLE</li>
-<li>HOOK_LAST</li>
-</ul>
-<p>
-To define the position you use the position and then modify it with the predecessors and successors. each of the modifiers can be a list of functions that should be called, either before the function is run (predecessors) or after the function has run (successors).
-</p>
-<p>
-In the mod_mmap_static case I didn't care about the post_config stage, but the mmap_static_xlat MUST be called after the core module had done it's name translation, hence the use of the aszPre to define a modifier to the position HOOK_LAST.
-</p>
-<h3>Module Definition</h3>
-
-<p>
-There are now a lot fewer stages to worry about when creating your module definition. The old defintion looked like
-</p>
-<pre>
-module MODULE_VAR_EXPORT [module_name]_module =
-{
- STANDARD_MODULE_STUFF,
- /* initializer */
- /* dir config creater */
- /* dir merger --- default is to override */
- /* server config */
- /* merge server config */
- /* command handlers */
- /* handlers */
- /* filename translation */
- /* check_user_id */
- /* check auth */
- /* check access */
- /* type_checker */
- /* fixups */
- /* logger */
- /* header parser */
- /* child_init */
- /* child_exit */
- /* post read-request */
-};
-</pre>
-<p>
-The new structure is a great deal simpler...
-</p>
-<pre>
-module MODULE_VAR_EXPORT [module_name]_module =
-{
- STANDARD20_MODULE_STUFF,
- /* create per-directory config structures */
- /* merge per-directory config structures */
- /* create per-server config structures */
- /* merge per-server config structures */
- /* command handlers */
- /* handlers */
- /* register hooks */
- };
-</pre>
-<p>
-Some of these read directly across, some don't. I'll try to summarise what should be done below.
-</p>
-<p>
-The stages that read directly across :
-</p>
-<ul style="list-style:none">
-<li>
-/* dir config creater */ ==> /* create per-directory config structures */
-</li>
-<li>
-/* server config */ ==> /* create per-server config structures */
-</li>
-<li>
-/* dir merger */ ==> /* merge per-directory config structures */
-</li>
-<li>
-/* merge server config */ ==> /* merge per-server config structures */
-</li>
-<li>
-/* command table */ ==> /* command ap_table_t */
-</li>
-<li>
-/* handlers */ ==> /* handlers */
-</li>
-</ul>
-<P>
-The remainder of the old functions should be registered as hooks. There are the following hook stages defined so far...
-</P>
-
-<ul style="list-style:none">
-<li>
-ap_hook_post_config <em>(this is where the old _init routines get registered)</em>
-</li>
-<li>
-ap_hook_http_method
-</li>
-<li>
-ap_hook_open_logs
-</li>
-<li>
-ap_hook_auth_checker
-</li>
-<li>
-ap_hook_default_port
-</li>
-<li>
-ap_hook_access_checker
-</li>
-<li>
-ap_hook_process_connection
-</li>
-<li>
-ap_hook_child_init_hook
-</li>
-
-
-</body>
-</html>
-
-
-
-
-
diff --git a/docs/manual/dso.html.en b/docs/manual/dso.html.en
deleted file mode 100644
index 66e6fc9841..0000000000
--- a/docs/manual/dso.html.en
+++ /dev/null
@@ -1,393 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML><HEAD>
-<TITLE>Apache 1.3 Dynamic Shared Object (DSO) support</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<BLOCKQUOTE>
-<!--#include virtual="header.html" -->
-
-<DIV ALIGN=CENTER>
-
-<H1>
-Apache 1.3<BR>
-Dynamic Shared Object (DSO)<BR>
-Support
-</H1>
-
-<ADDRESS>Originally written by<BR>
-Ralf S. Engelschall &lt;rse@apache.org&gt, April 1998</ADDRESS>
-
-</DIV>
-
-<H3>Background</H3>
-
-<P>On modern Unix derivatives there exists a nifty mechanism usually called
-dynamic linking/loading of <EM>Dynamic Shared Objects</EM> (DSO) which
-provides a way to build a piece of program code in a special format for
-loading it at run-time into the address space of an executable program.
-
-<P>This loading can usually be done in two ways: Automatically by a system
-program called <CODE>ld.so</CODE> when an executable program is started or
-manually from within the executing program via a programmatic system interface
-to the Unix loader through the system calls <CODE>dlopen()/dlsym()</CODE>.
-
-<P>In the first way the DSO's are usually called <EM>shared libraries</EM> or
-<EM>DSO libraries</EM> and named <CODE>libfoo.so</CODE> or
-<CODE>libfoo.so.1.2</CODE>. They reside in a system directory (usually
-<CODE>/usr/lib</CODE>) and the link to the executable program is established
-at build-time by specifying <CODE>-lfoo</CODE> to the linker command. This
-hard-codes library references into the executable program file so that at
-start-time the Unix loader is able to locate <CODE>libfoo.so</CODE> in
-<CODE>/usr/lib</CODE>, in paths hard-coded via linker-options like
-<CODE>-R</CODE> or in paths configured via the environment variable
-<CODE>LD_LIBRARY_PATH</CODE>. It then resolves any (yet unresolved) symbols in
-the executable program which are available in the DSO.
-
-<P>Symbols in the executable program are usually not referenced by the DSO
-(because it's a reusable library of general code) and hence no further
-resolving has to be done. The executable program has no need to do anything on
-its own to use the symbols from the DSO because the complete resolving is done
-by the Unix loader. (In fact, the code to invoke <CODE>ld.so</CODE> is part of
-the run-time startup code which is linked into every executable program which
-has been bound non-static). The advantage of dynamic loading of common library
-code is obvious: the library code needs to be stored only once, in a system
-library like <CODE>libc.so</CODE>, saving disk space for every program.
-
-<P>In the second way the DSO's are usually called <EM>shared objects</EM> or
-<EM>DSO files</EM> and can be named with an arbitrary extension (although the
-canonical name is <CODE>foo.so</CODE>). These files usually stay inside a
-program-specific directory and there is no automatically established link to
-the executable program where they are used. Instead the executable program
-manually loads the DSO at run-time into its address space via
-<CODE>dlopen()</CODE>. At this time no resolving of symbols from the DSO for
-the executable program is done. But instead the Unix loader automatically
-resolves any (yet unresolved) symbols in the DSO from the set of symbols
-exported by the executable program and its already loaded DSO libraries
-(especially all symbols from the ubiquitous <CODE>libc.so</CODE>). This way
-the DSO gets knowledge of the executable program's symbol set as if it had
-been statically linked with it in the first place.
-
-<P>Finally, to take advantage of the DSO's API the executable program has to
-resolve particular symbols from the DSO via <CODE>dlsym()</CODE> for later use
-inside dispatch tables <EM>etc.</EM> In other words: The executable program has to
-manually resolve every symbol it needs to be able to use it. The advantage of
-such a mechanism is that optional program parts need not be loaded (and thus
-do not spend memory) until they are needed by the program in question. When
-required, these program parts can be loaded dynamically to extend the base
-program's functionality.
-
-<P>Although this DSO mechanism sounds straightforward there is at least one
-difficult step here: The resolving of symbols from the executable program for
-the DSO when using a DSO to extend a program (the second way). Why? Because
-"reverse resolving" DSO symbols from the executable program's symbol set is
-against the library design (where the library has no knowledge about the
-programs it is used by) and is neither available under all platforms nor
-standardized. In practice the executable program's global symbols are often
-not re-exported and thus not available for use in a DSO. Finding a way to
-force the linker to export all global symbols is the main problem one has to
-solve when using DSO for extending a program at run-time.
-
-<H3>Practical Usage</H3>
-
-<P>The shared library approach is the typical one, because it is what the DSO
-mechanism was designed for, hence it is used for nearly all types of libraries
-the operating system provides. On the other hand using shared objects for
-extending a program is not used by a lot of programs.
-
-<P>As of 1998 there are only a few software packages available which use the
-DSO mechanism to actually extend their functionality at run-time: Perl 5 (via
-its XS mechanism and the DynaLoader module), Netscape Server, <EM>etc.</EM> Starting
-with version 1.3, Apache joined the crew, because Apache already uses a module
-concept to extend its functionality and internally uses a dispatch-list-based
-approach to link external modules into the Apache core functionality. So,
-Apache is really predestined for using DSO to load its modules at run-time.
-
-<P>As of Apache 1.3, the configuration system supports two optional features
-for taking advantage of the modular DSO approach: compilation of the Apache
-core program into a DSO library for shared usage and compilation of the
-Apache modules into DSO files for explicit loading at run-time.
-
-<H3>Implementation</H3>
-
-<P>The DSO support for loading individual Apache modules is based on a module
-named <A HREF="mod/mod_so.html"><CODE>mod_so.c</CODE></A> which has to be
-statically compiled into the Apache core. It is the only module besides
-<CODE>http_core.c</CODE> which cannot be put into a DSO itself
-(bootstrapping!). Practically all other distributed Apache modules then can
-then be placed into a DSO by individually enabling the DSO build for them via
-<CODE>configure</CODE>'s <CODE>--enable-shared</CODE> option (see top-level
-<CODE>INSTALL</CODE> file) or by changing the <CODE>AddModule</CODE> command
-in your <CODE>src/Configuration</CODE> into a <CODE>SharedModule</CODE>
-command (see <CODE>src/INSTALL</CODE> file). After a module is compiled into
-a DSO named <CODE>mod_foo.so</CODE> you can use <A
-HREF="mod/mod_so.html"><CODE>mod_so</CODE></A>'s <A
-HREF="mod/mod_so.html#loadmodule"><CODE>LoadModule</CODE></A> command in your
-<CODE>httpd.conf</CODE> file to load this module at server startup or restart.
-
-<P>To simplify this creation of DSO files for Apache modules (especially for
-third-party modules) a new support program named <CODE>apxs</CODE> (<EM>APache
-eXtenSion</EM>) is available. It can be used to build DSO based modules
-<EM>outside of</EM> the Apache source tree. The idea is simple: When
-installing Apache the <CODE>configure</CODE>'s <CODE>make install</CODE>
-procedure installs the Apache C header files and puts the platform-dependent
-compiler and linker flags for building DSO files into the <CODE>apxs</CODE>
-program. This way the user can use <CODE>apxs</CODE> to compile his Apache
-module sources without the Apache distribution source tree and without having
-to fiddle with the platform-dependent compiler and linker flags for DSO
-support.
-
-<P>To place the complete Apache core program into a DSO library (only required
-on some of the supported platforms to force the linker to export the apache
-core symbols -- a prerequisite for the DSO modularization) the rule
-<CODE>SHARED_CORE</CODE> has to be enabled via <CODE>configure</CODE>'s
-<CODE>--enable-rule=SHARED_CORE</CODE> option (see top-level
-<CODE>INSTALL</CODE> file) or by changing the <CODE>Rule</CODE> command in
-your <CODE>Configuration</CODE> file to <CODE>Rule SHARED_CORE=yes</CODE> (see
-<CODE>src/INSTALL</CODE> file). The Apache core code is then placed into a DSO
-library named <CODE>libhttpd.so</CODE>. Because one cannot link a DSO against
-static libraries on all platforms, an additional executable program named
-<CODE>libhttpd.ep</CODE> is created which both binds this static code and
-provides a stub for the <CODE>main()</CODE> function. Finally the
-<CODE>httpd</CODE> executable program itself is replaced by a bootstrapping
-code which automatically makes sure the Unix loader is able to load and start
-<CODE>libhttpd.ep</CODE> by providing the <CODE>LD_LIBRARY_PATH</CODE> to
-<CODE>libhttpd.so</CODE>.
-
-<H3>Supported Platforms</H3>
-
-<P>Apache's <CODE>src/Configure</CODE> script currently has only limited but
-adequate built-in knowledge on how to compile DSO files, because as already
-mentioned this is heavily platform-dependent. Nevertheless all major Unix
-platforms are supported. The definitive current state (May 1999) is this:
-
-<P>
-<UL>
-<LI>Out-of-the-box supported platforms:<BR>
-(actually tested versions in parenthesis)
-
-<PRE>
-o FreeBSD (2.1.5, 2.2.x, 3.x, 4.x)
-o OpenBSD (2.x)
-o NetBSD (1.3.1)
-o BSDI (3.x, 4.x)
-o Linux (Debian/1.3.1, RedHat/4.2)
-o Solaris (2.4, 2.5, 2.6, 2.7)
-o SunOS (4.1.3)
-o Digital UNIX (4.0)
-o IRIX (5.3, 6.2)
-o HP/UX (10.20)
-o UnixWare (2.01, 2.1.2)
-o SCO (5.0.4)
-o AIX (3.2, 4.1.5, 4.2, 4.3)
-o ReliantUNIX/SINIX (5.43)
-o SVR4 (-)
-o Mac OS X Server (1.0)
-o Mac OS (10.0 preview 1)
-o OpenStep/Mach (4.2)
-o DGUX (??)
-o NetWare (5.1)
-</PRE>
-
-<P>
-<LI> Explicitly unsupported platforms:
-
-<PRE>
-o Ultrix (no dlopen-style interface under this platform)
-</PRE>
-
-</UL>
-
-<H3>Usage Summary</H3>
-
-<P>To give you an overview of the DSO features of Apache 1.3, here is a short
-and concise summary:
-
-<OL>
-
-<LI>Placing the Apache core code (all the stuff which usually forms the
-<CODE>httpd</CODE> binary) into a DSO <CODE>libhttpd.so</CODE>, an executable
-program <CODE>libhttpd.ep</CODE> and a bootstrapping executable program
-<CODE>httpd</CODE> (Notice: this is only required on some of the supported
-platforms to force the linker to export the Apache core symbols, which in turn
-is a prerequisite for the DSO modularization):
-
-<P>
-<UL>
-<LI>Build and install via <CODE>configure</CODE> (preferred):
-<TABLE BGCOLOR="#f0f0f0" CELLPADDING=10><TR><TD>
-<PRE>
-$ ./configure --prefix=/path/to/install
- --enable-rule=SHARED_CORE ...
-$ make install
-</PRE>
-</TD></TR></TABLE>
-
-<LI>Build and install manually:
-<TABLE BGCOLOR="#f0f0f0" CELLPADDING=10><TR><TD>
-<PRE>
-- Edit src/Configuration:
- &lt;&lt; Rule SHARED_CORE=default
- &gt;&gt; Rule SHARED_CORE=yes
- &lt;&lt; EXTRA_CFLAGS=
- &gt;&gt; EXTRA_CFLAGS= -DSHARED_CORE_DIR=\"/path/to/install/libexec\"
-$ make
-$ cp src/libhttpd.so* /path/to/install/libexec/
-$ cp src/libhttpd.ep /path/to/install/libexec/
-$ cp src/httpd /path/to/install/bin/
-</PRE>
-</TD></TR></TABLE>
-</UL>
-
-<LI>Build and install a <EM>distributed</EM> Apache module, say
-<CODE>mod_foo.c</CODE>, into its own DSO <CODE>mod_foo.so</CODE>:
-
-<P>
-<UL>
-<LI>Build and install via <CODE>configure</CODE> (preferred):
-<TABLE BGCOLOR="#f0f0f0" CELLPADDING=10><TR><TD>
-<PRE>
-$ ./configure --prefix=/path/to/install
- --enable-shared=foo
-$ make install
-</PRE>
-</TD></TR></TABLE>
-
-<LI>Build and install manually:
-<TABLE BGCOLOR="#f0f0f0" CELLPADDING=10><TR><TD>
-<PRE>
-- Edit src/Configuration:
- &lt;&lt; AddModule modules/xxxx/mod_foo.o
- &gt;&gt; SharedModule modules/xxxx/mod_foo.so
-$ make
-$ cp src/xxxx/mod_foo.so /path/to/install/libexec
-- Edit /path/to/install/etc/httpd.conf
- &gt;&gt; LoadModule foo_module /path/to/install/libexec/mod_foo.so
-</PRE>
-</TD></TR></TABLE>
-</UL>
-
-<LI>Build and install a <EM>third-party</EM> Apache module, say
-<CODE>mod_foo.c</CODE>, into its own DSO <CODE>mod_foo.so</CODE>
-
-<P>
-<UL>
-<LI>Build and install via <CODE>configure</CODE> (preferred):
-<TABLE BGCOLOR="#f0f0f0" CELLPADDING=10><TR><TD>
-<PRE>
-$ ./configure --add-module=/path/to/3rdparty/mod_foo.c
- --enable-shared=foo
-$ make install
-</PRE>
-</TD></TR></TABLE>
-
-<LI>Build and install manually:
-<TABLE BGCOLOR="#f0f0f0" CELLPADDING=10><TR><TD>
-<PRE>
-$ cp /path/to/3rdparty/mod_foo.c /path/to/apache-1.3/src/modules/extra/
-- Edit src/Configuration:
- &gt;&gt; SharedModule modules/extra/mod_foo.so
-$ make
-$ cp src/xxxx/mod_foo.so /path/to/install/libexec
-- Edit /path/to/install/etc/httpd.conf
- &gt;&gt; LoadModule foo_module /path/to/install/libexec/mod_foo.so
-</PRE>
-</TD></TR></TABLE>
-</UL>
-
-<P>
-<LI>Build and install a <EM>third-party</EM> Apache module, say
-<CODE>mod_foo.c</CODE>, into its own DSO <CODE>mod_foo.so</CODE> <EM>outside
-of</EM> the Apache source tree:
-
-<P>
-<UL>
-<LI>Build and install via <CODE>apxs</CODE>:
-<TABLE BGCOLOR="#f0f0f0" CELLPADDING=10><TR><TD>
-<PRE>
-$ cd /path/to/3rdparty
-$ apxs -c mod_foo.c
-$ apxs -i -a -n foo mod_foo.so
-</PRE>
-</TD></TR></TABLE>
-</UL>
-
-</OL>
-
-<H3>Advantages & Disadvantages</H3>
-
-<P>The above DSO based features of Apache 1.3 have the following advantages:
-
-<UL>
-<LI> The server package is more flexible at run-time because the actual server
- process can be assembled at run-time via <A
- HREF="mod/mod_so.html#loadmodule"><CODE>LoadModule</CODE></A>
- <CODE>httpd.conf</CODE> configuration commands instead of
- <CODE>Configuration</CODE> <CODE>AddModule</CODE> commands at build-time.
- For instance this way one is able to run different server instances
- (standard &amp; SSL version, minimalistic &amp; powered up version
- [mod_perl, PHP3], <EM>etc.</EM>) with only one Apache installation.
-<P>
-<LI> The server package can be easily extended with third-party modules even
- after installation. This is at least a great benefit for vendor package
- maintainers who can create a Apache core package and additional packages
- containing extensions like PHP3, mod_perl, mod_fastcgi, <EM>etc.</EM>
-<P>
-<LI> Easier Apache module prototyping because with the DSO/<CODE>apxs</CODE>
- pair you can both work outside the Apache source tree and only need an
- <CODE>apxs -i</CODE> command followed by an <CODE>apachectl
- restart</CODE> to bring a new version of your currently developed module
- into the running Apache server.
-</UL>
-
-<P>DSO has the following disadvantages:
-
-<UL>
-<LI> The DSO mechanism cannot be used on every platform because not all
- operating systems support dynamic loading of code into the address space
- of a program.
-<P>
-<LI> The server is approximately 20% slower at startup time because of the
- symbol resolving overhead the Unix loader now has to do.
-<P>
-<LI> The server is approximately 5% slower at execution time under some
- platforms because position independent code (PIC) sometimes needs
- complicated assembler tricks for relative addressing which are not
- necessarily as fast as absolute addressing.
-<P>
-<LI> Because DSO modules cannot be linked against other DSO-based libraries
- (<CODE>ld -lfoo</CODE>) on all platforms (for instance a.out-based
- platforms usually don't provide this functionality while ELF-based
- platforms do) you cannot use the DSO mechanism for all types of modules.
- Or in other words, modules compiled as DSO files are restricted to only
- use symbols from the Apache core, from the C library (<CODE>libc</CODE>)
- and all other dynamic or static libraries used by the Apache core, or
- from static library archives (<CODE>libfoo.a</CODE>) containing position
- independent code. The only chances to use other code is to either make
- sure the Apache core itself already contains a reference to it, loading
- the code yourself via <CODE>dlopen()</CODE> or enabling the
- <CODE>SHARED_CHAIN</CODE> rule while building Apache when your platform
- supports linking DSO files against DSO libraries.
-<P>
-<LI> Under some platforms (many SVR4 systems) there is no way to force the
- linker to export all global symbols for use in DSO's when linking the
- Apache httpd executable program. But without the visibility of the Apache
- core symbols no standard Apache module could be used as a DSO. The only
- chance here is to use the <CODE>SHARED_CORE</CODE> feature because this
- way the global symbols are forced to be exported. As a consequence the
- Apache <CODE>src/Configure</CODE> script automatically enforces
- <CODE>SHARED_CORE</CODE> on these platforms when DSO features are used in
- the <CODE>Configuration</CODE> file or on the configure command line.
-</UL>
-
-<!--#include virtual="footer.html" -->
-</BLOCKQUOTE>
-</BODY>
-</HTML>
diff --git a/docs/manual/handler.html.en b/docs/manual/handler.html.en
deleted file mode 100644
index 72f16fd170..0000000000
--- a/docs/manual/handler.html.en
+++ /dev/null
@@ -1,195 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Apache's Handler Use</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Apache's Handler Use</H1>
-
-<H2>What is a Handler</H2>
-
-<P>A "handler" is an internal Apache representation of the action to be
-performed when a file is called. Generally, files have implicit
-handlers, based on the file type. Normally, all files are simply
-served by the server, but certain file typed are "handled"
-separately. For example, you may use a type of
-"application/x-httpd-cgi" to invoke CGI scripts.</P>
-
-<P>Apache 1.1 adds the additional ability to use handlers
-explicitly. Either based on filename extensions or on location, these
-handlers are unrelated to file type. This is advantageous both because
-it is a more elegant solution, but it also allows for both a type
-<STRONG>and</STRONG> a handler to be associated with a file (See also
-<A HREF="mod/mod_mime.html#multipleext">Files with Multiple Extensions</A>)
-
-</P>
-
-<P>Handlers can either be built into the server or to a module, or
-they can be added with the <A
-HREF="mod/mod_actions.html#action">Action</A> directive. The built-in
-handlers in the standard distribution are as follows:</P>
-
-<UL>
-<LI><STRONG>default-handler</STRONG>:
- Send the file using the <CODE>default_handler()</CODE>, which is the
- handler used by default to handle static content.
- (core)
-<LI><STRONG>send-as-is</STRONG>:
- Send file with HTTP headers as is.
- (<A HREF="mod/mod_asis.html">mod_asis</A>)
-<LI><STRONG>cgi-script</STRONG>:
- Treat the file as a CGI script.
- (<A HREF="mod/mod_cgi.html">mod_cgi</A>)
-<LI><STRONG>imap-file</STRONG>:
- Imagemap rule file.
- (<A HREF="mod/mod_imap.html">mod_imap</A>)
-<LI><STRONG>server-info</STRONG>:
- Get the server's configuration information
- (<A HREF="mod/mod_info.html">mod_info</A>)
-<LI><STRONG>server-parsed</STRONG>:
- Parse for server-side includes
- (<A HREF="mod/mod_include.html">mod_include</A>)
-<LI><STRONG>server-status</STRONG>:
- Get the server's status report
- (<A HREF="mod/mod_status.html">mod_status</A>)
-<LI><STRONG>type-map</STRONG>:
- Parse as a type map file for content negotiation
- (<A HREF="mod/mod_negotiation.html">mod_negotiation</A>)
-</UL>
-
-<P>
-
-<H2>Directives</H2>
-<UL>
-<LI><A HREF="#addhandler">AddHandler</A>
-<LI><A HREF="#sethandler">SetHandler</A>
-</UL>
-
-<HR>
-
-<H2><A NAME="addhandler">AddHandler</A></H2>
-
-<A
- HREF="mod/directive-dict.html#Syntax"
- REL="Help"
-><STRONG>Syntax:</STRONG></A> AddHandler <EM>handler-name extension extension...</EM><BR>
-<A
- HREF="mod/directive-dict.html#Context"
- REL="Help"
-><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
-<A
- HREF="mod/directive-dict.html#Override"
- REL="Help"
-><STRONG>Override:</STRONG></A> FileInfo<BR>
-<A
- HREF="mod/directive-dict.html#Status"
- REL="Help"
-><STRONG>Status:</STRONG></A> Base<BR>
-<A
- HREF="mod/directive-dict.html#Module"
- REL="Help"
-><STRONG>Module:</STRONG></A> mod_mime<BR>
-<A
- HREF="mod/directive-dict.html#Compatibility"
- REL="Help"
-><STRONG>Compatibility:</STRONG></A> AddHandler is only available in Apache
-1.1 and later<P>
-
-<P>AddHandler maps the filename extensions <EM>extension</EM> to the
-handler <EM>handler-name</EM>. This mapping is added to any already
-in force, overriding any mappings that already exist for the same
-<EM>extension</EM>.
-
-For example, to activate CGI scripts
-with the file extension "<CODE>.cgi</CODE>", you might use:
-<PRE>
- AddHandler cgi-script cgi
-</PRE>
-
-<P>Once that has been put into your srm.conf or httpd.conf file, any
-file containing the "<CODE>.cgi</CODE>" extension will be treated as a
-CGI program.</P>
-
-<P>
-
-<STRONG>See also</STRONG>: <A HREF="mod/mod_mime.html#multipleext">Files with
-multiple extensions</A>
-
-<HR>
-
-<H2><A NAME="sethandler">SetHandler</A></H2>
-
-<A
- HREF="mod/directive-dict.html#Syntax"
- REL="Help"
-><STRONG>Syntax:</STRONG></A> SetHandler <EM>handler-name</EM><BR>
-<A
- HREF="mod/directive-dict.html#Context"
- REL="Help"
-><STRONG>Context:</STRONG></A> directory, .htaccess<BR>
-<A
- HREF="mod/directive-dict.html#Status"
- REL="Help"
-><STRONG>Status:</STRONG></A> Base<BR>
-<A
- HREF="mod/directive-dict.html#Module"
- REL="Help"
-><STRONG>Module:</STRONG></A> mod_mime<BR>
-<A
- HREF="mod/directive-dict.html#Compatibility"
- REL="Help"
-><STRONG>Compatibility:</STRONG></A> SetHandler is only available in Apache
-1.1 and later.<P>
-
-<P>When placed into an <CODE>.htaccess</CODE> file or a
-<CODE>&lt;Directory&gt;</CODE> or <CODE>&lt;Location&gt;</CODE>
-section, this directive forces all matching files to be parsed through
-the handler given by <EM>handler-name</EM>. For example, if you had a
-directory you wanted to be parsed entirely as imagemap rule files,
-regardless of extension, you might put the following into an
-<CODE>.htaccess</CODE> file in that directory:
-<PRE>
- SetHandler imap-file
-</PRE>
-
-<P>Another example: if you wanted to have the server display a status
-report whenever a URL of <CODE>http://servername/status</CODE> was
-called, you might put the following into access.conf:
-<PRE>
- &lt;Location /status&gt;
- SetHandler server-status
- &lt;/Location&gt;
-</PRE>
-<HR>
-
-<H2>Programmer's Note</H2>
-
-<P>In order to implement the handler features, an addition has been
-made to the <A HREF="misc/API.html">Apache API</A> that you may wish to
-make use of. Specifically, a new record has been added to the
-<CODE>request_rec</CODE> structure:</P>
-<PRE>
- char *handler
-</PRE>
-<P>If you wish to have your module engage a handler, you need only to
-set <CODE>r-&gt;handler</CODE> to the name of the handler at any time
-prior to the <CODE>invoke_handler</CODE> stage of the
-request. Handlers are implemented as they were before, albeit using
-the handler name instead of a content type. While it is not
-necessary, the naming convention for handlers is to use a
-dash-separated word, with no slashes, so as to not invade the media
-type name-space.</P>
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
-
diff --git a/docs/manual/index.html b/docs/manual/index.html
deleted file mode 100644
index 5bfef758c0..0000000000
--- a/docs/manual/index.html
+++ /dev/null
@@ -1,31 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<title>Apache-2.0 Documentation</title>
-</head>
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<h2>Manual Index for Apache-2.0</h2>
-<p>The documentation has been split into 2 sections. One is for people installing and configuring an Apache server, the other is for those who are developing the server.</p>
-<h3 align="center">Where do you want to go today?</h3>
-<table width="100%">
-<tr>
-<td width="50%" align="center">
-<a href="user/index.html">I'm configuring/installing a server</a>
-</td>
-<td width="50%" align="center">
-<a href="developer/index.html">I'm a developer</a>
-</td>
-</tr>
-</table>
-<hr>
-<i>David Reid, 15<sup>th</sup> January 2000</i>
-</body>
-</html>
-
diff --git a/docs/manual/index.html.en b/docs/manual/index.html.en
deleted file mode 100644
index 5bfef758c0..0000000000
--- a/docs/manual/index.html.en
+++ /dev/null
@@ -1,31 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
-<head>
-<title>Apache-2.0 Documentation</title>
-</head>
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<h2>Manual Index for Apache-2.0</h2>
-<p>The documentation has been split into 2 sections. One is for people installing and configuring an Apache server, the other is for those who are developing the server.</p>
-<h3 align="center">Where do you want to go today?</h3>
-<table width="100%">
-<tr>
-<td width="50%" align="center">
-<a href="user/index.html">I'm configuring/installing a server</a>
-</td>
-<td width="50%" align="center">
-<a href="developer/index.html">I'm a developer</a>
-</td>
-</tr>
-</table>
-<hr>
-<i>David Reid, 15<sup>th</sup> January 2000</i>
-</body>
-</html>
-
diff --git a/docs/manual/install.html.en b/docs/manual/install.html.en
deleted file mode 100644
index b8f5047e00..0000000000
--- a/docs/manual/install.html.en
+++ /dev/null
@@ -1,270 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Compiling and Installing Apache</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-
-<H1 ALIGN="CENTER">Compiling and Installing Apache 1.3</H1>
-
-This document covers compilation and installation of Apache on Unix
-systems only. For compiling and installation on Windows, see <A
-HREF="windows.html">Using Apache with Microsoft Windows</A> and for
-TPF see <A HREF="install-tpf.html">Installing the Apache 1.3 HTTP
-Server on TPF</A>.
-
-<P>
-
-UnixWare users will want to consult <A HREF="unixware.html">build notes</A>
-for various UnixWare versions before compiling.
-
-<H2>Downloading Apache</H2>
-
-Information on the latest version of Apache can be found on the Apache
-web server at <A
-HREF="http://www.apache.org/">http://www.apache.org/</A>. This will
-list the current release, any more recent beta-test release, together
-with details of mirror web and anonymous ftp sites.
-
-<P>
-
-If you downloaded a binary distribution, skip to <A
-HREF="#install">Installing Apache</A>. Otherwise read the next section
-for how to compile the server.
-
-<H2>Compiling Apache</H2>
-
-Compiling Apache consists of three steps: Firstly select which Apache
-<STRONG>modules</STRONG> you want to include into the server. Secondly create a
-configuration for your operating system. Thirdly compile the
-executable.
-<P>
-
-All configuration of Apache is performed in the <CODE>src</CODE>
-directory of the Apache distribution. Change into this directory.
-
-<OL>
- <LI>
- Select modules to compile into Apache in the
- <CODE>Configuration</CODE> file. Uncomment lines corresponding to
- those optional modules you wish to include (among the AddModule lines
- at the bottom of the file), or add new lines corresponding to
- additional modules you have downloaded or written. (See <A
- HREF="misc/API.html">API.html</A> for preliminary docs on how to
- write Apache modules). Advanced users can comment out some of the
- default modules if they are sure they will not need them (be careful
- though, since many of the default modules are vital for the correct
- operation and security of the server).
- <P>
-
- You should also read the instructions in the <CODE>Configuration</CODE>
- file to see if you need to set any of the <CODE>Rule</CODE> lines.
-
-
- <LI>
- Configure Apache for your operating system. Normally you can just
- type run the <CODE>Configure</CODE> script as given below. However
- if this fails or you have any special requirements (<EM>e.g.</EM>, to include
- an additional library required by an optional module) you might need
- to edit one or more of the following options in the
- <CODE>Configuration</CODE> file:
- <CODE>EXTRA_CFLAGS, LIBS, LDFLAGS, INCLUDES</CODE>.
- <P>
-
- Run the <CODE>Configure</CODE> script:
- <BLOCKQUOTE>
- <PRE>
- % Configure
- Using 'Configuration' as config file
- + configured for &lt;whatever&gt; platform
- + setting C compiler to &lt;whatever&gt; *
- + setting C compiler optimization-level to &lt;whatever&gt; *
- + Adding selected modules
- + doing sanity check on compiler and options
- Creating Makefile in support
- Creating Makefile in main
- Creating Makefile in os/unix
- Creating Makefile in modules/standard
- </PRE>
- </BLOCKQUOTE>
-
- (*: Depending on Configuration and your system, Configure
- might not print these lines. That's OK).<P>
-
- This generates a Makefile for use in stage 3. It also creates a
- Makefile in the support directory, for compilation of the optional
- support programs.
- <P>
-
- (If you want to maintain multiple configurations, you can give a
- option to <CODE>Configure</CODE> to tell it to read an alternative
- Configuration file, such as <CODE>Configure -file
- Configuration.ai</CODE>).
- <P>
-
- <LI>
- Type <CODE>make</CODE>.
-</OL>
-
-The modules we place in the Apache distribution are the ones we have
-tested and are used regularly by various members of the Apache
-development group. Additional modules contributed by members or third
-parties with specific needs or functions are available at
-&lt;<A HREF="http://www.apache.org/dist/contrib/modules/"
- >http://www.apache.org/dist/contrib/modules/</A>&gt;.
-There are instructions on that page for linking these modules into the
-core Apache code.
-
-<H2><A NAME="install">Installing Apache</A></H2>
-
-You will have a binary file called <CODE>httpd</CODE> in the
-<CODE>src</CODE> directory. A binary distribution of Apache will
-supply this file. <P>
-
-The next step is to install the program and configure it. Apache is
-designed to be configured and run from the same set of directories
-where it is compiled. If you want to run it from somewhere else, make
-a directory and copy the <CODE>conf</CODE>, <CODE>logs</CODE> and
-<CODE>icons</CODE> directories into it. In either case you should
-read the <A HREF="misc/security_tips.html#serverroot">security tips</A>
-describing how to set the permissions on the server root directory.<P>
-
-The next step is to edit the configuration files for the server. This
-consists of setting up various <STRONG>directives</STRONG> in up to three
-central configuration files. By default, these files are located in
-the <CODE>conf</CODE> directory and are called <CODE>srm.conf</CODE>,
-<CODE>access.conf</CODE> and <CODE>httpd.conf</CODE>. To help you get
-started there are same files in the <CODE>conf</CODE> directory of the
-distribution, called <CODE>srm.conf-dist</CODE>,
-<CODE>access.conf-dist</CODE> and <CODE>httpd.conf-dist</CODE>. Copy
-or rename these files to the names without the <CODE>-dist</CODE>.
-Then edit each of the files. Read the comments in each file carefully.
-Failure to setup these files correctly could lead to your server not
-working or being insecure. You should also have an additional file in
-the <CODE>conf</CODE> directory called <CODE>mime.types</CODE>. This
-file usually does not need editing.
-
-<P>
-
-First edit <CODE>httpd.conf</CODE>. This sets up general attributes
-about the server: the port number, the user it runs as, <EM>etc.</EM> Next
-edit the <CODE>srm.conf</CODE> file; this sets up the root of the
-document tree, special functions like server-parsed HTML or internal
-imagemap parsing, <EM>etc.</EM> Finally, edit the <CODE>access.conf</CODE>
-file to at least set the base cases of access.
-
-<P>
-
-In addition to these three files, the server behavior can be configured
-on a directory-by-directory basis by using <CODE>.htaccess</CODE>
-files in directories accessed by the server.
-
-<H3>Set your system time properly!</H3>
-
-Proper operation of a public web server requires accurate time
-keeping, since elements of the HTTP protocol are expressed as the time
-of day. So, it's time to investigate setting up NTP or some other
-time synchronization system on your Unix box, or whatever the
-equivalent on NT would be.
-
-<H3>Starting and Stopping the Server</H3>
-
-To start the server, simply run <CODE>httpd</CODE>. This will look for
-<CODE>httpd.conf</CODE> in the location compiled into the code (by
-default <CODE>/usr/local/apache/conf/httpd.conf</CODE>). If
-this file is somewhere else, you can give the real
-location with the -f argument. For example:
-
-<PRE>
- /usr/local/apache/httpd -f /usr/local/apache/conf/httpd.conf
-</PRE>
-
-If all goes well this will return to the command prompt almost
-immediately. This indicates that the server is now up and running. If
-anything goes wrong during the initialization of the server you will
-see an error message on the screen.
-
-If the server started ok, you can now use your browser to
-connect to the server and read the documentation. If you are running
-the browser on the same machine as the server and using the default
-port of 80, a suitable URL to enter into your browser is
-
-<PRE>
- http://localhost/
-</PRE>
-
-<P>
-
-Note that when the server starts it will create a number of
-<EM>child</EM> processes to handle the requests. If you started Apache
-as the root user, the parent process will continue to run as root
-while the children will change to the user as given in the httpd.conf
-file.
-
-<P>
-
-If when you run <CODE>httpd</CODE> it complained about being unable to
-"bind" to an address, then either some other process is already using
-the port you have configured Apache to use, or you are running httpd
-as a normal user but trying to use a port below 1024 (such as the
-default port 80).
-
-<P>
-
-If the server is not running, read the error message displayed
-when you run httpd. You should also check the server
-error_log for additional information (with the default configuration,
-this will be located in the file <CODE>error_log</CODE> in the
-<CODE>logs</CODE> directory).
-
-<P>
-
-If you want your server to continue running after a system reboot, you
-should add a call to <CODE>httpd</CODE> to your system startup files
-(typically <CODE>rc.local</CODE> or a file in an
-<CODE>rc.<EM>N</EM></CODE> directory). This will start Apache as root.
-Before doing this ensure that your server is properly configured
-for security and access restrictions.
-
-<P>
-
-To stop Apache send the parent process a TERM signal. The PID of this
-process is written to the file <CODE>httpd.pid</CODE> in the
-<CODE>logs</CODE> directory (unless configured otherwise). Do not
-attempt to kill the child processes because they will be renewed by
-the parent. A typical command to stop the server is:
-
-<PRE>
- kill -TERM `cat /usr/local/apache/logs/httpd.pid`
-</PRE>
-
-<P>
-
-For more information about Apache command line options, configuration
-and log files, see <A HREF="invoking.html">Starting Apache</A>. For a
-reference guide to all Apache directives supported by the distributed
-modules, see the <A HREF="mod/directives.html">Apache directives</A>.
-
-<H2>Compiling Support Programs</H2>
-
-In addition to the main <CODE>httpd</CODE> server which is compiled
-and configured as above, Apache includes a number of support programs.
-These are not compiled by default. The support programs are in the
-<CODE>support</CODE> directory of the distribution. To compile
-the support programs, change into this directory and type
-<PRE>
- make
-</PRE>
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
diff --git a/docs/manual/invoking.html.en b/docs/manual/invoking.html.en
deleted file mode 100644
index 02ee07659f..0000000000
--- a/docs/manual/invoking.html.en
+++ /dev/null
@@ -1,220 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Starting Apache</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Starting Apache</H1>
-
-<H2>Invoking Apache</H2>
-
-On Unix, the <CODE>httpd</CODE> program is usually run as a daemon
-which executes continuously, handling requests. It is possible to
-invoke Apache by the Internet daemon <CODE>inetd</CODE> each time a
-connection to the HTTP service is made (use the <A
-HREF="mod/core.html#servertype">ServerType</A> directive) but this is
-not recommended.
-
-<P>
-
-On Windows, Apache is normally run as a service on Windows NT, or as a
-console application on Windows 95. See also <A
-HREF="windows.html#run">running Apache for Windows</A>.
-
-<H2>Command line options</H2>
-The following options are recognized on the httpd command line:
-<DL>
-<DT><CODE>-d</CODE> <EM>serverroot</EM>
-<DD>Set the initial value for the
-<A HREF="mod/core.html#serverroot">ServerRoot</A> variable to
-<EM>serverroot</EM>. This can be overridden by the ServerRoot command
-in the configuration file. The default is
-<CODE>/usr/local/apache</CODE> on Unix, <CODE>/apache</CODE> on
-Windows and <CODE>/os2httpd</CODE> on OS/2.
-
-<DT><CODE>-D</CODE> <EM>name</EM>
-<DD>Define a name for use in in
-<A HREF="mod/core.html#ifdefine">IfDefine</A> directives.
-This option can be used to optionally enable certain functionality in the
-configuration file, or to use a common configuration for
-several independent hosts, where host specific information is enclosed in
-&lt;IfDefine&gt; sections.
-
-<DT><CODE>-f</CODE> <EM>config</EM>
-<DD>Execute the commands in the file <EM>config</EM> on startup. If
-<EM>config</EM> does not begin with a <CODE>/</CODE>, then it is taken to be a
-path relative to the <A HREF="mod/core.html#serverroot">ServerRoot</A>. The
-default is <CODE>conf/httpd.conf</CODE>.
-
-<DT><CODE>-C</CODE> <EM>"directive"</EM>
-<DD>Process the given apache "directive" (just as if it had been part of a
-configuration file) <STRONG>before</STRONG> actually reading the regular configuration files.
-
-<DT><CODE>-c</CODE> <EM>"directive"</EM>
-<DD>Process the given apache "directive" <STRONG>after</STRONG> reading
-all the regular configuration files.
-
-<DT><CODE>-X</CODE>
-<DD>Run in single-process mode, for internal debugging purposes only; the
-daemon does not detach from the terminal or fork any children. Do <EM>NOT</EM>
-use this mode to provide ordinary web service.
-
-<DT><CODE>-v</CODE>
-<DD>Print the version of httpd and its build date, and then exit.
-
-<DT><A NAME="version"><CODE>-V</CODE></A>
-<DD>Print the base version of httpd, its
-build date, and a list of compile time settings which influence the
-behavior and performance of the apache server (<EM>e.g.</EM>,
-<SAMP>-DUSE_MMAP_FILES</SAMP>),
-then exit.
-
-<DT><A NAME="help"><CODE>-L</CODE></A>
-<DD>
-
-Give a list of directives together with expected arguments and places
-where the directive is valid, then exit. (Apache 1.3.4 and
-later. Earlier versions used -l instead).
-
-
-<DT><CODE>-l</CODE></A>
-<DD>
-
-Give a list of all modules compiled into the server, then exit.
-(Apache 1.3.4 and later. Earlier versions used -h instead).<br>
-
-Give a list of directives together with expected arguments and places
-where the directive is valid, then exit. (Apache 1.2 to 1.3.3. Later
-versions use -L instead).
-
-
-
-<DT><CODE>-h</CODE>
-<DD>
-
-Print a list of the httpd options, then exit. (Apache 1.3.4 and
-later. Earlier versions used -? instead).<br>
-
-Give a list of all modules compiled into the server, then exit. (Up to
-Apache 1.3.3. Later versions use -l instead).<br>
-
-
-<DT><CODE>-S</CODE>
-<DD>Show the settings as parsed from the config file (currently only
-shows a breakdown of the vhost settings) but do not start the
-server. (Up to Apache 1.3.3, this option also started the server).
-
-<DT><CODE>-t</CODE>
-<DD>Test the configuration file syntax (<EM>i.e.</EM>, read all configuration files
-and interpret them) but do not start the server. If the configuration contains
-errors, display an error message and exit with a non-zero exit status,
-otherwise display "Syntax OK" and terminate with a zero exit status. This
-command checks to see if all DocumentRoot entries exist and are directories.
-For sites with many vhosts, this is expensive; consider the <CODE>-T</CODE>
-command instead.
-
-<DT><CODE>-T</CODE>
-<DD>Test the configuration file syntax (<EM>i.e.</EM>, read all configuration files
-and interpret them) but do not start the server. If the configuration contains
-errors, display an error message and exit with a non-zero exit status,
-otherwise display "Syntax OK" and terminate with a zero exit status. This
-command does not perform any checking of the DocumentRoot entries.
-
-<DT><CODE>-k</CODE> <EM>option</EM>
-<DD>Windows only: signal Apache to restart or shutdown. <EM>option</EM>
-is one of "shutdown" or "restart". (Apache 1.3.3 and later).
-
-<DT><CODE>-?</CODE>
-<DD>Print a list of the httpd options, and then exit (up to Apache
-1.3.3. Later version use -h instead).
-
-</DL>
-
-<H2>Configuration files</H2>
-The server will read three files for configuration directives. Any
-directive may appear in any of these files. The the names of these
-files are taken to be relative to the server root; this is set by the
-<A HREF="mod/core.html#serverroot">ServerRoot</A> directive, the
-<CODE>-d</CODE> command line flag, or (on Windows only) the registry
-(see <A HREF="windows.html#run">Running Apache for Windows</A>).
-
-Conventionally, the files are:
-<DL>
-<DT><CODE>conf/httpd.conf</CODE>
-<DD>Contains directives that control the operation of the server daemon.
-The filename may be overridden with the <CODE>-f</CODE> command line flag.
-
-<DT><CODE>conf/srm.conf</CODE>
-<DD>Contains directives that control the specification of documents that
-the server can provide to clients. The filename may be overridden with
-the <A HREF="mod/core.html#resourceconfig">ResourceConfig</A> directive.
-
-<DT><CODE>conf/access.conf</CODE>
-<DD>Contains directives that control access to documents.
-The filename may be overridden with the
-<A HREF="mod/core.html#accessconfig">AccessConfig</A> directive.
-</DL>
-However, these conventions need not be adhered to.
-<P>
-The server also reads a file containing mime document types; the filename
-is set by the <A HREF="mod/mod_mime.html#typesconfig">TypesConfig</A>
-directive,
-and is <CODE>conf/mime.types</CODE> by default.
-
-<H2>Log files</H2>
-<H3>security warning</H3>
-Anyone who can write to the directory where Apache is writing a
-log file can almost certainly gain access to the uid that the server is
-started as, which is normally root. Do <EM>NOT</EM> give people write
-access to the directory the logs are stored in without being aware of
-the consequences; see the <A HREF="misc/security_tips.html">security tips</A>
-document for details.
-<H3>pid file</H3>
-
-On startup, Apache saves the process id of the parent httpd process to
-the file <CODE>logs/httpd.pid</CODE>. This filename can be changed
-with the <A HREF="mod/core.html#pidfile">PidFile</A> directive. The
-process-id is for use by the administrator in restarting and
-terminating the daemon: on Unix, a HUP or USR1 signal causes the
-daemon to re-read its configuration files and a TERM signal causes it
-to die gracefully; on Windows, use the -k command line option instead.
-For more information see the <A HREF="stopping.html">Stopping and
-Restarting</A> page.
-
-<P>
-If the process dies (or is killed) abnormally, then it will be necessary to
-kill the children httpd processes.
-
-<H3>Error log</H3>
-
-The server will log error messages to a log file, by default
-<CODE>logs/error_log</CODE> on Unix or <CODE>logs/error.log</CODE> on
-Windows and OS/2. The filename can be set using the <A
-HREF="mod/core.html#errorlog">ErrorLog</A> directive; different error
-logs can be set for different <A
-HREF="mod/core.html#virtualhost">virtual hosts</A>.
-
-<H3>Transfer log</H3>
-
-The server will typically log each request to a transfer file, by
-default <CODE>logs/access_log</CODE> on Unix or
-<CODE>logs/access.log</CODE> on Windows and OS/2. The filename can be
-set using a <A
-HREF="mod/mod_log_config.html#transferlog">TransferLog</A> directive
-or additional log files created with the <A
-HREF="mod/mod_log_config.html#customlog">CustomLog</A> directive;
-different transfer logs can be set for different <A
-HREF="mod/core.html#virtualhost">virtual hosts</A>.
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
diff --git a/docs/manual/mod/directive-dict.html.en b/docs/manual/mod/directive-dict.html.en
deleted file mode 100644
index 03a9c3f67e..0000000000
--- a/docs/manual/mod/directive-dict.html.en
+++ /dev/null
@@ -1,265 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
- <HEAD>
- <TITLE>Definitions of terms used to describe Apache directives
- </TITLE>
- </HEAD>
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
- <BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
- >
-<!--#include virtual="header.html" -->
- <H1 ALIGN="CENTER">Terms Used to Describe Apache Directives</H1>
-
- <P>
- Each Apache configuration directive is described using a common format
- that looks like this:
- </P>
- <DL>
- <DD><A
- HREF="#Syntax"
- REL="Help"
- ><STRONG>Syntax:</STRONG></A> <EM>directive-name</EM> <EM>some args</EM>
- <BR>
- <A
- HREF="#Default"
- REL="Help"
- ><STRONG>Default:</STRONG></A>
- <SAMP><EM>directive-name default-value</EM></SAMP>
- <BR>
- <A
- HREF="#Context"
- REL="Help"
- ><STRONG>Context:</STRONG></A> <EM>context-list</EM>
- <BR>
- <A
- HREF="#Override"
- REL="Help"
- ><STRONG>Override:</STRONG></A> <EM>override</EM>
- <BR>
- <A
- HREF="#Status"
- REL="Help"
- ><STRONG>Status:</STRONG></A> <EM>status</EM>
- <BR>
- <A
- HREF="#Module"
- REL="Help"
- ><STRONG>Module:</STRONG></A> <EM>module-name</EM>
- <BR>
- <A
- HREF="#Compatibility"
- REL="Help"
- ><STRONG>Compatibility:</STRONG></A> <EM>compatibility notes</EM>
- </DD>
- </DL>
- <P>
- Each of the directive's attributes, complete with possible values
- where possible, are described in this document.
- </P>
-
- <H2>Directive Terms</H2>
- <UL>
- <LI><A HREF="#Syntax">Syntax</A>
- </LI>
- <LI><A HREF="#Default">Default</A>
- </LI>
- <LI><A HREF="#Context">Context</A>
- </LI>
- <LI><A HREF="#Override">Override</A>
- </LI>
- <LI><A HREF="#Status">Status</A>
- </LI>
- <LI><A HREF="#Module">Module</A>
- </LI>
- <LI><A HREF="#Compatibility">Compatibility</A>
- </LI>
- </UL>
-
- <HR>
- <H2><A NAME="Syntax">Syntax</A></H2>
- <P>
- This indicates the format of the directive as it would appear in a
- configuration file. This syntax is extremely directive-specific, so
- refer to the text of the directive's description for details.
- </P>
-
- <HR>
- <H2><A NAME="Default">Default</A></H2>
- <P>
- If the directive has a default value (<EM>i.e.</EM>, if you omit it
- from your configuration entirely, the Apache Web server will behave as
- though you set it to a particular value), it is described here. If
- there is no default value, this section should say
- &quot;<EM>None</EM>&quot;.
- </P>
-
- <HR>
- <H2><A NAME="Context">Context</A></H2>
- <P>
- This indicates where in the server's configuration files the directive
- is legal. It's a comma-separated list of one or more of the following
- values:
- </P>
- <DL>
- <DT><STRONG>server config</STRONG>
- </DT>
- <DD>This means that the directive may be used in the server
- configuration files (<EM>e.g.</EM>, <SAMP>httpd.conf</SAMP>,
- <SAMP>srm.conf</SAMP>, and <SAMP>access.conf</SAMP>), but
- <STRONG>not</STRONG> within any <SAMP>&lt;VirtualHost&gt;</SAMP> or
- &lt;Directory&gt; containers. It is not allowed in
- <SAMP>.htaccess</SAMP> files at all.
- <P>
- </P>
- </DD>
- <DT><STRONG>virtual host</STRONG>
- </DT>
- <DD>This context means that the directive may appear inside
- <SAMP>&lt;VirtualHost&gt;</SAMP> containers in the server
- configuration files.
- <P>
- </P>
- </DD>
- <DT><STRONG>directory</STRONG>
- </DT>
- <DD>A directive marked as being valid in this context may be used
- inside <SAMP>&lt;Directory&gt;</SAMP>,
- <SAMP>&lt;Location&gt;</SAMP>, and <SAMP>&lt;Files&gt;</SAMP>
- containers in the server configuration files, subject to the
- restrictions outlined in <A HREF="../sections.html">How Directory,
- Location and Files sections work</A>.
- <P>
- </P>
- </DD>
- <DT><STRONG>.htaccess</STRONG>
- </DT>
- <DD>If a directive is valid in this context, it means that it can
- appear inside <EM>per</EM>-directory <SAMP>.htaccess</SAMP> files.
- It may not be processed, though depending upon the
- <A
- HREF="#Override"
- REL="Help"
- >overrides</A>
- currently active.
- <P>
- </P>
- </DD>
- </DL>
- <P>
- The directive is <EM>only</EM> allowed within the designated context;
- if you try to use it elsewhere, you'll get a configuration error that
- will either prevent the server from handling requests in that context
- correctly, or will keep the server from operating at all --
- <EM>i.e.</EM>, the server won't even start.
- </P>
- <P>
- The valid locations for the directive are actually the result of a
- Boolean OR of all of the listed contexts. In other words, a directive
- that is marked as being valid in &quot;<SAMP>server config,
- .htaccess</SAMP>&quot; can be used in the <SAMP>httpd.conf</SAMP> file
- and in <SAMP>.htaccess</SAMP> files, but not within any
- &lt;Directory&gt; or &lt;VirtualHost&gt; containers.
- </P>
-
- <HR>
- <H2><A NAME="Override">Override</A></H2>
- <P>
- This directive attribute indicates which configuration override must
- be active in order for the directive to be processed when it appears
- in a <SAMP>.htaccess</SAMP> file. If the directive's
- <A
- HREF="#Context"
- REL="Help"
- >context</A>
- doesn't permit it to appear in <SAMP>.htaccess</SAMP> files, this
- attribute should say &quot;<EM>Not applicable</EM>&quot;.
- </P>
- <P>
- Overrides are activated by the
- <A
- HREF="core.html#allowoverride"
- REL="Help"
- ><SAMP>AllowOverride</SAMP></A>
- directive, and apply to a particular scope (such as a directory) and
- all descendants, unless further modified by other
- <SAMP>AllowOverride</SAMP> directives at lower levels. The
- documentation for that directive also lists the possible override
- names available.
- </P>
-
- <HR>
- <H2><A NAME="Status">Status</A></H2>
- <P>
- This indicates how tightly bound into the Apache Web server the
- directive is; in other words, you may need to recompile the server
- with an enhanced set of modules in order to gain access to the
- directive and its functionality. Possible values for this attribute
- are:
- </P>
- <DL>
- <DT><STRONG>Core</STRONG>
- </DT>
- <DD>If a directive is listed as having &quot;Core&quot; status, that
- means it is part of the innermost portions of the Apache Web server,
- and is always available.
- <P>
- </P>
- </DD>
- <DT><STRONG>Base</STRONG>
- </DT>
- <DD>A directive labeled as having &quot;Base&quot; status is
- supported by one of the standard Apache modules which is compiled
- into the server by default, and is therefore normally available
- unless you've taken steps to remove the module from your configuration.
- <P>
- </P>
- </DD>
- <DT><STRONG>Extension</STRONG>
- </DT>
- <DD>A directive with &quot;Extension&quot; status is provided by one
- of the modules included with the Apache server kit, but the module
- isn't normally compiled into the server. To enable the directive
- and its functionality, you will need to change the server build
- configuration files and re-compile Apache.
- <P>
- </P>
- </DD>
- <DT><STRONG>Experimental</STRONG>
- </DT>
- <DD>&quot;Experimental&quot; status indicates that the directive is
- available as part of the Apache kit, but you're on your own if you
- try to use it. The directive is being documented for completeness,
- and is not necessarily supported. The module which provides the
- directive may or may not be compiled in by default; check the top of
- the page which describes the directive and its module to see if it
- remarks on the availability.
- <P>
- </P>
- </DD>
- </DL>
-
- <HR>
- <H2><A NAME="Module">Module</A></H2>
- <P>
- This quite simply lists the name of the source module which defines
- the directive.
- </P>
-
- <HR>
- <H2><A NAME="Compatibility">Compatibility</A></H2>
- <P>
- If the directive wasn't part of the original Apache version 1
- distribution, the version in which it was introduced should be listed
- here. If the directive has the same name as one from the NCSA HTTPd
- server, any inconsistencies in behaviour between the two should also
- be mentioned. Otherwise, this attribute should say &quot;<EM>No
- compatibility issues.</EM>&quot;
- </P>
-<!--#include virtual="footer.html" -->
- </BODY>
-</HTML>
diff --git a/docs/manual/mpm.html b/docs/manual/mpm.html
deleted file mode 100644
index 7521751bfe..0000000000
--- a/docs/manual/mpm.html
+++ /dev/null
@@ -1,96 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Available MPM's for Apache 2.0</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<h1 align="center">Apache 2.0 - Available MPM's</h1>
-<p align="center"><em>Dated 15<sup>th</sup> January 2000</em></p>
-<p>Apache 2.0 has a new architecture that moves the processing of requests from the code server into a MultiProcessing Module (MPM). By selecting the MPM to use you can alter the way the server behaves. Additionally the introduction of the MPM's has led to platforms developing their own optimised modules. On some platforms there is no choice, whilst on others there are different options, each with differing processing models. This list aims to help you select a suitable MPM for your system.</p>
-<hr>
-<h3>Platforms</h3>
-<ul>
-<li><A href="#unix">Unix</a></li>
-<li><a href="#windows">Windows</a></li>
-<li><a href="#os2">OS/2</a></li>
-<li><a href="#beos">BeOS</a></li>
-</ul>
-<a name="unix"><h3>Unix</h3>
-<table width="100%" border="1">
-<tr>
-<th width="20%">MPM</th>
-<th width="60%">Description</th>
-<th width="20%">Maintainer</th>
-</tr>
-<tr>
-<td>prefork</td>
-<td>The prefork MPM reproduces the behaviour of Apache 1.3.</td>
-<td>??</td>
-</tr>
-<tr>
-<td>mpmt_pthread</td>
-<td>This MPM uses a multi-process, multi-threaded model to provide good scability and stability.</td>
-<td>Manoj?</td>
-</tr>
-<tr>
-<td>dexter</td>
-<td>This is Manoj's plaything. It has a number of hybrid features that Manoj has been looking at to improve performance.</td>
-<td><a href="mailto:manojk@io.com">Manoj</a></td>
-</tr>
-</table>
-
-<a name="windows"><h3>Windows</h3>
-<table width="100%" border="1">
-<tr>
-<th width="20%">MPM</th>
-<th width="60%">Description</th>
-<th width="20%">Maintainer</th>
-</tr>
-<tr>
-<td>winnt</td>
-<td>The Windows MPM. This is mainly aimed at Windows NT.</td>
-<td><a href="mailto:stoddard@raleigh.ibm.com">Bill Stoddard</a></td>
-</tr>
-</table>
-
-<a name="os2"><h3>OS/2</h3>
-<table width="100%" border="1">
-<tr>
-<th width="20%">MPM</th>
-<th width="60%">Description</th>
-<th width="20%">Maintainer</th>
-</tr>
-<tr>
-<td>spmt_os2</td>
-<td>Single process, multiple thread MPM for OS2.</td>
-<td><a href="mailto:brianh@kheldar.apana.org.au">Brian Havard</a></td>
-</tr>
-</table>
-
-<a name="beos"><h3>BeOS</h3>
-<table width="100%" border="1">
-<tr>
-<th width="20%">MPM</th>
-<th width="60%">Description</th>
-<th width="20%">Maintainer</th>
-</tr>
-<tr>
-<td>mpmt_beos</td>
-<td>Multi-threaded MPM for BeOS. This follows the mpmt_pthread model.</td>
-<td><a href="mailto:dreid@jetnet.co.uk">David Reid</a></td>
-</tr>
-</table>
-
-<hr>
-<I>David Reid, 15<sup>th</sup> January 2000</I>
-</body>
-</html>
-
diff --git a/docs/manual/mpm.html.en b/docs/manual/mpm.html.en
deleted file mode 100644
index 7521751bfe..0000000000
--- a/docs/manual/mpm.html.en
+++ /dev/null
@@ -1,96 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Available MPM's for Apache 2.0</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<h1 align="center">Apache 2.0 - Available MPM's</h1>
-<p align="center"><em>Dated 15<sup>th</sup> January 2000</em></p>
-<p>Apache 2.0 has a new architecture that moves the processing of requests from the code server into a MultiProcessing Module (MPM). By selecting the MPM to use you can alter the way the server behaves. Additionally the introduction of the MPM's has led to platforms developing their own optimised modules. On some platforms there is no choice, whilst on others there are different options, each with differing processing models. This list aims to help you select a suitable MPM for your system.</p>
-<hr>
-<h3>Platforms</h3>
-<ul>
-<li><A href="#unix">Unix</a></li>
-<li><a href="#windows">Windows</a></li>
-<li><a href="#os2">OS/2</a></li>
-<li><a href="#beos">BeOS</a></li>
-</ul>
-<a name="unix"><h3>Unix</h3>
-<table width="100%" border="1">
-<tr>
-<th width="20%">MPM</th>
-<th width="60%">Description</th>
-<th width="20%">Maintainer</th>
-</tr>
-<tr>
-<td>prefork</td>
-<td>The prefork MPM reproduces the behaviour of Apache 1.3.</td>
-<td>??</td>
-</tr>
-<tr>
-<td>mpmt_pthread</td>
-<td>This MPM uses a multi-process, multi-threaded model to provide good scability and stability.</td>
-<td>Manoj?</td>
-</tr>
-<tr>
-<td>dexter</td>
-<td>This is Manoj's plaything. It has a number of hybrid features that Manoj has been looking at to improve performance.</td>
-<td><a href="mailto:manojk@io.com">Manoj</a></td>
-</tr>
-</table>
-
-<a name="windows"><h3>Windows</h3>
-<table width="100%" border="1">
-<tr>
-<th width="20%">MPM</th>
-<th width="60%">Description</th>
-<th width="20%">Maintainer</th>
-</tr>
-<tr>
-<td>winnt</td>
-<td>The Windows MPM. This is mainly aimed at Windows NT.</td>
-<td><a href="mailto:stoddard@raleigh.ibm.com">Bill Stoddard</a></td>
-</tr>
-</table>
-
-<a name="os2"><h3>OS/2</h3>
-<table width="100%" border="1">
-<tr>
-<th width="20%">MPM</th>
-<th width="60%">Description</th>
-<th width="20%">Maintainer</th>
-</tr>
-<tr>
-<td>spmt_os2</td>
-<td>Single process, multiple thread MPM for OS2.</td>
-<td><a href="mailto:brianh@kheldar.apana.org.au">Brian Havard</a></td>
-</tr>
-</table>
-
-<a name="beos"><h3>BeOS</h3>
-<table width="100%" border="1">
-<tr>
-<th width="20%">MPM</th>
-<th width="60%">Description</th>
-<th width="20%">Maintainer</th>
-</tr>
-<tr>
-<td>mpmt_beos</td>
-<td>Multi-threaded MPM for BeOS. This follows the mpmt_pthread model.</td>
-<td><a href="mailto:dreid@jetnet.co.uk">David Reid</a></td>
-</tr>
-</table>
-
-<hr>
-<I>David Reid, 15<sup>th</sup> January 2000</I>
-</body>
-</html>
-
diff --git a/docs/manual/new_features_2_0.html b/docs/manual/new_features_2_0.html
deleted file mode 100644
index af41cc1185..0000000000
--- a/docs/manual/new_features_2_0.html
+++ /dev/null
@@ -1,51 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML><HEAD>
-<TITLE>New features with Apache 2.0</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF"
- VLINK="#000080" ALINK="#FF0000">
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Overview of New Features in Apache 2.0</H1>
-
-<P>Enhancements: <A HREF="#core">Core</A> |
-
-<P><HR>
-
-<H2><A NAME="core">Core Enhancements:</A></H2>
-
-<DL>
-<DT><STRONG>Unix Threading</STRONG>
-<DD>On Unix systems with POSIX threads support, Apache can now run in a
- hybrid multiprocess, multithreaded mode. This should improve
- scalability.
-
-<DT><STRONG>New Build System</STRONG>
-<DD>The build system has been rewritten from scratch to be based on
- autoconf and libtool. This makes Apache's configuration system more
- similar to that of other packages.
-
-<DT><STRONG>Multiprotocol Support</STRONG>
-<DD>Apache now has some of the infrastructure in place to support serving
- multiple protocols. mod_echo has been written as an example.
-
-<DT><STRONG>Better support for non-Unix platforms</STRONG>
-<DD>Apache 2.0 should be faster and more stable on non-Unix platforms such
- as BeOS, OS/2, and Windows. With the introduction of platform-specific
- multiprocessing modules and the Apache Portable Runtime, these
- platforms can now avoid using POSIX-emulation functions that are
- sometimes buggy and always hurt performance.
-
-<DT><STRONG>New API</STRONG>
-<DD>The API for modules has changed significantly for 2.0. Many of the
- module-ordering problems from 1.3 should be gone. 2.0 does much of
- this automatically, and module ordering is now done per-hook to
- allow more flexibility. Also, new calls have been added that should
- allow modules to do more without requiring patching of the core
- Apache server.
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
-
diff --git a/docs/manual/new_features_2_0.html.en b/docs/manual/new_features_2_0.html.en
deleted file mode 100644
index af41cc1185..0000000000
--- a/docs/manual/new_features_2_0.html.en
+++ /dev/null
@@ -1,51 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML><HEAD>
-<TITLE>New features with Apache 2.0</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF"
- VLINK="#000080" ALINK="#FF0000">
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Overview of New Features in Apache 2.0</H1>
-
-<P>Enhancements: <A HREF="#core">Core</A> |
-
-<P><HR>
-
-<H2><A NAME="core">Core Enhancements:</A></H2>
-
-<DL>
-<DT><STRONG>Unix Threading</STRONG>
-<DD>On Unix systems with POSIX threads support, Apache can now run in a
- hybrid multiprocess, multithreaded mode. This should improve
- scalability.
-
-<DT><STRONG>New Build System</STRONG>
-<DD>The build system has been rewritten from scratch to be based on
- autoconf and libtool. This makes Apache's configuration system more
- similar to that of other packages.
-
-<DT><STRONG>Multiprotocol Support</STRONG>
-<DD>Apache now has some of the infrastructure in place to support serving
- multiple protocols. mod_echo has been written as an example.
-
-<DT><STRONG>Better support for non-Unix platforms</STRONG>
-<DD>Apache 2.0 should be faster and more stable on non-Unix platforms such
- as BeOS, OS/2, and Windows. With the introduction of platform-specific
- multiprocessing modules and the Apache Portable Runtime, these
- platforms can now avoid using POSIX-emulation functions that are
- sometimes buggy and always hurt performance.
-
-<DT><STRONG>New API</STRONG>
-<DD>The API for modules has changed significantly for 2.0. Many of the
- module-ordering problems from 1.3 should be gone. 2.0 does much of
- this automatically, and module ordering is now done per-hook to
- allow more flexibility. Also, new calls have been added that should
- allow modules to do more without requiring patching of the core
- Apache server.
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
-
diff --git a/docs/manual/platform/netware.html b/docs/manual/platform/netware.html
deleted file mode 100644
index 8add778b5f..0000000000
--- a/docs/manual/platform/netware.html
+++ /dev/null
@@ -1,278 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Using Apache with Novell NetWare 5</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-
-<H1 ALIGN="CENTER">Using Apache With Novell NetWare 5</H1>
-
-<P>This document explains how to install, configure and run
- Apache 1.3 under Novell NetWare 5. Please note that at
- this time, NetWare support is entirely experimental, and is
- recommended only for experienced users. The Apache Group does not
- guarantee that this software will work as documented, or even at
- all. If you find any bugs, or wish to contribute in other ways, please
- use our <A HREF="http://www.apache.org/bug_report.html">bug reporting
- page.</A></P>
-
-<P><STRONG>Warning: Apache on NetWare has not yet been optimized for performance.
-Apache still performs best, and is most reliable on Unix platforms. Over
-time we will improve NetWare performance. Folks doing comparative reviews
-of webserver performance are asked to compare against Apache
-on a Unix platform such as Solaris, FreeBSD, or Linux.</STRONG></P>
-
-<P>
-
-Most of this document assumes that you are installing Apache from a
-binary distribution. If you want to compile Apache yourself (possibly
-to help with development, or to track down bugs), see the section on
-<A HREF="#comp">Compiling Apache for NetWare</A> below.
-
-<HR>
-
-<UL>
- <LI><A HREF="#req">Requirements</A>
- <LI><A HREF="#down">Downloading Apache for NetWare</A>
- <LI><A HREF="#inst">Installing Apache for NetWare</A>
- <LI><A HREF="#run">Running Apache for NetWare</A>
- <LI><A HREF="#use">Using Apache for NetWare</A>
- <LI><A HREF="#comp">Compiling Apache for NetWare</A>
-</UL>
-
-<HR>
-
-<H2><A NAME="req">Requirements</A></H2>
-
-Apache 1.3 is designed to run on NetWare 5.0 and 5.1.
-<P>
-
-<STRONG>If running on NetWare 5.0 you must install Service Pack 4.</STRONG>
-
-<P>
-<P>
-
-Service pack 4 is available <A HREF="http://support.novell.com/misc/patlst.htm#nw">here.</A>
-
-<H2><A NAME="down">Downloading Apache for NetWare 5</A></H2>
-
-<P>Information on the latest version of Apache can be found on the
-Apache web server at <A
-HREF="http://www.apache.org/">http://www.apache.org/</A>. This will
-list the current release, any more recent alpha or beta-test releases,
-together with details of mirror web and anonymous ftp sites.</P>
-
-<P>
-<H2><A NAME="inst">Installing Apache for NetWare</A></H2>
-
-There is no Apache install program for NetWare currently. You will need
-to compile apache and copy the files over to the server manually. An
-install program will be posted at a later date.
-<P>
-Follow these steps to install Apache on NetWare (assuming you will install to sys:/apache):
-
-<UL>
- <LI>Create a directory called <CODE>Apache</CODE> on a NetWare volume
- <LI>Copy Apache.nlm, Apachec.nlm, htdigest.nlm, and htpasswd.nlm to sys:/apache
- <LI>Create a directory under <CODE>sys:/Apache</CODE> called <CODE>conf</CODE>
- <LI>Copy all the *.conf-dist-nw files to the <CODE>sys:/apache/conf</CODE> directory
- and rename them all as *.conf files
- <LI>Copy the mime.types and magic files to sys:/apache/conf directory
- <LI>Copy all files and subdirectories of \apache-1.3\htdocs to sys:/apache/htdocs and
- rename the proper index file (index.html.en) to index.html
- <LI>Copy all files and subdirectories in \apache-1.3\icons to sys:/apache/icons
- <LI>Create the directory sys:/apache/logs on the server
- <LI>Create the directory sys:/apache/cgi-bin on the server
- <LI>Create the directory sys:/apache/modules and copy all nlm modules built into the
- modules directory
- <LI>Edit the httpd.conf file setting ServerRoot and ServerName to reflect your correct
- server settings
- <LI>Add <CODE>sys:/apache</CODE> to the search path. EXAMPLE: search add sys:\apache
-</UL>
-
-<P>Apache may be installed to other volumes besides the default <CODE>sys</CODE> volume.
-
-<H2><A NAME="run">Running Apache for NetWare</A></H2>
-
-To start Apache just type <STRONG>apache</STRONG> at the console. This
-will load apache in the OS address space. If you prefer to load
-Apache in a protected address space you may specify the address space
-with the load statement as follows:
-<P>
-<PRE>
- load address space = apache apache
-</PRE>
-<P>
-This will load Apache into an address space called apache. Running multiple instances
-of Apache concurrently on NetWare is possible by loading each instance into its own
-protected address space.
-
-<P>
-After starting Apache it will be listening to port 80 (unless you
-changed the <SAMP>Port</SAMP>, <SAMP>Listen</SAMP> or
-<SAMP>BindAddress</SAMP> directives in the configuration files).
-To connect to the server and access the default page, launch a browser
-and enter the server's name or address.
-
-This should respond with a welcome page, and a link to the Apache
-manual. If nothing happens or you get an error, look in the
-<SAMP>error_log</SAMP> file in the <SAMP>logs</SAMP> directory.
-
-<P>
-
-Once your basic installation is working, you should configure it
-properly by editing the files in the <SAMP>conf</SAMP> directory.
-
-<P>
-To unload Apache running in the OS address space just type the
-following at the console:
-<PRE>
- unload apache
-</PRE>
-If apache is running in a protected address space specify the
-address space in the unload statement:
-<PRE>
- unload address space = apache apache
-</PRE>
-
-<P>
-When working with Apache it is important to know how it will find the
-configuration files. You can specify a configuration file on the command line
-in two ways:
-
-<UL>
-<LI>-f specifies a path to a particular configuration file
-</UL>
-<PRE> apache -f "vol:/my server/conf/my.conf"</PRE>
-<PRE> apache -f test/test.conf</PRE>
-
-In these cases, the proper ServerRoot should be set in the configuration file.
-
-<P>
-
-If you don't specify a configuration file name with -f, Apache will
-use the file name compiled into the server, usually "conf/httpd.conf". Invoking
-Apache with the -V switch will display this value labeled as SERVER_CONFIG_FILE.
-Apache will then determine its ServerRoot by trying the following, in this order:
-
-<UL>
-<LI>A ServerRoot directive via a -C switch.
-<LI>The -d switch on the command line.
-<LI>Current working directory
-<LI>The server root compiled into the server.
-</UL>
-
-<P>
-The server root compiled into the server is usually "sys:/apache".
-invoking apache with the -V switch will display this value
-labeled as HTTPD_ROOT.
-
-<H2><A NAME="use">Configuring Apache for NetWare</A></H2>
-
-Apache is configured by files in the <SAMP>conf</SAMP>
-directory. These are the same as files used to configure the Unix
-version, but there are a few different directives for Apache on
-NetWare. See the <A HREF="./">Apache documentation</A> for all the
-available directives.
-
-<P>
-
-The main differences in Apache for NetWare are:
-
-<UL>
- <LI><P>Because Apache for NetWare is multithreaded, it does not use a
- separate process for each request, as Apache does with
- Unix. Instead there are only threads running: a parent thread, and
- a child which handles the requests. Within the child each request is
- handled by a separate thread.
- <P>
-
- So the "process"-management directives are different:
- <P><A
- HREF="mod/core.html#maxrequestsperchild">MaxRequestsPerChild</A>
- - Like the Unix directive, this controls how many requests a
- process will serve before exiting. However, unlike Unix, a
- process serves all the requests at once, not just one, so if
- this is set, it is recommended that a very high number is
- used. The recommended default, <CODE>MaxRequestsPerChild
- 0</CODE>, does not cause the process to ever exit.
- <P><A HREF="mod/core.html#threadsperchild">ThreadsPerChild</A> -
- This directive is new, and tells the server how many threads it
- should use. This is the maximum number of connections the server
- can handle at once; be sure and set this number high enough for
- your site if you get a lot of hits. The recommended default is
- <CODE>ThreadsPerChild 50</CODE>.
- </P><A HREF="mod/core.html#threadstacksize">ThreadStackSize</A> -
- This directive tells the server what size of stack to use for
- the individual threads. The recommended default is
- <CODE>ThreadStackSize 65536</CODE>.
- <P>
- <LI><P>The directives that accept filenames as arguments now must use
- NetWare filenames instead of Unix ones. However, because Apache
- uses Unix-style names internally, you must use forward slashes, not
- backslashes. Volumes can be used; if omitted, the drive with the
- Apache executable will be assumed.</P>
- <LI><P>Apache for NetWare contains the ability to load modules at runtime,
- without recompiling the server. If Apache is compiled normally, it
- will install a number of optional modules in the
- <CODE>\Apache\modules</CODE> directory. To activate these, or other
- modules, the new <A HREF="mod/mod_so.html#loadmodule">LoadModule</A>
- directive must be used. For example, to active the status module,
- use the following (in addition to the status-activating directives
- in <CODE>access.conf</CODE>):</P>
-<PRE>
- LoadModule status_module modules/status
-</PRE>
- <P>Information on <A HREF="mod/mod_so.html#creating">creating loadable
- modules</A> is also available.</P>
-</UL>
-
-<H2><A NAME="comp">Compiling Apache for NetWare</A></H2>
-
-<P>Compiling Apache requires MetroWerks CodeWarrior 5 to be properly
- installed.
-
-<P>First, unpack the Apache distribution into an appropriate
- directory. Then go to the <CODE>src</CODE> subdirectory of the Apache
- distribution and unzip <CODE>ApacheNW.mcp.gz</CODE>. You may use a
- recent version of WinZip to accomplish this or gzip for Windows. The main
- Metrowerks project file for Apache <CODE>(ApacheNW.mcp)</CODE> is now ready
- to use. Just double click on it from within explorer and it should
- automatically launch MetroWerks CodeWarrior.
-</P>
-
-<P>All major pieces of Apache may be built using the ApacheNW.mcp project
- file. This includes modules such as status, info, and proxy. In addition,
- the following project files have been provided as well:
-<PRE>
- /apache-1.3/src/support/htpasswd.mcp.gz
- /apache-1.3/src/support/htdigest.mcp.gz
-</PRE>
-
-</P>
-<CODE>htpasswd.mcp.gz</CODE> and <CODE>htdigest.mcp.gz</CODE> will also need
-to be unzipped before they can be used with MetroWerks CodeWarrior.
-
-<P>Once Apache has been compiled, it needs to be installed in its server
- root directory. The default is the <CODE>sys:/Apache</CODE>
- directory. </P>
-<P>
-Before running the server you must fill out the conf directory.
-Copy the *.conf-dist-nw from the distribution conf directory
-and rename *.conf. Edit the ServerRoot entries to your
-actual server root (for example "sys:/apache"). Copy over
-the conf/magic and conf/mime.types files as well.
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
-
diff --git a/docs/manual/platform/perf-bsd44.html b/docs/manual/platform/perf-bsd44.html
deleted file mode 100644
index c5e978c2b9..0000000000
--- a/docs/manual/platform/perf-bsd44.html
+++ /dev/null
@@ -1,254 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Running a High-Performance Web Server for BSD</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<A NAME="initial">
-<!--#include virtual="header.html" -->
-</A>
-<H1 ALIGN="CENTER">Running a High-Performance Web Server for BSD</H1>
-
-Like other OS's, the listen queue is often the <STRONG>first limit
-hit</STRONG>. The
-following are comments from "Aaron Gifford &lt;agifford@InfoWest.COM&gt;"
-on how to fix this on BSDI 1.x, 2.x, and FreeBSD 2.0 (and earlier):
-
-<P>
-
-Edit the following two files:
-<BLOCKQUOTE><CODE> /usr/include/sys/socket.h <BR>
- /usr/src/sys/sys/socket.h </CODE></BLOCKQUOTE>
-In each file, look for the following:
-<PRE>
- /*
- * Maximum queue length specifiable by listen.
- */
- #define SOMAXCONN 5
-</PRE>
-
-Just change the "5" to whatever appears to work. I bumped the two
-machines I was having problems with up to 32 and haven't noticed the
-problem since.
-
-<P>
-
-After the edit, recompile the kernel and recompile the Apache server
-then reboot.
-
-<P>
-
-FreeBSD 2.1 seems to be perfectly happy, with SOMAXCONN
-set to 32 already.
-
-<P>
-
-<A NAME="detail">
-<STRONG>Addendum for <EM>very</EM> heavily loaded BSD servers</STRONG><BR>
-</A>
-from Chuck Murcko &lt;chuck@telebase.com&gt;
-
-<P>
-
-If you're running a really busy BSD Apache server, the following are useful
-things to do if the system is acting sluggish:<P>
-
-<UL>
-
-<LI> Run vmstat to check memory usage, page/swap rates, <EM>etc.</EM>
-
-<LI> Run netstat -m to check mbuf usage
-
-<LI> Run fstat to check file descriptor usage
-
-</UL>
-
-These utilities give you an idea what you'll need to tune in your kernel,
-and whether it'll help to buy more RAM.
-
-Here are some BSD kernel config parameters (actually BSDI, but pertinent to
-FreeBSD and other 4.4-lite derivatives) from a system getting heavy usage.
-The tools mentioned above were used, and the system memory was increased to
-48 MB before these tuneups. Other system parameters remained unchanged.
-
-<P>
-
-<PRE>
-maxusers 256
-</PRE>
-
-Maxusers drives a <EM>lot</EM> of other kernel parameters:
-
-<UL>
-
-<LI> Maximum # of processes
-
-<LI> Maximum # of processes per user
-
-<LI> System wide open files limit
-
-<LI> Per-process open files limit
-
-<LI> Maximum # of mbuf clusters
-
-<LI> Proc/pgrp hash table size
-
-</UL>
-
-The actual formulae for these derived parameters are in
-<EM>/usr/src/sys/conf/param.c</EM>.
-These calculated parameters can also be overridden (in part) by specifying
-your own values in the kernel configuration file:
-
-<PRE>
-# Network options. NMBCLUSTERS defines the number of mbuf clusters and
-# defaults to 256. This machine is a server that handles lots of traffic,
-# so we crank that value.
-options NMBCLUSTERS=4096 # mbuf clusters at 4096
-
-#
-# Misc. options
-#
-options CHILD_MAX=512 # maximum number of child processes
-options OPEN_MAX=512 # maximum fds (breaks RPC svcs)
-</PRE>
-
-<P>
-
-In many cases, NMBCLUSTERS must be set much larger than would appear
-necessary at first glance. The reason for this is that if the browser
-disconnects in mid-transfer, the socket fd associated with that particular
-connection ends up in the TIME_WAIT state for several minutes, during
-which time its mbufs are not yet freed. Another reason is that, on server
-timeouts, some connections end up in FIN_WAIT_2 state forever, because
-this state doesn't time out on the server, and the browser never sent
-a final FIN. For more details see the
-<A HREF="fin_wait_2.html">FIN_WAIT_2</A> page.
-
-<P>
-
-Some more info on mbuf clusters (from sys/mbuf.h):
-<PRE>
-/*
- * Mbufs are of a single size, MSIZE (machine/machparam.h), which
- * includes overhead. An mbuf may add a single "mbuf cluster" of size
- * MCLBYTES (also in machine/machparam.h), which has no additional overhead
- * and is used instead of the internal data area; this is done when
- * at least MINCLSIZE of data must be stored.
- */
-</PRE>
-
-<P>
-
-CHILD_MAX and OPEN_MAX are set to allow up to 512 child processes (different
-than the maximum value for processes per user ID) and file descriptors.
-These values may change for your particular configuration (a higher OPEN_MAX
-value if you've got modules or CGI scripts opening lots of connections or
-files). If you've got a lot of other activity besides httpd on the same
-machine, you'll have to set NPROC higher still. In this example, the NPROC
-value derived from maxusers proved sufficient for our load.
-
-<P>
-
-To increase the size of the <CODE>listen()</CODE> queue, you need to
-adjust the value of SOMAXCONN. SOMAXCONN is not derived from maxusers,
-so you'll always need to increase that yourself. We use a value guaranteed
-to be larger than Apache's default for the listen() of 128, currently.
-The actual value for SOMAXCONN is set in <CODE>sys/socket.h</CODE>.
-The best way to adjust this parameter is run-time, rather than changing
-it in this header file and thus hardcoding a value in the kernel and
-elsewhere. To do this, edit <CODE>/etc/rc.local</CODE> and add the
-following line:
-<PRE>
- /usr/sbin/sysctl -w kern.somaxconn=256
-</PRE>
-
-<P>
-
-We used <CODE>256</CODE> but you can tune it for your own setup. In
-many cases, however, even the default value of <CODE>128</CODE> (for
-later versions of FreeBSD) is OK.
-
-<P>
-
-<STRONG>Caveats</STRONG>
-
-<P>
-
-Be aware that your system may not boot with a kernel that is configured
-to use more resources than you have available system RAM.
-<STRONG>ALWAYS</STRONG>
-have a known bootable kernel available when tuning your system this way,
-and use the system tools beforehand to learn if you need to buy more
-memory before tuning.
-
-<P>
-
-RPC services will fail when the value of OPEN_MAX is larger than 256.
-This is a function of the original implementations of the RPC library,
-which used a byte value for holding file descriptors. BSDI has partially
-addressed this limit in its 2.1 release, but a real fix may well await
-the redesign of RPC itself.
-
-<P>
-
-Finally, there's the hard limit of child processes configured in Apache.
-
-<P>
-
-For versions of Apache later than 1.0.5 you'll need to change the
-definition for <STRONG>HARD_SERVER_LIMIT</STRONG> in <EM>httpd.h</EM> and
-recompile if you need to run more than the default 150 instances of httpd.
-
-<P>
-
-From conf/httpd.conf-dist:
-
-<PRE>
-# Limit on total number of servers running, <EM>i.e.</EM>, limit on the number
-# of clients who can simultaneously connect --- if this limit is ever
-# reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW.
-# It is intended mainly as a brake to keep a runaway server from taking
-# Unix with it as it spirals down...
-
-MaxClients 150
-</PRE>
-
-Know what you're doing if you bump this value up, and make sure you've
-done your system monitoring, RAM expansion, and kernel tuning beforehand.
-Then you're ready to service some serious hits!
-
-<P>
-
-Thanks to <EM>Tony Sanders</EM> and <EM>Chris Torek</EM> at BSDI for their
-helpful suggestions and information.
-
-<P>
-
-"M. Teterin" &lt;mi@ALDAN.ziplink.net&gt; writes:<P>
-<BLOCKQUOTE>It really does help if your kernel and frequently used utilities
-are fully optimized. Rebuilding the FreeBSD kernel on an AMD-133
-(486-class CPU) web-server with<BR>
-<CODE> -m486 -fexpensive-optimizations -fomit-frame-pointer -O2</CODE><BR>
-helped reduce the number of "unable" errors, because the CPU was
-often maxed out.</BLOCKQUOTE>
-<P>
-
-<HR>
-
-<H3>More welcome!</H3>
-
-If you have tips to contribute, send mail to
-<A HREF="mailto:apache@apache.org">apache@apache.org</A>
-
-<!--#include virtual="footer.html" -->
-</BODY></HTML>
-
diff --git a/docs/manual/platform/perf-dec.html b/docs/manual/platform/perf-dec.html
deleted file mode 100644
index 2b9cc9cc5e..0000000000
--- a/docs/manual/platform/perf-dec.html
+++ /dev/null
@@ -1,285 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Performance Tuning Tips for Digital Unix</TITLE>
-</HEAD>
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Performance Tuning Tips for Digital Unix</H1>
-
-Below is a set of newsgroup posts made by an engineer from DEC in
-response to queries about how to modify DEC's Digital Unix OS for more
-heavily loaded web sites. Copied with permission.
-
-<HR>
-
-<H2>Update</H2>
-From: Jeffrey Mogul &lt;mogul@pa.dec.com&gt;<BR>
-Date: Fri, 28 Jun 96 16:07:56 MDT<BR>
-
-<OL>
-<LI> The advice given in the README file regarding the
- "tcbhashsize" variable is incorrect. The largest value
- this should be set to is 1024. Setting it any higher
- will have the perverse result of disabling the hashing
- mechanism.
-
-<LI>Patch ID OSF350-146 has been superseded by
-<BLOCKQUOTE>
- Patch ID OSF350-195 for V3.2C<BR>
- Patch ID OSF360-350195 for V3.2D
-</BLOCKQUOTE>
- Patch IDs for V3.2E and V3.2F should be available soon.
- There is no known reason why the Patch ID OSF360-350195
- won't work on these releases, but such use is not officially
- supported by Digital. This patch kit will not be needed for
- V3.2G when it is released.
-</OL>
-<HR>
-
-
-<PRE>
-From mogul@pa.dec.com (Jeffrey Mogul)
-Organization DEC Western Research
-Date 30 May 1996 00:50:25 GMT
-Newsgroups <A HREF="news:comp.unix.osf.osf1">comp.unix.osf.osf1</A>
-Message-ID &lt;4oirch$bc8@usenet.pa.dec.com&gt;
-Subject Re: Web Site Performance
-References 1
-
-
-
-In article &lt;skoogDs54BH.9pF@netcom.com&gt; skoog@netcom.com (Jim Skoog) writes:
-&gt;Where are the performance bottlenecks for Alpha AXP running the
-&gt;Netscape Commerce Server 1.12 with high volume internet traffic?
-&gt;We are evaluating network performance for a variety of Alpha AXP
-&gt;runing DEC UNIX 3.2C, which run DEC's seal firewall and behind
-&gt;that Alpha 1000 and 2100 webservers.
-
-Our experience (running such Web servers as <A
- HREF="http://altavista.digital.com">altavista.digital.com</A>
-and <A HREF="http://www.digital.com"
- >www.digital.com</A>) is that there is one important kernel tuning
-knob to adjust in order to get good performance on V3.2C. You
-need to patch the kernel global variable "somaxconn" (use dbx -k
-to do this) from its default value of 8 to something much larger.
-
-How much larger? Well, no larger than 32767 (decimal). And
-probably no less than about 2048, if you have a really high volume
-(millions of hits per day), like AltaVista does.
-
-This change allows the system to maintain more than 8 TCP
-connections in the SYN_RCVD state for the HTTP server. (You
-can use "netstat -An |grep SYN_RCVD" to see how many such
-connections exist at any given instant).
-
-If you don't make this change, you might find that as the load gets
-high, some connection attempts take a very long time. And if a lot
-of your clients disconnect from the Internet during the process of
-TCP connection establishment (this happens a lot with dialup
-users), these "embryonic" connections might tie up your somaxconn
-quota of SYN_RCVD-state connections. Until the kernel times out
-these embryonic connections, no other connections will be accepted,
-and it will appear as if the server has died.
-
-The default value for somaxconn in Digital UNIX V4.0 will be quite
-a bit larger than it has been in previous versions (we inherited
-this default from 4.3BSD).
-
-Digital UNIX V4.0 includes some other performance-related changes
-that significantly improve its maximum HTTP connection rate. However,
-we've been using V3.2C systems to front-end for altavista.digital.com
-with no obvious performance bottlenecks at the millions-of-hits-per-day
-level.
-
-We have some Webstone performance results available at
- http://www.digital.com/info/alphaserver/news/webff.html
-
-<EM>[The document referenced above is no longer at that URL -- Ed.]</EM>
-
-I'm not sure if these were done using V4.0 or an earlier version
-of Digital UNIX, although I suspect they were done using a test
-version of V4.0.
-
--Jeff
-
-<HR>
-
-----------------------------------------------------------------------------
-
-From mogul@pa.dec.com (Jeffrey Mogul)
-Organization DEC Western Research
-Date 31 May 1996 21:01:01 GMT
-Newsgroups <A HREF="news:comp.unix.osf.osf1">comp.unix.osf.osf1</A>
-Message-ID &lt;4onmmd$mmd@usenet.pa.dec.com&gt;
-Subject Digital UNIX V3.2C Internet tuning patch info
-
-----------------------------------------------------------------------------
-
-Something that probably few people are aware of is that Digital
-has a patch kit available for Digital UNIX V3.2C that may improve
-Internet performance, especially for busy web servers.
-
-This patch kit is one way to increase the value of somaxconn,
-which I discussed in a message here a day or two ago.
-
-I've included in this message the revised README file for this
-patch kit below. Note that the original README file in the patch
-kit itself may be an earlier version; I'm told that the version
-below is the right one.
-
-Sorry, this patch kit is NOT available for other versions of Digital
-UNIX. Most (but not quite all) of these changes also made it into V4.0,
-so the description of the various tuning parameters in this README
-file might be useful to people running V4.0 systems.
-
-This patch kit does not appear to be available (yet?) from
- <A HREF="http://www.service.digital.com/html/patch_service.html"
- >http://www.service.digital.com/html/patch_service.html</A>
-so I guess you'll have to call Digital's Customer Support to get it.
-
--Jeff
-
-DESCRIPTION: Digital UNIX Network tuning patch
-
- Patch ID: OSF350-146
-
- SUPERSEDED PATCHES: OSF350-151, OSF350-158
-
- This set of files improves the performance of the network
- subsystem on a system being used as a web server. There are
- additional tunable parameters included here, to be used
- cautiously by an informed system administrator.
-
-TUNING
-
- To tune the web server, the number of simultaneous socket
- connection requests are limited by:
-
- somaxconn Sets the maximum number of pending requests
- allowed to wait on a listening socket. The
- default value in Digital UNIX V3.2 is 8.
- This patch kit increases the default to 1024,
- which matches the value in Digital UNIX V4.0.
-
- sominconn Sets the minimum number of pending connections
- allowed on a listening socket. When a user
- process calls listen with a backlog less
- than sominconn, the backlog will be set to
- sominconn. sominconn overrides somaxconn.
- The default value is 1.
-
- The effectiveness of tuning these parameters can be monitored by
- the sobacklog variables available in the kernel:
-
- sobacklog_hiwat Tracks the maximum pending requests to any
- socket. The initial value is 0.
-
- sobacklog_drops Tracks the number of drops exceeding the
- socket set backlog limit. The initial
- value is 0.
-
- somaxconn_drops Tracks the number of drops exceeding the
- somaxconn limit. When sominconn is larger
- than somaxconn, tracks the number of drops
- exceeding sominconn. The initial value is 0.
-
- TCP timer parameters also affect performance. Tuning the following
- require some knowledge of the characteristics of the network.
-
- tcp_msl Sets the tcp maximum segment lifetime.
- This is the maximum lifetime in half
- seconds that a packet can be in transit
- on the network. This value, when doubled,
- is the length of time a connection remains
- in the TIME_WAIT state after a incoming
- close request is processed. The unit is
- specified in 1/2 seconds, the initial
- value is 60.
-
- tcp_rexmit_interval_min
- Sets the minimum TCP retransmit interval.
- For some WAN networks the default value may
- be too short, causing unnecessary duplicate
- packets to be sent. The unit is specified
- in 1/2 seconds, the initial value is 1.
-
- tcp_keepinit This is the amount of time a partially
- established connection will sit on the listen
- queue before timing out (<EM>e.g.</EM>, if a client
- sends a SYN but never answers our SYN/ACK).
- Partially established connections tie up slots
- on the listen queue. If the queue starts to
- fill with connections in SYN_RCVD state,
- tcp_keepinit can be decreased to make those
- partial connects time out sooner. This should
- be used with caution, since there might be
- legitimate clients that are taking a while
- to respond to SYN/ACK. The unit is specified
- in 1/2 seconds, the default value is 150
- (ie. 75 seconds).
-
- The hashlist size for the TCP inpcb lookup table is regulated by:
-
- tcbhashsize The number of hash buckets used for the
- TCP connection table used in the kernel.
- The initial value is 32. For best results,
- should be specified as a power of 2. For
- busy Web servers, set this to 2048 or more.
-
- The hashlist size for the interface alias table is regulated by:
-
- inifaddr_hsize The number of hash buckets used for the
- interface alias table used in the kernel.
- The initial value is 32. For best results,
- should be specified as a power of 2.
-
- ipport_userreserved The maximum number of concurrent non-reserved,
- dynamically allocated ports. Default range
- is 1025-5000. The maximum value is 65535.
- This limits the numer of times you can
- simultaneously telnet or ftp out to connect
- to other systems.
-
- tcpnodelack Don't delay acknowledging TCP data; this
- can sometimes improve performance of locally
- run CAD packages. Default is value is 0,
- the enabled value is 1.
-
- Digital UNIX version:
-
- V3.2C
-Feature V3.2C patch V4.0
-======= ===== ===== ====
-somaxconn X X X
-sominconn - X X
-sobacklog_hiwat - X -
-sobacklog_drops - X -
-somaxconn_drops - X -
-tcpnodelack X X X
-tcp_keepidle X X X
-tcp_keepintvl X X X
-tcp_keepcnt - X X
-tcp_keepinit - X X
-TCP keepalive per-socket - - X
-tcp_msl - X -
-tcp_rexmit_interval_min - X -
-TCP inpcb hashing - X X
-tcbhashsize - X X
-interface alias hashing - X X
-inifaddr_hsize - X X
-ipport_userreserved - X -
-sysconfig -q inet - - X
-sysconfig -q socket - - X
-
-</PRE>
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
diff --git a/docs/manual/platform/perf-hp.html b/docs/manual/platform/perf-hp.html
deleted file mode 100644
index ca902a09fe..0000000000
--- a/docs/manual/platform/perf-hp.html
+++ /dev/null
@@ -1,122 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Running a High-Performance Web Server on HPUX</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<A NAME="initial">&nbsp;</A>
-<!--#include virtual="header.html" -->
-
-<H1 ALIGN="CENTER">Running a High-Performance Web Server for HPUX</H1>
-
-<PRE>
-Date: Wed, 05 Nov 1997 16:59:34 -0800
-From: Rick Jones &lt;<A HREF="mailto:raj@cup.hp.com">raj@cup.hp.com</A>&gt;
-Reply-To: raj@cup.hp.com
-Organization: Network Performance
-Subject: HP-UX tuning tips
-</PRE>
-
-Here are some tuning tips for HP-UX to add to the tuning page.
-
-<P>
-
-For HP-UX 9.X: Upgrade to 10.20<BR>
-For HP-UX 10.[00|01|10]: Upgrade to 10.20
-
-<P>
-
-For HP-UX 10.20:
-
-<P>
-
-Install the latest cumulative ARPA Transport Patch. This will allow you
-to configure the size of the TCP connection lookup hash table. The
-default is 256 buckets and must be set to a power of two. This is
-accomplished with adb against the *disc* image of the kernel. The
-variable name is tcp_hash_size.
-
-Notice that it's critically important that you use "W" to write a 32 bit
-quantity, not "w" to write a 16 bit value when patching the disc image because
-the tcp_hash_size variable is a 32 bit quantity.
-
-<P>
-
-How to pick the value? Examine the output of
-<A HREF="ftp://ftp.cup.hp.com/dist/networking/tools/connhist">
-ftp://ftp.cup.hp.com/dist/networking/tools/connhist</A> and see how many
-total TCP connections exist on the system. You probably want that number
-divided by the hash table size to be reasonably small, say less than 10.
-Folks can look at HP's SPECweb96 disclosures for some common settings.
-These can be found at <A HREF="http://www.specbench.org/">
-http://www.specbench.org/</A>. If an HP-UX system was
-performing at 1000 SPECweb96 connections per second, the TIME_WAIT time
-of 60 seconds would mean 60,000 TCP "connections" being tracked.
-
-<P>
-
-Folks can check their listen queue depths with
-<A HREF="ftp://ftp.cup.hp.com/dist/networking/misc/listenq">
-ftp://ftp.cup.hp.com/dist/networking/misc/listenq</A>.
-
-<P>
-
-If folks are running Apache on a PA-8000 based system, they should
-consider "chatr'ing" the Apache executable to have a large page size.
-This would be "chatr +pi L &lt;BINARY&gt;." The GID of the running executable
-must have MLOCK privileges. Setprivgrp(1m) should be consulted for
-assigning MLOCK. The change can be validated by running Glance and
-examining the memory regions of the server(s) to make sure that they
-show a non-trivial fraction of the text segment being locked.
-
-<P>
-
-If folks are running Apache on MP systems, they might consider writing a
-small program that uses mpctl() to bind processes to processors. A
-simple pid % numcpu algorithm is probably sufficient. This might even go
-into the source code.
-
-<P>
-
-If folks are concerned about the number of FIN_WAIT_2 connections, they
-can use nettune to shrink the value of tcp_keepstart. However, they
-should be careful there - certainly do not make it less than oh two to
-four minutes. If tcp_hash_size has been set well, it is probably OK to
-let the FIN_WAIT_2's take longer to timeout (perhaps even the default
-two hours) - they will not on average have a big impact on performance.
-
-<P>
-
-There are other things that could go into the code base, but that might
-be left for another email. Feel free to drop me a message if you or
-others are interested.
-
-<P>
-
-sincerely,
-
-<P>
-
-rick jones<BR>
-<A HREF="http://www.cup.hp.com/netperf/NetperfPage.html">
-http://www.cup.hp.com/netperf/NetperfPage.html</A>
-
-<HR>
-
-<H3 ALIGN="CENTER">
- Apache HTTP Server Version 1.3
-</H3>
-
-<A HREF="./"><IMG SRC="../images/index.gif" ALT="Index"></A>
-<A HREF="../"><IMG SRC="../images/home.gif" ALT="Home"></A>
-
-</BODY></HTML>
-
diff --git a/docs/manual/platform/perf.html b/docs/manual/platform/perf.html
deleted file mode 100644
index 73bd5b5b20..0000000000
--- a/docs/manual/platform/perf.html
+++ /dev/null
@@ -1,175 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Hints on Running a High-Performance Web Server</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Hints on Running a High-Performance Web Server</H1>
-
-Running Apache on a heavily loaded web server, one often encounters
-problems related to the machine and OS configuration. "Heavy" is
-relative, of course - but if you are seeing more than a couple hits
-per second on a sustained basis you should consult the pointers on
-this page. In general the suggestions involve how to tune your kernel
-for the heavier TCP load, hardware/software conflicts that arise, <EM>etc.</EM>
-
-<UL>
-<LI><A HREF="#AUX">A/UX (Apple's UNIX)</A>
-<LI><A HREF="#BSD">BSD-based (BSDI, FreeBSD, etc)</A>
-<LI><A HREF="#DEC">Digital UNIX</A>
-<LI><A HREF="perf-hp.html">HPUX</A>
-<LI><A HREF="#Linux">Linux</A>
-<LI><A HREF="#Solaris">Solaris</A>
-<LI><A HREF="#SunOS">SunOS 4.x</A>
-<LI><A HREF="#SVR4">SVR4</A>
-</UL>
-
-<HR>
-
-<H3><A NAME="AUX">
-A/UX (Apple's UNIX)
-</A></H3>
-
-If you are running Apache on A/UX, a page that gives some helpful
-performance hints (concerning the <EM>listen()</EM> queue and using
-virtual hosts)
-<A HREF="http://www.jaguNET.com/apache.html">can be found here</A>
-
-<P><HR>
-
-<H3><A NAME="BSD">
-BSD-based (BSDI, FreeBSD, etc)
-</A></H3>
-
-<A HREF="perf-bsd44.html#initial">Quick</A> and
-<A HREF="perf-bsd44.html#detail">detailed</A>
-performance tuning hints for BSD-derived systems.
-
-<P><HR>
-
-<H3><A NAME="DEC">
-Digital UNIX
-</A></H3>
-
-<UL>
- <LI><A
- HREF="http://www.digital.com/info/internet/document/ias/tuning.html"
- >DIGITAL UNIX Tuning Parameters for Web Servers</A>
- <LI>We have some <A HREF="perf-dec.html">newsgroup postings</A> on how
- to tune Digital UNIX 3.2 and 4.0.
-</UL>
-
-<P><HR>
-
-<H3><A NAME="Linux">
-Linux
-</A></H3>
-
-There are no known problems with heavily loaded systems running Linux
-kernels 2.0.32 or later. Earlier kernels have some problems, and an
-upgrade to the latest 2.0.x is a good idea to eliminate various security
-and denial of service attacks.
-
-<P><HR>
-
-<H3><A NAME="Solaris">
-Solaris 2.4
-</A></H3>
-
-The Solaris 2.4 TCP implementation has a few inherent limitations that
-only became apparent under heavy loads. This has been fixed to some
-extent in 2.5 (and completely revamped in 2.6), but for now consult
-the following URL for tips on how to expand the capabilities if you
-are finding slowdowns and lags are hurting performance.
-
-<P>
-
-Other links:
-
-<UL>
-
-<LI><A HREF="http://www.sun.com/sun-on-net/performance.html">
-World Wide Web Server Performance,
-&lt;http://www.sun.com/sun-on-net/performance.html&gt;</A>
-<LI><A HREF="http://www.rvs.uni-hannover.de/people/voeckler/tune/EN/tune.html">
-Solaris 2.x - tuning your TCP/IP stack</A> contains some good technical
-information about tuning various Solaris TCP/IP parameters.
-</UL>
-
-<P><HR>
-
-<H3><A NAME="SunOS">
-SunOS 4.x
-</A></H3>
-
-More information on tuning SOMAXCONN on SunOS can be found at
-<A HREF="http://www.islandnet.com/~mark/somaxconn.html">
-http://www.islandnet.com/~mark/somaxconn.html</A>.
-
-<P><HR>
-
-<H3><A NAME="SVR4">
-SVR4
-</A></H3>
-
-Some SVR4 versions waste three system calls on every
-<SAMP>gettimeofday()</SAMP> call. Depending on the syntactic
-form of the <SAMP>TZ</SAMP> environment variable, these
-systems have several different algorithms to determine the
-local time zone (presumably <EM>compatible</EM> with
-something). The following example uses the central european
-time zone to demonstrate this:
-<DL>
- <DT><STRONG>TZ=:MET</STRONG>
- <DD>This form delegates the knowledge of the time zone
- information to an external compiled zoneinfo file
- (&agrave; la BSD).<BR>
- <STRONG>Caveat:</STRONG> Each time the gettimeofday()
- function is called, the external zone info is read in
- again (at least on some SVR4 systems). That results in
- three wasted system calls with every apache request
- served.<PRE>
- open("/usr/lib/locale/TZ/MET", O_RDONLY) = 3
- read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 7944) = 778
- close(3) = 0</PRE>
-
- <DT><STRONG>TZ=MET-1MDT,M3.5.0/02:00:00,M10.5.0/03:00:00</STRONG>
- <DD>This syntax form (&agrave; la SYSV) contains all the
- knowledge about time zone beginning and ending times in
- its external representation. It has to be parsed each
- time it is evaluated, resulting in a slight computing
- overhead, but it requires no system call. Though the
- table lookup &agrave; la BSD is the more sophisticated
- technical solution, the bad SVR4 implementation makes
- this the preferred syntax on systems which otherwise
- access the external zone info file repeatedly.
-</DL>
-You should use the <SAMP>truss</SAMP> utility on a
-single-process apache server (started with the <SAMP>-X</SAMP>
-debugging switch) to determine whether your system can profit
-from the second form of the <SAMP>TZ</SAMP> environment
-variable. If it does, you could integrate the setting of the
-preferred <SAMP>TZ</SAMP> syntax into the httpd startup
-script, which is usually simply a copy of (or symbolic link
-to) the <SAMP>apachectl</SAMP> utility script, or into the
-system's <SAMP>/etc/TIMEZONE</SAMP> script.
-
-<P><HR>
-
-<H3>More welcome!</H3>
-
-If you have tips to contribute, send mail to <A
-HREF="mailto:apache@apache.org">apache@apache.org</A>
-
-<!--#include virtual="footer.html" -->
-</BODY></HTML>
-
diff --git a/docs/manual/platform/readme-tpf.html b/docs/manual/platform/readme-tpf.html
deleted file mode 100644
index 9d1a82a279..0000000000
--- a/docs/manual/platform/readme-tpf.html
+++ /dev/null
@@ -1,208 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>The Apache TPF Port</TITLE>
-</HEAD>
-<BODY>
-<A NAME="top"></A>
-<H1 align="center">Overview of the Apache TPF Port</H1>
-<HR>
-<CENTER>[&nbsp;<A HREF="#configuration_files">Configuration Files</A>
- &nbsp;|&nbsp;<A HREF="#whats_available">What's Available</A>
- &nbsp;|&nbsp;<A HREF="#porting_notes">Porting Notes</A>&nbsp;]
-</CENTER>
-<HR>
-<BR>
-
-<P>
- This version of Apache includes changes allowing it to run on
- IBM's EBCDIC-based
- <A HREF="http://www.s390.ibm.com/products/tpf/tpfhp.html">TPF</A>
- (Transaction Processing Facility) operating system.
- Unless otherwise noted TPF version 4.1 PUT09 is required.
- <BR><BR>
- Refer to htdocs/manual/<A HREF="install-tpf.html">install-tpf.html</A>
- for step-by-step installation instructions.
- <BR><BR>
- As this is the first cut at making Apache run on TPF,
- performance tuning has not been done.
- <BR><BR>
- This port builds upon the <A HREF="ebcdic.html">EBCDIC changes</A>
- previously made to Apache.
- <BR>
-</P>
-
-<A NAME="configuration_files">&nbsp;</A>
-<H2 align=center>Apache Configuration Files</H2>
-<P>
- The distributed configuration files (httpd.conf-dist and
- mime.types, both located in the conf subdirectory)
- work on TPF. Performance considerations may dictate setting KeepAlive to "Off"
- (the default is "On") or lowering the Timeout value from the default
- 300 seconds (5 minutes) in order to reduce the number of active ECBs on your system.
-</P>
-
-<A NAME="whats_available">&nbsp;</A>
-<H2 align=center>What's Available in this Version</H2>
-
- (The Apache organization provides
- <A HREF="http://www.apache.org/docs/">online documentation</A>
- describing the various modules and components of the server.)
-
-<H3>Components/modules tested on TPF:</H3>
-
- <multicol COLS=3><UL>
- <LI>alloc.c
- <LI>ap_base64.c
- <LI>ap_checkpass.c
- <LI>ap_cpystrn.c
- <LI>ap_fnmatch.c
- <LI>ap_md5c.c
- <LI>ap_sha1.c
- <LI>ap_signal.c
- <LI>ap_slack.c
- <LI>ap_snprintf.c
- <LI>buff.c
- <LI>buildmark.c
- <LI>ebcdic.c
- <LI>gen_test.char.c
- <LI>gen_uri_delims.c
- <LI>htpasswd.c <i><small>(requires PUT10)</small></i>
- <LI>http_config.c
- <LI>http_core.c
- <LI>http_log.c
- <LI>http_main.c
- <LI>http_protocol.c
- <LI>http_request.c
- <LI>http_vhost.c
- <LI>logresolve.c <i><small>(requires PUT10)</small></i>
- <LI>mod_access.c <A HREF="#notes"> <i><small>(see note 1)</small></i></A>
- <LI>mod_actions.c
- <LI>mod_alias.c
- <LI>mod_asis.c
- <LI>mod_auth.c
- <LI>mod_auth_anon.c
- <LI>mod_autoindex.c
- <LI>mod_cern_meta.c
- <LI>mod_cgi.c <i><small>(requires PUT10)</small></i>
- <LI>mod_digest.c
- <LI>mod_dir.c
- <LI>mod_env.c
- <LI>mod_example.c
- <LI>mod_expires.c
- <LI>mod_headers.c
- <LI>mod_imap.c
- <LI>mod_include.c <A HREF="#notes"> <i><small>(see note 2)</small></i></A>
- <LI>mod_info.c
- <LI>mod_log_agent.c
- <LI>mod_log_config.c
- <LI>mod_log_referer.c
- <LI>mod_mime.c
- <LI>mod_mime_magic.c
- <LI>mod_negotiation.c
- <LI><A HREF="http://hpwww.ec-lyon.fr/~vincent/apache/mod_put.html">mod_put.c</A>
- <i> <small>(third party module)</small></i>
- <LI>mod_proxy.c
- <LI>mod_setenvif.c
- <LI>mod_speling.c
- <LI>mod_status.c
- <LI>mod_tpf_shm_static.c <i><small>(third party module, requires PUT10)</small></i>
- <LI>mod_unique_id.c <i><small>(requires PUT10)</small></i>
- <LI>mod_userdir.c
- <LI>mod_usertrack.c
- <LI>os.c
- <LI>os-inline.c
- <LI>proxy_cache.c
- <LI>proxy_connect.c
- <LI>proxy_ftp.c
- <LI>proxy_http.c
- <LI>proxy_util.c
- <LI>regular expression parser
- <LI>regular expression test tool <i><small>(requires PUT10)</small></i>
- <LI>rfc1413.c
- <LI>rotatelogs.c <i><small>(requires PUT10)</small></i>
- <LI>util.c
- <LI>util_date.c
- <LI>util_md5.c
- <LI>util_script.c
- <LI>util_uri.c
- </UL></MULTICOL>
- <A NAME="notes"></A><b>Notes:</b>
- <ol>
- <li>Use of mod_access directives &quot;<tt>allow from</tt>&quot; &amp; &quot;<tt>deny from</tt>&quot;
- with host <i>names</i> (verses ip addresses) requires TPF version 4.1 PUT10
- <li>CGI execution requires TPF version 4.1 PUT10
- </ol>
-
-<H3>Components/modules not yet supported on TPF:</H3>
-
- <multicol COLS=3><UL>
- <LI>htdigest.c
- <LI>lib/expat-lite
- <LI>mod_auth_digest.c
- <LI>mod_rewrite.c
- <LI>mod_vhost_alias.c
- </UL></MULTICOL>
-
-<H3>Components/modules that don't apply or that probably won't ever be available on TPF:</H3>
-
- <multicol COLS=3><UL>
- <LI>ab.c
- <LI>ap_getpass.c
- <LI>mod_auth_db.c
- <LI>mod_auth_dbm.c
- <LI>mod_auth_db.module
- <LI>mod_mmap_static.c
- <LI>mod_so.c
- <LI>suexec.c
- </UL></MULTICOL>
-
-<A NAME="porting_notes">&nbsp;</A>
-<H2 align=center>Porting Notes</H2>
-<P>
- <H3>Changes made due to differences between UNIX and
- TPF's process models:</H3>
- <UL>
- <LI><STRONG>Signals</STRONG>: On TPF a signal that is sent to a process
- remains unhandled until the process explicitly requests that signals
- be handled using the <CODE>tpf_process_signals()</CODE> function.
- Additionally, the default action for an alarm on TPF is to take
- an OPR-7777 dump and exit. (On UNIX the default is the equivalent
- of <CODE>exit()</CODE> with no dump taken.)
- These differences necessitated a few modifications:
- <BR><BR>
- <UL>
- <LI>bypass the use of <CODE>ap_block_alarms()</CODE> &amp;
- <CODE>ap_unblock_alarms()</CODE>
- <LI>add <CODE>tpf_process_signals()</CODE> calls
- <LI>add <CODE>select()</CODE> calls to prevent blocking.
- </UL>
- <BR>
- </UL>
-
- <H3>Find that function...</H3>
- <P>Some simple functions &amp; definitions initially needed to be added
- on TPF, such as <CODE>FD_SET()</CODE>.
- We've put these in src/os/tpf/os.h for now.
- </P>
-
- <H3>EBCDIC changes:</H3>
- <P>TPF-specific conversion tables between US-ASCII and
- EBCDIC (character set IBM-1047 to be exact) were created
- and put into ebcdic.c in the src/os/tpf directory.
- </P>
-
- <H3>Miscellaneous, minor changes:</H3>
- <P>Various minor changes (such as casting) were made due to
- differences in how some functions are implemented on TPF.
- </P>
-
-<HR>
-<CENTER>[&nbsp;<A HREF="#top">top</A>
- &nbsp;|&nbsp;<A HREF="#configuration_files">Configuration Files</A>
- &nbsp;|&nbsp;<A HREF="#whats_available">What's Available</A>
- &nbsp;|&nbsp;<A HREF="#porting_notes">Porting Notes</A>&nbsp;]
-</CENTER>
-
-</BODY>
-</HTML>
diff --git a/docs/manual/platform/unixware.html b/docs/manual/platform/unixware.html
deleted file mode 100644
index a77a3b5cd4..0000000000
--- a/docs/manual/platform/unixware.html
+++ /dev/null
@@ -1,62 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Compiling Apache under UnixWare</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-
-<H1 ALIGN="CENTER">Compiling Apache under UnixWare</H1>
-
-To compile a working copy of Apache under UnixWare, there are several other
-steps you may need to take. These prevent such problems as zombie processes,
-bind errors, and accept errors, to name a few.
-
-<H2>UnixWare 1.x</H2>
-
-Make sure that USE_FCNTL_SERIALIZE_ACCEPT is defined (if not
-defined by Apache autoconfiguration). If using the UnixWare <EM>cc</EM>
-compiler, and you still see accept() errors, don't use compiler optimization,
-or get <EM>gcc</EM>.
-
-<H2>UnixWare 2.0.x</H2>
-
-SCO patch <A HREF="ftp://ftp.sco.com/UW20/tf2163.txt">tf2163</A> is required
-in order for Apache to work correctly on UnixWare 2.0.x. See
-<A HREF="http://www.sco.com">http://www.sco.com</A>
-for UnixWare patch information.<P>
-
-In addition, make sure that USE_FCNTL_SERIALIZE_ACCEPT is defined (if not
-defined by Apache autoconfiguration). To reduce instances of connections
-in FIN_WAIT_2 state, you may also want to define NO_LINGCLOSE (Apache 1.2
-only).
-
-<H2>UnixWare 2.1.x</H2>
-
-SCO patch <A HREF="ftp://ftp.sco.com/UW21/ptf3123b.txt">ptf3123</A> is required
-in order for Apache to work correctly on UnixWare 2.1.x. See
-<A HREF="http://www.sco.com">http://www.sco.com</A>
-for UnixWare patch information.<P>
-
-<STRONG>NOTE:</STRONG> Unixware 2.1.2 and later already have patch ptf3123
-included<P>
-
-In addition, make sure that USE_FCNTL_SERIALIZE_ACCEPT is defined (if not
-defined by Apache autoconfiguration). To reduce instances of connections
-in FIN_WAIT_2 state, you may also want to define NO_LINGCLOSE (Apache 1.2
-only).<P>
-
-Thanks to Joe Doupnik &lt;JRD@cc.usu.edu&gt; and Rich Vaughn
-&lt;rvaughn@aad.com&gt; for additional info for UnixWare builds.<P>
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
diff --git a/docs/manual/platform/windows.html b/docs/manual/platform/windows.html
deleted file mode 100644
index a9989b0063..0000000000
--- a/docs/manual/platform/windows.html
+++ /dev/null
@@ -1,572 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Using Apache with Microsoft Windows</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-
-<H1 ALIGN="CENTER">Using Apache With Microsoft Windows</H1>
-
-<P>This document explains how to install, configure and run
- Apache 1.3 under Microsoft Windows. Please note that at
- this time, Windows support is entirely experimental, and is
- recommended only for experienced users. The Apache Group does not
- guarantee that this software will work as documented, or even at
- all. If you find any bugs, or wish to contribute in other ways, please
- use our <A HREF="http://www.apache.org/bug_report.html">bug reporting
- page.</A></P>
-
-<P><STRONG>Warning: Apache on NT has not yet been optimized for performance.
-Apache still performs best, and is most reliable on Unix platforms. Over
-time we will improve NT performance. Folks doing comparative reviews
-of webserver performance are asked to compare against Apache
-on a Unix platform such as Solaris, FreeBSD, or Linux.</STRONG></P>
-
-<P>
-
-Most of this document assumes that you are installing Windows from a
-binary distribution. If you want to compile Apache yourself (possibly
-to help with development, or to track down bugs), see the section on
-<A HREF="#comp">Compiling Apache for Windows</A> below.
-
-<HR>
-
-<UL>
- <LI><A HREF="#req">Requirements</A>
- <LI><A HREF="#down">Downloading Apache for Windows</A>
- <LI><A HREF="#inst">Installing Apache for Windows (binary install)</A>
- <LI><A HREF="#run">Running Apache for Windows</A>
- <LI><A HREF="#use">Using Apache for Windows</A>
- <LI><A HREF="#cmdline">Running Apache for Windows from the Command Line</A>
- <LI><A HREF="#service">Running Apache for Windows as a Service</A>
- <LI><A HREF="#signal">Signalling Console Apache when running</A>
- <LI><A HREF="#signalsrv">Signalling Service Apache when running</A>
- <LI><A HREF="#comp">Compiling Apache for Windows</A>
-</UL>
-
-<HR>
-
-<H2><A NAME="req">Requirements</A></H2>
-
-Apache 1.3 is designed to run on Windows NT 4.0. The binary installer
-will only work in Intel processors. Apache may also run on Windows 95,
-Windows 98 and Windows NT 3.5.1, but these have not been tested. In
-all cases TCP/IP networking must be installed.
-
-<P>
-
-If running on Windows 95, using the "Winsock2" upgrade is recommended
-but may not be necessary. If running on NT 4.0, installing Service Pack 2
-is recommended.
-
-<P>
-
-<STRONG>Note: "Winsock 2" is required for Apache 1.3.7 and later.</STRONG>
-
-<P>
-
-"Winsock 2" for Windows 95 is available <A HREF="http://www.microsoft.com/windows95/downloads/">here.</A>
-
-<H2><A NAME="down">Downloading Apache for Windows</A></H2>
-
-<P>Information on the latest version of Apache can be found on the
-Apache web server at <A
-HREF="http://www.apache.org/">http://www.apache.org/</A>. This will
-list the current release, any more recent alpha or beta-test releases,
-together with details of mirror web and anonymous ftp sites.</P>
-
-<P>
-
-You should download the version of Apache for Windows with the
-<CODE>.exe</CODE> extension. This is a single file containing Apache,
-ready to install and run. There may also be a <CODE>.zip</CODE> file
-containing the source code, to compile Apache yourself. (If there is
-no <SAMP>.zip</SAMP> file, the source will be available in a
-<SAMP>.tar.gz</SAMP> file but this will contain Unix line endings. You
-will have to convert at least the <SAMP>.mak</SAMP> and
-<SAMP>.dsp</SAMP> files to have DOS line endings before MSVC will
-understand them).
-
-<H2><A NAME="inst">Installing Apache for Windows</A></H2>
-
-Run the Apache <SAMP>.exe</SAMP> file you downloaded above. This will
-ask for:
-
-<UL>
-
- <LI>the directory to install Apache into (the default is
- <CODE>\Program Files\Apache Group\Apache</CODE> although you can
- change this to any other directory)
-
- <LI>the start menu name (default is "Apache Web Server")
-
- <LI>the installation type. The "Typical" option installs
- everything except the source code. The "Minimum" option does not
- install the manuals or source code. Choose the "Custom" install if
- you want to install the source code.
-
-</UL>
-
-<P>
-
-During the installation, Apache will configure the files in the
-<SAMP>conf</SAMP> directory for your chosen installation
-directory. However if any of the files in this directory already exist
-they will <STRONG>not</STRONG> be overwritten. Instead the new copy of
-the corresponding file will be left with the extension
-<SAMP>.default</SAMP>. So, for example, if
-<SAMP>conf\httpd.conf</SAMP> already exists it will not be altered,
-but the version which would have been installed will be left in
-<SAMP>conf\httpd.conf.default</SAMP>. After the installation has
-finished you should manually check to see what in new in the
-<SAMP>.default</SAMP> file, and if necessary update your existing
-configuration files.
-
-<P>
-
-Also, if you already have a file called <SAMP>htdocs\index.html</SAMP>
-then it will not be overwritten (no <SAMP>index.html.default</SAMP>
-file will be installed either). This should mean it a safe to install
-Apache over an existing installation (but you will have to stop the
-existing server running before doing the installation, then start the
-new one after the installation is finished).
-
-<P>
-
-After installing Apache, you should edit the configuration files in
-the <SAMP>conf</SAMP> directory as required. These files will be
-configured during the install ready for Apache to be run from the
-directory where it was installed, with the documents served from the
-subdirectory <SAMP>htdocs</SAMP>. There are lots of other options
-which should be set before you start really using Apache. However to
-get started quickly the files should work as installed.
-
-<H2><A NAME="run">Running Apache for Windows</A></H2>
-
-There are two ways you can run Apache:
-
-<UL>
- <LI>As a <A HREF="#service">"service"</A> (available on NT only). This is the best option if
- you want Apache to automatically start when you machine boots, and to
- keep Apache running when you log-off.
-
- <LI>From a <A HREF="#cmdline">console window</A>. This is the only option
- available for
- Windows 95 users.
-</UL>
-
-To start Apache as a service, you first need to install it as a
-service. Multiple Apache services can be installed, each with a
-different name and configuration. To install the default Apache
-service named "Apache", run the "Install Apache as Service (NT only)"
-option from the Start menu. Once this is done you can start the "Apache"
-service by opening the Services window (in the Control Panel), selecting Apache,
-then clicking on Start. Apache will now be running in the background. You
-can later stop Apache by clicking on Stop. As an alternative to using
-the Services window, you can start and stop the "Apache" service from the control
-line with
-
-<PRE>
- NET START APACHE
- NET STOP APACHE
-</PRE>
-
-See <A HREF="#signalsrv">Signalling Service Apache when Running</A>
-for more information on installing and controlling Apache services.
-
-<P>
-
-To run Apache from a console window, select the "Start Apache as
-console app" option from the Start menu (in Apache 1.3.4 and earlier,
-this option was called "Apache Server"). This will open a console
-window and start Apache running inside it. The window will remain
-active until you stop Apache. To stop Apache running, either select
-the "Shutdown Apache console app" icon option from the Start menu
-(this is not available in Apache 1.3.4 or earlier), or see <A
-HREF="#signal">Signalling Console Apache when Running</A> for how
-to control Apache from the command line.
-
-<P>
-
-After starting Apache running (either in a console window or as a
-service) if will be listening to port 80 (unless you changed the
-<SAMP>Port</SAMP>, <SAMP>Listen</SAMP> or <SAMP>BindAddress</SAMP>
-directives in the configuration files). To connect to the server and
-access the default page, launch a browser and enter this URL:
-
-<PRE>
- http://localhost/
-</PRE>
-
-This should respond with a welcome page, and a link to the Apache
-manual. If nothing happens or you get an error, look in the
-<SAMP>error_log</SAMP> file in the <SAMP>logs</SAMP> directory.
-If your host isn't connected to the net, you may have to use
-this URL:
-
-<PRE>
- http://127.0.0.1/
-</PRE>
-
-<P>
-
-Once your basic installation is working, you should configure it
-properly by editing the files in the <SAMP>conf</SAMP> directory.
-
-<H2><A NAME="use">Configuring Apache for Windows</A></H2>
-
-Apache is configured by files in the <SAMP>conf</SAMP>
-directory. These are the same as files used to configure the Unix
-version, but there are a few different directives for Apache on
-Windows. See the <A HREF="./">Apache documentation</A> for all the
-available directives.
-
-<P>
-
-The main differences in Apache for Windows are:
-
-<UL>
- <LI><P>Because Apache for Windows is multithreaded, it does not use a
- separate process for each request, as Apache does with
- Unix. Instead there are usually only two Apache processes running:
- a parent process, and a child which handles the requests. Within
- the child each request is handled by a separate thread.
- <P>
-
- So the "process"-management directives are different:
- <P><A
- HREF="mod/core.html#maxrequestsperchild">MaxRequestsPerChild</A>
- - Like the Unix directive, this controls how many requests a
- process will serve before exiting. However, unlike Unix, a
- process serves all the requests at once, not just one, so if
- this is set, it is recommended that a very high number is
- used. The recommended default, <CODE>MaxRequestsPerChild
- 0</CODE>, does not cause the process to ever exit.
- <P><A HREF="mod/core.html#threadsperchild">ThreadsPerChild</A> -
- This directive is new, and tells the server how many threads it
- should use. This is the maximum number of connections the server
- can handle at once; be sure and set this number high enough for
- your site if you get a lot of hits. The recommended default is
- <CODE>ThreadsPerChild 50</CODE>.</P>
- <LI><P>The directives that accept filenames as arguments now must use
- Windows filenames instead of Unix ones. However, because Apache
- uses Unix-style names internally, you must use forward slashes, not
- backslashes. Drive letters can be used; if omitted, the drive with
- the Apache executable will be assumed.</P>
- <LI><P>Apache for Windows contains the ability to load modules at runtime,
- without recompiling the server. If Apache is compiled normally, it
- will install a number of optional modules in the
- <CODE>\Apache\modules</CODE> directory. To activate these, or other
- modules, the new <A HREF="mod/mod_so.html#loadmodule">LoadModule</A>
- directive must be used. For example, to active the status module,
- use the following (in addition to the status-activating directives
- in <CODE>access.conf</CODE>):</P>
-<PRE>
- LoadModule status_module modules/ApacheModuleStatus.dll
-</PRE>
- <P>Information on <A HREF="mod/mod_so.html#creating">creating loadable
- modules</A> is also available.</P>
- <LI><P>Apache can also load ISAPI Extensions (<EM>i.e.</EM>, Internet Server
- Applications), such as those used by Microsoft's IIS, and other
- Windows servers. <A HREF="mod/mod_isapi.html">More information
- is available.</A>
-</UL>
-
-<H2><A NAME="service">Running Apache for Windows as a Service</A></H2>
- <STRONG>Note: The -n option to specify a service name is only available
- with Apache 1.3.7 and later. Earlier versions of Apache only support
- the default service name 'Apache'.</STRONG>
-
-<P>
-
-You can install Apache as a Windows NT service as follows:
-
-<PRE>
- apache -i -n "service name"
-</PRE>
-
-To install a service to use a particular configuration, specify the
-configuration file when the service is installed:
-
-<PRE>
- apache -i -n "service name" -f "\my server\conf\my.conf"
-</PRE>
-
-To remove an Apache service, use
-
-<PRE>
- apache -u -n "service name"
-</PRE>
-
-The default "service name", if one is not specified, is "Apache".
-
-<P>
-
-Once a service is installed, you can use the <SAMP>-n</SAMP> option, in conjunction
-with other options, to refer to a service's configuration file. For example:<br>
-
-To test a service's configuration file:
-<PRE>
- apache -n "service name" -t
-</PRE>
-
-To start a console Apache using a service's configuration file:
-<PRE>
- apache -n "service name"
-</PRE>
-
-<H2><A NAME="cmdline">Running Apache for Windows from the Command Line</A></H2>
-
-The Start menu icons and the NT Service manager can provide a simple
-interface for administering Apache. But in some cases it is easier to
-work from the command line.
-
-<P>
-When working with Apache it is important to know how it will find the
-configuration files. You can specify a configuration file on the command line
-in two ways:
-
-<UL>
-<LI>-f specifies a path to a particular configuration file
-</UL>
-<PRE> apache -f "c:\my server\conf\my.conf"</PRE>
-<PRE> apache -f test\test.conf</PRE>
-<UL>
-<LI>-n specifies the configuration file of an installed Apache service (Apache 1.3.7 and later)
-</UL>
-<PRE> apache -n "service name"</PRE>
-
-In these cases, the proper ServerRoot should be set in the configuration file.
-
-<P>
-
-If you don't specify a configuration file name with -f or -n, Apache will
-use the file name compiled into the server, usually "conf/httpd.conf". Invoking
-Apache with the -V switch will display this value labeled as SERVER_CONFIG_FILE.
-Apache will then determine its ServerRoot by trying the following, in this order:
-
-<UL>
-<LI>A ServerRoot directive via a -C switch.
-<LI>The -d switch on the command line.
-<LI>Current working directory
-<LI>A registry entry, created if you did a binary install.
-<LI>The server root compiled into the server.
-</UL>
-
-<P>
-The server root compiled into the server is usually "/apache".
-invoking apache with the -V switch will display this value
-labeled as HTTPD_ROOT.
-
-<P>
-When invoked from the start menu, Apache is usually passed no arguments,
-so using the registry entry is the preferred technique for console Apache.
-
-<P>
-During a binary installation, a registry key will have
-been installed, for example:
-<PRE>
- HKEY_LOCAL_MACHINE\Software\Apache Group\Apache\1.3.4\ServerRoot
-</PRE>
-
-<P>
-This key is compiled into the server and can enable you to test
-new versions without affecting the current version. Of course
-you must take care not to install the new version on top of the
-old version in the file system.
-
-<P>
-If you did not do a binary install then Apache will in some
-scenarios complain that about the missing registry key. This
-warning can be ignored if it otherwise was able to find its
-configuration files.
-
-<P>
-The value of this key is the "ServerRoot" directory, containing the
-<SAMP>conf</SAMP> directory. When Apache starts it will read the
-<SAMP>httpd.conf</SAMP> file from this directory. If this file
-contains a <SAMP>ServerRoot</SAMP> directive which is different from
-the directory obtained from the registry key above, Apache will forget
-the registry key and use the directory from the configuration file.
-If you copy the Apache directory or configuration files to a new
-location it is vital that you update the <SAMP>ServerRoot</SAMP>
-directory in the <SAMP>httpd.conf</SAMP> file to the new location.
-
-<P>
-To run Apache from the command line as a console application, use the
-following command:
-
-<PRE>
- apache
-</PRE>
-
-Apache will execute, and will remain running until it is stopped by pressing
-control-C.
-
-<H2><A NAME="signalsrv">Signalling Service Apache when running</A></H2>
-
-On Windows NT, multiple instances of Apache can be run as services.
-Signal an Apache service to start, restart, or shutdown as follows:
-
-<PRE>
- apache -n "service name" -k start
- apache -n "service name" -k restart
- apache -n "service name" -k shutdown
-</PRE>
-
-In addition, you can use the native NT NET command to
-start and stop Apache services as follows:
-
-<PRE>
- NET START "service name"
- NET STOP "service name"
-</PRE>
-
-<H2><A NAME="signal">Signalling Console Apache when running</A></H2>
-
-On Windows 95, Apache runs as a console application. You can tell a
-running Apache to stop by opening another console window and running
-
-<PRE>
- apache -k shutdown
-</PRE>
-<BLOCKQUOTE>
- <STRONG>Note: This option is only available with Apache 1.3.3 and
- later. For earlier versions, you need to use Control-C in the
- Apache console window to shut down the server.</STRONG>
-</BLOCKQUOTE>
-
-<P>
-This should be used instead of pressing Control-C in the running
-Apache console window, because it lets Apache end any current
-transactions and cleanup gracefully.
-
-<P>
-
-You can also tell Apache to restart. This makes it re-read the
-configuration files. Any transactions in progress are allowed to
-complete without interruption. To restart Apache, run
-
-<PRE>
- apache -k restart
-</PRE>
-<BLOCKQUOTE>
- <STRONG>Note: This option is only available with Apache 1.3.3 and
- later. For earlier versions, you need to use Control-C in the
- Apache console window to shut down the server.</STRONG>
-</BLOCKQUOTE>
-
-<P>
-Note for people familiar with the Unix version of Apache: these
-commands provide a Windows equivalent to <CODE>kill -TERM
-<EM>pid</EM></CODE> and <CODE>kill -USR1 <EM>pid</EM></CODE>. The command
-line option used, <CODE>-k</CODE>, was chosen as a reminder of the
-"kill" command used on Unix.
-
-<H2><A NAME="comp">Compiling Apache for Windows</A></H2>
-
-<P>Compiling Apache requires Microsoft Visual C++ 5.0 to be properly
- installed. It is easiest to compile with the command-line tools
- (nmake, <EM>etc.</EM>..). Consult the VC++ manual to determine how to install
- them.</P>
-
-<P>First, unpack the Apache distribution into an appropriate
- directory. Open a command-line prompt, and change to the
- <CODE>src</CODE> subdirectory of the Apache distribution.</P>
-
-<P>The master Apache makefile instructions are contained in the
- <CODE>Makefile.nt</CODE> file. To compile Apache on Windows NT, simply
- use one of the following commands:
-<UL>
-<LI><CODE>nmake /f Makefile.nt _apacher</CODE> (release build)
-<LI><CODE>nmake /f Makefile.nt _apached</CODE> (debug build)
-</UL>
-
-<P><em>(1.3.4 and later)</em> To compile Apache on Windows 95, use one of
-<UL>
-<LI><CODE>nmake /f Makefile_win32.txt</CODE> (release build)
-<LI><CODE>nmake /f Makefile_win32_debug.txt</CODE> (debug build)
-</UL>
-
-<P>These will both compile Apache. The latter will include debugging
- information in the resulting files, making it easier to find bugs and
- track down problems.</P>
-
-<P>Apache can also be compiled using VC++'s Visual Studio development
- environment. Although compiling Apache in this manner is not as
- simple, it makes it possible to easily modify the Apache source, or
- to compile Apache if the command-line tools are not installed.
- Project files (<CODE>.DSP</CODE>) are included for each of the
- portions of Apache. To build Apache from the these projects files
- you will need to build the following projects <EM>in this order</EM>:
-
- <OL>
- <LI><CODE>os\win32\ApacheOS.dsp</CODE>
- <LI><CODE>regex\regex.dsp</CODE>
- <LI><CODE>ap\ap.dsp</CODE>
- <LI><CODE>main\gen_uri_delims.dsp</CODE>
- <LI><CODE>main\gen_test_char.dsp</CODE>
- <LI><CODE>ApacheCore.dsp</CODE>
- <LI><CODE>Apache.dsp</CODE>
- </OL>
-
- In addition, the <CODE>src\os\win32</CODE> subdirectory contains
- project files for the optional modules (see below).</P>
-
-<P>Once Apache has been compiled, it needs to be installed in its server
- root directory. The default is the <CODE>\Apache</CODE>
- directory, on the current hard drive. </P>
-
-<P>To install the files into the <CODE>\Apache</CODE> directory
- automatically, use one the following nmake commands (see above):</P>
-<UL>
-<LI><CODE>nmake /f Makefile.nt installr INSTDIR=<EM>dir</EM></CODE>
- (for release build)
-<LI><CODE>nmake /f Makefile.nt installd INSTDIR=<EM>dir</EM></CODE>
- (for debug build)
-</UL>
-or, for Windows 95 (1.3.4 and later), use one of:
-<UL>
-<LI><CODE>nmake /f Makefile_win32.txt install INSTDIR=<EM>dir</EM></CODE>
- (for release build)
-<LI><CODE>nmake /f Makefile_win32_debug.txt install INSTDIR=<EM>dir</EM></CODE>
- (for debug build)
-</UL>
-
-The dir argument to INSTDIR gives the installation directory; it can
-be omitted if Apache is to be installed into <SAMP>\Apache</SAMP>.
-
-<P>This will install the following:</P>
-
-<UL>
- <LI><CODE><EM>dir</EM>\Apache.exe</CODE> - Apache executable
- <LI><CODE><EM>dir</EM>\ApacheCore.dll</CODE> - Main Apache shared library
- <LI><CODE><EM>dir</EM>\modules\ApacheModule*.dll</CODE> - Optional Apache
- modules (7 files)
- <LI><CODE><EM>dir</EM>\conf</CODE> - Empty configuration directory
- <LI><CODE><EM>dir</EM>\logs</CODE> - Empty logging directory
-</UL>
-
-<P>If you do not have nmake, or wish to install in a different directory,
- be sure to use a similar naming scheme.</P>
-
-<P>
-Before running the server you must fill out the conf directory.
-Copy the *.conf-dist-win from the distribution conf directory
-and rename *.conf. Edit the @@ServerRoot@@ entries to your
-actual server root (for example "C:\apache"). Copy over
-the conf/magic and conf/mime.types files as well.
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
-
diff --git a/docs/manual/sections.html.en b/docs/manual/sections.html.en
deleted file mode 100644
index 88f3329408..0000000000
--- a/docs/manual/sections.html.en
+++ /dev/null
@@ -1,170 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML><HEAD>
-<TITLE>How Directory, Location and Files sections work</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">How Directory, Location and Files sections work</H1>
-
-The sections <A
-HREF="mod/core.html#directory"><CODE>&lt;Directory&gt;</CODE></A>, <A
-HREF="mod/core.html#location"><CODE>&lt;Location&gt;</CODE></A> and <A
-HREF="mod/core.html#files"><CODE>&lt;Files&gt;</CODE></A> can contain
-directives which only apply to specified directories, URLs or files
-respectively. Also htaccess files can be used inside a directory to
-apply directives to that directory. This document explains how these
-different sections differ and how they relate to each other when
-Apache decides which directives apply for a particular directory or
-request URL.
-
-<H2>Directives allowed in the sections</H2>
-
-Everything that is syntactically allowed in
-<CODE>&lt;Directory&gt;</CODE> is also allowed in
-<CODE>&lt;Location&gt;</CODE> (except a sub-<CODE>&lt;Files&gt;</CODE>
-section). Semantically however some things, and the most
-notable are <CODE>AllowOverride</CODE> and the two options
-<CODE>FollowSymLinks</CODE> and <CODE>SymLinksIfOwnerMatch</CODE>,
-make no sense in <CODE>&lt;Location&gt;</CODE>,
-<CODE>&lt;LocationMatch&gt;</CODE> or <CODE>&lt;DirectoryMatch&gt;</CODE>.
-The same for <CODE>&lt;Files&gt;</CODE> -- syntactically everything
-is fine, but semantically some things are different.
-
-<H2>How the sections are merged</H2>
-
-The order of merging is:
-
-<OL>
-
-<LI>
-
- <CODE>&lt;Directory&gt;</CODE> (except regular expressions) and
- .htaccess done simultaneously (with .htaccess overriding
- <CODE>&lt;Directory&gt;</CODE>)
-
-</LI>
-
-<LI>
- <CODE>&lt;DirectoryMatch&gt;</CODE>, and
- <CODE>&lt;Directory&gt;</CODE> with regular expressions
-
-</LI>
-
- <LI><CODE>&lt;Files&gt;</CODE> and <CODE>&lt;FilesMatch&gt;</CODE> done
- simultaneously
- </LI>
-
- <LI><CODE>&lt;Location&gt;</CODE> and <CODE>&lt;LocationMatch&gt;</CODE> done
- simultaneously
- </LI>
-
-</OL>
-
-Apart from <CODE>&lt;Directory&gt;</CODE>, each group is processed in
-the order that they appear in the configuration
-files. <CODE>&lt;Directory&gt;</CODE> (group 1 above) is processed in
-the order shortest directory component to longest. If multiple
-<CODE>&lt;Directory&gt;</CODE> sections apply to the same directory
-they they are processed in the configuration file order. The
-configuration files are read in the order httpd.conf, srm.conf and
-access.conf. Configurations included via the <CODE>Include</CODE>
-directive will be treated as if they where inside the including file
-at the location of the <CODE>Include</CODE> directive.
-
-<P>
-
-Sections inside <CODE>&lt;VirtualHost&gt;</CODE> sections are applied
-<EM>after</EM> the corresponding sections outside the virtual host
-definition. This allows virtual hosts to override the main server
-configuration. (Note: this only works correctly from 1.2.2 and 1.3a2
-onwards. Before those releases sections inside virtual hosts were
-applied <EM>before</EM> the main server).
-
-<H2>Notes about using sections</H2>
-
-The general guidelines are:
-
-<P>
-
-<UL>
-<LI>
- If you are attempting to match objects at the filesystem level
- then you must use <CODE>&lt;Directory&gt;</CODE> and/or
- <CODE>&lt;Files&gt;</CODE>.
-</LI>
-
-<LI>
- If you are attempting to match objects at the URL level then you
- must use <CODE>&lt;Location&gt;</CODE>
-</LI>
-</UL>
-
-But a notable exception is:
-
-<UL>
-<LI>
- proxy control is done via <CODE>&lt;Directory&gt;</CODE>. This is
- a legacy mistake because the proxy existed prior to
- <CODE>&lt;Location&gt;</CODE>. A future version of the config
- language should probably switch this to
- <CODE>&lt;Location&gt;</CODE>.
-</LI>
-</UL>
-
-<P>
-Note about .htaccess parsing:
-</P>
-<UL>
-<LI>
- Modifying .htaccess parsing during Location doesn't do
- anything because .htaccess parsing has already occurred.
-</UL>
-
-<P>
-<CODE>&lt;Location&gt;</CODE> and symbolic links:
-</P>
-<UL>
-<LI>
- It is not possible to use "<CODE>Options FollowSymLinks</CODE>"
- or "<CODE>Options SymLinksIfOwnerMatch</CODE>" inside a
- <CODE>&lt;Location&gt;</CODE>, <CODE>&lt;LocationMatch&gt;</CODE>
- or <CODE>&lt;DirectoryMatch&gt;</CODE> section
- (the options are simply ignored).
- Using the options in question is only possible inside a
- <CODE>&lt;Directory&gt;</CODE> section (or a <CODE>.htaccess</CODE> file).
-</UL>
-
-<P>
-<CODE>&lt;Files&gt;</CODE> and <CODE>Options</CODE>:
-</P>
-<UL>
-<LI>
- Apache won't check for it, but using an <CODE>Options</CODE>
- directive inside a <CODE>&lt;Files&gt;</CODE> section has no effect.
-</UL>
-
-<P>
-Another note:
-</P>
-
-<UL>
-<LI>
- There is actually a
- <CODE>&lt;Location&gt;</CODE>/<CODE>&lt;LocationMatch&gt;</CODE>
- sequence performed just before the name translation phase (where
- <CODE>Aliases</CODE> and <CODE>DocumentRoots</CODE> are used to
- map URLs to filenames). The results of this sequence are
- completely thrown away after the translation has completed.
-</LI>
-</UL>
-
-<!--#include virtual="footer.html" -->
-</BODY></HTML>
diff --git a/docs/manual/stopping.html.en b/docs/manual/stopping.html.en
deleted file mode 100644
index 783d1c0250..0000000000
--- a/docs/manual/stopping.html.en
+++ /dev/null
@@ -1,183 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Stopping and Restarting Apache</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Stopping and Restarting Apache</H1>
-
-<P>This document covers stopping and restarting Apache on Unix
-only. Windows users should see <A HREF="windows.html#signal">Signalling
-Apache when running</A>.</P>
-
-<P>You will notice many <CODE>httpd</CODE> executables running on your system,
-but you should not send signals to any of them except the parent, whose
-pid is in the <A HREF="mod/core.html#pidfile">PidFile</A>. That is to
-say you shouldn't ever need to send signals to any process except the
-parent. There are three signals that you can send the parent:
-<CODE>TERM</CODE>, <CODE>HUP</CODE>, and <CODE>USR1</CODE>, which will
-be described in a moment.
-
-<P>To send a signal to the parent you should issue a command such as:
-<BLOCKQUOTE><PRE>
- kill -TERM `cat /usr/local/apache/logs/httpd.pid`
-</PRE></BLOCKQUOTE>
-
-You can read about its progress by issuing:
-
-<BLOCKQUOTE><PRE>
- tail -f /usr/local/apache/logs/error_log
-</PRE></BLOCKQUOTE>
-
-Modify those examples to match your
-<A HREF="mod/core.html#serverroot">ServerRoot</A> and
-<A HREF="mod/core.html#pidfile">PidFile</A> settings.
-
-<P>As of Apache 1.3 we provide a script <CODE>src/support/apachectl</CODE>
-which can be used to start, stop, and restart Apache. It may need a
-little customization for your system, see the comments at the top of
-the script.
-
-<H3>TERM Signal: stop now</H3>
-
-<P>Sending the <CODE>TERM</CODE> signal to the parent causes it to
-immediately attempt to kill off all of its children. It may take it
-several seconds to complete killing off its children. Then the
-parent itself exits. Any requests in progress are terminated, and no
-further requests are served.
-
-<H3>HUP Signal: restart now</H3>
-
-<P>Sending the <CODE>HUP</CODE> signal to the parent causes it to kill off
-its children like in <CODE>TERM</CODE> but the parent doesn't exit. It
-re-reads its configuration files, and re-opens any log files.
-Then it spawns a new set of children and continues
-serving hits.
-
-<P>Users of the
-<A HREF="mod/mod_status.html">status module</A>
-will notice that the server statistics are
-set to zero when a <CODE>HUP</CODE> is sent.
-
-<P><STRONG>Note:</STRONG> If your configuration file has errors in it when
-you issue a
-restart then your parent will not restart, it will exit with an error.
-See below for a method of avoiding this.
-
-<H3>USR1 Signal: graceful restart</H3>
-
-<P><STRONG>Note:</STRONG> prior to release 1.2b9 this code is quite unstable
-and shouldn't be used at all.
-
-<P>The <CODE>USR1</CODE> signal causes the parent process to <EM>advise</EM>
-the children to exit after their current request (or to exit immediately
-if they're not serving anything). The parent re-reads its configuration
-files and re-opens its log files. As each child dies off the parent
-replaces it with a child from the new <EM>generation</EM> of the
-configuration, which begins serving new requests immediately.
-
-<P>This code is designed to always respect the
-<A HREF="mod/core.html#maxclients">MaxClients</A>,
-<A HREF="mod/core.html#minspareservers">MinSpareServers</A>,
-and <A HREF="mod/core.html#maxspareservers">MaxSpareServers</A> settings.
-Furthermore, it respects <A HREF="mod/core.html#startservers">StartServers</A>
-in the following manner: if after one second at least StartServers new
-children have not been created, then create enough to pick up the slack.
-This is to say that the code tries to maintain both the number of children
-appropriate for the current load on the server, and respect your wishes
-with the StartServers parameter.
-
-<P>Users of the
-<A HREF="mod/mod_status.html">status module</A>
-will notice that the server statistics
-are <STRONG>not</STRONG> set to zero when a <CODE>USR1</CODE> is sent. The
-code
-was written to both minimize the time in which the server is unable to serve
-new requests (they will be queued up by the operating system, so they're
-not lost in any event) and to respect your tuning parameters. In order
-to do this it has to keep the <EM>scoreboard</EM> used to keep track
-of all children across generations.
-
-<P>The status module will also use a <CODE>G</CODE> to indicate those
-children which are still serving requests started before the graceful
-restart was given.
-
-<P>At present there is no way for a log rotation script using
-<CODE>USR1</CODE> to know for certain that all children writing the
-pre-restart log have finished. We suggest that you use a suitable delay
-after sending the <CODE>USR1</CODE> signal before you do anything with the
-old log. For example if most of your hits take less than 10 minutes to
-complete for users on low bandwidth links then you could wait 15 minutes
-before doing anything with the old log.
-
-<P><STRONG>Note:</STRONG> If your configuration file has errors in it when
-you issue a
-restart then your parent will not restart, it will exit with an error.
-In the case of graceful
-restarts it will also leave children running when it exits. (These are
-the children which are "gracefully exiting" by handling their last request.)
-This will cause problems if you attempt to restart the server -- it will
-not be able to bind to its listening ports. Before doing a restart, you
-can check the syntax of the configuration files with the <CODE>-t</CODE>
-command line argument (see <A HREF="invoking.html">Starting
-Apache</A>). This still will not guarantee that the server will restart
-correctly. To check the semantics of the configuration files as well
-as the syntax, you can try starting httpd as a non-root user. If
-there are no errors it will attempt to open its sockets and logs and
-fail because it's not root (or because the currently running httpd
-already has those ports bound). If it fails for any other reason then
-it's probably a config file error and the error should be fixed before
-issuing the graceful restart.
-
-
-<H3>Appendix: signals and race conditions</H3>
-
-<P>Prior to Apache 1.2b9 there were several <EM>race conditions</EM>
-involving the restart and die signals (a simple description of race
-condition is: a time-sensitive problem, as in if something happens at just
-the wrong time it won't behave as expected). For those architectures that
-have the "right" feature set we have eliminated as many as we can.
-But it should be noted that there still do exist race conditions on
-certain architectures.
-
-<P>Architectures that use an on disk
-<A HREF="mod/core.html#scoreboardfile">ScoreBoardFile</A>
-have the potential to corrupt their scoreboards. This can result in
-the "bind: Address already in use" (after <CODE>HUP</CODE>) or
-"long lost child came home!" (after <CODE>USR1</CODE>). The former is
-a fatal error, while the latter just causes the server to lose a scoreboard
-slot. So it might be advisable to use graceful restarts, with
-an occasional hard restart. These problems are very difficult to work
-around, but fortunately most architectures do not require a scoreboard file.
-See the ScoreBoardFile documentation for a method to determine if your
-architecture uses it.
-
-<P><CODE>NEXT</CODE> and <CODE>MACHTEN</CODE> (68k only) have small race
-conditions
-which can cause a restart/die signal to be lost, but should not cause the
-server to do anything otherwise problematic.
-<!-- they don't have sigaction, or we're not using it -djg -->
-
-<P>All architectures have a small race condition in each child involving
-the second and subsequent requests on a persistent HTTP connection
-(KeepAlive). It may exit after reading the request line but before
-reading any of the request headers. There is a fix that was discovered
-too late to make 1.2. In theory this isn't an issue because the KeepAlive
-client has to expect these events because of network latencies and
-server timeouts. In practice it doesn't seem to affect anything either
--- in a test case the server was restarted twenty times per second and
-clients successfully browsed the site without getting broken images or
-empty documents.
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
diff --git a/docs/manual/suexec.html.en b/docs/manual/suexec.html.en
deleted file mode 100644
index 3d8623df04..0000000000
--- a/docs/manual/suexec.html.en
+++ /dev/null
@@ -1,518 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Apache suEXEC Support</TITLE>
-</HEAD>
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-
-<H1 ALIGN="CENTER">Apache suEXEC Support</H1>
-
-<P ALIGN="LEFT">
-<OL>
- <LI><BIG><STRONG>CONTENTS</STRONG></BIG></LI>
- <LI><A HREF="#what">What is suEXEC?</A></LI>
- <LI><A HREF="#before">Before we begin.</A></LI>
- <LI><A HREF="#model">suEXEC Security Model.</A></LI>
- <LI><A HREF="#install">Configuring &amp; Installing suEXEC</A></LI>
- <LI><A HREF="#enable">Enabling &amp; Disabling suEXEC</A></LI>
- <LI><A HREF="#usage">Using suEXEC</A></LI>
- <LI><A HREF="#debug">Debugging suEXEC</A></LI>
- <LI><A HREF="#jabberwock">Beware the Jabberwock: Warnings &amp;
- Examples</A></LI>
-</OL>
-</P>
-
-<H3><A NAME="what">What is suEXEC?</A></H3>
-<P ALIGN="LEFT">
-The <STRONG>suEXEC</STRONG> feature -- introduced in Apache 1.2 -- provides
-Apache users the ability to run <STRONG>CGI</STRONG> and <STRONG>SSI</STRONG>
-programs under user IDs different from the user ID of the calling web-server.
-Normally, when a CGI or SSI program executes, it runs as the same user who is
-running the web server.
-</P>
-
-<P ALIGN="LEFT">
-Used properly, this feature can reduce considerably the security risks involved
-with allowing users to develop and run private CGI or SSI programs. However,
-if suEXEC is improperly configured, it can cause any number of problems and
-possibly create new holes in your computer's security. If you aren't familiar
-with managing setuid root programs and the security issues they present, we
-highly recommend that you not consider using suEXEC.
-</P>
-
-<P ALIGN="CENTER">
-<STRONG><A HREF="suexec.html">BACK TO CONTENTS</A></STRONG>
-</P>
-
-<H3><A NAME="before">Before we begin.</A></H3>
-<P ALIGN="LEFT">
-Before jumping head-first into this document, you should be aware of the
-assumptions made on the part of the Apache Group and this document.
-</P>
-
-<P ALIGN="LEFT">
-First, it is assumed that you are using a UNIX derivate operating system that
-is capable of <STRONG>setuid</STRONG> and <STRONG>setgid</STRONG> operations.
-All command examples are given in this regard. Other platforms, if they are
-capable of supporting suEXEC, may differ in their configuration.
-</P>
-
-<P ALIGN="LEFT">
-Second, it is assumed you are familiar with some basic concepts of your
-computer's security and its administration. This involves an understanding
-of <STRONG>setuid/setgid</STRONG> operations and the various effects they
-may have on your system and its level of security.
-</P>
-
-<P ALIGN="LEFT">
-Third, it is assumed that you are using an <STRONG>unmodified</STRONG>
-version of suEXEC code. All code for suEXEC has been carefully scrutinized and
-tested by the developers as well as numerous beta testers. Every precaution
-has been taken to ensure a simple yet solidly safe base of code. Altering this
-code can cause unexpected problems and new security risks. It is
-<STRONG>highly</STRONG> recommended you not alter the suEXEC code unless you
-are well versed in the particulars of security programming and are willing to
-share your work with the Apache Group for consideration.
-</P>
-
-<P ALIGN="LEFT">
-Fourth, and last, it has been the decision of the Apache Group to
-<STRONG>NOT</STRONG> make suEXEC part of the default installation of Apache.
-To this end, suEXEC configuration requires of the administrator careful
-attention to details. After due consideration has been given to the various
-settings for suEXEC, the administrator may install suEXEC through normal
-installation methods. The values for these settings need to be carefully
-determined and specified by the administrator to properly maintain system
-security during the use of suEXEC functionality. It is through this detailed
-process that the Apache Group hopes to limit suEXEC installation only to those
-who are careful and determined enough to use it.
-</P>
-
-<P ALIGN="LEFT">
-Still with us? Yes? Good. Let's move on!
-</P>
-
-<P ALIGN="CENTER">
-<STRONG><A HREF="suexec.html">BACK TO CONTENTS</A></STRONG>
-</P>
-
-<H3><A NAME="model">suEXEC Security Model</A></H3>
-<P ALIGN="LEFT">
-Before we begin configuring and installing suEXEC, we will first discuss
-the security model you are about to implement. By doing so, you may
-better understand what exactly is going on inside suEXEC and what precautions
-are taken to ensure your system's security.
-</P>
-
-<P ALIGN="LEFT">
-<STRONG>suEXEC</STRONG> is based on a setuid "wrapper" program that is
-called by the main Apache web server. This wrapper is called when an HTTP
-request is made for a CGI or SSI program that the administrator has designated
-to run as a userid other than that of the main server. When such a request
-is made, Apache provides the suEXEC wrapper with the program's name and the
-user and group IDs under which the program is to execute.
-</P>
-
-<P ALIGN="LEFT">
-The wrapper then employs the following process to determine success or
-failure -- if any one of these conditions fail, the program logs the failure
-and exits with an error, otherwise it will continue:
-<OL>
- <LI><STRONG>Was the wrapper called with the proper number of
- arguments?</STRONG>
- <BLOCKQUOTE>
- The wrapper will only execute if it is given the proper number of arguments.
- The proper argument format is known to the Apache web server. If the
- wrapper
- is not receiving the proper number of arguments, it is either being hacked,
- or
- there is something wrong with the suEXEC portion of your Apache binary.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the user executing this wrapper a valid user of this
- system?</STRONG>
- <BLOCKQUOTE>
- This is to ensure that the user executing the wrapper is truly a user of the
- system.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is this valid user allowed to run the wrapper?</STRONG>
- <BLOCKQUOTE>
- Is this user the user allowed to run this wrapper? Only one user (the
- Apache user) is allowed to execute this program.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Does the target program have an unsafe hierarchical
- reference?</STRONG>
- <BLOCKQUOTE>
- Does the target program contain a leading '/' or have a '..' backreference?
- These are not allowed; the target program must reside within the Apache
- webspace.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the target user name valid?</STRONG>
- <BLOCKQUOTE>
- Does the target user exist?
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the target group name valid?</STRONG>
- <BLOCKQUOTE>
- Does the target group exist?
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the target user <EM>NOT</EM> superuser?</STRONG>
- <BLOCKQUOTE>
- Presently, suEXEC does not allow 'root' to execute CGI/SSI programs.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the target userid <EM>ABOVE</EM> the minimum ID
- number?</STRONG>
- <BLOCKQUOTE>
- The minimum user ID number is specified during configuration. This allows
- you
- to set the lowest possible userid that will be allowed to execute CGI/SSI
- programs. This is useful to block out "system" accounts.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the target group <EM>NOT</EM> the superuser group?</STRONG>
- <BLOCKQUOTE>
- Presently, suEXEC does not allow the 'root' group to execute CGI/SSI
- programs.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the target groupid <EM>ABOVE</EM> the minimum ID
- number?</STRONG>
- <BLOCKQUOTE>
- The minimum group ID number is specified during configuration. This allows
- you
- to set the lowest possible groupid that will be allowed to execute CGI/SSI
- programs. This is useful to block out "system" groups.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Can the wrapper successfully become the target user and
- group?</STRONG>
- <BLOCKQUOTE>
- Here is where the program becomes the target user and group via setuid and
- setgid
- calls. The group access list is also initialized with all of the groups
- of which
- the user is a member.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Does the directory in which the program resides exist?</STRONG>
- <BLOCKQUOTE>
- If it doesn't exist, it can't very well contain files.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the directory within the Apache webspace?</STRONG>
- <BLOCKQUOTE>
- If the request is for a regular portion of the server, is the requested
- directory
- within the server's document root? If the request is for a UserDir, is
- the requested
- directory within the user's document root?
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the directory <EM>NOT</EM> writable by anyone else?</STRONG>
- <BLOCKQUOTE>
- We don't want to open up the directory to others; only the owner user
- may be able
- to alter this directories contents.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Does the target program exist?</STRONG>
- <BLOCKQUOTE>
- If it doesn't exists, it can't very well be executed.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the target program <EM>NOT</EM> writable by anyone
- else?</STRONG>
- <BLOCKQUOTE>
- We don't want to give anyone other than the owner the ability to
- change the program.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the target program <EM>NOT</EM> setuid or setgid?</STRONG>
- <BLOCKQUOTE>
- We do not want to execute programs that will then change our UID/GID again.
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Is the target user/group the same as the program's
- user/group?</STRONG>
- <BLOCKQUOTE>
- Is the user the owner of the file?
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Can we successfully clean the process environment to
- ensure safe operations?</STRONG>
- <BLOCKQUOTE>
- suEXEC cleans the process' environment by establishing a safe
- execution PATH (defined
- during configuration), as well as only passing through those
- variables whose names
- are listed in the safe environment list (also created during
- configuration).
- </BLOCKQUOTE>
- </LI>
- <LI><STRONG>Can we successfully become the target program and
- execute?</STRONG>
- <BLOCKQUOTE>
- Here is where suEXEC ends and the target program begins.
- </BLOCKQUOTE>
- </LI>
-</OL>
-</P>
-
-<P ALIGN="LEFT">
-This is the standard operation of the the suEXEC wrapper's security model.
-It is somewhat stringent and can impose new limitations and guidelines for
-CGI/SSI design, but it was developed carefully step-by-step with security
-in mind.
-</P>
-
-<P ALIGN="LEFT">
-For more information as to how this security model can limit your possibilities
-in regards to server configuration, as well as what security risks can be
-avoided with a proper suEXEC setup, see the
-<A HREF="#jabberwock">"Beware the Jabberwock"</A>
-section of this document.
-</P>
-
-<P ALIGN="CENTER">
-<STRONG><A HREF="suexec.html">BACK TO CONTENTS</A></STRONG>
-</P>
-
-<H3><A NAME="install">Configuring &amp; Installing suEXEC</A></H3>
-<P ALIGN="LEFT">
-Here's where we begin the fun. If you use Apache 1.2 or prefer to configure
-Apache 1.3 with the "<CODE>src/Configure</CODE>" script you have to edit
-the suEXEC header file and install the binary in its proper location
-manually. This procedure is described in an
-<A HREF="suexec_1_2.html">extra document</A>.
-The following sections describe the configuration and installation
-for Apache 1.3 with the AutoConf-style interface (APACI).
-</P>
-
-<P ALIGN="LEFT">
-<STRONG>APACI's suEXEC configuration options</STRONG><BR>
-<DL>
-<DT><CODE>--enable-suexec</CODE>
-<DD>This option enables the suEXEC feature which is never installed or
- activated by default. At least one --suexec-xxxxx option has to be
- provided together with the --enable-suexec option to let APACI
- accept your request for using the suEXEC feature.
-<DT><CODE>--suexec-caller=<EM>UID</EM></CODE>
-<DD>The <A HREF="mod/core.html#user">username</A> under which
- Apache normally runs.
- This is the only user allowed to execute this program.
-<DT><CODE>--suexec-docroot=<EM>DIR</EM></CODE>
-<DD>Define as the DocumentRoot set for Apache.
- This will be the only hierarchy (aside from UserDirs)
- that can be used for suEXEC behavior.
- The default directory is the --datadir value with
- the suffix "/htdocs", <EM>e.g.</EM> if you configure with
- "<CODE>--datadir=/home/apache</CODE>" the directory
- "/home/apache/htdocs" is used as document root for
- the suEXEC wrapper.
-<DT><CODE>--suexec-logfile=<EM>FILE</EM></CODE>
-<DD>This defines the filename to which all suEXEC transactions and
- errors are logged (useful for auditing and debugging purposes).
- By default the logfile is named "suexec_log" and located in your
- standard logfile directory (--logfiledir).
-<DT><CODE>--suexec-userdir=<EM>DIR</EM></CODE>
-<DD>Define to be the subdirectory under users'
- home directories where suEXEC access should
- be allowed. All executables under this directory
- will be executable by suEXEC as the user so
- they should be "safe" programs. If you are
- using a "simple" UserDir directive (ie. one
- without a "*" in it) this should be set to
- the same value. suEXEC will not work properly
- in cases where the UserDir directive points to
- a location that is not the same as the user's
- home directory as referenced in the passwd file.
- Default value is "public_html".
- <BR>
- If you have virtual hosts with a different
- UserDir for each, you will need to define them to
- all reside in one parent directory; then name that
- parent directory here. <STRONG>If this is not defined
- properly, "~userdir" cgi requests will not work!</STRONG>
-<DT><CODE>--suexec-uidmin=<EM>UID</EM></CODE>
-<DD>Define this as the lowest UID allowed to be a target user
- for suEXEC. For most systems, 500 or 100 is common.
- Default value is 100.
-<DT><CODE>--suexec-gidmin=<EM>GID</EM></CODE>
-<DD>Define this as the lowest GID allowed to be a target group
- for suEXEC. For most systems, 100 is common and therefore
- used as default value.
-<DT><CODE>--suexec-safepath=<EM>PATH</EM></CODE>
-<DD>Define a safe PATH environment to pass to CGI executables.
- Default value is "/usr/local/bin:/usr/bin:/bin".
-</DL>
-</P>
-
-<P ALIGN="LEFT">
-<STRONG>Checking your suEXEC setup</STRONG><BR>
-Before you compile and install the suEXEC wrapper you can check
-the configuration with the --layout option.
-<BR>
-Example output:
-<PRE>
- suEXEC setup:
- suexec binary: /usr/local/apache/sbin/suexec
- document root: /usr/local/apache/share/htdocs
- userdir suffix: public_html
- logfile: /usr/local/apache/var/log/suexec_log
- safe path: /usr/local/bin:/usr/bin:/bin
- caller ID: www
- minimum user ID: 100
- minimum group ID: 100
-</PRE>
-</P>
-
-<P ALIGN="LEFT">
-<STRONG>Compiling and installing the suEXEC wrapper</STRONG><BR>
-If you have enabled the suEXEC feature with the --enable-suexec option
-the suexec binary (together with Apache itself) is automatically built
-if you execute the command "make".
-<BR>
-After all components have been built you can execute the command
-"make install" to install them.
-The binary image "suexec" is installed in the directory defined by
-the --sbindir option. Default location is "/usr/local/apache/sbin/suexec".
-<BR>
-Please note that you need <STRONG><EM>root privileges</EM></STRONG> for
-the installation step. In order for the wrapper to set the user ID, it
-must be installed as owner <CODE><EM>root</EM></CODE> and must have the
-setuserid execution bit set for file modes.
-</P>
-
-<P ALIGN="CENTER">
-<STRONG><A HREF="suexec.html">BACK TO CONTENTS</A></STRONG>
-</P>
-
-<H3><A NAME="enable">Enabling &amp; Disabling suEXEC</A></H3>
-<P ALIGN="LEFT">
-Upon startup of Apache, it looks for the file "suexec" in the "sbin"
-directory (default is "/usr/local/apache/sbin/suexec").
-If Apache finds a properly configured suEXEC wrapper, it will print
-the following message to the error log:
-<PRE>
- [notice] suEXEC mechanism enabled (wrapper: <EM>/path/to/suexec</EM>)
-</PRE>
-If you don't see this message at server startup, the server is most
-likely not finding the wrapper program where it expects it, or the
-executable is not installed <EM>setuid root</EM>.
-<BR>
-If you want to enable the suEXEC mechanism for the first time
-and an Apache server is already running you must kill and restart Apache.
-Restarting it with a simple HUP or USR1 signal will not be enough.
-<BR>
-If you want to disable suEXEC you should kill and restart Apache after
-you have removed the "suexec" file.
-</P>
-
-<P ALIGN="CENTER">
-<STRONG><A HREF="suexec.html">BACK TO CONTENTS</A></STRONG>
-</P>
-
-<H3><A NAME="usage">Using suEXEC</A></H3>
-<P ALIGN="LEFT">
-<STRONG>Virtual Hosts:</STRONG><BR>
-One way to use the suEXEC wrapper is through the
-<A HREF="mod/core.html#user">User</A> and
-<A HREF="mod/core.html#group">Group</A> directives in
-<A HREF="mod/core.html#virtualhost">VirtualHost</A>
-definitions. By setting these directives to values different from the
-main server user ID, all requests for CGI resources will be executed as
-the <EM>User</EM> and <EM>Group</EM> defined for that
-<CODE>&lt;VirtualHost&gt;</CODE>. If only one or
-neither of these directives are specified for a
-<CODE>&lt;VirtualHost&gt;</CODE> then the main
-server userid is assumed.
-<P>
-<STRONG>User directories:</STRONG><BR>
-The suEXEC wrapper can also be used to execute CGI programs as
-the user to which the request is being directed. This is accomplished by
-using the "<STRONG><CODE>~</CODE></STRONG>" character prefixing the user
-ID for whom execution is desired.
-The only requirement needed for this feature to work is for CGI
-execution to be enabled for the user and that the script must meet the
-scrutiny of the <A HREF="#model">security checks</A> above.
-
-<P ALIGN="CENTER">
-<STRONG><A HREF="suexec.html">BACK TO CONTENTS</A></STRONG>
-</P>
-
-<H3><A NAME="debug">Debugging suEXEC</A></H3>
-<P ALIGN="LEFT">
-The suEXEC wrapper will write log information to the file defined
-with the --suexec-logfile option as indicated above. If you feel you have
-configured and installed the wrapper properly, have a look at this log
-and the error_log for the server to see where you may have gone astray.
-</P>
-
-<P ALIGN="CENTER">
-<STRONG><A HREF="suexec.html">BACK TO CONTENTS</A></STRONG>
-</P>
-
-<H3>
-<A NAME="jabberwock">Beware the Jabberwock: Warnings &amp; Examples</A>
-</H3>
-<P ALIGN="LEFT">
-<STRONG>NOTE!</STRONG> This section may not be complete. For the latest
-revision of this section of the documentation, see the Apache Group's
-<A HREF="http://www.apache.org/docs/suexec.html">Online Documentation</A>
-version.
-</P>
-
-<P ALIGN="LEFT">
-There are a few points of interest regarding the wrapper that can cause
-limitations on server setup. Please review these before submitting any
-"bugs" regarding suEXEC.
-<UL>
- <LI><STRONG>suEXEC Points Of Interest</STRONG></LI>
- <LI>Hierarchy limitations
- <BLOCKQUOTE>
- For security and efficiency reasons, all suexec requests must
- remain within either a top-level document root for virtual
- host requests, or one top-level personal document root for
- userdir requests. For example, if you have four VirtualHosts
- configured, you would need to structure all of your VHosts'
- document roots off of one main Apache document hierarchy to
- take advantage of suEXEC for VirtualHosts. (Example forthcoming.)
- </BLOCKQUOTE>
- </LI>
- <LI>suEXEC's PATH environment variable
- <BLOCKQUOTE>
- This can be a dangerous thing to change. Make certain every
- path you include in this define is a <STRONG>trusted</STRONG>
- directory. You don't want to open people up to having someone
- from across the world running a trojan horse on them.
- </BLOCKQUOTE>
- </LI>
- <LI>Altering the suEXEC code
- <BLOCKQUOTE>
- Again, this can cause <STRONG>Big Trouble</STRONG> if you try
- this without knowing what you are doing. Stay away from it
- if at all possible.
- </BLOCKQUOTE>
- </LI>
-</UL>
-
-<P ALIGN="CENTER">
-<STRONG><A HREF="suexec.html">BACK TO CONTENTS</A></STRONG>
-</P>
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
diff --git a/docs/manual/vhosts/fd-limits.html.en b/docs/manual/vhosts/fd-limits.html.en
deleted file mode 100644
index 6b9d0f93c4..0000000000
--- a/docs/manual/vhosts/fd-limits.html.en
+++ /dev/null
@@ -1,59 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Apache Server Virtual Host Support</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">File Descriptor Limits</H1>
-
-<P>
-When using a large number of Virtual Hosts, Apache may run out of available
-file descriptors (sometimes called <CITE>file handles</CITE> if each Virtual
-Host specifies different log files.
-The total number of file descriptors used by Apache is one for each distinct
-error log file, one for every other log file directive, plus 10-20 for
-internal use. Unix operating systems limit the number of file descriptors that
-may be used by a process; the limit is typically 64, and may usually be
-increased up to a large hard-limit.
-<P>
-Although Apache attempts to increase the limit as required, this
-may not work if:
-<OL>
-<LI>Your system does not provide the setrlimit() system call.
-<LI>The setrlimit(RLIMIT_NOFILE) call does not function on your system
- (such as Solaris 2.3)
-<LI>The number of file descriptors required exceeds the hard limit.
-<LI>Your system imposes other limits on file descriptors, such as a limit
-on stdio streams only using file descriptors below 256. (Solaris 2)
-</OL>
-
-In the event of problems you can:
-<UL>
-<LI>Reduce the number of log files; don't specify log files in the VirtualHost
-sections, but only log to the main log files.
-<LI>If you system falls into 1 or 2 (above), then increase the file descriptor
-limit before starting Apache, using a script like
-<BLOCKQUOTE><CODE>
-#!/bin/sh <BR>
-ulimit -S -n 100 <BR>
-exec httpd</CODE></BLOCKQUOTE>
-</UL>
-<P>
-Please see the
-<A HREF="../misc/descriptors.html">Descriptors and Apache</A>
-document containing further details about file descriptor problems and how
-they can be solved on your operating system.
-</P>
-
-<!--#include virtual="footer.html" -->
-</BODY></HTML>
-
diff --git a/docs/manual/vhosts/index.html.en b/docs/manual/vhosts/index.html.en
deleted file mode 100644
index 06fcf1d16f..0000000000
--- a/docs/manual/vhosts/index.html.en
+++ /dev/null
@@ -1,65 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
-<HEAD>
-<TITLE>Apache Virtual Host documentation</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Apache Virtual Host documentation</H1>
-
-<P>The term <CITE>Virtual Host</CITE> refers to the practice of maintaining
-more than one server on one machine, as differentiated by their apparent
-hostname. For example, it is often desirable for companies sharing a
-web server to have their own domains, with web servers accessible as
-<SAMP>www.company1.com</SAMP> and <SAMP>www.company2.com</SAMP>,
-without requiring the user to know any extra path information.</P>
-
-<P>Apache was one of the first servers to support IP-based
-virtual hosts right out of the box. Versions 1.1 and later of
-Apache support both, IP-based and name-based virtual hosts (vhosts).
-The latter variant of virtual hosts is sometimes also called host-based or
-non-IP virtual hosts.</P>
-
-<P>Below is a list of documentation pages which explain all details
-of virtual host support in Apache version 1.3 and later.</P>
-
-<HR>
-
-<H2>Virtual Host Support</H2>
-
-<UL>
-<LI><A HREF="ip-based.html">IP-based Virtual Hosts</A>
-<LI><A HREF="name-based.html">Name-based Virtual Hosts</A>
-<LI><A HREF="examples.html">Virtual Host examples for common setups</A>
-<LI><A HREF="details.html">In-Depth Discussion of Virtual Host Matching</A>
-<LI><A HREF="fd-limits.html">File Descriptor Limits</A>
-<LI><A HREF="mass.html">Dynamically Configured Mass Virtual Hosting</A>
-</UL>
-
-<H2>Configuration directives</H2>
-
-<UL>
-<LI><A HREF="../mod/core.html#virtualhost">&lt;VirtualHost&gt;</A>
-<LI><A HREF="../mod/core.html#namevirtualhost">NameVirtualHost</A>
-<LI><A HREF="../mod/core.html#servername">ServerName</A>
-<LI><A HREF="../mod/core.html#serveralias">ServerAlias</A>
-<LI><A HREF="../mod/core.html#serverpath">ServerPath</A>
-</UL>
-
-<P>Folks trying to debug their virtual host configuration may find the
-Apache <CODE>-S</CODE> command line switch useful. It will dump out a
-description of how Apache parsed the configuration file. Careful
-examination of the IP addresses and server names may help uncover
-configuration mistakes.
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
diff --git a/docs/manual/vhosts/name-based.html.en b/docs/manual/vhosts/name-based.html.en
deleted file mode 100644
index 238cf5c721..0000000000
--- a/docs/manual/vhosts/name-based.html.en
+++ /dev/null
@@ -1,164 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML><HEAD>
-<TITLE>Apache name-based Virtual Hosts</TITLE>
-</HEAD>
-
-<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
-<BODY
- BGCOLOR="#FFFFFF"
- TEXT="#000000"
- LINK="#0000FF"
- VLINK="#000080"
- ALINK="#FF0000"
->
-<!--#include virtual="header.html" -->
-<H1 ALIGN="CENTER">Apache name-based Virtual Host Support</H1>
-
-<STRONG>See Also:</STRONG>
-<A HREF="ip-based.html">IP-based Virtual Host Support</A>
-
-<HR>
-
-<H2>Name-based vs. IP-based virtual hosts</H2>
-
-<P>While the approach with IP-based virtual hosts works very well,
-it is not the most elegant solution, because a dedicated IP address
-is needed for every virtual host and it is hard to implement on some
-machines. The <CODE>HTTP/1.1</CODE> protocol contains a method for the
-server to identify what name it is being addressed as. Apache 1.1 and
-later support this approach as well as the traditional
-IP-address-per-hostname method.</P>
-
-<P>The benefits of using the new name-based virtual host support is a
-practically unlimited number of servers, ease of configuration and use, and
-requires no additional hardware or software.
-The main disadvantage is that the client must support this part of the
-protocol. The latest versions of most browsers do, but there are still
-old browsers in use who do not. This can cause problems, although a possible
-solution is addressed below.</P>
-
-<H2>Using non-IP Virtual Hosts</H2>
-
-<P>Using the new virtual hosts is quite easy, and superficially looks
-like the old method. The notable difference between IP-based and
-name-based virtual host configuration is the
-<A HREF="../mod/core.html#namevirtualhost"><CODE>NameVirtualHost</CODE></A>
-directive which specifies an IP address that should be used as a
-target for name-based virtual hosts.</P>
-
-<P>For example, suppose that both <SAMP>www.domain.tld</SAMP> and
-<SAMP>www.otherdomain.tld</SAMP> point at the IP address
-<SAMP>111.22.33.44</SAMP>. Then you simply add to one of the Apache
-configuration files (most likely <CODE>httpd.conf</CODE> or
-<CODE>srm.conf</CODE>) code similar to the following:</P>
-
-
-
-<PRE>
- NameVirtualHost 111.22.33.44
-
- &lt;VirtualHost 111.22.33.44&gt;
- ServerName www.domain.tld
- DocumentRoot /www/domain
- &lt;/VirtualHost&gt;
-
- &lt;VirtualHost 111.22.33.44&gt;
- ServerName www.otherdomain.tld
- DocumentRoot /www/otherdomain
- &lt;/VirtualHost&gt;
-</PRE>
-
-<P>Of course, any additional directives can (and should) be placed
-into the <CODE>&lt;VirtualHost&gt;</CODE> section. To make this work,
-all that is needed is to make sure that the names
-<SAMP>www.domain.tld</SAMP> and <SAMP>www.otherdomain.tld</SAMP>
-are pointing to the IP address <SAMP>111.22.33.44</SAMP></P>
-
-<P>Note: When you specify an IP address in a <CODE>NameVirtualHost</CODE>
-directive then requests to that IP address will only ever be served
-by matching &lt;VirtualHost&gt;s. The "main server" will
-<STRONG>never</STRONG> be served from the specified IP address.
-If you start to use virtual hosts you should stop to use the "main server"
-as an independent server and rather use it as a place for
-configuration directives that are common for all your virtual hosts.
-In other words, you should add a &lt;VirtualHost&gt; section for
-<EM>every</EM> server (hostname) you want to maintain on your server.
-
-<P>Additionally, many servers may wish to be accessible by more than
-one name. For example, the example server might want to be accessible
-as <CODE>domain.tld</CODE>, or <CODE>www2.domain.tld</CODE>, assuming
-the IP addresses pointed to the same server. In fact, one might want it
-so that all addresses at <CODE>domain.tld</CODE> were picked up by the
-server. This is possible with the
-<A HREF="../mod/core.html#serveralias"><CODE>ServerAlias</CODE></A>
-directive, placed inside the &lt;VirtualHost&gt; section. For
-example:</P>
-
-<PRE>
- ServerAlias domain.tld *.domain.tld
-</PRE>
-
-<P>Note that you can use <CODE>*</CODE> and <CODE>?</CODE> as wild-card
-characters.</P>
-
-<P>You also might need <CODE>ServerAlias</CODE> if you are
-serving local users who do not always include the domain name.
-For example, if local users are
-familiar with typing "www" or "www.foobar" then you will need to add
-<CODE>ServerAlias www www.foobar</CODE>. It isn't possible for the
-server to know what domain the client uses for their name resolution
-because the client doesn't provide that information in the request.
-The <CODE>ServerAlias</CODE> directive is generally a way to have different
-hostnames pointing to the same virtual host.
-</P>
-
-<H2>Compatibility with Older Browsers</H2>
-
-<P>As mentioned earlier, there are still some clients in use who
-do not send the required data for the name-based virtual hosts to work
-properly. These clients will always be sent the pages from the
-first virtual host listed for that IP address (the
-<CITE>primary</CITE> name-based virtual host).</P>
-
-<P>There is a possible workaround with the
-<A HREF="../mod/core.html#serverpath"><CODE>ServerPath</CODE></A>
-directive, albeit a slightly cumbersome one:</P>
-
-<P>Example configuration:
-
-<PRE>
- NameVirtualHost 111.22.33.44
-
- &lt;VirtualHost 111.22.33.44&gt;
- ServerName www.domain.tld
- ServerPath /domain
- DocumentRoot /web/domain
- &lt;/VirtualHost&gt;
-</PRE>
-
-<P>What does this mean? It means that a request for any URI beginning
-with "<SAMP>/domain</SAMP>" will be served from the virtual host
-<SAMP>www.domain.tld</SAMP> This means that the pages can be accessed as
-<CODE>http://www.domain.tld/domain/</CODE> for all clients, although
-clients sending a <SAMP>Host:</SAMP> header can also access it as
-<CODE>http://www.domain.tld/</CODE>.</P>
-
-<P>In order to make this work, put a link on your primary virtual host's page
-to <SAMP>http://www.domain.tld/domain/</SAMP>
-Then, in the virtual host's pages, be sure to use either purely
-relative links (<EM>e.g.</EM>, "<SAMP>file.html</SAMP>" or
-"<SAMP>../icons/image.gif</SAMP>" or links containing the prefacing
-<SAMP>/domain/</SAMP>
-(<EM>e.g.</EM>, "<SAMP>http://www.domain.tld/domain/misc/file.html</SAMP>" or
-"<SAMP>/domain/misc/file.html</SAMP>").</P>
-
-<P>This requires a bit of
-discipline, but adherence to these guidelines will, for the most part,
-ensure that your pages will work with all browsers, new and old.</P>
-
-<P>See also: <A HREF="examples.html#serverpath">ServerPath configuration
-example</A></P>
-
-<!--#include virtual="footer.html" -->
-</BODY>
-</HTML>
diff --git a/emacs-style b/emacs-style
deleted file mode 100644
index 283b6f0255..0000000000
--- a/emacs-style
+++ /dev/null
@@ -1,10 +0,0 @@
-(add-hook 'c-mode-hook
- (function (lambda ()
- (c-set-offset 'inclass' ++)
- (c-set-offset 'defun-block-intro' ++)
- (c-set-offset 'statement-block-intro' ++)
- (c-set-offset 'substatement' ++)
- (c-set-offset 'brace-list-intro' ++)
- (c-set-offset 'statement-case-intro' ++)
- )))
-(setq c++-mode-hook c-mode-hook)
diff --git a/httpd.dsp b/httpd.dsp
deleted file mode 100644
index 2247eeb72f..0000000000
--- a/httpd.dsp
+++ /dev/null
@@ -1,413 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheCore" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheCore - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheCore.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheCore.mak" CFG="ApacheCore - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheCore - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheCore - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheCore - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\ApacheCo"
-# PROP BASE Intermediate_Dir ".\ApacheCo"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\CoreR"
-# PROP Intermediate_Dir ".\CoreR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I ".\include" /I ".\lib\apr\include" /I ".\os\win32" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "WIN32_LEAN_AND_MEAN" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 lib\apr\Release\aprlib.lib os\win32\ApacheOSR\ApacheOS.lib regex\release\regex.lib ap\Release\ap.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheCore - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\ApacheC0"
-# PROP BASE Intermediate_Dir ".\ApacheC0"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\CoreD"
-# PROP Intermediate_Dir ".\CoreD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I ".\include" /I ".\lib\apr\include" /I ".\os\win32" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "WIN32_LEAN_AND_MEAN" /FR /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 lib\apr\debug\aprlib.lib regex\debug\regex.lib os\win32\ApacheOSD\ApacheOS.lib ap\Debug\ap.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ws2_32.lib mswsock.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# SUBTRACT LINK32 /map
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheCore - Win32 Release"
-# Name "ApacheCore - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=.\ApacheCore.def
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\buff.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\buildmark.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_config.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_connection.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_core.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_log.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_main.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_protocol.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_request.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\http_vhost.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\iol_file.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\iol_socket.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\listen.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_access.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_actions.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_alias.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_asis.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_auth.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_autoindex.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_cgi.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_dir.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_env.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_imap.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_include.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_log_config.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_mime.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_negotiation.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_setenvif.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_so.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_userdir.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\modules.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\registry.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\rfc1413.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\service.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\util.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\util_date.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\util_md5.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\util_script.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\util_uri.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\util_win32.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\mpm\winnt\winnt.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\include\ap.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\ap_hooks.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\ap_iol.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\ap_listen.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\ap_md5.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\buff.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\conf.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\explain.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\fnmatch.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\hsregex.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_conf_globals.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_config.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_connection.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_core.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_log.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_main.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_protocol.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_request.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\http_vhost.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\httpd.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\iol_socket.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\standard\mod_mime.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\mpm\winnt\mpm_default.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\os.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\registry.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\rfc1413.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\os\win32\service.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\util_date.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\util_md5.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\util_script.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\include\util_uri.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\modules\mpm\winnt\winnt.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# Begin Group "Generated Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\main\test_char.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\main\uri_delims.h
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/include/.cvsignore b/include/.cvsignore
deleted file mode 100644
index 8132c4f7e9..0000000000
--- a/include/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-stamp-h*
-ap_config_auto.h*
diff --git a/include/.indent.pro b/include/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/include/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/include/ap_config.h b/include/ap_config.h
deleted file mode 100644
index 9569a6b679..0000000000
--- a/include/ap_config.h
+++ /dev/null
@@ -1,1480 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef AP_CONFIG_H
-#define AP_CONFIG_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "ap_ac_config.h" /* If we're using autoconf, go to the new
- ap_config.h replacement */
-#else /* HAVE_CONFIG_H */
-
-/*
- * ap_config.h: system-dependant #defines and includes...
- * See PORTING for a listing of what they mean
- */
-
-#include "ap_mmn.h" /* MODULE_MAGIC_NUMBER_ */
-
-/*
- * Support for platform dependent autogenerated defines
- */
-#ifndef WIN32
-#include "ap_config_auto.h"
-#else
-/* not available under WIN32, so provide important entries manually */
-#undef HAVE_UNISTD_H
-#endif
-
-/* Have to include sys/stat.h before ../os/win32/os.h so we can override
-stat() properly */
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-/* 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
-
-#ifdef WIN32
-#include "../os/win32/os.h"
-#else
-#include "os.h"
-#endif
-
-#if !defined(QNX) && !defined(MPE) && !defined(WIN32) && !defined(TPF)
-/* #include <sys/param.h> */
-#endif
-
-/* Define one of these according to your system. */
-#if defined(MINT)
-typedef int rlim_t;
-#define JMP_BUF sigjmp_buf
-#define NO_LONG_DOUBLE
-#define USE_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);
-
-#elif defined(MPE)
-#include <sys/times.h>
-#define NO_SETSID
-#define NO_KILLPG
-#define NO_WRITEV
-#define HAVE_SHMGET 1
-#define USE_SHMGET_SCOREBOARD
-#define SHM_R 0400 /* Read permission */
-#define SHM_W 0200 /* 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
-#define NO_GETTIMEOFDAY
-#define S_IEXEC S_IXUSR
-#define S_IREAD S_IRUSR
-#define S_IWRITE S_IWUSR
-#define PF_INET AF_INET
-
-#elif defined(SUNOS4)
-#define HAVE_GMTOFF 1
-#undef NO_KILLPG
-#undef NO_SETSID
-char *crypt(const char *pw, const char *salt);
-char *mktemp(char *template);
-#define HAVE_MMAP 1
-#define USE_MMAP_SCOREBOARD
-#define USE_MMAP_FILES
-#include <sys/time.h>
-#define NEED_STRERROR
-typedef int rlim_t;
-#define memmove(a,b,c) bcopy(b,a,c)
-#define NO_LINGCLOSE
-#define USE_FLOCK_SERIALIZED_ACCEPT
-#define NEED_DIFFTIME
-#define HAVE_SYSLOG 1
-
-#elif defined(SOLARIS2)
-#undef HAVE_GMTOFF
-#define NO_KILLPG
-#undef NO_SETSID
-#define bzero(a,b) memset(a,0,b)
-#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
-#ifndef INADDR_NONE
-#define INADDR_NONE ((unsigned int) 0xffffffff)
-#endif
-
-#elif 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
-#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
-
-#elif 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
-
-#elif defined(HPUX) || defined(HPUX10)
-#undef HAVE_GMTOFF
-#define NO_KILLPG
-#undef NO_SETSID
-#define USE_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
-
-#elif defined(HPUX11)
-#ifndef _HPUX_SOURCE
-#define _HPUX_SOURCE
-#endif
-#define HAVE_SHMGET
-#define USE_SHMGET_SCOREBOARD
-#undef HAVE_GMTOFF
-#define USE_FCNTL_SERIALIZED_ACCEPT
-/* feeling brave? want to try using POSIX mutexes? */
-/* #define HAVE_MMAP */
-/* #define USE_MMAP_SCOREBOARD */
-/* #define USE_MMAP_FILES */
-/* #define USE_PTHREAD_SERIALIZED_ACCEPT */
-#define NO_KILLPG
-#undef NO_SETSID
-#define HAVE_SYSLOG
-
-#elif 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
-/* Some versions of AIX support cross-process pthread mutexes; some don't. */
-#ifdef _POSIX_THREAD_PROCESS_SHARED
-#define USE_PTHREAD_SERIALIZED_ACCEPT
-#else
-#define USE_FCNTL_SERIALIZED_ACCEPT
-#endif
-#ifdef USEBCOPY
-#define memmove(a,b,c) bcopy(b,a,c)
-#endif
-#if AIX >= 42
-#define NET_SIZE_T size_t
-#endif
-
-#elif 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
-
-#elif 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 USE_FLOCK_SERIALIZED_ACCEPT
-#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-
-#elif 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;
-
-#elif 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 USE_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
-
-#elif defined(NEXT)
-typedef unsigned short mode_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
-
-#elif defined(MAC_OS) || defined(MAC_OS_X_SERVER) /* Mac OS (>= 10.0) and Mac OS X Server (<= 5.x) */
-#undef PLATFORM
-#ifdef MAC_OS_X_SERVER
-#define PLATFORM "Mac OS X Server"
-#else
-#define PLATFORM "Mac OS"
-#endif
-#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 USE_FLOCK_SERIALIZED_ACCEPT
-#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-/*
- * If you are using APACI, (you probably should be on Mac OS) these
- * values are set at configure time.
- */
-#ifndef HTTPD_ROOT
-#define HTTPD_ROOT "/Local/Library/WebServer"
-#endif
-#ifndef DOCUMENT_LOCATION
-#define DOCUMENT_LOCATION HTTPD_ROOT "/Documents"
-#endif
-#ifndef DEFAULT_XFERLOG
-#define DEFAULT_XFERLOG "Logs/Access"
-#endif
-#ifndef DEFAULT_ERRORLOG
-#define DEFAULT_ERRORLOG "Logs/Errors"
-#endif
-#ifndef DEFAULT_PIDLOG
-#define DEFAULT_PIDLOG "Logs/Process"
-#endif
-#ifndef DEFAULT_SCOREBOARD
-#define DEFAULT_SCOREBOARD "Logs/Status"
-#endif
-#ifndef DEFAULT_LOCKFILE
-#define DEFAULT_LOCKFILE "Logs/Lock"
-#endif
-#ifndef SERVER_CONFIG_FILE
-#define SERVER_CONFIG_FILE "Configuration/Server"
-#endif
-#ifndef RESOURCE_CONFIG_FILE
-#define RESOURCE_CONFIG_FILE "Configuration/Resources"
-#endif
-#ifndef TYPES_CONFIG_FILE
-#define TYPES_CONFIG_FILE "Configuration/MIME"
-#endif
-#ifndef ACCESS_CONFIG_FILE
-#define ACCESS_CONFIG_FILE "Configuration/Access"
-#endif
-#ifndef DEFAULT_USER_DIR
-#define DEFAULT_USER_DIR "Library/Web Documents"
-#endif
-#ifndef DEFAULT_USER
-#define DEFAULT_USER "www"
-#endif
-#ifndef DEFAULT_GROUP
-#define DEFAULT_GROUP "www"
-#endif
-#ifndef DEFAULT_PATH
-#define DEFAULT_PATH "/bin:/usr/bin:/usr/local/bin"
-#endif
-
-#elif 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
-
-#define HAVE_SHMGET 1
-#define USE_SHMGET_SCOREBOARD
-#define HAVE_MMAP 1
-#define USE_MMAP_FILES
-
-/* flock is faster ... but hasn't been tested on 1.x systems */
-/* PR#3531 indicates flock() may not be stable, probably depends on
- * kernel version. Go back to using fcntl, but provide a way for
- * folks to tweak their Configuration to get flock.
- */
-#ifndef USE_FLOCK_SERIALIZED_ACCEPT
-#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>
-#define 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
-
-#elif 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
-
-#elif defined(SCO5)
-
-#define USE_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);
-
-#elif 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 USE_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 */
-
-#elif 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 */
-#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> */
-#undef NEED_STRCASECMP
-#undef NEED_STRNCASECMP
-#undef bzero
-#endif /*_OSD_POSIX*/
-
-#elif defined(UW)
-#if UW < 700
-#define USE_FCNTL_SERIALIZED_ACCEPT
-#define NO_LINGCLOSE
-#define NO_KILLPG
-#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
-
-#elif 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 USE_FCNTL_SERIALIZED_ACCEPT
-#define ap_inet_addr inet_network
-#define HAVE_SYSLOG 1
-
-#elif defined(__NetBSD__) || defined(__OpenBSD__) || 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 USE_FLOCK_SERIALIZED_ACCEPT
-#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-
-#elif 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>
-
-#elif defined(APOLLO)
-#undef HAVE_GMTOFF
-#undef NO_KILLPG
-#undef NO_SETSID
-#define HAVE_SYSLOG 1
-
-#elif defined(__FreeBSD__) || 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 USE_FLOCK_SERIALIZED_ACCEPT
-#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-#define HAVE_SYSLOG 1
-#define SYS_SIGLIST sys_siglist
-
-#elif 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 USE_FLOCK_SERIALIZED_ACCEPT
-#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-#define HAVE_SYSLOG 1
-
-#elif defined(LYNXOS)
-#undef HAVE_GMTOFF
-#undef USE_MMAP_SCOREBOARD
-#undef USE_SHMGET_SCOREBOARD
-#undef USE_FCNTL_SERIALIZED_ACCEPT
-#undef USE_FLOCK_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
-
-#elif 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 USE_FCNTL_SERIALIZED_ACCEPT
-#define HAVE_MMAP 1
-#define USE_MMAP_SCOREBOARD
-#define USE_MMAP_FILES
-#define HAVE_SYSLOG 1
-
-#elif 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 USE_OS2SEM_SERIALIZED_ACCEPT
-#define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-
-#elif 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 USE_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 USE_FCNTL_SERIALIZED_ACCEPT
-#endif
-
-/* Convex OS v11 */
-#elif 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;
-
-#elif defined(ISC)
-#include <net/errno.h>
-#define NO_KILLPG
-#undef NO_SETSID
-#define HAVE_SHMGET 1
-#define USE_SHMGET_SCOREBOARD
-#define USE_FCNTL_SERIALIZED_ACCEPT
-#define HAVE_SYSLOG 1
-
-#elif defined(NEWSOS)
-#define HAVE_SHMGET 1
-#define USE_SHMGET_SCOREBOARD
-#define USE_LONGJMP
-#define NO_SETSID
-#define NO_USE_SIGACTION
-#define NEED_WAITPID
-#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;
-
-#elif 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
-
-#elif defined(BEOS)
-#include <stddef.h>
-#include <kernel/OS.h>
-#include <kernel/image.h>
-#include <sys/uio.h>
-
-#define NO_WRITEV
-#define NO_KILLPG
-#define NEED_INITGROUPS
-
-#elif defined(_CX_SX)
-#define JMP_BUF sigjmp_buf
-#include <sys/types.h>
-#include <sys/time.h>
-
-#elif defined(WIN32)
-
-/* All windows stuff is now in os/win32/os.h */
-
-#elif defined(TPF) /* IBM Transaction Processing Facility operating system */
-
-#include <tpfeq.h>
-#include <tpfio.h>
-#include <sysapi.h>
-#include <sysgtime.h>
-#define PRIMECRAS 0x010000
-#define JMP_BUF jmp_buf
-#define HAVE_SHMGET
-#undef HAVE_SYS_RESOURCE_H
-#define NEED_INITGROUPS
-#define NEED_SIGNAL_INTERRUPT
-#include <strings.h>
-#ifndef __strings_h
-#define NEED_STRCASECMP
-#define NEED_STRNCASECMP
-#endif
-#define NEED_STRDUP
-#define NO_DBM_REWRITEMAP
-#define NO_GETTIMEOFDAY
-#define NO_KILLPG
-#define NO_LINGCLOSE
-#define NO_MMAP
-#define NO_RELIABLE_PIPED_LOGS
-#define NO_SETSID
-#define NO_SLACK
-#define NO_TIMES
-#define NO_USE_SIGACTION
-#define NO_WRITEV
-#define USE_LONGJMP
-/*#define USE_SHMGET_SCOREBOARD*/
-#define USE_TPF_ACCEPT
-#define USE_TPF_CORE_SERIALIZED_ACCEPT
-/*#define USE_TPF_DAEMON*/
-#define USE_TPF_SCOREBOARD
-#define USE_TPF_SELECT
-#undef offsetof
-#define offsetof(s_type,field) ((size_t)&(((s_type*)0)->field))
-
-#elif defined(__TANDEM)
-#define NO_WRITEV
-#define NO_KILLPG
-#define NEED_INITGROUPS
-#define NO_SLACK
-
-#else
-/* Unknown system - Edit these to match */
-#ifdef BSD
-#define HAVE_GMTOFF 1
-#else
-#undef HAVE_GMTOFF
-#endif
-/* NO_KILLPG is set on systems that don't have killpg */
-#undef NO_KILLPG
-/* NO_SETSID is set on systems that don't have setsid */
-#undef NO_SETSID
-/* NEED_STRDUP is set on stupid systems that don't have strdup. */
-#undef NEED_STRDUP
-#endif
-
-/* 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
-#endif
-
-/* 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 Mac OS X Server, 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(MAC_OS) || defined(MAC_OS_X_SERVER)) && 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.
- */
-
-#include <sys/types.h>
-#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(TPF) && !defined(__TANDEM)
-#include <sys/file.h>
-#endif
-#ifndef WIN32
-#include <sys/socket.h>
-#ifdef HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#endif /* HAVE_SYS_SELECT_H */
-#ifndef TPF
-#include <netinet/in.h>
-#endif /* TPF */
-#include <netdb.h>
-#include <sys/ioctl.h>
-#if !defined(MPE) && !defined(BEOS) && !defined(TPF)
-#include <arpa/inet.h> /* for inet_ntoa */
-#endif
-#include <sys/wait.h>
-#include <pwd.h>
-#include <grp.h>
-#include <fcntl.h>
-#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>
-#if defined(TPF) && defined(NSIG)
-#undef NSIG
-#endif
-#include <errno.h>
-#if !defined(QNX) && !defined(CONVEXOS11) && !defined(NEXT) && !defined(TPF)
-#include <memory.h>
-#endif
-
-#ifdef NEED_PROCESS_H
-#include <process.h>
-#endif
-
-#ifdef WIN32
-#include "../include/hsregex.h"
-#elif defined(USE_HSREGEX)
-#include "hsregex.h"
-#else
-#include <regex.h>
-#endif
-
-#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
-
-#ifndef LOGNAME_MAX
-#define LOGNAME_MAX 25
-#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
-
-#if 0
-/* This stuff taken care of in APR XXXXX */
-/*
- * 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
-#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)
-#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))
-#elif defined(OS2)
-int ap_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
-#else
-#define ap_select(_a, _b, _c, _d, _e) \
- select(_a, _b, _c, _d, _e)
-#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
-
-#ifndef HAS_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, const char *argv[],
- const char *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 */
-
-#ifdef offsetof
-#define XtOffsetOf(s_type,field) offsetof(s_type,field)
-#else
-#define XtOffsetOf(s_type,field) XtOffset(s_type*,field)
-#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.
- */
-#ifndef NET_SIZE_T
-#define NET_SIZE_T int
-#endif
-
-/* 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 *);
-
-long vfprintf(FILE *, const char *, va_list);
-
-#endif /* SUNOS_LIB_PROTOTYPES */
-
-/*
- * Transition macros from old-style configuration to autoconf
- */
-#ifndef HAVE_CONFIG_H
-
-#if !defined(NO_KILLPG) && !defined(HAVE_KILLPG)
-#define HAVE_KILLPG
-#endif
-
-#if !defined(NEED_STRDUP) && !defined(HAVE_STRDUP)
-#define HAVE_STRDUP
-#endif
-
-#if !defined(NEED_STRCASECMP) && !defined(HAVE_STRCASECMP)
-#define HAVE_STRCASECMP
-#endif
-
-#if !defined(NEED_STRNCASECMP) && !defined(HAVE_STRNCASECMP)
-#define HAVE_STRNCASECMP
-#endif
-
-#if !defined(NEED_STRSTR) && !defined(HAVE_STRSTR)
-#define HAVE_STRSTR
-#endif
-
-#if !defined(NEED_INITGROUPS) && !defined(HAVE_INITGROUPS)
-#define HAVE_INITGROUPS
-#endif
-
-#if !defined(NEED_WAITPID) && !defined(HAVE_WAITPID)
-#define HAVE_WAITPID
-#endif
-
-#if !defined(NEED_STRERROR) && !defined(HAVE_STRERROR)
-#define HAVE_STRERROR
-#endif
-
-#if !defined(NEED_DIFFTIME) && !defined(HAVE_DIFFTIME)
-#define HAVE_DIFFTIME
-#endif
-
-#if !defined(NEED_GETTIMEOFDAY) && !defined(HAVE_GETTIMEOFDAY)
-#define HAVE_GETTIMEOFDAY
-#endif
-
-#if !defined(NEED_SETSID) && !defined(HAVE_SETSID)
-#define HAVE_SETSID
-#endif
-
-#if !defined(NO_TIMES) && !defined(HAVE_TIMES)
-#define HAVE_TIMES
-#define HAVE_SYS_TIMES_H
-#endif
-
-#if !defined(NO_RELIABLE_PIPED_LOGS)
-#define HAVE_RELIABLE_PIPED_LOGS
-#endif
-
-#endif /* HAVE_CONFIG_H */
-
-/* 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.
- */
-#ifndef HAVE_STRDUP
-extern char *strdup (const char *str);
-#endif
-#ifndef HAVE_STRCASECMP
-extern int strcasecmp (const char *a, const char *b);
-#endif
-#ifndef HAVE_STRNCASECMP
-extern int strncasecmp (const char *a, const char *b, int n);
-#endif
-#ifndef HAVE_INITGROUPS
-extern int initgroups(const char *name, gid_t basegid);
-#endif
-#ifndef HAVE_WAITPID
-extern int waitpid(pid_t pid, int *statusp, int options);
-#endif
-#ifndef HAVE_STRERROR
-extern char *strerror (int err);
-#endif
-#ifndef HAVE_DIFFTIME
-extern double difftime(time_t time1, time_t time0);
-#endif
-
-#ifndef ap_wait_t
-#define ap_wait_t int
-#endif
-
-/*
- * Special Support for User-Space Threading Environments [rse, 12-Aug-1999]
- */
-
-/* optionally make sure the Pthread environment is available in _EVERY_ source
- by including the Pthread header already in this header file. This is
- important for portable user-space threading environments which can only use
- soft syscall wrapping (i.e. ``#define read _pthread_read'', etc.) */
-#ifdef PTHREAD_EVERYWHERE
-#include <pthread.h>
-#endif
-
-/* support for forcing no serialized accept situation. This has to be
- used by user-space threading environments, because mostly all (except for
- USE_PTHREAD_SERIALIZED_ACCEPT, but this only works on a few platforms)
- variants of the inter-process accept lock would suspend the whole process
- and not just the acceptor thread. */
-#ifdef NO_SERIALIZED_ACCEPT
-#undef USE_FCNTL_SERIALIZED_ACCEPT
-#undef USE_FLOCK_SERIALIZED_ACCEPT
-#undef USE_USLOCK_SERIALIZED_ACCEPT
-#undef USE_SYSVSEM_SERIALIZED_ACCEPT
-#undef USE_PTHREAD_SERIALIZED_ACCEPT
-#endif
-#endif /* HAVE_CONFIG_H */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !AP_CONFIG_H */
diff --git a/include/ap_listen.h b/include/ap_listen.h
deleted file mode 100644
index 13565e97d0..0000000000
--- a/include/ap_listen.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef AP_LISTEN_H
-#define AP_LISTEN_H
-
-#include "apr_network_io.h"
-
-typedef struct ap_listen_rec ap_listen_rec;
-struct ap_listen_rec {
- ap_listen_rec *next;
- ap_socket_t *sd;
- int active;
-#ifdef WIN32
- int count;
-#endif
-/* more stuff here, like which protocol is bound to the port */
-};
-
-extern ap_listen_rec *ap_listeners;
-
-void ap_listen_pre_config(void);
-int ap_listen_open(process_rec *process, unsigned port);
-const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, char *arg);
-const char *ap_set_listener(cmd_parms *cmd, void *dummy, char *ips);
-const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy, char *arg);
-
-#define LISTEN_COMMANDS \
-{ "ListenBacklog", ap_set_listenbacklog, NULL, RSRC_CONF, TAKE1, \
- "Maximum length of the queue of pending connections, as used by listen(2)" }, \
-{ "Listen", ap_set_listener, NULL, RSRC_CONF, TAKE1, \
- "A port number or a numeric IP address and a port number"}, \
-{ "SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, TAKE1, \
- "Send buffer size in bytes"},
-
-#endif
diff --git a/include/ap_mmn.h b/include/ap_mmn.h
deleted file mode 100644
index 6f3138346d..0000000000
--- a/include/ap_mmn.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_AP_MMN_H
-#define APACHE_AP_MMN_H
-
-/*
- * 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()
- */
-
-#define MODULE_MAGIC_COOKIE 0x41503133UL /* "AP13" */
-
-#ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 19990320
-#endif
-#define MODULE_MAGIC_NUMBER_MINOR 6 /* 0...n */
-#define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR /* backward compat */
-
-/* Useful for testing for features. */
-#define 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 MODULE_MAGIC_AT_LEAST(19980812,2)
- ... use ap_overlap_tables()
-#else
- ... alternative code which doesn't use ap_overlap_tables()
-#endif
-
-*/
-
-#endif /* !APACHE_AP_MMN_H */
diff --git a/include/ap_mpm.h b/include/ap_mpm.h
deleted file mode 100644
index 35fc4b229b..0000000000
--- a/include/ap_mpm.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef AP_MMN_H
-#define AP_MMN_H
-
-/*
- 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 ap_context_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/iol 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 its SIG_IGN
-*/
-
-/* run until a restart/shutdown is indicated, return 1 for shutdown
- 0 otherwise */
-API_EXPORT(int) ap_mpm_run(ap_context_t *pconf, ap_context_t *plog, server_rec *server_conf);
-
-/* predicate indicating if a graceful stop has been requested ...
- used by the connection loop */
-API_EXPORT(int) ap_graceful_stop_signalled(void);
-
-/*
- * ap_start_shutdown() and ap_start_restart() are functions to initiate
- * shutdown or restart without relying on signals.
- *
- * These should only be called from the parent process itself, since the
- * parent process will use the shutdown_pending and restart_pending variables
- * to determine whether to shutdown or restart. The child process should
- * call signal_parent() directly to tell the parent to die -- this will
- * cause neither of those variable to be set, which the parent will
- * assume means something serious is wrong (which it will be, for the
- * child to force an exit) and so do an exit anyway.
- */
-
-void ap_start_shutdown(void);
-void ap_start_restart(int graceful);
-
-/*
- * ap_signal_parent() - used to send a signal to the parent process.
- */
-void ap_signal_parent(ap_context_t *p, const char* signal, const char* server_root);
-
-#ifdef HAS_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.
- */
-API_EXPORT(void) ap_register_other_child(int pid,
- void (*maintenance) (int reason, void *data, ap_wait_t status), void *data,
- int write_fd);
-#define OC_REASON_DEATH 0 /* child has died, caller must call
- * unregister still */
-#define OC_REASON_UNWRITABLE 1 /* write_fd is unwritable */
-#define OC_REASON_RESTART 2 /* a restart is occuring, perform
- * any necessary cleanup (including
- * sending a special signal to child)
- */
-#define OC_REASON_UNREGISTER 3 /* unregister has been called, do
- * whatever is necessary (including
- * kill the child) */
-#define 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.
- */
-API_EXPORT(void) ap_unregister_other_child(void *data);
-
-#endif
-
-#endif
diff --git a/include/http_conf_globals.h b/include/http_conf_globals.h
deleted file mode 100644
index 26e9fc4f9e..0000000000
--- a/include/http_conf_globals.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_HTTP_CONF_GLOBALS_H
-#define APACHE_HTTP_CONF_GLOBALS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* TODO: this file should be deleted after the other todos are dealt with */
-
-/* TODO: extern enum server_token_type ap_server_tokens; */
-
-/* TODO: extern int ap_configtestonly; ... although it pains me because this breaks an abstraction */
-/* TODO: extern int ap_docrootcheck; */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_HTTP_CONF_GLOBALS_H */
diff --git a/include/http_config.h b/include/http_config.h
deleted file mode 100644
index 93317635b4..0000000000
--- a/include/http_config.h
+++ /dev/null
@@ -1,380 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_HTTP_CONFIG_H
-#define APACHE_HTTP_CONFIG_H
-
-#include "ap_hooks.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * 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.
- */
-enum 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 */
-};
-
-typedef struct command_struct {
- const char *name; /* Name of this command */
- const char *(*func) (); /* Function invoked */
- void *cmd_data; /* Extra data, for functions which
- * implement multiple commands...
- */
- int req_override; /* What overrides need to be allowed to
- * enable this command.
- */
- enum cmd_how args_how; /* What the command expects as arguments */
-
- const char *errmsg; /* 'usage' message, in case of syntax errors */
-} 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
- */
-#define OR_NONE 0
-#define OR_LIMIT 1
-#define OR_OPTIONS 2
-#define OR_FILEINFO 4
-#define OR_AUTHCFG 8
-#define OR_INDEXES 16
-#define OR_UNSET 32
-#define ACCESS_CONF 64
-#define RSRC_CONF 128
-#define OR_ALL (OR_LIMIT|OR_OPTIONS|OR_FILEINFO|OR_AUTHCFG|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.
- */
-
-#define 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*...
- */
-
-typedef struct {
- void *info; /* Argument to command from cmd_table */
- int override; /* Which allow-override bits are set */
- int limited; /* Which methods are <Limit>ed */
-
- configfile_t *config_file; /* Config file structure from pcfg_openfile() */
-
- ap_context_t *pool; /* Pool to allocate new storage in */
- ap_context_t *temp_pool; /* Pool for scratch memory; persists during
- * configuration, but wiped before the first
- * request is served...
- */
- server_rec *server; /* Server_rec being configured for */
- char *path; /* 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).
- */
- const command_rec *cmd; /* configuration command */
- const char *end_token; /* end token required to end a nested section */
- void *context; /* per_dir_config vector passed
- * to handle_command */
-} cmd_parms;
-
-/* This structure records the existence of handlers in a module... */
-
-typedef struct {
- const char *content_type; /* MUST be all lower case */
- int (*handler) (request_rec *);
-} handler_rec;
-
-/*
- * Module structures. Just about everything is dispatched through
- * these, directly or indirectly (through the command and handler
- * tables).
- */
-
-typedef struct module_struct {
- int version; /* API version, *not* module version;
- * check that module is compatible with this
- * version of the server.
- */
- int minor_version; /* API minor version. Provides API feature
- * milestones. Not checked during module init
- */
- int module_index; /* Index to this modules structures in
- * config vectors.
- */
-
- const char *name;
- void *dynamic_load_handle;
-
- struct module_struct *next;
-
- unsigned long magic; /* Magic Cookie to identify a module structure;
- * It's mainly important for the DSO facility
- * (see also mod_so).
- */
-
- void *(*create_dir_config) (ap_context_t *p, char *dir);
- void *(*merge_dir_config) (ap_context_t *p, void *base_conf, void *new_conf);
- void *(*create_server_config) (ap_context_t *p, server_rec *s);
- void *(*merge_server_config) (ap_context_t *p, void *base_conf, void *new_conf);
-
- const command_rec *cmds;
- const handler_rec *handlers;
-
- /* 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.
- */
-
- void (*register_hooks) (void);
-} 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.
- */
-
-#define STANDARD_MODULE_STUFF this_module_needs_to_be_ported_to_apache_2_0
-
-#define STANDARD20_MODULE_STUFF MODULE_MAGIC_NUMBER_MAJOR, \
- MODULE_MAGIC_NUMBER_MINOR, \
- -1, \
- __FILE__, \
- NULL, \
- NULL, \
- MODULE_MAGIC_COOKIE
-
-/* 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(const char *) ap_server_root_relative(ap_context_t *p, const char *fname);
-
-/* Finally, the hook for dynamically loading modules in... */
-
-API_EXPORT(void) ap_add_module(module *m);
-API_EXPORT(void) ap_remove_module(module *m);
-API_EXPORT(void) ap_add_loaded_module(module *mod);
-API_EXPORT(void) ap_remove_loaded_module(module *mod);
-API_EXPORT(int) ap_add_named_module(const char *name);
-API_EXPORT(void) ap_clear_module_list(void);
-API_EXPORT(const char *) ap_find_module_name(module *m);
-API_EXPORT(module *) ap_find_linked_module(const char *name);
-
-/* for implementing subconfigs and customized config files */
-API_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config);
-
-/* ap_check_cmd_context() definitions: */
-API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd, unsigned forbidden);
-
-/* ap_check_cmd_context(): Forbidden in: */
-#define NOT_IN_VIRTUALHOST 0x01 /* <Virtualhost> */
-#define NOT_IN_LIMIT 0x02 /* <Limit> */
-#define NOT_IN_DIRECTORY 0x04 /* <Directory> */
-#define NOT_IN_LOCATION 0x08 /* <Location> */
-#define NOT_IN_FILES 0x10 /* <Files> */
-#define NOT_IN_DIR_LOC_FILE (NOT_IN_DIRECTORY|NOT_IN_LOCATION|NOT_IN_FILES) /* <Directory>/<Location>/<Files>*/
-#define GLOBAL_ONLY (NOT_IN_VIRTUALHOST|NOT_IN_LIMIT|NOT_IN_DIR_LOC_FILE)
-
-
-#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... */
-
-void ap_single_module_configure(ap_context_t *p, server_rec *s, module *m);
-
-/* For http_main.c... */
-
-void ap_setup_prelinked_modules(process_rec *process);
-void ap_show_directives(void);
-void ap_show_modules(void);
-server_rec *ap_read_config(process_rec *process, ap_context_t *temp_pool, const char *config_name);
-void ap_post_config_hook(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s);
-void ap_child_init_hook(ap_context_t *pchild, server_rec *s);
-
-/* For http_request.c... */
-
-void *ap_create_request_config(ap_context_t *p);
-CORE_EXPORT(void *) ap_create_per_dir_config(ap_context_t *p);
-void *ap_merge_per_dir_configs(ap_context_t *p, void *base, void *new);
-
-/* For http_connection.c... */
-
-void *ap_create_conn_config(ap_context_t *p);
-
-/* For http_core.c... (<Directory> command and virtual hosts) */
-
-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(ap_context_t *p, const char *hostname,
- server_rec *main_server, server_rec **);
-void ap_process_resource_config(server_rec *s, const char *fname, ap_context_t *p, ap_context_t *ptemp);
-
-/* Module-method dispatchers, also for http_request.c */
-
-int ap_translate_name(request_rec *);
-int ap_check_user_id(request_rec *); /* obtain valid username from client auth */
-int ap_invoke_handler(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
-
- /* Hooks */
-DECLARE_HOOK(int,header_parser,(request_rec *))
-DECLARE_HOOK(void,pre_config,(ap_context_t *pconf,ap_context_t *plog,ap_context_t *ptemp))
-DECLARE_HOOK(void,post_config,
- (ap_context_t *pconf,ap_context_t *plog,ap_context_t *ptemp,server_rec *s))
-DECLARE_HOOK(void,open_logs,
- (ap_context_t *pconf,ap_context_t *plog,ap_context_t *ptemp,server_rec *s))
-DECLARE_HOOK(void,child_init,(ap_context_t *pchild, server_rec *s))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_HTTP_CONFIG_H */
diff --git a/include/http_connection.h b/include/http_connection.h
deleted file mode 100644
index bbd91d51a9..0000000000
--- a/include/http_connection.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_HTTP_CONNECTION_H
-#define APACHE_HTTP_CONNECTION_H
-
-#include "ap_hooks.h"
-#include "apr_network_io.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef CORE_PRIVATE
-conn_rec *ap_new_connection(ap_context_t *p, server_rec *server, BUFF *inout,
- const struct sockaddr_in *remaddr,
- const struct sockaddr_in *saddr, long id);
-conn_rec *ap_new_apr_connection(ap_context_t *p, server_rec *server, BUFF *inout,
- const ap_socket_t *conn_socket, long id);
-CORE_EXPORT(void) ap_process_connection(conn_rec *);
-int ap_process_http_connection(conn_rec *);
-#endif
-
- /* Hooks */
-DECLARE_HOOK(void,pre_connection,(conn_rec *))
-DECLARE_HOOK(int,process_connection,(conn_rec *))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_HTTP_REQUEST_H */
diff --git a/include/http_core.h b/include/http_core.h
deleted file mode 100644
index ef096b84ca..0000000000
--- a/include/http_core.h
+++ /dev/null
@@ -1,302 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_HTTP_CORE_H
-#define APACHE_HTTP_CORE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "apr_lib.h"
-
-/*****************************************************************
- *
- * 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).
- */
-
-#define OPT_NONE 0
-#define OPT_INDEXES 1
-#define OPT_INCLUDES 2
-#define OPT_SYM_LINKS 4
-#define OPT_EXECCGI 8
-#define OPT_UNSET 16
-#define OPT_INCNOEXEC 32
-#define OPT_SYM_OWNER 64
-#define OPT_MULTI 128
-#define OPT_ALL (OPT_INDEXES|OPT_INCLUDES|OPT_SYM_LINKS|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.
- */
-#define 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.
- */
-#define REMOTE_NAME (1)
-
-/* REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
- * never forced.
- */
-#define 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.
- */
-#define REMOTE_DOUBLE_REV (3)
-
-#define SATISFY_ALL 0
-#define SATISFY_ANY 1
-#define SATISFY_NOSPEC 2
-
-API_EXPORT(int) ap_allow_options (request_rec *);
-API_EXPORT(int) ap_allow_overrides (request_rec *);
-API_EXPORT(const char *) ap_default_type (request_rec *);
-API_EXPORT(const char *) ap_document_root (request_rec *); /* Don't use this! If your request went
- * through a Userdir, or something like
- * that, it'll screw you. But it's
- * back-compatible...
- */
-API_EXPORT(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config, int type);
-API_EXPORT(const char *) ap_get_remote_logname(request_rec *r);
-
-/* Used for constructing self-referencing URLs, and things like SERVER_PORT,
- * and SERVER_NAME.
- */
-API_EXPORT(char *) ap_construct_url(ap_context_t *p, const char *uri, request_rec *r);
-API_EXPORT(const char *) ap_get_server_name(request_rec *r);
-API_EXPORT(unsigned) ap_get_server_port(const request_rec *r);
-API_EXPORT(unsigned long) ap_get_limit_req_body(const request_rec *r);
-API_EXPORT(void) ap_custom_response(request_rec *r, int status, char *string);
-API_EXPORT(int) ap_exists_config_define(char *name);
-
-/* 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.
- */
-
-typedef struct {
- int method_mask;
- char *requirement;
-} require_line;
-
-API_EXPORT(const char *) ap_auth_type (request_rec *);
-API_EXPORT(const char *) ap_auth_name (request_rec *);
-API_EXPORT(int) ap_satisfies (request_rec *r);
-API_EXPORT(const ap_array_header_t *) ap_requires (request_rec *);
-
-#ifdef WIN32
-/*
- * CGI Script stuff for Win32...
- */
-typedef enum { eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, eFileTypeEXE32,
- eFileTypeSCRIPT } file_type_e;
-typedef enum { INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY,
- INTERPRETER_SOURCE_SHEBANG } interpreter_source_e;
-API_EXPORT(file_type_e) ap_get_win32_interpreter(const request_rec *, char **);
-#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.
- */
-
-char *ap_response_code_string (request_rec *r, int error_index);
-
-extern API_VAR_EXPORT module core_module;
-
-/* Per-directory configuration */
-
-typedef unsigned char allow_options_t;
-typedef unsigned char overrides_t;
-
-typedef struct {
- /* path of the directory/regex/etc. see also d_is_fnmatch below */
- char *d;
- /* the number of slashes in d */
- unsigned d_components;
-
- /* 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.
- */
- allow_options_t opts;
- allow_options_t opts_add;
- allow_options_t opts_remove;
- overrides_t override;
-
- /* 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...
- */
-
- char *ap_default_type;
-
- /* Authentication stuff. Groan... */
-
- int satisfy;
- char *ap_auth_type;
- char *ap_auth_name;
- ap_array_header_t *ap_requires;
-
- /* 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().
- */
-
- char **response_code_strings;
-
- /* Hostname resolution etc */
-#define HOSTNAME_LOOKUP_OFF 0
-#define HOSTNAME_LOOKUP_ON 1
-#define HOSTNAME_LOOKUP_DOUBLE 2
-#define HOSTNAME_LOOKUP_UNSET 3
- 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? */
-
-#define USE_CANONICAL_NAME_OFF (0)
-#define USE_CANONICAL_NAME_ON (1)
-#define USE_CANONICAL_NAME_DNS (2)
-#define USE_CANONICAL_NAME_UNSET (3)
- 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;
-
- unsigned long limit_req_body; /* limit on bytes in request msg body */
-
- /* logging options */
- enum { srv_sig_unset, srv_sig_off, srv_sig_on,
- srv_sig_withmail } server_signature;
- int loglevel;
-
- /* Access control */
- ap_array_header_t *sec;
- regex_t *r;
-
-#ifdef WIN32
- /* Where to find interpreter to run scripts */
- interpreter_source_e script_interpreter_source;
-#endif
-
-} core_dir_config;
-
-/* Per-server core configuration */
-
-typedef struct {
-
-#ifdef GPROF
- char *gprof_dir;
-#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:
- */
- char *ap_document_root;
-
- /* Access control */
-
- char *access_name;
- ap_array_header_t *sec;
- ap_array_header_t *sec_url;
-} core_server_config;
-
-/* for http_config.c */
-void ap_core_reorder_directories(ap_context_t *, 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
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_HTTP_CORE_H */
diff --git a/include/http_log.h b/include/http_log.h
deleted file mode 100644
index f96311051a..0000000000
--- a/include/http_log.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_HTTP_LOG_H
-#define APACHE_HTTP_LOG_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "apr_thread_proc.h"
-
-#ifdef HAVE_SYSLOG
-#include <syslog.h>
-
-#define APLOG_EMERG LOG_EMERG /* system is unusable */
-#define APLOG_ALERT LOG_ALERT /* action must be taken immediately */
-#define APLOG_CRIT LOG_CRIT /* critical conditions */
-#define APLOG_ERR LOG_ERR /* error conditions */
-#define APLOG_WARNING LOG_WARNING /* warning conditions */
-#define APLOG_NOTICE LOG_NOTICE /* normal but significant condition */
-#define APLOG_INFO LOG_INFO /* informational */
-#define APLOG_DEBUG LOG_DEBUG /* debug-level messages */
-
-#define APLOG_LEVELMASK LOG_PRIMASK /* mask off the level value */
-
-#else
-
-#define APLOG_EMERG 0 /* system is unusable */
-#define APLOG_ALERT 1 /* action must be taken immediately */
-#define APLOG_CRIT 2 /* critical conditions */
-#define APLOG_ERR 3 /* error conditions */
-#define APLOG_WARNING 4 /* warning conditions */
-#define APLOG_NOTICE 5 /* normal but significant condition */
-#define APLOG_INFO 6 /* informational */
-#define APLOG_DEBUG 7 /* debug-level messages */
-
-#define APLOG_LEVELMASK 7 /* mask off the level value */
-
-#endif
-
-#define APLOG_NOERRNO (APLOG_LEVELMASK + 1)
-
-/* normal but significant condition on startup, usually printed to stderr */
-#define APLOG_STARTUP ((APLOG_LEVELMASK + 1) * 4)
-
-#ifndef DEFAULT_LOGLEVEL
-#define DEFAULT_LOGLEVEL APLOG_WARNING
-#endif
-
-#define APLOG_MARK __FILE__,__LINE__
-
-void ap_open_logs (server_rec *, ap_context_t *p);
-
-/* 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.
- */
-API_EXPORT(void) ap_log_error(const char *file, int line, int level,
- ap_status_t status, const server_rec *s,
- const char *fmt, ...)
- __attribute__((format(printf,6,7)));
-API_EXPORT(void) ap_log_rerror(const char *file, int line, int level,
- ap_status_t status, const request_rec *s,
- const char *fmt, ...)
- __attribute__((format(printf,6,7)));
-API_EXPORT(void) ap_error_log2stderr (server_rec *);
-
-void ap_log_pid (ap_context_t *p, const char *fname);
-/* 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(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);
-
-typedef struct piped_log {
- ap_context_t *p;
- ap_file_t *fds[2];
- /* XXX - an #ifdef that needs to be eliminated from public view. Shouldn't
- * be hard */
-#ifdef HAVE_RELIABLE_PIPED_LOGS
- char *program;
- ap_proc_t *pid;
-#endif
-} piped_log;
-
-API_EXPORT(piped_log *) ap_open_piped_log (ap_context_t *p, const char *program);
-API_EXPORT(void) ap_close_piped_log (piped_log *);
-#define ap_piped_log_read_fd(pl) ((pl)->fds[0])
-#define ap_piped_log_write_fd(pl) ((pl)->fds[1])
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_HTTP_LOG_H */
diff --git a/include/http_main.h b/include/http_main.h
deleted file mode 100644
index 9b5e0b1bd5..0000000000
--- a/include/http_main.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_HTTP_MAIN_H
-#define APACHE_HTTP_MAIN_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern MODULE_VAR_EXPORT const char *ap_server_argv0;
-extern API_VAR_EXPORT const char *ap_server_root;
-
-/* for -C, -c and -D switches */
-extern ap_array_header_t *ap_server_pre_read_config;
-extern ap_array_header_t *ap_server_post_read_config;
-extern ap_array_header_t *ap_server_config_defines;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_HTTP_MAIN_H */
diff --git a/include/http_protocol.h b/include/http_protocol.h
deleted file mode 100644
index 13a7ac287f..0000000000
--- a/include/http_protocol.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_HTTP_PROTOCOL_H
-#define APACHE_HTTP_PROTOCOL_H
-
-#include "ap_hooks.h"
-#include "apr_portable.h"
-#include "apr_mmap.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * 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. */
-
-request_rec *ap_read_request(conn_rec *c);
-
-/* Send a single HTTP header field */
-
-API_EXPORT_NONSTD(int) ap_send_header_field(request_rec *r, const char *fieldname,
- const char *fieldval);
-
-/* 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().
- */
-API_EXPORT(void) ap_basic_http_header(request_rec *r);
-
-/* Send the Status-Line and header fields for HTTP response */
-
-API_EXPORT(void) ap_send_http_header(request_rec *l);
-
-/* Send the response to special method requests */
-
-API_EXPORT(int) ap_send_http_trace(request_rec *r);
-int ap_send_http_options(request_rec *r);
-
-/* Finish up stuff after a request */
-
-API_EXPORT(void) ap_finalize_request_protocol(request_rec *r);
-
-/* 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.
- */
-
-API_EXPORT(void) ap_send_error_response(request_rec *r, int recursive_error);
-
-/* 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).
- */
-
-API_EXPORT(int) ap_set_content_length(request_rec *r, long length);
-API_EXPORT(int) ap_set_keepalive(request_rec *r);
-API_EXPORT(ap_time_t) ap_rationalize_mtime(request_rec *r, ap_time_t mtime);
-API_EXPORT(char *) ap_make_etag(request_rec *r, int force_weak);
-API_EXPORT(void) ap_set_etag(request_rec *r);
-API_EXPORT(void) ap_set_last_modified(request_rec *r);
-API_EXPORT(int) ap_meets_conditions(request_rec *r);
-
-/* 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).
- */
-
-API_EXPORT(long) ap_send_fd(ap_file_t *fd, request_rec *r);
-API_EXPORT(long) ap_send_fd_length(ap_file_t *fd, request_rec *r, long length);
-
-API_EXPORT(long) ap_send_fb(BUFF *f, request_rec *r);
-API_EXPORT(long) ap_send_fb_length(BUFF *f, request_rec *r, long length);
-
-API_EXPORT(size_t) ap_send_mmap(ap_mmap_t *mm, request_rec *r, size_t offset,
- size_t length);
-
-/* Hmmm... could macrofy these for now, and maybe forever, though the
- * definitions of the macros would get a whole lot hairier.
- */
-
-API_EXPORT(int) ap_rputc(int c, request_rec *r);
-API_EXPORT(int) ap_rputs(const char *str, request_rec *r);
-API_EXPORT(int) ap_rwrite(const void *buf, int nbyte, request_rec *r);
-API_EXPORT_NONSTD(int) ap_rvputs(request_rec *r,...);
-API_EXPORT(int) ap_vrprintf(request_rec *r, const char *fmt, va_list vlist);
-API_EXPORT_NONSTD(int) ap_rprintf(request_rec *r, const char *fmt,...)
- __attribute__((format(printf,2,3)));
-API_EXPORT(int) ap_rflush(request_rec *r);
-
-/*
- * Index used in custom_responses array for a specific error code
- * (only use outside protocol.c is in getting them configured).
- */
-
-API_EXPORT(int) ap_index_of_response(int status);
-
-/* Reading a block of data from the client connection (e.g., POST arg) */
-
-API_EXPORT(int) ap_setup_client_block(request_rec *r, int read_policy);
-API_EXPORT(int) ap_should_client_block(request_rec *r);
-API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz);
-API_EXPORT(int) ap_discard_request_body(request_rec *r);
-
-/* Sending a byterange */
-
-API_EXPORT(int) ap_set_byterange(request_rec *r);
-API_EXPORT(int) ap_each_byterange(request_rec *r, ap_off_t *offset,
- long *length);
-
-/* 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.
- *
- */
-
-API_EXPORT(void) ap_note_auth_failure(request_rec *r);
-API_EXPORT(void) ap_note_basic_auth_failure(request_rec *r);
-API_EXPORT(void) ap_note_digest_auth_failure(request_rec *r);
-API_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, const char **pw);
-
-/*
- * Setting up the protocol fields for subsidiary requests...
- * Also, a wrapup function to keep the internal accounting straight.
- */
-
-void ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r);
-void ap_finalize_sub_req_protocol(request_rec *sub_r);
-
-/* 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.
- */
-API_EXPORT(int) ap_method_number_of(const char *method);
-
- /* Hooks */
- /*
- * post_read_request --- run right after read_request or internal_redirect,
- * and not run during any subrequests.
- */
-DECLARE_HOOK(int,post_read_request,(request_rec *))
-DECLARE_HOOK(int,log_transaction,(request_rec *))
-DECLARE_HOOK(const char *,http_method,(const request_rec *))
-DECLARE_HOOK(unsigned short,default_port,(const request_rec *))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_HTTP_PROTOCOL_H */
diff --git a/include/http_request.h b/include/http_request.h
deleted file mode 100644
index 7e0fa711b8..0000000000
--- a/include/http_request.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_HTTP_REQUEST_H
-#define APACHE_HTTP_REQUEST_H
-
-#include "ap_hooks.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* 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 ap_context_t elsewhere before doing this.
- */
-
-API_EXPORT(request_rec *) ap_sub_req_lookup_uri(const char *new_file,
- const request_rec *r);
-API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file,
- const request_rec *r);
-API_EXPORT(request_rec *) ap_sub_req_method_uri(const char *method,
- const char *new_file,
- const request_rec *r);
-API_EXPORT(int) ap_run_sub_req(request_rec *r);
-API_EXPORT(void) ap_destroy_sub_req(request_rec *r);
-
-/*
- * 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.
- */
-
-API_EXPORT(void) ap_internal_redirect(const char *new_uri, request_rec *);
-API_EXPORT(void) ap_internal_redirect_handler(const char *new_uri, request_rec *);
-API_EXPORT(int) ap_some_auth_required(request_rec *r);
-API_EXPORT(int) ap_is_initial_req(request_rec *r);
-API_EXPORT(void) ap_update_mtime(request_rec *r, ap_time_t dependency_mtime);
-
-#ifdef CORE_PRIVATE
-/* Function called by main.c to handle first-level request */
-void ap_process_request(request_rec *);
-API_EXPORT(void) ap_die(int type, request_rec *r);
-#endif
-
- /* Hooks */
-DECLARE_HOOK(int,translate_name,(request_rec *))
-DECLARE_HOOK(int,check_user_id,(request_rec *))
-DECLARE_HOOK(int,fixups,(request_rec *))
-DECLARE_HOOK(int,type_checker,(request_rec *))
-DECLARE_HOOK(int,access_checker,(request_rec *))
-DECLARE_HOOK(int,auth_checker,(request_rec *))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_HTTP_REQUEST_H */
diff --git a/include/http_vhost.h b/include/http_vhost.h
deleted file mode 100644
index a1a4fcada8..0000000000
--- a/include/http_vhost.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_HTTP_VHOST_H
-#define APACHE_HTTP_VHOST_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* called before any config is read */
-void ap_init_vhost_config(ap_context_t *p);
-
-/* called after the config has been read */
-void ap_fini_vhost_config(ap_context_t *p, server_rec *main_server);
-
-/* handle addresses in <VirtualHost> statement */
-const char *ap_parse_vhost_addrs(ap_context_t *p, const char *hostname, server_rec *s);
-
-/* handle NameVirtualHost directive */
-const char *ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, char *arg);
-
-/* given an ip address only, give our best guess as to what vhost it is */
-void ap_update_vhost_given_ip(conn_rec *conn);
-
-/* The above is never enough, and this is always called after the headers
- * have been read. It may change r->server.
- */
-void ap_update_vhost_from_headers(request_rec *r);
-
-/* return 1 if the host:port matches any of the aliases of r->server
- * return 0 otherwise
- */
-API_EXPORT(int) ap_matches_request_vhost(request_rec *r, const char *host,
- unsigned port);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_HTTP_VHOST_H */
diff --git a/include/httpd.h b/include/httpd.h
deleted file mode 100644
index 815f14cb65..0000000000
--- a/include/httpd.h
+++ /dev/null
@@ -1,1063 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_HTTPD_H
-#define APACHE_HTTPD_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * httpd.h: header for simple (ha! not anymore) http daemon
- */
-
-/* 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 "os.h"
-#include "apr_general.h"
-#include "apr_lib.h"
-#include "apr_time.h"
-#include "apr_network_io.h"
-#include "buff.h"
-#include "ap_mmn.h"
-
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-
-#ifdef CORE_PRIVATE
-
-/* ----------------------------- 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.
- */
-#ifndef HTTPD_ROOT
-#ifdef OS2
-/* Set default for OS/2 file system */
-#define HTTPD_ROOT "/os2httpd"
-#elif defined(WIN32)
-/* Set default for Windows file system */
-#define HTTPD_ROOT "/apache"
-#elif defined (BEOS)
-/* Set the default for BeOS */
-#define HTTPD_ROOT "/boot/home/apache"
-#else
-#define HTTPD_ROOT "/usr/local/apache"
-#endif
-#endif /* HTTPD_ROOT */
-
-/*
- * --------- 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.
- *
- */
-
-/* Default location of documents. Can be overridden by the DocumentRoot
- * directive.
- */
-#ifndef DOCUMENT_LOCATION
-#ifdef OS2
-/* Set default for OS/2 file system */
-#define DOCUMENT_LOCATION HTTPD_ROOT "/docs"
-#else
-#define DOCUMENT_LOCATION HTTPD_ROOT "/htdocs"
-#endif
-#endif /* DOCUMENT_LOCATION */
-
-/* Max. number of dynamically loaded modules */
-#ifndef DYNAMIC_MODULE_LIMIT
-#define DYNAMIC_MODULE_LIMIT 64
-#endif
-
-/* Default administrator's address */
-#define DEFAULT_ADMIN "[no address given]"
-
-/* The target name of the installed Apache */
-#ifndef TARGET
-#define TARGET "httpd"
-#endif
-
-/* --------- Default user name and group name ----------------------------- */
-/* --- These may be specified as numbers by placing a # before a number --- */
-
-#ifndef DEFAULT_USER
-#define DEFAULT_USER "#-1"
-#endif
-#ifndef DEFAULT_GROUP
-#define DEFAULT_GROUP "#-1"
-#endif
-
-/* The name of the log files */
-#ifndef DEFAULT_XFERLOG
-#if defined(OS2) || defined(WIN32)
-#define DEFAULT_XFERLOG "logs/access.log"
-#else
-#define DEFAULT_XFERLOG "logs/access_log"
-#endif
-#endif /* DEFAULT_XFERLOG */
-
-#ifndef DEFAULT_ERRORLOG
-#if defined(OS2) || defined(WIN32)
-#define DEFAULT_ERRORLOG "logs/error.log"
-#else
-#define DEFAULT_ERRORLOG "logs/error_log"
-#endif
-#endif /* DEFAULT_ERRORLOG */
-
-/* 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 */
-#define DEFAULT_ACCESS_FNAME "htaccess"
-#else
-#define DEFAULT_ACCESS_FNAME ".htaccess"
-#endif
-#endif /* DEFAULT_ACCESS_FNAME */
-
-/* The name of the server config file */
-#ifndef SERVER_CONFIG_FILE
-#define SERVER_CONFIG_FILE "conf/httpd.conf"
-#endif
-
-/* The name of the document config file */
-#ifndef RESOURCE_CONFIG_FILE
-#define RESOURCE_CONFIG_FILE "conf/srm.conf"
-#endif
-
-/* The name of the access file */
-#ifndef ACCESS_CONFIG_FILE
-#define ACCESS_CONFIG_FILE "conf/access.conf"
-#endif
-
-/* Whether we should enable rfc1413 identity checking */
-#ifndef DEFAULT_RFC1413
-#define DEFAULT_RFC1413 0
-#endif
-
-/* The default path for CGI scripts if none is currently set */
-#ifndef DEFAULT_PATH
-#define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
-#endif
-
-/* The path to the suExec wrapper, can be overridden in Configuration */
-#ifndef SUEXEC_BIN
-#define SUEXEC_BIN HTTPD_ROOT "/sbin/suexec"
-#endif
-
-/* The timeout for waiting for messages */
-#ifndef DEFAULT_TIMEOUT
-#define DEFAULT_TIMEOUT 120000
-#endif
-
-/* The timeout for waiting for keepalive timeout until next request */
-#ifndef DEFAULT_KEEPALIVE_TIMEOUT
-#define DEFAULT_KEEPALIVE_TIMEOUT 300
-#endif
-
-/* The number of requests to entertain per connection */
-#ifndef DEFAULT_KEEPALIVE
-#define DEFAULT_KEEPALIVE 100
-#endif
-
-/* 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.
- */
-
-#ifndef DEFAULT_LISTENBACKLOG
-#define DEFAULT_LISTENBACKLOG 511
-#endif
-
-/* 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.
- */
-#ifndef DEFAULT_LIMIT_REQUEST_LINE
-#define DEFAULT_LIMIT_REQUEST_LINE 8190
-#endif /* default limit on bytes in Request-Line (Method+URI+HTTP-version) */
-#ifndef DEFAULT_LIMIT_REQUEST_FIELDSIZE
-#define DEFAULT_LIMIT_REQUEST_FIELDSIZE 8190
-#endif /* default limit on bytes in any one header field */
-#ifndef DEFAULT_LIMIT_REQUEST_FIELDS
-#define DEFAULT_LIMIT_REQUEST_FIELDS 100
-#endif /* default limit on number of request header fields */
-
-/*
- * 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"
- */
-
-/* Define this to 1 if you want fancy indexing, 0 otherwise */
-#ifndef DEFAULT_INDEXING
-#define DEFAULT_INDEXING 0
-#endif
-#endif /* CORE_PRIVATE */
-
-#define AP_SERVER_BASEVERSION "Apache/2.0-dev" /* SEE COMMENTS ABOVE */
-#define AP_SERVER_VERSION AP_SERVER_BASEVERSION
-
-#define AP_SERVER_PROTOCOL "HTTP/1.1"
-
-
-/* ------------------ stuff that modules are allowed to look at ----------- */
-
-/* Define this to be what your HTML directory content files are called */
-#ifndef AP_DEFAULT_INDEX
-#define AP_DEFAULT_INDEX "index.html"
-#endif
-
-
-/* Define this to be what type you'd like returned for files with unknown */
-/* suffixes. MUST be all lower case. */
-#ifndef DEFAULT_CONTENT_TYPE
-#define DEFAULT_CONTENT_TYPE "text/plain"
-#endif
-
-/* The name of the MIME types file */
-#ifndef AP_TYPES_CONFIG_FILE
-#define AP_TYPES_CONFIG_FILE "conf/mime.types"
-#endif
-
-/*
- * Define the HTML doctype strings centrally.
- */
-#define DOCTYPE_HTML_2_0 "<!DOCTYPE HTML PUBLIC \"-//IETF//" \
- "DTD HTML 2.0//EN\">\n"
-#define DOCTYPE_HTML_3_2 "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
- "DTD HTML 3.2 Final//EN\">\n"
-#define DOCTYPE_HTML_4_0S "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
- "DTD HTML 4.0//EN\"\n" \
- "\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
-#define DOCTYPE_HTML_4_0T "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
- "DTD HTML 4.0 Transitional//EN\"\n" \
- "\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n"
-#define DOCTYPE_HTML_4_0F "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
- "DTD HTML 4.0 Frameset//EN\"\n" \
- "\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n"
-
-/* -- 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 --------------- */
-
-#define DEFAULT_HTTP_PORT 80
-#define DEFAULT_HTTPS_PORT 443
-#define ap_is_default_port(port,r) ((port) == ap_default_port(r))
-#define ap_http_method(r) ap_run_http_method(r)
-#define ap_default_port(r) ap_run_default_port(r)
-
-/* The default string lengths */
-#define MAX_STRING_LEN HUGE_STRING_LEN
-#define HUGE_STRING_LEN 8192
-
-/* The size of the server's internal read-write buffers */
-#define IOBUFSIZE 8192
-
-/*
- * 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.
- *
- */
-#define APEXIT_OK 0x0
-#define APEXIT_INIT 0x2
-#define APEXIT_CHILDINIT 0x3
-#define APEXIT_CHILDFATAL 0xf
-
-/* TODO: re-implement the server token/version stuff -- it's part of http_core
- * it should be possible to do without touching http_main at all. (or else
- * we haven't got enough module hooks)
- */
-
-enum 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 */
-};
-
-#if 0
-API_EXPORT(const char *) ap_get_server_version(void);
-API_EXPORT(void) ap_add_version_component(const char *component);
-#else
-#define ap_get_server_version() (AP_SERVER_BASEVERSION)
-#define ap_add_version_component(x) ((void)0)
-#endif
-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'.
- */
-#define APACHE_RELEASE 10309100
-
-#define DECLINED -1 /* Module declines to handle */
-#define DONE -2 /* Module has served the response completely
- * - it's safe to die() with no more output
- */
-#define 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 ap_table_t at startup.
- */
-#define RESPONSE_CODES 55
-
-#define HTTP_CONTINUE 100
-#define HTTP_SWITCHING_PROTOCOLS 101
-#define HTTP_PROCESSING 102
-#define HTTP_OK 200
-#define HTTP_CREATED 201
-#define HTTP_ACCEPTED 202
-#define HTTP_NON_AUTHORITATIVE 203
-#define HTTP_NO_CONTENT 204
-#define HTTP_RESET_CONTENT 205
-#define HTTP_PARTIAL_CONTENT 206
-#define HTTP_MULTI_STATUS 207
-#define HTTP_MULTIPLE_CHOICES 300
-#define HTTP_MOVED_PERMANENTLY 301
-#define HTTP_MOVED_TEMPORARILY 302
-#define HTTP_SEE_OTHER 303
-#define HTTP_NOT_MODIFIED 304
-#define HTTP_USE_PROXY 305
-#define HTTP_TEMPORARY_REDIRECT 307
-#define HTTP_BAD_REQUEST 400
-#define HTTP_UNAUTHORIZED 401
-#define HTTP_PAYMENT_REQUIRED 402
-#define HTTP_FORBIDDEN 403
-#define HTTP_NOT_FOUND 404
-#define HTTP_METHOD_NOT_ALLOWED 405
-#define HTTP_NOT_ACCEPTABLE 406
-#define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
-#define HTTP_REQUEST_TIME_OUT 408
-#define HTTP_CONFLICT 409
-#define HTTP_GONE 410
-#define HTTP_LENGTH_REQUIRED 411
-#define HTTP_PRECONDITION_FAILED 412
-#define HTTP_REQUEST_ENTITY_TOO_LARGE 413
-#define HTTP_REQUEST_URI_TOO_LARGE 414
-#define HTTP_UNSUPPORTED_MEDIA_TYPE 415
-#define HTTP_RANGE_NOT_SATISFIABLE 416
-#define HTTP_EXPECTATION_FAILED 417
-#define HTTP_UNPROCESSABLE_ENTITY 422
-#define HTTP_LOCKED 423
-#define HTTP_FAILED_DEPENDENCY 424
-#define HTTP_INTERNAL_SERVER_ERROR 500
-#define HTTP_NOT_IMPLEMENTED 501
-#define HTTP_BAD_GATEWAY 502
-#define HTTP_SERVICE_UNAVAILABLE 503
-#define HTTP_GATEWAY_TIME_OUT 504
-#define HTTP_VERSION_NOT_SUPPORTED 505
-#define HTTP_VARIANT_ALSO_VARIES 506
-#define HTTP_INSUFFICIENT_STORAGE 507
-#define HTTP_NOT_EXTENDED 510
-
-#define DOCUMENT_FOLLOWS HTTP_OK
-#define PARTIAL_CONTENT HTTP_PARTIAL_CONTENT
-#define MULTIPLE_CHOICES HTTP_MULTIPLE_CHOICES
-#define MOVED HTTP_MOVED_PERMANENTLY
-#define REDIRECT HTTP_MOVED_TEMPORARILY
-#define USE_LOCAL_COPY HTTP_NOT_MODIFIED
-#define BAD_REQUEST HTTP_BAD_REQUEST
-#define AUTH_REQUIRED HTTP_UNAUTHORIZED
-#define FORBIDDEN HTTP_FORBIDDEN
-#define NOT_FOUND HTTP_NOT_FOUND
-#define METHOD_NOT_ALLOWED HTTP_METHOD_NOT_ALLOWED
-#define NOT_ACCEPTABLE HTTP_NOT_ACCEPTABLE
-#define LENGTH_REQUIRED HTTP_LENGTH_REQUIRED
-#define PRECONDITION_FAILED HTTP_PRECONDITION_FAILED
-#define SERVER_ERROR HTTP_INTERNAL_SERVER_ERROR
-#define NOT_IMPLEMENTED HTTP_NOT_IMPLEMENTED
-#define BAD_GATEWAY HTTP_BAD_GATEWAY
-#define 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.
- */
-#define M_GET 0
-#define M_PUT 1
-#define M_POST 2
-#define M_DELETE 3
-#define M_CONNECT 4
-#define M_OPTIONS 5
-#define M_TRACE 6
-#define M_PATCH 7
-#define M_PROPFIND 8
-#define M_PROPPATCH 9
-#define M_MKCOL 10
-#define M_COPY 11
-#define M_MOVE 12
-#define M_LOCK 13
-#define M_UNLOCK 14
-#define M_INVALID 15
-
-#define METHODS 16
-
-#define CGI_MAGIC_TYPE "application/x-httpd-cgi"
-#define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html"
-#define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3"
-#define DIR_MAGIC_TYPE "httpd/unix-directory"
-
-#define LF 10
-#define CR 13
-
-/* 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.
- */
-#define REQUEST_NO_BODY 0
-#define REQUEST_CHUNKED_ERROR 1
-#define REQUEST_CHUNKED_DECHUNK 2
-#define REQUEST_CHUNKED_PASS 3
-
-/* 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.
- */
-struct htaccess_result {
- char *dir; /* the directory to which this applies */
- int override; /* the overrides allowed for the .htaccess file */
- void *htaccess; /* the configuration directives */
-/* the next one, or NULL if no more; N.B. never change this */
- const struct htaccess_result *next;
-};
-
-/* 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. */
-
-typedef struct process_rec process_rec;
-typedef struct server_rec server_rec;
-typedef struct conn_rec conn_rec;
-typedef struct request_rec request_rec;
-
-#include "util_uri.h"
-
-struct process_rec {
- ap_context_t *pool; /* Global pool. Please try to cleared on _all_ exits */
- ap_context_t *pconf; /* aka configuration pool, cleared on restarts */
- int argc;
- const char **argv;
- const char *short_name;
-};
-
-struct request_rec {
-
- ap_context_t *pool;
- conn_rec *connection;
- server_rec *server;
-
- request_rec *next; /* If we wind up getting redirected,
- * pointer to the request we redirected to.
- */
- request_rec *prev; /* If this is an internal redirect,
- * pointer to where we redirected *from*.
- */
-
- request_rec *main; /* 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...
- */
-
- char *the_request; /* First line of request, so we can log it */
- int assbackwards; /* HTTP/0.9, "simple" request */
- int proxyreq; /* A proxy request (calculated during
- * post_read_request or translate_name) */
- int header_only; /* HEAD request, as opposed to GET */
- char *protocol; /* Protocol, as given to us, or HTTP/0.9 */
- int proto_num; /* Number version of protocol; 1.1 = 1001 */
- const char *hostname; /* Host, as set by full URI or Host: */
-
- ap_time_t request_time; /* When the request started */
-
- const char *status_line; /* Status line, if set by script */
- int status; /* In any case */
-
- /* Request method, two ways; also, protocol, etc.. Outside of protocol.c,
- * look, but don't touch.
- */
-
- const char *method; /* GET, HEAD, POST, etc. */
- int method_number; /* 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.
- */
- int allowed; /* Allowed methods - for 405, OPTIONS, etc */
-
- int sent_bodyct; /* byte count in stream is for body */
- long bytes_sent; /* body byte count, for easy access */
- ap_time_t mtime; /* Time the resource was last modified */
-
- /* HTTP/1.1 connection-level features */
-
- int chunked; /* sending chunked transfer-coding */
- int byterange; /* number of byte ranges */
- char *boundary; /* multipart/byteranges boundary */
- const char *range; /* The Range: header */
- long clength; /* The "real" content length */
-
- long remaining; /* bytes left to read */
- long read_length; /* bytes that have been read */
- int read_body; /* how the request body should be read */
- int read_chunked; /* reading chunked transfer-coding */
- unsigned expecting_100; /* 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' ap_table_t is for notes from one module to another, with no
- * other set purpose in mind...
- */
-
- ap_table_t *headers_in;
- ap_table_t *headers_out;
- ap_table_t *err_headers_out;
- ap_table_t *subprocess_env;
- ap_table_t *notes;
-
- /* 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.
- */
- const char *content_type; /* Break these out --- we dispatch on 'em */
- const char *handler; /* What we *really* dispatch on */
-
- const char *content_encoding;
- const char *content_language; /* for back-compat. only -- do not use */
- ap_array_header_t *content_languages; /* array of (char*) */
-
- char *vlist_validator; /* variant list validator (if negotiated) */
-
- char *user; /* If an authentication check was made,
- * this gets set to the user name.
- */
- char *ap_auth_type; /* Ditto. */
-
- int no_cache;
- int no_local_copy;
-
- /* What object is being requested (either directly, or via include
- * or content-negotiation mapping).
- */
-
- char *unparsed_uri; /* the uri without any parsing performed */
- char *uri; /* the path portion of the URI */
- char *filename;
- char *path_info;
- char *args; /* QUERY_ARGS, if any */
- ap_finfo_t finfo; /* ST_MODE set to zero if no such file */
- uri_components parsed_uri; /* 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).
- */
-
- void *per_dir_config; /* Options set in config files, etc. */
- void *request_config; /* 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
- */
- const struct htaccess_result *htaccess;
-
-/* 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.
- */
-};
-
-
-/* Things which are per connection
- */
-
-struct conn_rec {
-
- ap_context_t *pool;
- server_rec *base_server; /* Physical vhost this conn come in on */
- void *vhost_lookup_data; /* used by http_vhost.c */
-
- /* Information about the connection itself */
-
- BUFF *client; /* Connection to the guy */
-
- /* Who is the client? */
-
- struct sockaddr_in local_addr; /* local address */
- struct sockaddr_in remote_addr; /* remote address */
- char *remote_ip; /* Client's IP address */
- char *remote_host; /* 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() */
- char *remote_logname; /* Only ever set if doing rfc1413 lookups.
- * N.B. Only access this through
- * get_remote_logname() */
-
- 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 */
- int keepalives; /* How many times have we used it? */
- char *local_ip; /* server IP address */
- char *local_host; /* used for ap_get_server_name when
- * UseCanonicalName is set to DNS
- * (ignores setting of HostnameLookups) */
- long id; /* ID of this connection; unique at any
- * point in time */
- void *conn_config; /* Notes on *this* connection */
-};
-
-/* 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.
- */
-#define DEFAULT_VHOST_ADDR 0xfffffffful
-
-typedef struct server_addr_rec server_addr_rec;
-struct server_addr_rec {
- server_addr_rec *next;
- ap_in_addr host_addr; /* The bound address, for this server */
- unsigned short host_port; /* The bound port, for this server */
- char *virthost; /* The name given in <VirtualHost> */
-};
-
-struct server_rec {
- process_rec *process;
- server_rec *next;
-
- /* description of where the definition came from */
- const char *defn_name;
- unsigned defn_line_number;
-
- /* Full locations of server config info */
-
- char *srm_confname;
- char *access_confname;
-
- /* Contact information */
-
- char *server_admin;
- char *server_hostname;
- unsigned short port; /* for redirects, etc. */
-
- /* Log files --- note that transfer log is now in the modules... */
-
- char *error_fname;
- ap_file_t *error_log;
- int loglevel;
-
- /* Module-specific configuration for server, and defaults... */
-
- int is_virtual; /* true if this is the virtual server */
- void *module_config; /* Config vector containing pointers to
- * modules' per-server config structures.
- */
- void *lookup_defaults; /* MIME type info, etc., before we start
- * checking per-directory info.
- */
- /* Transaction handling */
-
- server_addr_rec *addrs;
- int timeout; /* Timeout, in seconds, before we give up */
- int keep_alive_timeout; /* Seconds we'll wait for another request */
- int keep_alive_max; /* Maximum requests per connection */
- int keep_alive; /* Use persistent connections? */
-
- char *path; /* Pathname for ServerPath */
- int pathlen; /* Length of path */
-
- ap_array_header_t *names; /* Normal names for ServerAlias servers */
- ap_array_header_t *wild_names; /* Wildcarded names for ServerAlias servers */
-
- uid_t server_uid; /* effective user id when calling exec wrapper */
- gid_t server_gid; /* effective group id when calling exec wrapper */
-
- int limit_req_line; /* limit on size of the HTTP request line */
- int limit_req_fieldsize; /* limit on size of any request header field */
- int limit_req_fields; /* limit on number of request header fields */
-};
-
-/* 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
-#endif
-
-/* 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 Mac OS X Server, 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.
- */
-#ifndef ap_private_extern
-#if (defined(MAC_OS) || defined(MAC_OS_X_SERVER)) && defined(__DYNAMIC__)
-#define ap_private_extern __private_extern__
-#else
-#define ap_private_extern
-#endif
-#endif
-
-/* Time */
-
-API_EXPORT(char *) ap_field_noparam(ap_context_t *p, const char *intype);
-API_EXPORT(char *) ap_ht_time(ap_context_t *p, ap_time_t t, const char *fmt, int gmt);
-
-/* 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 **) */
-
-API_EXPORT(char *) ap_getword(ap_context_t *p, const char **line, char stop);
-API_EXPORT(char *) ap_getword_nc(ap_context_t *p, char **line, char stop);
-API_EXPORT(char *) ap_getword_white(ap_context_t *p, const char **line);
-API_EXPORT(char *) ap_getword_white_nc(ap_context_t *p, char **line);
-API_EXPORT(char *) ap_getword_nulls(ap_context_t *p, const char **line, char stop);
-API_EXPORT(char *) ap_getword_nulls_nc(ap_context_t *p, char **line, char stop);
-API_EXPORT(char *) ap_getword_conf(ap_context_t *p, const char **line);
-API_EXPORT(char *) ap_getword_conf_nc(ap_context_t *p, char **line);
-
-API_EXPORT(const char *) ap_size_list_item(const char **field, int *len);
-API_EXPORT(char *) ap_get_list_item(ap_context_t *p, const char **field);
-API_EXPORT(int) ap_find_list_item(ap_context_t *p, const char *line, const char *tok);
-
-API_EXPORT(char *) ap_get_token(ap_context_t *p, const char **accept_line, int accept_white);
-API_EXPORT(int) ap_find_token(ap_context_t *p, const char *line, const char *tok);
-API_EXPORT(int) ap_find_last_token(ap_context_t *p, const char *line, const char *tok);
-
-API_EXPORT(int) ap_is_url(const char *u);
-API_EXPORT(int) ap_unescape_url(char *url);
-API_EXPORT(void) ap_no2slash(char *name);
-API_EXPORT(void) ap_getparents(char *name);
-API_EXPORT(char *) ap_escape_path_segment(ap_context_t *p, const char *s);
-API_EXPORT(char *) ap_os_escape_path(ap_context_t *p, const char *path, int partial);
-#define ap_escape_uri(ppool,path) ap_os_escape_path(ppool,path,1)
-API_EXPORT(char *) ap_escape_html(ap_context_t *p, const char *s);
-API_EXPORT(char *) ap_construct_server(ap_context_t *p, const char *hostname,
- unsigned port, const request_rec *r);
-API_EXPORT(char *) ap_escape_shell_cmd(ap_context_t *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(ap_context_t *p, const char *s);
-/* deprecated. The previous two routines are preferred. */
-API_EXPORT(char *) ap_make_dirstr(ap_context_t *a, const char *s, int n);
-API_EXPORT(char *) ap_make_full_path(ap_context_t *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_pbase64decode(ap_context_t *p, const char *bufcoded);
-API_EXPORT(char *) ap_pbase64encode(ap_context_t *p, char *string);
-API_EXPORT(char *) ap_uudecode(ap_context_t *p, const char *bufcoded);
-API_EXPORT(char *) ap_uuencode(ap_context_t *p, char *string);
-
-/* Regexes */
-#if defined(USE_HSREGEX) || defined(WIN32)
-#include "hsregex.h"
-#else
-#include <regex.h>
-#endif
-
-API_EXPORT(regex_t *) ap_pregcomp(ap_context_t *p, const char *pattern,
- int cflags);
-API_EXPORT(void) ap_pregfree(ap_context_t *p, regex_t *reg);
-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(ap_context_t *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 (ap_context_t *p, const char *instring);
-
-/* Common structure for reading of config files / passwd files etc. */
-typedef struct {
- int (*getch) (void *param); /* a getc()-like function */
- void *(*getstr) (void *buf, size_t bufsiz, void *param); /* a fgets()-like function */
- int (*close) (void *param); /* a close hander function */
- void *param; /* the argument passed to getch/getstr/close */
- const char *name; /* the filename / description */
- unsigned line_number; /* current line number, starting at 1 */
-} configfile_t;
-
-/* Open a configfile_t as FILE, return open configfile_t struct pointer */
-API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **, ap_context_t *p, const char *name);
-
-/* Allocate a configfile_t handle with user defined functions and params */
-API_EXPORT(configfile_t *) ap_pcfg_open_custom(ap_context_t *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);
-
-/* Misc system hackery */
-
-API_EXPORT(uid_t) ap_uname2id(const char *name);
-API_EXPORT(gid_t) ap_gname2id(const char *name);
-API_EXPORT(int) ap_is_directory(const char *name);
-API_EXPORT(void) ap_chdir_file(const char *file);
-API_EXPORT(int) ap_get_max_daemons(void);
-API_EXPORT(const server_rec *) ap_get_server_conf(void);
-
-#ifdef _OSD_POSIX
-extern const char *os_set_account(ap_context_t *p, const char *account);
-extern int os_init_job_environment(server_rec *s, const char *user_name, int one_process);
-#endif /* _OSD_POSIX */
-
-char *ap_get_local_host(ap_context_t *);
-unsigned long ap_get_virthost_addr(char *hostname, unsigned short *port);
-
-API_EXPORT(char *) ap_escape_quotes(ap_context_t *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__))
-
-/* 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.
- */
-#define SIGSTOP_DETACH 1
-#define SIGSTOP_MAKE_CHILD 2
-#define SIGSTOP_SPAWN_CHILD 4
-#define SIGSTOP_PIPED_LOG_SPAWN 8
-#define SIGSTOP_CGI_CHILD 16
-
-#ifdef DEBUG_SIGSTOP
-extern int raise_sigstop_flags;
-#define RAISE_SIGSTOP(x) do { \
- if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
- } 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. */
-#ifdef strtoul
-#undef strtoul
-#endif
-#define strtoul strtoul_is_not_a_portable_function_use_strtol_instead
-
-#define ap_is_aborted(abort) (abort->aborted ==1)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_HTTPD_H */
diff --git a/include/mpm_status.h b/include/mpm_status.h
deleted file mode 100644
index ee6f50f6c6..0000000000
--- a/include/mpm_status.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * TODO: Possible additions to this API include getting a list of connection
- * IDs and a list of keys in a particular row.
- */
-
-#ifndef APACHE_MPM_STATUS_H
-#define APACHE_MPM_STATUS_H
-
-#include "apr_lib.h"
-
-typedef struct {
- long conn_id;
- ap_table_t *data;
-} ap_status_table_row_t;
-
-/**
- *
- * Get a cell from the status table. Don't mess with the string you get.
- *
- * conn_id = Connection ID
- * key = key
- *
- */
-API_EXPORT(const char *) ap_get_connection_status(long conn_id, const char *key);
-
-/**
- * Get an array of current connection IDs.
- *
- */
-API_EXPORT(ap_array_header_t *) ap_get_connections(ap_context_t *p);
-
-/**
- * Get an array of keys from a given connection.
- *
- * conn_id = Connection ID
- *
- */
-API_EXPORT(ap_array_header_t *) ap_get_connection_keys(ap_context_t *p,
- long conn_id);
-
-/**
- *
- * Set a cell in the status table. No guarantees are made that long strings
- * won't be truncated.
- *
- * conn_id = Connection ID
- * key = key
- * value = value
- *
- */
-API_EXPORT(void) ap_update_connection_status(long conn_id, const char *key, const char *value);
-
-/**
- *
- * Clear out this connection's status values. Normally called when a
- * connection is closed
- *
- * conn_id = Connection ID
- *
- */
-API_EXPORT(void) ap_reset_connection_status(long conn_id);
-
-/**
- *
- * Returns the most up-to-date status table available, in the form of an array
- * of ap_status_row_t's.
- *
- * p = context, generally of the request
- *
- */
-API_EXPORT(ap_array_header_t *) ap_get_status_table(ap_context_t *p);
-
-#endif /* APACHE_SERVER_STATS_H */
-
diff --git a/include/rfc1413.h b/include/rfc1413.h
deleted file mode 100644
index e69c9d2a14..0000000000
--- a/include/rfc1413.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_RFC1413_H
-#define APACHE_RFC1413_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern char *ap_rfc1413(conn_rec *conn, server_rec *srv);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_RFC1413_H */
diff --git a/include/util_date.h b/include/util_date.h
deleted file mode 100644
index 88c9155a38..0000000000
--- a/include/util_date.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_UTIL_DATE_H
-#define APACHE_UTIL_DATE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * util_date.h: prototypes for date parsing utility routines
- */
-
-#include "apr_time.h"
-
-#define BAD_DATE (ap_time_t)0
-
-API_EXPORT(int) ap_checkmask(const char *data, const char *mask);
-API_EXPORT(ap_time_t) ap_parseHTTPdate(const char *date);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_UTIL_DATE_H */
diff --git a/include/util_md5.h b/include/util_md5.h
deleted file mode 100644
index 6e11506a79..0000000000
--- a/include/util_md5.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_UTIL_MD5_H
-#define APACHE_UTIL_MD5_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "ap_md5.h"
-
-API_EXPORT(char *) ap_md5(ap_context_t *a, const unsigned char *string);
-API_EXPORT(char *) ap_md5_binary(ap_context_t *a, const unsigned char *buf, int len);
-API_EXPORT(char *) ap_md5contextTo64(ap_context_t *p, AP_MD5_CTX * context);
-API_EXPORT(char *) ap_md5digest(ap_context_t *p, ap_file_t *infile);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_UTIL_MD5_H */
diff --git a/include/util_script.h b/include/util_script.h
deleted file mode 100644
index d438c63fdb..0000000000
--- a/include/util_script.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_UTIL_SCRIPT_H
-#define APACHE_UTIL_SCRIPT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef APACHE_ARG_MAX
-#ifdef _POSIX_ARG_MAX
-#define APACHE_ARG_MAX _POSIX_ARG_MAX
-#else
-#define APACHE_ARG_MAX 512
-#endif
-#endif
-
-API_EXPORT(char **) ap_create_environment(ap_context_t *p, ap_table_t *t);
-API_EXPORT(int) ap_find_path_info(const char *uri, const char *path_info);
-API_EXPORT(void) ap_add_cgi_vars(request_rec *r);
-API_EXPORT(void) ap_add_common_vars(request_rec *r);
-API_EXPORT(int) ap_scan_script_header_err(request_rec *r, ap_file_t *f, char *buffer);
-API_EXPORT(int) ap_scan_script_header_err_buff(request_rec *r, BUFF *f,
- char *buffer);
-API_EXPORT(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
- int (*getsfunc) (char *, int, void *),
- void *getsfunc_data);
-API_EXPORT(void) ap_send_size(ap_ssize_t size, request_rec *r);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_UTIL_SCRIPT_H */
diff --git a/include/util_uri.h b/include/util_uri.h
deleted file mode 100644
index 6210c813cd..0000000000
--- a/include/util_uri.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * util_uri.h: External Interface of util_uri.c
- */
-
-#ifndef UTIL_URI_H
-#define UTIL_URI_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- const char *name;
- unsigned short default_port;
-} schemes_t;
-
-#define DEFAULT_FTP_DATA_PORT 20
-#define DEFAULT_FTP_PORT 21
-#define DEFAULT_GOPHER_PORT 70
-#define DEFAULT_NNTP_PORT 119
-#define DEFAULT_WAIS_PORT 210
-#define DEFAULT_SNEWS_PORT 563
-#define DEFAULT_PROSPERO_PORT 1525 /* WARNING: conflict w/Oracle */
-
-/* Flags passed to unparse_uri_components(): */
-#define UNP_OMITSITEPART (1U<<0) /* suppress "scheme://user@site:port" */
-#define UNP_OMITUSER (1U<<1) /* Just omit user */
-#define UNP_OMITPASSWORD (1U<<2) /* Just omit password */
-#define UNP_OMITUSERINFO (UNP_OMITUSER|UNP_OMITPASSWORD) /* omit "user:password@" part */
-#define UNP_REVEALPASSWORD (1U<<3) /* Show plain text password (default: show XXXXXXXX) */
-#define UNP_OMITPATHINFO (1U<<4) /* Show "scheme://user@site:port" only */
-#define UNP_OMITQUERY (1U<<5) /* Omit the "?queryarg" from the path */
-
-typedef struct {
- char *scheme; /* scheme ("http"/"ftp"/...) */
- char *hostinfo; /* combined [user[:password]@]host[:port] */
- char *user; /* user name, as in http://user:passwd@host:port/ */
- char *password; /* password, as in http://user:passwd@host:port/ */
- char *hostname; /* hostname from URI (or from Host: header) */
- char *port_str; /* port string (integer representation is in "port") */
- char *path; /* the request path (or "/" if only scheme://host was given) */
- char *query; /* Everything after a '?' in the path, if present */
- char *fragment; /* Trailing "#fragment" string, if present */
-
- struct hostent *hostent;
-
- unsigned short port; /* The port number, numeric, valid only if port_str != NULL */
-
- unsigned is_initialized:1;
-
- unsigned dns_looked_up:1;
- unsigned dns_resolved:1;
-
-} uri_components;
-
-/* 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(ap_context_t *p, const struct hostent *hp);
-API_EXPORT(struct hostent *) ap_pgethostbyname(ap_context_t *p, const char *hostname);
-API_EXPORT(char *) ap_unparse_uri_components(ap_context_t *p, const uri_components *uptr,
- unsigned flags);
-API_EXPORT(int) ap_parse_uri_components(ap_context_t *p, const char *uri, uri_components *uptr);
-API_EXPORT(int) ap_parse_hostinfo_components(ap_context_t *p, const char *hostinfo, uri_components *uptr);
-/* called by the core in main() */
-extern void ap_util_uri_init(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*UTIL_URI_H*/
diff --git a/libhttpd.def b/libhttpd.def
deleted file mode 100644
index 312311533f..0000000000
--- a/libhttpd.def
+++ /dev/null
@@ -1,396 +0,0 @@
-; apachecore.def :
-
-LIBRARY ApacheCore
-DESCRIPTION ''
-
-EXPORTS
- ; Add new API calls to the end of this list.
-; ap_MD5Final @1
-; ap_MD5Init @2
-; ap_MD5Update @3
-; ap_acquire_mutex @4
- ap_add_cgi_vars @5
- ap_add_common_vars @6
- ap_add_loaded_module @7
- ap_add_module @8
- ap_add_named_module @9
- ap_add_per_dir_conf @10
- ap_add_per_url_conf @11
- ;ap_add_version_component @12
- ap_allow_options @13
- ap_allow_overrides @14
-; ap_append_arrays @15
-; ap_array_cat @16
- ap_auth_name @17
- ap_auth_type @18
- ap_basic_http_header @19
- ap_bclose @20
- ap_bcreate @21
- ap_bfilbuf @22
- ;ap_bfileno @23
- ap_bflsbuf @24
- ap_bflush @25
- ap_bgetopt @26
- ap_bgets @27
- ;ap_bhalfduplex @28
- ;ap_block_alarms @29
- ap_blookc @30
- ;ap_bnonblock @31
- ap_bonerror @32
- ;ap_bpushfd @33
- ;ap_bpushh @34
- ap_bputs @35
- ap_bread @36
- ap_bsetflag @37
- ap_bsetopt @38
- ;ap_bskiplf @39
-; ap_bspawn_child @40
- ap_bwrite @41
- ;ap_bytes_in_free_blocks @42
- ;ap_bytes_in_pool @43
-; ap_call_exec @44
- ;ap_can_exec @45
- ap_cfg_closefile @46
- ap_cfg_getc @47
- ap_cfg_getline @48
- ap_chdir_file @49
- ;ap_check_alarm @50
- ap_check_cmd_context @51
- ap_checkmask @52
-; ap_cleanup_for_exec @53
- ap_clear_module_list @54
-; ap_clear_pool @55
-; ap_clear_table @56
- ap_close_piped_log @57
- ap_construct_server @58
- ap_construct_url @59
- ap_content_type_tolower @60
-; ap_copy_array @61
-; ap_copy_array_hdr @62
-; ap_copy_table @63
- ap_count_dirs @64
-; ap_cpystrn @65
- ap_create_environment @66
-; ap_create_mutex @67
- ap_create_per_dir_config @68
- ap_custom_response @69
- ap_default_port_for_request @70
- ap_default_port_for_scheme @71
- ap_default_type @72
-; ap_destroy_mutex @73
-; ap_destroy_pool @74
- ap_destroy_sub_req @75
- ap_die @76
- ap_discard_request_body @77
- ap_document_root @78
- ap_each_byterange @79
- ap_error_log2stderr @80
- ap_escape_html @81
- ap_escape_path_segment @82
- ap_escape_quotes @83
- ap_escape_shell_cmd @84
- ;ap_exists_scoreboard_image @85
- ap_finalize_request_protocol @86
- ap_find_command @87
- ap_find_command_in_modules @88
- ap_find_last_token @89
- ap_find_linked_module @90
- ap_find_module_name @91
- ap_find_path_info @92
- ap_find_token @93
- ap_get_basic_auth_pw @94
- ap_get_client_block @95
-; ap_get_gmtoff @96
- ap_get_limit_req_body @97
- ap_get_remote_host @98
- ap_get_remote_logname @99
- ap_get_server_built @100
- ap_get_server_name @101
- ap_get_server_port @102
- ;ap_get_server_version @103
-; ap_get_time @104
- ap_get_token @105
- ap_getparents @106
- ap_getword @107
- ap_getword_conf @108
- ap_getword_conf_nc @109
- ap_getword_nc @110
- ap_getword_nulls @111
- ap_getword_nulls_nc @112
- ap_getword_white @113
- ap_getword_white_nc @114
-; ap_gm_timestr_822 @115
- ap_gname2id @116
- ap_handle_command @117
- ;ap_hard_timeout @118
- ap_ht_time @119
- ap_ind @120
- ap_index_of_response @121
- ap_init_virtual_host @122
- ap_internal_redirect @123
- ap_internal_redirect_handler @124
- ap_is_directory @125
-; ap_is_fnmatch @126
- ap_is_initial_req @127
- ap_is_matchexp @128
- ap_is_url @129
-; ap_kill_cleanup @130
-; ap_kill_cleanups_for_fd @131
-; ap_kill_cleanups_for_socket @132
- ;ap_kill_timeout @133
- ap_log_assert @134
- ap_log_error_old @135
- ap_log_reason @136
- ap_log_unixerr @137
-; ap_make_array @138
- ap_make_dirstr @139
- ap_make_dirstr_parent @140
- ap_make_dirstr_prefix @141
- ap_make_full_path @142
-; ap_make_sub_pool @143
-; ap_make_table @144
- ap_matches_request_vhost @145
- ap_md5 @146
- ap_md5_binary @147
- ap_md5contextTo64 @148
- ap_md5digest @149
- ap_meets_conditions @150
- ap_no2slash @151
- ap_note_auth_failure @152
- ap_note_basic_auth_failure @153
-; ap_note_cleanups_for_fd @154
-; ap_note_cleanups_for_file @155
-; ap_note_cleanups_for_h @156
-; ap_note_cleanups_for_socket @157
- ap_note_digest_auth_failure @158
-; ap_note_subprocess @159
-; ap_open_mutex @160
- ap_open_piped_log @161
- ap_os_canonical_filename @162
- ap_os_escape_path @163
-; ap_overlap_tables @164
-; ap_overlay_tables @165
-; ap_palloc @166
- ap_parseHTTPdate @167
- ap_parse_hostinfo_components @168
- ap_parse_uri @169
- ap_parse_uri_components @170
-; ap_pcalloc @171
- ap_pcfg_open_custom @172
- ap_pcfg_openfile @173
-; ap_pclosedir @174
-; ap_pclosef @175
-; ap_pcloseh @176
-; ap_pclosesocket @177
- ap_pduphostent @178
-; ap_pfclose @179
-; ap_pfdopen @180
-; ap_pfopen @181
- ap_pgethostbyname @182
-; ap_popendir @183
-; ap_popenf @184
- ap_pregcomp @185
- ap_pregfree @186
- ap_pregsub @187
- ap_psignature @188
-; ap_psocket @189
-; ap_pstrdup @190
-; ap_pstrndup @191
-; ap_push_array @192
-; ap_pvsprintf @193
- ap_rationalize_mtime @194
-; ap_register_cleanup @195
-; ap_release_mutex @196
- ap_remove_loaded_module @197
- ap_remove_module @198
- ap_requires @199
- ;ap_reset_timeout @200
- ap_rflush @201
- ap_rind @202
- ap_rputc @203
- ap_rputs @204
-; ap_run_cleanup @205
- ap_run_sub_req @206
- ap_rwrite @207
- ap_satisfies @208
- ap_scan_script_header_err @209
- ap_scan_script_header_err_buff @210
- ap_scan_script_header_err_core @211
- ;ap_send_fb @212
- ;ap_send_fb_length @213
- ap_send_fd @214
- ap_send_fd_length @215
- ap_send_http_header @216
- ap_send_http_trace @217
-; ap_send_mmap @218
- ap_send_size @219
- ap_server_root_relative @220
- ap_set_byterange @221
- ap_set_content_length @222
- ap_set_etag @223
- ap_set_keepalive @224
- ap_set_last_modified @225
- ap_setup_client_block @226
- ap_should_client_block @227
- ;ap_soft_timeout @228
- ap_some_auth_required @229
-; ap_spawn_child @230
- ap_srm_command_loop @231
- ap_str_tolower @232
- ap_strcasecmp_match @233
- ap_strcmp_match @234
- ap_sub_req_lookup_file @235
- ap_sub_req_lookup_uri @236
- ;ap_sync_scoreboard_image @237
-; ap_table_add @238
-; ap_table_addn @239
-; ap_table_get @240
-; ap_table_merge @241
-; ap_table_mergen @242
-; ap_table_set @243
-; ap_table_setn @244
-; ap_table_unset @245
-; ap_tm2sec @246
- ap_uname2id @247
- ;ap_unblock_alarms @248
- ap_unescape_url @249
- ap_unparse_uri_components @250
- ap_update_mtime @251
- ap_uudecode @252
- ap_uuencode @253
- ap_vbprintf @254
-; ap_vformatter @255
-; ap_vsnprintf @256
- closedir @257
- opendir @258
-; os_spawnv @259
-; os_spawnve @260
- os_stat @261
- readdir @262
- regcomp @263
- regexec @264
- regfree @265
- access_module @266
- alias_module @267
- ap_bprintf @268
- ap_bvputs @269
-; ap_day_snames @270
- ;ap_extended_status @271
- ap_limit_section @272
- ap_loaded_modules @273
- ap_log_error @274
- ap_log_printf @275
- ap_log_rerror @276
-; ap_month_snames @277
-; ap_null_cleanup @278
-; ap_psprintf @279
-; ap_pstrcat @280
- ;ap_restart_time @281
- ap_rprintf @282
- ap_rvputs @283
- ;ap_scoreboard_image @284
- ap_send_header_field @285
- ap_server_argv0 @286
- ap_server_root @287
- ap_set_file_slot @288
- ap_set_flag_slot @289
- ap_set_string_slot @290
- ap_set_string_slot_lower @291
-; ap_snprintf @292
- ;ap_suexec_enabled @293
-; ap_table_do @294
- apache_main @295
- asis_module @296
- auth_module @297
- autoindex_module @298
- ;cgi_module @299
- config_log_module @300
- core_module @301
- dir_module @302
- env_module @303
- imap_module @304
- ;includes_module @305
- mime_module @306
- negotiation_module @307
-; os_spawnle @308
- setenvif_module @309
- ;so_module @310
- top_module @311
-; ap_fnmatch @312
- ap_method_number_of @313
- ap_exists_config_define @314
- ap_single_module_configure @315
- ap_make_etag @317
-; ap_array_pstrcat @318
- ap_os_is_filename_valid @319
- ap_find_list_item @320
-; ap_MD5Encode @321
-; ap_validate_password @322
- ap_size_list_item @323
- ap_get_list_item @324
- ;ap_scoreboard_fname @325
- ;ap_pid_fname @326
- ;ap_excess_requests_per_child @327
- ;ap_threads_per_child @328
- ;ap_max_requests_per_child @329
- ;ap_daemons_to_start @330
- ;ap_daemons_min_free @331
- ;ap_daemons_max_free @332
- ;ap_daemons_limit @333
- ;ap_user_name @334
- ;ap_user_id @335
- ;ap_group_id @336
- ;ap_standalone @337
- ;ap_server_confname @338
- ap_sub_req_method_uri @339
- ap_regerror @341
- ap_regexec @342
- ap_field_noparam @343
- ap_pbase64decode @344
- ap_pbase64encode @345
- ap_base64encode @346
- ap_base64encode_binary @347
- ap_base64encode_len @348
- ap_base64decode @349
- ap_base64decode_binary @350
- ap_base64decode_len @351
- ap_SHA1Init @352
- ap_SHA1Update_binary @353
- ap_SHA1Update @354
- ap_SHA1Final @355
- ap_sha1_base64 @356
- ap_show_hook @357
- ap_hook_sort_register @358
- ap_hook_process_connection @359
- ap_process_http_connection @360
- ap_hook_check_user_id @361
- ap_hook_auth_checker @362
- ap_hook_fixups @363
- regerror @364
- ap_send_error_response @365
- ap_start_shutdown @366
- send_signal_to_service @367
- ap_read_config @368
- ap_server_pre_read_config @369
- ap_server_post_read_config @370
- ap_setup_prelinked_modules @371
- RemoveService @372
- InstallService @373
- isValidService @374
- service_main @375
- isProcessService @376
- ap_registry_get_server_root @377
- ap_registry_get_service_conf @378
- ap_hook_pre_connection @379
- ap_hook_post_read_request @380
- ap_hook_log_transaction @381
- ap_hook_http_method @382
- ap_hook_default_port @383
- ap_hook_translate_name @384
- ap_hook_type_checker @385
- ap_hook_access_checker @386
- ap_hook_header_parser @387
- ap_hook_pre_config @388
- ap_hook_post_config @389
- ap_hook_open_logs @390
- ap_hook_child_init @391
diff --git a/modules/.cvsignore b/modules/.cvsignore
deleted file mode 100644
index f3c7a7c5da..0000000000
--- a/modules/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-Makefile
diff --git a/modules/Makefile.in b/modules/Makefile.in
deleted file mode 100644
index da8a82274b..0000000000
--- a/modules/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-
-DEPTH = ..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-SUBDIRS = mpm $(MODULE_DIRS)
-
-include $(topsrcdir)/build/rules.mk
-
diff --git a/modules/README b/modules/README
deleted file mode 100644
index 3d9bd22608..0000000000
--- a/modules/README
+++ /dev/null
@@ -1,30 +0,0 @@
-The directory structure for this level is as follows:
-
-standard/
-
- In this directory are the standard supported modules for
- Apache. Not all are compiled by default.
-
-proxy/
-
- This houses the code for the proxy module for Apache.
-
-experimental/
-
- In this directory we've placed some modules which we think
- provide some pretty interesting functionality, but which
- are still in the early stages of development and could
- evolve radically in the future. This code isn't supported
- officially.
-
-test/
-
- This directory houses modules which test various components
- of Apache. You should not compile these into a production
- server.
-
-example/
-
- This directory houses example modules, to help module authors
- figure their way around the Apache API and module concept.
-
diff --git a/modules/aaa/.cvsignore b/modules/aaa/.cvsignore
deleted file mode 100644
index f2f7a70d2c..0000000000
--- a/modules/aaa/.cvsignore
+++ /dev/null
@@ -1,10 +0,0 @@
-.deps
-.libs
-*.la
-modules.mk
-Makefile
-*.lo
-*.slo
-*.so
-*.dll
-*.def
diff --git a/modules/aaa/.indent.pro b/modules/aaa/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/aaa/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/aaa/Makefile.in b/modules/aaa/Makefile.in
deleted file mode 100644
index ccd3c19755..0000000000
--- a/modules/aaa/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-
-DEPTH = ../..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-include $(topsrcdir)/build/special.mk
-
diff --git a/modules/aaa/config.m4 b/modules/aaa/config.m4
deleted file mode 100644
index 5a915530ad..0000000000
--- a/modules/aaa/config.m4
+++ /dev/null
@@ -1,60 +0,0 @@
-dnl modules enabled in this directory by default
-
-dnl AC_DEFUN(modulename, modulestructname, defaultonoroff, configmacros)
-dnl XXX - Need to add help text to --enable-module flags
-dnl XXX - Need to allow --enable-module to fail if optional config fails
-
-AC_DEFUN(APACHE_CHECK_STANDARD_MODULE, [
- APACHE_MODULE($1,,,$2,$3,$4)
-])
-
-APACHE_MODPATH_INIT(standard)
-
-APACHE_MODULE(vhost_alias,blabla)
-
-dnl APACHE_CHECK_STANDARD_MODULE(vhost_alias, , no)
-APACHE_CHECK_STANDARD_MODULE(env, , yes)
-APACHE_CHECK_STANDARD_MODULE(log_config, config_log, yes)
-APACHE_CHECK_STANDARD_MODULE(mime_magic, , no)
-APACHE_CHECK_STANDARD_MODULE(mime, , yes)
-APACHE_CHECK_STANDARD_MODULE(negotiation, , yes)
-APACHE_CHECK_STANDARD_MODULE(status, , no)
-APACHE_CHECK_STANDARD_MODULE(include, includes, yes)
-APACHE_CHECK_STANDARD_MODULE(autoindex, , yes)
-APACHE_CHECK_STANDARD_MODULE(dir, , yes)
-APACHE_CHECK_STANDARD_MODULE(cgi, , yes)
-APACHE_CHECK_STANDARD_MODULE(asis, , yes)
-APACHE_CHECK_STANDARD_MODULE(imap, , yes)
-APACHE_CHECK_STANDARD_MODULE(actions, action, yes)
-APACHE_CHECK_STANDARD_MODULE(speling, , no)
-APACHE_CHECK_STANDARD_MODULE(userdir, , yes)
-APACHE_CHECK_STANDARD_MODULE(alias, , yes)
-APACHE_CHECK_STANDARD_MODULE(rewrite, , no)
-APACHE_CHECK_STANDARD_MODULE(access, , yes)
-APACHE_CHECK_STANDARD_MODULE(auth, , yes)
-APACHE_CHECK_STANDARD_MODULE(auth_anon, , no)
-APACHE_CHECK_STANDARD_MODULE(auth_dbm, , no)
-APACHE_CHECK_STANDARD_MODULE(auth_db, , no)
-APACHE_CHECK_STANDARD_MODULE(auth_digest, , no)
-APACHE_CHECK_STANDARD_MODULE(cern_meta, , no)
-APACHE_CHECK_STANDARD_MODULE(expires, , no)
-APACHE_CHECK_STANDARD_MODULE(headers, , no)
-
-APACHE_CHECK_STANDARD_MODULE(usertrack, , no, [
- AC_CHECK_HEADERS(sys/times.h)
- AC_CHECK_FUNCS(times)
-])
-
-APACHE_CHECK_STANDARD_MODULE(unique_id, , no)
-APACHE_CHECK_STANDARD_MODULE(so, , no)
-APACHE_CHECK_STANDARD_MODULE(setenvif, , yes)
-APACHE_CHECK_STANDARD_MODULE(echo, , yes)
-
-APACHE_MODPATH_FINISH
-
-if test "$sharedobjs" = "yes"; then
- LIBS="$LIBS -ldl"
- LTFLAGS="$LTFLAGS -export-dynamic"
-fi
-
-APACHE_SUBST(STANDARD_LIBS)
diff --git a/modules/aaa/mod_access.c b/modules/aaa/mod_access.c
deleted file mode 100644
index 752bbe46a4..0000000000
--- a/modules/aaa/mod_access.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * Security options etc.
- *
- * Module derived from code originally written by Rob McCool
- *
- */
-
-#include "apr_network_io.h"
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_core.h"
-#include "http_config.h"
-#include "http_log.h"
-#include "http_request.h"
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-enum allowdeny_type {
- T_ENV,
- T_ALL,
- T_IP,
- T_HOST,
- T_FAIL
-};
-
-typedef struct {
- int limited;
- union {
- char *from;
- struct {
- unsigned long net;
- unsigned long mask;
- } ip;
- } x;
- enum allowdeny_type type;
-} allowdeny;
-
-/* things in the 'order' array */
-#define DENY_THEN_ALLOW 0
-#define ALLOW_THEN_DENY 1
-#define MUTUAL_FAILURE 2
-
-typedef struct {
- int order[METHODS];
- ap_array_header_t *allows;
- ap_array_header_t *denys;
-} access_dir_conf;
-
-module MODULE_VAR_EXPORT access_module;
-
-static void *create_access_dir_config(ap_context_t *p, char *dummy)
-{
- access_dir_conf *conf =
- (access_dir_conf *) ap_pcalloc(p, sizeof(access_dir_conf));
- int i;
-
- for (i = 0; i < METHODS; ++i)
- conf->order[i] = DENY_THEN_ALLOW;
- conf->allows = ap_make_array(p, 1, sizeof(allowdeny));
- conf->denys = ap_make_array(p, 1, sizeof(allowdeny));
-
- return (void *) conf;
-}
-
-static const char *order(cmd_parms *cmd, void *dv, char *arg)
-{
- access_dir_conf *d = (access_dir_conf *) dv;
- int i, o;
-
- if (!strcasecmp(arg, "allow,deny"))
- o = ALLOW_THEN_DENY;
- else if (!strcasecmp(arg, "deny,allow"))
- o = DENY_THEN_ALLOW;
- else if (!strcasecmp(arg, "mutual-failure"))
- o = MUTUAL_FAILURE;
- else
- return "unknown order";
-
- for (i = 0; i < METHODS; ++i)
- if (cmd->limited & (1 << i))
- d->order[i] = o;
-
- return NULL;
-}
-
-static int is_ip(const char *host)
-{
- while ((*host == '.') || ap_isdigit(*host))
- host++;
- return (*host == '\0');
-}
-
-static const char *allow_cmd(cmd_parms *cmd, void *dv, char *from, char *where)
-{
- access_dir_conf *d = (access_dir_conf *) dv;
- allowdeny *a;
- char *s;
-
- if (strcasecmp(from, "from"))
- return "allow and deny must be followed by 'from'";
-
- a = (allowdeny *) ap_push_array(cmd->info ? d->allows : d->denys);
- a->x.from = where;
- a->limited = cmd->limited;
-
- if (!strncasecmp(where, "env=", 4)) {
- a->type = T_ENV;
- a->x.from += 4;
-
- }
- else if (!strcasecmp(where, "all")) {
- a->type = T_ALL;
-
- }
- else if ((s = strchr(where, '/'))) {
- unsigned long mask;
-
- a->type = T_IP;
- /* trample on where, we won't be using it any more */
- *s++ = '\0';
-
- if (!is_ip(where)
- || (a->x.ip.net = ap_inet_addr(where)) == INADDR_NONE) {
- a->type = T_FAIL;
- return "syntax error in network portion of network/netmask";
- }
-
- /* is_ip just tests if it matches [\d.]+ */
- if (!is_ip(s)) {
- a->type = T_FAIL;
- return "syntax error in mask portion of network/netmask";
- }
- /* is it in /a.b.c.d form? */
- if (strchr(s, '.')) {
- mask = ap_inet_addr(s);
- if (mask == INADDR_NONE) {
- a->type = T_FAIL;
- return "syntax error in mask portion of network/netmask";
- }
- }
- else {
- /* assume it's in /nnn form */
- mask = atoi(s);
- if (mask > 32 || mask <= 0) {
- a->type = T_FAIL;
- return "invalid mask in network/netmask";
- }
- mask = 0xFFFFFFFFUL << (32 - mask);
- mask = htonl(mask);
- }
- a->x.ip.mask = mask;
- a->x.ip.net = (a->x.ip.net & mask); /* pjr - This fixes PR 4770 */
- }
- else if (ap_isdigit(*where) && is_ip(where)) {
- /* legacy syntax for ip addrs: a.b.c. ==> a.b.c.0/24 for example */
- int shift;
- char *t;
- int octet;
-
- a->type = T_IP;
- /* parse components */
- s = where;
- a->x.ip.net = 0;
- a->x.ip.mask = 0;
- shift = 24;
- while (*s) {
- t = s;
- if (!ap_isdigit(*t)) {
- a->type = T_FAIL;
- return "invalid ip address";
- }
- while (ap_isdigit(*t)) {
- ++t;
- }
- if (*t == '.') {
- *t++ = 0;
- }
- else if (*t) {
- a->type = T_FAIL;
- return "invalid ip address";
- }
- if (shift < 0) {
- return "invalid ip address, only 4 octets allowed";
- }
- octet = atoi(s);
- if (octet < 0 || octet > 255) {
- a->type = T_FAIL;
- return "each octet must be between 0 and 255 inclusive";
- }
- a->x.ip.net |= octet << shift;
- a->x.ip.mask |= 0xFFUL << shift;
- s = t;
- shift -= 8;
- }
- a->x.ip.net = ntohl(a->x.ip.net);
- a->x.ip.mask = ntohl(a->x.ip.mask);
- }
- else {
- a->type = T_HOST;
- }
-
- return NULL;
-}
-
-static char its_an_allow;
-
-static const command_rec access_cmds[] =
-{
- {"order", order, NULL, OR_LIMIT, TAKE1,
- "'allow,deny', 'deny,allow', or 'mutual-failure'"},
- {"allow", allow_cmd, &its_an_allow, OR_LIMIT, ITERATE2,
- "'from' followed by hostnames or IP-address wildcards"},
- {"deny", allow_cmd, NULL, OR_LIMIT, ITERATE2,
- "'from' followed by hostnames or IP-address wildcards"},
- {NULL}
-};
-
-static int in_domain(const char *domain, const char *what)
-{
- int dl = strlen(domain);
- int wl = strlen(what);
-
- if ((wl - dl) >= 0) {
- if (strcasecmp(domain, &what[wl - dl]) != 0)
- return 0;
-
- /* Make sure we matched an *entire* subdomain --- if the user
- * said 'allow from good.com', we don't want people from nogood.com
- * to be able to get in.
- */
-
- if (wl == dl)
- return 1; /* matched whole thing */
- else
- return (domain[0] == '.' || what[wl - dl - 1] == '.');
- }
- else
- return 0;
-}
-
-static int find_allowdeny(request_rec *r, ap_array_header_t *a, int method)
-{
- allowdeny *ap = (allowdeny *) a->elts;
- int mmask = (1 << method);
- int i;
- int gothost = 0;
- const char *remotehost = NULL;
-
- for (i = 0; i < a->nelts; ++i) {
- if (!(mmask & ap[i].limited))
- continue;
-
- switch (ap[i].type) {
- case T_ENV:
- if (ap_table_get(r->subprocess_env, ap[i].x.from)) {
- return 1;
- }
- break;
-
- case T_ALL:
- return 1;
-
- case T_IP:
- if (ap[i].x.ip.net != INADDR_NONE
- && (r->connection->remote_addr.sin_addr.s_addr
- & ap[i].x.ip.mask) == ap[i].x.ip.net) {
- return 1;
- }
- break;
-
- case T_HOST:
- if (!gothost) {
- remotehost = ap_get_remote_host(r->connection, r->per_dir_config,
- REMOTE_DOUBLE_REV);
-
- if ((remotehost == NULL) || is_ip(remotehost))
- gothost = 1;
- else
- gothost = 2;
- }
-
- if ((gothost == 2) && in_domain(ap[i].x.from, remotehost))
- return 1;
- break;
-
- case T_FAIL:
- /* do nothing? */
- break;
- }
- }
-
- return 0;
-}
-
-static int check_dir_access(request_rec *r)
-{
- int method = r->method_number;
- access_dir_conf *a =
- (access_dir_conf *)
- ap_get_module_config(r->per_dir_config, &access_module);
- int ret = OK;
-
- if (a->order[method] == ALLOW_THEN_DENY) {
- ret = FORBIDDEN;
- if (find_allowdeny(r, a->allows, method))
- ret = OK;
- if (find_allowdeny(r, a->denys, method))
- ret = FORBIDDEN;
- }
- else if (a->order[method] == DENY_THEN_ALLOW) {
- if (find_allowdeny(r, a->denys, method))
- ret = FORBIDDEN;
- if (find_allowdeny(r, a->allows, method))
- ret = OK;
- }
- else {
- if (find_allowdeny(r, a->allows, method)
- && !find_allowdeny(r, a->denys, method))
- ret = OK;
- else
- ret = FORBIDDEN;
- }
-
- if (ret == FORBIDDEN
- && (ap_satisfies(r) != SATISFY_ANY || !ap_some_auth_required(r))) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "client denied by server configuration: %s",
- r->filename);
- }
-
- return ret;
-}
-
-static void register_hooks(void)
-{
- ap_hook_access_checker(check_dir_access,NULL,NULL,HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT access_module =
-{
- STANDARD20_MODULE_STUFF,
- create_access_dir_config, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- access_cmds,
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/aaa/mod_access.exp b/modules/aaa/mod_access.exp
deleted file mode 100644
index f8aff339da..0000000000
--- a/modules/aaa/mod_access.exp
+++ /dev/null
@@ -1 +0,0 @@
-access_module
diff --git a/modules/aaa/mod_auth.c b/modules/aaa/mod_auth.c
deleted file mode 100644
index f0ed282b7a..0000000000
--- a/modules/aaa/mod_auth.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_auth: authentication
- *
- * Rob McCool
- *
- * Adapted to Apache by rst.
- *
- * dirkx - Added Authoritative control to allow passing on to lower
- * modules if and only if the userid is not known to this
- * module. A known user with a faulty or absent password still
- * causes an AuthRequired. The default is 'Authoritative', i.e.
- * no control is passed along.
- */
-
-#include "ap_config.h"
-#include "apr_md5.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_protocol.h"
-#include "http_request.h"
-
-typedef struct auth_config_struct {
- char *auth_pwfile;
- char *auth_grpfile;
- int auth_authoritative;
-} auth_config_rec;
-
-static void *create_auth_dir_config(ap_context_t *p, char *d)
-{
- auth_config_rec *sec =
- (auth_config_rec *) ap_pcalloc(p, sizeof(auth_config_rec));
- sec->auth_pwfile = NULL; /* just to illustrate the default really */
- sec->auth_grpfile = NULL; /* unless you have a broken HP cc */
- sec->auth_authoritative = 1; /* keep the fortress secure by default */
- return sec;
-}
-
-static const char *set_auth_slot(cmd_parms *cmd, void *offset, char *f, char *t)
-{
- if (t && strcmp(t, "standard"))
- return ap_pstrcat(cmd->pool, "Invalid auth file type: ", t, NULL);
-
- return ap_set_file_slot(cmd, offset, f);
-}
-
-static const command_rec auth_cmds[] =
-{
- {"AuthUserFile", set_auth_slot,
- (void *) XtOffsetOf(auth_config_rec, auth_pwfile), OR_AUTHCFG, TAKE12,
- "text file containing user IDs and passwords"},
- {"AuthGroupFile", set_auth_slot,
- (void *) XtOffsetOf(auth_config_rec, auth_grpfile), OR_AUTHCFG, TAKE12,
- "text file containing group names and member user IDs"},
- {"AuthAuthoritative", ap_set_flag_slot,
- (void *) XtOffsetOf(auth_config_rec, auth_authoritative),
- OR_AUTHCFG, FLAG,
- "Set to 'no' to allow access control to be passed along to lower modules if the UserID is not known to this module"},
- {NULL}
-};
-
-module MODULE_VAR_EXPORT auth_module;
-
-static char *get_pw(request_rec *r, char *user, char *auth_pwfile)
-{
- configfile_t *f;
- char l[MAX_STRING_LEN];
- const char *rpw, *w;
- ap_status_t status;
-
- if ((status = ap_pcfg_openfile(&f, r->pool, auth_pwfile)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
- "Could not open password file: %s", auth_pwfile);
- return NULL;
- }
- while (!(ap_cfg_getline(l, MAX_STRING_LEN, f))) {
- if ((l[0] == '#') || (!l[0]))
- continue;
- rpw = l;
- w = ap_getword(r->pool, &rpw, ':');
-
- if (!strcmp(user, w)) {
- ap_cfg_closefile(f);
- return ap_getword(r->pool, &rpw, ':');
- }
- }
- ap_cfg_closefile(f);
- return NULL;
-}
-
-static ap_table_t *groups_for_user(ap_context_t *p, char *user, char *grpfile)
-{
- configfile_t *f;
- ap_table_t *grps = ap_make_table(p, 15);
- ap_context_t *sp;
- char l[MAX_STRING_LEN];
- const char *group_name, *ll, *w;
- ap_status_t status;
-
- if ((status = ap_pcfg_openfile(&f, p, grpfile)) != APR_SUCCESS) {
-/*add? aplog_error(APLOG_MARK, APLOG_ERR, NULL,
- "Could not open group file: %s", grpfile);*/
- return NULL;
- }
-
- ap_create_context(&sp, p);
-
- while (!(ap_cfg_getline(l, MAX_STRING_LEN, f))) {
- if ((l[0] == '#') || (!l[0]))
- continue;
- ll = l;
- ap_clear_pool(sp);
-
- group_name = ap_getword(sp, &ll, ':');
-
- while (ll[0]) {
- w = ap_getword_conf(sp, &ll);
- if (!strcmp(w, user)) {
- ap_table_setn(grps, ap_pstrdup(p, group_name), "in");
- break;
- }
- }
- }
- ap_cfg_closefile(f);
- ap_destroy_pool(sp);
- return grps;
-}
-
-/* These functions return 0 if client is OK, and proper error status
- * if not... either AUTH_REQUIRED, if we made a check, and it failed, or
- * SERVER_ERROR, if things are so totally confused that we couldn't
- * figure out how to tell if the client is authorized or not.
- *
- * If they return DECLINED, and all other modules also decline, that's
- * treated by the server core as a configuration error, logged and
- * reported as such.
- */
-
-/* Determine user ID, and check if it really is that user, for HTTP
- * basic authentication...
- */
-
-static int authenticate_basic_user(request_rec *r)
-{
- auth_config_rec *sec =
- (auth_config_rec *) ap_get_module_config(r->per_dir_config, &auth_module);
- const char *sent_pw;
- char *real_pw;
- ap_status_t invalid_pw;
- int res;
-
- if ((res = ap_get_basic_auth_pw(r, &sent_pw)))
- return res;
-
- if (!sec->auth_pwfile)
- return DECLINED;
-
- if (!(real_pw = get_pw(r, r->user, sec->auth_pwfile))) {
- if (!(sec->auth_authoritative))
- return DECLINED;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "user %s not found: %s", r->user, r->uri);
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- invalid_pw = ap_validate_password(sent_pw, real_pw);
- if (invalid_pw != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "user %s: authentication failure for \"%s\": "
- "Password Mismatch",
- r->user, r->uri);
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- return OK;
-}
-
-/* Checking ID */
-
-static int check_user_access(request_rec *r)
-{
- auth_config_rec *sec =
- (auth_config_rec *) ap_get_module_config(r->per_dir_config, &auth_module);
- char *user = r->user;
- int m = r->method_number;
- int method_restricted = 0;
- register int x;
- const char *t, *w;
- ap_table_t *grpstatus;
- const ap_array_header_t *reqs_arr = ap_requires(r);
- require_line *reqs;
-
- /* BUG FIX: tadc, 11-Nov-1995. If there is no "requires" directive,
- * then any user will do.
- */
- if (!reqs_arr)
- return (OK);
- reqs = (require_line *) reqs_arr->elts;
-
- if (sec->auth_grpfile)
- grpstatus = groups_for_user(r->pool, user, sec->auth_grpfile);
- else
- grpstatus = NULL;
-
- for (x = 0; x < reqs_arr->nelts; x++) {
-
- if (!(reqs[x].method_mask & (1 << m)))
- continue;
-
- method_restricted = 1;
-
- t = reqs[x].requirement;
- w = ap_getword_white(r->pool, &t);
- if (!strcmp(w, "valid-user"))
- return OK;
- if (!strcmp(w, "user")) {
- while (t[0]) {
- w = ap_getword_conf(r->pool, &t);
- if (!strcmp(user, w))
- return OK;
- }
- }
- else if (!strcmp(w, "group")) {
- if (!grpstatus)
- return DECLINED; /* DBM group? Something else? */
-
- while (t[0]) {
- w = ap_getword_conf(r->pool, &t);
- if (ap_table_get(grpstatus, w))
- return OK;
- }
- } else if (sec->auth_authoritative) {
- /* if we aren't authoritative, any require directive could be
- * valid even if we don't grok it. However, if we are
- * authoritative, we can warn the user they did something wrong.
- * That something could be a missing "AuthAuthoritative off", but
- * more likely is a typo in the require directive.
- */
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "access to %s failed, reason: unknown require directive:"
- "\"%s\"", r->uri, reqs[x].requirement);
- }
- }
-
- if (!method_restricted)
- return OK;
-
- if (!(sec->auth_authoritative))
- return DECLINED;
-
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "access to %s failed, reason: user %s not allowed access",
- r->uri, user);
-
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
-}
-
-static void register_hooks(void)
-{
- ap_hook_check_user_id(authenticate_basic_user,NULL,NULL,HOOK_MIDDLE);
- ap_hook_auth_checker(check_user_access,NULL,NULL,HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT auth_module =
-{
- STANDARD20_MODULE_STUFF,
- create_auth_dir_config, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- auth_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/aaa/mod_auth.exp b/modules/aaa/mod_auth.exp
deleted file mode 100644
index 76adad0a66..0000000000
--- a/modules/aaa/mod_auth.exp
+++ /dev/null
@@ -1 +0,0 @@
-auth_module
diff --git a/modules/aaa/mod_auth_anon.c b/modules/aaa/mod_auth_anon.c
deleted file mode 100644
index 8e6abfde0d..0000000000
--- a/modules/aaa/mod_auth_anon.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * IT'S 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_auth: authentication
- *
- * Rob McCool & Brian Behlendorf.
- *
- * Adapted to Apache by rst.
- *
- * Version 0.5 May 1996
- *
- * Modified by Dirk.vanGulik@jrc.it to
- *
- * Adapted to allow anonymous logins, just like with Anon-FTP, when
- * one gives the magic user name 'anonymous' and ones email address
- * as the password.
- *
- * Just add the following tokes to your <directory> setup:
- *
- * Anonymous magic-userid [magic-userid]...
- *
- * Anonymous_MustGiveEmail [ on | off ] default = off
- * Anonymous_LogEmail [ on | off ] default = on
- * Anonymous_VerifyEmail [ on | off ] default = off
- * Anonymous_NoUserId [ on | off ] default = off
- * Anonymous_Authoritative [ on | off ] default = off
- *
- * The magic user id is something like 'anonymous', it is NOT case sensitive.
- *
- * The MustGiveEmail flag can be used to force users to enter something
- * in the password field (like an email address). Default is off.
- *
- * Furthermore the 'NoUserID' flag can be set to allow completely empty
- * usernames in as well; this can be is convenient as a single return
- * in broken GUIs like W95 is often given by the user. The Default is off.
- *
- * Dirk.vanGulik@jrc.it; http://ewse.ceo.org; http://me-www.jrc.it/~dirkx
- *
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_protocol.h"
-#include "http_request.h"
-
-typedef struct auth_anon {
- char *password;
- struct auth_anon *next;
-} auth_anon;
-
-typedef struct {
-
- auth_anon *auth_anon_passwords;
- int auth_anon_nouserid;
- int auth_anon_logemail;
- int auth_anon_verifyemail;
- int auth_anon_mustemail;
- int auth_anon_authoritative;
-
-} anon_auth_config_rec;
-
-static void *create_anon_auth_dir_config(ap_context_t *p, char *d)
-{
- anon_auth_config_rec *sec = (anon_auth_config_rec *)
- ap_pcalloc(p, sizeof(anon_auth_config_rec));
-
- if (!sec)
- return NULL; /* no memory... */
-
- /* just to illustrate the defaults really. */
- sec->auth_anon_passwords = NULL;
-
- sec->auth_anon_nouserid = 0;
- sec->auth_anon_logemail = 1;
- sec->auth_anon_verifyemail = 0;
- sec->auth_anon_mustemail = 1;
- sec->auth_anon_authoritative = 0;
- return sec;
-}
-
-static const char *anon_set_passwd_flag(cmd_parms *cmd,
- anon_auth_config_rec * sec, int arg)
-{
- sec->auth_anon_mustemail = arg;
- return NULL;
-}
-
-static const char *anon_set_userid_flag(cmd_parms *cmd,
- anon_auth_config_rec * sec, int arg)
-{
- sec->auth_anon_nouserid = arg;
- return NULL;
-}
-static const char *anon_set_logemail_flag(cmd_parms *cmd,
- anon_auth_config_rec * sec, int arg)
-{
- sec->auth_anon_logemail = arg;
- return NULL;
-}
-static const char *anon_set_verifyemail_flag(cmd_parms *cmd,
- anon_auth_config_rec * sec, int arg)
-{
- sec->auth_anon_verifyemail = arg;
- return NULL;
-}
-static const char *anon_set_authoritative_flag(cmd_parms *cmd,
- anon_auth_config_rec * sec, int arg)
-{
- sec->auth_anon_authoritative = arg;
- return NULL;
-}
-
-static const char *anon_set_string_slots(cmd_parms *cmd,
- anon_auth_config_rec * sec, char *arg)
-{
-
- auth_anon *first;
-
- if (!(*arg))
- return "Anonymous string cannot be empty, use Anonymous_NoUserId instead";
-
- /* squeeze in a record */
- first = sec->auth_anon_passwords;
-
- if (
- (!(sec->auth_anon_passwords = (auth_anon *) ap_palloc(cmd->pool, sizeof(auth_anon)))) ||
- (!(sec->auth_anon_passwords->password = arg))
- )
- return "Failed to claim memory for an anonymous password...";
-
- /* and repair the next */
- sec->auth_anon_passwords->next = first;
-
- return NULL;
-}
-
-static const command_rec anon_auth_cmds[] =
-{
- {"Anonymous", anon_set_string_slots, NULL, OR_AUTHCFG, ITERATE,
- "a space-separated list of user IDs"},
- {"Anonymous_MustGiveEmail", anon_set_passwd_flag, NULL, OR_AUTHCFG, FLAG,
- "Limited to 'on' or 'off'"},
- {"Anonymous_NoUserId", anon_set_userid_flag, NULL, OR_AUTHCFG, FLAG,
- "Limited to 'on' or 'off'"},
-{"Anonymous_VerifyEmail", anon_set_verifyemail_flag, NULL, OR_AUTHCFG, FLAG,
- "Limited to 'on' or 'off'"},
- {"Anonymous_LogEmail", anon_set_logemail_flag, NULL, OR_AUTHCFG, FLAG,
- "Limited to 'on' or 'off'"},
- {"Anonymous_Authoritative", anon_set_authoritative_flag, NULL, OR_AUTHCFG, FLAG,
- "Limited to 'on' or 'off'"},
-
- {NULL}
-};
-
-module MODULE_VAR_EXPORT anon_auth_module;
-
-static int anon_authenticate_basic_user(request_rec *r)
-{
- anon_auth_config_rec *sec =
- (anon_auth_config_rec *) ap_get_module_config(r->per_dir_config,
- &anon_auth_module);
- const char *sent_pw;
- int res = DECLINED;
-
- if ((res = ap_get_basic_auth_pw(r, &sent_pw)))
- return res;
-
- /* Ignore if we are not configured */
- if (!sec->auth_anon_passwords)
- return DECLINED;
-
- /* Do we allow an empty userID and/or is it the magic one
- */
-
- if ((!(r->user[0])) && (sec->auth_anon_nouserid)) {
- res = OK;
- }
- else {
- auth_anon *p = sec->auth_anon_passwords;
- res = DECLINED;
- while ((res == DECLINED) && (p != NULL)) {
- if (!(strcasecmp(r->user, p->password)))
- res = OK;
- p = p->next;
- }
- }
- if (
- /* username is OK */
- (res == OK)
- /* password been filled out ? */
- && ((!sec->auth_anon_mustemail) || strlen(sent_pw))
- /* does the password look like an email address ? */
- && ((!sec->auth_anon_verifyemail)
- || ((strpbrk("@", sent_pw) != NULL)
- && (strpbrk(".", sent_pw) != NULL)))) {
- if (sec->auth_anon_logemail && ap_is_initial_req(r)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, APR_SUCCESS, r,
- "Anonymous: Passwd <%s> Accepted",
- sent_pw ? sent_pw : "\'none\'");
- }
- return OK;
- }
- else {
- if (sec->auth_anon_authoritative) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, APR_SUCCESS, r,
- "Anonymous: Authoritative, Passwd <%s> not accepted",
- sent_pw ? sent_pw : "\'none\'");
- return AUTH_REQUIRED;
- }
- /* Drop out the bottom to return DECLINED */
- }
-
- return DECLINED;
-}
-
-static int check_anon_access(request_rec *r)
-{
-#ifdef NOTYET
- conn_rec *c = r->connection;
- anon_auth_config_rec *sec =
- (anon_auth_config_rec *) ap_get_module_config(r->per_dir_config,
- &anon_auth_module);
-
- if (!sec->auth_anon)
- return DECLINED;
-
- if (strcasecmp(r->connection->user, sec->auth_anon))
- return DECLINED;
-
- return OK;
-#endif
- return DECLINED;
-}
-static void register_hooks(void)
-{
- ap_hook_check_user_id(anon_authenticate_basic_user,NULL,NULL,HOOK_MIDDLE);
- ap_hook_auth_checker(check_anon_access,NULL,NULL,HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT anon_auth_module =
-{
- STANDARD20_MODULE_STUFF,
- create_anon_auth_dir_config,/* dir config creater */
- NULL, /* dir merger ensure strictness */
- NULL, /* server config */
- NULL, /* merge server config */
- anon_auth_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/aaa/mod_auth_anon.dsp b/modules/aaa/mod_auth_anon.dsp
deleted file mode 100644
index a67e58d61b..0000000000
--- a/modules/aaa/mod_auth_anon.dsp
+++ /dev/null
@@ -1,113 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheModuleAuthAnon" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheModuleAuthAnon - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleAuthAnon.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleAuthAnon.mak"\
- CFG="ApacheModuleAuthAnon - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheModuleAuthAnon - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheModuleAuthAnon - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheModuleAuthAnon - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\Release"
-# PROP BASE Intermediate_Dir ".\Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\ApacheModuleAuthAnonR"
-# PROP Intermediate_Dir ".\ApacheModuleAuthAnonR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ..\..\CoreR\ApacheCore.lib ..\..\lib\apr\Release\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheModuleAuthAnon - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\Debug"
-# PROP BASE Intermediate_Dir ".\Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\ApacheModuleAuthAnonD"
-# PROP Intermediate_Dir ".\ApacheModuleAuthAnonD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ..\..\CoreD\ApacheCore.lib ..\..\lib\apr\Debug\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheModuleAuthAnon - Win32 Release"
-# Name "ApacheModuleAuthAnon - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=..\..\modules\standard\mod_auth_anon.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\readdir.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/modules/aaa/mod_auth_anon.exp b/modules/aaa/mod_auth_anon.exp
deleted file mode 100644
index 4139896061..0000000000
--- a/modules/aaa/mod_auth_anon.exp
+++ /dev/null
@@ -1 +0,0 @@
-anon_auth_module
diff --git a/modules/aaa/mod_auth_db.c b/modules/aaa/mod_auth_db.c
deleted file mode 100644
index 34657e1ae0..0000000000
--- a/modules/aaa/mod_auth_db.c
+++ /dev/null
@@ -1,349 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * IT'S 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_auth_db: authentication
- *
- * Original work by Rob McCool & Brian Behlendorf.
- *
- * Adapted to Apache by rst (mod_auth_dbm)
- *
- * Adapted for Berkeley DB by Andrew Cohen
- *
- * mod_auth_db was based on mod_auth_dbm.
- *
- * Warning, this is not a drop in replacement for mod_auth_dbm,
- * for people wanting to switch from dbm to Berkeley DB.
- * It requires the use of AuthDBUserFile and AuthDBGroupFile
- * instead of AuthDBMUserFile AuthDBMGroupFile
- *
- * Also, in the configuration file you need to specify
- * db_auth_module rather than dbm_auth_module
- *
- * On some BSD systems (e.g. FreeBSD and NetBSD) dbm is automatically
- * mapped to Berkeley DB. You can use either mod_auth_dbm or
- * mod_auth_db. The latter makes it more obvious that it's Berkeley.
- * On other platforms where you want to use the DB library you
- * usually have to install it first. See http://www.sleepycat.com/
- * for the distribution. The interface this module uses is the
- * one from DB version 1.85 and 1.86, but DB version 2.x
- * can also be used when compatibility mode is enabled.
- *
- * dirkx - Added Authoritative control to allow passing on to lower
- * modules if and only if the userid is not known to this
- * module. A known user with a faulty or absent password still
- * causes an AuthRequired. The default is 'Authoritative', i.e.
- * no control is passed along.
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_protocol.h"
-#ifdef HAVE_DB_H
-#include <db.h>
-#endif
-
-#if defined(DB_VERSION_MAJOR) && (DB_VERSION_MAJOR == 2)
-#define DB2
-#endif
-
-typedef struct {
-
- char *auth_dbpwfile;
- char *auth_dbgrpfile;
- int auth_dbauthoritative;
-} db_auth_config_rec;
-
-static void *create_db_auth_dir_config(ap_context_t *p, char *d)
-{
- db_auth_config_rec *sec
- = (db_auth_config_rec *) ap_pcalloc(p, sizeof(db_auth_config_rec));
- sec->auth_dbpwfile = NULL;
- sec->auth_dbgrpfile = NULL;
- sec->auth_dbauthoritative = 1; /* fortress is secure by default */
- return sec;
-}
-
-static const char *set_db_slot(cmd_parms *cmd, void *offset, char *f, char *t)
-{
- if (!t || strcmp(t, "db"))
- return DECLINE_CMD;
-
- return ap_set_file_slot(cmd, offset, f);
-}
-
-static const command_rec db_auth_cmds[] =
-{
- {"AuthDBUserFile", ap_set_file_slot,
- (void *) XtOffsetOf(db_auth_config_rec, auth_dbpwfile),
- OR_AUTHCFG, TAKE1, NULL},
- {"AuthDBGroupFile", ap_set_file_slot,
- (void *) XtOffsetOf(db_auth_config_rec, auth_dbgrpfile),
- OR_AUTHCFG, TAKE1, NULL},
- {"AuthUserFile", set_db_slot,
- (void *) XtOffsetOf(db_auth_config_rec, auth_dbpwfile),
- OR_AUTHCFG, TAKE12, NULL},
- {"AuthGroupFile", set_db_slot,
- (void *) XtOffsetOf(db_auth_config_rec, auth_dbgrpfile),
- OR_AUTHCFG, TAKE12, NULL},
- {"AuthDBAuthoritative", ap_set_flag_slot,
- (void *) XtOffsetOf(db_auth_config_rec, auth_dbauthoritative),
- OR_AUTHCFG, FLAG,
- "Set to 'no' to allow access control to be passed along to lower modules if the userID is not known to this module"},
- {NULL}
-};
-
-module db_auth_module;
-
-static char *get_db_pw(request_rec *r, char *user, const char *auth_dbpwfile)
-{
- DB *f;
- DBT d, q;
- char *pw = NULL;
-
- memset(&d, 0, sizeof(d));
- memset(&q, 0, sizeof(q));
-
- q.data = user;
- q.size = strlen(q.data);
-
-#ifdef DB2
- if (db_open(auth_dbpwfile, DB_HASH, DB_RDONLY, 0664, NULL, NULL, &f) != 0) {
-#else
- if (!(f = dbopen(auth_dbpwfile, O_RDONLY, 0664, DB_HASH, NULL))) {
-#endif
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "could not open db auth file: %s", auth_dbpwfile);
- return NULL;
- }
-
-#ifdef DB2
- if (!((f->get) (f, NULL, &q, &d, 0))) {
-#else
- if (!((f->get) (f, &q, &d, 0))) {
-#endif
- pw = ap_palloc(r->pool, d.size + 1);
- strncpy(pw, d.data, d.size);
- pw[d.size] = '\0'; /* Terminate the string */
- }
-
-#ifdef DB2
- (f->close) (f, 0);
-#else
- (f->close) (f);
-#endif
- return pw;
-}
-
-/* We do something strange with the group file. If the group file
- * contains any : we assume the format is
- * key=username value=":"groupname [":"anything here is ignored]
- * otherwise we now (0.8.14+) assume that the format is
- * key=username value=groupname
- * The first allows the password and group files to be the same
- * physical DB file; key=username value=password":"groupname[":"anything]
- *
- * mark@telescope.org, 22Sep95
- */
-
-static char *get_db_grp(request_rec *r, char *user, const char *auth_dbgrpfile)
-{
- char *grp_data = get_db_pw(r, user, auth_dbgrpfile);
- char *grp_colon;
- char *grp_colon2;
-
- if (grp_data == NULL)
- return NULL;
-
- if ((grp_colon = strchr(grp_data, ':')) != NULL) {
- grp_colon2 = strchr(++grp_colon, ':');
- if (grp_colon2)
- *grp_colon2 = '\0';
- return grp_colon;
- }
- return grp_data;
-}
-
-static int db_authenticate_basic_user(request_rec *r)
-{
- db_auth_config_rec *sec =
- (db_auth_config_rec *) ap_get_module_config(r->per_dir_config,
- &db_auth_module);
- const char *sent_pw;
- char *real_pw, *colon_pw;
- char *invalid_pw;
- int res;
-
- if ((res = ap_get_basic_auth_pw(r, &sent_pw)))
- return res;
-
- if (!sec->auth_dbpwfile)
- return DECLINED;
-
- if (!(real_pw = get_db_pw(r, r->user, sec->auth_dbpwfile))) {
- if (!(sec->auth_dbauthoritative))
- return DECLINED;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "DB user %s not found: %s", r->user, r->filename);
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- /* Password is up to first : if exists */
- colon_pw = strchr(real_pw, ':');
- if (colon_pw) {
- *colon_pw = '\0';
- }
- invalid_pw = ap_validate_password(sent_pw, real_pw);
- if (invalid_pw != NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "DB user %s: authentication failure for \"%s\": %s",
- r->user, r->uri, invalid_pw);
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- return OK;
-}
-
-/* Checking ID */
-
-static int db_check_auth(request_rec *r)
-{
- db_auth_config_rec *sec =
- (db_auth_config_rec *) ap_get_module_config(r->per_dir_config,
- &db_auth_module);
- char *user = r->user;
- int m = r->method_number;
-
- const ap_array_header_t *reqs_arr = ap_requires(r);
- require_line *reqs = reqs_arr ? (require_line *) reqs_arr->elts : NULL;
-
- register int x;
- const char *t;
- char *w;
-
- if (!sec->auth_dbgrpfile)
- return DECLINED;
- if (!reqs_arr)
- return DECLINED;
-
- for (x = 0; x < reqs_arr->nelts; x++) {
-
- if (!(reqs[x].method_mask & (1 << m)))
- continue;
-
- t = reqs[x].requirement;
- w = ap_getword_white(r->pool, &t);
-
- if (!strcmp(w, "group") && sec->auth_dbgrpfile) {
- const char *orig_groups, *groups;
- char *v;
-
- if (!(groups = get_db_grp(r, user, sec->auth_dbgrpfile))) {
- if (!(sec->auth_dbauthoritative))
- return DECLINED;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "user %s not in DB group file %s: %s",
- user, sec->auth_dbgrpfile, r->filename);
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- orig_groups = groups;
- while (t[0]) {
- w = ap_getword_white(r->pool, &t);
- groups = orig_groups;
- while (groups[0]) {
- v = ap_getword(r->pool, &groups, ',');
- if (!strcmp(v, w))
- return OK;
- }
- }
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "user %s not in right group: %s", user, r->filename);
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- }
-
- return DECLINED;
-}
-
-
-module db_auth_module =
-{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- create_db_auth_dir_config, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- db_auth_cmds, /* command ap_table_t */
- NULL, /* handlers */
- NULL, /* filename translation */
- db_authenticate_basic_user, /* check_user_id */
- db_check_auth, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
-};
diff --git a/modules/aaa/mod_auth_db.module b/modules/aaa/mod_auth_db.module
deleted file mode 100644
index 5508e290a7..0000000000
--- a/modules/aaa/mod_auth_db.module
+++ /dev/null
@@ -1,36 +0,0 @@
-Name: db_auth_module
-ConfigStart
- DB_VERSION=''
- DB_LIB=''
- if ./helpers/TestCompile func db_open; then
- DB_VERSION='Berkeley-DB/2.x'
- else
- if ./helpers/TestCompile lib db db_open; then
- DB_VERSION='Berkeley-DB/2.x'
- DB_LIB='-ldb'
- else
- if ./helpers/TestCompile func dbopen; then
- DB_VERSION='Berkeley-DB/1.x'
- else
- if ./helpers/TestCompile lib db dbopen; then
- DB_VERSION='Berkeley-DB/1.x'
- DB_LIB='-ldb'
- fi
- fi
- fi
- fi
- if [ ".$DB_VERSION" != . ]; then
- if [ ".$DB_LIB" != . ]; then
- LIBS="$LIBS $DB_LIB"
- echo " using $DB_VERSION for mod_auth_db ($DB_LIB)"
- else
- echo " using $DB_VERSION for mod_auth_db (-lc)"
- fi
- else
- echo "Error: Neither Berkeley-DB/1.x nor Berkeley-DB/2.x library found."
- echo " Either disable mod_auth_db or provide us with the paths"
- echo " to the Berkeley-DB include and library files."
- echo " (Hint: INCLUDES, LDFLAGS, LIBS)"
- exit 1
- fi
-ConfigEnd
diff --git a/modules/aaa/mod_auth_dbm.c b/modules/aaa/mod_auth_dbm.c
deleted file mode 100644
index 2c24d60778..0000000000
--- a/modules/aaa/mod_auth_dbm.c
+++ /dev/null
@@ -1,328 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_auth: authentication
- *
- * Rob McCool & Brian Behlendorf.
- *
- * Adapted to Apache by rst.
- *
- * dirkx - Added Authoritative control to allow passing on to lower
- * modules if and only if the userid is not known to this
- * module. A known user with a faulty or absent password still
- * causes an AuthRequired. The default is 'Authoritative', i.e.
- * no control is passed along.
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_protocol.h"
-#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) \
- && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
-#include <db1/ndbm.h>
-#else
-#include <ndbm.h>
-#endif
-
-/*
- * Module definition information - the part between the -START and -END
- * lines below is used by Configure. This could be stored in a separate
- * instead.
- *
- * MODULE-DEFINITION-START
- * Name: dbm_auth_module
- * ConfigStart
- . ./helpers/find-dbm-lib
- * ConfigEnd
- * MODULE-DEFINITION-END
- */
-
-typedef struct {
-
- char *auth_dbmpwfile;
- char *auth_dbmgrpfile;
- int auth_dbmauthoritative;
-
-} dbm_auth_config_rec;
-
-static void *create_dbm_auth_dir_config(ap_context_t *p, char *d)
-{
- dbm_auth_config_rec *sec
- = (dbm_auth_config_rec *) ap_pcalloc(p, sizeof(dbm_auth_config_rec));
-
- sec->auth_dbmpwfile = NULL;
- sec->auth_dbmgrpfile = NULL;
- sec->auth_dbmauthoritative = 1; /* fortress is secure by default */
-
- return sec;
-}
-
-static const char *set_dbm_slot(cmd_parms *cmd, void *offset, char *f, char *t)
-{
- if (!t || strcmp(t, "dbm"))
- return DECLINE_CMD;
-
- return ap_set_file_slot(cmd, offset, f);
-}
-
-static const command_rec dbm_auth_cmds[] =
-{
- {"AuthDBMUserFile", ap_set_file_slot,
- (void *) XtOffsetOf(dbm_auth_config_rec, auth_dbmpwfile),
- OR_AUTHCFG, TAKE1, NULL},
- {"AuthDBMGroupFile", ap_set_file_slot,
- (void *) XtOffsetOf(dbm_auth_config_rec, auth_dbmgrpfile),
- OR_AUTHCFG, TAKE1, NULL},
- {"AuthUserFile", set_dbm_slot,
- (void *) XtOffsetOf(dbm_auth_config_rec, auth_dbmpwfile),
- OR_AUTHCFG, TAKE12, NULL},
- {"AuthGroupFile", set_dbm_slot,
- (void *) XtOffsetOf(dbm_auth_config_rec, auth_dbmgrpfile),
- OR_AUTHCFG, TAKE12, NULL},
- {"AuthDBMAuthoritative", ap_set_flag_slot,
- (void *) XtOffsetOf(dbm_auth_config_rec, auth_dbmauthoritative),
- OR_AUTHCFG, FLAG, "Set to 'no' to allow access control to be passed along to lower modules, if the UserID is not known in this module"},
- {NULL}
-};
-
-module dbm_auth_module;
-
-static char *get_dbm_pw(request_rec *r, char *user, char *auth_dbmpwfile)
-{
- DBM *f;
- datum d, q;
- char *pw = NULL;
-
- q.dptr = user;
-#ifndef NETSCAPE_DBM_COMPAT
- q.dsize = strlen(q.dptr);
-#else
- q.dsize = strlen(q.dptr) + 1;
-#endif
-
-
- if (!(f = dbm_open(auth_dbmpwfile, O_RDONLY, 0664))) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "could not open dbm auth file: %s", auth_dbmpwfile);
- return NULL;
- }
-
- d = dbm_fetch(f, q);
-
- if (d.dptr) {
- pw = ap_palloc(r->pool, d.dsize + 1);
- strncpy(pw, d.dptr, d.dsize);
- pw[d.dsize] = '\0'; /* Terminate the string */
- }
-
- dbm_close(f);
- return pw;
-}
-
-/* We do something strange with the group file. If the group file
- * contains any : we assume the format is
- * key=username value=":"groupname [":"anything here is ignored]
- * otherwise we now (0.8.14+) assume that the format is
- * key=username value=groupname
- * The first allows the password and group files to be the same
- * physical DBM file; key=username value=password":"groupname[":"anything]
- *
- * mark@telescope.org, 22Sep95
- */
-
-static char *get_dbm_grp(request_rec *r, char *user, char *auth_dbmgrpfile)
-{
- char *grp_data = get_dbm_pw(r, user, auth_dbmgrpfile);
- char *grp_colon;
- char *grp_colon2;
-
- if (grp_data == NULL)
- return NULL;
-
- if ((grp_colon = strchr(grp_data, ':')) != NULL) {
- grp_colon2 = strchr(++grp_colon, ':');
- if (grp_colon2)
- *grp_colon2 = '\0';
- return grp_colon;
- }
- return grp_data;
-}
-
-static int dbm_authenticate_basic_user(request_rec *r)
-{
- dbm_auth_config_rec *sec =
- (dbm_auth_config_rec *) ap_get_module_config(r->per_dir_config,
- &dbm_auth_module);
- const char *sent_pw;
- char *real_pw, *colon_pw;
- ap_status_t invalid_pw;
- int res;
-
- if ((res = ap_get_basic_auth_pw(r, &sent_pw)))
- return res;
-
- if (!sec->auth_dbmpwfile)
- return DECLINED;
-
- if (!(real_pw = get_dbm_pw(r, r->user, sec->auth_dbmpwfile))) {
- if (!(sec->auth_dbmauthoritative))
- return DECLINED;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "DBM user %s not found: %s", r->user, r->filename);
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- /* Password is up to first : if exists */
- colon_pw = strchr(real_pw, ':');
- if (colon_pw) {
- *colon_pw = '\0';
- }
- invalid_pw = ap_validate_password(sent_pw, real_pw);
- if (invalid_pw != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "DBM user %s: authentication failure for \"%s\": %s",
- r->user, r->uri, invalid_pw);
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- return OK;
-}
-
-/* Checking ID */
-
-static int dbm_check_auth(request_rec *r)
-{
- dbm_auth_config_rec *sec =
- (dbm_auth_config_rec *) ap_get_module_config(r->per_dir_config,
- &dbm_auth_module);
- char *user = r->user;
- int m = r->method_number;
-
- const ap_array_header_t *reqs_arr = ap_requires(r);
- require_line *reqs = reqs_arr ? (require_line *) reqs_arr->elts : NULL;
-
- register int x;
- const char *t;
- char *w;
-
- if (!sec->auth_dbmgrpfile)
- return DECLINED;
- if (!reqs_arr)
- return DECLINED;
-
- for (x = 0; x < reqs_arr->nelts; x++) {
-
- if (!(reqs[x].method_mask & (1 << m)))
- continue;
-
- t = reqs[x].requirement;
- w = ap_getword_white(r->pool, &t);
-
- if (!strcmp(w, "group") && sec->auth_dbmgrpfile) {
- const char *orig_groups, *groups;
- char *v;
-
- if (!(groups = get_dbm_grp(r, user, sec->auth_dbmgrpfile))) {
- if (!(sec->auth_dbmauthoritative))
- return DECLINED;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "user %s not in DBM group file %s: %s",
- user, sec->auth_dbmgrpfile, r->filename);
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- orig_groups = groups;
- while (t[0]) {
- w = ap_getword_white(r->pool, &t);
- groups = orig_groups;
- while (groups[0]) {
- v = ap_getword(r->pool, &groups, ',');
- if (!strcmp(v, w))
- return OK;
- }
- }
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "user %s not in right group: %s",
- user, r->filename);
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
- }
-
- return DECLINED;
-}
-
-static void register_hooks(void)
-{
- ap_hook_check_user_id(dbm_authenticate_basic_user, NULL, NULL, HOOK_MIDDLE);
- ap_hook_auth_checker(dbm_check_auth, NULL, NULL, HOOK_MIDDLE);
-}
-
-module dbm_auth_module =
-{
- STANDARD20_MODULE_STUFF,
- create_dbm_auth_dir_config, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- dbm_auth_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/aaa/mod_auth_dbm.exp b/modules/aaa/mod_auth_dbm.exp
deleted file mode 100644
index dc8a438deb..0000000000
--- a/modules/aaa/mod_auth_dbm.exp
+++ /dev/null
@@ -1 +0,0 @@
-dbm_auth_module
diff --git a/modules/aaa/mod_auth_digest.c b/modules/aaa/mod_auth_digest.c
deleted file mode 100644
index 967a58c471..0000000000
--- a/modules/aaa/mod_auth_digest.c
+++ /dev/null
@@ -1,1970 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_auth_digest: MD5 digest authentication
- *
- * Originally by Alexei Kosut <akosut@nueva.pvt.k12.ca.us>
- * Updated to RFC-2617 by Ronald Tschalär <ronald@innovation.ch>
- * based on mod_auth, by Rob McCool and Robert S. Thau
- *
- * This module an updated version of modules/standard/mod_digest.c
- * However, it has not been extensively tested yet, and is therefore
- * currently marked experimental. Send problem reports to me
- * (ronald@innovation.ch)
- *
- * Requires either /dev/random (or equivalent) or the truerand library,
- * available for instance from
- * ftp://research.att.com/dist/mab/librand.shar
- *
- * Open Issues:
- * - qop=auth-int (when streams and trailer support available)
- * - nonce-format configurability
- * - Proxy-Authorization-Info header is set by this module, but is
- * currently ignored by mod_proxy (needs patch to mod_proxy)
- * - generating the secret takes a while (~ 8 seconds) if using the
- * truerand library
- * - shared-mem not completely tested yet. Seems to work ok for me,
- * but... (definitely won't work on Windoze)
- */
-
-/* The section for the Configure script:
- * MODULE-DEFINITION-START
- * Name: digest_auth_module
- * ConfigStart
-
- RULE_DEV_RANDOM=`./helpers/CutRule DEV_RANDOM $file`
- if [ "$RULE_DEV_RANDOM" = "default" ]; then
- if [ -r "/dev/random" ]; then
- RULE_DEV_RANDOM="/dev/random"
- elif [ -r "/dev/urandom" ]; then
- RULE_DEV_RANDOM="/dev/urandom"
- else
- RULE_DEV_RANDOM="truerand"
- if helpers/TestCompile func randbyte; then
- :
- elif helpers/TestCompile lib rand randbyte; then
- :
- else
- echo " (mod_auth_digest) truerand library missing!"
- echo "** This will most probably defeat successful compilation."
- echo "** See Rule DEV_RANDOM in src/Configuration.tmpl for more information."
- fi
- fi
- fi
- if [ "$RULE_DEV_RANDOM" = "truerand" ]; then
- echo " using truerand library (-lrand) for the random seed"
- LIBS="$LIBS -L/usr/local/lib -lrand"
- else
- echo " using $RULE_DEV_RANDOM for the random seed"
- CFLAGS="$CFLAGS -DDEV_RANDOM=$RULE_DEV_RANDOM"
- fi
-
- * ConfigEnd
- * MODULE-DEFINITION-END
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_conf_globals.h"
-#include "http_core.h"
-#include "http_request.h"
-#include "http_log.h"
-#include "http_protocol.h"
-#include "ap_ctype.h"
-#include "util_uri.h"
-#include "util_md5.h"
-#include "ap_sha1.h"
-
-#ifdef WIN32
-/* Crypt APIs are available on Win95 with OSR 2 */
-#include <wincrypt.h>
-#endif
-
-#ifdef HAVE_SHMEM_MM
-#include "mm.h"
-#endif /* HAVE_SHMEM_MM */
-
-
-/* struct to hold the configuration info */
-
-typedef struct digest_config_struct {
- const char *dir_name;
- const char *pwfile;
- const char *grpfile;
- const char *realm;
- const char **qop_list;
- AP_SHA1_CTX nonce_ctx;
- long nonce_lifetime;
- const char *nonce_format;
- int check_nc;
- const char *algorithm;
- char *uri_list;
- const char *ha1;
-} digest_config_rec;
-
-
-#define DFLT_ALGORITHM "MD5"
-
-#define DFLT_NONCE_LIFE 300L
-#define NEXTNONCE_DELTA 30
-
-
-#define NONCE_TIME_LEN (((sizeof(time_t)+2)/3)*4)
-#define NONCE_HASH_LEN (2*SHA_DIGESTSIZE)
-#define NONCE_LEN (NONCE_TIME_LEN + NONCE_HASH_LEN)
-
-#define SECRET_LEN 20
-
-
-/* client list definitions */
-
-typedef struct hash_entry {
- unsigned long key; /* the key for this entry */
- struct hash_entry *next; /* next entry in the bucket */
- unsigned long nonce_count; /* for nonce-count checking */
- char ha1[2*MD5_DIGESTSIZE+1]; /* for algorithm=MD5-sess */
- char last_nonce[NONCE_LEN+1]; /* for one-time nonce's */
-} client_entry;
-
-static struct hash_table {
- client_entry **ap_table_t;
- unsigned long tbl_len;
- unsigned long num_entries;
- unsigned long num_created;
- unsigned long num_removed;
- unsigned long num_renewed;
-} *client_list;
-
-
-/* struct to hold a parsed Authorization header */
-
-enum hdr_sts { NO_HEADER, NOT_DIGEST, INVALID, VALID };
-
-typedef struct digest_header_struct {
- const char *scheme;
- const char *realm;
- const char *username;
- char *nonce;
- const char *uri;
- const char *digest;
- const char *algorithm;
- const char *cnonce;
- const char *opaque;
- unsigned long opaque_num;
- const char *message_qop;
- const char *nonce_count;
- /* the following fields are not (directly) from the header */
- time_t nonce_time;
- enum hdr_sts auth_hdr_sts;
- uri_components *request_uri;
- int needed_auth;
- client_entry *client;
-} digest_header_rec;
-
-
-/* (mostly) nonce stuff */
-
-typedef union time_union {
- time_t time;
- unsigned char arr[sizeof(time_t)];
-} time_rec;
-
-
-static unsigned char secret[SECRET_LEN];
-static int call_cnt = 0;
-
-
-#ifdef HAVE_SHMEM_MM
-/* opaque stuff */
-
-static MM *opaque_mm;
-static unsigned long *opaque_cntr;
-
-static MM *client_mm;
-
-static MM *otn_count_mm;
-static time_t *otn_counter; /* one-time-nonce counter */
-
-#define SHMEM_SIZE 1000 /* ~ 12 entries */
-#define NUM_BUCKETS 15UL
-
-#else /* HAVE_SHMEM_MM */
-static void *client_mm = NULL;
-#endif /* HAVE_SHMEM_MM */
-
-module MODULE_VAR_EXPORT digest_auth_module;
-
-/*
- * initialization code
- */
-
-#ifdef HAVE_SHMEM_MM
-static ap_status_t cleanup_tables(void *not_used)
-{
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Digest: cleaning up shared memory");
- fflush(stderr);
-
- if (client_mm) {
- mm_destroy(client_mm);
- client_mm = NULL;
- }
-
- if (opaque_mm) {
- mm_destroy(opaque_mm);
- opaque_mm = NULL;
- }
-
- if (otn_count_mm) {
- mm_destroy(otn_count_mm);
- otn_count_mm = NULL;
- }
-
- return APR_SUCCESS;
-}
-#endif /* HAVE_SHMEM_MM */
-
-#ifdef WIN32
-/* TODO: abstract out the random number generation. APR? */
-static void initialize_secret(server_rec *s)
-{
- HCRYPTPROV hProv;
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, s,
- "Digest: generating secret for digest authentication ...");
- if (!CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,0)) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, s,
- "Digest: Error acquiring context. Errno = %d",
- GetLastError());
- exit(EXIT_FAILURE);
- }
- if (!CryptGenRandom(hProv,sizeof(secret),secret)) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, s,
- "Digest: Error generating secret. Errno = %d",
- GetLastError());
- exit(EXIT_FAILURE);
- }
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, s, "Digest: done");
-}
-#else
-static void initialize_secret(server_rec *s)
-{
-#ifdef DEV_RANDOM
- int rnd;
- size_t got, tot;
-#else
- extern int randbyte(void); /* from the truerand library */
- unsigned int idx;
-#endif
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, s,
- "Digest: generating secret for digest authentication ...");
-
-#ifdef DEV_RANDOM
-#define XSTR(x) #x
-#define STR(x) XSTR(x)
- if ((rnd = open(STR(DEV_RANDOM), O_RDONLY)) == NULL) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, s,
- "Digest: Couldn't open " STR(DEV_RANDOM));
- exit(EXIT_FAILURE);
- }
- for (tot=0; tot<sizeof(secret); tot += got) {
- if ((got = read(rnd, secret+tot, sizeof(secret)-tot)) < 0) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, s,
- "Digest: Error reading " STR(DEV_RANDOM));
- exit(EXIT_FAILURE);
- }
- }
- close(rnd);
-#undef STR
-#undef XSTR
-#else /* use truerand */
- /* this will increase the startup time of the server, unfortunately...
- * (generating 20 bytes takes about 8 seconds)
- */
- for (idx=0; idx<sizeof(secret); idx++)
- secret[idx] = (unsigned char) randbyte();
-#endif /* DEV_RANDOM */
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, s, "Digest: done");
-}
-#endif
-
-#ifdef HAVE_SHMEM_MM
-static void initialize_tables(server_rec *s)
-{
- unsigned long idx;
-
- /* set up client list */
-
- client_mm = mm_create(SHMEM_SIZE, tmpnam(NULL));
- if (client_mm == NULL)
- goto failed;
-#ifdef MPE
- if (geteuid() == 1) {
-#else
- if (geteuid() == 0) {
-#endif
- if (mm_permission(client_mm, 0600, ap_user_id, ap_group_id))
- goto failed;
- }
- client_list = mm_malloc(client_mm, sizeof(*client_list) +
- sizeof(client_entry*)*NUM_BUCKETS);
- if (!client_list) goto failed;
- client_list->table = (client_entry**) (client_list + 1);
- for (idx=0; idx<NUM_BUCKETS; idx++)
- client_list->table[idx] = NULL;
- client_list->tbl_len = NUM_BUCKETS;
- client_list->num_entries = 0;
-
-
- /* setup opaque */
-
- opaque_mm = mm_create(sizeof(*opaque_cntr), tmpnam(NULL));
- if (opaque_mm == NULL)
- goto failed;
-#ifdef MPE
- if (geteuid() == 1) {
-#else
- if (geteuid() == 0) {
-#endif
- if (mm_permission(opaque_mm, 0600, ap_user_id, ap_group_id))
- goto failed;
- }
- opaque_cntr = mm_malloc(opaque_mm, sizeof(*opaque_cntr));
- if (opaque_cntr == NULL)
- goto failed;
- *opaque_cntr = 1UL;
-
-
- /* setup one-time-nonce counter */
-
- otn_count_mm = mm_create(sizeof(*otn_counter), tmpnam(NULL));
- if (otn_count_mm == NULL)
- goto failed;
-#ifdef MPE
- if (geteuid() == 1) {
-#else
- if (geteuid() == 0) {
-#endif
- if (mm_permission(otn_count_mm, 0600, ap_user_id, ap_group_id))
- goto failed;
- }
- otn_counter = mm_malloc(otn_count_mm, sizeof(*otn_counter));
- if (otn_counter == NULL)
- goto failed;
- *otn_counter = 0;
-
-
- /* success */
- return;
-
-failed:
- if (!client_mm || (client_list && client_list->table && !opaque_mm)
- || (opaque_cntr && !otn_count_mm))
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, s,
- "Digest: failed to create shared memory segments; reason "
- "was `%s' - all nonce-count checking, one-time nonces, "
- "and MD5-sess algorithm disabled", mm_error());
- else
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, s,
- "Digest: failed to allocate shared mem; reason was `%s' "
- "- all nonce-count checking, one-time nonces, and "
- "MD5-sess algorithm disabled", mm_error());
-
- cleanup_tables(NULL);
-}
-#endif /* HAVE_SHMEM_MM */
-
-static void initialize_module(ap_context_t *p, ap_context_t *plog,
- ap_context_t *ptemp, server_rec *s)
-{
- /* keep from doing the init more than once at startup, and delay
- * the init until the second round
- */
- if (++call_cnt < 2)
- return;
-
- /* only initialize the secret on startup, not on restarts */
- if (call_cnt == 2)
- initialize_secret(s);
-
-#ifdef HAVE_SHMEM_MM
- /* Note: this stuff is currently fixed for the lifetime of the server,
- * i.e. even across restarts. This means that A) any shmem-size
- * configuration changes are ignored, and B) certain optimizations,
- * such as only allocating the smallest necessary entry for each
- * client, can't be done. However, the alternative is a nightmare:
- * we can't call mm_destroy on a graceful restart because there will
- * be children using the tables, and we also don't know when the
- * last child dies. Therefore we can never clean up the old stuff,
- * creating a creeping memory leak.
- */
- initialize_tables(s);
- ap_register_cleanup(p, NULL, cleanup_tables, ap_null_cleanup);
-#endif /* HAVE_SHMEM_MM */
-}
-
-
-/*
- * configuration code
- */
-
-static void *create_digest_dir_config(ap_context_t *p, char *dir)
-{
- digest_config_rec *conf;
-
- if (dir == NULL) return NULL;
-
- conf = (digest_config_rec *) ap_pcalloc(p, sizeof(digest_config_rec));
- if (conf) {
- conf->qop_list = ap_palloc(p, sizeof(char*));
- conf->qop_list[0] = NULL;
- conf->nonce_lifetime = DFLT_NONCE_LIFE;
- conf->dir_name = ap_pstrdup(p, dir);
- conf->algorithm = DFLT_ALGORITHM;
- }
-
- return conf;
-}
-
-static const char *set_realm(cmd_parms *cmd, void *config, const char *realm)
-{
- digest_config_rec *conf = (digest_config_rec *) config;
-
- /* The core already handles the realm, but it's just too convenient to
- * grab it ourselves too and cache some setups. However, we need to
- * let the core get at it too, which is why we decline at the end -
- * this relies on the fact that http_core is last in the list.
- */
- conf->realm = realm;
-
- /* we precompute the part of the nonce hash that is constant (well,
- * the host:port would be too, but that varies for .htaccess files
- * and directives outside a virtual host section)
- */
- ap_SHA1Init(&conf->nonce_ctx);
- ap_SHA1Update_binary(&conf->nonce_ctx, (const unsigned char *) realm,
- strlen(realm));
- ap_SHA1Update_binary(&conf->nonce_ctx, secret, sizeof(secret));
-
- return DECLINE_CMD;
-}
-
-static const char *set_digest_file(cmd_parms *cmd, void *config,
- const char *file)
-{
- ((digest_config_rec *) config)->pwfile = file;
- return NULL;
-}
-
-static const char *set_group_file(cmd_parms *cmd, void *config,
- const char *file)
-{
- ((digest_config_rec *) config)->grpfile = file;
- return NULL;
-}
-
-static const char *set_qop(cmd_parms *cmd, void *config, const char *op)
-{
- digest_config_rec *conf = (digest_config_rec *) config;
- const char **tmp;
- int cnt;
-
- if (!strcasecmp(op, "none")) {
- if (conf->qop_list[0] == NULL) {
- conf->qop_list = ap_palloc(cmd->pool, 2 * sizeof(char*));
- conf->qop_list[1] = NULL;
- }
- conf->qop_list[0] = "none";
- return NULL;
- }
-
- if (!strcasecmp(op, "auth-int"))
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, cmd->server,
- "Digest: WARNING: qop `auth-int' currently only works "
- "correctly for responses with no entity");
- else if (strcasecmp(op, "auth"))
- return ap_pstrcat(cmd->pool, "Unrecognized qop: ", op, NULL);
-
- for (cnt=0; conf->qop_list[cnt] != NULL; cnt++)
- ;
- tmp = ap_palloc(cmd->pool, (cnt+2)*sizeof(char*));
- memcpy(tmp, conf->qop_list, cnt*sizeof(char*));
- tmp[cnt] = ap_pstrdup(cmd->pool, op);
- tmp[cnt+1] = NULL;
- conf->qop_list = tmp;
-
- return NULL;
-}
-
-static const char *set_nonce_lifetime(cmd_parms *cmd, void *config,
- const char *t)
-{
- char *endptr;
- long lifetime;
-
- lifetime = strtol(t, &endptr, 10);
- if (endptr < (t+strlen(t)) && !ap_isspace(*endptr))
- return ap_pstrcat(cmd->pool, "Invalid time in AuthDigestNonceLifetime: ", t, NULL);
-
- ((digest_config_rec *) config)->nonce_lifetime = lifetime;
- return NULL;
-}
-
-static const char *set_nonce_format(cmd_parms *cmd, void *config,
- const char *fmt)
-{
- ((digest_config_rec *) config)->nonce_format = fmt;
- return "AuthDigestNonceFormat is not implemented (yet)";
-}
-
-static const char *set_nc_check(cmd_parms *cmd, void *config, int flag)
-{
- ((digest_config_rec *) config)->check_nc = flag;
- return NULL;
-}
-
-static const char *set_algorithm(cmd_parms *cmd, void *config, const char *alg)
-{
- if (!strcasecmp(alg, "MD5-sess"))
-#ifdef HAVE_SHMEM_MM
- ;
-#else /* HAVE_SHMEM_MM */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, cmd->server,
- "Digest: WARNING: algorithm `MD5-sess' is currently not "
- "correctly implemented");
-#endif /* HAVE_SHMEM_MM */
- else if (strcasecmp(alg, "MD5"))
- return ap_pstrcat(cmd->pool, "Invalid algorithm in AuthDigestAlgorithm: ", alg, NULL);
-
- ((digest_config_rec *) config)->algorithm = alg;
- return NULL;
-}
-
-static const char *set_uri_list(cmd_parms *cmd, void *config, const char *uri)
-{
- digest_config_rec *c = (digest_config_rec *) config;
- if (c->uri_list) {
- c->uri_list[strlen(c->uri_list)-1] = '\0';
- c->uri_list = ap_pstrcat(cmd->pool, c->uri_list, " ", uri, "\"", NULL);
- }
- else
- c->uri_list = ap_pstrcat(cmd->pool, ", domain=\"", uri, "\"", NULL);
- return NULL;
-}
-
-static const command_rec digest_cmds[] =
-{
- {"AuthName", set_realm, NULL, OR_AUTHCFG, TAKE1,
- "The authentication realm (e.g. \"Members Only\")"},
- {"AuthDigestFile", set_digest_file, NULL, OR_AUTHCFG, TAKE1,
- "The name of the file containing the usernames and password hashes"},
- {"AuthDigestGroupFile", set_group_file, NULL, OR_AUTHCFG, TAKE1,
- "The name of the file containing the group names and members"},
- {"AuthDigestQop", set_qop, NULL, OR_AUTHCFG, ITERATE,
- "A list of quality-of-protection options"},
- {"AuthDigestNonceLifetime", set_nonce_lifetime, NULL, OR_AUTHCFG, TAKE1,
- "Maximum lifetime of the server nonce (seconds)"},
- {"AuthDigestNonceFormat", set_nonce_format, NULL, OR_AUTHCFG, TAKE1,
- "The format to use when generating the server nonce"},
- {"AuthDigestNcCheck", set_nc_check, NULL, OR_AUTHCFG, FLAG,
- "Whether or not to check the nonce-count sent by the client"},
- {"AuthDigestAlgorithm", set_algorithm, NULL, OR_AUTHCFG, TAKE1,
- "The algorithm used for the hash calculation"},
- {"AuthDigestDomain", set_uri_list, NULL, OR_AUTHCFG, ITERATE,
- "A list of URI's which belong to the same protection space as the current URI"},
- {NULL}
-};
-
-
-#ifdef HAVE_SHMEM_MM
-/*
- * client list code
- *
- * Each client is assigned a number, which is transfered in the opaque
- * field of the WWW-Authenticate and Authorization headers. The number
- * is just a simple counter which is incremented for each new client.
- * Clients can't forge this number because it is hashed up into the
- * server nonce, and that is checked.
- *
- * The clients are kept in a simple hash table, which consists of an
- * array of client_entry's, each with a linked list of entries hanging
- * off it. The client's number modulo the size of the array gives the
- * bucket number.
- *
- * The clients are garbage collected whenever a new client is allocated
- * but there is not enough space left in the shared memory segment. A
- * simple semi-LRU is used for this: whenever a client entry is accessed
- * it is moved to the beginning of the linked list in its bucket (this
- * also makes for faster lookups for current clients). The garbage
- * collecter then just removes the oldest entry (i.e. the one at the
- * end of the list) in each bucket.
- *
- * The main advantages of the above scheme are that it's easy to implement
- * and it keeps the hash table evenly balanced (i.e. same number of entries
- * in each bucket). The major disadvantage is that you may be throwing
- * entries out which are in active use. This is not tragic, as these
- * clients will just be sent a new client id (opaque field) and nonce
- * with a stale=true (i.e. it will just look like the nonce expired,
- * thereby forcing an extra round trip). If the shared memory segment
- * has enough headroom over the current client set size then this should
- * not occur too often.
- *
- * To help tune the size of the shared memory segment (and see if the
- * above algorithm is really sufficient) a set of counters is kept
- * indicating the number of clients held, the number of garbage collected
- * clients, and the number of erroneously purged clients. These are printed
- * out at each garbage collection run. Note that access to the counters is
- * not synchronized because they are just indicaters, and whether they are
- * off by a few doesn't matter; and for the same reason no attempt is made
- * to guarantee the num_renewed is correct in the face of clients spoofing
- * the opaque field.
- */
-
-/*
- * Get the client given its client number (the key). Returns the entry,
- * or NULL if its not found.
- *
- * Access to the list itself is synchronized via locks. However, access
- * to the entry returned by get_client() is NOT synchronized. This means
- * that there are potentially problems if a client uses multiple,
- * simultaneous connections to access url's within the same protection
- * space. However, these problems are not new: when using multiple
- * connections you have no guarantee of the order the requests are
- * processed anyway, so you have problems with the nonce-count and
- * one-time nonces anyway.
- */
-static client_entry *get_client(unsigned long key, const request_rec *r)
-{
- int bucket;
- client_entry *entry, *prev = NULL;
-
-
- if (!key || !client_mm) return NULL;
-
- bucket = key % client_list->tbl_len;
- entry = client_list->table[bucket];
-
- mm_lock(client_mm, MM_LOCK_RD);
-
- while(entry && key != entry->key) {
- prev = entry;
- entry = entry->next;
- }
-
- if (entry && prev) { /* move entry to front of list */
- prev->next = entry->next;
- entry->next = client_list->table[bucket];
- client_list->table[bucket] = entry;
- }
-
- mm_unlock(client_mm);
-
- if (entry)
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, 0, r,
- "get_client(): client %lu found", key);
- else
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, 0, r,
- "get_client(): client %lu not found", key);
-
- return entry;
-}
-
-
-/* A simple garbage-collecter to remove unused clients. It removes the
- * last entry in each bucket and updates the counters. Returns the
- * number of removed entries.
- */
-static long gc(void)
-{
- client_entry *entry, *prev;
- unsigned long num_removed = 0, idx;
-
- /* garbage collect all last entries */
-
- for (idx=0; idx<client_list->tbl_len; idx++) {
- entry = client_list->table[idx];
- prev = NULL;
- while (entry->next) { /* find last entry */
- prev = entry;
- entry = entry->next;
- }
- if (prev) prev->next = NULL; /* cut list */
- else client_list->table[idx] = NULL;
- if (entry) { /* remove entry */
- mm_free(client_mm, entry);
- num_removed++;
- }
- }
-
- /* update counters and log */
-
- client_list->num_entries -= num_removed;
- client_list->num_removed += num_removed;
-
- return num_removed;
-}
-
-
-/*
- * Add a new client to the list. Returns the entry if successful, NULL
- * otherwise. This triggers the garbage collection is memory is low.
- */
-static client_entry *add_client(unsigned long key, client_entry *new,
- server_rec *s)
-{
- int bucket;
- client_entry *entry;
-
-
- if (!key || !client_mm) return NULL;
-
- bucket = key % client_list->tbl_len;
- entry = client_list->table[bucket];
-
- mm_lock(client_mm, MM_LOCK_RW);
-
- /* try to allocate a new entry */
-
- entry = mm_malloc(client_mm, sizeof(client_entry));
- if (!entry) {
- long num_removed = gc();
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, s,
- "Digest: gc'd %ld client entries. Total new clients: "
- "%ld; Total removed clients: %ld; Total renewed clients: "
- "%ld", num_removed,
- client_list->num_created - client_list->num_renewed,
- client_list->num_removed, client_list->num_renewed);
- entry = mm_malloc(client_mm, sizeof(client_entry));
- if (!entry) return NULL; /* give up */
- }
-
- /* now add the entry */
-
- memcpy(entry, new, sizeof(client_entry));
- entry->key = key;
- entry->next = client_list->table[bucket];
- client_list->table[bucket] = entry;
- client_list->num_created++;
- client_list->num_entries++;
-
- mm_unlock(client_mm);
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, s,
- "allocated new client %lu", key);
-
- return entry;
-}
-#else /* HAVE_SHMEM_MM */
-static client_entry *get_client(unsigned long key, const request_rec *r)
-{
- return NULL;
-}
-#endif /* HAVE_SHMEM_MM */
-
-
-/*
- * Authorization header parser code
- */
-
-/* Parse the Authorization header, if it exists */
-static int get_digest_rec(request_rec *r, digest_header_rec *resp)
-{
- const char *auth_line = ap_table_get(r->headers_in,
- r->proxyreq ? "Proxy-Authorization"
- : "Authorization");
- size_t l;
- int vk = 0, vv = 0;
- char *key, *value;
-
-
- if (!auth_line) {
- resp->auth_hdr_sts = NO_HEADER;
- return !OK;
- }
-
- resp->scheme = ap_getword_white(r->pool, &auth_line);
- if (strcasecmp(resp->scheme, "Digest")) {
- resp->auth_hdr_sts = NOT_DIGEST;
- return !OK;
- }
-
- l = strlen(auth_line);
-
- key = ap_palloc(r->pool, l+1);
- value = ap_palloc(r->pool, l+1);
-
- while (auth_line[0] != '\0') {
-
- /* find key */
-
- while (ap_isspace(auth_line[0])) auth_line++;
- vk = 0;
- while (auth_line[0] != '=' && auth_line[0] != ','
- && auth_line[0] != '\0' && !ap_isspace(auth_line[0]))
- key[vk++] = *auth_line++;
- key[vk] = '\0';
- while (ap_isspace(auth_line[0])) auth_line++;
-
- /* find value */
-
- if (auth_line[0] == '=') {
- auth_line++;
- while (ap_isspace(auth_line[0])) auth_line++;
-
- vv = 0;
- if (auth_line[0] == '\"') { /* quoted string */
- auth_line++;
- while (auth_line[0] != '\"' && auth_line[0] != '\0') {
- if (auth_line[0] == '\\' && auth_line[1] != '\0')
- auth_line++; /* escaped char */
- value[vv++] = *auth_line++;
- }
- if (auth_line[0] != '\0') auth_line++;
- }
- else { /* token */
- while (auth_line[0] != ',' && auth_line[0] != '\0'
- && !ap_isspace(auth_line[0]))
- value[vv++] = *auth_line++;
- }
- value[vv] = '\0';
- }
-
- while (auth_line[0] != ',' && auth_line[0] != '\0') auth_line++;
- if (auth_line[0] != '\0') auth_line++;
-
- if (!strcasecmp(key, "username"))
- resp->username = ap_pstrdup(r->pool, value);
- else if (!strcasecmp(key, "realm"))
- resp->realm = ap_pstrdup(r->pool, value);
- else if (!strcasecmp(key, "nonce"))
- resp->nonce = ap_pstrdup(r->pool, value);
- else if (!strcasecmp(key, "uri"))
- resp->uri = ap_pstrdup(r->pool, value);
- else if (!strcasecmp(key, "response"))
- resp->digest = ap_pstrdup(r->pool, value);
- else if (!strcasecmp(key, "algorithm"))
- resp->algorithm = ap_pstrdup(r->pool, value);
- else if (!strcasecmp(key, "cnonce"))
- resp->cnonce = ap_pstrdup(r->pool, value);
- else if (!strcasecmp(key, "opaque"))
- resp->opaque = ap_pstrdup(r->pool, value);
- else if (!strcasecmp(key, "qop"))
- resp->message_qop = ap_pstrdup(r->pool, value);
- else if (!strcasecmp(key, "nc"))
- resp->nonce_count = ap_pstrdup(r->pool, value);
- }
-
- if (!resp->username || !resp->realm || !resp->nonce || !resp->uri
- || !resp->digest) {
- resp->auth_hdr_sts = INVALID;
- return !OK;
- }
-
- if (resp->opaque)
- resp->opaque_num = (unsigned long) strtol(resp->opaque, NULL, 16);
-
- resp->auth_hdr_sts = VALID;
- return OK;
-}
-
-
-/* Because the browser may preemptively send auth info, incrementing the
- * nonce-count when it does, and because the client does not get notified
- * if the URI didn't need authentication after all, we need to be sure to
- * update the nonce-count each time we receive an Authorization header no
- * matter what the final outcome of the request. Furthermore this is a
- * convenient place to get the request-uri (before any subrequests etc
- * are initiated) and to initialize the request_config.
- *
- * Note that this must be called after mod_proxy had its go so that
- * r->proxyreq is set correctly.
- */
-static int parse_hdr_and_update_nc(request_rec *r)
-{
- digest_header_rec *resp;
- int res;
-
- if (!ap_is_initial_req(r))
- return DECLINED;
-
- resp = ap_pcalloc(r->pool, sizeof(digest_header_rec));
- resp->request_uri = &r->parsed_uri;
- resp->needed_auth = 0;
- ap_set_module_config(r->request_config, &digest_auth_module, resp);
-
- res = get_digest_rec(r, resp);
- resp->client = get_client(resp->opaque_num, r);
- if (res == OK && resp->client)
- resp->client->nonce_count++;
-
- return DECLINED;
-}
-
-
-/*
- * Nonce generation code
- */
-
-/* The hash part of the nonce is a SHA-1 hash of the time, realm, opaque,
- * and our secret.
- */
-static void gen_nonce_hash(char *hash, const char *timestr, const char *opaque,
- const server_rec *server,
- const digest_config_rec *conf)
-{
- const char *hex = "0123456789abcdef";
- unsigned char sha1[SHA_DIGESTSIZE];
- AP_SHA1_CTX ctx;
- int idx;
-
- memcpy(&ctx, &conf->nonce_ctx, sizeof(ctx));
- ap_SHA1Update_binary(&ctx, (const unsigned char *) server->server_hostname,
- strlen(server->server_hostname));
- ap_SHA1Update_binary(&ctx, (const unsigned char *) &server->port,
- sizeof(server->port));
- ap_SHA1Update_binary(&ctx, (const unsigned char *) timestr, strlen(timestr));
- if (opaque)
- ap_SHA1Update_binary(&ctx, (const unsigned char *) opaque,
- strlen(opaque));
- ap_SHA1Final(sha1, &ctx);
-
- for (idx=0; idx<SHA_DIGESTSIZE; idx++) {
- *hash++ = hex[sha1[idx] >> 4];
- *hash++ = hex[sha1[idx] & 0xF];
- }
-
- *hash++ = '\0';
-}
-
-
-/* The nonce has the format b64(time)+hash .
- */
-static const char *gen_nonce(ap_context_t *p, time_t now, const char *opaque,
- const server_rec *server,
- const digest_config_rec *conf)
-{
- char *nonce = ap_palloc(p, NONCE_LEN+1);
- time_rec t;
-
- if (conf->nonce_lifetime != 0)
- t.time = now;
- else
-#ifdef HAVE_SHMEM_MM
- /* this counter is not synch'd, because it doesn't really matter
- * if it counts exactly.
- */
- t.time = (*otn_counter)++;
-#else /* HAVE_SHMEM_MM */
- t.time = 42;
-#endif /* HAVE_SHMEM_MM */
- ap_base64encode_binary(nonce, t.arr, sizeof(t.arr));
- gen_nonce_hash(nonce+NONCE_TIME_LEN, nonce, opaque, server, conf);
-
- return nonce;
-}
-
-
-/*
- * Opaque and hash-table management
- */
-
-#ifdef HAVE_SHMEM_MM
-/*
- * Generate a new client entry, add it to the list, and return the
- * entry. Returns NULL if failed.
- */
-static client_entry *gen_client(const request_rec *r)
-{
- unsigned long op;
- client_entry new = { 0, NULL, 0, "", "" }, *entry;
-
- if (!opaque_mm) return 0;
-
- mm_lock(opaque_mm, MM_LOCK_RW);
- op = (*opaque_cntr)++;
- mm_unlock(opaque_mm);
-
- if (!(entry = add_client(op, &new, r->server))) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- "Digest: failed to allocate client entry - ignoring "
- "client");
- return NULL;
- }
-
- return entry;
-}
-#else /* HAVE_SHMEM_MM */
-static client_entry *gen_client(const request_rec *r) { return NULL; }
-#endif /* HAVE_SHMEM_MM */
-
-
-
-/*
- * MD5-sess code.
- *
- * If you want to use algorithm=MD5-sess you must write get_userpw_hash()
- * yourself (see below). The dummy provided here just returns the hash
- * from the auth-file, i.e. it is only useful for testing client
- * implementations of MD5-sess .
- */
-
-/*
- * get_userpw_hash() will be called each time a new session needs to be
- * generated and is expected to return the equivalent of
- *
- * ap_md5(r->pool,
- * ap_pstrcat(r->pool, username, ":", ap_auth_name(r), ":", passwd))
- *
- * You must implement this yourself, and will probably consist of code
- * contacting the password server and retrieving the hash from it.
- *
- * TBD: This function should probably be in a seperate source file so that
- * people need not modify mod_auth_digest.c each time they install a new version
- * of apache.
- */
-static const char *get_userpw_hash(const request_rec *r,
- const digest_header_rec *resp,
- const digest_config_rec *conf)
-{
- /* for now, just get it from pwfile */
- return conf->ha1;
-}
-
-
-static const char *get_session(const request_rec *r,
- digest_header_rec *resp,
- const digest_config_rec *conf)
-{
- const char *ha1 = NULL, *urp;
-
- /* get ha1 from client list */
- if (resp->opaque && resp->client)
- ha1 = resp->client->ha1;
-
- /* generate new session if necessary */
- if (ha1 == NULL || ha1[0] == '\0') {
- urp = get_userpw_hash(r, resp, conf);
- ha1 = ap_md5(r->pool,
- (unsigned char *) ap_pstrcat(r->pool, urp, ":", resp->nonce,
- ":", resp->cnonce, NULL));
- if (!resp->client)
- resp->client = gen_client(r);
- if (resp->client)
- memcpy(resp->client->ha1, ha1, sizeof(resp->client->ha1));
- }
-
- return ha1;
-}
-
-
-static void clear_session(const digest_header_rec *resp)
-{
- if (resp->client)
- resp->client->ha1[0] = '\0';
-}
-
-
-/*
- * Authorization challenge generation code (for WWW-Authenticate)
- */
-
-static const char *guess_domain(ap_context_t *p, const char *uri,
- const char *filename, const char *dir)
-{
- size_t u_len = strlen(uri), f_len = strlen(filename), d_len = strlen(dir);
- const char *u, *f;
-
-
- /* Because of things like mod_alias and mod_rewrite and the fact that
- * protection is often on a directory basis (not a location basis) it
- * is hard to determine the uri to put in the domain attribute.
- *
- * What we do is the following: first we see if the directory is
- * a prefix for the uri - if this is the case we assume that therefore
- * a <Location> directive was protecting this uri and we can use it
- * for the domain.
- */
- if (u_len >= d_len && !memcmp(uri, dir, d_len))
- return dir;
-
- /* Now we check for <Files ...>, and if we find one we send back a
- * dummy uri - this is the only way to specify that the protection
- * space only covers a single uri.
- */
- if (dir[0] != '/')
- /* This doesn't work for Amaya (ok, it's of arguable validity in
- * the first place), so just return the file name instead
- return "http://0.0.0.0/";
- */
- return dir;
-
- /* Next we find the largest common common suffix of the request-uri
- * and the final file name, ignoring any extensions; this gives us a
- * hint as to where any rewriting could've occured (assuming that some
- * prefix of the uri is rewritten, not a suffix).
- */
- u = uri + u_len - 1; /* strip any extension */
- while (u > uri && *u != '/') u--;
- while (*u && *u != '.') u++;
- if (*u == '.') u--;
- if (*u == '/') u--;
-
- f = filename + f_len - 1; /* strip any extension */
- while (f > filename && *f != '/') f--;
- while (*f && *f != '.') f++;
- if (*f == '.') f--;
- if (*f == '/') f--;
-
- while (*f == *u && f > filename && u > uri) u--, f--;
- f++; u++;
-
- while (*f && *f != '/') f++, u++; /* suffix must start with / */
-
- /* Now, if the directory reaches into this common suffix then we can
- * take the uri with the same reach.
- */
- if ((unsigned long) (f-filename) < d_len) {
- char *tmp = ap_pstrdup(p, uri);
- tmp[(u-uri)+(d_len-(f-filename))] = '\0';
- return tmp;
- }
-
- return ""; /* give up */
-}
-
-
-static const char *ltox(ap_context_t *p, unsigned long num)
-{
- if (num != 0)
- return ap_psprintf(p, "%lx", num);
- else
- return "";
-}
-
-static void note_digest_auth_failure(request_rec *r,
- const digest_config_rec *conf,
- digest_header_rec *resp, int stale)
-{
- const char *qop, *opaque, *opaque_param, *domain, *nonce;
- int cnt;
-
-
- /* Setup qop */
-
- if (conf->qop_list[0] == NULL)
- qop = ", qop=\"auth\"";
- else if (!strcasecmp(conf->qop_list[0], "none"))
- qop = "";
- else {
- qop = ap_pstrcat(r->pool, ", qop=\"", conf->qop_list[0], NULL);
- for (cnt=1; conf->qop_list[cnt] != NULL; cnt++)
- qop = ap_pstrcat(r->pool, qop, ",", conf->qop_list[cnt], NULL);
- qop = ap_pstrcat(r->pool, qop, "\"", NULL);
- }
-
- /* MD5-sess stuff */
-
- if (!stale && !strcasecmp(conf->algorithm, "MD5-sess"))
- clear_session(resp);
-
- /* Setup opaque */
-
- if (resp->opaque == NULL) {
- /* new client */
- if ((conf->check_nc || conf->nonce_lifetime == 0
- || !strcasecmp(conf->algorithm, "MD5-sess"))
- && (resp->client = gen_client(r)) != NULL)
- opaque = ltox(r->pool, resp->client->key);
- else
- opaque = ""; /* opaque not needed */
- }
- else if (resp->client == NULL) {
- /* client info was gc'd */
- resp->client = gen_client(r);
- if (resp->client != NULL) {
- opaque = ltox(r->pool, resp->client->key);
- stale = 1;
- client_list->num_renewed++;
- }
- else
- opaque = ""; /* ??? */
- }
- else {
- opaque = resp->opaque;
- /* we're generating a new nonce, so reset the nonce-count */
- resp->client->nonce_count = 0;
- }
-
- if (opaque[0])
- opaque_param = ap_pstrcat(r->pool, ", opaque=\"", opaque, "\"", NULL);
- else
- opaque_param = NULL;
-
- /* Setup nonce */
-
- nonce = gen_nonce(r->pool, r->request_time, opaque, r->server, conf);
- if (resp->client && conf->nonce_lifetime == 0)
- memcpy(resp->client->last_nonce, nonce, NONCE_LEN+1);
-
- /* setup domain attribute. We want to send this attribute wherever
- * possible so that the client won't send the Authorization header
- * unneccessarily (it's usually > 200 bytes!).
- */
-
- if (r->proxyreq)
- domain = NULL; /* don't send domain for proxy requests */
- else if (conf->uri_list)
- domain = conf->uri_list;
- else {
- /* They didn't specify any domain, so let's guess at it */
- domain = guess_domain(r->pool, resp->request_uri->path, r->filename,
- conf->dir_name);
- if (domain[0] == '/' && domain[1] == '\0')
- domain = NULL; /* "/" is the default, so no need to send it */
- else
- domain = ap_pstrcat(r->pool, ", domain=\"", domain, "\"", NULL);
- }
-
- ap_table_mergen(r->err_headers_out,
- r->proxyreq ? "Proxy-Authenticate" : "WWW-Authenticate",
- ap_psprintf(r->pool, "Digest realm=\"%s\", nonce=\"%s\", "
- "algorithm=%s%s%s%s%s",
- ap_auth_name(r), nonce, conf->algorithm,
- opaque_param ? opaque_param : "",
- domain ? domain : "",
- stale ? ", stale=true" : "", qop));
-}
-
-
-/*
- * Authorization header verification code
- */
-
-static const char *get_hash(request_rec *r, const char *user,
- const char *realm, const char *auth_pwfile)
-{
- configfile_t *f;
- char l[MAX_STRING_LEN];
- const char *rpw;
- char *w, *x;
- ap_status_t sts;
-
- if ((sts = ap_pcfg_openfile(&f, r->pool, auth_pwfile)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "Digest: Could not open password file: %s", auth_pwfile);
- return NULL;
- }
- while (!(ap_cfg_getline(l, MAX_STRING_LEN, f))) {
- if ((l[0] == '#') || (!l[0]))
- continue;
- rpw = l;
- w = ap_getword(r->pool, &rpw, ':');
- x = ap_getword(r->pool, &rpw, ':');
-
- if (x && w && !strcmp(user, w) && !strcmp(realm, x)) {
- ap_cfg_closefile(f);
- return ap_pstrdup(r->pool, rpw);
- }
- }
- ap_cfg_closefile(f);
- return NULL;
-}
-
-static int check_nc(const request_rec *r, const digest_header_rec *resp,
- const digest_config_rec *conf)
-{
- if (conf->check_nc && client_mm) {
- unsigned long nc;
-
- const char *snc = resp->nonce_count;
- char *endptr;
-
- nc = strtol(snc, &endptr, 16);
- if (endptr < (snc+strlen(snc)) && !ap_isspace(*endptr)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: invalid nc %s received - not a number", snc);
- return !OK;
- }
-
- if (!resp->client)
- return !OK;
-
- if (nc != resp->client->nonce_count) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, 0, r,
- "nonce-count check failed: %lu != %lu", nc,
- resp->client->nonce_count);
- return !OK;
- }
- }
-
- return OK;
-}
-
-static int check_nonce(request_rec *r, digest_header_rec *resp,
- const digest_config_rec *conf)
-{
- double dt;
- time_rec nonce_time;
- char tmp, hash[NONCE_HASH_LEN+1];
-
- if (strlen(resp->nonce) != NONCE_LEN) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: invalid nonce %s received - length is not %d",
- resp->nonce, NONCE_LEN);
- note_digest_auth_failure(r, conf, resp, 1);
- return AUTH_REQUIRED;
- }
-
- tmp = resp->nonce[NONCE_TIME_LEN];
- resp->nonce[NONCE_TIME_LEN] = '\0';
- ap_base64decode_binary(nonce_time.arr, resp->nonce);
- gen_nonce_hash(hash, resp->nonce, resp->opaque, r->server, conf);
- resp->nonce[NONCE_TIME_LEN] = tmp;
- resp->nonce_time = nonce_time.time;
-
- if (strcmp(hash, resp->nonce+NONCE_TIME_LEN)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: invalid nonce %s received - hash is not %s",
- resp->nonce, hash);
- note_digest_auth_failure(r, conf, resp, 1);
- return AUTH_REQUIRED;
- }
-
- dt = difftime(r->request_time, nonce_time.time);
- if (conf->nonce_lifetime > 0 && dt < 0) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: invalid nonce %s received - user attempted "
- "time travel", resp->nonce);
- note_digest_auth_failure(r, conf, resp, 1);
- return AUTH_REQUIRED;
- }
-
- if (conf->nonce_lifetime > 0) {
- if (dt > conf->nonce_lifetime) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0,r,
- "Digest: user %s: nonce expired - sending new nonce",
- r->user);
- note_digest_auth_failure(r, conf, resp, 1);
- return AUTH_REQUIRED;
- }
- }
- else if (conf->nonce_lifetime == 0 && resp->client) {
- if (memcmp(resp->client->last_nonce, resp->nonce, NONCE_LEN)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r,
- "Digest: user %s: one-time-nonce mismatch - sending "
- "new nonce", r->user);
- note_digest_auth_failure(r, conf, resp, 1);
- return AUTH_REQUIRED;
- }
- }
- /* else (lifetime < 0) => never expires */
-
- return OK;
-}
-
-/* The actual MD5 code... whee */
-
-static const char *old_digest(const request_rec *r,
- const digest_header_rec *resp, const char *ha1)
-{
- const char *ha2;
-
- /* rfc-2069 */
- ha2 = ap_md5(r->pool, (unsigned char *)ap_pstrcat(r->pool, r->method, ":",
- resp->uri, NULL));
- return ap_md5(r->pool,
- (unsigned char *)ap_pstrcat(r->pool, ha1, ":", resp->nonce,
- ":", ha2, NULL));
-}
-
-static const char *new_digest(const request_rec *r,
- digest_header_rec *resp,
- const digest_config_rec *conf)
-{
- const char *ha1, *ha2, *a2;
-
- /* draft-ietf-http-authentication-03 */
- if (resp->algorithm && !strcasecmp(resp->algorithm, "MD5-sess"))
- ha1 = get_session(r, resp, conf);
- else
- ha1 = conf->ha1;
-
- if (resp->message_qop && !strcasecmp(resp->message_qop, "auth-int"))
- a2 = ap_pstrcat(r->pool, r->method, ":", resp->uri, ":",
- ap_md5(r->pool, (const unsigned char*) ""), NULL); /* TBD */
- else
- a2 = ap_pstrcat(r->pool, r->method, ":", resp->uri, NULL);
- ha2 = ap_md5(r->pool, (const unsigned char *)a2);
-
- return ap_md5(r->pool,
- (unsigned char *)ap_pstrcat(r->pool, ha1, ":", resp->nonce,
- ":", resp->nonce_count, ":",
- resp->cnonce, ":",
- resp->message_qop, ":", ha2,
- NULL));
-}
-
-
-/* These functions return 0 if client is OK, and proper error status
- * if not... either AUTH_REQUIRED, if we made a check, and it failed, or
- * SERVER_ERROR, if things are so totally confused that we couldn't
- * figure out how to tell if the client is authorized or not.
- *
- * If they return DECLINED, and all other modules also decline, that's
- * treated by the server core as a configuration error, logged and
- * reported as such.
- */
-
-/* Determine user ID, and check if the attributes are correct, if it
- * really is that user, if the nonce is correct, etc.
- */
-
-static int authenticate_digest_user(request_rec *r)
-{
- digest_config_rec *conf;
- digest_header_rec *resp;
- request_rec *mainreq;
- const char *t;
- int res;
-
-
- /* do we require Digest auth for this URI? */
-
- if (!(t = ap_auth_type(r)) || strcasecmp(t, "Digest"))
- return DECLINED;
-
- if (!ap_auth_name(r)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: need AuthName: %s", r->uri);
- return SERVER_ERROR;
- }
-
-
- /* get the client response and mark */
-
- mainreq = r;
- while (mainreq->main != NULL) mainreq = mainreq->main;
- while (mainreq->prev != NULL) mainreq = mainreq->prev;
- resp = (digest_header_rec *) ap_get_module_config(mainreq->request_config,
- &digest_auth_module);
- resp->needed_auth = 1;
-
-
- /* get our conf */
-
- conf = (digest_config_rec *) ap_get_module_config(r->per_dir_config,
- &digest_auth_module);
-
-
- /* check for existence and syntax of Auth header */
-
- if (resp->auth_hdr_sts != VALID) {
- if (resp->auth_hdr_sts == NOT_DIGEST)
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: client used wrong authentication scheme "
- "`%s': %s", resp->scheme, r->uri);
- else if (resp->auth_hdr_sts == INVALID)
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: missing user, realm, nonce, uri, or digest "
- "in authorization header: %s", r->uri);
- /* else (resp->auth_hdr_sts == NO_HEADER) */
- note_digest_auth_failure(r, conf, resp, 0);
- return AUTH_REQUIRED;
- }
-
- r->user = (char *) resp->username;
- r->ap_auth_type = (char *) "Digest";
-
-
- /* check the auth attributes */
-
- if (strcmp(resp->uri, resp->request_uri->path)) {
- uri_components *r_uri = resp->request_uri, d_uri;
- int port;
-
- if (ap_parse_uri_components(r->pool, resp->uri, &d_uri) != HTTP_OK) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: invalid uri <%s> in Authorization header",
- resp->uri);
- return BAD_REQUEST;
- }
-
- if (d_uri.hostname)
- ap_unescape_url(d_uri.hostname);
- if (d_uri.path)
- ap_unescape_url(d_uri.path);
- if (d_uri.query)
- ap_unescape_url(d_uri.query);
- if (r_uri->query)
- ap_unescape_url(r_uri->query);
- port = ap_get_server_port(r);
-
- if ((d_uri.hostname && d_uri.hostname[0] != '\0'
- && strcasecmp(d_uri.hostname, ap_get_server_name(r)))
- || (d_uri.port_str && d_uri.port != port)
- || (d_uri.hostname && d_uri.hostname[0] != '\0'
- && !d_uri.port_str && port != ap_default_port(r))
- || !d_uri.path || strcmp(d_uri.path, r_uri->path)
- || (d_uri.query != r_uri->query
- && (!d_uri.query || !r_uri->query
- || strcmp(d_uri.query, r_uri->query)))
- ) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: uri mismatch - <%s> does not match "
- "request-uri <%s>", resp->uri,
- ap_unparse_uri_components(r->pool, r_uri, 0));
- return BAD_REQUEST;
- }
- }
-
- if (resp->opaque && resp->opaque_num == 0) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: received invalid opaque - got `%s'",
- resp->opaque);
- note_digest_auth_failure(r, conf, resp, 0);
- return AUTH_REQUIRED;
- }
-
- if (strcmp(resp->realm, conf->realm)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: realm mismatch - got `%s' but expected `%s'",
- resp->realm, conf->realm);
- note_digest_auth_failure(r, conf, resp, 0);
- return AUTH_REQUIRED;
- }
-
- if (resp->algorithm != NULL
- && strcasecmp(resp->algorithm, "MD5")
- && strcasecmp(resp->algorithm, "MD5-sess")) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: unknown algorithm `%s' received: %s",
- resp->algorithm, r->uri);
- note_digest_auth_failure(r, conf, resp, 0);
- return AUTH_REQUIRED;
- }
-
- if (!conf->pwfile)
- return DECLINED;
-
- if (!(conf->ha1 = get_hash(r, r->user, conf->realm, conf->pwfile))) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: user `%s' in realm `%s' not found: %s",
- r->user, conf->realm, r->uri);
- note_digest_auth_failure(r, conf, resp, 0);
- return AUTH_REQUIRED;
- }
-
- if (resp->message_qop == NULL) {
- /* old (rfc-2069) style digest */
- if (strcmp(resp->digest, old_digest(r, resp, conf->ha1))) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: user %s: password mismatch: %s", r->user,
- r->uri);
- note_digest_auth_failure(r, conf, resp, 0);
- return AUTH_REQUIRED;
- }
- }
- else {
- int match = 0, idx;
- for (idx=0; conf->qop_list[idx] != NULL; idx++) {
- if (!strcasecmp(conf->qop_list[idx], resp->message_qop)) {
- match = 1;
- break;
- }
- }
-
- if (!match
- && !(conf->qop_list[0] == NULL
- && !strcasecmp(resp->message_qop, "auth"))) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: invalid qop `%s' received: %s",
- resp->message_qop, r->uri);
- note_digest_auth_failure(r, conf, resp, 0);
- return AUTH_REQUIRED;
- }
-
- if (strcmp(resp->digest, new_digest(r, resp, conf))) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: user %s: password mismatch: %s", r->user,
- r->uri);
- note_digest_auth_failure(r, conf, resp, 0);
- return AUTH_REQUIRED;
- }
- }
-
- if (check_nc(r, resp, conf) != OK) {
- note_digest_auth_failure(r, conf, resp, 0);
- return AUTH_REQUIRED;
- }
-
- /* Note: this check is done last so that a "stale=true" can be
- generated if the nonce is old */
- if ((res = check_nonce(r, resp, conf)))
- return res;
-
- return OK;
-}
-
-
-/*
- * Checking ID
- */
-
-static ap_table_t *groups_for_user(request_rec *r, const char *user,
- const char *grpfile)
-{
- configfile_t *f;
- ap_table_t *grps = ap_make_table(r->pool, 15);
- ap_context_t *sp;
- char l[MAX_STRING_LEN];
- const char *group_name, *ll, *w;
- ap_status_t sts;
-
- if ((sts = ap_pcfg_openfile(&f, r->pool, grpfile)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "Digest: Could not open group file: %s", grpfile);
- return NULL;
- }
-
- if (ap_create_context(&sp, r->pool) != APR_SUCCESS)
- return NULL;
-
- while (!(ap_cfg_getline(l, MAX_STRING_LEN, f))) {
- if ((l[0] == '#') || (!l[0]))
- continue;
- ll = l;
- ap_clear_pool(sp);
-
- group_name = ap_getword(sp, &ll, ':');
-
- while (ll[0]) {
- w = ap_getword_conf(sp, &ll);
- if (!strcmp(w, user)) {
- ap_table_setn(grps, ap_pstrdup(r->pool, group_name), "in");
- break;
- }
- }
- }
-
- ap_cfg_closefile(f);
- ap_destroy_pool(sp);
- return grps;
-}
-
-
-static int digest_check_auth(request_rec *r)
-{
- const digest_config_rec *conf =
- (digest_config_rec *) ap_get_module_config(r->per_dir_config,
- &digest_auth_module);
- const char *user = r->user;
- int m = r->method_number;
- int method_restricted = 0;
- register int x;
- const char *t, *w;
- ap_table_t *grpstatus;
- const ap_array_header_t *reqs_arr;
- require_line *reqs;
-
- if (!(t = ap_auth_type(r)) || strcasecmp(t, "Digest"))
- return DECLINED;
-
- reqs_arr = ap_requires(r);
- /* If there is no "requires" directive, then any user will do.
- */
- if (!reqs_arr)
- return OK;
- reqs = (require_line *) reqs_arr->elts;
-
- if (conf->grpfile)
- grpstatus = groups_for_user(r, user, conf->grpfile);
- else
- grpstatus = NULL;
-
- for (x = 0; x < reqs_arr->nelts; x++) {
-
- if (!(reqs[x].method_mask & (1 << m)))
- continue;
-
- method_restricted = 1;
-
- t = reqs[x].requirement;
- w = ap_getword_white(r->pool, &t);
- if (!strcasecmp(w, "valid-user"))
- return OK;
- else if (!strcasecmp(w, "user")) {
- while (t[0]) {
- w = ap_getword_conf(r->pool, &t);
- if (!strcmp(user, w))
- return OK;
- }
- }
- else if (!strcasecmp(w, "group")) {
- if (!grpstatus)
- return DECLINED;
-
- while (t[0]) {
- w = ap_getword_conf(r->pool, &t);
- if (ap_table_get(grpstatus, w))
- return OK;
- }
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: access to %s failed, reason: unknown require "
- "directive \"%s\"", r->uri, reqs[x].requirement);
- return DECLINED;
- }
- }
-
- if (!method_restricted)
- return OK;
-
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Digest: access to %s failed, reason: user %s not allowed access",
- r->uri, user);
-
- note_digest_auth_failure(r, conf,
- (digest_header_rec *) ap_get_module_config(r->request_config,
- &digest_auth_module),
- 0);
- return AUTH_REQUIRED;
-}
-
-
-/*
- * Authorization-Info header code
- */
-
-#ifdef SEND_DIGEST
-static const char *hdr(const ap_table_t *tbl, const char *name)
-{
- const char *val = ap_table_get(tbl, name);
- if (val)
- return val;
- else
- return "";
-}
-#endif
-
-static int add_auth_info(request_rec *r)
-{
- const digest_config_rec *conf =
- (digest_config_rec *) ap_get_module_config(r->per_dir_config,
- &digest_auth_module);
- digest_header_rec *resp =
- (digest_header_rec *) ap_get_module_config(r->request_config,
- &digest_auth_module);
- const char *ai = NULL, *digest = NULL, *nextnonce = "";
-
- if (resp == NULL || !resp->needed_auth || conf == NULL)
- return OK;
-
-
- /* rfc-2069 digest
- */
- if (resp->message_qop == NULL) {
- /* old client, so calc rfc-2069 digest */
-
-#ifdef SEND_DIGEST
- /* most of this totally bogus because the handlers don't set the
- * headers until the final handler phase (I wonder why this phase
- * is called fixup when there's almost nothing you can fix up...)
- *
- * Because it's basically impossible to get this right (e.g. the
- * Content-length is never set yet when we get here, and we can't
- * calc the entity hash) it's best to just leave this #def'd out.
- */
- char *entity_info =
- ap_md5(r->pool,
- (unsigned char *) ap_pstrcat(r->pool,
- ap_unparse_uri_components(r->pool,
- resp->request_uri, 0), ":",
- r->content_type ? r->content_type : ap_default_type(r), ":",
- hdr(r->headers_out, "Content-Length"), ":",
- r->content_encoding ? r->content_encoding : "", ":",
- hdr(r->headers_out, "Last-Modified"), ":",
- r->no_cache && !ap_table_get(r->headers_out, "Expires") ?
- ap_gm_timestr_822(r->pool, r->request_time) :
- hdr(r->headers_out, "Expires"),
- NULL));
- digest =
- ap_md5(r->pool,
- (unsigned char *)ap_pstrcat(r->pool, conf->ha1, ":",
- resp->nonce, ":",
- r->method, ":",
- ap_gm_timestr_822(r->pool, r->request_time), ":",
- entity_info, ":",
- ap_md5(r->pool, (unsigned char *) ""), /* H(entity) - TBD */
- NULL));
-#endif
- }
-
-
- /* setup nextnonce
- */
- if (conf->nonce_lifetime > 0) {
- /* send nextnonce if current nonce will expire in less than 30 secs */
- if (difftime(r->request_time, resp->nonce_time) > (conf->nonce_lifetime-NEXTNONCE_DELTA)) {
- nextnonce = ap_pstrcat(r->pool, ", nextnonce=\"",
- gen_nonce(r->pool, r->request_time,
- resp->opaque, r->server, conf),
- "\"", NULL);
- resp->client->nonce_count = 0;
- }
- }
- else if (conf->nonce_lifetime == 0 && resp->client) {
- const char *nonce = gen_nonce(r->pool, 0, resp->opaque, r->server,
- conf);
- nextnonce = ap_pstrcat(r->pool, ", nextnonce=\"", nonce, "\"", NULL);
- memcpy(resp->client->last_nonce, nonce, NONCE_LEN+1);
- }
- /* else nonce never expires, hence no nextnonce */
-
-
- /* do rfc-2069 digest
- */
- if (conf->qop_list[0] && !strcasecmp(conf->qop_list[0], "none")
- && resp->message_qop == NULL) {
- /* use only RFC-2069 format */
- if (digest)
- ai = ap_pstrcat(r->pool, "digest=\"", digest, "\"", nextnonce,NULL);
- else
- ai = nextnonce;
- }
- else {
- const char *resp_dig, *ha1, *a2, *ha2;
-
- /* calculate rspauth attribute
- */
- if (resp->algorithm && !strcasecmp(resp->algorithm, "MD5-sess"))
- ha1 = get_session(r, resp, conf);
- else
- ha1 = conf->ha1;
-
- if (resp->message_qop && !strcasecmp(resp->message_qop, "auth-int"))
- a2 = ap_pstrcat(r->pool, ":", resp->uri, ":",
- ap_md5(r->pool, (const unsigned char *) ""), NULL); /* TBD */
- else
- a2 = ap_pstrcat(r->pool, ":", resp->uri, NULL);
- ha2 = ap_md5(r->pool, (const unsigned char *)a2);
-
- resp_dig = ap_md5(r->pool,
- (unsigned char *)ap_pstrcat(r->pool, ha1, ":",
- resp->nonce, ":",
- resp->nonce_count, ":",
- resp->cnonce, ":",
- resp->message_qop ?
- resp->message_qop : "",
- ":", ha2, NULL));
-
- /* assemble Authentication-Info header
- */
- ai = ap_pstrcat(r->pool,
- "rspauth=\"", resp_dig, "\"",
- nextnonce,
- resp->cnonce ? ", cnonce=\"" : "",
- resp->cnonce ? ap_escape_quotes(r->pool, resp->cnonce) :
- "",
- resp->cnonce ? "\"" : "",
- resp->nonce_count ? ", nc=" : "",
- resp->nonce_count ? resp->nonce_count : "",
- resp->message_qop ? ", qop=" : "",
- resp->message_qop ? resp->message_qop : "",
- digest ? "digest=\"" : "",
- digest ? digest : "",
- digest ? "\"" : "",
- NULL);
- }
-
- if (ai && ai[0])
- ap_table_mergen(r->headers_out,
- r->proxyreq ? "Proxy-Authentication-Info" :
- "Authentication-Info",
- ai);
- return OK;
-}
-
-
-static void register_hooks(void)
-{
- static const char * const cfgPost[]={ "http_core.c", NULL };
- static const char * const parsePre[]={ "mod_proxy.c", NULL };
-
- ap_hook_post_config(initialize_module, NULL, cfgPost, NULL);
- ap_hook_post_read_request(parse_hdr_and_update_nc, parsePre, NULL, NULL);
- ap_hook_check_user_id(authenticate_digest_user, NULL, NULL, HOOK_MIDDLE);
- ap_hook_auth_checker(digest_check_auth, NULL, NULL, HOOK_MIDDLE);
- ap_hook_fixups(add_auth_info, NULL, NULL, HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT digest_auth_module =
-{
- STANDARD20_MODULE_STUFF,
- create_digest_dir_config, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- digest_cmds, /* command table */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
-
diff --git a/modules/arch/win32/mod_isapi.c b/modules/arch/win32/mod_isapi.c
deleted file mode 100644
index 86aee51558..0000000000
--- a/modules/arch/win32/mod_isapi.c
+++ /dev/null
@@ -1,569 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_isapi.c - Internet Server Application (ISA) module for Apache
- * by Alexei Kosut <akosut@apache.org>
- *
- * This module implements Microsoft's ISAPI, allowing Apache (when running
- * under Windows) to load Internet Server Applications (ISAPI extensions).
- * It implements all of the ISAPI 2.0 specification, except for the
- * "Microsoft-only" extensions dealing with asynchronous I/O. All ISAPI
- * extensions that use only synchronous I/O and are compatible with the
- * ISAPI 2.0 specification should work (most ISAPI 1.0 extensions should
- * function as well).
- *
- * To load, simply place the ISA in a location in the document tree.
- * Then add an "AddHandler isapi-isa dll" into your config file.
- * You should now be able to load ISAPI DLLs just be reffering to their
- * URLs. Make sure the ExecCGI option is active in the directory
- * the ISA is in.
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_request.h"
-#include "http_log.h"
-#include "util_script.h"
-
-/* We use the exact same header file as the original */
-#include <HttpExt.h>
-
-/* Seems IIS does not enforce the requirement for \r\n termination on HSE_REQ_SEND_RESPONSE_HEADER,
- define this to conform */
-#define RELAX_HEADER_RULE
-
-module isapi_module;
-
-/* Our "Connection ID" structure */
-
-typedef struct {
- LPEXTENSION_CONTROL_BLOCK ecb;
- request_rec *r;
- int status;
-} isapi_cid;
-
-/* Declare the ISAPI functions */
-
-BOOL WINAPI GetServerVariable (HCONN hConn, LPSTR lpszVariableName,
- LPVOID lpvBuffer, LPDWORD lpdwSizeofBuffer);
-BOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpwdwBytes,
- DWORD dwReserved);
-BOOL WINAPI ReadClient (HCONN ConnID, LPVOID lpvBuffer, LPDWORD lpdwSize);
-BOOL WINAPI ServerSupportFunction (HCONN hConn, DWORD dwHSERequest,
- LPVOID lpvBuffer, LPDWORD lpdwSize,
- LPDWORD lpdwDataType);
-
-/*
- The optimiser blows it totally here. What happens is that autos are addressed relative to the
- stack pointer, which, of course, moves around. The optimiser seems to lose track of it somewhere
- between setting isapi_entry and calling through it. We work around the problem by forcing it to
- use frame pointers.
-*/
-#pragma optimize("y",off)
-
-int isapi_handler (request_rec *r) {
- LPEXTENSION_CONTROL_BLOCK ecb =
- ap_pcalloc(r->pool, sizeof(struct _EXTENSION_CONTROL_BLOCK));
- HSE_VERSION_INFO *pVer = ap_pcalloc(r->pool, sizeof(HSE_VERSION_INFO));
-
- HINSTANCE isapi_handle;
- BOOL (*isapi_version)(HSE_VERSION_INFO *); /* entry point 1 */
- DWORD (*isapi_entry)(LPEXTENSION_CONTROL_BLOCK); /* entry point 2 */
- BOOL (*isapi_term)(DWORD); /* optional entry point 3 */
-
- isapi_cid *cid = ap_pcalloc(r->pool, sizeof(isapi_cid));
- ap_table_t *e = r->subprocess_env;
- int retval;
-
- /* Use similar restrictions as CGIs */
-
- if (!(ap_allow_options(r) & OPT_EXECCGI))
- return FORBIDDEN;
-
- if (r->finfo.st_mode == 0)
- return NOT_FOUND;
-
- if (S_ISDIR(r->finfo.st_mode))
- return FORBIDDEN;
-
- /* Load the module */
-
- if (!(isapi_handle = LoadLibraryEx(r->filename, NULL,
- LOAD_WITH_ALTERED_SEARCH_PATH))) {
- ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
- "Could not load DLL: %s", r->filename);
- return SERVER_ERROR;
- }
-
- if (!(isapi_version =
- (void *)(GetProcAddress(isapi_handle, "GetExtensionVersion")))) {
- ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
- "DLL could not load GetExtensionVersion(): %s", r->filename);
- FreeLibrary(isapi_handle);
- return SERVER_ERROR;
- }
-
- if (!(isapi_entry =
- (void *)(GetProcAddress(isapi_handle, "HttpExtensionProc")))) {
- ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
- "DLL could not load HttpExtensionProc(): %s", r->filename);
- FreeLibrary(isapi_handle);
- return SERVER_ERROR;
- }
-
- isapi_term = (void *)(GetProcAddress(isapi_handle, "TerminateExtension"));
-
- /* Run GetExtensionVersion() */
-
- if (!(*isapi_version)(pVer)) {
- ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
- "ISAPI GetExtensionVersion() failed: %s", r->filename);
- FreeLibrary(isapi_handle);
- return SERVER_ERROR;
- }
-
- /* Set up variables */
- ap_add_common_vars(r);
- ap_add_cgi_vars(r);
-
- /* Set up connection ID */
- ecb->ConnID = (HCONN)cid;
- cid->ecb = ecb;
- cid->r = r;
- cid->status = 0;
-
- ecb->cbSize = sizeof(struct _EXTENSION_CONTROL_BLOCK);
- ecb->dwVersion = MAKELONG(0, 2);
- ecb->dwHttpStatusCode = 0;
- strcpy(ecb->lpszLogData, "");
- ecb->lpszMethod = r->method;
- ecb->lpszQueryString = ap_table_get(e, "QUERY_STRING");
- ecb->lpszPathInfo = ap_table_get(e, "PATH_INFO");
- ecb->lpszPathTranslated = ap_table_get(e, "PATH_TRANSLATED");
- ecb->lpszContentType = ap_table_get(e, "CONTENT_TYPE");
-
- /* Set up client input */
- if ((retval = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
- if (isapi_term) (*isapi_term)(HSE_TERM_MUST_UNLOAD);
- FreeLibrary(isapi_handle);
- return retval;
- }
-
- if (ap_should_client_block(r)) {
- /* Unlike IIS, which limits this to 48k, we read the whole
- * sucker in. I suppose this could be bad for memory if someone
- * uploaded the complete works of Shakespeare. Well, WebSite
- * does the same thing.
- */
- long to_read = atol(ap_table_get(e, "CONTENT_LENGTH"));
- long read;
-
- /* Actually, let's cap it at 48k, until we figure out what
- * to do with this... we don't want a Content-Length: 1000000000
- * taking out the machine.
- */
-
- if (to_read > 49152) {
- if (isapi_term) (*isapi_term)(HSE_TERM_MUST_UNLOAD);
- FreeLibrary(isapi_handle);
- return HTTP_REQUEST_ENTITY_TOO_LARGE;
- }
-
- ecb->lpbData = ap_pcalloc(r->pool, 1 + to_read);
-
- if ((read = ap_get_client_block(r, ecb->lpbData, to_read)) < 0) {
- if (isapi_term) (*isapi_term)(HSE_TERM_MUST_UNLOAD);
- FreeLibrary(isapi_handle);
- return SERVER_ERROR;
- }
-
- /* Although its not to spec, IIS seems to null-terminate
- * its lpdData string. So we will too. To make sure
- * cbAvailable matches cbTotalBytes, we'll up the latter
- * and equalize them.
- */
- ecb->cbAvailable = ecb->cbTotalBytes = read + 1;
- ecb->lpbData[read] = '\0';
- }
- else {
- ecb->cbTotalBytes = 0;
- ecb->cbAvailable = 0;
- ecb->lpbData = NULL;
- }
-
- /* Set up the callbacks */
-
- ecb->GetServerVariable = &GetServerVariable;
- ecb->WriteClient = &WriteClient;
- ecb->ReadClient = &ReadClient;
- ecb->ServerSupportFunction = &ServerSupportFunction;
-
- /* All right... try and load the sucker */
- retval = (*isapi_entry)(ecb);
-
- /* Set the status (for logging) */
- if (ecb->dwHttpStatusCode)
- r->status = ecb->dwHttpStatusCode;
-
- /* Check for a log message - and log it */
- if (ecb->lpszLogData && strcmp(ecb->lpszLogData, ""))
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "%s: %s", ecb->lpszLogData, r->filename);
-
- /* All done with the DLL... get rid of it */
- if (isapi_term) (*isapi_term)(HSE_TERM_MUST_UNLOAD);
- FreeLibrary(isapi_handle);
-
- switch(retval) {
- case HSE_STATUS_SUCCESS:
- case HSE_STATUS_SUCCESS_AND_KEEP_CONN:
- /* Ignore the keepalive stuff; Apache handles it just fine without
- * the ISA's "advice".
- */
-
- if (cid->status) /* We have a special status to return */
- return cid->status;
-
- return OK;
- case HSE_STATUS_PENDING: /* We don't support this */
- ap_log_rerror(APLOG_MARK, APLOG_WARNING, r,
- "ISAPI asynchronous I/O not supported: %s", r->filename);
- case HSE_STATUS_ERROR:
- default:
- return SERVER_ERROR;
- }
-
-}
-#pragma optimize("",on)
-
-BOOL WINAPI GetServerVariable (HCONN hConn, LPSTR lpszVariableName,
- LPVOID lpvBuffer, LPDWORD lpdwSizeofBuffer) {
- request_rec *r = ((isapi_cid *)hConn)->r;
- ap_table_t *e = r->subprocess_env;
- const char *result;
-
- /* Mostly, we just grab it from the environment, but there are
- * a couple of special cases
- */
-
- if (!strcasecmp(lpszVariableName, "UNMAPPED_REMOTE_USER")) {
- /* We don't support NT users, so this is always the same as
- * REMOTE_USER
- */
- result = ap_table_get(e, "REMOTE_USER");
- }
- else if (!strcasecmp(lpszVariableName, "SERVER_PORT_SECURE")) {
- /* Apache doesn't support secure requests inherently, so
- * we have no way of knowing. We'll be conservative, and say
- * all requests are insecure.
- */
- result = "0";
- }
- else if (!strcasecmp(lpszVariableName, "URL")) {
- result = r->uri;
- }
- else {
- result = ap_table_get(e, lpszVariableName);
- }
-
- if (result) {
- if (strlen(result) > *lpdwSizeofBuffer) {
- *lpdwSizeofBuffer = strlen(result);
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
- return FALSE;
- }
- strncpy(lpvBuffer, result, *lpdwSizeofBuffer);
- return TRUE;
- }
-
- /* Didn't find it */
- SetLastError(ERROR_INVALID_INDEX);
- return FALSE;
-}
-
-BOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpwdwBytes,
- DWORD dwReserved) {
- request_rec *r = ((isapi_cid *)ConnID)->r;
- int writ; /* written, actually, but why shouldn't I make up words? */
-
- /* We only support synchronous writing */
- if (dwReserved && dwReserved != HSE_IO_SYNC) {
- ap_log_rerror(APLOG_MARK, APLOG_WARNING, r,
- "ISAPI asynchronous I/O not supported: %s", r->filename);
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- if ((writ = ap_rwrite(Buffer, *lpwdwBytes, r)) == EOF) {
- SetLastError(ERROR); /* XXX: Find the right error code */
- return FALSE;
- }
-
- *lpwdwBytes = writ;
- return TRUE;
-}
-
-BOOL WINAPI ReadClient (HCONN ConnID, LPVOID lpvBuffer, LPDWORD lpdwSize) {
- /* Doesn't need to do anything; we've read all the data already */
- return TRUE;
-}
-
-/* XXX: There is an O(n^2) attack possible here. */
-BOOL WINAPI ServerSupportFunction (HCONN hConn, DWORD dwHSERequest,
- LPVOID lpvBuffer, LPDWORD lpdwSize,
- LPDWORD lpdwDataType) {
- isapi_cid *cid = (isapi_cid *)hConn;
- request_rec *subreq, *r = cid->r;
- char *data;
-
- switch (dwHSERequest) {
- case HSE_REQ_SEND_URL_REDIRECT_RESP:
- /* Set the status to be returned when the HttpExtensionProc()
- * is done.
- */
- ap_table_set (r->headers_out, "Location", lpvBuffer);
- cid->status = cid->r->status = cid->ecb->dwHttpStatusCode = REDIRECT;
- return TRUE;
-
- case HSE_REQ_SEND_URL:
- /* Read any additional input */
-
- if (r->remaining > 0) {
- char argsbuffer[HUGE_STRING_LEN];
-
- while (ap_get_client_block(r, argsbuffer, HUGE_STRING_LEN));
- }
-
- /* Reset the method to GET */
- r->method = ap_pstrdup(r->pool, "GET");
- r->method_number = M_GET;
-
- /* Don't let anyone think there's still data */
- ap_table_unset(r->headers_in, "Content-Length");
-
- ap_internal_redirect((char *)lpvBuffer, r);
- return TRUE;
-
- case HSE_REQ_SEND_RESPONSE_HEADER:
- r->status_line = lpvBuffer ? lpvBuffer : ap_pstrdup(r->pool, "200 OK");
- sscanf(r->status_line, "%d", &r->status);
- cid->ecb->dwHttpStatusCode = r->status;
-
- /* Now fill in the HTTP headers, and the rest of it. Ick.
- * lpdwDataType contains a string that has headers (in MIME
- * format), a blank like, then (possibly) data. We need
- * to parse it.
- *
- * Easy case first:
- */
- if (!lpdwDataType) {
- ap_send_http_header(r);
- return TRUE;
- }
-
- /* Make a copy - don't disturb the original */
- data = ap_pstrdup(r->pool, (char *)lpdwDataType);
-
- /* We *should* break before this while loop ends */
- while (*data) {
- char *value, *lf = strchr(data, '\n');
- int p;
-
-#ifdef RELAX_HEADER_RULE
- if (lf)
- *lf = '\0';
-#else
- if (!lf) { /* Huh? Invalid data, I think */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "ISA sent invalid headers: %s", r->filename);
- SetLastError(ERROR); /* XXX: Find right error */
- return FALSE;
- }
-
- /* Get rid of \n and \r */
- *lf = '\0';
-#endif
- p = strlen(data);
- if (p > 0 && data[p-1] == '\r') data[p-1] = '\0';
-
- /* End of headers */
- if (*data == '\0') {
-#ifdef RELAX_HEADER_RULE
- if (lf)
-#endif
- data = lf + 1; /* Reset data */
- break;
- }
-
- if (!(value = strchr(data, ':'))) {
- SetLastError(ERROR); /* XXX: Find right error */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "ISA sent invalid headers", r->filename);
- return FALSE;
- }
-
- *value++ = '\0';
- while (*value && ap_isspace(*value)) ++value;
-
- /* Check all the special-case headers. Similar to what
- * ap_scan_script_header_err() does (see that function for
- * more detail)
- */
-
- if (!strcasecmp(data, "Content-Type")) {
- char *tmp;
- /* Nuke trailing whitespace */
-
- char *endp = value + strlen(value) - 1;
- while (endp > value && ap_isspace(*endp)) *endp-- = '\0';
-
- tmp = ap_pstrdup (r->pool, value);
- ap_str_tolower(tmp);
- r->content_type = tmp;
- }
- else if (!strcasecmp(data, "Content-Length")) {
- ap_table_set(r->headers_out, data, value);
- }
- else if (!strcasecmp(data, "Transfer-Encoding")) {
- ap_table_set(r->headers_out, data, value);
- }
- else if (!strcasecmp(data, "Set-Cookie")) {
- ap_table_add(r->err_headers_out, data, value);
- }
- else {
- ap_table_merge(r->err_headers_out, data, value);
- }
-
- /* Reset data */
-#ifdef RELAX_HEADER_RULE
- if (!lf) {
- data += p;
- break;
- }
-#endif
- data = lf + 1;
- }
-
- /* All the headers should be set now */
-
- ap_send_http_header(r);
-
- /* Any data left should now be sent directly */
- ap_rputs(data, r);
-
- return TRUE;
-
- case HSE_REQ_MAP_URL_TO_PATH:
- /* Map a URL to a filename */
- subreq = ap_sub_req_lookup_uri(ap_pstrndup(r->pool, (char *)lpvBuffer,
- *lpdwSize), r);
-
- GetFullPathName(subreq->filename, *lpdwSize - 1, (char *)lpvBuffer, NULL);
-
- /* IIS puts a trailing slash on directories, Apache doesn't */
-
- if (S_ISDIR (subreq->finfo.st_mode)) {
- int l = strlen((char *)lpvBuffer);
-
- ((char *)lpvBuffer)[l] = '\\';
- ((char *)lpvBuffer)[l + 1] = '\0';
- }
-
- return TRUE;
-
- case HSE_REQ_DONE_WITH_SESSION:
- /* Do nothing... since we don't support async I/O, they'll
- * return from HttpExtensionProc soon
- */
- return TRUE;
-
- /* We don't support all this async I/O, Microsoft-specific stuff */
- case HSE_REQ_IO_COMPLETION:
- case HSE_REQ_TRANSMIT_FILE:
- ap_log_rerror(APLOG_MARK, APLOG_WARNING, r,
- "ISAPI asynchronous I/O not supported: %s", r->filename);
- default:
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-}
-
-handler_rec isapi_handlers[] = {
-{ "isapi-isa", isapi_handler },
-{ NULL}
-};
-
-module isapi_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- NULL, /* create per-dir config */
- NULL, /* merge per-dir config */
- NULL, /* server config */
- NULL, /* merge server config */
- NULL, /* command ap_table_t */
- isapi_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* logger */
- NULL /* header parser */
-};
diff --git a/modules/cache/.indent.pro b/modules/cache/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/cache/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/echo/.indent.pro b/modules/echo/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/echo/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/echo/mod_echo.c b/modules/echo/mod_echo.c
deleted file mode 100644
index dabe5d1739..0000000000
--- a/modules/echo/mod_echo.c
+++ /dev/null
@@ -1,75 +0,0 @@
-#include "ap_config.h"
-#include "ap_mmn.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_connection.h"
-
-API_VAR_EXPORT module echo_module;
-
-typedef struct
- {
- int bEnabled;
- } EchoConfig;
-
-static void *create_echo_server_config(ap_context_t *p,server_rec *s)
- {
- EchoConfig *pConfig=ap_pcalloc(p,sizeof *pConfig);
-
- pConfig->bEnabled=0;
-
- return pConfig;
- }
-
-static const char *echo_on(cmd_parms *cmd, void *dummy, char *arg)
- {
- EchoConfig *pConfig=ap_get_module_config(cmd->server->module_config,
- &echo_module);
- pConfig->bEnabled=1;
-
- return NULL;
- }
-
-static int process_echo_connection(conn_rec *c)
- {
- char buf[1024];
- EchoConfig *pConfig=ap_get_module_config(c->base_server->module_config,
- &echo_module);
-
- if(!pConfig->bEnabled)
- return DECLINED;
-
- for( ; ; )
- {
- ap_ssize_t r, w;
- (void) ap_bread(c->client,buf,sizeof buf,&r);
- if(r <= 0)
- break;
- (void) ap_bwrite(c->client,buf,r, &w);
- if(w != r)
- break;
- ap_bflush(c->client);
- }
- return OK;
- }
-
-static const command_rec echo_cmds[] = {
-{ "ProtocolEcho", echo_on, NULL, RSRC_CONF, RAW_ARGS,
- "Run an echo server on this host" },
-{ NULL }
-};
-
-static void register_hooks()
-{
- ap_hook_process_connection(process_echo_connection,NULL,NULL,HOOK_MIDDLE);
-}
-
-API_VAR_EXPORT module echo_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- create_echo_server_config, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- echo_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/experimental/.cvsignore b/modules/experimental/.cvsignore
deleted file mode 100644
index 8b4c6e3da4..0000000000
--- a/modules/experimental/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-*.lo
-*.so
diff --git a/modules/experimental/.indent.pro b/modules/experimental/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/experimental/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/experimental/README b/modules/experimental/README
deleted file mode 100644
index 77abc097c0..0000000000
--- a/modules/experimental/README
+++ /dev/null
@@ -1,53 +0,0 @@
-README for Apache 1.2 Example Module
-[April, 1997]
-
-The files in the src/modules/example directory under the Apache
-distribution directory tree are provided as an example to those that
-wish to write modules that use the Apache API.
-
-The main file is mod_example.c, which illustrates all the different
-callback mechanisms and call syntaces. By no means does an add-on
-module need to include routines for all of the callbacks - quite the
-contrary!
-
-The example module is an actual working module. If you link it into
-your server, enable the "example-handler" handler for a location, and then
-browse to that location, you will see a display of some of the tracing
-the example module did as the various callbacks were made.
-
-To include the example module in your server, follow the steps below:
-
- 1. Uncomment the "Module example_module" line near the bottom of
- the src/Configuration file. If there isn't one, add it; it
- should look like this:
-
- Module example_module modules/example/mod_example.o
-
- 2. Run the src/Configure script ("cd src; ./Configure"). This will
- build the Makefile for the server itself, and update the
- src/modules/Makefile for any additional modules you have
- requested from beneath that subdirectory.
-
- 3. Make the server (run "make" in the src directory).
-
-To add another module of your own:
-
- A. mkdir src/modules/mymodule
- B. cp src/modules/example/* src/modules/mymodule
- C. Modify the files in the new directory
- D. Follow steps [1] through [3] above, with appropriate changes.
-
-To activate the example module, include a block similar to the
-following in your srm.conf file:
-
- <Location /example-info>
- SetHandler example-handler
- </Location>
-
-As an alternative, you can put the following into a .htaccess file and
-then request the file "test.example" from that location:
-
- AddHandler example-handler .example
-
-After reloading/restarting your server, you should be able to browse
-to this location and see the brief display mentioned earlier.
diff --git a/modules/experimental/mod_example.c b/modules/experimental/mod_example.c
deleted file mode 100644
index dfa252516f..0000000000
--- a/modules/experimental/mod_example.c
+++ /dev/null
@@ -1,1146 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * Apache example module. Provide demonstrations of how modules do things.
- *
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "http_protocol.h"
-#include "util_script.h"
-
-#include <stdio.h>
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* 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 zero 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.
- */
-typedef struct excfg {
- int cmode; /* Environment to which record applies (directory,
- * server, or combination).
- */
-#define CONFIG_MODE_SERVER 1
-#define CONFIG_MODE_DIRECTORY 2
-#define CONFIG_MODE_COMBO 3 /* Shouldn't ever happen. */
- int local; /* Boolean: "Example" directive declared here? */
- int congenital; /* Boolean: did we inherit an "Example"? */
- char *trace; /* Pointer to trace string. */
- char *loc; /* Location to which this record applies. */
-} excfg;
-
-/*
- * 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.
- */
-static const char *trace = NULL;
-static ap_table_t *static_calls_made = NULL;
-
-/*
- * 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.
- */
-static ap_context_t *example_pool = NULL;
-static ap_context_t *example_subpool = NULL;
-
-/*
- * Declare ourselves so the configuration routines can find and know us.
- * We'll fill it in at the end of the module.
- */
-module example_module;
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* 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.
- *
- * 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.
- *
- * 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.
- *
- * 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".
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- *
- * 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.
- */
-static excfg *our_dconfig(request_rec *r)
-{
-
- return (excfg *) ap_get_module_config(r->per_dir_config, &example_module);
-}
-
-#if 0
-/*
- * Locate our server configuration record for the specified server.
- */
-static excfg *our_sconfig(server_rec *s)
-{
-
- return (excfg *) ap_get_module_config(s->module_config, &example_module);
-}
-
-/*
- * Likewise for our configuration record for the specified request.
- */
-static excfg *our_rconfig(request_rec *r)
-{
-
- return (excfg *) ap_get_module_config(r->request_config, &example_module);
-}
-#endif
-
-/*
- * This routine sets up some module-wide cells if they haven't been already.
- */
-static void setup_module_cells()
-{
- /*
- * If we haven't already allocated our module-private pool, do so now.
- */
- if (example_pool == NULL) {
- example_pool = ap_make_sub_pool(NULL);
- };
- /*
- * Likewise for the ap_table_t of routine/environment pairs we visit outside of
- * request context.
- */
- if (static_calls_made == NULL) {
- static_calls_made = ap_make_table(example_pool, 16);
- };
-}
-
-/*
- * 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 example_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 ap_context_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 ap_table_t is only for storing strings; if you need to
- * maintain per-request data of any other type, you need to use another
- * mechanism.
- */
-
-#define TRACE_NOTE "example-trace"
-
-static void trace_add(server_rec *s, request_rec *r, excfg *mconfig,
- const char *note)
-{
-
- const char *sofar;
- char *addon;
- char *where;
- ap_context_t *p;
- const char *trace_copy;
-
- /*
- * 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 != NULL) {
- p = r->pool;
- if ((trace_copy = ap_table_get(r->notes, TRACE_NOTE)) == NULL) {
- trace_copy = "";
- }
- }
- else {
- /*
- * 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.
- */
- p = ap_make_sub_pool(example_pool);
- if (trace != NULL) {
- trace = ap_pstrdup(p, trace);
- }
- /*
- * Now, if we have a sub-pool from before, nuke it and replace with
- * the one we just allocated.
- */
- if (example_subpool != NULL) {
- ap_destroy_pool(example_subpool);
- }
- example_subpool = p;
- trace_copy = trace;
- }
- /*
- * 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.
- */
- where = (mconfig != NULL) ? mconfig->loc : "nowhere";
- where = (where != NULL) ? where : "";
- /*
- * Now, if we're not in request context, see if we've been called with
- * this particular combination before. The ap_table_t is allocated in the
- * module's private pool, which doesn't get destroyed.
- */
- if (r == NULL) {
- char *key;
-
- key = ap_pstrcat(p, note, ":", where, NULL);
- if (ap_table_get(static_calls_made, key) != NULL) {
- /*
- * Been here, done this.
- */
- return;
- }
- else {
- /*
- * First time for this combination of routine and environment -
- * log it so we don't do it again.
- */
- ap_table_set(static_calls_made, key, "been here");
- }
- }
- addon = ap_pstrcat(p, " <LI>\n", " <DL>\n", " <DT><SAMP>",
- note, "</SAMP>\n", " </DT>\n", " <DD><SAMP>[",
- where, "]</SAMP>\n", " </DD>\n", " </DL>\n",
- " </LI>\n", NULL);
- sofar = (trace_copy == NULL) ? "" : trace_copy;
- trace_copy = ap_pstrcat(p, sofar, addon, NULL);
- if (r != NULL) {
- ap_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.
- */
-#define EXAMPLE_LOG_EACH 0
- if (EXAMPLE_LOG_EACH && (s != NULL)) {
- ap_log_error(APLOG_MARK, APLOG_DEBUG, s, "mod_example: %s", note);
- }
-}
-
-/*--------------------------------------------------------------------------*/
-/* 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.
- */
-static const char *cmd_example(cmd_parms *cmd, void *mconfig)
-{
-
- excfg *cfg = (excfg *) mconfig;
-
- /*
- * "Example Wuz Here"
- */
- cfg->local = 1;
- trace_add(cmd->server, NULL, cfg, "cmd_example()");
- return NULL;
-}
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* 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 connexion */
-/* (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")
- */
-static int example_handler(request_rec *r)
-{
-
- excfg *dcfg;
-
- dcfg = our_dconfig(r);
- trace_add(r->server, r, dcfg, "example_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.
- */
- r->content_type = "text/html";
- ap_send_http_header(r);
- /*
- * If we're only supposed to send header information (HEAD request), we're
- * already there.
- */
- if (r->header_only) {
- return OK;
- }
-
- /*
- * 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>\n", r);
- ap_rputs(" <HEAD>\n", r);
- ap_rputs(" <TITLE>mod_example Module Content-Handler Output\n", r);
- ap_rputs(" </TITLE>\n", r);
- ap_rputs(" </HEAD>\n", r);
- ap_rputs(" <BODY>\n", r);
- ap_rputs(" <H1><SAMP>mod_example</SAMP> Module Content-Handler Output\n", r);
- ap_rputs(" </H1>\n", r);
- ap_rputs(" <P>\n", r);
- ap_rprintf(r, " Apache HTTP Server version: \"%s\"\n",
- ap_get_server_version());
- ap_rputs(" <BR>\n", r);
- ap_rprintf(r, " Server built: \"%s\"\n", ap_get_server_built());
- ap_rputs(" </P>\n", r);;
- ap_rputs(" <P>\n", r);
- ap_rputs(" The format for the callback trace is:\n", r);
- ap_rputs(" </P>\n", r);
- ap_rputs(" <DL>\n", r);
- ap_rputs(" <DT><EM>n</EM>.<SAMP>&lt;routine-name&gt;", r);
- ap_rputs("(&lt;routine-data&gt;)</SAMP>\n", r);
- ap_rputs(" </DT>\n", r);
- ap_rputs(" <DD><SAMP>[&lt;applies-to&gt;]</SAMP>\n", r);
- ap_rputs(" </DD>\n", r);
- ap_rputs(" </DL>\n", r);
- ap_rputs(" <P>\n", r);
- ap_rputs(" The <SAMP>&lt;routine-data&gt;</SAMP> is supplied by\n", r);
- ap_rputs(" the routine when it requests the trace,\n", r);
- ap_rputs(" and the <SAMP>&lt;applies-to&gt;</SAMP> is extracted\n", r);
- ap_rputs(" from the configuration record at the time of the trace.\n", r);
- ap_rputs(" <STRONG>SVR()</STRONG> indicates a server environment\n", r);
- ap_rputs(" (blank means the main or default server, otherwise it's\n", r);
- ap_rputs(" the name of the VirtualHost); <STRONG>DIR()</STRONG>\n", r);
- ap_rputs(" indicates a location in the URL or filesystem\n", r);
- ap_rputs(" namespace.\n", r);
- ap_rputs(" </P>\n", r);
- ap_rprintf(r, " <H2>Static callbacks so far:</H2>\n <OL>\n%s </OL>\n",
- trace);
- ap_rputs(" <H2>Request-specific callbacks so far:</H2>\n", r);
- ap_rprintf(r, " <OL>\n%s </OL>\n", ap_table_get(r->notes, TRACE_NOTE));
- ap_rputs(" <H2>Environment for <EM>this</EM> call:</H2>\n", r);
- ap_rputs(" <UL>\n", r);
- ap_rprintf(r, " <LI>Applies-to: <SAMP>%s</SAMP>\n </LI>\n", dcfg->loc);
- ap_rprintf(r, " <LI>\"Example\" directive declared here: %s\n </LI>\n",
- (dcfg->local ? "YES" : "NO"));
- ap_rprintf(r, " <LI>\"Example\" inherited: %s\n </LI>\n",
- (dcfg->congenital ? "YES" : "NO"));
- ap_rputs(" </UL>\n", r);
- ap_rputs(" </BODY>\n", r);
- ap_rputs("</HTML>\n", 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.
- */
- return OK;
-}
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* 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.
- */
-
-/*
- * All our module initialiser does is add its trace to the log.
- */
-static void example_init(server_rec *s, ap_context_t *p)
-{
-
- char *note;
- char *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.
- */
- sname = (sname != NULL) ? sname : "";
- note = ap_pstrcat(p, "example_init(", sname, ")", NULL);
- trace_add(s, NULL, NULL, note);
-}
-
-/*
- * 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.
- */
-
-/*
- * All our process initialiser does is add its trace to the log.
- */
-static void example_child_init(server_rec *s, ap_context_t *p)
-{
-
- char *note;
- char *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.
- */
- sname = (sname != NULL) ? sname : "";
- note = ap_pstrcat(p, "example_child_init(", sname, ")", NULL);
- trace_add(s, NULL, NULL, note);
-}
-
-/*
- * 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.
- */
-
-/*
- * All our process-death routine does is add its trace to the log.
- */
-static void example_child_exit(server_rec *s, ap_context_t *p)
-{
-
- char *note;
- char *sname = s->server_hostname;
-
- /*
- * The arbitrary text we add to our trace entry indicates for which server
- * we're being called.
- */
- sname = (sname != NULL) ? sname : "";
- note = ap_pstrcat(p, "example_child_exit(", sname, ")", NULL);
- trace_add(s, NULL, NULL, note);
-}
-
-/*
- * This function gets called to create up 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.
- */
-static void *example_create_dir_config(ap_context_t *p, char *dirspec)
-{
-
- excfg *cfg;
- char *dname = dirspec;
-
- /*
- * Allocate the space for our record from the pool supplied.
- */
- cfg = (excfg *) ap_pcalloc(p, sizeof(excfg));
- /*
- * 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.
- */
- dname = (dname != NULL) ? dname : "";
- cfg->loc = ap_pstrcat(p, "DIR(", dname, ")", NULL);
- trace_add(NULL, NULL, cfg, "example_create_dir_config()");
- return (void *) cfg;
-}
-
-/*
- * 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.
- */
-static void *example_merge_dir_config(ap_context_t *p, void *parent_conf,
- void *newloc_conf)
-{
-
- excfg *merged_config = (excfg *) ap_pcalloc(p, sizeof(excfg));
- excfg *pconf = (excfg *) parent_conf;
- excfg *nconf = (excfg *) newloc_conf;
- char *note;
-
- /*
- * Some things get copied directly from the more-specific record, rather
- * than getting merged.
- */
- merged_config->local = nconf->local;
- merged_config->loc = ap_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 | 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.
- */
- merged_config->cmode =
- (pconf->cmode == nconf->cmode) ? pconf->cmode : CONFIG_MODE_COMBO;
- /*
- * Now just record our being called in the trace list. Include the
- * locations we were asked to merge.
- */
- note = ap_pstrcat(p, "example_merge_dir_config(\"", pconf->loc, "\",\"",
- nconf->loc, "\")", NULL);
- trace_add(NULL, NULL, merged_config, note);
- return (void *) merged_config;
-}
-
-/*
- * 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.
- */
-static void *example_create_server_config(ap_context_t *p, server_rec *s)
-{
-
- excfg *cfg;
- char *sname = s->server_hostname;
-
- /*
- * As with the example_create_dir_config() reoutine, we allocate and fill
- * in an empty record.
- */
- cfg = (excfg *) ap_pcalloc(p, sizeof(excfg));
- cfg->local = 0;
- cfg->congenital = 0;
- cfg->cmode = CONFIG_MODE_SERVER;
- /*
- * Note that we were called in the trace list.
- */
- sname = (sname != NULL) ? sname : "";
- cfg->loc = ap_pstrcat(p, "SVR(", sname, ")", NULL);
- trace_add(s, NULL, cfg, "example_create_server_config()");
- return (void *) cfg;
-}
-
-/*
- * 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.
- */
-static void *example_merge_server_config(ap_context_t *p, void *server1_conf,
- void *server2_conf)
-{
-
- excfg *merged_config = (excfg *) ap_pcalloc(p, sizeof(excfg));
- excfg *s1conf = (excfg *) server1_conf;
- excfg *s2conf = (excfg *) server2_conf;
- char *note;
-
- /*
- * Our inheritance rules are our own, and part of our module's semantics.
- * Basically, just note whence we came.
- */
- merged_config->cmode =
- (s1conf->cmode == s2conf->cmode) ? s1conf->cmode : CONFIG_MODE_COMBO;
- merged_config->local = s2conf->local;
- merged_config->congenital = (s1conf->congenital | s1conf->local);
- merged_config->loc = ap_pstrdup(p, s2conf->loc);
- /*
- * Trace our call, including what we were asked to merge.
- */
- note = ap_pstrcat(p, "example_merge_server_config(\"", s1conf->loc, "\",\"",
- s2conf->loc, "\")", NULL);
- trace_add(NULL, NULL, merged_config, note);
- return (void *) merged_config;
-}
-
-/*
- * 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.
- */
-static int example_post_read_request(request_rec *r)
-{
-
- excfg *cfg;
-
- 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, "example_post_read_request()");
- return DECLINED;
-}
-
-/*
- * 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.
- */
-static int example_translate_handler(request_rec *r)
-{
-
- excfg *cfg;
-
- 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, "example_translate_handler()");
- return DECLINED;
-}
-
-/*
- * 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.
- */
-static int example_check_user_id(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- /*
- * Don't do anything except log the call.
- */
- trace_add(r->server, r, cfg, "example_check_user_id()");
- return DECLINED;
-}
-
-/*
- * 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.
- */
-static int example_auth_checker(request_rec *r)
-{
-
- excfg *cfg;
-
- 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, "example_auth_checker()");
- return DECLINED;
-}
-
-/*
- * 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.
- */
-static int example_access_checker(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- trace_add(r->server, r, cfg, "example_access_checker()");
- return DECLINED;
-}
-
-/*
- * 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.
- */
-static int example_type_checker(request_rec *r)
-{
-
- excfg *cfg;
-
- 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, "example_type_checker()");
- return DECLINED;
-}
-
-/*
- * 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.
- */
-static int example_fixer_upper(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- /*
- * Log the call and exit.
- */
- trace_add(r->server, r, cfg, "example_fixer_upper()");
- return OK;
-}
-
-/*
- * 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.
- */
-static int example_logger(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- trace_add(r->server, r, cfg, "example_logger()");
- return DECLINED;
-}
-
-/*
- * This routine is called to give the module a chance to look at the request
- * headers and take any appropriate specific actions early in the processing
- * sequence.
- *
- * The return value is OK, DECLINED, or HTTP_mumble. If we return OK, any
- * remaining modules with handlers for this phase will still be called.
- */
-static int example_header_parser(request_rec *r)
-{
-
- excfg *cfg;
-
- cfg = our_dconfig(r);
- trace_add(r->server, r, cfg, "example_header_parser()");
- return DECLINED;
-}
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* 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. */
-/* */
-/*--------------------------------------------------------------------------*/
-/*
- * List of directives specific to our module.
- */
-static const command_rec example_cmds[] =
-{
- {
- "Example", /* directive name */
- cmd_example, /* config action routine */
- NULL, /* argument to include in call */
- OR_OPTIONS, /* where available */
- NO_ARGS, /* arguments */
- "Example directive - no arguments"
- /* directive description */
- },
- {NULL}
-};
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* Now the list of content handlers available from this module. */
-/* */
-/*--------------------------------------------------------------------------*/
-/*
- * List of content handlers our module supplies. Each handler is defined by
- * two parts: a name by which it can be referenced (such as by
- * {Add,Set}Handler), and the actual routine name. The list is terminated by
- * a NULL block, since it can be of variable length.
- *
- * Note that content-handlers are invoked on a most-specific to least-specific
- * basis; that is, a handler that is declared for "text/plain" will be
- * invoked before one that was declared for "text / *". Note also that
- * if a content-handler returns anything except DECLINED, no other
- * content-handlers will be called.
- */
-static const handler_rec example_handlers[] =
-{
- {"example-handler", example_handler},
- {NULL}
-};
-
-/*--------------------------------------------------------------------------*/
-/* */
-/* Finally, the list of callback routines and data structures that */
-/* provide the 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.
- *
- * 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).
- */
-module example_module =
-{
- STANDARD_MODULE_STUFF,
- example_init, /* module initializer */
- example_create_dir_config, /* per-directory config creator */
- example_merge_dir_config, /* dir config merger */
- example_create_server_config, /* server config creator */
- example_merge_server_config, /* server config merger */
- example_cmds, /* command ap_table_t */
- example_handlers, /* [7] list of handlers */
- example_translate_handler, /* [2] filename-to-URI translation */
- example_check_user_id, /* [5] check/validate user_id */
- example_auth_checker, /* [6] check user_id is valid *here* */
- example_access_checker, /* [4] check access by host address */
- example_type_checker, /* [7] MIME type checker/setter */
- example_fixer_upper, /* [8] fixups */
- example_logger, /* [10] logger */
-#if MODULE_MAGIC_NUMBER >= 19970103
- example_header_parser, /* [3] header parser */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970719
- example_child_init, /* process initializer */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970728
- example_child_exit, /* process exit/cleanup */
-#endif
-#if MODULE_MAGIC_NUMBER >= 19970902
- example_post_read_request /* [1] post read_request handling */
-#endif
-};
diff --git a/modules/filters/.indent.pro b/modules/filters/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/filters/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/filters/mod_include.c b/modules/filters/mod_include.c
deleted file mode 100644
index 08e2d94c6a..0000000000
--- a/modules/filters/mod_include.c
+++ /dev/null
@@ -1,2488 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_include.c: Handles the server-parsed HTML documents
- *
- * Original by Rob McCool; substantial fixups by David Robinson;
- * incorporated into the Apache module framework by rst.
- *
- */
-/*
- * sub key may be anything a Perl*Handler can be:
- * subroutine name, package name (defaults to package::handler),
- * Class->method call or anoymous sub {}
- *
- * Child <!--#perl sub="sub {print $$}" --> accessed
- * <!--#perl sub="sub {print ++$Access::Cnt }" --> times. <br>
- *
- * <!--#perl arg="one" sub="mymod::includer" -->
- *
- * -Doug MacEachern
- */
-
-#ifdef USE_PERL_SSI
-#include "config.h"
-#undef VOIDUSED
-#ifdef USE_SFIO
-#undef USE_SFIO
-#define USE_STDIO
-#endif
-#include "modules/perl/mod_perl.h"
-#else
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "util_script.h"
-#include <string.h>
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-#endif
-
-#define STARTING_SEQUENCE "<!--#"
-#define ENDING_SEQUENCE "-->"
-#define DEFAULT_ERROR_MSG "[an error occurred while processing this directive]"
-#define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z"
-#define SIZEFMT_BYTES 0
-#define SIZEFMT_KMG 1
-#ifdef CHARSET_EBCDIC
-#define RAW_ASCII_CHAR(ch) os_toebcdic[(unsigned char)ch]
-#else /*CHARSET_EBCDIC*/
-#define RAW_ASCII_CHAR(ch) (ch)
-#endif /*CHARSET_EBCDIC*/
-
-module MODULE_VAR_EXPORT includes_module;
-
-/* just need some arbitrary non-NULL pointer which can't also be a request_rec */
-#define NESTED_INCLUDE_MAGIC (&includes_module)
-
-/* TODO: changing directory should be handled by CreateProcess */
-#define ap_chdir_file(x) do {} while(0)
-
-/* ------------------------ Environment function -------------------------- */
-
-/* XXX: could use ap_table_overlap here */
-static void add_include_vars(request_rec *r, char *timefmt)
-{
-#ifndef WIN32
- struct passwd *pw;
-#endif /* ndef WIN32 */
- ap_table_t *e = r->subprocess_env;
- char *t;
- ap_time_t date = r->request_time;
-
- ap_table_setn(e, "DATE_LOCAL", ap_ht_time(r->pool, date, timefmt, 0));
- ap_table_setn(e, "DATE_GMT", ap_ht_time(r->pool, date, timefmt, 1));
- ap_table_setn(e, "LAST_MODIFIED",
- ap_ht_time(r->pool, r->finfo.mtime, timefmt, 0));
- ap_table_setn(e, "DOCUMENT_URI", r->uri);
- ap_table_setn(e, "DOCUMENT_PATH_INFO", r->path_info);
-#ifndef WIN32
- pw = getpwuid(r->finfo.user);
- if (pw) {
- ap_table_setn(e, "USER_NAME", ap_pstrdup(r->pool, pw->pw_name));
- }
- else {
- ap_table_setn(e, "USER_NAME", ap_psprintf(r->pool, "user#%lu",
- (unsigned long) r->finfo.user));
- }
-#endif /* ndef WIN32 */
-
- if ((t = strrchr(r->filename, '/'))) {
- ap_table_setn(e, "DOCUMENT_NAME", ++t);
- }
- else {
- ap_table_setn(e, "DOCUMENT_NAME", r->uri);
- }
- if (r->args) {
- char *arg_copy = ap_pstrdup(r->pool, r->args);
-
- ap_unescape_url(arg_copy);
- ap_table_setn(e, "QUERY_STRING_UNESCAPED",
- ap_escape_shell_cmd(r->pool, arg_copy));
- }
-}
-
-
-
-/* --------------------------- Parser functions --------------------------- */
-
-#define OUTBUFSIZE 4096
-/* PUT_CHAR and FLUSH_BUF currently only work within the scope of
- * find_string(); they are hacks to avoid calling rputc for each and
- * every character output. A common set of buffering calls for this
- * type of output SHOULD be implemented.
- */
-#define PUT_CHAR(c,r) \
- { \
- outbuf[outind++] = c; \
- if (outind == OUTBUFSIZE) { \
- FLUSH_BUF(r) \
- }; \
- }
-
-/* there SHOULD be some error checking on the return value of
- * rwrite, however it is unclear what the API for rwrite returning
- * errors is and little can really be done to help the error in
- * any case.
- */
-#define FLUSH_BUF(r) \
- { \
- ap_rwrite(outbuf, outind, r); \
- outind = 0; \
- }
-
-/*
- * f: file handle being read from
- * c: character to read into
- * ret: return value to use if input fails
- * r: current request_rec
- *
- * This macro is redefined after find_string() for historical reasons
- * to avoid too many code changes. This is one of the many things
- * that should be fixed.
- */
-#define GET_CHAR(f,c,ret,r) \
- { \
- ap_status_t status = ap_getc(&c, f); \
- if (status != APR_SUCCESS) { /* either EOF or error -- needs error handling if latter */ \
- if (status != APR_EOF) { \
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, \
- "encountered error in GET_CHAR macro, " \
- "mod_include."); \
- } \
- FLUSH_BUF(r); \
- ap_close(f); \
- return ret; \
- } \
- }
-
-static int find_string(ap_file_t *in, const char *str, request_rec *r, int printing)
-{
- int x, l = strlen(str), p;
- char outbuf[OUTBUFSIZE];
- int outind = 0;
- char c;
-
- p = 0;
- while (1) {
- GET_CHAR(in, c, 1, r);
- if (c == str[p]) {
- if ((++p) == l) {
- FLUSH_BUF(r);
- return 0;
- }
- }
- else {
- if (printing) {
- for (x = 0; x < p; x++) {
- PUT_CHAR(str[x], r);
- }
- PUT_CHAR(c, r);
- }
- p = 0;
- }
- }
-}
-
-#undef FLUSH_BUF
-#undef PUT_CHAR
-#undef GET_CHAR
-#define GET_CHAR(f,c,r,p) \
- { \
- ap_status_t status = ap_getc(&c, f); \
- if (status != APR_SUCCESS) { /* either EOF or error -- needs error handling if latter */ \
- if (status != APR_EOF) { \
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, \
- "encountered error in GET_CHAR macro, " \
- "mod_include."); \
- } \
- ap_close(f); \
- return r; \
- } \
- }
-
-/*
- * decodes a string containing html entities or numeric character references.
- * 's' is overwritten with the decoded string.
- * If 's' is syntatically incorrect, then the followed fixups will be made:
- * unknown entities will be left undecoded;
- * references to unused numeric characters will be deleted.
- * In particular, &#00; will not be decoded, but will be deleted.
- *
- * drtr
- */
-
-/* maximum length of any ISO-LATIN-1 HTML entity name. */
-#define MAXENTLEN (6)
-
-/* The following is a shrinking transformation, therefore safe. */
-
-static void decodehtml(char *s)
-{
- int val, i, j;
- char *p = s;
- const char *ents;
- static const char * const entlist[MAXENTLEN + 1] =
- {
- NULL, /* 0 */
- NULL, /* 1 */
- "lt\074gt\076", /* 2 */
- "amp\046ETH\320eth\360", /* 3 */
- "quot\042Auml\304Euml\313Iuml\317Ouml\326Uuml\334auml\344euml\353\
-iuml\357ouml\366uuml\374yuml\377", /* 4 */
- "Acirc\302Aring\305AElig\306Ecirc\312Icirc\316Ocirc\324Ucirc\333\
-THORN\336szlig\337acirc\342aring\345aelig\346ecirc\352icirc\356ocirc\364\
-ucirc\373thorn\376", /* 5 */
- "Agrave\300Aacute\301Atilde\303Ccedil\307Egrave\310Eacute\311\
-Igrave\314Iacute\315Ntilde\321Ograve\322Oacute\323Otilde\325Oslash\330\
-Ugrave\331Uacute\332Yacute\335agrave\340aacute\341atilde\343ccedil\347\
-egrave\350eacute\351igrave\354iacute\355ntilde\361ograve\362oacute\363\
-otilde\365oslash\370ugrave\371uacute\372yacute\375" /* 6 */
- };
-
- for (; *s != '\0'; s++, p++) {
- if (*s != '&') {
- *p = *s;
- continue;
- }
- /* find end of entity */
- for (i = 1; s[i] != ';' && s[i] != '\0'; i++) {
- continue;
- }
-
- if (s[i] == '\0') { /* treat as normal data */
- *p = *s;
- continue;
- }
-
- /* is it numeric ? */
- if (s[1] == '#') {
- for (j = 2, val = 0; j < i && ap_isdigit(s[j]); j++) {
- val = val * 10 + s[j] - '0';
- }
- s += i;
- if (j < i || val <= 8 || (val >= 11 && val <= 31) ||
- (val >= 127 && val <= 160) || val >= 256) {
- p--; /* no data to output */
- }
- else {
- *p = RAW_ASCII_CHAR(val);
- }
- }
- else {
- j = i - 1;
- if (j > MAXENTLEN || entlist[j] == NULL) {
- /* wrong length */
- *p = '&';
- continue; /* skip it */
- }
- for (ents = entlist[j]; *ents != '\0'; ents += i) {
- if (strncmp(s + 1, ents, j) == 0) {
- break;
- }
- }
-
- if (*ents == '\0') {
- *p = '&'; /* unknown */
- }
- else {
- *p = RAW_ASCII_CHAR(((const unsigned char *) ents)[j]);
- s += i;
- }
- }
- }
-
- *p = '\0';
-}
-
-/*
- * extract the next tag name and value.
- * if there are no more tags, set the tag name to 'done'
- * the tag value is html decoded if dodecode is non-zero
- */
-
-static char *get_tag(ap_context_t *p, ap_file_t *in, char *tag, int tagbuf_len, int dodecode)
-{
- char *t = tag, *tag_val, c, term;
-
- /* makes code below a little less cluttered */
- --tagbuf_len;
-
- do { /* skip whitespace */
- GET_CHAR(in, c, NULL, p);
- } while (ap_isspace(c));
-
- /* tags can't start with - */
- if (c == '-') {
- GET_CHAR(in, c, NULL, p);
- if (c == '-') {
- do {
- GET_CHAR(in, c, NULL, p);
- } while (ap_isspace(c));
- if (c == '>') {
- ap_cpystrn(tag, "done", tagbuf_len);
- return tag;
- }
- }
- return NULL; /* failed */
- }
-
- /* find end of tag name */
- while (1) {
- if (t - tag == tagbuf_len) {
- *t = '\0';
- return NULL;
- }
- if (c == '=' || ap_isspace(c)) {
- break;
- }
- *(t++) = ap_tolower(c);
- GET_CHAR(in, c, NULL, p);
- }
-
- *t++ = '\0';
- tag_val = t;
-
- while (ap_isspace(c)) {
- GET_CHAR(in, c, NULL, p); /* space before = */
- }
- if (c != '=') {
- ap_ungetc(c, in);
- return NULL;
- }
-
- do {
- GET_CHAR(in, c, NULL, p); /* space after = */
- } while (ap_isspace(c));
-
- /* we should allow a 'name' as a value */
-
- if (c != '"' && c != '\'') {
- return NULL;
- }
- term = c;
- while (1) {
- GET_CHAR(in, c, NULL, p);
- if (t - tag == tagbuf_len) {
- *t = '\0';
- return NULL;
- }
-/* Want to accept \" as a valid character within a string. */
- if (c == '\\') {
- *(t++) = c; /* Add backslash */
- GET_CHAR(in, c, NULL, p);
- if (c == term) { /* Only if */
- *(--t) = c; /* Replace backslash ONLY for terminator */
- }
- }
- else if (c == term) {
- break;
- }
- *(t++) = c;
- }
- *t = '\0';
- if (dodecode) {
- decodehtml(tag_val);
- }
- return ap_pstrdup(p, tag_val);
-}
-
-static int get_directive(ap_file_t *in, char *dest, size_t len, ap_context_t *p)
-{
- char *d = dest;
- char c;
-
- /* make room for nul terminator */
- --len;
-
- /* skip initial whitespace */
- while (1) {
- GET_CHAR(in, c, 1, p);
- if (!ap_isspace(c)) {
- break;
- }
- }
- /* now get directive */
- while (1) {
- if (d - dest == len) {
- return 1;
- }
- *d++ = ap_tolower(c);
- GET_CHAR(in, c, 1, p);
- if (ap_isspace(c)) {
- break;
- }
- }
- *d = '\0';
- return 0;
-}
-
-/*
- * Do variable substitution on strings
- */
-static void parse_string(request_rec *r, const char *in, char *out,
- size_t length, int leave_name)
-{
- char ch;
- char *next = out;
- char *end_out;
-
- /* leave room for nul terminator */
- end_out = out + length - 1;
-
- while ((ch = *in++) != '\0') {
- switch (ch) {
- case '\\':
- if (next == end_out) {
- /* truncated */
- *next = '\0';
- return;
- }
- if (*in == '$') {
- *next++ = *in++;
- }
- else {
- *next++ = ch;
- }
- break;
- case '$':
- {
- char var[MAX_STRING_LEN];
- const char *start_of_var_name;
- const char *end_of_var_name; /* end of var name + 1 */
- const char *expansion;
- const char *val;
- size_t l;
-
- /* guess that the expansion won't happen */
- expansion = in - 1;
- if (*in == '{') {
- ++in;
- start_of_var_name = in;
- in = strchr(in, '}');
- if (in == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR,
- 0, r, "Missing '}' on variable \"%s\"",
- expansion);
- *next = '\0';
- return;
- }
- end_of_var_name = in;
- ++in;
- }
- else {
- start_of_var_name = in;
- while (ap_isalnum(*in) || *in == '_') {
- ++in;
- }
- end_of_var_name = in;
- }
- /* what a pain, too bad there's no table_getn where you can
- * pass a non-nul terminated string */
- l = end_of_var_name - start_of_var_name;
- if (l != 0) {
- l = (l > sizeof(var) - 1) ? (sizeof(var) - 1) : l;
- memcpy(var, start_of_var_name, l);
- var[l] = '\0';
-
- val = ap_table_get(r->subprocess_env, var);
- if (val) {
- expansion = val;
- l = strlen(expansion);
- }
- else if (leave_name) {
- l = in - expansion;
- }
- else {
- break; /* no expansion to be done */
- }
- }
- else {
- /* zero-length variable name causes just the $ to be copied */
- l = 1;
- }
- l = (l > end_out - next) ? (end_out - next) : l;
- memcpy(next, expansion, l);
- next += l;
- break;
- }
- default:
- if (next == end_out) {
- /* truncated */
- *next = '\0';
- return;
- }
- *next++ = ch;
- break;
- }
- }
- *next = '\0';
- return;
-}
-
-/* --------------------------- Action handlers ---------------------------- */
-
-static int include_cgi(char *s, request_rec *r)
-{
- request_rec *rr = ap_sub_req_lookup_uri(s, r);
- int rr_status;
-
- if (rr->status != HTTP_OK) {
- return -1;
- }
-
- /* No hardwired path info or query allowed */
-
- if ((rr->path_info && rr->path_info[0]) || rr->args) {
- return -1;
- }
- if (rr->finfo.protection == 0) {
- return -1;
- }
-
- /* Script gets parameters of the *document*, for back compatibility */
-
- rr->path_info = r->path_info; /* hard to get right; see mod_cgi.c */
- rr->args = r->args;
-
- /* Force sub_req to be treated as a CGI request, even if ordinary
- * typing rules would have called it something else.
- */
-
- rr->content_type = CGI_MAGIC_TYPE;
-
- /* Run it. */
-
- rr_status = ap_run_sub_req(rr);
- if (ap_is_HTTP_REDIRECT(rr_status)) {
- const char *location = ap_table_get(rr->headers_out, "Location");
- location = ap_escape_html(rr->pool, location);
- ap_rvputs(r, "<A HREF=\"", location, "\">", location, "</A>", NULL);
- }
-
- ap_destroy_sub_req(rr);
- ap_chdir_file(r->filename);
-
- return 0;
-}
-
-/* ensure that path is relative, and does not contain ".." elements
- * ensentially ensure that it does not match the regex:
- * (^/|(^|/)\.\.(/|$))
- * XXX: this needs os abstraction... consider c:..\foo in win32
- */
-static int is_only_below(const char *path)
-{
-#ifdef HAVE_DRIVE_LETTERS
- if (path[1] == ':')
- return 0;
-#endif
- if (path[0] == '/') {
- return 0;
- }
- if (path[0] == '.' && path[1] == '.'
- && (path[2] == '\0' || path[2] == '/')) {
- return 0;
- }
- while (*path) {
- if (*path == '/' && path[1] == '.' && path[2] == '.'
- && (path[3] == '\0' || path[3] == '/')) {
- return 0;
- }
- ++path;
- }
- return 1;
-}
-
-static int handle_include(ap_file_t *in, request_rec *r, const char *error, int noexec)
-{
- char tag[MAX_STRING_LEN];
- char parsed_string[MAX_STRING_LEN];
- char *tag_val;
-
- while (1) {
- if (!(tag_val = get_tag(r->pool, in, tag, sizeof(tag), 1))) {
- return 1;
- }
- if (!strcmp(tag, "file") || !strcmp(tag, "virtual")) {
- request_rec *rr = NULL;
- char *error_fmt = NULL;
-
- parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0);
- if (tag[0] == 'f') {
- /* be safe; only files in this directory or below allowed */
- if (!is_only_below(parsed_string)) {
- error_fmt = "unable to include file \"%s\" "
- "in parsed file %s";
- }
- else {
- rr = ap_sub_req_lookup_file(parsed_string, r);
- }
- }
- else {
- rr = ap_sub_req_lookup_uri(parsed_string, r);
- }
-
- if (!error_fmt && rr->status != HTTP_OK) {
- error_fmt = "unable to include \"%s\" in parsed file %s";
- }
-
- if (!error_fmt && noexec && rr->content_type
- && (strncmp(rr->content_type, "text/", 5))) {
- error_fmt = "unable to include potential exec \"%s\" "
- "in parsed file %s";
- }
- if (error_fmt == NULL) {
- /* try to avoid recursive includes. We do this by walking
- * up the r->main list of subrequests, and at each level
- * walking back through any internal redirects. At each
- * step, we compare the filenames and the URIs.
- *
- * The filename comparison catches a recursive include
- * with an ever-changing URL, eg.
- * <!--#include virtual=
- * "$REQUEST_URI/$QUERY_STRING?$QUERY_STRING/x"-->
- * which, although they would eventually be caught because
- * we have a limit on the length of files, etc., can
- * recurse for a while.
- *
- * The URI comparison catches the case where the filename
- * is changed while processing the request, so the
- * current name is never the same as any previous one.
- * This can happen with "DocumentRoot /foo" when you
- * request "/" on the server and it includes "/".
- * This only applies to modules such as mod_dir that
- * (somewhat improperly) mess with r->filename outside
- * of a filename translation phase.
- */
- int founddupe = 0;
- request_rec *p;
- for (p = r; p != NULL && !founddupe; p = p->main) {
- request_rec *q;
- for (q = p; q != NULL; q = q->prev) {
- if ( (strcmp(q->filename, rr->filename) == 0) ||
- (strcmp(q->uri, rr->uri) == 0) ){
- founddupe = 1;
- break;
- }
- }
- }
-
- if (p != NULL) {
- error_fmt = "Recursive include of \"%s\" "
- "in parsed file %s";
- }
- }
-
- /* see the Kludge in send_parsed_file for why */
- if (rr)
- ap_set_module_config(rr->request_config, &includes_module, r);
-
- if (!error_fmt && ap_run_sub_req(rr)) {
- error_fmt = "unable to include \"%s\" in parsed file %s";
- }
- ap_chdir_file(r->filename);
- if (error_fmt) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR,
- 0, r, error_fmt, tag_val, r->filename);
- ap_rputs(error, r);
- }
-
- /* destroy the sub request if it's not a nested include */
- if (rr != NULL
- && ap_get_module_config(rr->request_config, &includes_module)
- != NESTED_INCLUDE_MAGIC) {
- ap_destroy_sub_req(rr);
- }
- }
- else if (!strcmp(tag, "done")) {
- return 0;
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "unknown parameter \"%s\" to tag include in %s",
- tag, r->filename);
- ap_rputs(error, r);
- }
- }
-}
-
-typedef struct {
-#ifdef TPF
- TPF_FORK_CHILD t;
-#endif
- request_rec *r;
- char *s;
-} include_cmd_arg;
-
-
-
-static ap_status_t build_argv_list(char ***argv, request_rec *r, ap_context_t *p)
-{
- int numwords, x, idx;
- char *w;
- const char *args = r->args;
-
- if (!args || !args[0] || strchr(args, '=')) {
- numwords = 1;
- }
- else {
- /* count the number of keywords */
- for (x = 0, numwords = 1; args[x]; x++) {
- if (args[x] == '+') {
- ++numwords;
- }
- }
- }
- /* Everything is - 1 to account for the first parameter which is the
- * program name. We didn't used to have to do this, but APR wants it.
- */
- if (numwords > APACHE_ARG_MAX - 1) {
- numwords = APACHE_ARG_MAX - 1; /* Truncate args to prevent overrun */
- }
- *argv = (char **) ap_palloc(p, (numwords + 2) * sizeof(char *));
-
- for (x = 1, idx = 1; x < numwords; x++) {
- w = ap_getword_nulls(p, &args, '+');
- ap_unescape_url(w);
- (*argv)[idx++] = ap_escape_shell_cmd(p, w);
- }
- (*argv)[idx] = NULL;
-
- return APR_SUCCESS;
-}
-
-
-
-static int include_cmd(char *s, request_rec *r)
-{
- include_cmd_arg arg;
- BUFF *script_in;
- ap_procattr_t *procattr;
- ap_proc_t *procnew;
- ap_status_t rc;
- ap_table_t *env = r->subprocess_env;
- char **argv;
- ap_file_t *file = NULL;
- ap_iol *iol;
-
- arg.r = r;
- arg.s = s;
-#ifdef TPF
- arg.t.filename = r->filename;
- arg.t.subprocess_env = r->subprocess_env;
- arg.t.prog_type = FORK_FILE;
-#endif
-
- if (r->path_info && r->path_info[0] != '\0') {
- request_rec *pa_req;
-
- ap_table_setn(env, "PATH_INFO", ap_escape_shell_cmd(r->pool, r->path_info));
-
- pa_req = ap_sub_req_lookup_uri(ap_escape_uri(r->pool, r->path_info), r);
- if (pa_req->filename) {
- ap_table_setn(env, "PATH_TRANSLATED",
- ap_pstrcat(r->pool, pa_req->filename, pa_req->path_info,
- NULL));
- }
- }
-
- if (r->args) {
- char *arg_copy = ap_pstrdup(r->pool, r->args);
-
- ap_table_setn(env, "QUERY_STRING", r->args);
- ap_unescape_url(arg_copy);
- ap_table_setn(env, "QUERY_STRING_UNESCAPED",
- ap_escape_shell_cmd(r->pool, arg_copy));
- }
-
- if ((ap_createprocattr_init(&procattr, r->pool) != APR_SUCCESS) ||
- (ap_setprocattr_io(procattr, APR_NO_PIPE,
- APR_FULL_BLOCK, APR_NO_PIPE) != APR_SUCCESS) ||
- (ap_setprocattr_dir(procattr, ap_make_dirstr_parent(r->pool, r->filename)) != APR_SUCCESS) ||
- (ap_setprocattr_cmdtype(procattr, APR_SHELLCMD) != APR_SUCCESS)) {
- /* Something bad happened, tell the world. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "couldn't initialize proc attributes: %s %s", r->filename, s);
- rc = !APR_SUCCESS;
- }
- else {
- build_argv_list(&argv, r, r->pool);
- argv[0] = ap_pstrdup(r->pool, s);
- rc = ap_create_process(&procnew, s, argv, ap_create_environment(r->pool, env), procattr, r->pool);
-
- if (rc != APR_SUCCESS) {
- /* Bad things happened. Everyone should have cleaned up. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "couldn't create child process: %d: %s", rc, s);
- }
- else {
- ap_note_subprocess(r->pool, procnew, kill_after_timeout);
- /* Fill in BUFF structure for parents pipe to child's stdout */
- ap_get_childout(&file, procnew);
- iol = ap_create_file_iol(file);
- if (!iol)
- return APR_EBADF;
- script_in = ap_bcreate(r->pool, B_RD);
- ap_bpush_iol(script_in, iol);
- ap_send_fb(script_in, r);
- ap_bclose(script_in);
- }
- }
-
- return 0;
-}
-
-static int handle_exec(ap_file_t *in, request_rec *r, const char *error)
-{
- char tag[MAX_STRING_LEN];
- char *tag_val;
- char *file = r->filename;
- char parsed_string[MAX_STRING_LEN];
-
- while (1) {
- if (!(tag_val = get_tag(r->pool, in, tag, sizeof(tag), 1))) {
- return 1;
- }
- if (!strcmp(tag, "cmd")) {
- parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 1);
- if (include_cmd(parsed_string, r) == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "execution failure for parameter \"%s\" "
- "to tag exec in file %s",
- tag, r->filename);
- ap_rputs(error, r);
- }
- /* just in case some stooge changed directories */
- ap_chdir_file(r->filename);
- }
- else if (!strcmp(tag, "cgi")) {
- parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0);
- if (include_cgi(parsed_string, r) == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "invalid CGI ref \"%s\" in %s", tag_val, file);
- ap_rputs(error, r);
- }
- ap_chdir_file(r->filename);
- }
- else if (!strcmp(tag, "done")) {
- return 0;
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "unknown parameter \"%s\" to tag exec in %s",
- tag, file);
- ap_rputs(error, r);
- }
- }
-
-}
-
-static int handle_echo(ap_file_t *in, request_rec *r, const char *error)
-{
- char tag[MAX_STRING_LEN];
- char *tag_val;
-
- while (1) {
- if (!(tag_val = get_tag(r->pool, in, tag, sizeof(tag), 1))) {
- return 1;
- }
- if (!strcmp(tag, "var")) {
- const char *val = ap_table_get(r->subprocess_env, tag_val);
-
- if (val) {
- ap_rputs(val, r);
- }
- else {
- ap_rputs("(none)", r);
- }
- }
- else if (!strcmp(tag, "done")) {
- return 0;
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "unknown parameter \"%s\" to tag echo in %s",
- tag, r->filename);
- ap_rputs(error, r);
- }
- }
-}
-
-#ifdef USE_PERL_SSI
-static int handle_perl(ap_file_t *in, request_rec *r, const char *error)
-{
- char tag[MAX_STRING_LEN];
- char parsed_string[MAX_STRING_LEN];
- char *tag_val;
- SV *sub = Nullsv;
- AV *av = newAV();
-
- if (ap_allow_options(r) & OPT_INCNOEXEC) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "#perl SSI disallowed by IncludesNoExec in %s",
- r->filename);
- return DECLINED;
- }
- while (1) {
- if (!(tag_val = get_tag(r->pool, in, tag, sizeof(tag), 1))) {
- break;
- }
- if (strnEQ(tag, "sub", 3)) {
- sub = newSVpv(tag_val, 0);
- }
- else if (strnEQ(tag, "arg", 3)) {
- parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0);
- av_push(av, newSVpv(parsed_string, 0));
- }
- else if (strnEQ(tag, "done", 4)) {
- break;
- }
- }
- perl_stdout2client(r);
- perl_setup_env(r);
- perl_call_handler(sub, r, av);
- return OK;
-}
-#endif
-
-/* error and tf must point to a string with room for at
- * least MAX_STRING_LEN characters
- */
-static int handle_config(ap_file_t *in, request_rec *r, char *error, char *tf,
- int *sizefmt)
-{
- char tag[MAX_STRING_LEN];
- char *tag_val;
- char parsed_string[MAX_STRING_LEN];
- ap_table_t *env = r->subprocess_env;
-
- while (1) {
- if (!(tag_val = get_tag(r->pool, in, tag, sizeof(tag), 0))) {
- return 1;
- }
- if (!strcmp(tag, "errmsg")) {
- parse_string(r, tag_val, error, MAX_STRING_LEN, 0);
- }
- else if (!strcmp(tag, "timefmt")) {
- ap_time_t date = r->request_time;
-
- parse_string(r, tag_val, tf, MAX_STRING_LEN, 0);
- ap_table_setn(env, "DATE_LOCAL", ap_ht_time(r->pool, date, tf, 0));
- ap_table_setn(env, "DATE_GMT", ap_ht_time(r->pool, date, tf, 1));
- ap_table_setn(env, "LAST_MODIFIED",
- ap_ht_time(r->pool, r->finfo.mtime, tf, 0));
- }
- else if (!strcmp(tag, "sizefmt")) {
- parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0);
- decodehtml(parsed_string);
- if (!strcmp(parsed_string, "bytes")) {
- *sizefmt = SIZEFMT_BYTES;
- }
- else if (!strcmp(parsed_string, "abbrev")) {
- *sizefmt = SIZEFMT_KMG;
- }
- }
- else if (!strcmp(tag, "done")) {
- return 0;
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "unknown parameter \"%s\" to tag config in %s",
- tag, r->filename);
- ap_rputs(error, r);
- }
- }
-}
-
-
-static int find_file(request_rec *r, const char *directive, const char *tag,
- char *tag_val, ap_finfo_t *finfo, const char *error)
-{
- char *to_send = tag_val;
- request_rec *rr = NULL;
- int ret=0;
- char *error_fmt = NULL;
-
- if (!strcmp(tag, "file")) {
- /* be safe; only files in this directory or below allowed */
- if (!is_only_below(tag_val)) {
- error_fmt = "unable to access file \"%s\" "
- "in parsed file %s";
- }
- else {
- ap_getparents(tag_val); /* get rid of any nasties */
- rr = ap_sub_req_lookup_file(tag_val, r);
-
- if (rr->status == HTTP_OK && rr->finfo.protection != 0) {
- to_send = rr->filename;
- if (ap_stat(finfo, to_send, rr->pool) != APR_SUCCESS) {
- error_fmt = "unable to get information about \"%s\" "
- "in parsed file %s";
- }
- }
- else {
- error_fmt = "unable to lookup information about \"%s\" "
- "in parsed file %s";
- }
- }
-
- if (error_fmt) {
- ret = -1;
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, error_fmt, to_send, r->filename);
- ap_rputs(error, r);
- }
-
- if (rr) ap_destroy_sub_req(rr);
-
- return ret;
- }
- else if (!strcmp(tag, "virtual")) {
- rr = ap_sub_req_lookup_uri(tag_val, r);
-
- if (rr->status == HTTP_OK && rr->finfo.protection != 0) {
- memcpy((char *) finfo, (const char *) &rr->finfo,
- sizeof(struct stat));
- ap_destroy_sub_req(rr);
- return 0;
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "unable to get information about \"%s\" "
- "in parsed file %s",
- tag_val, r->filename);
- ap_rputs(error, r);
- ap_destroy_sub_req(rr);
- return -1;
- }
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "unknown parameter \"%s\" to tag %s in %s",
- tag, directive, r->filename);
- ap_rputs(error, r);
- return -1;
- }
-}
-
-
-static int handle_fsize(ap_file_t *in, request_rec *r, const char *error, int sizefmt)
-{
- char tag[MAX_STRING_LEN];
- char *tag_val;
- ap_finfo_t finfo;
- char parsed_string[MAX_STRING_LEN];
-
- while (1) {
- if (!(tag_val = get_tag(r->pool, in, tag, sizeof(tag), 1))) {
- return 1;
- }
- else if (!strcmp(tag, "done")) {
- return 0;
- }
- else {
- parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0);
- if (!find_file(r, "fsize", tag, parsed_string, &finfo, error)) {
- if (sizefmt == SIZEFMT_KMG) {
- ap_send_size(finfo.size, r);
- }
- else {
- int l, x;
-#if defined(AP_OFF_T_IS_QUAD)
- ap_snprintf(tag, sizeof(tag), "%qd", finfo.size);
-#else
- ap_snprintf(tag, sizeof(tag), "%ld", finfo.size);
-#endif
- l = strlen(tag); /* grrr */
- for (x = 0; x < l; x++) {
- if (x && (!((l - x) % 3))) {
- ap_rputc(',', r);
- }
- ap_rputc(tag[x], r);
- }
- }
- }
- }
- }
-}
-
-static int handle_flastmod(ap_file_t *in, request_rec *r, const char *error, const char *tf)
-{
- char tag[MAX_STRING_LEN];
- char *tag_val;
- ap_finfo_t finfo;
- char parsed_string[MAX_STRING_LEN];
-
- while (1) {
- if (!(tag_val = get_tag(r->pool, in, tag, sizeof(tag), 1))) {
- return 1;
- }
- else if (!strcmp(tag, "done")) {
- return 0;
- }
- else {
- parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0);
- if (!find_file(r, "flastmod", tag, parsed_string, &finfo, error)) {
- ap_rputs(ap_ht_time(r->pool, finfo.mtime, tf, 0), r);
- }
- }
- }
-}
-
-static int re_check(request_rec *r, char *string, char *rexp)
-{
- regex_t *compiled;
- int regex_error;
-
- compiled = ap_pregcomp(r->pool, rexp, REG_EXTENDED | REG_NOSUB);
- if (compiled == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "unable to compile pattern \"%s\"", rexp);
- return -1;
- }
- regex_error = ap_regexec(compiled, string, 0, (regmatch_t *) NULL, 0);
- ap_pregfree(r->pool, compiled);
- return (!regex_error);
-}
-
-enum token_type {
- token_string,
- token_and, token_or, token_not, token_eq, token_ne,
- token_rbrace, token_lbrace, token_group,
- token_ge, token_le, token_gt, token_lt
-};
-struct token {
- enum token_type type;
- char value[MAX_STRING_LEN];
-};
-
-/* there is an implicit assumption here that string is at most MAX_STRING_LEN-1
- * characters long...
- */
-static const char *get_ptoken(request_rec *r, const char *string, struct token *token)
-{
- char ch;
- int next = 0;
- int qs = 0;
-
- /* Skip leading white space */
- if (string == (char *) NULL) {
- return (char *) NULL;
- }
- while ((ch = *string++)) {
- if (!ap_isspace(ch)) {
- break;
- }
- }
- if (ch == '\0') {
- return (char *) NULL;
- }
-
- token->type = token_string; /* the default type */
- switch (ch) {
- case '(':
- token->type = token_lbrace;
- return (string);
- case ')':
- token->type = token_rbrace;
- return (string);
- case '=':
- token->type = token_eq;
- return (string);
- case '!':
- if (*string == '=') {
- token->type = token_ne;
- return (string + 1);
- }
- else {
- token->type = token_not;
- return (string);
- }
- case '\'':
- token->type = token_string;
- qs = 1;
- break;
- case '|':
- if (*string == '|') {
- token->type = token_or;
- return (string + 1);
- }
- break;
- case '&':
- if (*string == '&') {
- token->type = token_and;
- return (string + 1);
- }
- break;
- case '>':
- if (*string == '=') {
- token->type = token_ge;
- return (string + 1);
- }
- else {
- token->type = token_gt;
- return (string);
- }
- case '<':
- if (*string == '=') {
- token->type = token_le;
- return (string + 1);
- }
- else {
- token->type = token_lt;
- return (string);
- }
- default:
- token->type = token_string;
- break;
- }
- /* We should only be here if we are in a string */
- if (!qs) {
- token->value[next++] = ch;
- }
-
- /*
- * Yes I know that goto's are BAD. But, c doesn't allow me to
- * exit a loop from a switch statement. Yes, I could use a flag,
- * but that is (IMHO) even less readable/maintainable than the goto.
- */
- /*
- * I used the ++string throughout this section so that string
- * ends up pointing to the next token and I can just return it
- */
- for (ch = *string; ch != '\0'; ch = *++string) {
- if (ch == '\\') {
- if ((ch = *++string) == '\0') {
- goto TOKEN_DONE;
- }
- token->value[next++] = ch;
- continue;
- }
- if (!qs) {
- if (ap_isspace(ch)) {
- goto TOKEN_DONE;
- }
- switch (ch) {
- case '(':
- goto TOKEN_DONE;
- case ')':
- goto TOKEN_DONE;
- case '=':
- goto TOKEN_DONE;
- case '!':
- goto TOKEN_DONE;
- case '|':
- if (*(string + 1) == '|') {
- goto TOKEN_DONE;
- }
- break;
- case '&':
- if (*(string + 1) == '&') {
- goto TOKEN_DONE;
- }
- break;
- case '<':
- goto TOKEN_DONE;
- case '>':
- goto TOKEN_DONE;
- }
- token->value[next++] = ch;
- }
- else {
- if (ch == '\'') {
- qs = 0;
- ++string;
- goto TOKEN_DONE;
- }
- token->value[next++] = ch;
- }
- }
- TOKEN_DONE:
- /* If qs is still set, I have an unmatched ' */
- if (qs) {
- ap_rputs("\nUnmatched '\n", r);
- next = 0;
- }
- token->value[next] = '\0';
- return (string);
-}
-
-
-/*
- * Hey I still know that goto's are BAD. I don't think that I've ever
- * used two in the same project, let alone the same file before. But,
- * I absolutely want to make sure that I clean up the memory in all
- * cases. And, without rewriting this completely, the easiest way
- * is to just branch to the return code which cleans it up.
- */
-/* there is an implicit assumption here that expr is at most MAX_STRING_LEN-1
- * characters long...
- */
-static int parse_expr(request_rec *r, const char *expr, const char *error)
-{
- struct parse_node {
- struct parse_node *left, *right, *parent;
- struct token token;
- int value, done;
- } *root, *current, *new;
- const char *parse;
- char buffer[MAX_STRING_LEN];
- ap_context_t *expr_pool;
- int retval = 0;
-
- if ((parse = expr) == (char *) NULL) {
- return (0);
- }
- root = current = (struct parse_node *) NULL;
- if (ap_create_context(&expr_pool, r->pool) != APR_SUCCESS)
- return 0;
-
- /* Create Parse Tree */
- while (1) {
- new = (struct parse_node *) ap_palloc(expr_pool,
- sizeof(struct parse_node));
- new->parent = new->left = new->right = (struct parse_node *) NULL;
- new->done = 0;
- if ((parse = get_ptoken(r, parse, &new->token)) == (char *) NULL) {
- break;
- }
- switch (new->token.type) {
-
- case token_string:
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, " Token: string (", new->token.value, ")\n", NULL);
-#endif
- if (current == (struct parse_node *) NULL) {
- root = current = new;
- break;
- }
- switch (current->token.type) {
- case token_string:
- if (current->token.value[0] != '\0') {
- strncat(current->token.value, " ",
- sizeof(current->token.value)
- - strlen(current->token.value) - 1);
- }
- strncat(current->token.value, new->token.value,
- sizeof(current->token.value)
- - strlen(current->token.value) - 1);
- current->token.value[sizeof(current->token.value) - 1] = '\0';
- break;
- case token_eq:
- case token_ne:
- case token_and:
- case token_or:
- case token_lbrace:
- case token_not:
- case token_ge:
- case token_gt:
- case token_le:
- case token_lt:
- new->parent = current;
- current = current->right = new;
- break;
- default:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid expression \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
- break;
-
- case token_and:
- case token_or:
-#ifdef DEBUG_INCLUDE
- ap_rputs(" Token: and/or\n", r);
-#endif
- if (current == (struct parse_node *) NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid expression \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
- /* Percolate upwards */
- while (current != (struct parse_node *) NULL) {
- switch (current->token.type) {
- case token_string:
- case token_group:
- case token_not:
- case token_eq:
- case token_ne:
- case token_and:
- case token_or:
- case token_ge:
- case token_gt:
- case token_le:
- case token_lt:
- current = current->parent;
- continue;
- case token_lbrace:
- break;
- default:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid expression \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
- break;
- }
- if (current == (struct parse_node *) NULL) {
- new->left = root;
- new->left->parent = new;
- new->parent = (struct parse_node *) NULL;
- root = new;
- }
- else {
- new->left = current->right;
- current->right = new;
- new->parent = current;
- }
- current = new;
- break;
-
- case token_not:
-#ifdef DEBUG_INCLUDE
- ap_rputs(" Token: not\n", r);
-#endif
- if (current == (struct parse_node *) NULL) {
- root = current = new;
- break;
- }
- /* Percolate upwards */
- while (current != (struct parse_node *) NULL) {
- switch (current->token.type) {
- case token_not:
- case token_eq:
- case token_ne:
- case token_and:
- case token_or:
- case token_lbrace:
- case token_ge:
- case token_gt:
- case token_le:
- case token_lt:
- break;
- default:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid expression \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
- break;
- }
- if (current == (struct parse_node *) NULL) {
- new->left = root;
- new->left->parent = new;
- new->parent = (struct parse_node *) NULL;
- root = new;
- }
- else {
- new->left = current->right;
- current->right = new;
- new->parent = current;
- }
- current = new;
- break;
-
- case token_eq:
- case token_ne:
- case token_ge:
- case token_gt:
- case token_le:
- case token_lt:
-#ifdef DEBUG_INCLUDE
- ap_rputs(" Token: eq/ne/ge/gt/le/lt\n", r);
-#endif
- if (current == (struct parse_node *) NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid expression \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
- /* Percolate upwards */
- while (current != (struct parse_node *) NULL) {
- switch (current->token.type) {
- case token_string:
- case token_group:
- current = current->parent;
- continue;
- case token_lbrace:
- case token_and:
- case token_or:
- break;
- case token_not:
- case token_eq:
- case token_ne:
- case token_ge:
- case token_gt:
- case token_le:
- case token_lt:
- default:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid expression \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
- break;
- }
- if (current == (struct parse_node *) NULL) {
- new->left = root;
- new->left->parent = new;
- new->parent = (struct parse_node *) NULL;
- root = new;
- }
- else {
- new->left = current->right;
- current->right = new;
- new->parent = current;
- }
- current = new;
- break;
-
- case token_rbrace:
-#ifdef DEBUG_INCLUDE
- ap_rputs(" Token: rbrace\n", r);
-#endif
- while (current != (struct parse_node *) NULL) {
- if (current->token.type == token_lbrace) {
- current->token.type = token_group;
- break;
- }
- current = current->parent;
- }
- if (current == (struct parse_node *) NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Unmatched ')' in \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
- break;
-
- case token_lbrace:
-#ifdef DEBUG_INCLUDE
- ap_rputs(" Token: lbrace\n", r);
-#endif
- if (current == (struct parse_node *) NULL) {
- root = current = new;
- break;
- }
- /* Percolate upwards */
- while (current != (struct parse_node *) NULL) {
- switch (current->token.type) {
- case token_not:
- case token_eq:
- case token_ne:
- case token_and:
- case token_or:
- case token_lbrace:
- case token_ge:
- case token_gt:
- case token_le:
- case token_lt:
- break;
- case token_string:
- case token_group:
- default:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid expression \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
- break;
- }
- if (current == (struct parse_node *) NULL) {
- new->left = root;
- new->left->parent = new;
- new->parent = (struct parse_node *) NULL;
- root = new;
- }
- else {
- new->left = current->right;
- current->right = new;
- new->parent = current;
- }
- current = new;
- break;
- default:
- break;
- }
- }
-
- /* Evaluate Parse Tree */
- current = root;
- while (current != (struct parse_node *) NULL) {
- switch (current->token.type) {
- case token_string:
-#ifdef DEBUG_INCLUDE
- ap_rputs(" Evaluate string\n", r);
-#endif
- parse_string(r, current->token.value, buffer, sizeof(buffer), 0);
- ap_cpystrn(current->token.value, buffer, sizeof(current->token.value));
- current->value = (current->token.value[0] != '\0');
- current->done = 1;
- current = current->parent;
- break;
-
- case token_and:
- case token_or:
-#ifdef DEBUG_INCLUDE
- ap_rputs(" Evaluate and/or\n", r);
-#endif
- if (current->left == (struct parse_node *) NULL ||
- current->right == (struct parse_node *) NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid expression \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
- if (!current->left->done) {
- switch (current->left->token.type) {
- case token_string:
- parse_string(r, current->left->token.value,
- buffer, sizeof(buffer), 0);
- ap_cpystrn(current->left->token.value, buffer,
- sizeof(current->left->token.value));
- current->left->value = (current->left->token.value[0] != '\0');
- current->left->done = 1;
- break;
- default:
- current = current->left;
- continue;
- }
- }
- if (!current->right->done) {
- switch (current->right->token.type) {
- case token_string:
- parse_string(r, current->right->token.value,
- buffer, sizeof(buffer), 0);
- ap_cpystrn(current->right->token.value, buffer,
- sizeof(current->right->token.value));
- current->right->value = (current->right->token.value[0] != '\0');
- current->right->done = 1;
- break;
- default:
- current = current->right;
- continue;
- }
- }
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, " Left: ", current->left->value ? "1" : "0",
- "\n", NULL);
- ap_rvputs(r, " Right: ", current->right->value ? "1" : "0",
- "\n", NULL);
-#endif
- if (current->token.type == token_and) {
- current->value = current->left->value && current->right->value;
- }
- else {
- current->value = current->left->value || current->right->value;
- }
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, " Returning ", current->value ? "1" : "0",
- "\n", NULL);
-#endif
- current->done = 1;
- current = current->parent;
- break;
-
- case token_eq:
- case token_ne:
-#ifdef DEBUG_INCLUDE
- ap_rputs(" Evaluate eq/ne\n", r);
-#endif
- if ((current->left == (struct parse_node *) NULL) ||
- (current->right == (struct parse_node *) NULL) ||
- (current->left->token.type != token_string) ||
- (current->right->token.type != token_string)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid expression \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
- parse_string(r, current->left->token.value,
- buffer, sizeof(buffer), 0);
- ap_cpystrn(current->left->token.value, buffer,
- sizeof(current->left->token.value));
- parse_string(r, current->right->token.value,
- buffer, sizeof(buffer), 0);
- ap_cpystrn(current->right->token.value, buffer,
- sizeof(current->right->token.value));
- if (current->right->token.value[0] == '/') {
- int len;
- len = strlen(current->right->token.value);
- if (current->right->token.value[len - 1] == '/') {
- current->right->token.value[len - 1] = '\0';
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid rexp \"%s\" in file %s",
- current->right->token.value, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, " Re Compare (", current->left->token.value,
- ") with /", &current->right->token.value[1], "/\n", NULL);
-#endif
- current->value =
- re_check(r, current->left->token.value,
- &current->right->token.value[1]);
- }
- else {
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, " Compare (", current->left->token.value,
- ") with (", current->right->token.value, ")\n", NULL);
-#endif
- current->value =
- (strcmp(current->left->token.value,
- current->right->token.value) == 0);
- }
- if (current->token.type == token_ne) {
- current->value = !current->value;
- }
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, " Returning ", current->value ? "1" : "0",
- "\n", NULL);
-#endif
- current->done = 1;
- current = current->parent;
- break;
- case token_ge:
- case token_gt:
- case token_le:
- case token_lt:
-#ifdef DEBUG_INCLUDE
- ap_rputs(" Evaluate ge/gt/le/lt\n", r);
-#endif
- if ((current->left == (struct parse_node *) NULL) ||
- (current->right == (struct parse_node *) NULL) ||
- (current->left->token.type != token_string) ||
- (current->right->token.type != token_string)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid expression \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
- }
- parse_string(r, current->left->token.value,
- buffer, sizeof(buffer), 0);
- ap_cpystrn(current->left->token.value, buffer,
- sizeof(current->left->token.value));
- parse_string(r, current->right->token.value,
- buffer, sizeof(buffer), 0);
- ap_cpystrn(current->right->token.value, buffer,
- sizeof(current->right->token.value));
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, " Compare (", current->left->token.value,
- ") with (", current->right->token.value, ")\n", NULL);
-#endif
- current->value =
- strcmp(current->left->token.value,
- current->right->token.value);
- if (current->token.type == token_ge) {
- current->value = current->value >= 0;
- }
- else if (current->token.type == token_gt) {
- current->value = current->value > 0;
- }
- else if (current->token.type == token_le) {
- current->value = current->value <= 0;
- }
- else if (current->token.type == token_lt) {
- current->value = current->value < 0;
- }
- else {
- current->value = 0; /* Don't return -1 if unknown token */
- }
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, " Returning ", current->value ? "1" : "0",
- "\n", NULL);
-#endif
- current->done = 1;
- current = current->parent;
- break;
-
- case token_not:
- if (current->right != (struct parse_node *) NULL) {
- if (!current->right->done) {
- current = current->right;
- continue;
- }
- current->value = !current->right->value;
- }
- else {
- current->value = 0;
- }
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, " Evaluate !: ", current->value ? "1" : "0",
- "\n", NULL);
-#endif
- current->done = 1;
- current = current->parent;
- break;
-
- case token_group:
- if (current->right != (struct parse_node *) NULL) {
- if (!current->right->done) {
- current = current->right;
- continue;
- }
- current->value = current->right->value;
- }
- else {
- current->value = 1;
- }
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, " Evaluate (): ", current->value ? "1" : "0",
- "\n", NULL);
-#endif
- current->done = 1;
- current = current->parent;
- break;
-
- case token_lbrace:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Unmatched '(' in \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
-
- case token_rbrace:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Unmatched ')' in \"%s\" in file %s",
- expr, r->filename);
- ap_rputs(error, r);
- goto RETURN;
-
- default:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "bad token type");
- ap_rputs(error, r);
- goto RETURN;
- }
- }
-
- retval = (root == (struct parse_node *) NULL) ? 0 : root->value;
- RETURN:
- ap_destroy_pool(expr_pool);
- return (retval);
-}
-
-static int handle_if(ap_file_t *in, request_rec *r, const char *error,
- int *conditional_status, int *printing)
-{
- char tag[MAX_STRING_LEN];
- char *tag_val;
- char *expr;
-
- expr = NULL;
- while (1) {
- tag_val = get_tag(r->pool, in, tag, sizeof(tag), 0);
- if (*tag == '\0') {
- return 1;
- }
- else if (!strcmp(tag, "done")) {
- if (expr == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "missing expr in if statement: %s",
- r->filename);
- ap_rputs(error, r);
- return 1;
- }
- *printing = *conditional_status = parse_expr(r, expr, error);
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, "**** if conditional_status=\"",
- *conditional_status ? "1" : "0", "\"\n", NULL);
-#endif
- return 0;
- }
- else if (!strcmp(tag, "expr")) {
- expr = tag_val;
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, "**** if expr=\"", expr, "\"\n", NULL);
-#endif
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "unknown parameter \"%s\" to tag if in %s",
- tag, r->filename);
- ap_rputs(error, r);
- }
- }
-}
-
-static int handle_elif(ap_file_t *in, request_rec *r, const char *error,
- int *conditional_status, int *printing)
-{
- char tag[MAX_STRING_LEN];
- char *tag_val;
- char *expr;
-
- expr = NULL;
- while (1) {
- tag_val = get_tag(r->pool, in, tag, sizeof(tag), 0);
- if (*tag == '\0') {
- return 1;
- }
- else if (!strcmp(tag, "done")) {
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, "**** elif conditional_status=\"",
- *conditional_status ? "1" : "0", "\"\n", NULL);
-#endif
- if (*conditional_status) {
- *printing = 0;
- return (0);
- }
- if (expr == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "missing expr in elif statement: %s",
- r->filename);
- ap_rputs(error, r);
- return 1;
- }
- *printing = *conditional_status = parse_expr(r, expr, error);
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, "**** elif conditional_status=\"",
- *conditional_status ? "1" : "0", "\"\n", NULL);
-#endif
- return 0;
- }
- else if (!strcmp(tag, "expr")) {
- expr = tag_val;
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, "**** if expr=\"", expr, "\"\n", NULL);
-#endif
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "unknown parameter \"%s\" to tag if in %s",
- tag, r->filename);
- ap_rputs(error, r);
- }
- }
-}
-
-static int handle_else(ap_file_t *in, request_rec *r, const char *error,
- int *conditional_status, int *printing)
-{
- char tag[MAX_STRING_LEN];
-
- if (!get_tag(r->pool, in, tag, sizeof(tag), 1)) {
- return 1;
- }
- else if (!strcmp(tag, "done")) {
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, "**** else conditional_status=\"",
- *conditional_status ? "1" : "0", "\"\n", NULL);
-#endif
- *printing = !(*conditional_status);
- *conditional_status = 1;
- return 0;
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "else directive does not take tags in %s",
- r->filename);
- if (*printing) {
- ap_rputs(error, r);
- }
- return -1;
- }
-}
-
-static int handle_endif(ap_file_t *in, request_rec *r, const char *error,
- int *conditional_status, int *printing)
-{
- char tag[MAX_STRING_LEN];
-
- if (!get_tag(r->pool, in, tag, sizeof(tag), 1)) {
- return 1;
- }
- else if (!strcmp(tag, "done")) {
-#ifdef DEBUG_INCLUDE
- ap_rvputs(r, "**** endif conditional_status=\"",
- *conditional_status ? "1" : "0", "\"\n", NULL);
-#endif
- *printing = 1;
- *conditional_status = 1;
- return 0;
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "endif directive does not take tags in %s",
- r->filename);
- ap_rputs(error, r);
- return -1;
- }
-}
-
-static int handle_set(ap_file_t *in, request_rec *r, const char *error)
-{
- char tag[MAX_STRING_LEN];
- char parsed_string[MAX_STRING_LEN];
- char *tag_val;
- char *var;
-
- var = (char *) NULL;
- while (1) {
- if (!(tag_val = get_tag(r->pool, in, tag, sizeof(tag), 1))) {
- return 1;
- }
- else if (!strcmp(tag, "done")) {
- return 0;
- }
- else if (!strcmp(tag, "var")) {
- var = tag_val;
- }
- else if (!strcmp(tag, "value")) {
- if (var == (char *) NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "variable must precede value in set directive in %s",
- r->filename);
- ap_rputs(error, r);
- return -1;
- }
- parse_string(r, tag_val, parsed_string, sizeof(parsed_string), 0);
- ap_table_setn(r->subprocess_env, var, ap_pstrdup(r->pool, parsed_string));
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid tag for set directive in %s", r->filename);
- ap_rputs(error, r);
- return -1;
- }
- }
-}
-
-static int handle_printenv(ap_file_t *in, request_rec *r, const char *error)
-{
- char tag[MAX_STRING_LEN];
- char *tag_val;
- ap_array_header_t *arr = ap_table_elts(r->subprocess_env);
- ap_table_entry_t *elts = (ap_table_entry_t *)arr->elts;
- int i;
-
- if (!(tag_val = get_tag(r->pool, in, tag, sizeof(tag), 1))) {
- return 1;
- }
- else if (!strcmp(tag, "done")) {
- for (i = 0; i < arr->nelts; ++i) {
- ap_rvputs(r, elts[i].key, "=", elts[i].val, "\n", NULL);
- }
- return 0;
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "printenv directive does not take tags in %s",
- r->filename);
- ap_rputs(error, r);
- return -1;
- }
-}
-
-
-
-/* -------------------------- The main function --------------------------- */
-
-/* This is a stub which parses a file descriptor. */
-
-static void send_parsed_content(ap_file_t *f, request_rec *r)
-{
- char directive[MAX_STRING_LEN], error[MAX_STRING_LEN];
- char timefmt[MAX_STRING_LEN];
- int noexec = ap_allow_options(r) & OPT_INCNOEXEC;
- int ret, sizefmt;
- int if_nesting;
- int printing;
- int conditional_status;
-
- ap_cpystrn(error, DEFAULT_ERROR_MSG, sizeof(error));
- ap_cpystrn(timefmt, DEFAULT_TIME_FORMAT, sizeof(timefmt));
- sizefmt = SIZEFMT_KMG;
-
-/* Turn printing on */
- printing = conditional_status = 1;
- if_nesting = 0;
-
- ap_chdir_file(r->filename);
- if (r->args) { /* add QUERY stuff to env cause it ain't yet */
- char *arg_copy = ap_pstrdup(r->pool, r->args);
-
- ap_table_setn(r->subprocess_env, "QUERY_STRING", r->args);
- ap_unescape_url(arg_copy);
- ap_table_setn(r->subprocess_env, "QUERY_STRING_UNESCAPED",
- ap_escape_shell_cmd(r->pool, arg_copy));
- }
-
- while (1) {
- if (!find_string(f, STARTING_SEQUENCE, r, printing)) {
- if (get_directive(f, directive, sizeof(directive), r->pool)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "mod_include: error reading directive in %s",
- r->filename);
- ap_rputs(error, r);
- return;
- }
- if (!strcmp(directive, "if")) {
- if (!printing) {
- if_nesting++;
- }
- else {
- ret = handle_if(f, r, error, &conditional_status,
- &printing);
- if_nesting = 0;
- }
- continue;
- }
- else if (!strcmp(directive, "else")) {
- if (!if_nesting) {
- ret = handle_else(f, r, error, &conditional_status,
- &printing);
- }
- continue;
- }
- else if (!strcmp(directive, "elif")) {
- if (!if_nesting) {
- ret = handle_elif(f, r, error, &conditional_status,
- &printing);
- }
- continue;
- }
- else if (!strcmp(directive, "endif")) {
- if (!if_nesting) {
- ret = handle_endif(f, r, error, &conditional_status,
- &printing);
- }
- else {
- if_nesting--;
- }
- continue;
- }
- if (!printing) {
- continue;
- }
- if (!strcmp(directive, "exec")) {
- if (noexec) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "exec used but not allowed in %s",
- r->filename);
- if (printing) {
- ap_rputs(error, r);
- }
- ret = find_string(f, ENDING_SEQUENCE, r, 0);
- }
- else {
- ret = handle_exec(f, r, error);
- }
- }
- else if (!strcmp(directive, "config")) {
- ret = handle_config(f, r, error, timefmt, &sizefmt);
- }
- else if (!strcmp(directive, "set")) {
- ret = handle_set(f, r, error);
- }
- else if (!strcmp(directive, "include")) {
- ret = handle_include(f, r, error, noexec);
- }
- else if (!strcmp(directive, "echo")) {
- ret = handle_echo(f, r, error);
- }
- else if (!strcmp(directive, "fsize")) {
- ret = handle_fsize(f, r, error, sizefmt);
- }
- else if (!strcmp(directive, "flastmod")) {
- ret = handle_flastmod(f, r, error, timefmt);
- }
- else if (!strcmp(directive, "printenv")) {
- ret = handle_printenv(f, r, error);
- }
-#ifdef USE_PERL_SSI
- else if (!strcmp(directive, "perl")) {
- ret = handle_perl(f, r, error);
- }
-#endif
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "unknown directive \"%s\" "
- "in parsed doc %s",
- directive, r->filename);
- if (printing) {
- ap_rputs(error, r);
- }
- ret = find_string(f, ENDING_SEQUENCE, r, 0);
- }
- if (ret) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "premature EOF in parsed file %s",
- r->filename);
- return;
- }
- }
- else {
- return;
- }
- }
-}
-
-/*****************************************************************
- *
- * XBITHACK. Sigh... NB it's configurable per-directory; the compile-time
- * option only changes the default.
- */
-
-module includes_module;
-enum xbithack {
- xbithack_off, xbithack_on, xbithack_full
-};
-
-#ifdef XBITHACK
-#define DEFAULT_XBITHACK xbithack_full
-#else
-#define DEFAULT_XBITHACK xbithack_off
-#endif
-
-static void *create_includes_dir_config(ap_context_t *p, char *dummy)
-{
- enum xbithack *result = (enum xbithack *) ap_palloc(p, sizeof(enum xbithack));
- *result = DEFAULT_XBITHACK;
- return result;
-}
-
-static const char *set_xbithack(cmd_parms *cmd, void *xbp, char *arg)
-{
- enum xbithack *state = (enum xbithack *) xbp;
-
- if (!strcasecmp(arg, "off")) {
- *state = xbithack_off;
- }
- else if (!strcasecmp(arg, "on")) {
- *state = xbithack_on;
- }
- else if (!strcasecmp(arg, "full")) {
- *state = xbithack_full;
- }
- else {
- return "XBitHack must be set to Off, On, or Full";
- }
-
- return NULL;
-}
-
-static int send_parsed_file(request_rec *r)
-{
- ap_file_t *f = NULL;
- enum xbithack *state =
- (enum xbithack *) ap_get_module_config(r->per_dir_config, &includes_module);
- int errstatus;
- request_rec *parent;
-
- if (!(ap_allow_options(r) & OPT_INCLUDES)) {
- return DECLINED;
- }
- r->allowed |= (1 << M_GET);
- if (r->method_number != M_GET) {
- return DECLINED;
- }
- if (r->finfo.protection == 0) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "File does not exist: %s",
- (r->path_info
- ? ap_pstrcat(r->pool, r->filename, r->path_info, NULL)
- : r->filename));
- return HTTP_NOT_FOUND;
- }
-
- errstatus = ap_open(&f, r->filename, APR_READ, 0, r->pool);
-
- if (errstatus != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errstatus, r,
- "file permissions deny server access: %s", r->filename);
- return HTTP_FORBIDDEN;
- }
-
- if ((*state == xbithack_full)
-#if !defined(OS2) && !defined(WIN32)
- /* OS/2 dosen't support Groups. */
- && (r->finfo.protection & S_IXGRP)
-#endif
- ) {
- ap_update_mtime(r, r->finfo.mtime);
- ap_set_last_modified(r);
- }
- if ((errstatus = ap_meets_conditions(r)) != OK) {
- return errstatus;
- }
-
- ap_send_http_header(r);
-
- if (r->header_only) {
- ap_close(f);
- return OK;
- }
-
- if ((parent = ap_get_module_config(r->request_config, &includes_module))) {
- /* Kludge --- for nested includes, we want to keep the subprocess
- * environment of the base document (for compatibility); that means
- * torquing our own last_modified date as well so that the
- * LAST_MODIFIED variable gets reset to the proper value if the
- * nested document resets <!--#config timefmt-->.
- * We also insist that the memory for this subrequest not be
- * destroyed, that's dealt with in handle_include().
- */
- r->subprocess_env = parent->subprocess_env;
- ap_pool_join(parent->pool, r->pool);
- r->finfo.mtime = parent->finfo.mtime;
- }
- else {
- /* we're not a nested include, so we create an initial
- * environment */
- ap_add_common_vars(r);
- ap_add_cgi_vars(r);
- add_include_vars(r, DEFAULT_TIME_FORMAT);
- }
- /* XXX: this is bogus, at some point we're going to do a subrequest,
- * and when we do it we're going to be subjecting code that doesn't
- * expect to be signal-ready to SIGALRM. There is no clean way to
- * fix this, except to put alarm support into BUFF. -djg
- */
-#ifdef CHARSET_EBCDIC
- /* XXX:@@@ Is the generated/included output ALWAYS in text/ebcdic format? */
- ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, 1);
-#endif
-
- send_parsed_content(f, r);
-
- if (parent) {
- /* signify that the sub request should not be killed */
- ap_set_module_config(r->request_config, &includes_module,
- NESTED_INCLUDE_MAGIC);
- }
-
- return OK;
-}
-
-static int send_shtml_file(request_rec *r)
-{
- r->content_type = "text/html";
- return send_parsed_file(r);
-}
-
-static int xbithack_handler(request_rec *r)
-{
-#if defined(OS2) || defined(WIN32)
- /* OS/2 dosen't currently support the xbithack. This is being worked on. */
- return DECLINED;
-#else
- enum xbithack *state;
-
- if (!(r->finfo.protection & S_IXUSR)) {
- return DECLINED;
- }
-
- state = (enum xbithack *) ap_get_module_config(r->per_dir_config,
- &includes_module);
-
- if (*state == xbithack_off) {
- return DECLINED;
- }
- return send_parsed_file(r);
-#endif
-}
-
-static const command_rec includes_cmds[] =
-{
- {"XBitHack", set_xbithack, NULL, OR_OPTIONS, TAKE1, "Off, On, or Full"},
- {NULL}
-};
-
-static const handler_rec includes_handlers[] =
-{
- {INCLUDES_MAGIC_TYPE, send_shtml_file},
- {INCLUDES_MAGIC_TYPE3, send_shtml_file},
- {"server-parsed", send_parsed_file},
- {"text/html", xbithack_handler},
- {NULL}
-};
-
-module MODULE_VAR_EXPORT includes_module =
-{
- STANDARD20_MODULE_STUFF,
- create_includes_dir_config, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- includes_cmds, /* command ap_table_t */
- includes_handlers, /* handlers */
- NULL /* register hooks */
-};
diff --git a/modules/filters/mod_include.exp b/modules/filters/mod_include.exp
deleted file mode 100644
index 335da742da..0000000000
--- a/modules/filters/mod_include.exp
+++ /dev/null
@@ -1 +0,0 @@
-includes_module
diff --git a/modules/generators/.indent.pro b/modules/generators/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/generators/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/generators/mod_asis.c b/modules/generators/mod_asis.c
deleted file mode 100644
index 4ad6cf6799..0000000000
--- a/modules/generators/mod_asis.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_protocol.h"
-#include "http_log.h"
-#include "util_script.h"
-#include "http_main.h"
-#include "http_request.h"
-
-#define ASIS_MAGIC_TYPE "httpd/send-as-is"
-
-static int asis_handler(request_rec *r)
-{
- ap_file_t *f = NULL;
- ap_status_t status;
- const char *location;
-
- r->allowed |= (1 << M_GET);
- if (r->method_number != M_GET)
- return DECLINED;
- if (r->finfo.protection == 0) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "File does not exist: %s", r->filename);
- return NOT_FOUND;
- }
-
- if ((status = ap_open(&f, r->filename, APR_READ | APR_BUFFERED,
- APR_OS_DEFAULT, r->pool)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
- "file permissions deny server access: %s", r->filename);
- return FORBIDDEN;
- }
-
- ap_scan_script_header_err(r, f, NULL);
- location = ap_table_get(r->headers_out, "Location");
-
- if (location && location[0] == '/' &&
- ((r->status == HTTP_OK) || ap_is_HTTP_REDIRECT(r->status))) {
-
- ap_close(f);
-
- /* Internal redirect -- fake-up a pseudo-request */
- r->status = HTTP_OK;
-
- /* This redirect needs to be a GET no matter what the original
- * method was.
- */
- r->method = ap_pstrdup(r->pool, "GET");
- r->method_number = M_GET;
-
- ap_internal_redirect_handler(location, r);
- return OK;
- }
-
- ap_send_http_header(r);
- if (!r->header_only) {
- ap_send_fd(f, r);
- }
-
- ap_close(f);
- return OK;
-}
-
-static const handler_rec asis_handlers[] =
-{
- {ASIS_MAGIC_TYPE, asis_handler},
- {"send-as-is", asis_handler},
- {NULL}
-};
-
-module MODULE_VAR_EXPORT asis_module =
-{
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- NULL, /* command ap_table_t */
- asis_handlers, /* handlers */
- NULL /* register hooks */
-};
diff --git a/modules/generators/mod_asis.exp b/modules/generators/mod_asis.exp
deleted file mode 100644
index 4f347d921e..0000000000
--- a/modules/generators/mod_asis.exp
+++ /dev/null
@@ -1 +0,0 @@
-asis_module
diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c
deleted file mode 100644
index 4f693d64cd..0000000000
--- a/modules/generators/mod_autoindex.c
+++ /dev/null
@@ -1,1678 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_autoindex.c: Handles the on-the-fly html index generation
- *
- * Rob McCool
- * 3/23/93
- *
- * Adapted to Apache by rst.
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_request.h"
-#include "http_protocol.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "util_script.h"
-#include "apr_fnmatch.h"
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-module MODULE_VAR_EXPORT autoindex_module;
-
-/****************************************************************
- *
- * Handling configuration directives...
- */
-
-#define HRULE 1
-#define NO_HRULE 0
-#define FRONT_MATTER 1
-#define END_MATTER 0
-
-#define FANCY_INDEXING 1 /* Indexing options */
-#define ICONS_ARE_LINKS 2
-#define SCAN_HTML_TITLES 4
-#define SUPPRESS_LAST_MOD 8
-#define SUPPRESS_SIZE 16
-#define SUPPRESS_DESC 32
-#define SUPPRESS_PREAMBLE 64
-#define SUPPRESS_COLSORT 128
-#define NO_OPTIONS 256
-
-#define K_PAD 1
-#define K_NOPAD 0
-
-#define K_NOADJUST 0
-#define K_ADJUST 1
-#define K_UNSET 2
-
-/*
- * Define keys for sorting.
- */
-#define K_NAME 'N' /* Sort by file name (default) */
-#define K_LAST_MOD 'M' /* Last modification date */
-#define K_SIZE 'S' /* Size (absolute, not as displayed) */
-#define K_DESC 'D' /* Description */
-
-#define D_ASCENDING 'A'
-#define D_DESCENDING 'D'
-
-/*
- * These are the dimensions of the default icons supplied with Apache.
- */
-#define DEFAULT_ICON_WIDTH 20
-#define DEFAULT_ICON_HEIGHT 22
-
-/*
- * Other default dimensions.
- */
-#define DEFAULT_NAME_WIDTH 23
-
-struct item {
- char *type;
- char *apply_to;
- char *apply_path;
- char *data;
-};
-
-typedef struct ai_desc_t {
- char *pattern;
- char *description;
- int full_path;
- int wildcards;
-} ai_desc_t;
-
-typedef struct autoindex_config_struct {
-
- char *default_icon;
- int opts;
- int incremented_opts;
- int decremented_opts;
- int name_width;
- int name_adjust;
- int icon_width;
- int icon_height;
- char *default_order;
-
- ap_array_header_t *icon_list;
- ap_array_header_t *alt_list;
- ap_array_header_t *desc_list;
- ap_array_header_t *ign_list;
- ap_array_header_t *hdr_list;
- ap_array_header_t *rdme_list;
-
-} autoindex_config_rec;
-
-static char c_by_encoding, c_by_type, c_by_path;
-
-#define BY_ENCODING &c_by_encoding
-#define BY_TYPE &c_by_type
-#define BY_PATH &c_by_path
-
-/*
- * Return true if the specified string refers to the parent directory (i.e.,
- * matches ".." or "../"). Hopefully this one call is significantly less
- * expensive than multiple strcmp() calls.
- */
-static ap_inline int is_parent(const char *name)
-{
- /*
- * Now, IFF the first two bytes are dots, and the third byte is either
- * EOS (\0) or a slash followed by EOS, we have a match.
- */
- if (((name[0] == '.') && (name[1] == '.'))
- && ((name[2] == '\0')
- || ((name[2] == '/') && (name[3] == '\0')))) {
- return 1;
- }
- return 0;
-}
-
-/*
- * This routine puts the standard HTML header at the top of the index page.
- * We include the DOCTYPE because we may be using features therefrom (i.e.,
- * HEIGHT and WIDTH attributes on the icons if we're FancyIndexing).
- */
-static void emit_preamble(request_rec *r, char *title)
-{
- ap_rvputs(r, DOCTYPE_HTML_3_2,
- "<HTML>\n <HEAD>\n <TITLE>Index of ", title,
- "</TITLE>\n </HEAD>\n <BODY>\n", NULL);
-}
-
-static void push_item(ap_array_header_t *arr, char *type, char *to, char *path,
- char *data)
-{
- struct item *p = (struct item *) ap_push_array(arr);
-
- if (!to) {
- to = "";
- }
- if (!path) {
- path = "";
- }
-
- p->type = type;
- p->data = data ? ap_pstrdup(arr->cont, data) : NULL;
- p->apply_path = ap_pstrcat(arr->cont, path, "*", NULL);
-
- if ((type == BY_PATH) && (!ap_is_matchexp(to))) {
- p->apply_to = ap_pstrcat(arr->cont, "*", to, NULL);
- }
- else if (to) {
- p->apply_to = ap_pstrdup(arr->cont, to);
- }
- else {
- p->apply_to = NULL;
- }
-}
-
-static const char *add_alt(cmd_parms *cmd, void *d, char *alt, char *to)
-{
- if (cmd->info == BY_PATH) {
- if (!strcmp(to, "**DIRECTORY**")) {
- to = "^^DIRECTORY^^";
- }
- }
- if (cmd->info == BY_ENCODING) {
- ap_str_tolower(to);
- }
-
- push_item(((autoindex_config_rec *) d)->alt_list, cmd->info, to,
- cmd->path, alt);
- return NULL;
-}
-
-static const char *add_icon(cmd_parms *cmd, void *d, char *icon, char *to)
-{
- char *iconbak = ap_pstrdup(cmd->pool, icon);
-
- if (icon[0] == '(') {
- char *alt;
- char *cl = strchr(iconbak, ')');
-
- if (cl == NULL) {
- return "missing closing paren";
- }
- alt = ap_getword_nc(cmd->pool, &iconbak, ',');
- *cl = '\0'; /* Lose closing paren */
- add_alt(cmd, d, &alt[1], to);
- }
- if (cmd->info == BY_PATH) {
- if (!strcmp(to, "**DIRECTORY**")) {
- to = "^^DIRECTORY^^";
- }
- }
- if (cmd->info == BY_ENCODING) {
- ap_str_tolower(to);
- }
-
- push_item(((autoindex_config_rec *) d)->icon_list, cmd->info, to,
- cmd->path, iconbak);
- return NULL;
-}
-
-/*
- * Add description text for a filename pattern. If the pattern has
- * wildcards already (or we need to add them), add leading and
- * trailing wildcards to it to ensure substring processing. If the
- * pattern contains a '/' anywhere, force wildcard matching mode,
- * add a slash to the prefix so that "bar/bletch" won't be matched
- * by "foobar/bletch", and make a note that there's a delimiter;
- * the matching routine simplifies to just the actual filename
- * whenever it can. This allows definitions in parent directories
- * to be made for files in subordinate ones using relative paths.
- */
-
-/*
- * Absent a strcasestr() function, we have to force wildcards on
- * systems for which "AAA" and "aaa" mean the same file.
- */
-#ifdef CASE_BLIND_FILESYSTEM
-#define WILDCARDS_REQUIRED 1
-#else
-#define WILDCARDS_REQUIRED 0
-#endif
-
-static const char *add_desc(cmd_parms *cmd, void *d, char *desc, char *to)
-{
- autoindex_config_rec *dcfg = (autoindex_config_rec *) d;
- ai_desc_t *desc_entry;
- char *prefix = "";
-
- desc_entry = (ai_desc_t *) ap_push_array(dcfg->desc_list);
- desc_entry->full_path = (strchr(to, '/') == NULL) ? 0 : 1;
- desc_entry->wildcards = (WILDCARDS_REQUIRED
- || desc_entry->full_path
- || ap_is_fnmatch(to));
- if (desc_entry->wildcards) {
- prefix = desc_entry->full_path ? "*/" : "*";
- desc_entry->pattern = ap_pstrcat(dcfg->desc_list->cont,
- prefix, to, "*", NULL);
- }
- else {
- desc_entry->pattern = ap_pstrdup(dcfg->desc_list->cont, to);
- }
- desc_entry->description = ap_pstrdup(dcfg->desc_list->cont, desc);
- return NULL;
-}
-
-static const char *add_ignore(cmd_parms *cmd, void *d, char *ext)
-{
- push_item(((autoindex_config_rec *) d)->ign_list, 0, ext, cmd->path, NULL);
- return NULL;
-}
-
-static const char *add_header(cmd_parms *cmd, void *d, char *name)
-{
- push_item(((autoindex_config_rec *) d)->hdr_list, 0, NULL, cmd->path,
- name);
- return NULL;
-}
-
-static const char *add_readme(cmd_parms *cmd, void *d, char *name)
-{
- push_item(((autoindex_config_rec *) d)->rdme_list, 0, NULL, cmd->path,
- name);
- return NULL;
-}
-
-/* A legacy directive, FancyIndexing is superseded by the IndexOptions
- * keyword. But for compatibility..
- */
-static const char *fancy_indexing(cmd_parms *cmd, void *d, int arg)
-{
- int curopts;
- int newopts;
- autoindex_config_rec *cfg;
-
- cfg = (autoindex_config_rec *) d;
- curopts = cfg->opts;
- if (curopts & NO_OPTIONS) {
- return "FancyIndexing directive conflicts with existing "
- "IndexOptions None";
- }
- newopts = (arg ? (curopts | FANCY_INDEXING) : (curopts & ~FANCY_INDEXING));
- cfg->opts = newopts;
- return NULL;
-}
-
-static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr)
-{
- char *w;
- int opts;
- int opts_add;
- int opts_remove;
- char action;
- autoindex_config_rec *d_cfg = (autoindex_config_rec *) d;
-
- opts = d_cfg->opts;
- opts_add = d_cfg->incremented_opts;
- opts_remove = d_cfg->decremented_opts;
- while (optstr[0]) {
- int option = 0;
-
- w = ap_getword_conf(cmd->pool, &optstr);
- if ((*w == '+') || (*w == '-')) {
- action = *(w++);
- }
- else {
- action = '\0';
- }
- if (!strcasecmp(w, "FancyIndexing")) {
- option = FANCY_INDEXING;
- }
- else if (!strcasecmp(w, "IconsAreLinks")) {
- option = ICONS_ARE_LINKS;
- }
- else if (!strcasecmp(w, "ScanHTMLTitles")) {
- option = SCAN_HTML_TITLES;
- }
- else if (!strcasecmp(w, "SuppressLastModified")) {
- option = SUPPRESS_LAST_MOD;
- }
- else if (!strcasecmp(w, "SuppressSize")) {
- option = SUPPRESS_SIZE;
- }
- else if (!strcasecmp(w, "SuppressDescription")) {
- option = SUPPRESS_DESC;
- }
- else if (!strcasecmp(w, "SuppressHTMLPreamble")) {
- option = SUPPRESS_PREAMBLE;
- }
- else if (!strcasecmp(w, "SuppressColumnSorting")) {
- option = SUPPRESS_COLSORT;
- }
- else if (!strcasecmp(w, "None")) {
- if (action != '\0') {
- return "Cannot combine '+' or '-' with 'None' keyword";
- }
- opts = NO_OPTIONS;
- opts_add = 0;
- opts_remove = 0;
- }
- else if (!strcasecmp(w, "IconWidth")) {
- if (action != '-') {
- d_cfg->icon_width = DEFAULT_ICON_WIDTH;
- }
- else {
- d_cfg->icon_width = 0;
- }
- }
- else if (!strncasecmp(w, "IconWidth=", 10)) {
- if (action == '-') {
- return "Cannot combine '-' with IconWidth=n";
- }
- d_cfg->icon_width = atoi(&w[10]);
- }
- else if (!strcasecmp(w, "IconHeight")) {
- if (action != '-') {
- d_cfg->icon_height = DEFAULT_ICON_HEIGHT;
- }
- else {
- d_cfg->icon_height = 0;
- }
- }
- else if (!strncasecmp(w, "IconHeight=", 11)) {
- if (action == '-') {
- return "Cannot combine '-' with IconHeight=n";
- }
- d_cfg->icon_height = atoi(&w[11]);
- }
- else if (!strcasecmp(w, "NameWidth")) {
- if (action != '-') {
- return "NameWidth with no value may only appear as "
- "'-NameWidth'";
- }
- d_cfg->name_width = DEFAULT_NAME_WIDTH;
- d_cfg->name_adjust = K_NOADJUST;
- }
- else if (!strncasecmp(w, "NameWidth=", 10)) {
- if (action == '-') {
- return "Cannot combine '-' with NameWidth=n";
- }
- if (w[10] == '*') {
- d_cfg->name_adjust = K_ADJUST;
- }
- else {
- int width = atoi(&w[10]);
-
- if (width < 5) {
- return "NameWidth value must be greater than 5";
- }
- d_cfg->name_width = width;
- d_cfg->name_adjust = K_NOADJUST;
- }
- }
- else {
- return "Invalid directory indexing option";
- }
- if (action == '\0') {
- opts |= option;
- opts_add = 0;
- opts_remove = 0;
- }
- else if (action == '+') {
- opts_add |= option;
- opts_remove &= ~option;
- }
- else {
- opts_remove |= option;
- opts_add &= ~option;
- }
- }
- if ((opts & NO_OPTIONS) && (opts & ~NO_OPTIONS)) {
- return "Cannot combine other IndexOptions keywords with 'None'";
- }
- d_cfg->incremented_opts = opts_add;
- d_cfg->decremented_opts = opts_remove;
- d_cfg->opts = opts;
- return NULL;
-}
-
-static const char *set_default_order(cmd_parms *cmd, void *m, char *direction,
- char *key)
-{
- char temp[4];
- autoindex_config_rec *d_cfg = (autoindex_config_rec *) m;
-
- ap_cpystrn(temp, "k=d", sizeof(temp));
- if (!strcasecmp(direction, "Ascending")) {
- temp[2] = D_ASCENDING;
- }
- else if (!strcasecmp(direction, "Descending")) {
- temp[2] = D_DESCENDING;
- }
- else {
- return "First keyword must be 'Ascending' or 'Descending'";
- }
-
- if (!strcasecmp(key, "Name")) {
- temp[0] = K_NAME;
- }
- else if (!strcasecmp(key, "Date")) {
- temp[0] = K_LAST_MOD;
- }
- else if (!strcasecmp(key, "Size")) {
- temp[0] = K_SIZE;
- }
- else if (!strcasecmp(key, "Description")) {
- temp[0] = K_DESC;
- }
- else {
- return "Second keyword must be 'Name', 'Date', 'Size', or "
- "'Description'";
- }
-
- if (d_cfg->default_order == NULL) {
- d_cfg->default_order = ap_palloc(cmd->pool, 4);
- d_cfg->default_order[3] = '\0';
- }
- ap_cpystrn(d_cfg->default_order, temp, sizeof(temp));
- return NULL;
-}
-
-#define DIR_CMD_PERMS OR_INDEXES
-
-static const command_rec autoindex_cmds[] =
-{
- {"AddIcon", add_icon, BY_PATH, DIR_CMD_PERMS, ITERATE2,
- "an icon URL followed by one or more filenames"},
- {"AddIconByType", add_icon, BY_TYPE, DIR_CMD_PERMS, ITERATE2,
- "an icon URL followed by one or more MIME types"},
- {"AddIconByEncoding", add_icon, BY_ENCODING, DIR_CMD_PERMS, ITERATE2,
- "an icon URL followed by one or more content encodings"},
- {"AddAlt", add_alt, BY_PATH, DIR_CMD_PERMS, ITERATE2,
- "alternate descriptive text followed by one or more filenames"},
- {"AddAltByType", add_alt, BY_TYPE, DIR_CMD_PERMS, ITERATE2,
- "alternate descriptive text followed by one or more MIME types"},
- {"AddAltByEncoding", add_alt, BY_ENCODING, DIR_CMD_PERMS, ITERATE2,
- "alternate descriptive text followed by one or more content encodings"},
- {"IndexOptions", add_opts, NULL, DIR_CMD_PERMS, RAW_ARGS,
- "one or more index options"},
- {"IndexOrderDefault", set_default_order, NULL, DIR_CMD_PERMS, TAKE2,
- "{Ascending,Descending} {Name,Size,Description,Date}"},
- {"IndexIgnore", add_ignore, NULL, DIR_CMD_PERMS, ITERATE,
- "one or more file extensions"},
- {"AddDescription", add_desc, BY_PATH, DIR_CMD_PERMS, ITERATE2,
- "Descriptive text followed by one or more filenames"},
- {"HeaderName", add_header, NULL, DIR_CMD_PERMS, TAKE1, "a filename"},
- {"ReadmeName", add_readme, NULL, DIR_CMD_PERMS, TAKE1, "a filename"},
- {"FancyIndexing", fancy_indexing, NULL, DIR_CMD_PERMS, FLAG,
- "Limited to 'on' or 'off' (superseded by IndexOptions FancyIndexing)"},
- {"DefaultIcon", ap_set_string_slot,
- (void *) XtOffsetOf(autoindex_config_rec, default_icon),
- DIR_CMD_PERMS, TAKE1, "an icon URL"},
- {NULL}
-};
-
-static void *create_autoindex_config(ap_context_t *p, char *dummy)
-{
- autoindex_config_rec *new =
- (autoindex_config_rec *) ap_pcalloc(p, sizeof(autoindex_config_rec));
-
- new->icon_width = 0;
- new->icon_height = 0;
- new->name_width = DEFAULT_NAME_WIDTH;
- new->name_adjust = K_UNSET;
- new->icon_list = ap_make_array(p, 4, sizeof(struct item));
- new->alt_list = ap_make_array(p, 4, sizeof(struct item));
- new->desc_list = ap_make_array(p, 4, sizeof(ai_desc_t));
- new->ign_list = ap_make_array(p, 4, sizeof(struct item));
- new->hdr_list = ap_make_array(p, 4, sizeof(struct item));
- new->rdme_list = ap_make_array(p, 4, sizeof(struct item));
- new->opts = 0;
- new->incremented_opts = 0;
- new->decremented_opts = 0;
- new->default_order = NULL;
-
- return (void *) new;
-}
-
-static void *merge_autoindex_configs(ap_context_t *p, void *basev, void *addv)
-{
- autoindex_config_rec *new;
- autoindex_config_rec *base = (autoindex_config_rec *) basev;
- autoindex_config_rec *add = (autoindex_config_rec *) addv;
-
- new = (autoindex_config_rec *) ap_pcalloc(p, sizeof(autoindex_config_rec));
- new->default_icon = add->default_icon ? add->default_icon
- : base->default_icon;
- new->icon_height = add->icon_height ? add->icon_height : base->icon_height;
- new->icon_width = add->icon_width ? add->icon_width : base->icon_width;
-
- new->alt_list = ap_append_arrays(p, add->alt_list, base->alt_list);
- new->ign_list = ap_append_arrays(p, add->ign_list, base->ign_list);
- new->hdr_list = ap_append_arrays(p, add->hdr_list, base->hdr_list);
- new->desc_list = ap_append_arrays(p, add->desc_list, base->desc_list);
- new->icon_list = ap_append_arrays(p, add->icon_list, base->icon_list);
- new->rdme_list = ap_append_arrays(p, add->rdme_list, base->rdme_list);
- if (add->opts & NO_OPTIONS) {
- /*
- * If the current directory says 'no options' then we also
- * clear any incremental mods from being inheritable further down.
- */
- new->opts = NO_OPTIONS;
- new->incremented_opts = 0;
- new->decremented_opts = 0;
- }
- else {
- /*
- * If there were any nonincremental options selected for
- * this directory, they dominate and we don't inherit *anything.*
- * Contrariwise, we *do* inherit if the only settings here are
- * incremental ones.
- */
- if (add->opts == 0) {
- new->incremented_opts = (base->incremented_opts
- | add->incremented_opts)
- & ~add->decremented_opts;
- new->decremented_opts = (base->decremented_opts
- | add->decremented_opts);
- /*
- * We may have incremental settings, so make sure we don't
- * inadvertently inherit an IndexOptions None from above.
- */
- new->opts = (base->opts & ~NO_OPTIONS);
- }
- else {
- /*
- * There are local nonincremental settings, which clear
- * all inheritance from above. They *are* the new base settings.
- */
- new->opts = add->opts;;
- }
- /*
- * We're guaranteed that there'll be no overlap between
- * the add-options and the remove-options.
- */
- new->opts |= new->incremented_opts;
- new->opts &= ~new->decremented_opts;
- }
- /*
- * Inherit the NameWidth settings if there aren't any specific to
- * the new location; otherwise we'll end up using the defaults set in the
- * config-rec creation routine.
- */
- if (add->name_adjust == K_UNSET) {
- new->name_width = base->name_width;
- new->name_adjust = base->name_adjust;
- }
- else {
- new->name_width = add->name_width;
- new->name_adjust = add->name_adjust;
- }
-
- new->default_order = (add->default_order != NULL)
- ? add->default_order : base->default_order;
- return new;
-}
-
-/****************************************************************
- *
- * Looking things up in config entries...
- */
-
-/* Structure used to hold entries when we're actually building an index */
-
-struct ent {
- char *name;
- char *icon;
- char *alt;
- char *desc;
- off_t size;
- ap_time_t lm;
- struct ent *next;
- int ascending;
- char key;
-};
-
-static char *find_item(request_rec *r, ap_array_header_t *list, int path_only)
-{
- const char *content_type = r->content_type;
- const char *content_encoding = r->content_encoding;
- char *path = r->filename;
-
- struct item *items = (struct item *) list->elts;
- int i;
-
- for (i = 0; i < list->nelts; ++i) {
- struct item *p = &items[i];
-
- /* Special cased for ^^DIRECTORY^^ and ^^BLANKICON^^ */
- if ((path[0] == '^') || (!ap_strcmp_match(path, p->apply_path))) {
- if (!*(p->apply_to)) {
- return p->data;
- }
- else if (p->type == BY_PATH || path[0] == '^') {
- if (!ap_strcmp_match(path, p->apply_to)) {
- return p->data;
- }
- }
- else if (!path_only) {
- if (!content_encoding) {
- if (p->type == BY_TYPE) {
- if (content_type
- && !ap_strcasecmp_match(content_type,
- p->apply_to)) {
- return p->data;
- }
- }
- }
- else {
- if (p->type == BY_ENCODING) {
- if (!ap_strcasecmp_match(content_encoding,
- p->apply_to)) {
- return p->data;
- }
- }
- }
- }
- }
- }
- return NULL;
-}
-
-#define find_icon(d,p,t) find_item(p,d->icon_list,t)
-#define find_alt(d,p,t) find_item(p,d->alt_list,t)
-#define find_header(d,p) find_item(p,d->hdr_list,0)
-#define find_readme(d,p) find_item(p,d->rdme_list,0)
-
-static char *find_default_icon(autoindex_config_rec *d, char *bogus_name)
-{
- request_rec r;
-
- /* Bleah. I tried to clean up find_item, and it lead to this bit
- * of ugliness. Note that the fields initialized are precisely
- * those that find_item looks at...
- */
-
- r.filename = bogus_name;
- r.content_type = r.content_encoding = NULL;
-
- return find_item(&r, d->icon_list, 1);
-}
-
-/*
- * Look through the list of pattern/description pairs and return the first one
- * if any) that matches the filename in the request. If multiple patterns
- * match, only the first one is used; since the order in the array is the
- * same as the order in which directives were processed, earlier matching
- * directives will dominate.
- */
-
-#ifdef CASE_BLIND_FILESYSTEM
-#define MATCH_FLAGS FNM_CASE_BLIND
-#else
-#define MATCH_FLAGS 0
-#endif
-
-static char *find_desc(autoindex_config_rec *dcfg, request_rec *r)
-{
- int i;
- ai_desc_t *list = (ai_desc_t *) dcfg->desc_list->elts;
- const char *filename_full = r->filename;
- const char *filename_only;
- const char *filename;
-
- /*
- * If the filename includes a path, extract just the name itself
- * for the simple matches.
- */
- if ((filename_only = strrchr(filename_full, '/')) == NULL) {
- filename_only = filename_full;
- }
- else {
- filename_only++;
- }
- for (i = 0; i < dcfg->desc_list->nelts; ++i) {
- ai_desc_t *tuple = &list[i];
- int found;
-
- /*
- * Only use the full-path filename if the pattern contains '/'s.
- */
- filename = (tuple->full_path) ? filename_full : filename_only;
- /*
- * Make the comparison using the cheapest method; only do
- * wildcard checking if we must.
- */
- if (tuple->wildcards) {
- found = (ap_fnmatch(tuple->pattern, filename, MATCH_FLAGS) == 0);
- }
- else {
- found = (strstr(filename, tuple->pattern) != NULL);
- }
- if (found) {
- return tuple->description;
- }
- }
- return NULL;
-}
-
-static int ignore_entry(autoindex_config_rec *d, char *path)
-{
- ap_array_header_t *list = d->ign_list;
- struct item *items = (struct item *) list->elts;
- char *tt;
- int i;
-
- if ((tt = strrchr(path, '/')) == NULL) {
- tt = path;
- }
- else {
- tt++;
- }
-
- for (i = 0; i < list->nelts; ++i) {
- struct item *p = &items[i];
- char *ap;
-
- if ((ap = strrchr(p->apply_to, '/')) == NULL) {
- ap = p->apply_to;
- }
- else {
- ap++;
- }
-
-#ifndef CASE_BLIND_FILESYSTEM
- if (!ap_strcmp_match(path, p->apply_path)
- && !ap_strcmp_match(tt, ap)) {
- return 1;
- }
-#else /* !CASE_BLIND_FILESYSTEM */
- /*
- * On some platforms, the match must be case-blind. This is really
- * a factor of the filesystem involved, but we can't detect that
- * reliably - so we have to granularise at the OS level.
- */
- if (!ap_strcasecmp_match(path, p->apply_path)
- && !ap_strcasecmp_match(tt, ap)) {
- return 1;
- }
-#endif /* !CASE_BLIND_FILESYSTEM */
- }
- return 0;
-}
-
-/*****************************************************************
- *
- * Actually generating output
- */
-
-/*
- * Elements of the emitted document:
- * Preamble
- * Emitted unless SUPPRESS_PREAMBLE is set AND ap_run_sub_req
- * succeeds for the (content_type == text/html) header file.
- * Header file
- * Emitted if found (and able).
- * H1 tag line
- * Emitted if a header file is NOT emitted.
- * Directory stuff
- * Always emitted.
- * HR
- * Emitted if FANCY_INDEXING is set.
- * Readme file
- * Emitted if found (and able).
- * ServerSig
- * Emitted if ServerSignature is not Off AND a readme file
- * is NOT emitted.
- * Postamble
- * Emitted unless SUPPRESS_PREAMBLE is set AND ap_run_sub_req
- * succeeds for the (content_type == text/html) readme file.
- */
-
-
-/*
- * emit a plain text file
- */
-static void do_emit_plain(request_rec *r, ap_file_t *f)
-{
- char buf[IOBUFSIZE + 1];
- int i, c, ch;
- ap_ssize_t n;
- ap_status_t stat;
-
- ap_rputs("<PRE>\n", r);
- while (!ap_eof(f)) {
- do {
- n = sizeof(char) * IOBUFSIZE;
- stat = ap_read(f, buf, &n);
- }
- while (stat != APR_SUCCESS && stat == EINTR);
- if (n == -1 || n == 0) {
- break;
- }
- buf[n] = '\0';
- c = 0;
- while (c < n) {
- for (i = c; i < n; i++) {
- if (buf[i] == '<' || buf[i] == '>' || buf[i] == '&') {
- break;
- }
- }
- ch = buf[i];
- buf[i] = '\0';
- ap_rputs(&buf[c], r);
- if (ch == '<') {
- ap_rputs("&lt;", r);
- }
- else if (ch == '>') {
- ap_rputs("&gt;", r);
- }
- else if (ch == '&') {
- ap_rputs("&amp;", r);
- }
- c = i + 1;
- }
- }
- ap_rputs("</PRE>\n", r);
-}
-
-/*
- * Handle the preamble through the H1 tag line, inclusive. Locate
- * the file with a subrequests. Process text/html documents by actually
- * running the subrequest; text/xxx documents get copied verbatim,
- * and any other content type is ignored. This means that a non-text
- * document (such as HEADER.gif) might get multiviewed as the result
- * instead of a text document, meaning nothing will be displayed, but
- * oh well.
- */
-static void emit_head(request_rec *r, char *header_fname, int suppress_amble,
- char *title)
-{
- ap_file_t *f = NULL;
- request_rec *rr = NULL;
- int emit_amble = 1;
- int emit_H1 = 1;
-
- /*
- * If there's a header file, send a subrequest to look for it. If it's
- * found and a text file, handle it -- otherwise fall through and
- * pretend there's nothing there.
- */
- if ((header_fname != NULL)
- && (rr = ap_sub_req_lookup_uri(header_fname, r))
- && (rr->status == HTTP_OK)
- && (rr->filename != NULL)
- && rr->finfo.filetype == APR_REG) {
- /*
- * Check for the two specific cases we allow: text/html and
- * text/anything-else. The former is allowed to be processed for
- * SSIs.
- */
- if (rr->content_type != NULL) {
- if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type),
- "text/html")) {
- /* Hope everything will work... */
- emit_amble = 0;
- emit_H1 = 0;
-
- if (! suppress_amble) {
- emit_preamble(r, title);
- }
- /*
- * If there's a problem running the subrequest, display the
- * preamble if we didn't do it before -- the header file
- * didn't get displayed.
- */
- if (ap_run_sub_req(rr) != OK) {
- /* It didn't work */
- emit_amble = suppress_amble;
- emit_H1 = 1;
- }
- }
- else if (!strncasecmp("text/", rr->content_type, 5)) {
- /*
- * If we can open the file, prefix it with the preamble
- * regardless; since we'll be sending a <PRE> block around
- * the file's contents, any HTML header it had won't end up
- * where it belongs.
- */
- if (ap_open(&f, rr->filename, APR_READ | APR_BUFFERED,
- APR_OS_DEFAULT, r->pool) == APR_SUCCESS) {
- emit_preamble(r, title);
- emit_amble = 0;
- do_emit_plain(r, f);
- ap_close(f);
- emit_H1 = 0;
- }
- }
- }
- }
-
- if (emit_amble) {
- emit_preamble(r, title);
- }
- if (emit_H1) {
- ap_rvputs(r, "<H1>Index of ", title, "</H1>\n", NULL);
- }
- if (rr != NULL) {
- ap_destroy_sub_req(rr);
- }
-}
-
-
-/*
- * Handle the Readme file through the postamble, inclusive. Locate
- * the file with a subrequests. Process text/html documents by actually
- * running the subrequest; text/xxx documents get copied verbatim,
- * and any other content type is ignored. This means that a non-text
- * document (such as FOOTER.gif) might get multiviewed as the result
- * instead of a text document, meaning nothing will be displayed, but
- * oh well.
- */
-static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble)
-{
- ap_file_t *f = NULL;
- request_rec *rr = NULL;
- int suppress_post = 0;
- int suppress_sig = 0;
-
- /*
- * If there's a readme file, send a subrequest to look for it. If it's
- * found and a text file, handle it -- otherwise fall through and
- * pretend there's nothing there.
- */
- if ((readme_fname != NULL)
- && (rr = ap_sub_req_lookup_uri(readme_fname, r))
- && (rr->status == HTTP_OK)
- && (rr->filename != NULL)
- && rr->finfo.filetype == APR_REG) {
- /*
- * Check for the two specific cases we allow: text/html and
- * text/anything-else. The former is allowed to be processed for
- * SSIs.
- */
- if (rr->content_type != NULL) {
- if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type),
- "text/html")) {
- if (ap_run_sub_req(rr) == OK) {
- /* worked... */
- suppress_sig = 1;
- suppress_post = suppress_amble;
- }
- }
- else if (!strncasecmp("text/", rr->content_type, 5)) {
- /*
- * If we can open the file, suppress the signature.
- */
- if (ap_open(&f, rr->filename, APR_READ | APR_BUFFERED,
- APR_OS_DEFAULT, r->pool) == APR_SUCCESS) {
- do_emit_plain(r, f);
- ap_close(f);
- suppress_sig = 1;
- }
- }
- }
- }
-
- if (!suppress_sig) {
- ap_rputs(ap_psignature("", r), r);
- }
- if (!suppress_post) {
- ap_rputs("</BODY></HTML>\n", r);
- }
- if (rr != NULL) {
- ap_destroy_sub_req(rr);
- }
-}
-
-
-static char *find_title(request_rec *r)
-{
- char titlebuf[MAX_STRING_LEN], *find = "<TITLE>";
- ap_file_t *thefile = NULL;
- int x, y, p;
- ap_ssize_t n;
-
- if (r->status != HTTP_OK) {
- return NULL;
- }
- if ((r->content_type != NULL)
- && (!strcasecmp(ap_field_noparam(r->pool, r->content_type),
- "text/html")
- || !strcmp(r->content_type, INCLUDES_MAGIC_TYPE))
- && !r->content_encoding) {
- if (ap_open(&thefile, r->filename, APR_READ | APR_BUFFERED,
- APR_OS_DEFAULT, r->pool) != APR_SUCCESS) {
- return NULL;
- }
- n = sizeof(char) * (MAX_STRING_LEN - 1);
- ap_read(thefile, titlebuf, &n);
- if (n <= 0) {
- ap_close(thefile);
- return NULL;
- }
- titlebuf[n] = '\0';
- for (x = 0, p = 0; titlebuf[x]; x++) {
- if (ap_toupper(titlebuf[x]) == find[p]) {
- if (!find[++p]) {
- if ((p = ap_ind(&titlebuf[++x], '<')) != -1) {
- titlebuf[x + p] = '\0';
- }
- /* Scan for line breaks for Tanmoy's secretary */
- for (y = x; titlebuf[y]; y++) {
- if ((titlebuf[y] == CR) || (titlebuf[y] == LF)) {
- if (y == x) {
- x++;
- }
- else {
- titlebuf[y] = ' ';
- }
- }
- }
- ap_close(thefile);
- return ap_pstrdup(r->pool, &titlebuf[x]);
- }
- }
- else {
- p = 0;
- }
- }
- ap_close(thefile);
- }
- return NULL;
-}
-
-static struct ent *make_autoindex_entry(char *name, int autoindex_opts,
- autoindex_config_rec *d,
- request_rec *r, char keyid,
- char direction)
-{
- struct ent *p;
-
- if ((name[0] == '.') && (!name[1])) {
- return (NULL);
- }
-
- if (ignore_entry(d, ap_make_full_path(r->pool, r->filename, name))) {
- return (NULL);
- }
-
- p = (struct ent *) ap_pcalloc(r->pool, sizeof(struct ent));
- p->name = ap_pstrdup(r->pool, name);
- p->size = -1;
- p->icon = NULL;
- p->alt = NULL;
- p->desc = NULL;
- p->lm = -1;
- p->key = ap_toupper(keyid);
- p->ascending = (ap_toupper(direction) == D_ASCENDING);
-
- if (autoindex_opts & FANCY_INDEXING) {
- request_rec *rr = ap_sub_req_lookup_file(name, r);
-
- if (rr->finfo.protection != 0) {
- p->lm = rr->finfo.mtime;
- if (rr->finfo.filetype == APR_DIR) {
- if (!(p->icon = find_icon(d, rr, 1))) {
- p->icon = find_default_icon(d, "^^DIRECTORY^^");
- }
- if (!(p->alt = find_alt(d, rr, 1))) {
- p->alt = "DIR";
- }
- p->size = -1;
- p->name = ap_pstrcat(r->pool, name, "/", NULL);
- }
- else {
- p->icon = find_icon(d, rr, 0);
- p->alt = find_alt(d, rr, 0);
- p->size = rr->finfo.size;
- }
- }
-
- p->desc = find_desc(d, rr);
-
- if ((!p->desc) && (autoindex_opts & SCAN_HTML_TITLES)) {
- p->desc = ap_pstrdup(r->pool, find_title(rr));
- }
-
- ap_destroy_sub_req(rr);
- }
- /*
- * We don't need to take any special action for the file size key. If
- * we did, it would go here.
- */
- if (keyid == K_LAST_MOD) {
- if (p->lm < 0) {
- p->lm = 0;
- }
- }
- return (p);
-}
-
-static char *terminate_description(autoindex_config_rec *d, char *desc,
- int autoindex_opts)
-{
- int maxsize = 23;
- register int x;
-
- if (autoindex_opts & SUPPRESS_LAST_MOD) {
- maxsize += 19;
- }
- if (autoindex_opts & SUPPRESS_SIZE) {
- maxsize += 7;
- }
-
- for (x = 0; desc[x] && (maxsize > 0 || desc[x]=='<'); x++) {
- if (desc[x] == '<') {
- while (desc[x] != '>') {
- if (!desc[x]) {
- maxsize = 0;
- break;
- }
- ++x;
- }
- }
- else if (desc[x] == '&') {
- /* entities like &auml; count as one character */
- --maxsize;
- for ( ; desc[x] != ';'; ++x) {
- if (desc[x] == '\0') {
- maxsize = 0;
- break;
- }
- }
- }
- else {
- --maxsize;
- }
- }
- if (!maxsize && desc[x] != '\0') {
- desc[x - 1] = '>'; /* Grump. */
- desc[x] = '\0'; /* Double Grump! */
- }
- return desc;
-}
-
-/*
- * Emit the anchor for the specified field. If a field is the key for the
- * current request, the link changes its meaning to reverse the order when
- * selected again. Non-active fields always start in ascending order.
- */
-static void emit_link(request_rec *r, char *anchor, char fname, char curkey,
- char curdirection, int nosort)
-{
- char qvalue[5];
- int reverse;
-
- if (!nosort) {
- qvalue[0] = '?';
- qvalue[1] = fname;
- qvalue[2] = '=';
- qvalue[4] = '\0';
- reverse = ((curkey == fname) && (curdirection == D_ASCENDING));
- qvalue[3] = reverse ? D_DESCENDING : D_ASCENDING;
- ap_rvputs(r, "<A HREF=\"", qvalue, "\">", anchor, "</A>", NULL);
- }
- else {
- ap_rputs(anchor, r);
- }
-}
-
-static void output_directories(struct ent **ar, int n,
- autoindex_config_rec *d, request_rec *r,
- int autoindex_opts, char keyid, char direction)
-{
- int x;
- ap_size_t rv;
- char *name = r->uri;
- char *tp;
- int static_columns = (autoindex_opts & SUPPRESS_COLSORT);
- ap_context_t *scratch;
- int name_width;
- char *name_scratch;
- char *pad_scratch;
-
- ap_create_context(&scratch, r->pool);
- if (name[0] == '\0') {
- name = "/";
- }
-
- name_width = d->name_width;
- if (d->name_adjust == K_ADJUST) {
- for (x = 0; x < n; x++) {
- int t = strlen(ar[x]->name);
- if (t > name_width) {
- name_width = t;
- }
- }
- }
- name_scratch = ap_palloc(r->pool, name_width + 1);
- pad_scratch = ap_palloc(r->pool, name_width + 1);
- memset(pad_scratch, ' ', name_width);
- pad_scratch[name_width] = '\0';
-
- if (autoindex_opts & FANCY_INDEXING) {
- ap_rputs("<PRE>", r);
- if ((tp = find_default_icon(d, "^^BLANKICON^^"))) {
- ap_rvputs(r, "<IMG SRC=\"", ap_escape_html(scratch, tp),
- "\" ALT=\" \"", NULL);
- if (d->icon_width && d->icon_height) {
- ap_rprintf
- (
- r,
- " HEIGHT=\"%d\" WIDTH=\"%d\"",
- d->icon_height,
- d->icon_width
- );
- }
- ap_rputs("> ", r);
- }
- emit_link(r, "Name", K_NAME, keyid, direction, static_columns);
- ap_rputs(pad_scratch + 4, r);
- /*
- * Emit the guaranteed-at-least-one-space-between-columns byte.
- */
- ap_rputs(" ", r);
- if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
- emit_link(r, "Last modified", K_LAST_MOD, keyid, direction,
- static_columns);
- ap_rputs(" ", r);
- }
- if (!(autoindex_opts & SUPPRESS_SIZE)) {
- emit_link(r, "Size", K_SIZE, keyid, direction, static_columns);
- ap_rputs(" ", r);
- }
- if (!(autoindex_opts & SUPPRESS_DESC)) {
- emit_link(r, "Description", K_DESC, keyid, direction,
- static_columns);
- }
- ap_rputs("\n<HR>\n", r);
- }
- else {
- ap_rputs("<UL>", r);
- }
-
- for (x = 0; x < n; x++) {
- char *anchor, *t, *t2;
- int nwidth;
-
- ap_clear_pool(scratch);
-
- if (is_parent(ar[x]->name)) {
- t = ap_make_full_path(scratch, name, "../");
- ap_getparents(t);
- if (t[0] == '\0') {
- t = "/";
- }
- t2 = "Parent Directory";
- anchor = ap_escape_html(scratch, ap_os_escape_path(scratch, t, 0));
- }
- else {
- t = ar[x]->name;
- t2 = t;
- anchor = ap_escape_html(scratch, ap_os_escape_path(scratch, t, 0));
- }
-
- if (autoindex_opts & FANCY_INDEXING) {
- if (autoindex_opts & ICONS_ARE_LINKS) {
- ap_rvputs(r, "<A HREF=\"", anchor, "\">", NULL);
- }
- if ((ar[x]->icon) || d->default_icon) {
- ap_rvputs(r, "<IMG SRC=\"",
- ap_escape_html(scratch,
- ar[x]->icon ? ar[x]->icon
- : d->default_icon),
- "\" ALT=\"[", (ar[x]->alt ? ar[x]->alt : " "),
- "]\"", NULL);
- if (d->icon_width && d->icon_height) {
- ap_rprintf(r, " HEIGHT=\"%d\" WIDTH=\"%d\"",
- d->icon_height, d->icon_width);
- }
- ap_rputs(">", r);
- }
- if (autoindex_opts & ICONS_ARE_LINKS) {
- ap_rputs("</A>", r);
- }
-
- nwidth = strlen(t2);
- if (nwidth > name_width) {
- memcpy(name_scratch, t2, name_width - 3);
- name_scratch[name_width - 3] = '.';
- name_scratch[name_width - 2] = '.';
- name_scratch[name_width - 1] = '>';
- name_scratch[name_width] = 0;
- t2 = name_scratch;
- nwidth = name_width;
- }
- ap_rvputs(r, " <A HREF=\"", anchor, "\">",
- ap_escape_html(scratch, t2), "</A>", pad_scratch + nwidth,
- NULL);
- /*
- * The blank before the storm.. er, before the next field.
- */
- ap_rputs(" ", r);
- if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
- if (ar[x]->lm != -1) {
- char time_str[MAX_STRING_LEN];
- ap_exploded_time_t ts;
- ap_explode_localtime(&ts, ar[x]->lm);
- ap_strftime(time_str, &rv, MAX_STRING_LEN,
- "%d-%b-%Y %H:%M ", &ts);
- ap_rputs(time_str, r);
- }
- else {
- /*Length="22-Feb-1998 23:42 " (see 4 lines above) */
- ap_rputs(" ", r);
- }
- }
- if (!(autoindex_opts & SUPPRESS_SIZE)) {
- ap_send_size(ar[x]->size, r);
- ap_rputs(" ", r);
- }
- if (!(autoindex_opts & SUPPRESS_DESC)) {
- if (ar[x]->desc) {
- ap_rputs(terminate_description(d, ar[x]->desc,
- autoindex_opts), r);
- }
- }
- }
- else {
- ap_rvputs(r, "<LI><A HREF=\"", anchor, "\"> ", t2,
- "</A>", NULL);
- }
- ap_rputc('\n', r);
- }
- if (autoindex_opts & FANCY_INDEXING) {
- ap_rputs("</PRE>", r);
- }
- else {
- ap_rputs("</UL>", r);
- }
-}
-
-/*
- * Compare two file entries according to the sort criteria. The return
- * is essentially a signum function value.
- */
-
-static int dsortf(struct ent **e1, struct ent **e2)
-{
- struct ent *c1;
- struct ent *c2;
- int result = 0;
-
- /*
- * First, see if either of the entries is for the parent directory.
- * If so, that *always* sorts lower than anything else.
- */
- if (is_parent((*e1)->name)) {
- return -1;
- }
- if (is_parent((*e2)->name)) {
- return 1;
- }
- /*
- * All of our comparisons will be of the c1 entry against the c2 one,
- * so assign them appropriately to take care of the ordering.
- */
- if ((*e1)->ascending) {
- c1 = *e1;
- c2 = *e2;
- }
- else {
- c1 = *e2;
- c2 = *e1;
- }
- switch (c1->key) {
- case K_LAST_MOD:
- if (c1->lm > c2->lm) {
- return 1;
- }
- else if (c1->lm < c2->lm) {
- return -1;
- }
- break;
- case K_SIZE:
- if (c1->size > c2->size) {
- return 1;
- }
- else if (c1->size < c2->size) {
- return -1;
- }
- break;
- case K_DESC:
- result = strcmp(c1->desc ? c1->desc : "", c2->desc ? c2->desc : "");
- if (result) {
- return result;
- }
- break;
- }
- return strcmp(c1->name, c2->name);
-}
-
-
-static int index_directory(request_rec *r,
- autoindex_config_rec *autoindex_conf)
-{
- char *title_name = ap_escape_html(r->pool, r->uri);
- char *title_endp;
- char *name = r->filename;
-
- ap_dir_t *d;
- ap_status_t status;
- int num_ent = 0, x;
- struct ent *head, *p;
- struct ent **ar = NULL;
- const char *qstring;
- int autoindex_opts = autoindex_conf->opts;
- char keyid;
- char direction;
-
- if ((status = ap_opendir(&d, name, r->pool)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
- "Can't open directory for index: %s", r->filename);
- return HTTP_FORBIDDEN;
- }
-
- r->content_type = "text/html";
-
- ap_send_http_header(r);
-
- if (r->header_only) {
- ap_closedir(d);
- return 0;
- }
-
- /* Spew HTML preamble */
-
- title_endp = title_name + strlen(title_name) - 1;
-
- while (title_endp > title_name && *title_endp == '/') {
- *title_endp-- = '\0';
- }
-
- emit_head(r, find_header(autoindex_conf, r),
- autoindex_opts & SUPPRESS_PREAMBLE, title_name);
-
- /*
- * Figure out what sort of indexing (if any) we're supposed to use.
- *
- * If no QUERY_STRING was specified or column sorting has been
- * explicitly disabled, we use the default specified by the
- * IndexOrderDefault directive (if there is one); otherwise,
- * we fall back to ascending by name.
- */
- qstring = r->args;
- if ((autoindex_opts & SUPPRESS_COLSORT)
- || ((qstring == NULL) || (*qstring == '\0'))) {
- qstring = autoindex_conf->default_order;
- }
- /*
- * If there is no specific ordering defined for this directory,
- * default to ascending by filename.
- */
- if ((qstring == NULL) || (*qstring == '\0')) {
- keyid = K_NAME;
- direction = D_ASCENDING;
- }
- else {
- keyid = *qstring;
- ap_getword(r->pool, &qstring, '=');
- if (qstring != '\0') {
- direction = *qstring;
- }
- else {
- direction = D_ASCENDING;
- }
- }
-
- /*
- * Since we don't know how many dir. entries there are, put them into a
- * linked list and then arrayificate them so qsort can use them.
- */
- head = NULL;
- while (ap_readdir(d) == APR_SUCCESS) {
- char *d_name;
- ap_get_dir_filename(&d_name, d);
- p = make_autoindex_entry(d_name, autoindex_opts,
- autoindex_conf, r, keyid, direction);
- if (p != NULL) {
- p->next = head;
- head = p;
- num_ent++;
- }
- }
- if (num_ent > 0) {
- ar = (struct ent **) ap_palloc(r->pool,
- num_ent * sizeof(struct ent *));
- p = head;
- x = 0;
- while (p) {
- ar[x++] = p;
- p = p->next;
- }
-
- qsort((void *) ar, num_ent, sizeof(struct ent *),
- (int (*)(const void *, const void *)) dsortf);
- }
- output_directories(ar, num_ent, autoindex_conf, r, autoindex_opts, keyid,
- direction);
- ap_closedir(d);
-
- if (autoindex_opts & FANCY_INDEXING) {
- ap_rputs("<HR>\n", r);
- }
- emit_tail(r, find_readme(autoindex_conf, r),
- autoindex_opts & SUPPRESS_PREAMBLE);
-
- return 0;
-}
-
-/* The formal handler... */
-
-static int handle_autoindex(request_rec *r)
-{
- autoindex_config_rec *d;
- int allow_opts = ap_allow_options(r);
-
- d = (autoindex_config_rec *) ap_get_module_config(r->per_dir_config,
- &autoindex_module);
-
- r->allowed |= (1 << M_GET);
- if (r->method_number != M_GET) {
- return DECLINED;
- }
-
- /* OK, nothing easy. Trot out the heavy artillery... */
-
- if (allow_opts & OPT_INDEXES) {
- /* KLUDGE --- make the sub_req lookups happen in the right directory.
- * Fixing this in the sub_req_lookup functions themselves is difficult,
- * and would probably break virtual includes...
- */
-
- if (r->filename[strlen(r->filename) - 1] != '/') {
- r->filename = ap_pstrcat(r->pool, r->filename, "/", NULL);
- }
- return index_directory(r, d);
- }
- else {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Directory index forbidden by rule: %s", r->filename);
- return HTTP_FORBIDDEN;
- }
-}
-
-
-static const handler_rec autoindex_handlers[] =
-{
- {DIR_MAGIC_TYPE, handle_autoindex},
- {NULL}
-};
-
-module MODULE_VAR_EXPORT autoindex_module =
-{
- STANDARD20_MODULE_STUFF,
- create_autoindex_config, /* dir config creater */
- merge_autoindex_configs, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- autoindex_cmds, /* command ap_table_t */
- autoindex_handlers, /* handlers */
- NULL /* register hooks */
-};
diff --git a/modules/generators/mod_autoindex.exp b/modules/generators/mod_autoindex.exp
deleted file mode 100644
index 90f4057e9c..0000000000
--- a/modules/generators/mod_autoindex.exp
+++ /dev/null
@@ -1 +0,0 @@
-autoindex_module
diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c
deleted file mode 100644
index e96545cf77..0000000000
--- a/modules/generators/mod_cgi.c
+++ /dev/null
@@ -1,669 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_script: keeps all script-related ramblings together.
- *
- * Compliant to CGI/1.1 spec
- *
- * Adapted by rst from original NCSA code by Rob McCool
- *
- * Apache adds some new env vars; REDIRECT_URL and REDIRECT_QUERY_STRING for
- * custom error responses, and DOCUMENT_ROOT because we found it useful.
- * It also adds SERVER_ADMIN - useful for scripts to know who to mail when
- * they fail.
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "util_script.h"
-#include "http_conf_globals.h"
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-module MODULE_VAR_EXPORT cgi_module;
-
-/* KLUDGE --- for back-combatibility, we don't have to check ExecCGI
- * in ScriptAliased directories, which means we need to know if this
- * request came through ScriptAlias or not... so the Alias module
- * leaves a note for us.
- */
-
-static int is_scriptaliased(request_rec *r)
-{
- const char *t = ap_table_get(r->notes, "alias-forced-type");
- return t && (!strcasecmp(t, "cgi-script"));
-}
-
-/* Configuration stuff */
-
-#define DEFAULT_LOGBYTES 10385760
-#define DEFAULT_BUFBYTES 1024
-
-typedef struct {
- char *logname;
- long logbytes;
- int bufbytes;
-} cgi_server_conf;
-
-static void *create_cgi_config(ap_context_t *p, server_rec *s)
-{
- cgi_server_conf *c =
- (cgi_server_conf *) ap_pcalloc(p, sizeof(cgi_server_conf));
-
- c->logname = NULL;
- c->logbytes = DEFAULT_LOGBYTES;
- c->bufbytes = DEFAULT_BUFBYTES;
-
- return c;
-}
-
-static void *merge_cgi_config(ap_context_t *p, void *basev, void *overridesv)
-{
- cgi_server_conf *base = (cgi_server_conf *) basev, *overrides = (cgi_server_conf *) overridesv;
-
- return overrides->logname ? overrides : base;
-}
-
-static const char *set_scriptlog(cmd_parms *cmd, void *dummy, char *arg)
-{
- server_rec *s = cmd->server;
- cgi_server_conf *conf =
- (cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module);
-
- conf->logname = arg;
- return NULL;
-}
-
-static const char *set_scriptlog_length(cmd_parms *cmd, void *dummy, char *arg)
-{
- server_rec *s = cmd->server;
- cgi_server_conf *conf =
- (cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module);
-
- conf->logbytes = atol(arg);
- return NULL;
-}
-
-static const char *set_scriptlog_buffer(cmd_parms *cmd, void *dummy, char *arg)
-{
- server_rec *s = cmd->server;
- cgi_server_conf *conf =
- (cgi_server_conf *) ap_get_module_config(s->module_config, &cgi_module);
-
- conf->bufbytes = atoi(arg);
- return NULL;
-}
-
-static const command_rec cgi_cmds[] =
-{
- {"ScriptLog", set_scriptlog, NULL, RSRC_CONF, TAKE1,
- "the name of a log for script debugging info"},
- {"ScriptLogLength", set_scriptlog_length, NULL, RSRC_CONF, TAKE1,
- "the maximum length (in bytes) of the script debug log"},
- {"ScriptLogBuffer", set_scriptlog_buffer, NULL, RSRC_CONF, TAKE1,
- "the maximum size (in bytes) to record of a POST request"},
- {NULL}
-};
-
-static int log_scripterror(request_rec *r, cgi_server_conf * conf, int ret,
- int show_errno, char *error)
-{
- ap_file_t *f = NULL;
- struct stat finfo;
- char time_str[AP_CTIME_LEN];
-
- ap_log_rerror(APLOG_MARK, show_errno|APLOG_ERR, errno, r,
- "%s: %s", error, r->filename);
-
- if (!conf->logname ||
- ((stat(ap_server_root_relative(r->pool, conf->logname), &finfo) == 0)
- && (finfo.st_size > conf->logbytes)) ||
- (ap_open(&f, ap_server_root_relative(r->pool, conf->logname),
- APR_APPEND | APR_BUFFERED, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) {
- return ret;
- }
-
- /* "%% [Wed Jun 19 10:53:21 1996] GET /cgi-bin/printenv HTTP/1.0" */
- ap_ctime(time_str, ap_now());
- ap_fprintf(f, "%%%% [%s] %s %s%s%s %s\n", time_str, r->method, r->uri,
- r->args ? "?" : "", r->args ? r->args : "", r->protocol);
- /* "%% 500 /usr/local/apache/cgi-bin */
- ap_fprintf(f, "%%%% %d %s\n", ret, r->filename);
-
- ap_fprintf(f, "%%error\n%s\n", error);
-
- ap_close(f);
- return ret;
-}
-
-static int log_script(request_rec *r, cgi_server_conf * conf, int ret,
- char *dbuf, const char *sbuf, BUFF *script_in, BUFF *script_err)
-{
- ap_array_header_t *hdrs_arr = ap_table_elts(r->headers_in);
- ap_table_entry_t *hdrs = (ap_table_entry_t *) hdrs_arr->elts;
- char argsbuffer[HUGE_STRING_LEN];
- ap_file_t *f = NULL;
- int i;
- struct stat finfo;
- char time_str[AP_CTIME_LEN];
-
- if (!conf->logname ||
- ((stat(ap_server_root_relative(r->pool, conf->logname), &finfo) == 0)
- && (finfo.st_size > conf->logbytes)) ||
- (ap_open(&f, ap_server_root_relative(r->pool, conf->logname),
- APR_APPEND, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) {
- /* Soak up script output */
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0)
- continue;
-#ifdef WIN32
- /* Soak up stderr and redirect it to the error log.
- * Script output to stderr is already directed to the error log
- * on Unix, thanks to the magic of fork().
- */
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, r,
- "%s", argsbuffer);
- }
-#else
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0)
- continue;
-#endif
- return ret;
- }
-
- /* "%% [Wed Jun 19 10:53:21 1996] GET /cgi-bin/printenv HTTP/1.0" */
- ap_ctime(time_str, ap_now());
- ap_fprintf(f, "%%%% [%s] %s %s%s%s %s\n", time_str, r->method, r->uri,
- r->args ? "?" : "", r->args ? r->args : "", r->protocol);
- /* "%% 500 /usr/local/apache/cgi-bin" */
- ap_fprintf(f, "%%%% %d %s\n", ret, r->filename);
-
- ap_puts("%request\n", f);
- for (i = 0; i < hdrs_arr->nelts; ++i) {
- if (!hdrs[i].key)
- continue;
- ap_fprintf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
- }
- if ((r->method_number == M_POST || r->method_number == M_PUT)
- && *dbuf) {
- ap_fprintf(f, "\n%s\n", dbuf);
- }
-
- ap_puts("%response\n", f);
- hdrs_arr = ap_table_elts(r->err_headers_out);
- hdrs = (ap_table_entry_t *) hdrs_arr->elts;
-
- for (i = 0; i < hdrs_arr->nelts; ++i) {
- if (!hdrs[i].key)
- continue;
- ap_fprintf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
- }
-
- if (sbuf && *sbuf)
- ap_fprintf(f, "%s\n", sbuf);
-
- if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0) {
- ap_puts("%stdout\n", f);
- ap_puts(argsbuffer, f);
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0)
- ap_puts(argsbuffer, f);
- ap_puts("\n", f);
- }
-
- if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
- ap_puts("%stderr\n", f);
- ap_puts(argsbuffer, f);
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0)
- ap_puts(argsbuffer, f);
- ap_puts("\n", f);
- }
-
- ap_bclose(script_in);
- ap_bclose(script_err);
-
- ap_close(f);
- return ret;
-}
-static ap_status_t run_cgi_child(BUFF **script_out, BUFF **script_in, BUFF **script_err,
- char *command, char *const argv[], request_rec *r, ap_context_t *p)
-{
- char **env;
- ap_procattr_t *procattr;
- ap_proc_t *procnew;
- ap_status_t rc = APR_SUCCESS;
- ap_file_t *file = NULL;
- ap_iol *iol;
-
-#ifdef DEBUG_CGI
-#ifdef OS2
- /* Under OS/2 need to use device con. */
- FILE *dbg = fopen("con", "w");
-#else
- FILE *dbg = fopen("/dev/tty", "w");
-#endif
- int i;
-#endif
-
- ap_block_alarms();
-
- RAISE_SIGSTOP(CGI_CHILD);
-#ifdef DEBUG_CGI
- fprintf(dbg, "Attempting to exec %s as %sCGI child (argv0 = %s)\n",
- r->filename, cld->nph ? "NPH " : "", argv0);
-#endif
-
- ap_add_cgi_vars(r);
- env = ap_create_environment(p, r->subprocess_env);
-
-#ifdef DEBUG_CGI
- fprintf(dbg, "Environment: \n");
- for (i = 0; env[i]; ++i)
- fprintf(dbg, "'%s'\n", env[i]);
-#endif
-
- /* Transumute ourselves into the script.
- * NB only ISINDEX scripts get decoded arguments.
- */
- if (((rc = ap_createprocattr_init(&procattr, p)) != APR_SUCCESS) ||
- ((rc = ap_setprocattr_io(procattr,
- APR_FULL_BLOCK,
- APR_FULL_BLOCK,
- APR_FULL_BLOCK)) != APR_SUCCESS) ||
- ((rc = ap_setprocattr_dir(procattr,
- ap_make_dirstr_parent(r->pool, r->filename))) != APR_SUCCESS) ||
- ((rc = ap_setprocattr_cmdtype(procattr, APR_PROGRAM)) != APR_SUCCESS)) {
- /* Something bad happened, tell the world. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r,
- "couldn't create child process: %s", r->filename);
- }
- else {
- rc = ap_create_process(&procnew, command, argv, env, procattr, p);
-
- if (rc != APR_SUCCESS) {
- /* Bad things happened. Everyone should have cleaned up. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rc, r,
- "couldn't create child process: %d: %s", rc, r->filename);
- }
- else {
- ap_note_subprocess(p, procnew, kill_after_timeout);
-
- /* Fill in BUFF structure for parents pipe to child's stdout */
- ap_get_childout(&file, procnew);
- iol = ap_create_file_iol(file);
- if (!iol)
- return APR_EBADF;
- *script_in = ap_bcreate(p, B_RD);
- ap_bpush_iol(*script_in, iol);
-
- /* Fill in BUFF structure for parents pipe to child's stdin */
- ap_get_childin(&file, procnew);
- iol = ap_create_file_iol(file);
- if (!iol)
- return APR_EBADF;
- *script_out = ap_bcreate(p, B_WR);
- ap_bpush_iol(*script_out, iol);
-
- /* Fill in BUFF structure for parents pipe to child's stderr */
- ap_get_childerr(&file, procnew);
- iol = ap_create_file_iol(file);
- if (!iol)
- return APR_EBADF;
- *script_err = ap_bcreate(p, B_RD);
- ap_bpush_iol(*script_err, iol);
- }
- }
- ap_unblock_alarms();
- return (rc);
-}
-static ap_status_t build_argv_list(char ***argv, request_rec *r, ap_context_t *p)
-{
- int numwords, x, idx;
- char *w;
- const char *args = r->args;
-
- if (!args || !args[0] || strchr(args, '=')) {
- numwords = 1;
- }
- else {
- /* count the number of keywords */
- for (x = 0, numwords = 2; args[x]; x++) {
- if (args[x] == '+') {
- ++numwords;
- }
- }
- }
- /* Everything is - 1 to account for the first parameter which is the
- * program name. We didn't used to have to do this, but APR wants it.
- */
- if (numwords > APACHE_ARG_MAX - 1) {
- numwords = APACHE_ARG_MAX - 1; /* Truncate args to prevent overrun */
- }
- *argv = (char **) ap_palloc(p, (numwords + 2) * sizeof(char *));
-
- for (x = 1, idx = 1; x < numwords; x++) {
- w = ap_getword_nulls(p, &args, '+');
- ap_unescape_url(w);
- (*argv)[idx++] = ap_escape_shell_cmd(p, w);
- }
- (*argv)[idx] = NULL;
-
- return APR_SUCCESS;
-}
-
-static ap_status_t build_command_line(char **c, request_rec *r, ap_context_t *p)
-{
-#ifdef WIN32
- char *quoted_filename = NULL;
- char *interpreter = NULL;
- file_type_e fileType;
-
- *c = NULL;
- fileType = ap_get_win32_interpreter(r, &interpreter);
-
- if (fileType == eFileTypeUNKNOWN) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
- "%s is not executable; ensure interpreted scripts have "
- "\"#!\" first line",
- r->filename);
- return APR_EBADF;
- }
-
- /*
- * Build the command string to pass to ap_create_process()
- */
- quoted_filename = ap_pstrcat(p, "\"", r->filename, "\"", NULL);
- if (interpreter && *interpreter) {
- *c = ap_pstrcat(p, interpreter, " ", quoted_filename, " ", NULL);
- }
- else {
- *c = ap_pstrcat(p, quoted_filename, " ", NULL);
- }
-#else
- *c = ap_pstrcat(p, r->filename, NULL);
-#endif
- return APR_SUCCESS;
-}
-
-static int cgi_handler(request_rec *r)
-{
- int retval, nph, dbpos = 0;
- char *argv0, *dbuf = NULL;
- char *command;
- char **argv = NULL;
-
- BUFF *script_out = NULL, *script_in = NULL, *script_err = NULL;
- char argsbuffer[HUGE_STRING_LEN];
- int is_included = !strcmp(r->protocol, "INCLUDED");
- void *sconf = r->server->module_config;
- ap_context_t *p;
- cgi_server_conf *conf =
- (cgi_server_conf *) ap_get_module_config(sconf, &cgi_module);
-
- p = r->main ? r->main->pool : r->pool;
-
- if (r->method_number == M_OPTIONS) {
- /* 99 out of 100 CGI scripts, this is all they support */
- r->allowed |= (1 << M_GET);
- r->allowed |= (1 << M_POST);
- return DECLINED;
- }
-
- if ((argv0 = strrchr(r->filename, '/')) != NULL)
- argv0++;
- else
- argv0 = r->filename;
-
- nph = !(strncmp(argv0, "nph-", 4));
-
- if (!(ap_allow_options(r) & OPT_EXECCGI) && !is_scriptaliased(r))
- return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
- "Options ExecCGI is off in this directory");
- if (nph && is_included)
- return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
- "attempt to include NPH CGI script");
-
-#if defined(OS2) || defined(WIN32)
- /* Allow for cgi files without the .EXE extension on them under OS/2 */
- if (r->finfo.protection == 0) {
- struct stat statbuf;
- char *newfile;
-
- newfile = ap_pstrcat(r->pool, r->filename, ".EXE", NULL);
-
- if ((stat(newfile, &statbuf) != 0) || (!S_ISREG(statbuf.st_mode))) {
- return log_scripterror(r, conf, NOT_FOUND, 0,
- "script not found or unable to stat");
- } else {
- r->filename = newfile;
- }
- }
-#else
- if (r->finfo.protection == 0)
- return log_scripterror(r, conf, NOT_FOUND, APLOG_NOERRNO,
- "script not found or unable to stat");
-#endif
- if (r->finfo.filetype == APR_DIR)
- return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
- "attempt to invoke directory as script");
-
-/*
- if (!ap_suexec_enabled) {
- if (!ap_can_exec(&r->finfo))
- return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
- "file permissions deny server execution");
- }
-
-*/
- if ((retval = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
- return retval;
-
- ap_add_common_vars(r);
-
- /* build the command line */
- if (build_command_line(&command, r, p) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "couldn't spawn child process: %s", r->filename);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- /* build the argument list */
- else if (build_argv_list(&argv, r, p) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "couldn't spawn child process: %s", r->filename);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- argv[0] = ap_pstrdup(p, command);
- /* run the script in its own process */
- if (run_cgi_child(&script_out, &script_in, &script_err, command, argv, r, p) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "couldn't spawn child process: %s", r->filename);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- /* Transfer any put/post args, CERN style...
- * Note that we already ignore SIGPIPE in the core server.
- */
- if (ap_should_client_block(r)) {
- int dbsize, len_read;
- ap_ssize_t bytes_written;
-
- if (conf->logname) {
- dbuf = ap_pcalloc(r->pool, conf->bufbytes + 1);
- dbpos = 0;
- }
-
- while ((len_read =
- ap_get_client_block(r, argsbuffer, HUGE_STRING_LEN)) > 0) {
- if (conf->logname) {
- if ((dbpos + len_read) > conf->bufbytes) {
- dbsize = conf->bufbytes - dbpos;
- }
- else {
- dbsize = len_read;
- }
- memcpy(dbuf + dbpos, argsbuffer, dbsize);
- dbpos += dbsize;
- }
- (void) ap_bwrite(script_out, argsbuffer, len_read, &bytes_written);
- if (bytes_written < len_read) {
- /* silly script stopped reading, soak up remaining message */
- while (ap_get_client_block(r, argsbuffer, HUGE_STRING_LEN) > 0) {
- /* dump it */
- }
- break;
- }
- }
- ap_bflush(script_out);
- }
-
- ap_bclose(script_out);
-
- /* Handle script return... */
- if (script_in && !nph) {
- const char *location;
- char sbuf[MAX_STRING_LEN];
- int ret;
-
- if ((ret = ap_scan_script_header_err_buff(r, script_in, sbuf))) {
- return log_script(r, conf, ret, dbuf, sbuf, script_in, script_err);
- }
-
-#ifdef CHARSET_EBCDIC
- /* Now check the Content-Type to decide if conversion is needed */
- ap_checkconv(r);
-#endif /*CHARSET_EBCDIC*/
-
- location = ap_table_get(r->headers_out, "Location");
-
- if (location && location[0] == '/' && r->status == 200) {
-
- /* Soak up all the script output */
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0) {
- continue;
- }
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
- continue;
- }
- /* This redirect needs to be a GET no matter what the original
- * method was.
- */
- r->method = ap_pstrdup(r->pool, "GET");
- r->method_number = M_GET;
-
- /* We already read the message body (if any), so don't allow
- * the redirected request to think it has one. We can ignore
- * Transfer-Encoding, since we used REQUEST_CHUNKED_ERROR.
- */
- ap_table_unset(r->headers_in, "Content-Length");
-
- ap_internal_redirect_handler(location, r);
- return OK;
- }
- else if (location && r->status == 200) {
- /* XX Note that if a script wants to produce its own Redirect
- * body, it now has to explicitly *say* "Status: 302"
- */
- return REDIRECT;
- }
-
- ap_send_http_header(r);
- if (!r->header_only) {
- ap_send_fb(script_in, r);
- }
- ap_bclose(script_in);
-
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
- continue;
- }
- ap_bclose(script_err);
- }
-
- if (script_in && nph) {
- ap_send_fb(script_in, r);
- }
-
- return OK; /* NOT r->status, even if it has changed. */
-}
-
-static const handler_rec cgi_handlers[] =
-{
- {CGI_MAGIC_TYPE, cgi_handler},
- {"cgi-script", cgi_handler},
- {NULL}
-};
-
-module MODULE_VAR_EXPORT cgi_module =
-{
- STANDARD20_MODULE_STUFF,
- NULL, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- create_cgi_config, /* server config */
- merge_cgi_config, /* merge server config */
- cgi_cmds, /* command ap_table_t */
- cgi_handlers, /* handlers */
- NULL /* register hooks */
-};
diff --git a/modules/generators/mod_cgi.exp b/modules/generators/mod_cgi.exp
deleted file mode 100644
index 96ea0c2348..0000000000
--- a/modules/generators/mod_cgi.exp
+++ /dev/null
@@ -1 +0,0 @@
-cgi_module
diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c
deleted file mode 100644
index 8ea591d87e..0000000000
--- a/modules/generators/mod_cgid.c
+++ /dev/null
@@ -1,1010 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_script: keeps all script-related ramblings together.
- *
- * Compliant to cgi/1.1 spec
- *
- * Adapted by rst from original NCSA code by Rob McCool
- *
- * Apache adds some new env vars; REDIRECT_URL and REDIRECT_QUERY_STRING for
- * custom error responses, and DOCUMENT_ROOT because we found it useful.
- * It also adds SERVER_ADMIN - useful for scripts to know who to mail when
- * they fail.
- */
-
-
-
-#define CORE_PRIVATE
-
-#include "apr_lib.h"
-#include "apr_general.h"
-#include "apr_file_io.h"
-#include "apr_portable.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "util_script.h"
-#include "http_conf_globals.h"
-#include "buff.h"
-#include "ap_mpm.h"
-#include "iol_socket.h"
-
-#ifndef UNIX_PATH_MAX
-#define UNIX_PATH_MAX 108
-#endif
-
-#ifndef sockaddr_un
-struct sockaddr_un {
- unsigned short sun_family;
- char sun_path[UNIX_PATH_MAX];
-};
-#endif
-
-
-module MODULE_VAR_EXPORT cgid_module;
-
-static void cgid_init(ap_context_t *p, ap_context_t *plog, ap_context_t *ptemp, server_rec *main_server);
-static int once_through = 0;
-
-static ap_context_t *pcgi;
-
-/* KLUDGE --- for back-combatibility, we don't have to check Execcgid
- * in ScriptAliased directories, which means we need to know if this
- * request came through ScriptAlias or not... so the Alias module
- * leaves a note for us.
- */
-
-static int is_scriptaliased(request_rec *r)
-{
- const char *t = ap_table_get(r->notes, "alias-forced-type");
- return t && (!strcasecmp(t, "cgi-script"));
-}
-
-/* Configuration stuff */
-
-#define DEFAULT_LOGBYTES 10385760
-#define DEFAULT_BUFBYTES 1024
-#define DEFAULT_SOCKET "logs/cgisock"
-
-typedef struct {
- const char *sockname;
- char *logname;
- long logbytes;
- int bufbytes;
- BUFF *bin;
- BUFF *bout;
- BUFF *berror;
-} cgid_server_conf;
-
-/* If a request includes query info in the URL (stuff after "?"), and
- * the query info does not contain "=" (indicative of a FORM submission),
- * then this routine is called to create the argument list to be passed
- * to the CGI script. When suexec is enabled, the suexec path, user, and
- * group are the first three arguments to be passed; if not, all three
- * must be NULL. The query info is split into separate arguments, where
- * "+" is the separator between keyword arguments.
- *
- * XXXX: note that the WIN32 code uses one of the suexec strings
- * to pass an interpreter name. Remember this if changing the way they
- * are handled in create_argv.
- *
- */
-static char **create_argv(ap_context_t *p, char *path, char *user, char *group,
- char *av0, const char *args)
-{
- int x, numwords;
- char **av;
- char *w;
- int idx = 0;
-
- /* count the number of keywords */
-
- for (x = 0, numwords = 1; args[x]; x++) {
- if (args[x] == '+') {
- ++numwords;
- }
- }
-
- if (numwords > APACHE_ARG_MAX - 5) {
- numwords = APACHE_ARG_MAX - 5; /* Truncate args to prevent overrun */
- }
- av = (char **) ap_palloc(p, (numwords + 5) * sizeof(char *));
-
- if (path) {
- av[idx++] = path;
- }
- if (user) {
- av[idx++] = user;
- }
- if (group) {
- av[idx++] = group;
- }
-
- av[idx++] = av0;
-
- for (x = 1; x <= numwords; x++) {
- w = ap_getword_nulls(p, &args, '+');
- ap_unescape_url(w);
- av[idx++] = ap_escape_shell_cmd(p, w);
- }
- av[idx] = NULL;
- return av;
-}
-
-static int call_exec(request_rec *r, char *argv0, char **env, int shellcmd)
-{
- int pid = 0;
- int errfileno = STDERR_FILENO;
-
- /* the fd on r->server->error_log is closed, but we need somewhere to * put the error messages from the log_* functions. So, we use stderr,
- * since that is better than allowing errors to go unnoticed.
- */
- ap_put_os_file(&r->server->error_log, &errfileno, r->pool);
- /* TODO: reimplement suexec */
-#if 0
- if (ap_suexec_enabled
- && ((r->server->server_uid != ap_user_id)
- || (r->server->server_gid != ap_group_id)
- || (!strncmp("/~", r->uri, 2)))) {
-
- char *execuser, *grpname;
- struct passwd *pw;
- struct group *gr;
-
- if (!strncmp("/~", r->uri, 2)) {
- gid_t user_gid;
- char *username = ap_pstrdup(r->pool, r->uri + 2);
- char *pos = strchr(username, '/');
-
- if (pos) {
- *pos = '\0';
- }
-
- if ((pw = getpwnam(username)) == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "getpwnam: invalid username %s", username);
- return (pid);
- }
- execuser = ap_pstrcat(r->pool, "~", pw->pw_name, NULL);
- user_gid = pw->pw_gid;
-
- if ((gr = getgrgid(user_gid)) == NULL) {
- if ((grpname = ap_palloc(r->pool, 16)) == NULL) {
- return (pid);
- }
- else {
- ap_snprintf(grpname, 16, "%ld", (long) user_gid);
- }
- }
- else {
- grpname = gr->gr_name;
- }
- }
- else {
- if ((pw = getpwuid(r->server->server_uid)) == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "getpwuid: invalid userid %ld",
- (long) r->server->server_uid);
- return (pid);
- }
- execuser = ap_pstrdup(r->pool, pw->pw_name);
-
- if ((gr = getgrgid(r->server->server_gid)) == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "getgrgid: invalid groupid %ld",
- (long) r->server->server_gid);
- return (pid);
- }
- grpname = gr->gr_name;
- }
-
- if (shellcmd) {
- execle(SUEXEC_BIN, SUEXEC_BIN, execuser, grpname, argv0,
- NULL, env);
- }
-
- else if ((!r->args) || (!r->args[0]) || strchr(r->args, '=')) {
- execle(SUEXEC_BIN, SUEXEC_BIN, execuser, grpname, argv0,
- NULL, env);
- }
-
- else {
- execve(SUEXEC_BIN,
- create_argv(r->pool, SUEXEC_BIN, execuser, grpname,
- argv0, r->args),
- env);
- }
- }
- else {
-#endif
- if (shellcmd) {
- execle(SHELL_PATH, SHELL_PATH, "-c", argv0, NULL, env);
- }
-
- else if ((!r->args) || (!r->args[0]) || strchr(r->args, '=')) {
- execle(r->filename, argv0, NULL, env);
- }
-
- else {
- execve(r->filename,
- create_argv(r->pool, NULL, NULL, NULL, argv0, r->args),
- env);
- }
-#if 0
- }
-#endif
- return (pid);
-}
-
-static void cgid_maint(int reason, void *data, ap_wait_t status)
-{
-#ifdef HAS_OTHER_CHILD
- int *sd = data;
- switch (reason) {
- case OC_REASON_DEATH:
- case OC_REASON_LOST:
- /* stop gap to make sure everything else works. In the end,
- * we'll just restart the cgid server. */
- kill(getppid(), SIGWINCH);
- break;
- case OC_REASON_RESTART:
- case OC_REASON_UNREGISTER:
- kill(*sd, SIGHUP);
- break;
- }
-#endif
-}
-
-static void get_req(int fd, request_rec *r, char **filename, char **argv0, char ***env)
-{
- int i, len, j;
- unsigned char *data;
- char **environ;
- char temp[MAX_STRING_LEN];
- core_dir_config *temp_core;
- void **dconf;
-
- r->server = ap_pcalloc(r->pool, sizeof(server_rec));
-
- read(fd, &j, sizeof(int));
- read(fd, &len, sizeof(int));
- data = ap_pcalloc(r->pool, len);
- i = read(fd, data, len);
-
- r->filename = ap_getword(r->pool, (const char **)&data, '\n');
- *argv0 = ap_getword(r->pool, (const char **)&data, '\n');
-
- r->uri = ap_getword(r->pool, (const char **)&data, '\n');
-
- environ = ap_pcalloc(r->pool, (j + 2) *sizeof(char *));
- i = 0;
- for (i = 0; i < j; i++) {
- environ[i] = ap_getword(r->pool, (const char **)&data, '\n');
- }
- *env = environ;
- r->args = ap_getword(r->pool, (const char **)&data, '\n');
-
- read(fd, &r->server->server_uid, sizeof(uid_t));
- read(fd, &r->server->server_gid, sizeof(gid_t));
-
- read(fd, &i, sizeof(int));
-
- /* add 1, so that if i == 0, we still malloc something. */
- dconf = (void **)malloc(sizeof(void *) * i + 1);
-
- temp_core = (core_dir_config *)malloc(sizeof(core_module));
-#if 0
-#ifdef RLIMIT_CPU
- read(fd, &j, sizeof(int));
- if (j) {
- temp_core->limit_cpu = (struct rlimit *)malloc (sizeof(struct rlimit));
- read(fd, temp_core->limit_cpu, sizeof(struct rlimit));
- }
- else {
- temp_core->limit_cpu = NULL;
- }
-#endif
-
-#if defined (RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
- read(fd, &j, sizeof(int));
- if (j) {
- temp_core->limit_mem = (struct rlimit *)malloc (sizeof(struct rlimit));
- read(fd, temp_core->limit_mem, sizeof(struct rlimit));
- }
- else {
- temp_core->limit_mem = NULL;
- }
-#endif
-
-#ifdef RLIMIT_NPROC
- read(fd, &j, sizeof(int));
- if (j) {
- temp_core->limit_nproc = (struct rlimit *)malloc (sizeof(struct rlimit));
- read(fd, temp_core->limit_nproc, sizeof(struct rlimit));
- }
- else {
- temp_core->limit_nproc = NULL;
- }
-#endif
-#endif
- dconf[i] = (void *)temp_core;
- r->per_dir_config = dconf;
-}
-
-
-
-static void send_req(int fd, request_rec *r, char *argv0, char **env)
-{
- int len;
- int rv;
- int i = 0;
- char *data;
- core_dir_config *conf = ap_get_module_config(r->per_dir_config,
- &core_module);
-
- data = ap_pstrcat(r->pool, r->filename, "\n", argv0, "\n", r->uri, "\n",
- NULL);
-
- for (i =0; env[i]; i++) {
- continue;
- }
-
- if (write(fd, &i, sizeof(int)) < 0) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "write to cgi daemon process");
- }
-
- for (i = 0; env[i]; i++) {
- data = ap_pstrcat(r->pool, data, env[i], "\n", NULL);
- }
- data = ap_pstrcat(r->pool, data, r->args, NULL);
- len = strlen(data);
- if (write(fd, &len, sizeof(int)) < 0) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "write to cgi daemon process");
- }
- if (write(fd, data, len) < 0) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "write to cgi daemon process");
- }
- if (write(fd, &r->server->server_uid, sizeof(uid_t)) < 0) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "write to cgi daemon process");
- }
- if (write(fd, &r->server->server_gid, sizeof(gid_t)) < 0) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "write to cgi daemon process");
- }
- if (write(fd, &core_module.module_index, sizeof(int)) < 0) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "write to cgi daemon process");
- }
-#if 0
-#ifdef RLIMIT_CPU
- if (conf->limit_cpu) {
- len = 1;
- write(fd, &len, sizeof(int));
- write(fd, conf->limit_cpu, sizeof(struct rlimit));
- }
- else {
- len = 0;
- write(fd, &len, sizeof(int));
- }
-#endif
-
-#if defined(RLIMIT_DATA) || defined(RLIMIT_VMEM) || defined(RLIMIT_AS)
- if (conf->limit_mem) {
- len = 1;
- write(fd, &len, sizeof(int));
- write(fd, conf->limit_mem, sizeof(struct rlimit));
- }
- else {
- len = 0;
- write(fd, &len, sizeof(int));
- }
-#endif
-
-#ifdef RLIMIT_NPROC
- if (conf->limit_nproc) {
- len = 1;
- write(fd, &len, sizeof(int));
- write(fd, conf->limit_nproc, sizeof(struct rlimit));
- }
- else {
- len = 0;
- write(fd, &len, sizeof(int));
- }
-#endif
-#endif
-}
-
-static int cgid_server_child(int sd)
-{
- char *argv0;
- char *filename;
- char **env;
- ap_context_t *p;
- request_rec *r;
-
- ap_create_context(&p, pcgi);
- r = ap_pcalloc(p, sizeof(request_rec));
- r->pool = p;
- dup2(sd, STDIN_FILENO);
- dup2(sd, STDOUT_FILENO);
- get_req(sd, r, &filename, &argv0, &env);
- call_exec(r, argv0, env, 0);
- exit(-1); /* We should NEVER get here */
-}
-
-static int cgid_server(void *data)
-{
- struct sockaddr_un unix_addr;
- int pid;
- int sd, sd2, len;
- int errfile;
- server_rec *main_server = data;
- cgid_server_conf *sconf = (cgid_server_conf *)ap_get_module_config(
- main_server->module_config, &cgid_module);
-
- signal(SIGCHLD, SIG_IGN);
- unlink(sconf->sockname);
-
- if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server,
- "Couldn't create unix domain socket");
- }
-
- memset(&unix_addr, 0, sizeof(unix_addr));
- unix_addr.sun_family = AF_UNIX;
- strcpy(unix_addr.sun_path, sconf->sockname);
-
- if (bind(sd, (struct sockaddr *)&unix_addr, sizeof(unix_addr)) < 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server,
- "Couldn't bind unix domain socket");
- }
- /* Most implementations silently enforce a value of 5 anyway.
- * This way, it'll work the same everywhere. */
- if (listen(sd, 5) < 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server,
- "Couldn't listen on unix domain socket");
- }
-
- while (1) {
- sd2 = accept(sd, (struct sockaddr *)&unix_addr, &len);
- if (sd2 < 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, (server_rec *)data,
- "Error accepting on cgid socket.");
- continue;
- }
-
- if ((pid = fork()) > 0) {
- close(sd2);
- }
- else if (pid == 0) {
- /* setup the STDERR here, because I have all the info
- * for it. I'll do the STDIN and STDOUT later, but I can't
- * do STDERR as easily.
- */
- if (sconf->logname) {
- dup2(open(sconf->logname, O_WRONLY), STDERR_FILENO);
- }
- else {
- ap_get_os_file(&errfile, main_server->error_log);
- dup2(errfile, STDERR_FILENO);
- }
- cgid_server_child(sd2);
- }
- else {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, (server_rec *)data,
- "Couldn't fork cgi script");
- }
- }
- return -1;
-}
-
-static void cgid_init(ap_context_t *p, ap_context_t *plog, ap_context_t *ptemp, server_rec *main_server)
-{
- int pid;
- int tempfd;
-
- cgid_server_conf *sconf = (cgid_server_conf *)ap_get_module_config(
- main_server->module_config, &cgid_module);
-
- if (once_through > 0) {
- ap_create_context(&pcgi, p);
- tempfd = creat(sconf->sockname, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
- close(tempfd);
-
- if ((pid = fork()) < 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, main_server,
- "Couldn't spawn cgid daemon process");
- }
- else if (pid == 0) {
- cgid_server(main_server);
- exit(-1);
- }
-#ifdef HAS_OTHER_CHILD
- ap_register_other_child(pid, cgid_maint, &pid, -1);
-#endif
- }
- else once_through++;
-}
-
-static void *create_cgid_config(ap_context_t *p, server_rec *s)
-{
- cgid_server_conf *c =
- (cgid_server_conf *) ap_pcalloc(p, sizeof(cgid_server_conf));
-
- c->logname = NULL;
- c->logbytes = DEFAULT_LOGBYTES;
- c->bufbytes = DEFAULT_BUFBYTES;
- c->sockname = ap_server_root_relative(p, DEFAULT_SOCKET);
- c->bin = c->bout = c->berror = NULL;
- return c;
-}
-
-static void *merge_cgid_config(ap_context_t *p, void *basev, void *overridesv)
-{
- cgid_server_conf *base = (cgid_server_conf *) basev, *overrides = (cgid_server_conf *) overridesv;
-
- return overrides->logname ? overrides : base;
-}
-
-static const char *set_scriptlog(cmd_parms *cmd, void *dummy, char *arg)
-{
- server_rec *s = cmd->server;
- cgid_server_conf *conf =
- (cgid_server_conf *) ap_get_module_config(s->module_config, &cgid_module);
-
- conf->logname = arg;
- return NULL;
-}
-
-static const char *set_scriptlog_length(cmd_parms *cmd, void *dummy, char *arg)
-{
- server_rec *s = cmd->server;
- cgid_server_conf *conf =
- (cgid_server_conf *) ap_get_module_config(s->module_config, &cgid_module);
-
- conf->logbytes = atol(arg);
- return NULL;
-}
-
-static const char *set_scriptlog_buffer(cmd_parms *cmd, void *dummy, char *arg)
-{
- server_rec *s = cmd->server;
- cgid_server_conf *conf =
- (cgid_server_conf *) ap_get_module_config(s->module_config, &cgid_module);
-
- conf->bufbytes = atoi(arg);
- return NULL;
-}
-
-static const char *set_script_socket(cmd_parms *cmd, void *dummy, char *arg)
-{
- server_rec *s = cmd->server;
- cgid_server_conf *conf =
- (cgid_server_conf *) ap_get_module_config(s->module_config, &cgid_module);
-
- conf->sockname = ap_server_root_relative(cmd->pool, arg);
- return NULL;
-}
-
-static const command_rec cgid_cmds[] =
-{
- {"ScriptLog", set_scriptlog, NULL, RSRC_CONF, TAKE1,
- "the name of a log for script debugging info"},
- {"ScriptLogLength", set_scriptlog_length, NULL, RSRC_CONF, TAKE1,
- "the maximum length (in bytes) of the script debug log"},
- {"ScriptLogBuffer", set_scriptlog_buffer, NULL, RSRC_CONF, TAKE1,
- "the maximum size (in bytes) to record of a POST request"},
- {"Scriptsock", set_script_socket, NULL, RSRC_CONF, TAKE1,
- "the name of the socket to use for communication with the cgi daemon."},
- {NULL}
-};
-
-static int log_scripterror(request_rec *r, cgid_server_conf * conf, int ret,
- int show_errno, char *error)
-{
- ap_file_t *f = NULL;
- struct stat finfo;
- char time_str[AP_CTIME_LEN];
-
- ap_log_rerror(APLOG_MARK, show_errno|APLOG_ERR, errno, r,
- "%s: %s", error, r->filename);
-
- if (!conf->logname ||
- ((stat(ap_server_root_relative(r->pool, conf->logname), &finfo) == 0)
- && (finfo.st_size > conf->logbytes)) ||
- (ap_open(&f, ap_server_root_relative(r->pool, conf->logname),
- APR_APPEND, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) {
- return ret;
- }
-
- /* "%% [Wed Jun 19 10:53:21 1996] GET /cgid-bin/printenv HTTP/1.0" */
- ap_ctime(time_str, ap_now());
- ap_fprintf(f, "%%%% [%s] %s %s%s%s %s\n", time_str, r->method, r->uri,
- r->args ? "?" : "", r->args ? r->args : "", r->protocol);
- /* "%% 500 /usr/local/apache/cgid-bin */
- ap_fprintf(f, "%%%% %d %s\n", ret, r->filename);
-
- ap_fprintf(f, "%%error\n%s\n", error);
-
- ap_close(f);
- return ret;
-}
-
-static int log_script(request_rec *r, cgid_server_conf * conf, int ret,
- char *dbuf, const char *sbuf, BUFF *script_in, BUFF *script_err)
-{
- ap_array_header_t *hdrs_arr = ap_table_elts(r->headers_in);
- ap_table_entry_t *hdrs = (ap_table_entry_t *) hdrs_arr->elts;
- char argsbuffer[HUGE_STRING_LEN];
- ap_file_t *f = NULL;
- int i;
- struct stat finfo;
- char time_str[AP_CTIME_LEN];
-
- if (!conf->logname ||
- ((stat(ap_server_root_relative(r->pool, conf->logname), &finfo) == 0)
- && (finfo.st_size > conf->logbytes)) ||
- (ap_open(&f, ap_server_root_relative(r->pool, conf->logname),
- APR_APPEND, APR_OS_DEFAULT, r->pool) != APR_SUCCESS)) {
- /* Soak up script output */
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0)
- continue;
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0)
- continue;
- return ret;
- }
-
- /* "%% [Wed Jun 19 10:53:21 1996] GET /cgid-bin/printenv HTTP/1.0" */
- ap_ctime(time_str, ap_now());
- ap_fprintf(f, "%%%% [%s] %s %s%s%s %s\n", time_str, r->method, r->uri,
- r->args ? "?" : "", r->args ? r->args : "", r->protocol);
- /* "%% 500 /usr/local/apache/cgid-bin" */
- ap_fprintf(f, "%%%% %d %s\n", ret, r->filename);
-
- ap_puts("%request\n", f);
- for (i = 0; i < hdrs_arr->nelts; ++i) {
- if (!hdrs[i].key)
- continue;
- ap_fprintf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
- }
- if ((r->method_number == M_POST || r->method_number == M_PUT)
- && *dbuf) {
- ap_fprintf(f, "\n%s\n", dbuf);
- }
-
- ap_puts("%response\n", f);
- hdrs_arr = ap_table_elts(r->err_headers_out);
- hdrs = (ap_table_entry_t *) hdrs_arr->elts;
-
- for (i = 0; i < hdrs_arr->nelts; ++i) {
- if (!hdrs[i].key)
- continue;
- ap_fprintf(f, "%s: %s\n", hdrs[i].key, hdrs[i].val);
- }
-
- if (sbuf && *sbuf)
- ap_fprintf(f, "%s\n", sbuf);
-
- if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0) {
- ap_puts("%stdout\n", f);
- ap_puts(argsbuffer, f);
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0)
- ap_puts(argsbuffer, f);
- ap_puts("\n", f);
- }
-
- if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
- ap_puts("%stderr\n", f);
- ap_puts(argsbuffer, f);
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0)
- ap_puts(argsbuffer, f);
- ap_puts("\n", f);
- }
-
- ap_bclose(script_in);
- ap_bclose(script_err);
-
- ap_close(f);
- return ret;
-}
-
-
-
-/****************************************************************
- *
- * Actual cgid handling...
- */
-static int cgid_handler(request_rec *r)
-{
- int retval, nph, dbpos = 0;
- char *argv0, *dbuf = NULL;
- BUFF *script = NULL;
- char argsbuffer[HUGE_STRING_LEN];
- void *sconf = r->server->module_config;
- cgid_server_conf *conf = (cgid_server_conf *) ap_get_module_config(sconf, &cgid_module);
- int is_included = !strcmp(r->protocol, "INCLUDED");
- int sd;
- char **env;
- struct sockaddr_un unix_addr;
- ap_socket_t *tempsock = NULL;
- int nbytes;
- ap_iol *iol;
- script = ap_bcreate(r->pool, B_RDWR);
-
- if (r->method_number == M_OPTIONS) {
- /* 99 out of 100 cgid scripts, this is all they support */
- r->allowed |= (1 << M_GET);
- r->allowed |= (1 << M_POST);
- return DECLINED;
- }
-
- if ((argv0 = strrchr(r->filename, '/')) != NULL)
- argv0++;
- else
- argv0 = r->filename;
-
- nph = !(strncmp(argv0, "nph-", 4));
-
- if ((argv0 = strrchr(r->filename, '/')) != NULL)
- argv0++;
- else
- argv0 = r->filename;
-
- if (!(ap_allow_options(r) & OPT_EXECCGI) && !is_scriptaliased(r))
- return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
- "Options ExecCGI is off in this directory");
- if (nph && is_included)
- return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
- "attempt to include NPH CGI script");
-
-#if defined(OS2) || defined(WIN32)
- /* Allow for cgid files without the .EXE extension on them under OS/2 */
- if (r->finfo.st_mode == 0) {
- struct stat statbuf;
- char *newfile;
-
- newfile = ap_pstrcat(r->pool, r->filename, ".EXE", NULL);
-
- if ((stat(newfile, &statbuf) != 0) || (!S_ISREG(statbuf.st_mode))) {
- return log_scripterror(r, conf, NOT_FOUND, 0,
- "script not found or unable to stat");
- } else {
- r->filename = newfile;
- }
- }
-#else
- if (r->finfo.st_mode == 0)
- return log_scripterror(r, conf, NOT_FOUND, APLOG_NOERRNO,
- "script not found or unable to stat");
-#endif
- if (S_ISDIR(r->finfo.st_mode))
- return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
- "attempt to invoke directory as script");
-/*
- if (!ap_suexec_enabled) {
- if (!ap_can_exec(&r->finfo))
- return log_scripterror(r, conf, FORBIDDEN, APLOG_NOERRNO,
- "file permissions deny server execution");
- }
-*/
- ap_add_common_vars(r);
- ap_add_cgi_vars(r);
- env = ap_create_environment(r->pool, r->subprocess_env);
-
- if ((sd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
- return log_scripterror(r, conf, NOT_FOUND, 0,
- "unable to create socket to cgi daemon");
- }
- memset(&unix_addr, 0, sizeof(unix_addr));
- unix_addr.sun_family = AF_UNIX;
- strcpy(unix_addr.sun_path, conf->sockname);
-
- if (connect(sd, (struct sockaddr *)&unix_addr, sizeof(unix_addr)) < 0) {
- return log_scripterror(r, conf, NOT_FOUND, 0,
- "unable to connect to cgi daemon");
- }
-
- send_req(sd, r, argv0, env);
-
- ap_put_os_sock(&tempsock, &sd, pcgi);
-
- iol = unix_attach_socket(tempsock);
-
- ap_bpush_iol(script, iol);
-
- if ((retval = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
- return retval;
-
- if ((argv0 = strrchr(r->filename, '/')) != NULL)
- argv0++;
- else
- argv0 = r->filename;
-
- /* Transfer any put/post args, CERN style...
- * Note that we already ignore SIGPIPE in the core server.
- */
-
- if (ap_should_client_block(r)) {
- int dbsize, len_read;
-
- if (conf->logname) {
- dbuf = ap_pcalloc(r->pool, conf->bufbytes + 1);
- dbpos = 0;
- }
-
-
-
- while ((len_read =
- ap_get_client_block(r, argsbuffer, HUGE_STRING_LEN)) > 0) {
- if (conf->logname) {
- if ((dbpos + len_read) > conf->bufbytes) {
- dbsize = conf->bufbytes - dbpos;
- }
- else {
- dbsize = len_read;
- }
- memcpy(dbuf + dbpos, argsbuffer, dbsize);
- dbpos += dbsize;
- }
- ap_bwrite(script, argsbuffer, len_read, &nbytes);
- if (nbytes < len_read) {
- /* silly script stopped reading, soak up remaining message */
- while (ap_get_client_block(r, argsbuffer, HUGE_STRING_LEN) > 0) {
- /* dump it */
- }
- break;
- }
- }
-
- ap_bflush(script);
-
- }
-
- /* Handle script return... */
- if (script && !nph) {
- const char *location;
- char sbuf[MAX_STRING_LEN];
- int ret;
-
- if ((ret = ap_scan_script_header_err_buff(r, script, sbuf))) {
- return log_script(r, conf, ret, dbuf, sbuf, script, NULL);
- }
-
-#ifdef CHARSET_EBCDIC
- /* Now check the Content-Type to decide if conversion is needed */
- ap_checkconv(r);
-#endif /*CHARSET_EBCDIC*/
-
- location = ap_table_get(r->headers_out, "Location");
-
- if (location && location[0] == '/' && r->status == 200) {
-
- /* Soak up all the script output */
- while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script) > 0) {
- continue;
- }
- /* This redirect needs to be a GET no matter what the original
- * method was.
- */
- r->method = ap_pstrdup(r->pool, "GET");
- r->method_number = M_GET;
-
- /* We already read the message body (if any), so don't allow
- * the redirected request to think it has one. We can ignore
- * Transfer-Encoding, since we used REQUEST_CHUNKED_ERROR.
- */
- ap_table_unset(r->headers_in, "Content-Length");
-
- ap_internal_redirect_handler(location, r);
- return OK;
- }
- else if (location && r->status == 200) {
- /* XX Note that if a script wants to produce its own Redirect
- * body, it now has to explicitly *say* "Status: 302"
- */
- return REDIRECT;
- }
-
- ap_send_http_header(r);
- if (!r->header_only) {
- ap_send_fb(script, r);
- }
- ap_bclose(script);
- }
-
- if (script && nph) {
- ap_send_fb(script, r);
- }
-
-ap_destroy_pool(pcgi);
-
- return OK; /* NOT r->status, even if it has changed. */
-}
-
-static const handler_rec cgid_handlers[] =
-{
- {CGI_MAGIC_TYPE, cgid_handler},
- {"cgi-script", cgid_handler},
- {NULL}
-};
-
-static void register_hook(void)
-{
- ap_hook_post_config(cgid_init, NULL, NULL, HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT cgid_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- create_cgid_config, /* server config */
- merge_cgid_config, /* merge server config */
- cgid_cmds, /* command table */
- cgid_handlers, /* handlers */
- register_hook /* register_handlers */
-};
-
diff --git a/modules/generators/mod_info.c b/modules/generators/mod_info.c
deleted file mode 100644
index 99746949c8..0000000000
--- a/modules/generators/mod_info.c
+++ /dev/null
@@ -1,688 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * Info Module. Display configuration information for the server and
- * all included modules.
- *
- * <Location /server-info>
- * SetHandler server-info
- * </Location>
- *
- * GET /server-info - Returns full configuration page for server and all modules
- * GET /server-info?server - Returns server configuration only
- * GET /server-info?module_name - Returns configuration for a single module
- * GET /server-info?list - Returns quick list of included modules
- *
- * Rasmus Lerdorf <rasmus@vex.net>, May 1996
- *
- * 05.01.96 Initial Version
- *
- * Lou Langholtz <ldl@usi.utah.edu>, July 1997
- *
- * 07.11.97 Addition of the AddModuleInfo directive
- *
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "http_protocol.h"
-#include "util_script.h"
-#include "http_conf_globals.h"
-
-typedef struct {
- char *name; /* matching module name */
- char *info; /* additional info */
-} info_entry;
-
-typedef struct {
- ap_array_header_t *more_info;
-} info_svr_conf;
-
-typedef struct info_cfg_lines {
- char *cmd;
- char *line;
- struct info_cfg_lines *next;
-} info_cfg_lines;
-
-module MODULE_VAR_EXPORT info_module;
-extern module *top_module;
-
-static void *create_info_config(ap_context_t *p, server_rec *s)
-{
- info_svr_conf *conf = (info_svr_conf *) ap_pcalloc(p, sizeof(info_svr_conf));
-
- conf->more_info = ap_make_array(p, 20, sizeof(info_entry));
- return conf;
-}
-
-static void *merge_info_config(ap_context_t *p, void *basev, void *overridesv)
-{
- info_svr_conf *new = (info_svr_conf *) ap_pcalloc(p, sizeof(info_svr_conf));
- info_svr_conf *base = (info_svr_conf *) basev;
- info_svr_conf *overrides = (info_svr_conf *) overridesv;
-
- new->more_info = ap_append_arrays(p, overrides->more_info, base->more_info);
- return new;
-}
-
-static char *mod_info_html_cmd_string(const char *string, char *buf, size_t buf_len)
-{
- const char *s;
- char *t;
- char *end_buf;
-
- s = string;
- t = buf;
- /* keep space for \0 byte */
- end_buf = buf + buf_len - 1;
- while ((*s) && (t < end_buf)) {
- if (*s == '<') {
- strncpy(t, "&lt;", end_buf - t);
- t += 4;
- }
- else if (*s == '>') {
- strncpy(t, "&gt;", end_buf - t);
- t += 4;
- }
- else if (*s == '&') {
- strncpy(t, "&amp;", end_buf - t);
- t += 5;
- }
- else {
- *t++ = *s;
- }
- s++;
- }
- /* oops, overflowed... don't overwrite */
- if (t > end_buf) {
- *end_buf = '\0';
- }
- else {
- *t = '\0';
- }
- return (buf);
-}
-
-static info_cfg_lines *mod_info_load_config(ap_context_t *p, const char *filename,
- request_rec *r)
-{
- char s[MAX_STRING_LEN];
- configfile_t *fp;
- info_cfg_lines *new, *ret, *prev;
- const char *t;
-
- fp = ap_pcfg_openfile(p, filename);
- if (!fp) {
- ap_log_rerror(APLOG_MARK, APLOG_WARNING, errno, r,
- "mod_info: couldn't open config file %s",
- filename);
- return NULL;
- }
- ret = NULL;
- prev = NULL;
- while (!ap_cfg_getline(s, MAX_STRING_LEN, fp)) {
- if (*s == '#') {
- continue; /* skip comments */
- }
- new = ap_palloc(p, sizeof(struct info_cfg_lines));
- new->next = NULL;
- if (!ret) {
- ret = new;
- }
- if (prev) {
- prev->next = new;
- }
- t = s;
- new->cmd = ap_getword_conf(p, &t);
- if (*t) {
- new->line = ap_pstrdup(p, t);
- }
- else {
- new->line = NULL;
- }
- prev = new;
- }
- ap_cfg_closefile(fp);
- return (ret);
-}
-
-static void mod_info_module_cmds(request_rec *r, info_cfg_lines *cfg,
- const command_rec *cmds, char *label)
-{
- const command_rec *cmd = cmds;
- info_cfg_lines *li = cfg, *li_st = NULL, *li_se = NULL;
- info_cfg_lines *block_start = NULL;
- int lab = 0, nest = 0;
- char buf[MAX_STRING_LEN];
-
- while (li) {
- if (!strncasecmp(li->cmd, "<directory", 10) ||
- !strncasecmp(li->cmd, "<location", 9) ||
- !strncasecmp(li->cmd, "<limit", 6) ||
- !strncasecmp(li->cmd, "<files", 6)) {
- if (nest) {
- li_se = li;
- }
- else {
- li_st = li;
- }
- li = li->next;
- nest++;
- continue;
- }
- else if (nest && (!strncasecmp(li->cmd, "</limit", 7) ||
- !strncasecmp(li->cmd, "</location", 10) ||
- !strncasecmp(li->cmd, "</directory", 11) ||
- !strncasecmp(li->cmd, "</files", 7))) {
- if (block_start) {
- if ((nest == 1 && block_start == li_st) ||
- (nest == 2 && block_start == li_se)) {
- ap_rputs("<dd><tt>", r);
- if (nest == 2) {
- ap_rputs("&nbsp;&nbsp;", r);
- }
- ap_rputs(mod_info_html_cmd_string(li->cmd, buf, sizeof(buf)), r);
- ap_rputs(" ", r);
- if (li->line) {
- ap_rputs(mod_info_html_cmd_string(li->line, buf, sizeof(buf)), r);
- }
- ap_rputs("</tt>\n", r);
- nest--;
- if (!nest) {
- block_start = NULL;
- li_st = NULL;
- }
- else {
- block_start = li_st;
- }
- li_se = NULL;
- }
- else {
- nest--;
- if (!nest) {
- li_st = NULL;
- }
- li_se = NULL;
- }
- }
- else {
- nest--;
- if (!nest) {
- li_st = NULL;
- }
- li_se = NULL;
- }
- li = li->next;
- continue;
- }
- cmd = cmds;
- while (cmd) {
- if (cmd->name) {
- if (!strcasecmp(cmd->name, li->cmd)) {
- if (!lab) {
- ap_rputs("<dt><strong>", r);
- ap_rputs(label, r);
- ap_rputs("</strong>\n", r);
- lab = 1;
- }
- if (((nest && block_start == NULL) ||
- (nest == 2 && block_start == li_st)) &&
- (strncasecmp(li->cmd, "<directory", 10) &&
- strncasecmp(li->cmd, "<location", 9) &&
- strncasecmp(li->cmd, "<limit", 6) &&
- strncasecmp(li->cmd, "</limit", 7) &&
- strncasecmp(li->cmd, "</location", 10) &&
- strncasecmp(li->cmd, "</directory", 11) &&
- strncasecmp(li->cmd, "</files", 7))) {
- ap_rputs("<dd><tt>", r);
- ap_rputs(mod_info_html_cmd_string(li_st->cmd, buf, sizeof(buf)), r);
- ap_rputs(" ", r);
- if (li_st->line) {
- ap_rputs(mod_info_html_cmd_string(li_st->line, buf, sizeof(buf)), r);
- }
- ap_rputs("</tt>\n", r);
- block_start = li_st;
- if (li_se) {
- ap_rputs("<dd><tt>&nbsp;&nbsp;", r);
- ap_rputs(mod_info_html_cmd_string(li_se->cmd, buf, sizeof(buf)), r);
- ap_rputs(" ", r);
- if (li_se->line) {
- ap_rputs(mod_info_html_cmd_string(li_se->line, buf, sizeof(buf)), r);
- }
- ap_rputs("</tt>\n", r);
- block_start = li_se;
- }
- }
- ap_rputs("<dd><tt>", r);
- if (nest) {
- ap_rputs("&nbsp;&nbsp;", r);
- }
- if (nest == 2) {
- ap_rputs("&nbsp;&nbsp;", r);
- }
- ap_rputs(mod_info_html_cmd_string(li->cmd, buf, sizeof(buf)), r);
- if (li->line) {
- ap_rputs(" <i>", r);
- ap_rputs(mod_info_html_cmd_string(li->line, buf, sizeof(buf)), r);
- ap_rputs("</i>", r);
- }
- ap_rputs("</tt>", r);
- }
- }
- else
- break;
- cmd++;
- }
- li = li->next;
- }
-}
-
-static char *find_more_info(server_rec *s, const char *module_name)
-{
- int i;
- info_svr_conf *conf = (info_svr_conf *) ap_get_module_config(s->module_config,
- &info_module);
- info_entry *entry = (info_entry *) conf->more_info->elts;
-
- if (!module_name) {
- return 0;
- }
- for (i = 0; i < conf->more_info->nelts; i++) {
- if (!strcmp(module_name, entry->name)) {
- return entry->info;
- }
- entry++;
- }
- return 0;
-}
-
-static int display_info(request_rec *r)
-{
- module *modp = NULL;
- char buf[MAX_STRING_LEN], *cfname;
- char *more_info;
- const command_rec *cmd = NULL;
- const handler_rec *hand = NULL;
- server_rec *serv = r->server;
- int comma = 0;
- info_cfg_lines *mod_info_cfg_httpd = NULL;
- info_cfg_lines *mod_info_cfg_srm = NULL;
- info_cfg_lines *mod_info_cfg_access = NULL;
-
- r->allowed |= (1 << M_GET);
- if (r->method_number != M_GET)
- return DECLINED;
-
- r->content_type = "text/html";
- ap_send_http_header(r);
- if (r->header_only) {
- return 0;
- }
-
- ap_rputs(DOCTYPE_HTML_3_2
- "<html><head><title>Server Information</title></head>\n", r);
- ap_rputs("<body><h1 align=center>Apache Server Information</h1>\n", r);
- if (!r->args || strcasecmp(r->args, "list")) {
- cfname = ap_server_root_relative(r->pool, ap_server_confname);
- mod_info_cfg_httpd = mod_info_load_config(r->pool, cfname, r);
- cfname = ap_server_root_relative(r->pool, serv->srm_confname);
- mod_info_cfg_srm = mod_info_load_config(r->pool, cfname, r);
- cfname = ap_server_root_relative(r->pool, serv->access_confname);
- mod_info_cfg_access = mod_info_load_config(r->pool, cfname, r);
- if (!r->args) {
- ap_rputs("<tt><a href=\"#server\">Server Settings</a>, ", r);
- for (modp = top_module; modp; modp = modp->next) {
- ap_rprintf(r, "<a href=\"#%s\">%s</a>", modp->name, modp->name);
- if (modp->next) {
- ap_rputs(", ", r);
- }
- }
- ap_rputs("</tt><hr>", r);
-
- }
- if (!r->args || !strcasecmp(r->args, "server")) {
- ap_rprintf(r, "<a name=\"server\"><strong>Server Version:</strong> "
- "<font size=+1><tt>%s</tt></a></font><br>\n",
- ap_get_server_version());
- ap_rprintf(r, "<strong>Server Built:</strong> "
- "<font size=+1><tt>%s</tt></a></font><br>\n",
- ap_get_server_built());
- ap_rprintf(r, "<strong>API Version:</strong> "
- "<tt>%d:%d</tt><br>\n",
- MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
- ap_rprintf(r, "<strong>User/Group:</strong> "
- "<tt>%s(%d)/%d</tt><br>\n",
- ap_user_name, (int) ap_user_id, (int) ap_group_id);
- ap_rprintf(r, "<strong>Hostname/port:</strong> "
- "<tt>%s:%u</tt><br>\n",
- serv->server_hostname, serv->port);
- ap_rprintf(r, "<strong>Daemons:</strong> "
- "<tt>start: %d &nbsp;&nbsp; "
- "min idle: %d &nbsp;&nbsp; "
- "max idle: %d &nbsp;&nbsp; "
- "max: %d</tt><br>\n",
- ap_daemons_to_start, ap_daemons_min_free,
- ap_daemons_max_free, ap_daemons_limit);
- ap_rprintf(r, "<strong>Max Requests:</strong> "
- "<tt>per child: %d &nbsp;&nbsp; "
- "keep alive: %s &nbsp;&nbsp; "
- "max per connection: %d</tt><br>\n",
- ap_max_requests_per_child,
- (serv->keep_alive ? "on" : "off"),
- serv->keep_alive_max);
- ap_rprintf(r, "<strong>Threads:</strong> "
- "<tt>per child: %d &nbsp;&nbsp; </tt><br>\n",
- ap_threads_per_child);
- ap_rprintf(r, "<strong>Timeouts:</strong> "
- "<tt>connection: %d &nbsp;&nbsp; "
- "keep-alive: %d</tt><br>",
- serv->timeout, serv->keep_alive_timeout);
- ap_rprintf(r, "<strong>Server Root:</strong> "
- "<tt>%s</tt><br>\n", ap_server_root);
- ap_rprintf(r, "<strong>Config File:</strong> "
- "<tt>%s</tt><br>\n", ap_server_confname);
- ap_rprintf(r, "<strong>PID File:</strong> "
- "<tt>%s</tt><br>\n", ap_pid_fname);
- ap_rprintf(r, "<strong>Scoreboard File:</strong> "
- "<tt>%s</tt><br>\n", ap_scoreboard_fname);
- }
- ap_rputs("<hr><dl>", r);
- for (modp = top_module; modp; modp = modp->next) {
- if (!r->args || !strcasecmp(modp->name, r->args)) {
- ap_rprintf(r, "<dt><a name=\"%s\"><strong>Module Name:</strong> "
- "<font size=+1><tt>%s</tt></a></font>\n",
- modp->name, modp->name);
- ap_rputs("<dt><strong>Content handlers:</strong>", r);
- hand = modp->handlers;
- if (hand) {
- while (hand) {
- if (hand->content_type) {
- ap_rprintf(r, " <tt>%s</tt>\n", hand->content_type);
- }
- else {
- break;
- }
- hand++;
- if (hand && hand->content_type) {
- ap_rputs(",", r);
- }
- }
- }
- else {
- ap_rputs("<tt> <EM>none</EM></tt>", r);
- }
- ap_rputs("<dt><strong>Configuration Phase Participation:</strong> \n",
- r);
- if (modp->child_init) {
- ap_rputs("<tt>Child Init</tt>", r);
- comma = 1;
- }
- if (modp->create_dir_config) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Create Directory Config</tt>", r);
- comma = 1;
- }
- if (modp->merge_dir_config) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Merge Directory Configs</tt>", r);
- comma = 1;
- }
- if (modp->create_server_config) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Create Server Config</tt>", r);
- comma = 1;
- }
- if (modp->merge_server_config) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Merge Server Configs</tt>", r);
- comma = 1;
- }
- if (modp->child_exit) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Child Exit</tt>", r);
- comma = 1;
- }
- if (!comma)
- ap_rputs("<tt> <EM>none</EM></tt>", r);
- comma = 0;
- ap_rputs("<dt><strong>Request Phase Participation:</strong> \n",
- r);
- if (modp->post_read_request) {
- ap_rputs("<tt>Post-Read Request</tt>", r);
- comma = 1;
- }
- if (modp->header_parser) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Header Parse</tt>", r);
- comma = 1;
- }
- if (modp->translate_handler) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Translate Path</tt>", r);
- comma = 1;
- }
- if (modp->access_checker) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Check Access</tt>", r);
- comma = 1;
- }
- if (modp->ap_check_user_id) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Verify User ID</tt>", r);
- comma = 1;
- }
- if (modp->auth_checker) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Verify User Access</tt>", r);
- comma = 1;
- }
- if (modp->type_checker) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Check Type</tt>", r);
- comma = 1;
- }
- if (modp->fixer_upper) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Fixups</tt>", r);
- comma = 1;
- }
- if (modp->logger) {
- if (comma) {
- ap_rputs(", ", r);
- }
- ap_rputs("<tt>Logging</tt>", r);
- comma = 1;
- }
- if (!comma)
- ap_rputs("<tt> <EM>none</EM></tt>", r);
- comma = 0;
- ap_rputs("<dt><strong>Module Directives:</strong> ", r);
- cmd = modp->cmds;
- if (cmd) {
- while (cmd) {
- if (cmd->name) {
- ap_rprintf(r, "<dd><tt>%s - <i>",
- mod_info_html_cmd_string(cmd->name,
- buf, sizeof(buf)));
- if (cmd->errmsg) {
- ap_rputs(cmd->errmsg, r);
- }
- ap_rputs("</i></tt>\n", r);
- }
- else {
- break;
- }
- cmd++;
- }
- ap_rputs("<dt><strong>Current Configuration:</strong>\n", r);
- mod_info_module_cmds(r, mod_info_cfg_httpd, modp->cmds,
- "httpd.conf");
- mod_info_module_cmds(r, mod_info_cfg_srm, modp->cmds,
- "srm.conf");
- mod_info_module_cmds(r, mod_info_cfg_access, modp->cmds,
- "access.conf");
- }
- else {
- ap_rputs("<tt> none</tt>\n", r);
- }
- more_info = find_more_info(serv, modp->name);
- if (more_info) {
- ap_rputs("<dt><strong>Additional Information:</strong>\n<dd>",
- r);
- ap_rputs(more_info, r);
- }
- ap_rputs("<dt><hr>\n", r);
- if (r->args) {
- break;
- }
- }
- }
- if (!modp && r->args && strcasecmp(r->args, "server")) {
- ap_rputs("<b>No such module</b>\n", r);
- }
- }
- else {
- for (modp = top_module; modp; modp = modp->next) {
- ap_rputs(modp->name, r);
- if (modp->next) {
- ap_rputs("<br>", r);
- }
- }
- }
- ap_rputs("</dl>\n", r);
- ap_rputs(ap_psignature("",r), r);
- ap_rputs("</body></html>\n", r);
- /* Done, turn off timeout, close file and return */
- return 0;
-}
-
-static const char *add_module_info(cmd_parms *cmd, void *dummy, char *name,
- char *info)
-{
- server_rec *s = cmd->server;
- info_svr_conf *conf = (info_svr_conf *) ap_get_module_config(s->module_config,
- &info_module);
- info_entry *new = ap_push_array(conf->more_info);
-
- new->name = name;
- new->info = info;
- return NULL;
-}
-
-static const command_rec info_cmds[] =
-{
- {"AddModuleInfo", add_module_info, NULL, RSRC_CONF, TAKE2,
- "a module name and additional information on that module"},
- {NULL}
-};
-
-static const handler_rec info_handlers[] =
-{
- {"server-info", display_info},
- {NULL}
-};
-
-module MODULE_VAR_EXPORT info_module =
-{
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- NULL, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- create_info_config, /* server config */
- merge_info_config, /* merge server config */
- info_cmds, /* command ap_table_t */
- info_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* post read-request */
-};
diff --git a/modules/generators/mod_info.dsp b/modules/generators/mod_info.dsp
deleted file mode 100644
index f19bc07f4e..0000000000
--- a/modules/generators/mod_info.dsp
+++ /dev/null
@@ -1,112 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheModuleInfo" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheModuleInfo - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleInfo.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleInfo.mak" CFG="ApacheModuleInfo - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheModuleInfo - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheModuleInfo - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheModuleInfo - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\Release"
-# PROP BASE Intermediate_Dir ".\Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\ApacheModuleInfoR"
-# PROP Intermediate_Dir ".\ApacheModuleInfoR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ..\..\CoreR\ApacheCore.lib ..\..\lib\apr\Release\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheModuleInfo - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\Debug"
-# PROP BASE Intermediate_Dir ".\Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\ApacheModuleInfoD"
-# PROP Intermediate_Dir ".\ApacheModuleInfoD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ..\..\CoreD\ApacheCore.lib ..\..\lib\apr\Debug\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheModuleInfo - Win32 Release"
-# Name "ApacheModuleInfo - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=..\..\modules\standard\mod_info.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\readdir.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/modules/generators/mod_info.exp b/modules/generators/mod_info.exp
deleted file mode 100644
index c304fa776d..0000000000
--- a/modules/generators/mod_info.exp
+++ /dev/null
@@ -1 +0,0 @@
-info_module
diff --git a/modules/generators/mod_status.c b/modules/generators/mod_status.c
deleted file mode 100644
index 5cacf4561c..0000000000
--- a/modules/generators/mod_status.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "mpm_status.h"
-
-#ifndef DEFAULT_TIME_FORMAT
-#define DEFAULT_TIME_FORMAT "%A, %d-%b-%Y %H:%M:%S %Z"
-#endif
-
-#define STATUS_MAGIC_TYPE "application/x-httpd-status"
-
-module MODULE_VAR_EXPORT status_module;
-
-static int print_status_value(void *data, const char *key, const char *val)
-{
- request_rec *r = (request_rec *) data;
-
- ap_rprintf(r, "<dt>%s\n<dd>%s\n", key, val);
- return 1;
-}
-
-static int status_handler(request_rec *r)
-{
- int i;
- ap_array_header_t *server_status;
- ap_status_table_row_t *status_rows;
-
- r->allowed = (1 << M_GET);
- if (r->method_number != M_GET)
- return DECLINED;
-
- r->content_type = "text/html";
-
- ap_send_http_header(r);
-
- if (r->header_only)
- return 0;
-
- server_status = ap_get_status_table(r->pool);
-
- ap_rputs(DOCTYPE_HTML_3_2
- "<html><head>\n<title>Apache Status</title>\n</head><body>\n",
- r);
- ap_rputs("<H1>Apache Server Status for ", r);
- ap_rvputs(r, ap_get_server_name(r), "</H1>\n\n", NULL);
- ap_rvputs(r, "Server Version: ",
- ap_get_server_version(), "<br>\n", NULL);
- ap_rvputs(r, "Server Built: ",
- ap_get_server_built(), "<br>\n<hr>\n", NULL);
- ap_rvputs(r, "Current Time: ",
- ap_ht_time(r->pool, ap_now(), DEFAULT_TIME_FORMAT, 0), "<br>\n", NULL);
- ap_rprintf(r, "\n%d connections currently being processed\n",
- server_status->nelts);
-
- status_rows = (ap_status_table_row_t *) server_status->elts;
- for (i = 0; i < server_status->nelts; i++) {
- ap_rprintf(r, "<h2>Connection %ld</h2>\n", status_rows[i].conn_id);
- ap_table_do(print_status_value, (void *) r, status_rows[i].data, NULL);
- }
- ap_rputs("</body></html>\n", r);
- return 0;
-}
-
-static const handler_rec status_handlers[] =
-{
- {STATUS_MAGIC_TYPE, status_handler},
- {"server-status", status_handler},
- {NULL}
-};
-
-module MODULE_VAR_EXPORT status_module =
-{
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-dir config */
- NULL, /* merge per-dir config */
- NULL, /* server config */
- NULL, /* merge server config */
- NULL, /* command table */
- status_handlers, /* handlers */
- NULL /* register hooks */
-};
diff --git a/modules/generators/mod_status.dsp b/modules/generators/mod_status.dsp
deleted file mode 100644
index b1f5686bee..0000000000
--- a/modules/generators/mod_status.dsp
+++ /dev/null
@@ -1,113 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheModuleStatus" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheModuleStatus - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleStatus.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleStatus.mak"\
- CFG="ApacheModuleStatus - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheModuleStatus - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheModuleStatus - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheModuleStatus - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\Release"
-# PROP BASE Intermediate_Dir ".\Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\ApacheModuleStatusR"
-# PROP Intermediate_Dir ".\ApacheModuleStatusR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ..\..\CoreR\ApacheCore.lib ..\..\lib\apr\Release\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheModuleStatus - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\Debug"
-# PROP BASE Intermediate_Dir ".\Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\ApacheModuleStatusD"
-# PROP Intermediate_Dir ".\ApacheModuleStatusD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ..\..\CoreD\ApacheCore.lib ..\..\lib\apr\Debug\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheModuleStatus - Win32 Release"
-# Name "ApacheModuleStatus - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=..\..\modules\standard\mod_status.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\readdir.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/modules/generators/mod_status.exp b/modules/generators/mod_status.exp
deleted file mode 100644
index 5438093686..0000000000
--- a/modules/generators/mod_status.exp
+++ /dev/null
@@ -1 +0,0 @@
-status_module
diff --git a/modules/http/.indent.pro b/modules/http/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/http/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/http/http_core.c b/modules/http/http_core.c
deleted file mode 100644
index b110b87dc8..0000000000
--- a/modules/http/http_core.c
+++ /dev/null
@@ -1,2651 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#define CORE_PRIVATE
-#include "ap_config.h"
-#include "apr_lib.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_protocol.h" /* For index_of_response(). Grump. */
-#include "http_request.h"
-#include "http_vhost.h"
-#include "http_main.h" /* For the default_handler below... */
-#include "http_log.h"
-#include "rfc1413.h"
-#include "util_md5.h"
-#include "apr_fnmatch.h"
-#include "http_connection.h"
-
-/* Allow Apache to use ap_mmap */
-#ifdef USE_MMAP_FILES
-#include "apr_mmap.h"
-
-/* mmap support for static files based on ideas from John Heidemann's
- * patch against 1.0.5. See
- * <http://www.isi.edu/~johnh/SOFTWARE/APACHE/index.html>.
- */
-
-/* Files have to be at least this big before they're mmap()d. This is to deal
- * with systems where the expense of doing an mmap() and an munmap() outweighs
- * the benefit for small files. It shouldn't be set lower than 1.
- */
-#ifndef MMAP_THRESHOLD
- #ifdef SUNOS4
- #define MMAP_THRESHOLD (8*1024)
- #else
- #define MMAP_THRESHOLD 1
- #endif /* SUNOS4 */
-#endif /* MMAP_THRESHOLD */
-#ifndef MMAP_LIMIT
-#define MMAP_LIMIT (4*1024*1024)
-#endif
-#endif /* USE_MMAP_FILES */
-
-/* Server core module... This module provides support for really basic
- * server operations, including options and commands which control the
- * operation of other modules. Consider this the bureaucracy module.
- *
- * The core module also defines handlers, etc., do handle just enough
- * to allow a server with the core module ONLY to actually serve documents
- * (though it slaps DefaultType on all of 'em); this was useful in testing,
- * but may not be worth preserving.
- *
- * This file could almost be mod_core.c, except for the stuff which affects
- * the http_conf_globals.
- */
-
-static void *create_core_dir_config(ap_context_t *a, char *dir)
-{
- core_dir_config *conf;
-
- conf = (core_dir_config *)ap_pcalloc(a, sizeof(core_dir_config));
- if (!dir || dir[strlen(dir) - 1] == '/') {
- conf->d = dir;
- }
- else if (strncmp(dir, "proxy:", 6) == 0) {
- conf->d = ap_pstrdup(a, dir);
- }
- else {
- conf->d = ap_pstrcat(a, dir, "/", NULL);
- }
- conf->d_is_fnmatch = conf->d ? (ap_is_fnmatch(conf->d) != 0) : 0;
- conf->d_components = conf->d ? ap_count_dirs(conf->d) : 0;
-
- conf->opts = dir ? OPT_UNSET : OPT_UNSET|OPT_ALL;
- conf->opts_add = conf->opts_remove = OPT_NONE;
- conf->override = dir ? OR_UNSET : OR_UNSET|OR_ALL;
-
- conf->content_md5 = 2;
-
- conf->use_canonical_name = USE_CANONICAL_NAME_UNSET;
-
- conf->hostname_lookups = HOSTNAME_LOOKUP_UNSET;
- conf->do_rfc1413 = DEFAULT_RFC1413 | 2; /* set bit 1 to indicate default */
- conf->satisfy = SATISFY_NOSPEC;
-
- conf->limit_req_body = 0;
- conf->sec = ap_make_array(a, 2, sizeof(void *));
-#ifdef WIN32
- conf->script_interpreter_source = INTERPRETER_SOURCE_UNSET;
-#endif
-
- conf->server_signature = srv_sig_unset;
-
- return (void *)conf;
-}
-
-static void *merge_core_dir_configs(ap_context_t *a, void *basev, void *newv)
-{
- core_dir_config *base = (core_dir_config *)basev;
- core_dir_config *new = (core_dir_config *)newv;
- core_dir_config *conf;
- int i;
-
- conf = (core_dir_config *)ap_palloc(a, sizeof(core_dir_config));
- memcpy((char *)conf, (const char *)base, sizeof(core_dir_config));
- if (base->response_code_strings) {
- conf->response_code_strings =
- ap_palloc(a, sizeof(*conf->response_code_strings)
- * RESPONSE_CODES);
- memcpy(conf->response_code_strings, base->response_code_strings,
- sizeof(*conf->response_code_strings) * RESPONSE_CODES);
- }
-
- conf->d = new->d;
- conf->d_is_fnmatch = new->d_is_fnmatch;
- conf->d_components = new->d_components;
- conf->r = new->r;
-
- if (new->opts & OPT_UNSET) {
- /* there was no explicit setting of new->opts, so we merge
- * preserve the invariant (opts_add & opts_remove) == 0
- */
- conf->opts_add = (conf->opts_add & ~new->opts_remove) | new->opts_add;
- conf->opts_remove = (conf->opts_remove & ~new->opts_add)
- | new->opts_remove;
- conf->opts = (conf->opts & ~conf->opts_remove) | conf->opts_add;
- if ((base->opts & OPT_INCNOEXEC) && (new->opts & OPT_INCLUDES)) {
- conf->opts = (conf->opts & ~OPT_INCNOEXEC) | OPT_INCLUDES;
- }
- }
- else {
- /* otherwise we just copy, because an explicit opts setting
- * overrides all earlier +/- modifiers
- */
- conf->opts = new->opts;
- conf->opts_add = new->opts_add;
- conf->opts_remove = new->opts_remove;
- }
-
- if (!(new->override & OR_UNSET)) {
- conf->override = new->override;
- }
- if (new->ap_default_type) {
- conf->ap_default_type = new->ap_default_type;
- }
-
- if (new->ap_auth_type) {
- conf->ap_auth_type = new->ap_auth_type;
- }
- if (new->ap_auth_name) {
- conf->ap_auth_name = new->ap_auth_name;
- }
- if (new->ap_requires) {
- conf->ap_requires = new->ap_requires;
- }
-
- if (new->response_code_strings) {
- if (conf->response_code_strings == NULL) {
- conf->response_code_strings = ap_palloc(a,
- sizeof(*conf->response_code_strings) * RESPONSE_CODES);
- memcpy(conf->response_code_strings, new->response_code_strings,
- sizeof(*conf->response_code_strings) * RESPONSE_CODES);
- }
- else {
- for (i = 0; i < RESPONSE_CODES; ++i) {
- if (new->response_code_strings[i] != NULL) {
- conf->response_code_strings[i]
- = new->response_code_strings[i];
- }
- }
- }
- }
- if (new->hostname_lookups != HOSTNAME_LOOKUP_UNSET) {
- conf->hostname_lookups = new->hostname_lookups;
- }
- if ((new->do_rfc1413 & 2) == 0) {
- conf->do_rfc1413 = new->do_rfc1413;
- }
- if ((new->content_md5 & 2) == 0) {
- conf->content_md5 = new->content_md5;
- }
- if (new->use_canonical_name != USE_CANONICAL_NAME_UNSET) {
- conf->use_canonical_name = new->use_canonical_name;
- }
-
- if (new->limit_req_body) {
- conf->limit_req_body = new->limit_req_body;
- }
- conf->sec = ap_append_arrays(a, base->sec, new->sec);
-
- if (new->satisfy != SATISFY_NOSPEC) {
- conf->satisfy = new->satisfy;
- }
-
-#ifdef WIN32
- if (new->script_interpreter_source != INTERPRETER_SOURCE_UNSET) {
- conf->script_interpreter_source = new->script_interpreter_source;
- }
-#endif
-
- if (new->server_signature != srv_sig_unset) {
- conf->server_signature = new->server_signature;
- }
-
- return (void*)conf;
-}
-
-static void *create_core_server_config(ap_context_t *a, server_rec *s)
-{
- core_server_config *conf;
- int is_virtual = s->is_virtual;
-
- conf = (core_server_config *)ap_pcalloc(a, sizeof(core_server_config));
-#ifdef GPROF
- conf->gprof_dir = NULL;
-#endif
- conf->access_name = is_virtual ? NULL : DEFAULT_ACCESS_FNAME;
- conf->ap_document_root = is_virtual ? NULL : DOCUMENT_LOCATION;
- conf->sec = ap_make_array(a, 40, sizeof(void *));
- conf->sec_url = ap_make_array(a, 40, sizeof(void *));
-
- return (void *)conf;
-}
-
-static void *merge_core_server_configs(ap_context_t *p, void *basev, void *virtv)
-{
- core_server_config *base = (core_server_config *)basev;
- core_server_config *virt = (core_server_config *)virtv;
- core_server_config *conf;
-
- conf = (core_server_config *)ap_pcalloc(p, sizeof(core_server_config));
- *conf = *virt;
- if (!conf->access_name) {
- conf->access_name = base->access_name;
- }
- if (!conf->ap_document_root) {
- conf->ap_document_root = base->ap_document_root;
- }
- conf->sec = ap_append_arrays(p, base->sec, virt->sec);
- conf->sec_url = ap_append_arrays(p, base->sec_url, virt->sec_url);
-
- return conf;
-}
-
-/* Add per-directory configuration entry (for <directory> section);
- * these are part of the core server config.
- */
-
-CORE_EXPORT(void) ap_add_per_dir_conf(server_rec *s, void *dir_config)
-{
- core_server_config *sconf = ap_get_module_config(s->module_config,
- &core_module);
- void **new_space = (void **)ap_push_array(sconf->sec);
-
- *new_space = dir_config;
-}
-
-CORE_EXPORT(void) ap_add_per_url_conf(server_rec *s, void *url_config)
-{
- core_server_config *sconf = ap_get_module_config(s->module_config,
- &core_module);
- void **new_space = (void **)ap_push_array(sconf->sec_url);
-
- *new_space = url_config;
-}
-
-CORE_EXPORT(void) ap_add_file_conf(core_dir_config *conf, void *url_config)
-{
- void **new_space = (void **)ap_push_array(conf->sec);
-
- *new_space = url_config;
-}
-
-/* core_reorder_directories reorders the directory sections such that the
- * 1-component sections come first, then the 2-component, and so on, finally
- * followed by the "special" sections. A section is "special" if it's a regex,
- * or if it doesn't start with / -- consider proxy: matching. All movements
- * are in-order to preserve the ordering of the sections from the config files.
- * See directory_walk().
- */
-
-#ifdef HAVE_DRIVE_LETTERS
-#define IS_SPECIAL(entry_core) \
- ((entry_core)->r != NULL \
- || ((entry_core)->d[0] != '/' && (entry_core)->d[1] != ':'))
-#else
-#define IS_SPECIAL(entry_core) \
- ((entry_core)->r != NULL || (entry_core)->d[0] != '/')
-#endif
-
-/* We need to do a stable sort, qsort isn't stable. So to make it stable
- * we'll be maintaining the original index into the list, and using it
- * as the minor key during sorting. The major key is the number of
- * components (where a "special" section has infinite components).
- */
-struct reorder_sort_rec {
- void *elt;
- int orig_index;
-};
-
-static int reorder_sorter(const void *va, const void *vb)
-{
- const struct reorder_sort_rec *a = va;
- const struct reorder_sort_rec *b = vb;
- core_dir_config *core_a;
- core_dir_config *core_b;
-
- core_a = (core_dir_config *)ap_get_module_config(a->elt, &core_module);
- core_b = (core_dir_config *)ap_get_module_config(b->elt, &core_module);
- if (IS_SPECIAL(core_a)) {
- if (!IS_SPECIAL(core_b)) {
- return 1;
- }
- }
- else if (IS_SPECIAL(core_b)) {
- return -1;
- }
- else {
- /* we know they're both not special */
- if (core_a->d_components < core_b->d_components) {
- return -1;
- }
- else if (core_a->d_components > core_b->d_components) {
- return 1;
- }
- }
- /* Either they're both special, or they're both not special and have the
- * same number of components. In any event, we now have to compare
- * the minor key. */
- return a->orig_index - b->orig_index;
-}
-
-void ap_core_reorder_directories(ap_context_t *p, server_rec *s)
-{
- core_server_config *sconf;
- ap_array_header_t *sec;
- struct reorder_sort_rec *sortbin;
- int nelts;
- void **elts;
- int i;
- ap_context_t *tmp;
-
- sconf = ap_get_module_config(s->module_config, &core_module);
- sec = sconf->sec;
- nelts = sec->nelts;
- elts = (void **)sec->elts;
-
- /* we have to allocate tmp space to do a stable sort */
- ap_create_context(&tmp, p);
- sortbin = ap_palloc(tmp, sec->nelts * sizeof(*sortbin));
- for (i = 0; i < nelts; ++i) {
- sortbin[i].orig_index = i;
- sortbin[i].elt = elts[i];
- }
-
- qsort(sortbin, nelts, sizeof(*sortbin), reorder_sorter);
-
- /* and now copy back to the original array */
- for (i = 0; i < nelts; ++i) {
- elts[i] = sortbin[i].elt;
- }
-
- ap_destroy_pool(tmp);
-}
-
-/*****************************************************************
- *
- * There are some elements of the core config structures in which
- * other modules have a legitimate interest (this is ugly, but necessary
- * to preserve NCSA back-compatibility). So, we have a bunch of accessors
- * here...
- */
-
-API_EXPORT(int) ap_allow_options(request_rec *r)
-{
- core_dir_config *conf =
- (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
-
- return conf->opts;
-}
-
-API_EXPORT(int) ap_allow_overrides(request_rec *r)
-{
- core_dir_config *conf;
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
-
- return conf->override;
-}
-
-API_EXPORT(const char *) ap_auth_type(request_rec *r)
-{
- core_dir_config *conf;
-
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
- return conf->ap_auth_type;
-}
-
-API_EXPORT(const char *) ap_auth_name(request_rec *r)
-{
- core_dir_config *conf;
-
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
- return conf->ap_auth_name;
-}
-
-API_EXPORT(const char *) ap_default_type(request_rec *r)
-{
- core_dir_config *conf;
-
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
- return conf->ap_default_type
- ? conf->ap_default_type
- : DEFAULT_CONTENT_TYPE;
-}
-
-API_EXPORT(const char *) ap_document_root(request_rec *r) /* Don't use this! */
-{
- core_server_config *conf;
-
- conf = (core_server_config *)ap_get_module_config(r->server->module_config,
- &core_module);
- return conf->ap_document_root;
-}
-
-API_EXPORT(const ap_array_header_t *) ap_requires(request_rec *r)
-{
- core_dir_config *conf;
-
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
- return conf->ap_requires;
-}
-
-API_EXPORT(int) ap_satisfies(request_rec *r)
-{
- core_dir_config *conf;
-
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
-
- return conf->satisfy;
-}
-
-/* Should probably just get rid of this... the only code that cares is
- * part of the core anyway (and in fact, it isn't publicised to other
- * modules).
- */
-
-char *ap_response_code_string(request_rec *r, int error_index)
-{
- core_dir_config *conf;
-
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
-
- if (conf->response_code_strings == NULL) {
- return NULL;
- }
- return conf->response_code_strings[error_index];
-}
-
-
-/* Code from Harald Hanche-Olsen <hanche@imf.unit.no> */
-static ap_inline void do_double_reverse (conn_rec *conn)
-{
- struct hostent *hptr;
-
- if (conn->double_reverse) {
- /* already done */
- return;
- }
- if (conn->remote_host == NULL || conn->remote_host[0] == '\0') {
- /* single reverse failed, so don't bother */
- conn->double_reverse = -1;
- return;
- }
- hptr = gethostbyname(conn->remote_host);
- if (hptr) {
- char **haddr;
-
- for (haddr = hptr->h_addr_list; *haddr; haddr++) {
- if (((struct in_addr *)(*haddr))->s_addr
- == conn->remote_addr.sin_addr.s_addr) {
- conn->double_reverse = 1;
- return;
- }
- }
- }
- conn->double_reverse = -1;
-}
-
-API_EXPORT(const char *) ap_get_remote_host(conn_rec *conn, void *dir_config,
- int type)
-{
- struct in_addr *iaddr;
- struct hostent *hptr;
- int hostname_lookups;
-
- /* If we haven't checked the host name, and we want to */
- if (dir_config) {
- hostname_lookups =
- ((core_dir_config *)ap_get_module_config(dir_config, &core_module))
- ->hostname_lookups;
- if (hostname_lookups == HOSTNAME_LOOKUP_UNSET) {
- hostname_lookups = HOSTNAME_LOOKUP_OFF;
- }
- }
- else {
- /* the default */
- hostname_lookups = HOSTNAME_LOOKUP_OFF;
- }
-
- if (type != REMOTE_NOLOOKUP
- && conn->remote_host == NULL
- && (type == REMOTE_DOUBLE_REV
- || hostname_lookups != HOSTNAME_LOOKUP_OFF)) {
- iaddr = &(conn->remote_addr.sin_addr);
- hptr = gethostbyaddr((char *)iaddr, sizeof(struct in_addr), AF_INET);
- if (hptr != NULL) {
- conn->remote_host = ap_pstrdup(conn->pool, (void *)hptr->h_name);
- ap_str_tolower(conn->remote_host);
-
- if (hostname_lookups == HOSTNAME_LOOKUP_DOUBLE) {
- do_double_reverse(conn);
- if (conn->double_reverse != 1) {
- conn->remote_host = NULL;
- }
- }
- }
- /* if failed, set it to the NULL string to indicate error */
- if (conn->remote_host == NULL) {
- conn->remote_host = "";
- }
- }
- if (type == REMOTE_DOUBLE_REV) {
- do_double_reverse(conn);
- if (conn->double_reverse == -1) {
- return NULL;
- }
- }
-
-/*
- * Return the desired information; either the remote DNS name, if found,
- * or either NULL (if the hostname was requested) or the IP address
- * (if any identifier was requested).
- */
- if (conn->remote_host != NULL && conn->remote_host[0] != '\0') {
- return conn->remote_host;
- }
- else {
- if (type == REMOTE_HOST || type == REMOTE_DOUBLE_REV) {
- return NULL;
- }
- else {
- return conn->remote_ip;
- }
- }
-}
-
-API_EXPORT(const char *) ap_get_remote_logname(request_rec *r)
-{
- core_dir_config *dir_conf;
-
- if (r->connection->remote_logname != NULL) {
- return r->connection->remote_logname;
- }
-
-/* If we haven't checked the identity, and we want to */
- dir_conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
-
- if (dir_conf->do_rfc1413 & 1) {
- return ap_rfc1413(r->connection, r->server);
- }
- else {
- return NULL;
- }
-}
-
-/* There are two options regarding what the "name" of a server is. The
- * "canonical" name as defined by ServerName and Port, or the "client's
- * name" as supplied by a possible Host: header or full URI. We never
- * trust the port passed in the client's headers, we always use the
- * port of the actual socket.
- *
- * The DNS option to UseCanonicalName causes this routine to do a
- * reverse lookup on the local IP address of the connectiona and use
- * that for the ServerName. This makes its value more reliable while
- * at the same time allowing Demon's magic virtual hosting to work.
- * The assumption is that DNS lookups are sufficiently quick...
- * -- fanf 1998-10-03
- */
-API_EXPORT(const char *) ap_get_server_name(request_rec *r)
-{
- conn_rec *conn = r->connection;
- core_dir_config *d;
-
- d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
-
- if (d->use_canonical_name == USE_CANONICAL_NAME_OFF) {
- return r->hostname ? r->hostname : r->server->server_hostname;
- }
- if (d->use_canonical_name == USE_CANONICAL_NAME_DNS) {
- if (conn->local_host == NULL) {
- struct in_addr *iaddr;
- struct hostent *hptr;
- iaddr = &(conn->local_addr.sin_addr);
- hptr = gethostbyaddr((char *)iaddr, sizeof(struct in_addr),
- AF_INET);
- if (hptr != NULL) {
- conn->local_host = ap_pstrdup(conn->pool,
- (void *)hptr->h_name);
- ap_str_tolower(conn->local_host);
- }
- else {
- conn->local_host = ap_pstrdup(conn->pool,
- r->server->server_hostname);
- }
- }
- return conn->local_host;
- }
- /* default */
- return r->server->server_hostname;
-}
-
-API_EXPORT(unsigned) ap_get_server_port(const request_rec *r)
-{
- unsigned port;
- core_dir_config *d =
- (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
-
- port = r->server->port ? r->server->port : ap_default_port(r);
-
- if (d->use_canonical_name == USE_CANONICAL_NAME_OFF
- || d->use_canonical_name == USE_CANONICAL_NAME_DNS) {
- return r->hostname ? ntohs(r->connection->local_addr.sin_port)
- : port;
- }
- /* default */
- return port;
-}
-
-API_EXPORT(char *) ap_construct_url(ap_context_t *p, const char *uri,
- request_rec *r)
-{
- unsigned port = ap_get_server_port(r);
- const char *host = ap_get_server_name(r);
-
- if (ap_is_default_port(port, r)) {
- return ap_pstrcat(p, ap_http_method(r), "://", host, uri, NULL);
- }
- return ap_psprintf(p, "%s://%s:%u%s", ap_http_method(r), host, port, uri);
-}
-
-API_EXPORT(unsigned long) ap_get_limit_req_body(const request_rec *r)
-{
- core_dir_config *d =
- (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
-
- return d->limit_req_body;
-}
-
-#ifdef WIN32
-static char* get_interpreter_from_win32_registry(ap_context_t *p, const char* ext)
-{
- char extension_path[] = "SOFTWARE\\Classes\\";
- char executable_path[] = "\\SHELL\\OPEN\\COMMAND";
-
- HKEY hkeyOpen;
- DWORD type;
- int size;
- int result;
- char *keyName;
- char *buffer;
- char *s;
-
- if (!ext)
- return NULL;
- /*
- * Future optimization:
- * When the registry is successfully searched, store the interpreter
- * string in a ap_table_t to make subsequent look-ups faster
- */
-
- /* Open the key associated with the script extension */
- keyName = ap_pstrcat(p, extension_path, ext, NULL);
-
- result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName, 0, KEY_QUERY_VALUE,
- &hkeyOpen);
-
- if (result != ERROR_SUCCESS)
- return NULL;
-
- /* Read to NULL buffer to find value size */
- size = 0;
- result = RegQueryValueEx(hkeyOpen, "", NULL, &type, NULL, &size);
-
- if (result == ERROR_SUCCESS) {
- buffer = ap_palloc(p, size);
- result = RegQueryValueEx(hkeyOpen, "", NULL, &type, buffer, &size);
- }
-
- RegCloseKey(hkeyOpen);
-
- if (result != ERROR_SUCCESS)
- return NULL;
-
- /* Open the key associated with the interpreter path */
- keyName = ap_pstrcat(p, extension_path, buffer, executable_path, NULL);
-
- result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyName, 0, KEY_QUERY_VALUE,
- &hkeyOpen);
-
- if (result != ERROR_SUCCESS)
- return NULL;
-
- /* Read to NULL buffer to find value size */
- size = 0;
- result = RegQueryValueEx(hkeyOpen, "", 0, &type, NULL, &size);
-
- if (result == ERROR_SUCCESS) {
- buffer = ap_palloc(p, size);
- result = RegQueryValueEx(hkeyOpen, "", 0, &type, buffer, &size);
- }
-
- RegCloseKey(hkeyOpen);
-
- if (result != ERROR_SUCCESS)
- return NULL;
-
- /*
- * The canonical way shell command entries are entered in the Win32
- * registry is as follows:
- * shell [options] "%1"
- * where
- * shell - full path name to interpreter or shell to run.
- * E.g., c:\usr\local\ntreskit\perl\bin\perl.exe
- * options - optional switches
- * E.g., \C
- * "%1" - Place holder for file to run the shell against.
- * Typically quoted.
- *
- * If we find a %1 or a quoted %1, lop it off.
- */
- if (buffer && *buffer) {
- if ((s = strstr(buffer, "\"%1")))
- *s = '\0';
- else if ((s = strstr(buffer, "%1")))
- *s = '\0';
- }
-
- return buffer;
-}
-
-API_EXPORT (file_type_e) ap_get_win32_interpreter(const request_rec *r,
- char** interpreter )
-{
- HANDLE hFile;
- DWORD nBytesRead;
- BOOLEAN bResult;
- char buffer[1024];
- core_dir_config *d;
- int i;
- file_type_e fileType = eFileTypeUNKNOWN;
- char *ext = NULL;
- char *exename = NULL;
-
- d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
-
- /* Find the file extension */
- exename = strrchr(r->filename, '/');
- if (!exename) {
- exename = strrchr(r->filename, '\\');
- }
- if (!exename) {
- exename = r->filename;
- }
- else {
- exename++;
- }
- ext = strrchr(exename, '.');
-
- if (ext && (!strcasecmp(ext,".bat") || !strcasecmp(ext,".cmd"))) {
- return eFileTypeEXE32;
- }
-
- /* If the file has an extension and it is not .com and not .exe and
- * we've been instructed to search the registry, then do it!
- */
- if (ext && strcasecmp(ext,".exe") && strcasecmp(ext,".com") &&
- d->script_interpreter_source == INTERPRETER_SOURCE_REGISTRY) {
- /* Check the registry */
- *interpreter = get_interpreter_from_win32_registry(r->pool, ext);
- if (*interpreter)
- return eFileTypeSCRIPT;
- else {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r->server,
- "ScriptInterpreterSource config directive set to \"registry\".\n\t"
- "Registry was searched but interpreter not found. Trying the shebang line.");
- }
- }
-
- /* Need to peek into the file figure out what it really is... */
- hFile = CreateFile(r->filename, GENERIC_READ, FILE_SHARE_READ, NULL,
- OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (hFile == INVALID_HANDLE_VALUE) {
- return eFileTypeUNKNOWN;
- }
- bResult = ReadFile(hFile, (void*) &buffer, sizeof(buffer) - 1,
- &nBytesRead, NULL);
- if (!bResult || (nBytesRead == 0)) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, GetLastError(), r,
- "ReadFile(%s) failed", r->filename);
- CloseHandle(hFile);
- return eFileTypeUNKNOWN;
- }
- CloseHandle(hFile);
- buffer[nBytesRead] = '\0';
-
- /* Script or executable, that is the question... */
- if ((buffer[0] == '#') && (buffer[1] == '!')) {
- /* Assuming file is a script since it starts with a shebang */
- fileType = eFileTypeSCRIPT;
- for (i = 2; i < sizeof(buffer); i++) {
- if ((buffer[i] == '\r')
- || (buffer[i] == '\n')) {
- break;
- }
- }
- buffer[i] = '\0';
- for (i = 2; buffer[i] == ' ' ; ++i)
- ;
- *interpreter = ap_pstrdup(r->pool, buffer + i );
- }
- else {
- /* Not a script, is it an executable? */
- IMAGE_DOS_HEADER *hdr = (IMAGE_DOS_HEADER*)buffer;
- if ((nBytesRead >= sizeof(IMAGE_DOS_HEADER)) && (hdr->e_magic == IMAGE_DOS_SIGNATURE)) {
- if (hdr->e_lfarlc < 0x40)
- fileType = eFileTypeEXE16;
- else
- fileType = eFileTypeEXE32;
- }
- else
- fileType = eFileTypeUNKNOWN;
- }
-
- return fileType;
-}
-#endif
-
-/*****************************************************************
- *
- * Commands... this module handles almost all of the NCSA httpd.conf
- * commands, but most of the old srm.conf is in the the modules.
- */
-
-static const char end_directory_section[] = "</Directory>";
-static const char end_directorymatch_section[] = "</DirectoryMatch>";
-static const char end_location_section[] = "</Location>";
-static const char end_locationmatch_section[] = "</LocationMatch>";
-static const char end_files_section[] = "</Files>";
-static const char end_filesmatch_section[] = "</FilesMatch>";
-static const char end_virtualhost_section[] = "</VirtualHost>";
-static const char end_ifmodule_section[] = "</IfModule>";
-static const char end_ifdefine_section[] = "</IfDefine>";
-
-
-API_EXPORT(const char *) ap_check_cmd_context(cmd_parms *cmd,
- unsigned forbidden)
-{
- const char *gt = (cmd->cmd->name[0] == '<'
- && cmd->cmd->name[strlen(cmd->cmd->name)-1] != '>')
- ? ">" : "";
-
- if ((forbidden & NOT_IN_VIRTUALHOST) && cmd->server->is_virtual) {
- return ap_pstrcat(cmd->pool, cmd->cmd->name, gt,
- " cannot occur within <VirtualHost> section", NULL);
- }
-
- if ((forbidden & NOT_IN_LIMIT) && cmd->limited != -1) {
- return ap_pstrcat(cmd->pool, cmd->cmd->name, gt,
- " cannot occur within <Limit> section", NULL);
- }
-
- if ((forbidden & NOT_IN_DIR_LOC_FILE) == NOT_IN_DIR_LOC_FILE
- && cmd->path != NULL) {
- return ap_pstrcat(cmd->pool, cmd->cmd->name, gt,
- " cannot occur within <Directory/Location/Files> "
- "section", NULL);
- }
-
- if (((forbidden & NOT_IN_DIRECTORY)
- && (cmd->end_token == end_directory_section
- || cmd->end_token == end_directorymatch_section))
- || ((forbidden & NOT_IN_LOCATION)
- && (cmd->end_token == end_location_section
- || cmd->end_token == end_locationmatch_section))
- || ((forbidden & NOT_IN_FILES)
- && (cmd->end_token == end_files_section
- || cmd->end_token == end_filesmatch_section))) {
- return ap_pstrcat(cmd->pool, cmd->cmd->name, gt,
- " cannot occur within <", cmd->end_token+2,
- " section", NULL);
- }
-
- return NULL;
-}
-
-static const char *set_access_name(cmd_parms *cmd, void *dummy, char *arg)
-{
- void *sconf = cmd->server->module_config;
- core_server_config *conf = ap_get_module_config(sconf, &core_module);
-
- const char *err = ap_check_cmd_context(cmd,
- NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- conf->access_name = ap_pstrdup(cmd->pool, arg);
- return NULL;
-}
-
-#ifdef GPROF
-static const char *set_gprof_dir(cmd_parms *cmd, void *dummy, char *arg)
-{
- void *sconf = cmd->server->module_config;
- core_server_config *conf = ap_get_module_config(sconf, &core_module);
-
- const char *err = ap_check_cmd_context(cmd,
- NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- conf->gprof_dir = ap_pstrdup(cmd->pool, arg);
- return NULL;
-}
-#endif /*GPROF*/
-
-static const char *set_document_root(cmd_parms *cmd, void *dummy, char *arg)
-{
- void *sconf = cmd->server->module_config;
- core_server_config *conf = ap_get_module_config(sconf, &core_module);
-
- const char *err = ap_check_cmd_context(cmd,
- NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- arg = ap_os_canonical_filename(cmd->pool, arg);
- if (/* TODO: ap_configtestonly && ap_docrootcheck && */ !ap_is_directory(arg)) {
- if (cmd->server->is_virtual) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Warning: DocumentRoot [%s] does not exist",
- arg);
- }
- else {
- return "DocumentRoot must be a directory";
- }
- }
-
- conf->ap_document_root = arg;
- return NULL;
-}
-
-API_EXPORT(void) ap_custom_response(request_rec *r, int status, char *string)
-{
- core_dir_config *conf =
- ap_get_module_config(r->per_dir_config, &core_module);
- int idx;
-
- if(conf->response_code_strings == NULL) {
- conf->response_code_strings =
- ap_pcalloc(r->pool,
- sizeof(*conf->response_code_strings) *
- RESPONSE_CODES);
- }
-
- idx = ap_index_of_response(status);
-
- conf->response_code_strings[idx] =
- ((ap_is_url(string) || (*string == '/')) && (*string != '"')) ?
- ap_pstrdup(r->pool, string) : ap_pstrcat(r->pool, "\"", string, NULL);
-}
-
-static const char *set_error_document(cmd_parms *cmd, core_dir_config *conf,
- char *line)
-{
- int error_number, index_number, idx500;
- char *w;
-
- const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- /* 1st parameter should be a 3 digit number, which we recognize;
- * convert it into an array index
- */
-
- w = ap_getword_conf_nc(cmd->pool, &line);
- error_number = atoi(w);
-
- idx500 = ap_index_of_response(HTTP_INTERNAL_SERVER_ERROR);
-
- if (error_number == HTTP_INTERNAL_SERVER_ERROR) {
- index_number = idx500;
- }
- else if ((index_number = ap_index_of_response(error_number)) == idx500) {
- return ap_pstrcat(cmd->pool, "Unsupported HTTP response code ",
- w, NULL);
- }
-
- /* The entry should be ignored if it is a full URL for a 401 error */
-
- if (error_number == 401 &&
- line[0] != '/' && line[0] != '"') { /* Ignore it... */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, cmd->server,
- "cannot use a full URL in a 401 ErrorDocument "
- "directive --- ignoring!");
- }
- else { /* Store it... */
- if (conf->response_code_strings == NULL) {
- conf->response_code_strings =
- ap_pcalloc(cmd->pool,
- sizeof(*conf->response_code_strings) * RESPONSE_CODES);
- }
- conf->response_code_strings[index_number] = ap_pstrdup(cmd->pool, line);
- }
-
- return NULL;
-}
-
-/* access.conf commands...
- *
- * The *only* thing that can appear in access.conf at top level is a
- * <Directory> section. NB we need to have a way to cut the srm_command_loop
- * invoked by dirsection (i.e., <Directory>) short when </Directory> is seen.
- * We do that by returning an error, which dirsection itself recognizes and
- * discards as harmless. Cheesy, but it works.
- */
-
-static const char *set_override(cmd_parms *cmd, core_dir_config *d,
- const char *l)
-{
- char *w;
-
- const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- d->override = OR_NONE;
- while (l[0]) {
- w = ap_getword_conf(cmd->pool, &l);
- if (!strcasecmp(w, "Limit")) {
- d->override |= OR_LIMIT;
- }
- else if (!strcasecmp(w, "Options")) {
- d->override |= OR_OPTIONS;
- }
- else if (!strcasecmp(w, "FileInfo")) {
- d->override |= OR_FILEINFO;
- }
- else if (!strcasecmp(w, "AuthConfig")) {
- d->override |= OR_AUTHCFG;
- }
- else if (!strcasecmp(w, "Indexes")) {
- d->override |= OR_INDEXES;
- }
- else if (!strcasecmp(w, "None")) {
- d->override = OR_NONE;
- }
- else if (!strcasecmp(w, "All")) {
- d->override = OR_ALL;
- }
- else {
- return ap_pstrcat(cmd->pool, "Illegal override option ", w, NULL);
- }
- d->override &= ~OR_UNSET;
- }
-
- return NULL;
-}
-
-static const char *set_options(cmd_parms *cmd, core_dir_config *d,
- const char *l)
-{
- allow_options_t opt;
- int first = 1;
- char action;
-
- while (l[0]) {
- char *w = ap_getword_conf(cmd->pool, &l);
- action = '\0';
-
- if (*w == '+' || *w == '-') {
- action = *(w++);
- }
- else if (first) {
- d->opts = OPT_NONE;
- first = 0;
- }
-
- if (!strcasecmp(w, "Indexes")) {
- opt = OPT_INDEXES;
- }
- else if (!strcasecmp(w, "Includes")) {
- opt = OPT_INCLUDES;
- }
- else if (!strcasecmp(w, "IncludesNOEXEC")) {
- opt = (OPT_INCLUDES | OPT_INCNOEXEC);
- }
- else if (!strcasecmp(w, "FollowSymLinks")) {
- opt = OPT_SYM_LINKS;
- }
- else if (!strcasecmp(w, "SymLinksIfOwnerMatch")) {
- opt = OPT_SYM_OWNER;
- }
- else if (!strcasecmp(w, "execCGI")) {
- opt = OPT_EXECCGI;
- }
- else if (!strcasecmp(w, "MultiViews")) {
- opt = OPT_MULTI;
- }
- else if (!strcasecmp(w, "RunScripts")) { /* AI backcompat. Yuck */
- opt = OPT_MULTI|OPT_EXECCGI;
- }
- else if (!strcasecmp(w, "None")) {
- opt = OPT_NONE;
- }
- else if (!strcasecmp(w, "All")) {
- opt = OPT_ALL;
- }
- else {
- return ap_pstrcat(cmd->pool, "Illegal option ", w, NULL);
- }
-
- /* we ensure the invariant (d->opts_add & d->opts_remove) == 0 */
- if (action == '-') {
- d->opts_remove |= opt;
- d->opts_add &= ~opt;
- d->opts &= ~opt;
- }
- else if (action == '+') {
- d->opts_add |= opt;
- d->opts_remove &= ~opt;
- d->opts |= opt;
- }
- else {
- d->opts |= opt;
- }
- }
-
- return NULL;
-}
-
-static const char *satisfy(cmd_parms *cmd, core_dir_config *c, char *arg)
-{
- if (!strcasecmp(arg, "all")) {
- c->satisfy = SATISFY_ALL;
- }
- else if (!strcasecmp(arg, "any")) {
- c->satisfy = SATISFY_ANY;
- }
- else {
- return "Satisfy either 'any' or 'all'.";
- }
- return NULL;
-}
-
-static const char *require(cmd_parms *cmd, core_dir_config *c, char *arg)
-{
- require_line *r;
-
- if (!c->ap_requires) {
- c->ap_requires = ap_make_array(cmd->pool, 2, sizeof(require_line));
- }
- r = (require_line *)ap_push_array(c->ap_requires);
- r->requirement = ap_pstrdup(cmd->pool, arg);
- r->method_mask = cmd->limited;
- return NULL;
-}
-
-CORE_EXPORT_NONSTD(const char *) ap_limit_section(cmd_parms *cmd, void *dummy,
- const char *arg)
-{
- const char *limited_methods = ap_getword(cmd->pool, &arg, '>');
- void *tog = cmd->cmd->cmd_data;
- int limited = 0;
-
- const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- /* XXX: NB: Currently, we have no way of checking
- * whether <Limit> or <LimitExcept> sections are closed properly.
- * (If we would add a srm_command_loop() here we might...)
- */
-
- while (limited_methods[0]) {
- char *method = ap_getword_conf(cmd->pool, &limited_methods);
- int methnum = ap_method_number_of(method);
-
- if (methnum == M_TRACE && !tog) {
- return "TRACE cannot be controlled by <Limit>";
- }
- else if (methnum == M_INVALID) {
- return ap_pstrcat(cmd->pool, "unknown method \"", method,
- "\" in <Limit", tog ? "Except>" : ">", NULL);
- }
- else {
- limited |= (1 << methnum);
- }
- }
-
- /* Killing two features with one function,
- * if (tog == NULL) <Limit>, else <LimitExcept>
- */
- cmd->limited = tog ? ~limited : limited;
- return NULL;
-}
-
-static const char *endlimit_section(cmd_parms *cmd, void *dummy, void *dummy2)
-{
- void *tog = cmd->cmd->cmd_data;
-
- if (cmd->limited == -1) {
- return tog ? "</LimitExcept> unexpected" : "</Limit> unexpected";
- }
-
- cmd->limited = -1;
- return NULL;
-}
-
-/*
- * When a section is not closed properly when end-of-file is reached,
- * then an error message should be printed:
- */
-static const char *missing_endsection(cmd_parms *cmd, int nest)
-{
- if (nest < 2) {
- return ap_psprintf(cmd->pool, "Missing %s directive at end-of-file",
- cmd->end_token);
- }
- return ap_psprintf(cmd->pool, "%d missing %s directives at end-of-file",
- nest, cmd->end_token);
-}
-
-/* We use this in <DirectoryMatch> and <FilesMatch>, to ensure that
- * people don't get bitten by wrong-cased regex matches
- */
-
-#ifdef WIN32
-#define USE_ICASE REG_ICASE
-#else
-#define USE_ICASE 0
-#endif
-
-static const char *end_nested_section(cmd_parms *cmd, void *dummy)
-{
- if (cmd->end_token == NULL) {
- return ap_pstrcat(cmd->pool, cmd->cmd->name,
- " without matching <", cmd->cmd->name + 2,
- " section", NULL);
- }
- /*
- * This '!=' may look weird on a string comparison, but it's correct --
- * it's been set up so that checking for two pointers to the same datum
- * is valid here. And faster.
- */
- if (cmd->cmd->name != cmd->end_token) {
- return ap_pstrcat(cmd->pool, "Expected ", cmd->end_token, " but saw ",
- cmd->cmd->name, NULL);
- }
- return cmd->end_token;
-}
-
-/*
- * Report a missing-'>' syntax error.
- */
-static char *unclosed_directive(cmd_parms *cmd)
-{
- return ap_pstrcat(cmd->pool, cmd->cmd->name,
- "> directive missing closing '>'", NULL);
-}
-
-static const char *dirsection(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *errmsg;
- char *endp = strrchr(arg, '>');
- int old_overrides = cmd->override;
- char *old_path = cmd->path;
- core_dir_config *conf;
- void *new_dir_conf = ap_create_per_dir_config(cmd->pool);
- regex_t *r = NULL;
- const char *old_end_token;
- const command_rec *thiscmd = cmd->cmd;
-
- const char *err = ap_check_cmd_context(cmd,
- NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- if (endp == NULL) {
- return unclosed_directive(cmd);
- }
-
- *endp = '\0';
-
- cmd->path = ap_getword_conf(cmd->pool, &arg);
- cmd->override = OR_ALL|ACCESS_CONF;
-
- if (thiscmd->cmd_data) { /* <DirectoryMatch> */
- r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
- }
- else if (!strcmp(cmd->path, "~")) {
- cmd->path = ap_getword_conf(cmd->pool, &arg);
- r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
- }
- else {
- /* Ensure that the pathname is canonical */
- cmd->path = ap_os_canonical_filename(cmd->pool, cmd->path);
- }
-
- old_end_token = cmd->end_token;
- cmd->end_token = thiscmd->cmd_data ? end_directorymatch_section : end_directory_section;
- errmsg = ap_srm_command_loop(cmd, new_dir_conf);
- if (errmsg == NULL) {
- errmsg = missing_endsection(cmd, 1);
- }
- cmd->end_token = old_end_token;
- if (errmsg != (thiscmd->cmd_data
- ? end_directorymatch_section
- : end_directory_section)) {
- return errmsg;
- }
-
- conf = (core_dir_config *)ap_get_module_config(new_dir_conf, &core_module);
- conf->r = r;
-
- ap_add_per_dir_conf(cmd->server, new_dir_conf);
-
- if (*arg != '\0') {
- return ap_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
- "> arguments not (yet) supported.", NULL);
- }
-
- cmd->path = old_path;
- cmd->override = old_overrides;
-
- return NULL;
-}
-
-static const char *urlsection(cmd_parms *cmd, void *dummy, const char *arg)
-{
- const char *errmsg;
- char *endp = strrchr(arg, '>');
- int old_overrides = cmd->override;
- char *old_path = cmd->path;
- core_dir_config *conf;
- regex_t *r = NULL;
- const char *old_end_token;
- const command_rec *thiscmd = cmd->cmd;
-
- void *new_url_conf = ap_create_per_dir_config(cmd->pool);
-
- const char *err = ap_check_cmd_context(cmd,
- NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- if (endp == NULL) {
- return unclosed_directive(cmd);
- }
-
- *endp = '\0';
-
- cmd->path = ap_getword_conf(cmd->pool, &arg);
- cmd->override = OR_ALL|ACCESS_CONF;
-
- if (thiscmd->cmd_data) { /* <LocationMatch> */
- r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
- }
- else if (!strcmp(cmd->path, "~")) {
- cmd->path = ap_getword_conf(cmd->pool, &arg);
- r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED);
- }
-
- old_end_token = cmd->end_token;
- cmd->end_token = thiscmd->cmd_data ? end_locationmatch_section
- : end_location_section;
- errmsg = ap_srm_command_loop(cmd, new_url_conf);
- if (errmsg == NULL) {
- errmsg = missing_endsection(cmd, 1);
- }
- cmd->end_token = old_end_token;
- if (errmsg != (thiscmd->cmd_data
- ? end_locationmatch_section
- : end_location_section)) {
- return errmsg;
- }
-
- conf = (core_dir_config *)ap_get_module_config(new_url_conf, &core_module);
- conf->d = ap_pstrdup(cmd->pool, cmd->path); /* No mangling, please */
- conf->d_is_fnmatch = ap_is_fnmatch(conf->d) != 0;
- conf->r = r;
-
- ap_add_per_url_conf(cmd->server, new_url_conf);
-
- if (*arg != '\0') {
- return ap_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
- "> arguments not (yet) supported.", NULL);
- }
-
- cmd->path = old_path;
- cmd->override = old_overrides;
-
- return NULL;
-}
-
-static const char *filesection(cmd_parms *cmd, core_dir_config *c,
- const char *arg)
-{
- const char *errmsg;
- char *endp = strrchr(arg, '>');
- int old_overrides = cmd->override;
- char *old_path = cmd->path;
- core_dir_config *conf;
- regex_t *r = NULL;
- const char *old_end_token;
- const command_rec *thiscmd = cmd->cmd;
-
- void *new_file_conf = ap_create_per_dir_config(cmd->pool);
-
- const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT|NOT_IN_LOCATION);
- if (err != NULL) {
- return err;
- }
-
- if (endp == NULL) {
- return unclosed_directive(cmd);
- }
-
- *endp = '\0';
-
- cmd->path = ap_getword_conf(cmd->pool, &arg);
- /* Only if not an .htaccess file */
- if (!old_path) {
- cmd->override = OR_ALL|ACCESS_CONF;
- }
-
- if (thiscmd->cmd_data) { /* <FilesMatch> */
- r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
- }
- else if (!strcmp(cmd->path, "~")) {
- cmd->path = ap_getword_conf(cmd->pool, &arg);
- r = ap_pregcomp(cmd->pool, cmd->path, REG_EXTENDED|USE_ICASE);
- }
- else {
- /* Ensure that the pathname is canonical */
- cmd->path = ap_os_canonical_filename(cmd->pool, cmd->path);
- }
-
- old_end_token = cmd->end_token;
- cmd->end_token = thiscmd->cmd_data ? end_filesmatch_section : end_files_section;
- errmsg = ap_srm_command_loop(cmd, new_file_conf);
- if (errmsg == NULL) {
- errmsg = missing_endsection(cmd, 1);
- }
- cmd->end_token = old_end_token;
- if (errmsg != (thiscmd->cmd_data
- ? end_filesmatch_section
- : end_files_section)) {
- return errmsg;
- }
-
- conf = (core_dir_config *)ap_get_module_config(new_file_conf,
- &core_module);
- conf->d = cmd->path;
- conf->d_is_fnmatch = ap_is_fnmatch(conf->d) != 0;
- conf->r = r;
-
- ap_add_file_conf(c, new_file_conf);
-
- if (*arg != '\0') {
- return ap_pstrcat(cmd->pool, "Multiple ", thiscmd->name,
- "> arguments not (yet) supported.", NULL);
- }
-
- cmd->path = old_path;
- cmd->override = old_overrides;
-
- return NULL;
-}
-
-/* XXX: NB: Currently, we have no way of checking
- * whether <IfModule> sections are closed properly.
- * Extra (redundant, unpaired) </IfModule> directives are
- * simply silently ignored.
- */
-static const char *end_ifmod(cmd_parms *cmd, void *dummy)
-{
- return NULL;
-}
-
-static const char *start_ifmod(cmd_parms *cmd, void *dummy, char *arg)
-{
- char *endp = strrchr(arg, '>');
- char l[MAX_STRING_LEN];
- int not = (arg[0] == '!');
- module *found;
- int nest = 1;
-
- if (endp == NULL) {
- return unclosed_directive(cmd);
- }
-
- *endp = '\0';
-
- if (not) {
- arg++;
- }
-
- found = ap_find_linked_module(arg);
-
- if ((!not && found) || (not && !found)) {
- return NULL;
- }
-
- while (nest && !(ap_cfg_getline(l, MAX_STRING_LEN, cmd->config_file))) {
- if (!strncasecmp(l, "<IfModule", 9)) {
- nest++;
- }
- if (!strcasecmp(l, "</IfModule>")) {
- nest--;
- }
- }
-
- if (nest) {
- cmd->end_token = end_ifmodule_section;
- return missing_endsection(cmd, nest);
- }
- return NULL;
-}
-
-API_EXPORT(int) ap_exists_config_define(char *name)
-{
- char **defines;
- int i;
-
- defines = (char **)ap_server_config_defines->elts;
- for (i = 0; i < ap_server_config_defines->nelts; i++) {
- if (strcmp(defines[i], name) == 0) {
- return 1;
- }
- }
- return 0;
-}
-
-static const char *end_ifdefine(cmd_parms *cmd, void *dummy)
-{
- return NULL;
-}
-
-static const char *start_ifdefine(cmd_parms *cmd, void *dummy, char *arg)
-{
- char *endp;
- char l[MAX_STRING_LEN];
- int defined;
- int not = 0;
- int nest = 1;
-
- endp = strrchr(arg, '>');
- if (endp == NULL) {
- return unclosed_directive(cmd);
- }
-
- *endp = '\0';
-
- if (arg[0] == '!') {
- not = 1;
- arg++;
- }
-
- defined = ap_exists_config_define(arg);
-
- if ((!not && defined) || (not && !defined)) {
- return NULL;
- }
-
- while (nest && !(ap_cfg_getline(l, MAX_STRING_LEN, cmd->config_file))) {
- if (!strncasecmp(l, "<IfDefine", 9)) {
- nest++;
- }
- if (!strcasecmp(l, "</IfDefine>")) {
- nest--;
- }
- }
- if (nest) {
- cmd->end_token = end_ifdefine_section;
- return missing_endsection(cmd, nest);
- }
- return NULL;
-}
-
-/* httpd.conf commands... beginning with the <VirtualHost> business */
-
-static const char *virtualhost_section(cmd_parms *cmd, void *dummy, char *arg)
-{
- server_rec *main_server = cmd->server, *s;
- const char *errmsg;
- char *endp = strrchr(arg, '>');
- ap_context_t *p = cmd->pool, *ptemp = cmd->temp_pool;
- const char *old_end_token;
-
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (endp == NULL) {
- return unclosed_directive(cmd);
- }
-
- *endp = '\0';
-
- /* FIXME: There's another feature waiting to happen here -- since you
- can now put multiple addresses/names on a single <VirtualHost>
- you might want to use it to group common definitions and then
- define other "subhosts" with their individual differences. But
- personally I'd rather just do it with a macro preprocessor. -djg */
- if (main_server->is_virtual) {
- return "<VirtualHost> doesn't nest!";
- }
-
- errmsg = ap_init_virtual_host(p, arg, main_server, &s);
- if (errmsg) {
- return errmsg;
- }
-
- s->next = main_server->next;
- main_server->next = s;
-
- s->defn_name = cmd->config_file->name;
- s->defn_line_number = cmd->config_file->line_number;
-
- old_end_token = cmd->end_token;
- cmd->end_token = end_virtualhost_section;
- cmd->server = s;
- errmsg = ap_srm_command_loop(cmd, s->lookup_defaults);
- cmd->server = main_server;
- if (errmsg == NULL) {
- errmsg = missing_endsection(cmd, 1);
- }
- cmd->end_token = old_end_token;
-
- if (s->srm_confname) {
- ap_process_resource_config(s, s->srm_confname, p, ptemp);
- }
-
- if (s->access_confname) {
- ap_process_resource_config(s, s->access_confname, p, ptemp);
- }
-
- if (errmsg == end_virtualhost_section) {
- return NULL;
- }
- return errmsg;
-}
-
-static const char *set_server_alias(cmd_parms *cmd, void *dummy,
- const char *arg)
-{
- if (!cmd->server->names) {
- return "ServerAlias only used in <VirtualHost>";
- }
- while (*arg) {
- char **item, *name = ap_getword_conf(cmd->pool, &arg);
- if (ap_is_matchexp(name)) {
- item = (char **)ap_push_array(cmd->server->wild_names);
- }
- else {
- item = (char **)ap_push_array(cmd->server->names);
- }
- *item = name;
- }
- return NULL;
-}
-
-static const char *add_module_command(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (!ap_add_named_module(arg)) {
- return ap_pstrcat(cmd->pool, "Cannot add module via name '", arg,
- "': not in list of loaded modules", NULL);
- }
- return NULL;
-}
-
-static const char *clear_module_list_command(cmd_parms *cmd, void *dummy)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_clear_module_list();
- return NULL;
-}
-
-static const char *set_server_string_slot(cmd_parms *cmd, void *dummy,
- char *arg)
-{
- /* This one's pretty generic... */
-
- int offset = (int)(long)cmd->info;
- char *struct_ptr = (char *)cmd->server;
-
- const char *err = ap_check_cmd_context(cmd,
- NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- *(char **)(struct_ptr + offset) = arg;
- return NULL;
-}
-
-static const char *server_port(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- int port;
-
- if (err != NULL) {
- return err;
- }
- port = atoi(arg);
- if (port <= 0 || port >= 65536) { /* 65536 == 1<<16 */
- return ap_pstrcat(cmd->temp_pool, "The port number \"", arg,
- "\" is outside the appropriate range "
- "(i.e., 1..65535).", NULL);
- }
- cmd->server->port = port;
- return NULL;
-}
-
-static const char *set_signature_flag(cmd_parms *cmd, core_dir_config *d,
- char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- if (strcasecmp(arg, "On") == 0) {
- d->server_signature = srv_sig_on;
- }
- else if (strcasecmp(arg, "Off") == 0) {
- d->server_signature = srv_sig_off;
- }
- else if (strcasecmp(arg, "EMail") == 0) {
- d->server_signature = srv_sig_withmail;
- }
- else {
- return "ServerSignature: use one of: off | on | email";
- }
- return NULL;
-}
-
-static const char *set_server_root(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
-
- if (err != NULL) {
- return err;
- }
-
- arg = ap_os_canonical_filename(cmd->pool, arg);
-
- if (!ap_is_directory(arg)) {
- return "ServerRoot must be a valid directory";
- }
- ap_server_root = arg;
- return NULL;
-}
-
-static const char *set_timeout(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- cmd->server->timeout = atoi(arg);
- return NULL;
-}
-
-static const char *set_keep_alive_timeout(cmd_parms *cmd, void *dummy,
- char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- cmd->server->keep_alive_timeout = atoi(arg);
- return NULL;
-}
-
-static const char *set_keep_alive(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- /* We've changed it to On/Off, but used to use numbers
- * so we accept anything but "Off" or "0" as "On"
- */
- if (!strcasecmp(arg, "off") || !strcmp(arg, "0")) {
- cmd->server->keep_alive = 0;
- }
- else {
- cmd->server->keep_alive = 1;
- }
- return NULL;
-}
-
-static const char *set_keep_alive_max(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- cmd->server->keep_alive_max = atoi(arg);
- return NULL;
-}
-
-static const char *set_idcheck(cmd_parms *cmd, core_dir_config *d, int arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- d->do_rfc1413 = arg != 0;
- return NULL;
-}
-
-static const char *set_hostname_lookups(cmd_parms *cmd, core_dir_config *d,
- char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- if (!strcasecmp(arg, "on")) {
- d->hostname_lookups = HOSTNAME_LOOKUP_ON;
- }
- else if (!strcasecmp(arg, "off")) {
- d->hostname_lookups = HOSTNAME_LOOKUP_OFF;
- }
- else if (!strcasecmp(arg, "double")) {
- d->hostname_lookups = HOSTNAME_LOOKUP_DOUBLE;
- }
- else {
- return "parameter must be 'on', 'off', or 'double'";
- }
- return NULL;
-}
-
-static const char *set_serverpath(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- cmd->server->path = arg;
- cmd->server->pathlen = strlen(arg);
- return NULL;
-}
-
-static const char *set_content_md5(cmd_parms *cmd, core_dir_config *d, int arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- d->content_md5 = arg != 0;
- return NULL;
-}
-
-static const char *set_use_canonical_name(cmd_parms *cmd, core_dir_config *d,
- char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- if (strcasecmp(arg, "on") == 0) {
- d->use_canonical_name = USE_CANONICAL_NAME_ON;
- }
- else if (strcasecmp(arg, "off") == 0) {
- d->use_canonical_name = USE_CANONICAL_NAME_OFF;
- }
- else if (strcasecmp(arg, "dns") == 0) {
- d->use_canonical_name = USE_CANONICAL_NAME_DNS;
- }
- else {
- return "parameter must be 'on', 'off', or 'dns'";
- }
- return NULL;
-}
-
-
-static const char *include_config (cmd_parms *cmd, void *dummy, char *name)
-{
- ap_process_resource_config(cmd->server,
- ap_server_root_relative(cmd->pool, name),
- cmd->pool, cmd->temp_pool);
- return NULL;
-}
-
-static const char *set_loglevel(cmd_parms *cmd, void *dummy, const char *arg)
-{
- char *str;
-
- const char *err = ap_check_cmd_context(cmd,
- NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- if ((str = ap_getword_conf(cmd->pool, &arg))) {
- if (!strcasecmp(str, "emerg")) {
- cmd->server->loglevel = APLOG_EMERG;
- }
- else if (!strcasecmp(str, "alert")) {
- cmd->server->loglevel = APLOG_ALERT;
- }
- else if (!strcasecmp(str, "crit")) {
- cmd->server->loglevel = APLOG_CRIT;
- }
- else if (!strcasecmp(str, "error")) {
- cmd->server->loglevel = APLOG_ERR;
- }
- else if (!strcasecmp(str, "warn")) {
- cmd->server->loglevel = APLOG_WARNING;
- }
- else if (!strcasecmp(str, "notice")) {
- cmd->server->loglevel = APLOG_NOTICE;
- }
- else if (!strcasecmp(str, "info")) {
- cmd->server->loglevel = APLOG_INFO;
- }
- else if (!strcasecmp(str, "debug")) {
- cmd->server->loglevel = APLOG_DEBUG;
- }
- else {
- return "LogLevel requires level keyword: one of "
- "emerg/alert/crit/error/warn/notice/info/debug";
- }
- }
- else {
- return "LogLevel requires level keyword";
- }
-
- return NULL;
-}
-
-API_EXPORT(const char *) ap_psignature(const char *prefix, request_rec *r)
-{
- char sport[20];
- core_dir_config *conf;
-
- conf = (core_dir_config *)ap_get_module_config(r->per_dir_config,
- &core_module);
- if ((conf->server_signature == srv_sig_off)
- || (conf->server_signature == srv_sig_unset)) {
- return "";
- }
-
- ap_snprintf(sport, sizeof sport, "%u", (unsigned) ap_get_server_port(r));
-
- if (conf->server_signature == srv_sig_withmail) {
- return ap_pstrcat(r->pool, prefix, "<ADDRESS>" AP_SERVER_BASEVERSION
- " Server at <A HREF=\"mailto:",
- r->server->server_admin, "\">",
- ap_get_server_name(r), "</A> Port ", sport,
- "</ADDRESS>\n", NULL);
- }
- return ap_pstrcat(r->pool, prefix, "<ADDRESS>" AP_SERVER_BASEVERSION
- " Server at ", ap_get_server_name(r), " Port ", sport,
- "</ADDRESS>\n", NULL);
-}
-
-/*
- * Load an authorisation realm into our location configuration, applying the
- * usual rules that apply to realms.
- */
-static const char *set_authname(cmd_parms *cmd, void *mconfig, char *word1)
-{
- core_dir_config *aconfig = (core_dir_config *)mconfig;
-
- aconfig->ap_auth_name = ap_escape_quotes(cmd->pool, word1);
- return NULL;
-}
-
-#ifdef _OSD_POSIX /* BS2000 Logon Passwd file */
-static const char *set_bs2000_account(cmd_parms *cmd, void *dummy, char *name)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- return os_set_account(cmd->pool, name);
-}
-#endif /*_OSD_POSIX*/
-
-/*
- * Handle a request to include the server's OS platform in the Server
- * response header field (the ServerTokens directive). Unfortunately
- * this requires a new global in order to communicate the setting back to
- * http_main so it can insert the information in the right place in the
- * string.
- */
-
-static const char *set_serv_tokens(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- /* TODO: reimplement the server token stuff. */
-#if 0
- if (!strcasecmp(arg, "OS")) {
- ap_server_tokens = SrvTk_OS;
- }
- else if (!strcasecmp(arg, "Min") || !strcasecmp(arg, "Minimal")) {
- ap_server_tokens = SrvTk_MIN;
- }
- else {
- ap_server_tokens = SrvTk_FULL;
- }
-#endif
- return NULL;
-}
-
-static const char *set_limit_req_line(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd,
- NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- int lim;
-
- if (err != NULL) {
- return err;
- }
- lim = atoi(arg);
- if (lim < 0) {
- return ap_pstrcat(cmd->temp_pool, "LimitRequestLine \"", arg,
- "\" must be a non-negative integer", NULL);
- }
- if (lim > DEFAULT_LIMIT_REQUEST_LINE) {
- return ap_psprintf(cmd->temp_pool, "LimitRequestLine \"%s\" "
- "must not exceed the precompiled maximum of %d",
- arg, DEFAULT_LIMIT_REQUEST_LINE);
- }
- cmd->server->limit_req_line = lim;
- return NULL;
-}
-
-static const char *set_limit_req_fieldsize(cmd_parms *cmd, void *dummy,
- char *arg)
-{
- const char *err = ap_check_cmd_context(cmd,
- NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- int lim;
-
- if (err != NULL) {
- return err;
- }
- lim = atoi(arg);
- if (lim < 0) {
- return ap_pstrcat(cmd->temp_pool, "LimitRequestFieldsize \"", arg,
- "\" must be a non-negative integer (0 = no limit)",
- NULL);
- }
- if (lim > DEFAULT_LIMIT_REQUEST_FIELDSIZE) {
- return ap_psprintf(cmd->temp_pool, "LimitRequestFieldsize \"%s\" "
- "must not exceed the precompiled maximum of %d",
- arg, DEFAULT_LIMIT_REQUEST_FIELDSIZE);
- }
- cmd->server->limit_req_fieldsize = lim;
- return NULL;
-}
-
-static const char *set_limit_req_fields(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd,
- NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT);
- int lim;
-
- if (err != NULL) {
- return err;
- }
- lim = atoi(arg);
- if (lim < 0) {
- return ap_pstrcat(cmd->temp_pool, "LimitRequestFields \"", arg,
- "\" must be a non-negative integer (0 = no limit)",
- NULL);
- }
- cmd->server->limit_req_fields = lim;
- return NULL;
-}
-
-static const char *set_limit_req_body(cmd_parms *cmd, core_dir_config *conf,
- char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, NOT_IN_LIMIT);
- if (err != NULL) {
- return err;
- }
-
- /* WTF: If strtoul is not portable, then write a replacement.
- * Instead we have an idiotic define in httpd.h that prevents
- * it from being used even when it is available. Sheesh.
- */
- conf->limit_req_body = (unsigned long)strtol(arg, (char **)NULL, 10);
- return NULL;
-}
-
-#ifdef WIN32
-static const char *set_interpreter_source(cmd_parms *cmd, core_dir_config *d,
- char *arg)
-{
- if (!strcasecmp(arg, "registry")) {
- d->script_interpreter_source = INTERPRETER_SOURCE_REGISTRY;
- } else if (!strcasecmp(arg, "script")) {
- d->script_interpreter_source = INTERPRETER_SOURCE_SHEBANG;
- } else {
- d->script_interpreter_source = INTERPRETER_SOURCE_SHEBANG;
- }
- return NULL;
-}
-#endif
-
-/* Note --- ErrorDocument will now work from .htaccess files.
- * The AllowOverride of Fileinfo allows webmasters to turn it off
- */
-
-static const command_rec core_cmds[] = {
-
-/* Old access config file commands */
-
-{ "<Directory", dirsection, NULL, RSRC_CONF, RAW_ARGS,
- "Container for directives affecting resources located in the specified "
- "directories" },
-{ end_directory_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS,
- "Marks end of <Directory>" },
-{ "<Location", urlsection, NULL, RSRC_CONF, RAW_ARGS,
- "Container for directives affecting resources accessed through the "
- "specified URL paths" },
-{ end_location_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS,
- "Marks end of <Location>" },
-{ "<VirtualHost", virtualhost_section, NULL, RSRC_CONF, RAW_ARGS,
- "Container to map directives to a particular virtual host, takes one or "
- "more host addresses" },
-{ end_virtualhost_section, end_nested_section, NULL, RSRC_CONF, NO_ARGS,
- "Marks end of <VirtualHost>" },
-{ "<Files", filesection, NULL, OR_ALL, RAW_ARGS, "Container for directives "
- "affecting files matching specified patterns" },
-{ end_files_section, end_nested_section, NULL, OR_ALL, NO_ARGS,
- "Marks end of <Files>" },
-{ "<Limit", ap_limit_section, NULL, OR_ALL, RAW_ARGS, "Container for "
- "authentication directives when accessed using specified HTTP methods" },
-{ "</Limit>", endlimit_section, NULL, OR_ALL, NO_ARGS,
- "Marks end of <Limit>" },
-{ "<LimitExcept", ap_limit_section, (void*)1, OR_ALL, RAW_ARGS,
- "Container for authentication directives to be applied when any HTTP "
- "method other than those specified is used to access the resource" },
-{ "</LimitExcept>", endlimit_section, (void*)1, OR_ALL, NO_ARGS,
- "Marks end of <LimitExcept>" },
-{ "<IfModule", start_ifmod, NULL, OR_ALL, TAKE1,
- "Container for directives based on existance of specified modules" },
-{ end_ifmodule_section, end_ifmod, NULL, OR_ALL, NO_ARGS,
- "Marks end of <IfModule>" },
-{ "<IfDefine", start_ifdefine, NULL, OR_ALL, TAKE1,
- "Container for directives based on existance of command line defines" },
-{ end_ifdefine_section, end_ifdefine, NULL, OR_ALL, NO_ARGS,
- "Marks end of <IfDefine>" },
-{ "<DirectoryMatch", dirsection, (void*)1, RSRC_CONF, RAW_ARGS,
- "Container for directives affecting resources located in the "
- "specified directories" },
-{ end_directorymatch_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS,
- "Marks end of <DirectoryMatch>" },
-{ "<LocationMatch", urlsection, (void*)1, RSRC_CONF, RAW_ARGS,
- "Container for directives affecting resources accessed through the "
- "specified URL paths" },
-{ end_locationmatch_section, end_nested_section, NULL, ACCESS_CONF, NO_ARGS,
- "Marks end of <LocationMatch>" },
-{ "<FilesMatch", filesection, (void*)1, OR_ALL, RAW_ARGS,
- "Container for directives affecting files matching specified patterns" },
-{ end_filesmatch_section, end_nested_section, NULL, OR_ALL, NO_ARGS,
- "Marks end of <FilesMatch>" },
-{ "AuthType", ap_set_string_slot,
- (void*)XtOffsetOf(core_dir_config, ap_auth_type), OR_AUTHCFG, TAKE1,
- "An HTTP authorization type (e.g., \"Basic\")" },
-{ "AuthName", set_authname, NULL, OR_AUTHCFG, TAKE1,
- "The authentication realm (e.g. \"Members Only\")" },
-{ "Require", require, NULL, OR_AUTHCFG, RAW_ARGS,
- "Selects which authenticated users or groups may access a protected space" },
-{ "Satisfy", satisfy, NULL, OR_AUTHCFG, TAKE1,
- "access policy if both allow and require used ('all' or 'any')" },
-#ifdef GPROF
-{ "GprofDir", set_gprof_dir, NULL, RSRC_CONF, TAKE1,
- "Directory to plop gmon.out files" },
-#endif
-
-/* Old resource config file commands */
-
-{ "AccessFileName", set_access_name, NULL, RSRC_CONF, RAW_ARGS,
- "Name(s) of per-directory config files (default: .htaccess)" },
-{ "DocumentRoot", set_document_root, NULL, RSRC_CONF, TAKE1,
- "Root directory of the document tree" },
-{ "ErrorDocument", set_error_document, NULL, OR_FILEINFO, RAW_ARGS,
- "Change responses for HTTP errors" },
-{ "AllowOverride", set_override, NULL, ACCESS_CONF, RAW_ARGS,
- "Controls what groups of directives can be configured by per-directory "
- "config files" },
-{ "Options", set_options, NULL, OR_OPTIONS, RAW_ARGS,
- "Set a number of attributes for a given directory" },
-{ "DefaultType", ap_set_string_slot,
- (void*)XtOffsetOf (core_dir_config, ap_default_type),
- OR_FILEINFO, TAKE1, "the default MIME type for untypable files" },
-
-/* Old server config file commands */
-
-{ "Port", server_port, NULL, RSRC_CONF, TAKE1, "A TCP port number"},
-{ "HostnameLookups", set_hostname_lookups, NULL, ACCESS_CONF|RSRC_CONF, TAKE1,
- "\"on\" to enable, \"off\" to disable reverse DNS lookups, or \"double\" to "
- "enable double-reverse DNS lookups" },
-{ "ServerAdmin", set_server_string_slot,
- (void *)XtOffsetOf (server_rec, server_admin), RSRC_CONF, TAKE1,
- "The email address of the server administrator" },
-{ "ServerName", set_server_string_slot,
- (void *)XtOffsetOf (server_rec, server_hostname), RSRC_CONF, TAKE1,
- "The hostname of the server" },
-{ "ServerSignature", set_signature_flag, NULL, OR_ALL, TAKE1,
- "En-/disable server signature (on|off|email)" },
-{ "ServerRoot", set_server_root, NULL, RSRC_CONF, TAKE1,
- "Common directory of server-related files (logs, confs, etc.)" },
-{ "ErrorLog", set_server_string_slot,
- (void *)XtOffsetOf (server_rec, error_fname), RSRC_CONF, TAKE1,
- "The filename of the error log" },
-{ "AccessConfig", set_server_string_slot,
- (void *)XtOffsetOf (server_rec, access_confname), RSRC_CONF, TAKE1,
- "The filename of the access config file" },
-{ "ResourceConfig", set_server_string_slot,
- (void *)XtOffsetOf (server_rec, srm_confname), RSRC_CONF, TAKE1,
- "The filename of the resource config file" },
-{ "ServerAlias", set_server_alias, NULL, RSRC_CONF, RAW_ARGS,
- "A name or names alternately used to access the server" },
-{ "ServerPath", set_serverpath, NULL, RSRC_CONF, TAKE1,
- "The pathname the server can be reached at" },
-{ "Timeout", set_timeout, NULL, RSRC_CONF, TAKE1, "Timeout duration (sec)" },
-{ "KeepAliveTimeout", set_keep_alive_timeout, NULL, RSRC_CONF, TAKE1,
- "Keep-Alive timeout duration (sec)"},
-{ "MaxKeepAliveRequests", set_keep_alive_max, NULL, RSRC_CONF, TAKE1,
- "Maximum number of Keep-Alive requests per connection, or 0 for infinite" },
-{ "KeepAlive", set_keep_alive, NULL, RSRC_CONF, TAKE1,
- "Whether persistent connections should be On or Off" },
-{ "IdentityCheck", set_idcheck, NULL, RSRC_CONF|ACCESS_CONF, FLAG,
- "Enable identd (RFC 1413) user lookups - SLOW" },
-{ "ContentDigest", set_content_md5, NULL, OR_OPTIONS,
- FLAG, "whether or not to send a Content-MD5 header with each request" },
-{ "UseCanonicalName", set_use_canonical_name, NULL,
- RSRC_CONF|ACCESS_CONF, TAKE1,
- "How to work out the ServerName : Port when constructing URLs" },
-/* TODOC: MaxServers is deprecated */
-/* TODOC: ServersSafetyLimit is deprecated */
-/* TODO: RlimitFoo should all be part of mod_cgi, not in the core */
-/* TODOC: BindAddress deprecated */
-{ "AddModule", add_module_command, NULL, RSRC_CONF, ITERATE,
- "The name of a module" },
-{ "ClearModuleList", clear_module_list_command, NULL, RSRC_CONF, NO_ARGS,
- NULL },
-/* TODO: ListenBacklog in MPM */
-{ "Include", include_config, NULL, (RSRC_CONF | ACCESS_CONF), TAKE1,
- "Name of the config file to be included" },
-{ "LogLevel", set_loglevel, NULL, RSRC_CONF, TAKE1,
- "Level of verbosity in error logging" },
-{ "NameVirtualHost", ap_set_name_virtual_host, NULL, RSRC_CONF, TAKE1,
- "A numeric IP address:port, or the name of a host" },
-#ifdef _OSD_POSIX
-{ "BS2000Account", set_bs2000_account, NULL, RSRC_CONF, TAKE1,
- "Name of server User's bs2000 logon account name" },
-#endif
-#ifdef WIN32
-{ "ScriptInterpreterSource", set_interpreter_source, NULL, OR_FILEINFO, TAKE1,
- "Where to find interpreter to run Win32 scripts (Registry or script shebang line)" },
-#endif
-{ "ServerTokens", set_serv_tokens, NULL, RSRC_CONF, TAKE1,
- "Determine tokens displayed in the Server: header - Min(imal), OS or Full" },
-{ "LimitRequestLine", set_limit_req_line, NULL, RSRC_CONF, TAKE1,
- "Limit on maximum size of an HTTP request line"},
-{ "LimitRequestFieldsize", set_limit_req_fieldsize, NULL, RSRC_CONF, TAKE1,
- "Limit on maximum size of an HTTP request header field"},
-{ "LimitRequestFields", set_limit_req_fields, NULL, RSRC_CONF, TAKE1,
- "Limit (0 = unlimited) on max number of header fields in a request message"},
-{ "LimitRequestBody", set_limit_req_body,
- (void*)XtOffsetOf(core_dir_config, limit_req_body),
- OR_ALL, TAKE1,
- "Limit (in bytes) on maximum size of request message body" },
-{ NULL }
-};
-
-/*****************************************************************
- *
- * Core handlers for various phases of server operation...
- */
-
-static int core_translate(request_rec *r)
-{
- void *sconf = r->server->module_config;
- core_server_config *conf = ap_get_module_config(sconf, &core_module);
-
- if (r->proxyreq) {
- return HTTP_FORBIDDEN;
- }
- if ((r->uri[0] != '/') && strcmp(r->uri, "*")) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid URI in request %s", r->the_request);
- return BAD_REQUEST;
- }
-
- if (r->server->path
- && !strncmp(r->uri, r->server->path, r->server->pathlen)
- && (r->server->path[r->server->pathlen - 1] == '/'
- || r->uri[r->server->pathlen] == '/'
- || r->uri[r->server->pathlen] == '\0')) {
- r->filename = ap_pstrcat(r->pool, conf->ap_document_root,
- (r->uri + r->server->pathlen), NULL);
- }
- else {
- /*
- * Make sure that we do not mess up the translation by adding two
- * /'s in a row. This happens under windows when the document
- * root ends with a /
- */
- if ((conf->ap_document_root[strlen(conf->ap_document_root)-1] == '/')
- && (*(r->uri) == '/')) {
- r->filename = ap_pstrcat(r->pool, conf->ap_document_root, r->uri+1,
- NULL);
- }
- else {
- r->filename = ap_pstrcat(r->pool, conf->ap_document_root, r->uri,
- NULL);
- }
- }
-
- return OK;
-}
-
-static int do_nothing(request_rec *r) { return OK; }
-
-/*
- * Default handler for MIME types without other handlers. Only GET
- * and OPTIONS at this point... anyone who wants to write a generic
- * handler for PUT or POST is free to do so, but it seems unwise to provide
- * any defaults yet... So, for now, we assume that this will always be
- * the last handler called and return 405 or 501.
- */
-
-static int default_handler(request_rec *r)
-{
- core_dir_config *d =
- (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
- int rangestatus, errstatus;
- ap_file_t *fd = NULL;
- ap_status_t status;
-#ifdef USE_MMAP_FILES
- ap_mmap_t *mm = NULL;
-#endif
-#ifdef CHARSET_EBCDIC
- /* To make serving of "raw ASCII text" files easy (they serve faster
- * since they don't have to be converted from EBCDIC), a new
- * "magic" type prefix was invented: text/x-ascii-{plain,html,...}
- * If we detect one of these content types here, we simply correct
- * the type to the real text/{plain,html,...} type. Otherwise, we
- * set a flag that translation is required later on.
- */
- int convert_flag = ap_checkconv(r);
-#endif
-
- /* This handler has no use for a request body (yet), but we still
- * need to read and discard it if the client sent one.
- */
- if ((errstatus = ap_discard_request_body(r)) != OK) {
- return errstatus;
- }
-
- r->allowed |= (1 << M_GET) | (1 << M_OPTIONS);
-
- if (r->method_number == M_INVALID) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid method in request %s", r->the_request);
- return NOT_IMPLEMENTED;
- }
- if (r->method_number == M_OPTIONS) {
- return ap_send_http_options(r);
- }
- if (r->method_number == M_PUT) {
- return METHOD_NOT_ALLOWED;
- }
- if (r->finfo.protection == 0 || (r->path_info && *r->path_info)) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, r,
- "File does not exist: %s",r->path_info ?
- ap_pstrcat(r->pool, r->filename, r->path_info, NULL)
- : r->filename);
- return HTTP_NOT_FOUND;
- }
- if (r->method_number != M_GET) {
- return METHOD_NOT_ALLOWED;
- }
-
- if ((status = ap_open(&fd, r->filename, APR_READ | APR_BINARY, 0, r->pool)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
- "file permissions deny server access: %s", r->filename);
- return FORBIDDEN;
- }
- ap_update_mtime(r, r->finfo.mtime);
- ap_set_last_modified(r);
- ap_set_etag(r);
- ap_table_setn(r->headers_out, "Accept-Ranges", "bytes");
- if (((errstatus = ap_meets_conditions(r)) != OK)
- || (errstatus = ap_set_content_length(r, r->finfo.size))) {
- ap_close(fd);
- return errstatus;
- }
-
-#ifdef USE_MMAP_FILES
- if ((r->finfo.size >= MMAP_THRESHOLD)
- && (r->finfo.size < MMAP_LIMIT)
- && (!r->header_only || (d->content_md5 & 1))) {
- /* we need to protect ourselves in case we die while we've got the
- * file mmapped */
- if (ap_mmap_create(&mm, fd, 0, r->finfo.size, r->pool) != APR_SUCCESS){
- ap_log_rerror(APLOG_MARK, APLOG_CRIT, errno, r,
- "default_handler: mmap failed: %s", r->filename);
- mm = NULL;
- }
- }
- else {
- mm = NULL;
- }
-
- if (mm == NULL) {
-#endif
-
-#ifdef CHARSET_EBCDIC
- if (d->content_md5 & 1) {
- ap_table_setn(r->headers_out, "Content-MD5",
- ap_md5digest(r->pool, fd, convert_flag));
- }
-#else
- if (d->content_md5 & 1) {
- ap_table_setn(r->headers_out, "Content-MD5",
- ap_md5digest(r->pool, fd));
- }
-#endif /* CHARSET_EBCDIC */
-
- rangestatus = ap_set_byterange(r);
-
- ap_send_http_header(r);
-
- if (!r->header_only) {
- if (!rangestatus) {
- ap_send_fd(fd, r);
- }
- else {
- long length;
- ap_off_t offset;
-
- while (ap_each_byterange(r, &offset, &length)) {
- if ((status = ap_seek(fd, APR_SET, &offset)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, status, r->server,
- "error byteserving file: %s", r->filename);
- ap_close(fd);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- ap_send_fd_length(fd, r, length);
- }
- }
- }
-
-#ifdef USE_MMAP_FILES
- }
- else {
- char *addr;
- ap_mmap_offset((void**)&addr, mm ,0);
-
- if (d->content_md5 & 1) {
- AP_MD5_CTX context;
-
- ap_MD5Init(&context);
- ap_MD5Update(&context, addr, (unsigned int)r->finfo.size);
- ap_table_setn(r->headers_out, "Content-MD5",
- ap_md5contextTo64(r->pool, &context));
- }
-
- rangestatus = ap_set_byterange(r);
- ap_send_http_header(r);
-
- if (!r->header_only) {
- if (!rangestatus) {
- ap_send_mmap(mm, r, 0, r->finfo.size);
- }
- else {
- ap_off_t offset;
- long length;
- while (ap_each_byterange(r, &offset, &length)) {
- ap_send_mmap(mm, r, offset, length);
- }
- }
- }
- }
-#endif
-
- ap_close(fd);
- return OK;
-}
-
-static const handler_rec core_handlers[] = {
-{ "*/*", default_handler },
-{ "default-handler", default_handler },
-{ NULL, NULL }
-};
-
-static void core_open_logs(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s)
-{
- ap_open_logs(s, pconf);
-}
-
-static const char *core_method(const request_rec *r)
- { return "http"; }
-
-static unsigned short core_port(const request_rec *r)
- { return DEFAULT_HTTP_PORT; }
-
-static void register_hooks(void)
-{
- ap_hook_translate_name(core_translate,NULL,NULL,HOOK_REALLY_LAST);
- ap_hook_process_connection(ap_process_http_connection,NULL,NULL,
- HOOK_REALLY_LAST);
- ap_hook_http_method(core_method,NULL,NULL,HOOK_REALLY_LAST);
- ap_hook_default_port(core_port,NULL,NULL,HOOK_REALLY_LAST);
- ap_hook_open_logs(core_open_logs,NULL,NULL,HOOK_MIDDLE);
- /* FIXME: I suspect we can eliminate the need for these - Ben */
- ap_hook_type_checker(do_nothing,NULL,NULL,HOOK_REALLY_LAST);
- ap_hook_access_checker(do_nothing,NULL,NULL,HOOK_REALLY_LAST);
-}
-
-API_VAR_EXPORT module core_module = {
- STANDARD20_MODULE_STUFF,
- create_core_dir_config, /* create per-directory config structure */
- merge_core_dir_configs, /* merge per-directory config structures */
- create_core_server_config, /* create per-server config structure */
- merge_core_server_configs, /* merge per-server config structures */
- core_cmds, /* command ap_table_t */
- core_handlers, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c
deleted file mode 100644
index bf6ee4aaf6..0000000000
--- a/modules/http/http_protocol.c
+++ /dev/null
@@ -1,2797 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_protocol.c --- routines which directly communicate with the client.
- *
- * Code originally by Rob McCool; much redone by Robert S. Thau
- * and the Apache Group.
- */
-
-#define CORE_PRIVATE
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_main.h"
-#include "http_request.h"
-#include "http_vhost.h"
-#include "http_log.h" /* For errors detected in basic auth common
- * support code... */
-#include "util_date.h" /* For parseHTTPdate and BAD_DATE */
-#include "mpm_status.h"
-#include <stdarg.h>
-
-HOOK_STRUCT(
- HOOK_LINK(post_read_request)
- HOOK_LINK(log_transaction)
- HOOK_LINK(http_method)
- HOOK_LINK(default_port)
-)
-
-#define SET_BYTES_SENT(r) \
- do { if (r->sent_bodyct) \
- ap_bgetopt (r->connection->client, BO_BYTECT, &r->bytes_sent); \
- } while (0)
-
-
-static int parse_byterange(char *range, long clength, long *start, long *end)
-{
- char *dash = strchr(range, '-');
-
- if (!dash)
- return 0;
-
- if ((dash == range)) {
- /* In the form "-5" */
- *start = clength - atol(dash + 1);
- *end = clength - 1;
- }
- else {
- *dash = '\0';
- dash++;
- *start = atol(range);
- if (*dash)
- *end = atol(dash);
- else /* "5-" */
- *end = clength - 1;
- }
-
- if (*start < 0)
- *start = 0;
-
- if (*end >= clength)
- *end = clength - 1;
-
- if (*start > *end)
- return 0;
-
- return (*start > 0 || *end < clength - 1);
-}
-
-static int internal_byterange(int, long *, request_rec *, const char **,
- ap_off_t *, long *);
-
-API_EXPORT(int) ap_set_byterange(request_rec *r)
-{
- const char *range, *if_range, *match;
- long range_start, range_end;
-
- if (!r->clength || r->assbackwards)
- return 0;
-
- /* Check for Range request-header (HTTP/1.1) or Request-Range for
- * backwards-compatibility with second-draft Luotonen/Franks
- * byte-ranges (e.g. Netscape Navigator 2-3).
- *
- * We support this form, with Request-Range, and (farther down) we
- * send multipart/x-byteranges instead of multipart/byteranges for
- * Request-Range based requests to work around a bug in Netscape
- * Navigator 2-3 and MSIE 3.
- */
-
- if (!(range = ap_table_get(r->headers_in, "Range")))
- range = ap_table_get(r->headers_in, "Request-Range");
-
- if (!range || strncasecmp(range, "bytes=", 6)) {
- return 0;
- }
-
- /* Check the If-Range header for Etag or Date.
- * Note that this check will return false (as required) if either
- * of the two etags are weak.
- */
- if ((if_range = ap_table_get(r->headers_in, "If-Range"))) {
- if (if_range[0] == '"') {
- if (!(match = ap_table_get(r->headers_out, "Etag")) ||
- (strcmp(if_range, match) != 0))
- return 0;
- }
- else if (!(match = ap_table_get(r->headers_out, "Last-Modified")) ||
- (strcmp(if_range, match) != 0))
- return 0;
- }
-
- if (!strchr(range, ',')) {
- /* A single range */
- if (!parse_byterange(ap_pstrdup(r->pool, range + 6), r->clength,
- &range_start, &range_end))
- return 0;
-
- r->byterange = 1;
-
- ap_table_setn(r->headers_out, "Content-Range",
- ap_psprintf(r->pool, "bytes %ld-%ld/%ld",
- range_start, range_end, r->clength));
- ap_table_setn(r->headers_out, "Content-Length",
- ap_psprintf(r->pool, "%ld", range_end - range_start + 1));
- }
- else {
- /* a multiple range */
- const char *r_range = ap_pstrdup(r->pool, range + 6);
- long tlength = 0;
-
- r->byterange = 2;
- r->boundary = ap_psprintf(r->pool, "%lx%lx",
- r->request_time, (long) getpid());
- while (internal_byterange(0, &tlength, r, &r_range, NULL, NULL));
- ap_table_setn(r->headers_out, "Content-Length",
- ap_psprintf(r->pool, "%ld", tlength));
- }
-
- r->status = PARTIAL_CONTENT;
- r->range = range + 6;
-
- return 1;
-}
-
-API_EXPORT(int) ap_each_byterange(request_rec *r, ap_off_t *offset,
- long *length)
-{
- return internal_byterange(1, NULL, r, &r->range, offset, length);
-}
-
-/* If this function is called with realreq=1, it will spit out
- * the correct headers for a byterange chunk, and set offset and
- * length to the positions they should be.
- *
- * If it is called with realreq=0, it will add to tlength the length
- * it *would* have used with realreq=1.
- *
- * Either case will return 1 if it should be called again, and 0
- * when done.
- */
-static int internal_byterange(int realreq, long *tlength, request_rec *r,
- const char **r_range, ap_off_t *offset,
- long *length)
-{
- long range_start, range_end;
- char *range;
-
- if (!**r_range) {
- if (r->byterange > 1) {
- if (realreq)
- ap_rvputs(r, "\015\012--", r->boundary, "--\015\012", NULL);
- else
- *tlength += 4 + strlen(r->boundary) + 4;
- }
- return 0;
- }
-
- range = ap_getword(r->pool, r_range, ',');
- if (!parse_byterange(range, r->clength, &range_start, &range_end))
- /* Skip this one */
- return internal_byterange(realreq, tlength, r, r_range, offset,
- length);
-
- if (r->byterange > 1) {
- const char *ct = r->content_type ? r->content_type : ap_default_type(r);
- char ts[MAX_STRING_LEN];
-
- ap_snprintf(ts, sizeof(ts), "%ld-%ld/%ld", range_start, range_end,
- r->clength);
- if (realreq)
- ap_rvputs(r, "\015\012--", r->boundary, "\015\012Content-type: ",
- ct, "\015\012Content-range: bytes ", ts, "\015\012\015\012",
- NULL);
- else
- *tlength += 4 + strlen(r->boundary) + 16 + strlen(ct) + 23 +
- strlen(ts) + 4;
- }
-
- if (realreq) {
- *offset = range_start;
- *length = range_end - range_start + 1;
- }
- else {
- *tlength += range_end - range_start + 1;
- }
- return 1;
-}
-
-API_EXPORT(int) ap_set_content_length(request_rec *r, long clength)
-{
- r->clength = clength;
- ap_table_setn(r->headers_out, "Content-Length", ap_psprintf(r->pool, "%ld", clength));
- return 0;
-}
-
-API_EXPORT(int) ap_set_keepalive(request_rec *r)
-{
- int ka_sent = 0;
- int wimpy = ap_find_token(r->pool,
- ap_table_get(r->headers_out, "Connection"), "close");
- const char *conn = ap_table_get(r->headers_in, "Connection");
-
- /* The following convoluted conditional determines whether or not
- * the current connection should remain persistent after this response
- * (a.k.a. HTTP Keep-Alive) and whether or not the output message
- * body should use the HTTP/1.1 chunked transfer-coding. In English,
- *
- * IF we have not marked this connection as errored;
- * and the response body has a defined length due to the status code
- * being 304 or 204, the request method being HEAD, already
- * having defined Content-Length or Transfer-Encoding: chunked, or
- * the request version being HTTP/1.1 and thus capable of being set
- * as chunked [we know the (r->chunked = 1) side-effect is ugly];
- * and the server configuration enables keep-alive;
- * and the server configuration has a reasonable inter-request timeout;
- * and there is no maximum # requests or the max hasn't been reached;
- * and the response status does not require a close;
- * and the response generator has not already indicated close;
- * and the client did not request non-persistence (Connection: close);
- * and we haven't been configured to ignore the buggy twit
- * or they're a buggy twit coming through a HTTP/1.1 proxy
- * and the client is requesting an HTTP/1.0-style keep-alive
- * or the client claims to be HTTP/1.1 compliant (perhaps a proxy);
- * THEN we can be persistent, which requires more headers be output.
- *
- * Note that the condition evaluation order is extremely important.
- */
- if ((r->connection->keepalive != -1) &&
- ((r->status == HTTP_NOT_MODIFIED) ||
- (r->status == HTTP_NO_CONTENT) ||
- r->header_only ||
- ap_table_get(r->headers_out, "Content-Length") ||
- ap_find_last_token(r->pool,
- ap_table_get(r->headers_out, "Transfer-Encoding"),
- "chunked") ||
- ((r->proto_num >= HTTP_VERSION(1,1)) &&
- (r->chunked = 1))) && /* THIS CODE IS CORRECT, see comment above. */
- r->server->keep_alive &&
- (r->server->keep_alive_timeout > 0) &&
- ((r->server->keep_alive_max == 0) ||
- (r->server->keep_alive_max > r->connection->keepalives)) &&
- !ap_status_drops_connection(r->status) &&
- !wimpy &&
- !ap_find_token(r->pool, conn, "close") &&
- (!ap_table_get(r->subprocess_env, "nokeepalive") ||
- ap_table_get(r->headers_in, "Via")) &&
- ((ka_sent = ap_find_token(r->pool, conn, "keep-alive")) ||
- (r->proto_num >= HTTP_VERSION(1,1)))
- ) {
- int left = r->server->keep_alive_max - r->connection->keepalives;
-
- r->connection->keepalive = 1;
- r->connection->keepalives++;
-
- /* If they sent a Keep-Alive token, send one back */
- if (ka_sent) {
- if (r->server->keep_alive_max)
- ap_table_setn(r->headers_out, "Keep-Alive",
- ap_psprintf(r->pool, "timeout=%d, max=%d",
- r->server->keep_alive_timeout, left));
- else
- ap_table_setn(r->headers_out, "Keep-Alive",
- ap_psprintf(r->pool, "timeout=%d",
- r->server->keep_alive_timeout));
- ap_table_mergen(r->headers_out, "Connection", "Keep-Alive");
- }
-
- return 1;
- }
-
- /* Otherwise, we need to indicate that we will be closing this
- * connection immediately after the current response.
- *
- * We only really need to send "close" to HTTP/1.1 clients, but we
- * always send it anyway, because a broken proxy may identify itself
- * as HTTP/1.0, but pass our request along with our HTTP/1.1 tag
- * to a HTTP/1.1 client. Better safe than sorry.
- */
- if (!wimpy)
- ap_table_mergen(r->headers_out, "Connection", "close");
-
- r->connection->keepalive = 0;
-
- return 0;
-}
-
-/*
- * Return the latest rational time from a request/mtime (modification time)
- * pair. We return the mtime unless it's in the future, in which case we
- * return the current time. We use the request time as a reference in order
- * to limit the number of calls to time(). We don't check for futurosity
- * unless the mtime is at least as new as the reference.
- */
-API_EXPORT(ap_time_t) ap_rationalize_mtime(request_rec *r, ap_time_t mtime)
-{
- ap_time_t now;
-
- /* For all static responses, it's almost certain that the file was
- * last modified before the beginning of the request. So there's
- * no reason to call time(NULL) again. But if the response has been
- * created on demand, then it might be newer than the time the request
- * started. In this event we really have to call time(NULL) again
- * so that we can give the clients the most accurate Last-Modified. If we
- * were given a time in the future, we return the current time - the
- * Last-Modified can't be in the future.
- */
- now = (mtime < r->request_time) ? r->request_time : ap_now();
- return (mtime > now) ? now : mtime;
-}
-
-API_EXPORT(int) ap_meets_conditions(request_rec *r)
-{
- const char *etag = ap_table_get(r->headers_out, "ETag");
- const char *if_match, *if_modified_since, *if_unmodified, *if_nonematch;
- ap_time_t mtime;
-
- /* Check for conditional requests --- note that we only want to do
- * this if we are successful so far and we are not processing a
- * subrequest or an ErrorDocument.
- *
- * The order of the checks is important, since ETag checks are supposed
- * to be more accurate than checks relative to the modification time.
- * However, not all documents are guaranteed to *have* ETags, and some
- * might have Last-Modified values w/o ETags, so this gets a little
- * complicated.
- */
-
- if (!ap_is_HTTP_SUCCESS(r->status) || r->no_local_copy) {
- return OK;
- }
-
- /* XXX: we should define a "time unset" constant */
- mtime = (r->mtime != 0) ? r->mtime : ap_now();
-
- /* If an If-Match request-header field was given
- * AND the field value is not "*" (meaning match anything)
- * AND if our strong ETag does not match any entity tag in that field,
- * respond with a status of 412 (Precondition Failed).
- */
- if ((if_match = ap_table_get(r->headers_in, "If-Match")) != NULL) {
- if (if_match[0] != '*' &&
- (etag == NULL || etag[0] == 'W' ||
- !ap_find_list_item(r->pool, if_match, etag))) {
- return HTTP_PRECONDITION_FAILED;
- }
- }
- else {
- /* Else if a valid If-Unmodified-Since request-header field was given
- * AND the requested resource has been modified since the time
- * specified in this field, then the server MUST
- * respond with a status of 412 (Precondition Failed).
- */
- if_unmodified = ap_table_get(r->headers_in, "If-Unmodified-Since");
- if (if_unmodified != NULL) {
- ap_time_t ius = ap_parseHTTPdate(if_unmodified);
-
- if ((ius != BAD_DATE) && (mtime > ius)) {
- return HTTP_PRECONDITION_FAILED;
- }
- }
- }
-
- /* If an If-None-Match request-header field was given
- * AND the field value is "*" (meaning match anything)
- * OR our ETag matches any of the entity tags in that field, fail.
- *
- * If the request method was GET or HEAD, failure means the server
- * SHOULD respond with a 304 (Not Modified) response.
- * For all other request methods, failure means the server MUST
- * respond with a status of 412 (Precondition Failed).
- *
- * GET or HEAD allow weak etag comparison, all other methods require
- * strong comparison. We can only use weak if it's not a range request.
- */
- if_nonematch = ap_table_get(r->headers_in, "If-None-Match");
- if (if_nonematch != NULL) {
- if (r->method_number == M_GET) {
- if (if_nonematch[0] == '*')
- return HTTP_NOT_MODIFIED;
- if (etag != NULL) {
- if (ap_table_get(r->headers_in, "Range")) {
- if (etag[0] != 'W' &&
- ap_find_list_item(r->pool, if_nonematch, etag)) {
- return HTTP_NOT_MODIFIED;
- }
- }
- else if (strstr(if_nonematch, etag)) {
- return HTTP_NOT_MODIFIED;
- }
- }
- }
- else if (if_nonematch[0] == '*' ||
- (etag != NULL &&
- ap_find_list_item(r->pool, if_nonematch, etag))) {
- return HTTP_PRECONDITION_FAILED;
- }
- }
- /* Else if a valid If-Modified-Since request-header field was given
- * AND it is a GET or HEAD request
- * AND the requested resource has not been modified since the time
- * specified in this field, then the server MUST
- * respond with a status of 304 (Not Modified).
- * A date later than the server's current request time is invalid.
- */
- else if ((r->method_number == M_GET)
- && ((if_modified_since =
- ap_table_get(r->headers_in, "If-Modified-Since")) != NULL)) {
- ap_time_t ims = ap_parseHTTPdate(if_modified_since);
-
- if ((ims >= mtime) && (ims <= r->request_time)) {
- return HTTP_NOT_MODIFIED;
- }
- }
- return OK;
-}
-
-/*
- * Construct an entity tag (ETag) from resource information. If it's a real
- * file, build in some of the file characteristics. If the modification time
- * is newer than (request-time minus 1 second), mark the ETag as weak - it
- * could be modified again in as short an interval. We rationalize the
- * modification time we're given to keep it from being in the future.
- */
-API_EXPORT(char *) ap_make_etag(request_rec *r, int force_weak)
-{
- char *etag;
- char *weak;
-
- /*
- * Make an ETag header out of various pieces of information. We use
- * the last-modified date and, if we have a real file, the
- * length and inode number - note that this doesn't have to match
- * the content-length (i.e. includes), it just has to be unique
- * for the file.
- *
- * If the request was made within a second of the last-modified date,
- * we send a weak tag instead of a strong one, since it could
- * be modified again later in the second, and the validation
- * would be incorrect.
- */
-
- weak = ((r->request_time - r->mtime > AP_USEC_PER_SEC) && !force_weak) ? "" : "W/";
-
- if (r->finfo.protection != 0) {
- etag = ap_psprintf(r->pool,
- "%s\"%lx-%lx-%lx\"", weak,
- (unsigned long) r->finfo.inode,
- (unsigned long) r->finfo.size,
- (unsigned long) r->mtime);
- }
- else {
- etag = ap_psprintf(r->pool, "%s\"%lx\"", weak,
- (unsigned long) r->mtime);
- }
-
- return etag;
-}
-
-API_EXPORT(void) ap_set_etag(request_rec *r)
-{
- char *etag;
- char *variant_etag, *vlv;
- int vlv_weak;
-
- if (!r->vlist_validator) {
- etag = ap_make_etag(r, 0);
- }
- else {
- /* If we have a variant list validator (vlv) due to the
- * response being negotiated, then we create a structured
- * entity tag which merges the variant etag with the variant
- * list validator (vlv). This merging makes revalidation
- * somewhat safer, ensures that caches which can deal with
- * Vary will (eventually) be updated if the set of variants is
- * changed, and is also a protocol requirement for transparent
- * content negotiation.
- */
-
- /* if the variant list validator is weak, we make the whole
- * structured etag weak. If we would not, then clients could
- * have problems merging range responses if we have different
- * variants with the same non-globally-unique strong etag.
- */
-
- vlv = r->vlist_validator;
- vlv_weak = (vlv[0] == 'W');
-
- variant_etag = ap_make_etag(r, vlv_weak);
-
- /* merge variant_etag and vlv into a structured etag */
-
- variant_etag[strlen(variant_etag) - 1] = '\0';
- if (vlv_weak)
- vlv += 3;
- else
- vlv++;
- etag = ap_pstrcat(r->pool, variant_etag, ";", vlv, NULL);
- }
-
- ap_table_setn(r->headers_out, "ETag", etag);
-}
-
-/*
- * This function sets the Last-Modified output header field to the value
- * of the mtime field in the request structure - rationalized to keep it from
- * being in the future.
- */
-API_EXPORT(void) ap_set_last_modified(request_rec *r)
-{
- ap_time_t mod_time = ap_rationalize_mtime(r, r->mtime);
- char *datestr = ap_palloc(r->pool, AP_RFC822_DATE_LEN);
- ap_rfc822_date(datestr, mod_time);
- ap_table_setn(r->headers_out, "Last-Modified", datestr);
-}
-
-/* Get the method number associated with the given string, assumed to
- * contain an HTTP method. Returns M_INVALID if not recognized.
- *
- * This is the first step toward placing method names in a configurable
- * list. Hopefully it (and other routines) can eventually be moved to
- * something like a mod_http_methods.c, complete with config stuff.
- */
-API_EXPORT(int) ap_method_number_of(const char *method)
-{
- switch (*method) {
- case 'H':
- if (strcmp(method, "HEAD") == 0)
- return M_GET; /* see header_only in request_rec */
- break;
- case 'G':
- if (strcmp(method, "GET") == 0)
- return M_GET;
- break;
- case 'P':
- if (strcmp(method, "POST") == 0)
- return M_POST;
- if (strcmp(method, "PUT") == 0)
- return M_PUT;
- if (strcmp(method, "PATCH") == 0)
- return M_PATCH;
- if (strcmp(method, "PROPFIND") == 0)
- return M_PROPFIND;
- if (strcmp(method, "PROPPATCH") == 0)
- return M_PROPPATCH;
- break;
- case 'D':
- if (strcmp(method, "DELETE") == 0)
- return M_DELETE;
- break;
- case 'C':
- if (strcmp(method, "CONNECT") == 0)
- return M_CONNECT;
- if (strcmp(method, "COPY") == 0)
- return M_COPY;
- break;
- case 'M':
- if (strcmp(method, "MKCOL") == 0)
- return M_MKCOL;
- if (strcmp(method, "MOVE") == 0)
- return M_MOVE;
- break;
- case 'O':
- if (strcmp(method, "OPTIONS") == 0)
- return M_OPTIONS;
- break;
- case 'T':
- if (strcmp(method, "TRACE") == 0)
- return M_TRACE;
- break;
- case 'L':
- if (strcmp(method, "LOCK") == 0)
- return M_LOCK;
- break;
- case 'U':
- if (strcmp(method, "UNLOCK") == 0)
- return M_UNLOCK;
- break;
- }
- return M_INVALID;
-}
-
-/* Get a line of protocol input, including any continuation lines
- * caused by MIME folding (or broken clients) if fold != 0, and place it
- * in the buffer s, of size n bytes, without the ending newline.
- *
- * Returns -1 on error, or the length of s.
- *
- * Note: Because bgets uses 1 char for newline and 1 char for NUL,
- * the most we can get is (n - 2) actual characters if it
- * was ended by a newline, or (n - 1) characters if the line
- * length exceeded (n - 1). So, if the result == (n - 1),
- * then the actual input line exceeded the buffer length,
- * and it would be a good idea for the caller to puke 400 or 414.
- */
-static int getline(char *s, int n, BUFF *in, int fold)
-{
- char *pos, next;
- int retval;
- int total = 0;
-
- pos = s;
-
- do {
- retval = ap_bgets(pos, n, in);
- /* retval == -1 if error, 0 if EOF */
-
- if (retval <= 0)
- return ((retval < 0) && (total == 0)) ? -1 : total;
-
- /* retval is the number of characters read, not including NUL */
-
- n -= retval; /* Keep track of how much of s is full */
- pos += (retval - 1); /* and where s ends */
- total += retval; /* and how long s has become */
-
- if (*pos == '\n') { /* Did we get a full line of input? */
- /*
- * Trim any extra trailing spaces or tabs except for the first
- * space or tab at the beginning of a blank string. This makes
- * it much easier to check field values for exact matches, and
- * saves memory as well. Terminate string at end of line.
- */
- while (pos > (s + 1) && (*(pos - 1) == ' ' || *(pos - 1) == '\t')) {
- --pos; /* trim extra trailing spaces or tabs */
- --total; /* but not one at the beginning of line */
- ++n;
- }
- *pos = '\0';
- --total;
- ++n;
- }
- else
- return total; /* if not, input line exceeded buffer size */
-
- /* Continue appending if line folding is desired and
- * the last line was not empty and we have room in the buffer and
- * the next line begins with a continuation character.
- */
- } while (fold && (retval != 1) && (n > 1)
- && (next = ap_blookc(in))
- && ((next == ' ') || (next == '\t')));
-
- return total;
-}
-
-/* parse_uri: break apart the uri
- * Side Effects:
- * - 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)
- */
-CORE_EXPORT(void) ap_parse_uri(request_rec *r, const char *uri)
-{
- int status = HTTP_OK;
-
- r->unparsed_uri = ap_pstrdup(r->pool, uri);
-
- if (r->method_number == M_CONNECT) {
- status = ap_parse_hostinfo_components(r->pool, uri, &r->parsed_uri);
- } else {
- /* Simple syntax Errors in URLs are trapped by parse_uri_components(). */
- status = ap_parse_uri_components(r->pool, uri, &r->parsed_uri);
- }
-
- if (ap_is_HTTP_SUCCESS(status)) {
- /* if it has a scheme we may need to do absoluteURI vhost stuff */
- if (r->parsed_uri.scheme
- && !strcasecmp(r->parsed_uri.scheme, ap_http_method(r))) {
- r->hostname = r->parsed_uri.hostname;
- } else if (r->method_number == M_CONNECT) {
- r->hostname = r->parsed_uri.hostname;
- }
- r->args = r->parsed_uri.query;
- r->uri = r->parsed_uri.path ? r->parsed_uri.path
- : ap_pstrdup(r->pool, "/");
-#if defined(OS2) || defined(WIN32)
- /* Handle path translations for OS/2 and plug security hole.
- * This will prevent "http://www.wherever.com/..\..\/" from
- * returning a directory for the root drive.
- */
- {
- char *x;
-
- for (x = r->uri; (x = strchr(x, '\\')) != NULL; )
- *x = '/';
- }
-#endif /* OS2 || WIN32 */
- }
- else {
- r->args = NULL;
- r->hostname = NULL;
- r->status = status; /* set error status */
- r->uri = ap_pstrdup(r->pool, uri);
- }
-}
-
-static int read_request_line(request_rec *r)
-{
- char l[DEFAULT_LIMIT_REQUEST_LINE + 2]; /* getline's two extra for \n\0 */
- const char *ll = l;
- const char *uri;
- conn_rec *conn = r->connection;
- int major = 1, minor = 0; /* Assume HTTP/1.0 if non-"HTTP" protocol */
- int len;
-
- /* Read past empty lines until we get a real request line,
- * a read error, the connection closes (EOF), or we timeout.
- *
- * We skip empty lines because browsers have to tack a CRLF on to the end
- * of POSTs to support old CERN webservers. But note that we may not
- * have flushed any previous response completely to the client yet.
- * We delay the flush as long as possible so that we can improve
- * performance for clients that are pipelining requests. If a request
- * is pipelined then we won't block during the (implicit) read() below.
- * If the requests aren't pipelined, then the client is still waiting
- * for the final buffer flush from us, and we will block in the implicit
- * read(). B_SAFEREAD ensures that the BUFF layer flushes if it will
- * have to block during a read.
- */
- /* TODO: reimplement SAFEREAD external to BUFF using a layer */
- /* //ap_bsetflag(conn->client, B_SAFEREAD, 1); */
- ap_bflush(conn->client);
- while ((len = getline(l, sizeof(l), conn->client, 0)) <= 0) {
- if ((len < 0) || ap_bgetflag(conn->client, B_EOF)) {
- /* //ap_bsetflag(conn->client, B_SAFEREAD, 0); */
- /* this is a hack to make sure that request time is set,
- * it's not perfect, but it's better than nothing
- */
- r->request_time = ap_now();
- return 0;
- }
- }
- /* we've probably got something to do, ignore graceful restart requests */
-
- /* XXX - sigwait doesn't work if the signal has been SIG_IGNed (under
- * linux 2.0 w/ glibc 2.0, anyway), and this step isn't necessary when
- * we're running a sigwait thread anyway. If/when unthreaded mode is
- * put back in, we should make sure to ignore this signal iff a sigwait
- * thread isn't used. - mvsk
-
-#ifdef SIGWINCH
- signal(SIGWINCH, SIG_IGN);
-#endif
- */
-
- /* //ap_bsetflag(conn->client, B_SAFEREAD, 0); */
-
- r->request_time = ap_now();
- r->the_request = ap_pstrdup(r->pool, l);
- r->method = ap_getword_white(r->pool, &ll);
- ap_update_connection_status(conn->id, "Method", r->method);
- uri = ap_getword_white(r->pool, &ll);
-
- /* Provide quick information about the request method as soon as known */
-
- r->method_number = ap_method_number_of(r->method);
- if (r->method_number == M_GET && r->method[0] == 'H') {
- r->header_only = 1;
- }
-
- ap_parse_uri(r, uri);
-
- /* getline returns (size of max buffer - 1) if it fills up the
- * buffer before finding the end-of-line. This is only going to
- * happen if it exceeds the configured limit for a request-line.
- */
- if (len > r->server->limit_req_line) {
- r->status = HTTP_REQUEST_URI_TOO_LARGE;
- r->proto_num = HTTP_VERSION(1,0);
- r->protocol = ap_pstrdup(r->pool, "HTTP/1.0");
- return 0;
- }
-
- r->assbackwards = (ll[0] == '\0');
- r->protocol = ap_pstrdup(r->pool, ll[0] ? ll : "HTTP/0.9");
- ap_update_connection_status(conn->id, "Protocol", r->protocol);
-
- if (2 == sscanf(r->protocol, "HTTP/%u.%u", &major, &minor)
- && minor < HTTP_VERSION(1,0)) /* don't allow HTTP/0.1000 */
- r->proto_num = HTTP_VERSION(major, minor);
- else
- r->proto_num = HTTP_VERSION(1,0);
-
- return 1;
-}
-
-static void get_mime_headers(request_rec *r)
-{
- char field[DEFAULT_LIMIT_REQUEST_FIELDSIZE + 2]; /* getline's two extra */
- conn_rec *c = r->connection;
- char *value;
- char *copy;
- int len;
- unsigned int fields_read = 0;
- ap_table_t *tmp_headers;
-
- /* We'll use ap_overlap_tables later to merge these into r->headers_in. */
- tmp_headers = ap_make_table(r->pool, 50);
-
- /*
- * Read header lines until we get the empty separator line, a read error,
- * the connection closes (EOF), reach the server limit, or we timeout.
- */
- while ((len = getline(field, sizeof(field), c->client, 1)) > 0) {
-
- if (r->server->limit_req_fields &&
- (++fields_read > r->server->limit_req_fields)) {
- r->status = HTTP_BAD_REQUEST;
- ap_table_setn(r->notes, "error-notes",
- "The number of request header fields exceeds "
- "this server's limit.<P>\n");
- return;
- }
- /* getline returns (size of max buffer - 1) if it fills up the
- * buffer before finding the end-of-line. This is only going to
- * happen if it exceeds the configured limit for a field size.
- */
- if (len > r->server->limit_req_fieldsize) {
- r->status = HTTP_BAD_REQUEST;
- ap_table_setn(r->notes, "error-notes", ap_pstrcat(r->pool,
- "Size of a request header field exceeds server limit.<P>\n"
- "<PRE>\n", field, "</PRE>\n", NULL));
- return;
- }
- copy = ap_palloc(r->pool, len + 1);
- memcpy(copy, field, len + 1);
-
- if (!(value = strchr(copy, ':'))) { /* Find the colon separator */
- r->status = HTTP_BAD_REQUEST; /* or abort the bad request */
- ap_table_setn(r->notes, "error-notes", ap_pstrcat(r->pool,
- "Request header field is missing colon separator.<P>\n"
- "<PRE>\n", copy, "</PRE>\n", NULL));
- return;
- }
-
- *value = '\0';
- ++value;
- while (*value == ' ' || *value == '\t')
- ++value; /* Skip to start of value */
-
- ap_table_addn(tmp_headers, copy, value);
- }
-
- ap_overlap_tables(r->headers_in, tmp_headers, AP_OVERLAP_TABLES_MERGE);
-}
-
-request_rec *ap_read_request(conn_rec *conn)
-{
- request_rec *r;
- ap_context_t *p;
- const char *expect;
- int access_status;
-
- ap_create_context(&p, conn->pool);
- r = ap_pcalloc(p, sizeof(request_rec));
- r->pool = p;
- r->connection = conn;
- r->server = conn->base_server;
-
- conn->keptalive = conn->keepalive == 1;
- conn->keepalive = 0;
-
- r->user = NULL;
- r->ap_auth_type = NULL;
-
- r->headers_in = ap_make_table(r->pool, 50);
- r->subprocess_env = ap_make_table(r->pool, 50);
- r->headers_out = ap_make_table(r->pool, 12);
- r->err_headers_out = ap_make_table(r->pool, 5);
- r->notes = ap_make_table(r->pool, 5);
-
- r->request_config = ap_create_request_config(r->pool);
- r->per_dir_config = r->server->lookup_defaults;
-
- r->sent_bodyct = 0; /* bytect isn't for body */
-
- r->read_length = 0;
- r->read_body = REQUEST_NO_BODY;
-
- r->status = HTTP_REQUEST_TIME_OUT; /* Until we get a request */
- r->the_request = NULL;
-
-#ifdef CHARSET_EBCDIC
- ap_bsetflag(r->connection->client, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 1);
-#endif
-
- ap_bsetopt(conn->client, BO_TIMEOUT,
- conn->keptalive
- ? &r->server->keep_alive_timeout
- : &r->server->timeout);
-
- /* Get the request... */
- if (!read_request_line(r)) {
- if (r->status == HTTP_REQUEST_URI_TOO_LARGE) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "request failed: URI too long");
- ap_send_error_response(r, 0);
- ap_run_log_transaction(r);
- return r;
- }
- return NULL;
- }
- if (r->connection->keptalive) {
- ap_bsetopt(r->connection->client, BO_TIMEOUT,
- &r->server->timeout);
- }
- if (!r->assbackwards) {
- get_mime_headers(r);
- if (r->status != HTTP_REQUEST_TIME_OUT) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "request failed: error reading the headers");
- ap_send_error_response(r, 0);
- ap_run_log_transaction(r);
- return r;
- }
- }
- else {
- if (r->header_only) {
- /*
- * Client asked for headers only with HTTP/0.9, which doesn't send
- * headers! Have to dink things just to make sure the error message
- * comes through...
- */
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "client sent invalid HTTP/0.9 request: HEAD %s",
- r->uri);
- r->header_only = 0;
- r->status = HTTP_BAD_REQUEST;
- ap_send_error_response(r, 0);
- ap_run_log_transaction(r);
- return r;
- }
- }
-
- r->status = HTTP_OK; /* Until further notice. */
-
- /* update what we think the virtual host is based on the headers we've
- * now read. may update status.
- */
- ap_update_vhost_from_headers(r);
-
- /* we may have switched to another server */
- r->per_dir_config = r->server->lookup_defaults;
-
- conn->keptalive = 0; /* We now have a request to play with */
-
- if ((!r->hostname && (r->proto_num >= HTTP_VERSION(1,1))) ||
- ((r->proto_num == HTTP_VERSION(1,1)) &&
- !ap_table_get(r->headers_in, "Host"))) {
- /*
- * Client sent us an HTTP/1.1 or later request without telling us the
- * hostname, either with a full URL or a Host: header. We therefore
- * need to (as per the 1.1 spec) send an error. As a special case,
- * HTTP/1.1 mentions twice (S9, S14.23) that a request MUST contain
- * a Host: header, and the server MUST respond with 400 if it doesn't.
- */
- r->status = HTTP_BAD_REQUEST;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "client sent HTTP/1.1 request without hostname "
- "(see RFC2068 section 9, and 14.23): %s", r->uri);
- }
- if (r->status != HTTP_OK) {
- ap_send_error_response(r, 0);
- ap_run_log_transaction(r);
- return r;
- }
- if (((expect = ap_table_get(r->headers_in, "Expect")) != NULL) &&
- (expect[0] != '\0')) {
- /*
- * The Expect header field was added to HTTP/1.1 after RFC 2068
- * as a means to signal when a 100 response is desired and,
- * unfortunately, to signal a poor man's mandatory extension that
- * the server must understand or return 417 Expectation Failed.
- */
- if (strcasecmp(expect, "100-continue") == 0) {
- r->expecting_100 = 1;
- }
- else {
- r->status = HTTP_EXPECTATION_FAILED;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, r,
- "client sent an unrecognized expectation value of "
- "Expect: %s", expect);
- ap_send_error_response(r, 0);
- (void) ap_discard_request_body(r);
- ap_run_log_transaction(r);
- return r;
- }
- }
-
- if ((access_status = ap_run_post_read_request(r))) {
- ap_die(access_status, r);
- ap_run_log_transaction(r);
- return NULL;
- }
-
- return r;
-}
-
-/*
- * A couple of other functions which initialize some of the fields of
- * a request structure, as appropriate for adjuncts of one kind or another
- * to a request in progress. Best here, rather than elsewhere, since
- * *someone* has to set the protocol-specific fields...
- */
-
-void ap_set_sub_req_protocol(request_rec *rnew, const request_rec *r)
-{
- rnew->the_request = r->the_request; /* Keep original request-line */
-
- rnew->assbackwards = 1; /* Don't send headers from this. */
- rnew->no_local_copy = 1; /* Don't try to send USE_LOCAL_COPY for a
- * fragment. */
- rnew->method = "GET";
- rnew->method_number = M_GET;
- rnew->protocol = "INCLUDED";
-
- rnew->status = HTTP_OK;
-
- rnew->headers_in = r->headers_in;
- rnew->subprocess_env = ap_copy_table(rnew->pool, r->subprocess_env);
- rnew->headers_out = ap_make_table(rnew->pool, 5);
- rnew->err_headers_out = ap_make_table(rnew->pool, 5);
- rnew->notes = ap_make_table(rnew->pool, 5);
-
- rnew->expecting_100 = r->expecting_100;
- rnew->read_length = r->read_length;
- rnew->read_body = REQUEST_NO_BODY;
-
- rnew->main = (request_rec *) r;
-}
-
-void ap_finalize_sub_req_protocol(request_rec *sub)
-{
- SET_BYTES_SENT(sub->main);
-}
-
-/*
- * Support for the Basic authentication protocol, and a bit for Digest.
- */
-
-API_EXPORT(void) ap_note_auth_failure(request_rec *r)
-{
- if (!strcasecmp(ap_auth_type(r), "Basic"))
- ap_note_basic_auth_failure(r);
- else if (!strcasecmp(ap_auth_type(r), "Digest"))
- ap_note_digest_auth_failure(r);
-}
-
-API_EXPORT(void) ap_note_basic_auth_failure(request_rec *r)
-{
- if (strcasecmp(ap_auth_type(r), "Basic"))
- ap_note_auth_failure(r);
- else
- ap_table_setn(r->err_headers_out,
- r->proxyreq ? "Proxy-Authenticate" : "WWW-Authenticate",
- ap_pstrcat(r->pool, "Basic realm=\"", ap_auth_name(r), "\"",
- NULL));
-}
-
-API_EXPORT(void) ap_note_digest_auth_failure(request_rec *r)
-{
- ap_table_setn(r->err_headers_out,
- r->proxyreq ? "Proxy-Authenticate" : "WWW-Authenticate",
- ap_psprintf(r->pool, "Digest realm=\"%s\", nonce=\"%lu\"",
- ap_auth_name(r), r->request_time));
-}
-
-API_EXPORT(int) ap_get_basic_auth_pw(request_rec *r, const char **pw)
-{
- const char *auth_line = ap_table_get(r->headers_in,
- r->proxyreq ? "Proxy-Authorization"
- : "Authorization");
- const char *t;
-
- if (!(t = ap_auth_type(r)) || strcasecmp(t, "Basic"))
- return DECLINED;
-
- if (!ap_auth_name(r)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR,
- 0, r, "need AuthName: %s", r->uri);
- return SERVER_ERROR;
- }
-
- if (!auth_line) {
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
-
- if (strcasecmp(ap_getword(r->pool, &auth_line, ' '), "Basic")) {
- /* Client tried to authenticate using wrong auth scheme */
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "client used wrong authentication scheme: %s", r->uri);
- ap_note_basic_auth_failure(r);
- return AUTH_REQUIRED;
- }
-
- /* CHARSET_EBCDIC Issue's here ?!? Compare with 32/9 instead
- * as we are operating on an octed stream ?
- */
- while (*auth_line== ' ' || *auth_line== '\t')
- auth_line++;
-
- t = ap_pbase64decode(r->pool, auth_line);
- /* Note that this allocation has to be made from r->connection->pool
- * because it has the lifetime of the connection. The other allocations
- * are temporary and can be tossed away any time.
- */
- r->user = ap_getword_nulls (r->pool, &t, ':');
- r->ap_auth_type = "Basic";
-
- *pw = t;
-
- return OK;
-}
-
-/* New Apache routine to map status codes into array indicies
- * e.g. 100 -> 0, 101 -> 1, 200 -> 2 ...
- * The number of status lines must equal the value of RESPONSE_CODES (httpd.h)
- * and must be listed in order.
- */
-
-#ifdef UTS21
-/* The second const triggers an assembler bug on UTS 2.1.
- * Another workaround is to move some code out of this file into another,
- * but this is easier. Dave Dykstra, 3/31/99
- */
-static const char * status_lines[RESPONSE_CODES] =
-#else
-static const char * const status_lines[RESPONSE_CODES] =
-#endif
-{
- "100 Continue",
- "101 Switching Protocols",
- "102 Processing",
-#define LEVEL_200 3
- "200 OK",
- "201 Created",
- "202 Accepted",
- "203 Non-Authoritative Information",
- "204 No Content",
- "205 Reset Content",
- "206 Partial Content",
- "207 Multi-Status",
-#define LEVEL_300 11
- "300 Multiple Choices",
- "301 Moved Permanently",
- "302 Found",
- "303 See Other",
- "304 Not Modified",
- "305 Use Proxy",
- "306 unused",
- "307 Temporary Redirect",
-#define LEVEL_400 19
- "400 Bad Request",
- "401 Authorization Required",
- "402 Payment Required",
- "403 Forbidden",
- "404 Not Found",
- "405 Method Not Allowed",
- "406 Not Acceptable",
- "407 Proxy Authentication Required",
- "408 Request Time-out",
- "409 Conflict",
- "410 Gone",
- "411 Length Required",
- "412 Precondition Failed",
- "413 Request Entity Too Large",
- "414 Request-URI Too Large",
- "415 Unsupported Media Type",
- "416 Requested Range Not Satisfiable",
- "417 Expectation Failed",
- "418 unused",
- "419 unused",
- "420 unused",
- "421 unused",
- "422 Unprocessable Entity",
- "423 Locked",
- "424 Failed Dependency",
-#define LEVEL_500 44
- "500 Internal Server Error",
- "501 Method Not Implemented",
- "502 Bad Gateway",
- "503 Service Temporarily Unavailable",
- "504 Gateway Time-out",
- "505 HTTP Version Not Supported",
- "506 Variant Also Negotiates",
- "507 Insufficient Storage",
- "508 unused",
- "509 unused",
- "510 Not Extended"
-};
-
-/* The index is found by its offset from the x00 code of each level.
- * Although this is fast, it will need to be replaced if some nutcase
- * decides to define a high-numbered code before the lower numbers.
- * If that sad event occurs, replace the code below with a linear search
- * from status_lines[shortcut[i]] to status_lines[shortcut[i+1]-1];
- */
-API_EXPORT(int) ap_index_of_response(int status)
-{
- static int shortcut[6] = {0, LEVEL_200, LEVEL_300, LEVEL_400,
- LEVEL_500, RESPONSE_CODES};
- int i, pos;
-
- if (status < 100) /* Below 100 is illegal for HTTP status */
- return LEVEL_500;
-
- for (i = 0; i < 5; i++) {
- status -= 100;
- if (status < 100) {
- pos = (status + shortcut[i]);
- if (pos < shortcut[i + 1])
- return pos;
- else
- return LEVEL_500; /* status unknown (falls in gap) */
- }
- }
- return LEVEL_500; /* 600 or above is also illegal */
-}
-
-/* Send a single HTTP header field to the client. Note that this function
- * is used in calls to table_do(), so their interfaces are co-dependent.
- * In other words, don't change this one without checking table_do in alloc.c.
- * It returns true unless there was a write error of some kind.
- */
-API_EXPORT_NONSTD(int) ap_send_header_field(request_rec *r,
- const char *fieldname, const char *fieldval)
-{
- return (0 < ap_rvputs(r, fieldname, ": ", fieldval, "\015\012", NULL));
-}
-
-API_EXPORT(void) ap_basic_http_header(request_rec *r)
-{
- char *protocol;
- char *date = NULL;
-#ifdef CHARSET_EBCDIC
- int convert = ap_bgetflag(r->connection->client, B_EBCDIC2ASCII);
-#endif /*CHARSET_EBCDIC*/
-
- if (r->assbackwards)
- return;
-
- if (!r->status_line)
- r->status_line = status_lines[ap_index_of_response(r->status)];
-
- /* mod_proxy is only HTTP/1.0, so avoid sending HTTP/1.1 error response;
- * kluge around broken browsers when indicated by force-response-1.0
- */
- if (r->proxyreq
- || (r->proto_num == HTTP_VERSION(1,0)
- && ap_table_get(r->subprocess_env, "force-response-1.0"))) {
-
- protocol = "HTTP/1.0";
- r->connection->keepalive = -1;
- }
- else
- protocol = AP_SERVER_PROTOCOL;
-
-#ifdef CHARSET_EBCDIC
- ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, 1);
-#endif /*CHARSET_EBCDIC*/
-
- /* Output the HTTP/1.x Status-Line and the Date and Server fields */
-
- ap_rvputs(r, protocol, " ", r->status_line, "\015\012", NULL);
-
- date = ap_palloc(r->pool, AP_RFC822_DATE_LEN);
- ap_rfc822_date(date, r->request_time);
- ap_send_header_field(r, "Date", date);
- ap_send_header_field(r, "Server", ap_get_server_version());
-
- ap_table_unset(r->headers_out, "Date"); /* Avoid bogosity */
- ap_table_unset(r->headers_out, "Server");
-#ifdef CHARSET_EBCDIC
- if (!convert)
- ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert);
-#endif /*CHARSET_EBCDIC*/
-}
-
-/* Navigator versions 2.x, 3.x and 4.0 betas up to and including 4.0b2
- * have a header parsing bug. If the terminating \r\n occur starting
- * at offset 256, 257 or 258 of output then it will not properly parse
- * the headers. Curiously it doesn't exhibit this problem at 512, 513.
- * We are guessing that this is because their initial read of a new request
- * uses a 256 byte buffer, and subsequent reads use a larger buffer.
- * So the problem might exist at different offsets as well.
- *
- * This should also work on keepalive connections assuming they use the
- * same small buffer for the first read of each new request.
- *
- * At any rate, we check the bytes written so far and, if we are about to
- * tickle the bug, we instead insert a bogus padding header. Since the bug
- * manifests as a broken image in Navigator, users blame the server. :(
- * It is more expensive to check the User-Agent than it is to just add the
- * bytes, so we haven't used the BrowserMatch feature here.
- */
-static void terminate_header(request_rec *r)
-{
- long int bs;
-
- ap_bgetopt(r->connection->client, BO_BYTECT, &bs);
- if (bs >= 255 && bs <= 257)
- ap_rputs("X-Pad: avoid browser bug\015\012", r);
-
- ap_rputs("\015\012", r); /* Send the terminating empty line */
-}
-
-/* Build the Allow field-value from the request handler method mask.
- * Note that we always allow TRACE, since it is handled below.
- */
-static char *make_allow(request_rec *r)
-{
- return 2 + ap_pstrcat(r->pool,
- (r->allowed & (1 << M_GET)) ? ", GET, HEAD" : "",
- (r->allowed & (1 << M_POST)) ? ", POST" : "",
- (r->allowed & (1 << M_PUT)) ? ", PUT" : "",
- (r->allowed & (1 << M_DELETE)) ? ", DELETE" : "",
- (r->allowed & (1 << M_CONNECT)) ? ", CONNECT" : "",
- (r->allowed & (1 << M_OPTIONS)) ? ", OPTIONS" : "",
- (r->allowed & (1 << M_PATCH)) ? ", PATCH" : "",
- (r->allowed & (1 << M_PROPFIND)) ? ", PROPFIND" : "",
- (r->allowed & (1 << M_PROPPATCH)) ? ", PROPPATCH" : "",
- (r->allowed & (1 << M_MKCOL)) ? ", MKCOL" : "",
- (r->allowed & (1 << M_COPY)) ? ", COPY" : "",
- (r->allowed & (1 << M_MOVE)) ? ", MOVE" : "",
- (r->allowed & (1 << M_LOCK)) ? ", LOCK" : "",
- (r->allowed & (1 << M_UNLOCK)) ? ", UNLOCK" : "",
- ", TRACE",
- NULL);
-}
-
-API_EXPORT(int) ap_send_http_trace(request_rec *r)
-{
- int rv;
-
- /* Get the original request */
- while (r->prev)
- r = r->prev;
-
- if ((rv = ap_setup_client_block(r, REQUEST_NO_BODY)))
- return rv;
-
- r->content_type = "message/http";
- ap_send_http_header(r);
-
- /* Now we recreate the request, and echo it back */
-
- ap_rvputs(r, r->the_request, "\015\012", NULL);
-
- ap_table_do((int (*) (void *, const char *, const char *))
- ap_send_header_field, (void *) r, r->headers_in, NULL);
- ap_rputs("\015\012", r);
-
- return OK;
-}
-
-int ap_send_http_options(request_rec *r)
-{
- const long int zero = 0L;
-
- if (r->assbackwards)
- return DECLINED;
-
- ap_basic_http_header(r);
-
- ap_table_setn(r->headers_out, "Content-Length", "0");
- ap_table_setn(r->headers_out, "Allow", make_allow(r));
- ap_set_keepalive(r);
-
- ap_table_do((int (*) (void *, const char *, const char *)) ap_send_header_field,
- (void *) r, r->headers_out, NULL);
-
- terminate_header(r);
-
- ap_bsetopt(r->connection->client, BO_BYTECT, &zero);
-
- return OK;
-}
-
-/*
- * Here we try to be compatible with clients that want multipart/x-byteranges
- * instead of multipart/byteranges (also see above), as per HTTP/1.1. We
- * look for the Request-Range header (e.g. Netscape 2 and 3) as an indication
- * that the browser supports an older protocol. We also check User-Agent
- * for Microsoft Internet Explorer 3, which needs this as well.
- */
-static int use_range_x(request_rec *r)
-{
- const char *ua;
- return (ap_table_get(r->headers_in, "Request-Range") ||
- ((ua = ap_table_get(r->headers_in, "User-Agent"))
- && strstr(ua, "MSIE 3")));
-}
-
-/* This routine is called by ap_table_do and merges all instances of
- * the passed field values into a single array that will be further
- * processed by some later routine. Originally intended to help split
- * and recombine multiple Vary fields, though it is generic to any field
- * consisting of comma/space-separated tokens.
- */
-static int uniq_field_values(void *d, const char *key, const char *val)
-{
- ap_array_header_t *values;
- char *start;
- char *e;
- char **strpp;
- int i;
-
- values = (ap_array_header_t *)d;
-
- e = ap_pstrdup(values->cont, val);
-
- do {
- /* Find a non-empty fieldname */
-
- while (*e == ',' || ap_isspace(*e)) {
- ++e;
- }
- if (*e == '\0') {
- break;
- }
- start = e;
- while (*e != '\0' && *e != ',' && !ap_isspace(*e)) {
- ++e;
- }
- if (*e != '\0') {
- *e++ = '\0';
- }
-
- /* Now add it to values if it isn't already represented.
- * Could be replaced by a ap_array_strcasecmp() if we had one.
- */
- for (i = 0, strpp = (char **) values->elts; i < values->nelts;
- ++i, ++strpp) {
- if (*strpp && strcasecmp(*strpp, start) == 0) {
- break;
- }
- }
- if (i == values->nelts) { /* if not found */
- *(char **)ap_push_array(values) = start;
- }
- } while (*e != '\0');
-
- return 1;
-}
-
-/*
- * Since some clients choke violently on multiple Vary fields, or
- * Vary fields with duplicate tokens, combine any multiples and remove
- * any duplicates.
- */
-static void fixup_vary(request_rec *r)
-{
- ap_array_header_t *varies;
-
- varies = ap_make_array(r->pool, 5, sizeof(char *));
-
- /* Extract all Vary fields from the headers_out, separate each into
- * its comma-separated fieldname values, and then add them to varies
- * if not already present in the array.
- */
- ap_table_do((int (*)(void *, const char *, const char *))uniq_field_values,
- (void *) varies, r->headers_out, "Vary", NULL);
-
- /* If we found any, replace old Vary fields with unique-ified value */
-
- if (varies->nelts > 0) {
- ap_table_setn(r->headers_out, "Vary",
- ap_array_pstrcat(r->pool, varies, ','));
- }
-}
-
-API_EXPORT(void) ap_send_http_header(request_rec *r)
-{
- int i;
- const long int zero = 0L;
- char *date = NULL;
-#ifdef CHARSET_EBCDIC
- int convert = ap_bgetflag(r->connection->client, B_EBCDIC2ASCII);
-#endif /*CHARSET_EBCDIC*/
-
- if (r->assbackwards) {
- if (!r->main)
- ap_bsetopt(r->connection->client, BO_BYTECT, &zero);
- r->sent_bodyct = 1;
- return;
- }
-
- /*
- * Now that we are ready to send a response, we need to combine the two
- * header field tables into a single table. If we don't do this, our
- * later attempts to set or unset a given fieldname might be bypassed.
- */
- if (!ap_is_empty_table(r->err_headers_out))
- r->headers_out = ap_overlay_tables(r->pool, r->err_headers_out,
- r->headers_out);
-
- /*
- * Remove the 'Vary' header field if the client can't handle it.
- * Since this will have nasty effects on HTTP/1.1 caches, force
- * the response into HTTP/1.0 mode.
- */
- if (ap_table_get(r->subprocess_env, "force-no-vary") != NULL) {
- ap_table_unset(r->headers_out, "Vary");
- r->proto_num = HTTP_VERSION(1,0);
- ap_table_set(r->subprocess_env, "force-response-1.0", "1");
- }
- else {
- fixup_vary(r);
- }
-
- ap_basic_http_header(r);
-
-#ifdef CHARSET_EBCDIC
- ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, 1);
-#endif /*CHARSET_EBCDIC*/
-
- ap_set_keepalive(r);
-
- if (r->chunked) {
- ap_table_mergen(r->headers_out, "Transfer-Encoding", "chunked");
- ap_table_unset(r->headers_out, "Content-Length");
- }
-
- if (r->byterange > 1)
- ap_table_setn(r->headers_out, "Content-Type",
- ap_pstrcat(r->pool, "multipart", use_range_x(r) ? "/x-" : "/",
- "byteranges; boundary=", r->boundary, NULL));
- else if (r->content_type)
- ap_table_setn(r->headers_out, "Content-Type", r->content_type);
- else
- ap_table_setn(r->headers_out, "Content-Type", ap_default_type(r));
-
- if (r->content_encoding)
- ap_table_setn(r->headers_out, "Content-Encoding", r->content_encoding);
-
- if (r->content_languages && r->content_languages->nelts) {
- for (i = 0; i < r->content_languages->nelts; ++i) {
- ap_table_mergen(r->headers_out, "Content-Language",
- ((char **) (r->content_languages->elts))[i]);
- }
- }
- else if (r->content_language)
- ap_table_setn(r->headers_out, "Content-Language", r->content_language);
-
- /*
- * Control cachability for non-cachable responses if not already set by
- * some other part of the server configuration.
- */
- if (r->no_cache && !ap_table_get(r->headers_out, "Expires")) {
- date = ap_palloc(r->pool, AP_RFC822_DATE_LEN);
- ap_rfc822_date(date, r->request_time);
- ap_table_addn(r->headers_out, "Expires", date);
- }
-
- /* Send the entire ap_table_t of header fields, terminated by an empty line. */
-
- ap_table_do((int (*) (void *, const char *, const char *)) ap_send_header_field,
- (void *) r, r->headers_out, NULL);
-
- terminate_header(r);
-
-
- ap_bsetopt(r->connection->client, BO_BYTECT, &zero);
- r->sent_bodyct = 1; /* Whatever follows is real body stuff... */
-
- /* Set buffer flags for the body */
- if (r->chunked)
- ap_bsetflag(r->connection->client, B_CHUNK, 1);
-#ifdef CHARSET_EBCDIC
- if (!convert)
- ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert);
-#endif /*CHARSET_EBCDIC*/
-}
-
-/* finalize_request_protocol is called at completion of sending the
- * response. It's sole purpose is to send the terminating protocol
- * information for any wrappers around the response message body
- * (i.e., transfer encodings). It should have been named finalize_response.
- */
-API_EXPORT(void) ap_finalize_request_protocol(request_rec *r)
-{
- if (r->chunked && !r->connection->aborted) {
- /*
- * Turn off chunked encoding --- we can only do this once.
- */
- r->chunked = 0;
- ap_bsetflag(r->connection->client, B_CHUNK, 0);
-
- ap_rputs("0\015\012", r);
- /* If we had footer "headers", we'd send them now */
- ap_rputs("\015\012", r);
- }
-}
-
-/* Here we deal with getting the request message body from the client.
- * Whether or not the request contains a body is signaled by the presence
- * of a non-zero Content-Length or by a Transfer-Encoding: chunked.
- *
- * Note that this is more complicated than it was in Apache 1.1 and prior
- * versions, because chunked support means that the module does less.
- *
- * The proper procedure is this:
- *
- * 1. Call setup_client_block() near the beginning of the request
- * handler. This will set up all the necessary properties, and will
- * return either OK, or an error code. If the latter, the module should
- * return that error code. The second parameter selects the policy to
- * apply if the request message indicates a body, and how a chunked
- * transfer-coding should be interpreted. Choose one of
- *
- * 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.
- *
- * In order to use the last two options, the caller MUST provide a buffer
- * large enough to hold a chunk-size line, including any extensions.
- *
- * 2. When you are ready to read a body (if any), call should_client_block().
- * This will tell the module whether or not to read input. If it is 0,
- * the module should assume that there is no message body to read.
- * This step also sends a 100 Continue response to HTTP/1.1 clients,
- * so should not be called until the module is *definitely* ready to
- * read content. (otherwise, the point of the 100 response is defeated).
- * Never call this function more than once.
- *
- * 3. Finally, call get_client_block in a loop. Pass it a buffer and its size.
- * It will put data into the buffer (not necessarily a full buffer), and
- * return the length of the input block. When it is done reading, it will
- * return 0 if EOF, or -1 if there was an error.
- * If an error occurs on input, we force an end to keepalive.
- */
-
-API_EXPORT(int) ap_setup_client_block(request_rec *r, int read_policy)
-{
- const char *tenc = ap_table_get(r->headers_in, "Transfer-Encoding");
- const char *lenp = ap_table_get(r->headers_in, "Content-Length");
- unsigned long max_body;
-
- r->read_body = read_policy;
- r->read_chunked = 0;
- r->remaining = 0;
-
- if (tenc) {
- if (strcasecmp(tenc, "chunked")) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Unknown Transfer-Encoding %s", tenc);
- return HTTP_NOT_IMPLEMENTED;
- }
- if (r->read_body == REQUEST_CHUNKED_ERROR) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "chunked Transfer-Encoding forbidden: %s", r->uri);
- return (lenp) ? HTTP_BAD_REQUEST : HTTP_LENGTH_REQUIRED;
- }
-
- r->read_chunked = 1;
- }
- else if (lenp) {
- const char *pos = lenp;
-
- while (ap_isdigit(*pos) || ap_isspace(*pos))
- ++pos;
- if (*pos != '\0') {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid Content-Length %s", lenp);
- return HTTP_BAD_REQUEST;
- }
-
- r->remaining = atol(lenp);
- }
-
- if ((r->read_body == REQUEST_NO_BODY) &&
- (r->read_chunked || (r->remaining > 0))) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "%s with body is not allowed for %s", r->method, r->uri);
- return HTTP_REQUEST_ENTITY_TOO_LARGE;
- }
-
- max_body = ap_get_limit_req_body(r);
- if (max_body && (r->remaining > max_body)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Request content-length of %s is larger than the configured "
- "limit of %lu", lenp, max_body);
- return HTTP_REQUEST_ENTITY_TOO_LARGE;
- }
-
- return OK;
-}
-
-API_EXPORT(int) ap_should_client_block(request_rec *r)
-{
- /* First check if we have already read the request body */
-
- if (r->read_length || (!r->read_chunked && (r->remaining <= 0)))
- return 0;
-
- if (r->expecting_100 && r->proto_num >= HTTP_VERSION(1,1)) {
- /* sending 100 Continue interim response */
- ap_rvputs(r, AP_SERVER_PROTOCOL, " ", status_lines[0], "\015\012\015\012",
- NULL);
- ap_rflush(r);
- }
-
- return 1;
-}
-
-static long get_chunk_size(char *b)
-{
- long chunksize = 0;
-
- while (ap_isxdigit(*b)) {
- int xvalue = 0;
-
- if (*b >= '0' && *b <= '9')
- xvalue = *b - '0';
- else if (*b >= 'A' && *b <= 'F')
- xvalue = *b - 'A' + 0xa;
- else if (*b >= 'a' && *b <= 'f')
- xvalue = *b - 'a' + 0xa;
-
- chunksize = (chunksize << 4) | xvalue;
- ++b;
- }
-
- return chunksize;
-}
-
-/* get_client_block is called in a loop to get the request message body.
- * This is quite simple if the client includes a content-length
- * (the normal case), but gets messy if the body is chunked. Note that
- * r->remaining is used to maintain state across calls and that
- * r->read_length is the total number of bytes given to the caller
- * across all invocations. It is messy because we have to be careful not
- * to read past the data provided by the client, since these reads block.
- * Returns 0 on End-of-body, -1 on error or premature chunk end.
- *
- * Reading the chunked encoding requires a buffer size large enough to
- * hold a chunk-size line, including any extensions. For now, we'll leave
- * that to the caller, at least until we can come up with a better solution.
- */
-API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz)
-{
- int c;
- ap_size_t len_to_read;
- ap_ssize_t len_read;
- long chunk_start = 0;
- unsigned long max_body;
- ap_status_t rv;
-
- if (!r->read_chunked) { /* Content-length read */
- len_to_read = (r->remaining > bufsiz) ? bufsiz : r->remaining;
- rv = ap_bread(r->connection->client, buffer, len_to_read, &len_read);
- if (len_read == 0) { /* error or eof */
- if (rv != APR_SUCCESS) {
- r->connection->keepalive = -1;
- return -1;
- }
- return 0;
- }
- r->read_length += len_read;
- r->remaining -= len_read;
- return len_read;
- }
-
- /*
- * Handle chunked reading Note: we are careful to shorten the input
- * bufsiz so that there will always be enough space for us to add a CRLF
- * (if necessary).
- */
- if (r->read_body == REQUEST_CHUNKED_PASS)
- bufsiz -= 2;
- if (bufsiz <= 0)
- return -1; /* Cannot read chunked with a small buffer */
-
- /* Check to see if we have already read too much request data.
- * For efficiency reasons, we only check this at the top of each
- * caller read pass, since the limit exists just to stop infinite
- * length requests and nobody cares if it goes over by one buffer.
- */
- max_body = ap_get_limit_req_body(r);
- if (max_body && (r->read_length > max_body)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Chunked request body is larger than the configured limit of %lu",
- max_body);
- r->connection->keepalive = -1;
- return -1;
- }
-
- if (r->remaining == 0) { /* Start of new chunk */
-
- chunk_start = getline(buffer, bufsiz, r->connection->client, 0);
- if ((chunk_start <= 0) || (chunk_start >= (bufsiz - 1))
- || !ap_isxdigit(*buffer)) {
- r->connection->keepalive = -1;
- return -1;
- }
-
- len_to_read = get_chunk_size(buffer);
-
- if (len_to_read == 0) { /* Last chunk indicated, get footers */
- if (r->read_body == REQUEST_CHUNKED_DECHUNK) {
- get_mime_headers(r);
- ap_snprintf(buffer, bufsiz, "%ld", r->read_length);
- ap_table_unset(r->headers_in, "Transfer-Encoding");
- ap_table_setn(r->headers_in, "Content-Length",
- ap_pstrdup(r->pool, buffer));
- return 0;
- }
- r->remaining = -1; /* Indicate footers in-progress */
- }
- else {
- r->remaining = len_to_read;
- }
- if (r->read_body == REQUEST_CHUNKED_PASS) {
- buffer[chunk_start++] = CR; /* Restore chunk-size line end */
- buffer[chunk_start++] = LF;
- buffer += chunk_start; /* and pass line on to caller */
- bufsiz -= chunk_start;
- }
- else {
- /* REQUEST_CHUNKED_DECHUNK -- do not include the length of the
- * header in the return value
- */
- chunk_start = 0;
- }
- }
- /* When REQUEST_CHUNKED_PASS, we are */
- if (r->remaining == -1) { /* reading footers until empty line */
- len_read = chunk_start;
-
- while ((bufsiz > 1) && ((len_read =
- getline(buffer, bufsiz, r->connection->client, 1)) > 0)) {
-
- if (len_read != (bufsiz - 1)) {
- buffer[len_read++] = CR; /* Restore footer line end */
- buffer[len_read++] = LF;
- }
- chunk_start += len_read;
- buffer += len_read;
- bufsiz -= len_read;
- }
- if (len_read < 0) {
- r->connection->keepalive = -1;
- return -1;
- }
-
- if (len_read == 0) { /* Indicates an empty line */
- buffer[0] = CR;
- buffer[1] = LF;
- chunk_start += 2;
- r->remaining = -2;
- }
- r->read_length += chunk_start;
- return chunk_start;
- }
- /* When REQUEST_CHUNKED_PASS, we */
- if (r->remaining == -2) { /* finished footers when last called */
- r->remaining = 0; /* so now we must signal EOF */
- return 0;
- }
-
- /* Otherwise, we are in the midst of reading a chunk of data */
-
- len_to_read = (r->remaining > bufsiz) ? bufsiz : r->remaining;
-
- (void) ap_bread(r->connection->client, buffer, len_to_read, &len_read);
- if (len_read == 0) { /* error or eof */
- r->connection->keepalive = -1;
- return -1;
- }
-
- r->remaining -= len_read;
-
- if (r->remaining == 0) { /* End of chunk, get trailing CRLF */
- if ((c = ap_bgetc(r->connection->client)) == CR) {
- c = ap_bgetc(r->connection->client);
- }
- if (c != LF) {
- r->connection->keepalive = -1;
- return -1;
- }
- if (r->read_body == REQUEST_CHUNKED_PASS) {
- buffer[len_read++] = CR;
- buffer[len_read++] = LF;
- }
- }
- r->read_length += (chunk_start + len_read);
-
- return (chunk_start + len_read);
-}
-
-/* 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.
- *
- * Since we return an error status if the request is malformed, this
- * routine should be called at the beginning of a no-body handler, e.g.,
- *
- * if ((retval = ap_discard_request_body(r)) != OK)
- * return retval;
- */
-API_EXPORT(int) ap_discard_request_body(request_rec *r)
-{
- int rv;
-
- if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_PASS)))
- return rv;
-
- /* In order to avoid sending 100 Continue when we already know the
- * final response status, and yet not kill the connection if there is
- * no request body to be read, we need to duplicate the test from
- * ap_should_client_block() here negated rather than call it directly.
- */
- if ((r->read_length == 0) && (r->read_chunked || (r->remaining > 0))) {
- char dumpbuf[HUGE_STRING_LEN];
-
- if (r->expecting_100) {
- r->connection->keepalive = -1;
- return OK;
- }
-
- while ((rv = ap_get_client_block(r, dumpbuf, HUGE_STRING_LEN)) > 0)
- continue;
-
- if (rv < 0)
- return HTTP_BAD_REQUEST;
- }
- return OK;
-}
-
-/*
- * Send the body of a response to the client.
- */
-API_EXPORT(long) ap_send_fd(ap_file_t *fd, request_rec *r)
-{
- ap_status_t rv;
- long len = r->finfo.size;
-#ifdef HAVE_SENDFILE
- if (!r->chunked) {
- ap_bsetopt(r->connection->client, BO_TIMEOUT,
- r->connection->keptalive
- ? &r->server->keep_alive_timeout
- : &r->server->timeout);
- ap_bflush(r->connection->client);
- rv = iol_sendfile(r->connection->client->iol,
- fd, /* The file to send */
- NULL, /* header and trailer iovecs */
- 0, /* Offset in file to begin sending from */
- &len,
- 0);
- if (rv != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "ap_send_fd: iol_sendfile failed.");
- }
- if (r->connection->keptalive) {
- ap_bsetopt(r->connection->client, BO_TIMEOUT,
- &r->server->timeout);
- }
- }
- else {
- len = ap_send_fd_length(fd, r, -1);
- }
-#else
- len = ap_send_fd_length(fd, r, -1);
-#endif
- return len;
-}
-
-API_EXPORT(long) ap_send_fd_length(ap_file_t *fd, request_rec *r, long length)
-{
- char buf[IOBUFSIZE];
- long total_bytes_sent = 0;
- register int o;
- ap_ssize_t w;
- ap_ssize_t n;
- ap_status_t rv;
-
- if (length == 0)
- return 0;
-
- while (!ap_is_aborted(r->connection)) {
- if ((length > 0) && (total_bytes_sent + IOBUFSIZE) > length)
- o = length - total_bytes_sent;
- else
- o = IOBUFSIZE;
-
- n = o;
- do {
- rv = ap_read(fd, buf, &n);
- } while (rv == APR_EINTR && !ap_is_aborted(r->connection));
-
- if (n < 1) {
- break;
- }
-
- o = 0;
-
- while (n && !ap_is_aborted(r->connection)) {
- rv = ap_bwrite(r->connection->client, &buf[o], n, &w);
- if (w > 0) {
- total_bytes_sent += w;
- n -= w;
- o += w;
- }
- else if (rv != APR_SUCCESS) {
- if (!ap_is_aborted(r->connection)) {
- ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r,
- "client stopped connection before send body completed");
- ap_bsetflag(r->connection->client, B_EOUT, 1);
- r->connection->aborted = 1;
- }
- break;
- }
- }
- }
-
- SET_BYTES_SENT(r);
- return total_bytes_sent;
-}
-
-/*
- * Send the body of a response to the client.
- */
-API_EXPORT(long) ap_send_fb(BUFF *fb, request_rec *r)
-{
- return ap_send_fb_length(fb, r, -1);
-}
-
-API_EXPORT(long) ap_send_fb_length(BUFF *fb, request_rec *r, long length)
-{
- char buf[IOBUFSIZE];
- long total_bytes_sent = 0;
- long zero_timeout = 0;
- register int o;
- ap_ssize_t w;
- ap_ssize_t n;
- ap_status_t rv;
-
- if (length == 0) {
- return 0;
- }
-
- /* This function tries to as much as possible through non-blocking
- * reads so that it can do writes while waiting for the CGI to
- * produce more data. This way, the CGI's output gets to the client
- * as soon as possible */
-
- ap_bsetopt(fb, BO_TIMEOUT, &zero_timeout);
- while (!ap_is_aborted(r->connection)) {
- rv = ap_bread(fb, buf, sizeof(buf), &n);
- if (n == 0) {
- if (rv == APR_SUCCESS) { /* eof */
- (void) ap_rflush(r);
- break;
- }
- if (rv != APR_EAGAIN) {
- r->connection->aborted = 1;
- break;
- }
- /* next read will block, so flush the client now */
- if (ap_rflush(r) == EOF) {
- break;
- }
-
- ap_bsetopt(fb, BO_TIMEOUT, &r->server->timeout);
- rv = ap_bread(fb, buf, sizeof(buf), &n);
- if (n == 0) {
- if (rv == APR_SUCCESS) { /* eof */
- (void) ap_rflush(r);
- }
- r->connection->aborted = 1;
- break;
- }
- ap_bsetopt(fb, BO_TIMEOUT, &zero_timeout);
- }
-
- o = 0;
- while (n && !ap_is_aborted(r->connection)) {
- rv = ap_bwrite(r->connection->client, &buf[o], n, &w);
- if (w > 0) {
- total_bytes_sent += w;
- n -= w;
- o += w;
- }
- else if (rv != APR_SUCCESS) {
- if (!ap_is_aborted(r->connection)) {
- ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r,
- "client stopped connection before rflush completed");
- ap_bsetflag(r->connection->client, B_EOUT, 1);
- r->connection->aborted = 1;
- }
- break;
- }
- }
- }
- SET_BYTES_SENT(r);
- return total_bytes_sent;
-}
-
-#ifdef USE_MMAP_FILES
-
-/* The code writes MMAP_SEGMENT_SIZE bytes at a time. This is due to Apache's
- * timeout model, which is a timeout per-write rather than a time for the
- * entire transaction to complete. Essentially this should be small enough
- * so that in one Timeout period, your slowest clients should be reasonably
- * able to receive this many bytes.
- *
- * To take advantage of zero-copy TCP under Solaris 2.6 this should be a
- * multiple of 16k. (And you need a SunATM2.0 network card.)
- */
-#ifndef MMAP_SEGMENT_SIZE
-#define MMAP_SEGMENT_SIZE 32768
-#endif
-
-/* send data from an in-memory buffer */
-API_EXPORT(size_t) ap_send_mmap(ap_mmap_t *mm, request_rec *r, size_t offset,
- size_t length)
-{
- size_t total_bytes_sent = 0;
- int n;
- ap_ssize_t w;
- ap_status_t rv;
- char *addr;
-
- if (length == 0)
- return 0;
-
-
- length += offset;
- while (!r->connection->aborted && offset < length) {
- if (length - offset > MMAP_SEGMENT_SIZE) {
- n = MMAP_SEGMENT_SIZE;
- }
- else {
- n = length - offset;
- }
-
- while (n && !r->connection->aborted) {
- ap_mmap_offset((void**)&addr, mm, offset);
- rv = ap_bwrite(r->connection->client, addr, n, &w);
- if (w > 0) {
- total_bytes_sent += w;
- n -= w;
- offset += w;
- }
- else if (rv != APR_SUCCESS) {
- if (r->connection->aborted)
- break;
- else if (rv == EAGAIN)
- continue;
- else {
- ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r,
- "client stopped connection before send mmap completed");
- ap_bsetflag(r->connection->client, B_EOUT, 1);
- r->connection->aborted = 1;
- break;
- }
- }
- }
- }
-
- SET_BYTES_SENT(r);
- return total_bytes_sent;
-}
-#endif /* USE_MMAP_FILES */
-
-API_EXPORT(int) ap_rputc(int c, request_rec *r)
-{
- if (r->connection->aborted)
- return EOF;
-
- if (ap_bputc(c, r->connection->client) < 0) {
- if (!r->connection->aborted) {
- ap_log_rerror(APLOG_MARK, APLOG_INFO,
- ap_berror(r->connection->client), r,
- "client stopped connection before rputc completed");
- ap_bsetflag(r->connection->client, B_EOUT, 1);
- r->connection->aborted = 1;
- }
- return EOF;
- }
- SET_BYTES_SENT(r);
- return c;
-}
-
-API_EXPORT(int) ap_rputs(const char *str, request_rec *r)
-{
- int rcode;
-
- if (r->connection->aborted)
- return EOF;
-
- rcode = ap_bputs(str, r->connection->client);
- if (rcode < 0) {
- if (!r->connection->aborted) {
- ap_log_rerror(APLOG_MARK, APLOG_INFO,
- ap_berror(r->connection->client), r,
- "client stopped connection before rputs completed");
- ap_bsetflag(r->connection->client, B_EOUT, 1);
- r->connection->aborted = 1;
- }
- return EOF;
- }
- SET_BYTES_SENT(r);
- return rcode;
-}
-
-API_EXPORT(int) ap_rwrite(const void *buf, int nbyte, request_rec *r)
-{
- ap_ssize_t n;
- ap_status_t rv;
-
- if (r->connection->aborted)
- return EOF;
-
- rv = ap_bwrite(r->connection->client, buf, nbyte, &n);
- if (n < 0) {
- if (!r->connection->aborted) {
- ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r,
- "client stopped connection before rwrite completed");
- ap_bsetflag(r->connection->client, B_EOUT, 1);
- r->connection->aborted = 1;
- }
- return EOF;
- }
- SET_BYTES_SENT(r);
- return n;
-}
-
-API_EXPORT(int) ap_vrprintf(request_rec *r, const char *fmt, va_list ap)
-{
- int n;
-
- if (r->connection->aborted)
- return -1;
-
- n = ap_vbprintf(r->connection->client, fmt, ap);
-
- if (n < 0) {
- if (!r->connection->aborted) {
- ap_log_rerror(APLOG_MARK, APLOG_INFO,
- ap_berror(r->connection->client), r,
- "client stopped connection before vrprintf completed");
- ap_bsetflag(r->connection->client, B_EOUT, 1);
- r->connection->aborted = 1;
- }
- return -1;
- }
- SET_BYTES_SENT(r);
- return n;
-}
-
-API_EXPORT(int) ap_rprintf(request_rec *r, const char *fmt,...)
-{
- va_list vlist;
- int n;
-
- if (r->connection->aborted)
- return -1;
-
- va_start(vlist, fmt);
- n = ap_vbprintf(r->connection->client, fmt, vlist);
- va_end(vlist);
-
- if (n < 0) {
- if (!r->connection->aborted) {
- ap_log_rerror(APLOG_MARK, APLOG_INFO,
- ap_berror(r->connection->client), r,
- "client stopped connection before rprintf completed");
- ap_bsetflag(r->connection->client, B_EOUT, 1);
- r->connection->aborted = 1;
- }
- return -1;
- }
- SET_BYTES_SENT(r);
- return n;
-}
-
-API_EXPORT_NONSTD(int) ap_rvputs(request_rec *r,...)
-{
- va_list args;
- ap_ssize_t i;
- int j, k;
- const char *x;
- BUFF *fb = r->connection->client;
- ap_status_t rv;
-
- if (r->connection->aborted)
- return EOF;
-
- va_start(args, r);
- for (k = 0;;) {
- x = va_arg(args, const char *);
- if (x == NULL)
- break;
- j = strlen(x);
- rv = ap_bwrite(fb, x, j, &i);
- if (i != j) {
- va_end(args);
- if (!r->connection->aborted) {
- ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r,
- "client stopped connection before rvputs completed");
- ap_bsetflag(r->connection->client, B_EOUT, 1);
- r->connection->aborted = 1;
- }
- return EOF;
- }
- k += i;
- }
- va_end(args);
-
- SET_BYTES_SENT(r);
- return k;
-}
-
-API_EXPORT(int) ap_rflush(request_rec *r)
-{
- ap_status_t rv;
-
- if ((rv = ap_bflush(r->connection->client)) != APR_SUCCESS) {
- if (!ap_is_aborted(r->connection)) {
- ap_log_rerror(APLOG_MARK, APLOG_INFO, rv, r,
- "client stopped connection before rflush completed");
- ap_bsetflag(r->connection->client, B_EOUT, 1);
- r->connection->aborted = 1;
- }
- return EOF;
- }
- return 0;
-}
-
-/* We should have named this send_canned_response, since it is used for any
- * response that can be generated by the server from the request record.
- * This includes all 204 (no content), 3xx (redirect), 4xx (client error),
- * and 5xx (server error) messages that have not been redirected to another
- * handler via the ErrorDocument feature.
- */
-API_EXPORT(void) ap_send_error_response(request_rec *r, int recursive_error)
-{
- int status = r->status;
- int idx = ap_index_of_response(status);
- char *custom_response;
- const char *location = ap_table_get(r->headers_out, "Location");
-
- /*
- * It's possible that the Location field might be in r->err_headers_out
- * instead of r->headers_out; use the latter if possible, else the
- * former.
- */
- if (location == NULL) {
- location = ap_table_get(r->err_headers_out, "Location");
- }
- /* We need to special-case the handling of 204 and 304 responses,
- * since they have specific HTTP requirements and do not include a
- * message body. Note that being assbackwards here is not an option.
- */
- if (status == HTTP_NOT_MODIFIED) {
- if (!ap_is_empty_table(r->err_headers_out))
- r->headers_out = ap_overlay_tables(r->pool, r->err_headers_out,
- r->headers_out);
- ap_basic_http_header(r);
- ap_set_keepalive(r);
-
- ap_table_do((int (*)(void *, const char *, const char *)) ap_send_header_field,
- (void *) r, r->headers_out,
- "Connection",
- "Keep-Alive",
- "ETag",
- "Content-Location",
- "Expires",
- "Cache-Control",
- "Vary",
- "Warning",
- "WWW-Authenticate",
- "Proxy-Authenticate",
- NULL);
-
- terminate_header(r);
-
- return;
- }
-
- if (status == HTTP_NO_CONTENT) {
- ap_send_http_header(r);
- ap_finalize_request_protocol(r);
- return;
- }
-
- if (!r->assbackwards) {
- ap_table_t *tmp = r->headers_out;
-
- /* For all HTTP/1.x responses for which we generate the message,
- * we need to avoid inheriting the "normal status" header fields
- * that may have been set by the request handler before the
- * error or redirect, except for Location on external redirects.
- */
- r->headers_out = r->err_headers_out;
- r->err_headers_out = tmp;
- ap_clear_table(r->err_headers_out);
-
- if (ap_is_HTTP_REDIRECT(status) || (status == HTTP_CREATED)) {
- if ((location != NULL) && *location) {
- ap_table_setn(r->headers_out, "Location", location);
- }
- else {
- location = ""; /* avoids coredump when printing, below */
- }
- }
-
- r->content_language = NULL;
- r->content_languages = NULL;
- r->content_encoding = NULL;
- r->clength = 0;
- r->content_type = "text/html";
-
- if ((status == METHOD_NOT_ALLOWED) || (status == NOT_IMPLEMENTED))
- ap_table_setn(r->headers_out, "Allow", make_allow(r));
-
- ap_send_http_header(r);
-
- if (r->header_only) {
- ap_finalize_request_protocol(r);
- ap_rflush(r);
- return;
- }
- }
-
- if ((custom_response = ap_response_code_string(r, idx))) {
- /*
- * We have a custom response output. This should only be
- * a text-string to write back. But if the ErrorDocument
- * was a local redirect and the requested resource failed
- * for any reason, the custom_response will still hold the
- * redirect URL. We don't really want to output this URL
- * as a text message, so first check the custom response
- * string to ensure that it is a text-string (using the
- * same test used in ap_die(), i.e. does it start with a ").
- * If it doesn't, we've got a recursive error, so find
- * the original error and output that as well.
- */
- if (custom_response[0] == '\"') {
- ap_rputs(custom_response + 1, r);
- ap_finalize_request_protocol(r);
- ap_rflush(r);
- return;
- }
- /*
- * Redirect failed, so get back the original error
- */
- while (r->prev && (r->prev->status != HTTP_OK))
- r = r->prev;
- }
- {
- const char *title = status_lines[idx];
- const char *h1;
- const char *error_notes;
-
- /* Accept a status_line set by a module, but only if it begins
- * with the 3 digit status code
- */
- if (r->status_line != NULL
- && strlen(r->status_line) > 4 /* long enough */
- && ap_isdigit(r->status_line[0])
- && ap_isdigit(r->status_line[1])
- && ap_isdigit(r->status_line[2])
- && ap_isspace(r->status_line[3])
- && ap_isalnum(r->status_line[4])) {
- title = r->status_line;
- }
-
- /* folks decided they didn't want the error code in the H1 text */
- h1 = &title[4];
-
- ap_rvputs(r,
- DOCTYPE_HTML_2_0
- "<HTML><HEAD>\n<TITLE>", title,
- "</TITLE>\n</HEAD><BODY>\n<H1>", h1, "</H1>\n",
- NULL);
-
- switch (status) {
- case HTTP_MOVED_PERMANENTLY:
- case HTTP_MOVED_TEMPORARILY:
- case HTTP_TEMPORARY_REDIRECT:
- ap_rvputs(r, "The document has moved <A HREF=\"",
- ap_escape_html(r->pool, location), "\">here</A>.<P>\n",
- NULL);
- break;
- case HTTP_SEE_OTHER:
- ap_rvputs(r, "The answer to your request is located <A HREF=\"",
- ap_escape_html(r->pool, location), "\">here</A>.<P>\n",
- NULL);
- break;
- case HTTP_USE_PROXY:
- ap_rvputs(r, "This resource is only accessible "
- "through the proxy\n",
- ap_escape_html(r->pool, location),
- "<BR>\nYou will need to ",
- "configure your client to use that proxy.<P>\n", NULL);
- break;
- case HTTP_PROXY_AUTHENTICATION_REQUIRED:
- case AUTH_REQUIRED:
- ap_rputs("This server could not verify that you\n"
- "are authorized to access the document\n"
- "requested. Either you supplied the wrong\n"
- "credentials (e.g., bad password), or your\n"
- "browser doesn't understand how to supply\n"
- "the credentials required.<P>\n", r);
- break;
- case BAD_REQUEST:
- ap_rputs("Your browser sent a request that "
- "this server could not understand.<P>\n", r);
- if ((error_notes = ap_table_get(r->notes, "error-notes")) != NULL) {
- ap_rvputs(r, error_notes, "<P>\n", NULL);
- }
- break;
- case HTTP_FORBIDDEN:
- ap_rvputs(r, "You don't have permission to access ",
- ap_escape_html(r->pool, r->uri),
- "\non this server.<P>\n", NULL);
- break;
- case NOT_FOUND:
- ap_rvputs(r, "The requested URL ",
- ap_escape_html(r->pool, r->uri),
- " was not found on this server.<P>\n", NULL);
- break;
- case METHOD_NOT_ALLOWED:
- ap_rvputs(r, "The requested method ", r->method,
- " is not allowed "
- "for the URL ", ap_escape_html(r->pool, r->uri),
- ".<P>\n", NULL);
- break;
- case NOT_ACCEPTABLE:
- ap_rvputs(r,
- "An appropriate representation of the "
- "requested resource ",
- ap_escape_html(r->pool, r->uri),
- " could not be found on this server.<P>\n", NULL);
- /* fall through */
- case MULTIPLE_CHOICES:
- {
- const char *list;
- if ((list = ap_table_get(r->notes, "variant-list")))
- ap_rputs(list, r);
- }
- break;
- case LENGTH_REQUIRED:
- ap_rvputs(r, "A request of the requested method ", r->method,
- " requires a valid Content-length.<P>\n", NULL);
- if ((error_notes = ap_table_get(r->notes, "error-notes")) != NULL) {
- ap_rvputs(r, error_notes, "<P>\n", NULL);
- }
- break;
- case PRECONDITION_FAILED:
- ap_rvputs(r, "The precondition on the request for the URL ",
- ap_escape_html(r->pool, r->uri),
- " evaluated to false.<P>\n", NULL);
- break;
- case HTTP_NOT_IMPLEMENTED:
- ap_rvputs(r, ap_escape_html(r->pool, r->method), " to ",
- ap_escape_html(r->pool, r->uri),
- " not supported.<P>\n", NULL);
- if ((error_notes = ap_table_get(r->notes, "error-notes")) != NULL) {
- ap_rvputs(r, error_notes, "<P>\n", NULL);
- }
- break;
- case BAD_GATEWAY:
- ap_rputs("The proxy server received an invalid\015\012"
- "response from an upstream server.<P>\015\012", r);
- if ((error_notes = ap_table_get(r->notes, "error-notes")) != NULL) {
- ap_rvputs(r, error_notes, "<P>\n", NULL);
- }
- break;
- case VARIANT_ALSO_VARIES:
- ap_rvputs(r, "A variant for the requested resource\n<PRE>\n",
- ap_escape_html(r->pool, r->uri),
- "\n</PRE>\nis itself a negotiable resource. "
- "This indicates a configuration error.<P>\n", NULL);
- break;
- case HTTP_REQUEST_TIME_OUT:
- ap_rputs("I'm tired of waiting for your request.\n", r);
- break;
- case HTTP_GONE:
- ap_rvputs(r, "The requested resource<BR>",
- ap_escape_html(r->pool, r->uri),
- "<BR>\nis no longer available on this server ",
- "and there is no forwarding address.\n",
- "Please remove all references to this resource.\n",
- NULL);
- break;
- case HTTP_REQUEST_ENTITY_TOO_LARGE:
- ap_rvputs(r, "The requested resource<BR>",
- ap_escape_html(r->pool, r->uri), "<BR>\n",
- "does not allow request data with ", r->method,
- " requests, or the amount of data provided in\n",
- "the request exceeds the capacity limit.\n", NULL);
- break;
- case HTTP_REQUEST_URI_TOO_LARGE:
- ap_rputs("The requested URL's length exceeds the capacity\n"
- "limit for this server.<P>\n", r);
- if ((error_notes = ap_table_get(r->notes, "error-notes")) != NULL) {
- ap_rvputs(r, error_notes, "<P>\n", NULL);
- }
- break;
- case HTTP_UNSUPPORTED_MEDIA_TYPE:
- ap_rputs("The supplied request data is not in a format\n"
- "acceptable for processing by this resource.\n", r);
- break;
- case HTTP_RANGE_NOT_SATISFIABLE:
- ap_rputs("None of the range-specifier values in the Range\n"
- "request-header field overlap the current extent\n"
- "of the selected resource.\n", r);
- break;
- case HTTP_EXPECTATION_FAILED:
- ap_rvputs(r, "The expectation given in the Expect request-header"
- "\nfield could not be met by this server.<P>\n"
- "The client sent<PRE>\n Expect: ",
- ap_table_get(r->headers_in, "Expect"), "\n</PRE>\n"
- "but we only allow the 100-continue expectation.\n",
- NULL);
- break;
- case HTTP_UNPROCESSABLE_ENTITY:
- ap_rputs("The server understands the media type of the\n"
- "request entity, but was unable to process the\n"
- "contained instructions.\n", r);
- break;
- case HTTP_LOCKED:
- ap_rputs("The requested resource is currently locked.\n"
- "The lock must be released or proper identification\n"
- "given before the method can be applied.\n", r);
- break;
- case HTTP_FAILED_DEPENDENCY:
- ap_rputs("The method could not be performed on the resource\n"
- "because the requested action depended on another\n"
- "action and that other action failed.\n", r);
- break;
- case HTTP_INSUFFICIENT_STORAGE:
- ap_rputs("The method could not be performed on the resource\n"
- "because the server is unable to store the\n"
- "representation needed to successfully complete the\n"
- "request. There is insufficient free space left in\n"
- "your storage allocation.\n", r);
- break;
- case HTTP_SERVICE_UNAVAILABLE:
- ap_rputs("The server is temporarily unable to service your\n"
- "request due to maintenance downtime or capacity\n"
- "problems. Please try again later.\n", r);
- break;
- case HTTP_GATEWAY_TIME_OUT:
- ap_rputs("The proxy server did not receive a timely response\n"
- "from the upstream server.\n", r);
- break;
- case HTTP_NOT_EXTENDED:
- ap_rputs("A mandatory extension policy in the request is not\n"
- "accepted by the server for this resource.\n", r);
- break;
- default: /* HTTP_INTERNAL_SERVER_ERROR */
- /*
- * This comparison to expose error-notes could be modified to
- * use a configuration directive and export based on that
- * directive. For now "*" is used to designate an error-notes
- * that is totally safe for any user to see (ie lacks paths,
- * database passwords, etc.)
- */
- if (((error_notes = ap_table_get(r->notes, "error-notes")) != NULL)
- && (h1 = ap_table_get(r->notes, "verbose-error-to")) != NULL
- && (strcmp(h1, "*") == 0)) {
- ap_rvputs(r, error_notes, "<P>\n", NULL);
- }
- else {
- ap_rvputs(r, "The server encountered an internal error or\n"
- "misconfiguration and was unable to complete\n"
- "your request.<P>\n"
- "Please contact the server administrator,\n ",
- ap_escape_html(r->pool, r->server->server_admin),
- " and inform them of the time the error occurred,\n"
- "and anything you might have done that may have\n"
- "caused the error.<P>\n"
- "More information about this error may be available\n"
- "in the server error log.<P>\n", NULL);
- }
- /*
- * It would be nice to give the user the information they need to
- * fix the problem directly since many users don't have access to
- * the error_log (think University sites) even though they can easily
- * get this error by misconfiguring an htaccess file. However, the
- * error notes tend to include the real file pathname in this case,
- * which some people consider to be a breach of privacy. Until we
- * can figure out a way to remove the pathname, leave this commented.
- *
- * if ((error_notes = ap_table_get(r->notes, "error-notes")) != NULL) {
- * ap_rvputs(r, error_notes, "<P>\n", NULL);
- * }
- */
- break;
- }
-
- if (recursive_error) {
- ap_rvputs(r, "<P>Additionally, a ",
- status_lines[ap_index_of_response(recursive_error)],
- "\nerror was encountered while trying to use an "
- "ErrorDocument to handle the request.\n", NULL);
- }
- ap_rputs(ap_psignature("<HR>\n", r), r);
- ap_rputs("</BODY></HTML>\n", r);
- }
- ap_finalize_request_protocol(r);
- ap_rflush(r);
-}
-
-IMPLEMENT_HOOK_RUN_ALL(int,post_read_request,(request_rec *r),(r),OK,DECLINED)
-IMPLEMENT_HOOK_RUN_ALL(int,log_transaction,(request_rec *r),(r),OK,DECLINED)
-IMPLEMENT_HOOK_RUN_FIRST(const char *,http_method,(const request_rec *r),(r),
- NULL)
-IMPLEMENT_HOOK_RUN_FIRST(unsigned short,default_port,(const request_rec *r),
- (r),0)
diff --git a/modules/http/http_request.c b/modules/http/http_request.c
deleted file mode 100644
index add4a9ec96..0000000000
--- a/modules/http/http_request.c
+++ /dev/null
@@ -1,1384 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_request.c: functions to get and process requests
- *
- * Rob McCool 3/21/93
- *
- * Thoroughly revamped by rst for Apache. NB this file reads
- * best from the bottom up.
- *
- */
-
-#define CORE_PRIVATE
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "apr_fnmatch.h"
-
-HOOK_STRUCT(
- HOOK_LINK(translate_name)
- HOOK_LINK(check_user_id)
- HOOK_LINK(fixups)
- HOOK_LINK(type_checker)
- HOOK_LINK(access_checker)
- HOOK_LINK(auth_checker)
-)
-
-IMPLEMENT_HOOK_RUN_FIRST(int,translate_name,(request_rec *r),(r),DECLINED)
-IMPLEMENT_HOOK_RUN_FIRST(int,check_user_id,(request_rec *r),(r),DECLINED)
-IMPLEMENT_HOOK_RUN_ALL(int,fixups,(request_rec *r),(r),OK,DECLINED)
-IMPLEMENT_HOOK_RUN_FIRST(int,type_checker,(request_rec *r),(r),DECLINED)
-IMPLEMENT_HOOK_RUN_ALL(int,access_checker,(request_rec *r),(r),OK,DECLINED)
-IMPLEMENT_HOOK_RUN_FIRST(int,auth_checker,(request_rec *r),(r),DECLINED)
-
-/*****************************************************************
- *
- * Getting and checking directory configuration. Also checks the
- * FollowSymlinks and FollowSymOwner stuff, since this is really the
- * only place that can happen (barring a new mid_dir_walk callout).
- *
- * We can't do it as an access_checker module function which gets
- * called with the final per_dir_config, since we could have a directory
- * with FollowSymLinks disabled, which contains a symlink to another
- * with a .htaccess file which turns FollowSymLinks back on --- and
- * access in such a case must be denied. So, whatever it is that
- * checks FollowSymLinks needs to know the state of the options as
- * they change, all the way down.
- */
-
-/*
- * We don't want people able to serve up pipes, or unix sockets, or other
- * scary things. Note that symlink tests are performed later.
- */
-static int check_safe_file(request_rec *r)
-{
-
- if (r->finfo.protection == 0 /* doesn't exist */
- || r->finfo.filetype == APR_DIR
- || r->finfo.filetype == APR_REG
- || r->finfo.filetype == APR_LNK) {
- return OK;
- }
-
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "object is not a file, directory or symlink: %s",
- r->filename);
- return HTTP_FORBIDDEN;
-}
-
-
-static int check_symlinks(char *d, int opts)
-{
-#if defined(OS2) || defined(WIN32)
- /* OS/2 doesn't have symlinks */
- return OK;
-#else
- struct stat lfi, fi;
- char *lastp;
- int res;
-
- if (opts & OPT_SYM_LINKS)
- return OK;
-
- /*
- * Strip trailing '/', if any, off what we're checking; trailing slashes
- * make some systems follow symlinks to directories even in lstat().
- * After we've done the lstat, put it back. Also, don't bother checking
- * '/' at all...
- *
- * Note that we don't have to worry about multiple slashes here because of
- * no2slash() below...
- */
-
- lastp = d + strlen(d) - 1;
- if (lastp == d)
- return OK; /* Root directory, '/' */
-
- if (*lastp == '/')
- *lastp = '\0';
- else
- lastp = NULL;
-
- res = lstat(d, &lfi);
-
- if (lastp)
- *lastp = '/';
-
- /*
- * Note that we don't reject accesses to nonexistent files (multiviews or
- * the like may cons up a way to run the transaction anyway)...
- */
-
- if (!(res >= 0) || !S_ISLNK(lfi.st_mode))
- return OK;
-
- /* OK, it's a symlink. May still be OK with OPT_SYM_OWNER */
-
- if (!(opts & OPT_SYM_OWNER))
- return HTTP_FORBIDDEN;
-
- if (stat(d, &fi) < 0)
- return HTTP_FORBIDDEN;
-
- return (fi.st_uid == lfi.st_uid) ? OK : HTTP_FORBIDDEN;
-
-#endif
-}
-
-/* Dealing with the file system to get PATH_INFO
- */
-static int get_path_info(request_rec *r)
-{
- char *cp;
- char *path = r->filename;
- char *end = &path[strlen(path)];
- char *last_cp = NULL;
- int rv;
-#ifdef HAVE_DRIVE_LETTERS
- char bStripSlash=1;
-#endif
-
- if (r->finfo.protection) {
- /* assume path_info already set */
- return OK;
- }
-
-#ifdef HAVE_DRIVE_LETTERS
- /* If the directory is x:\, then we don't want to strip
- * the trailing slash since x: is not a valid directory.
- */
- if (strlen(path) == 3 && path[1] == ':' && path[2] == '/')
- bStripSlash = 0;
-
-
- /* If UNC name == //machine/share/, do not
- * advance over the trailing slash. Any other
- * UNC name is OK to strip the slash.
- */
- cp = end;
- if (strlen(path) > 2 && path[0] == '/' && path[1] == '/' &&
- path[2] != '/' && cp[-1] == '/') {
- char *p;
- int iCount=0;
- p = path;
- while ((p = strchr(p,'/')) != NULL) {
- p++;
- iCount++;
- }
-
- if (iCount == 4)
- bStripSlash = 0;
- }
-
- if (bStripSlash)
-#endif
- /* Advance over trailing slashes ... NOT part of filename
- * if file is not a UNC name (Win32 only).
- */
- for (cp = end; cp > path && cp[-1] == '/'; --cp)
- continue;
-
-
- while (cp > path) {
-
- /* See if the pathname ending here exists... */
-
- *cp = '\0';
-
- /* We must not stat() filenames that may cause os-specific system
- * problems, such as "/file/aux" on DOS-abused filesystems.
- * So pretend that they do not exist by returning an ENOENT error.
- * This will force us to drop that part of the path and keep
- * looking back for a "real" file that exists, while still allowing
- * the "invalid" path parts within the PATH_INFO.
- */
- if (!ap_os_is_filename_valid(path)) {
- errno = ENOENT;
- rv = -1;
- }
- else {
- errno = 0;
- rv = ap_stat(&r->finfo, path, r->pool);
- }
-
- if (cp != end)
- *cp = '/';
-
- if (rv == APR_SUCCESS) {
- /*
- * Aha! Found something. If it was a directory, we will search
- * contents of that directory for a multi_match, so the PATH_INFO
- * argument starts with the component after that.
- */
- if (r->finfo.filetype == APR_DIR && last_cp) {
- r->finfo.protection = 0; /* No such file... */
- r->finfo.filetype = APR_NOFILE; /* No such file... */
- cp = last_cp;
- }
-
- r->path_info = ap_pstrdup(r->pool, cp);
- *cp = '\0';
- return OK;
- }
- /* must set this to zero, some stat()s may have corrupted it
- * even if they returned an error.
- */
- r->finfo.protection = 0;
-
-#if defined(APR_ENOENT) && defined(APR_ENOTDIR)
- if (rv == APR_ENOENT || rv == APR_ENOTDIR) {
- last_cp = cp;
-
- while (--cp > path && *cp != '/')
- continue;
-
- while (cp > path && cp[-1] == '/')
- --cp;
- }
- else {
-#if defined(APR_EACCES)
- if (rv != APR_EACCES)
-#endif
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- "access to %s failed", r->uri);
- return HTTP_FORBIDDEN;
- }
-#else
-#error ENOENT || ENOTDIR not defined; please see the
-#error comments at this line in the source for a workaround.
- /*
- * If ENOENT || ENOTDIR is not defined in one of the your OS's
- * include files, Apache does not know how to check to see why the
- * stat() of the index file failed; there are cases where it can fail
- * even though the file exists. This means that it is possible for
- * someone to get a directory listing of a directory even though
- * there is an index (eg. index.html) file in it. If you do not have
- * a problem with this, delete the above #error lines and start the
- * compile again. If you need to do this, please submit a bug report
- * from http://www.apache.org/bug_report.html letting us know that
- * you needed to do this. Please be sure to include the operating
- * system you are using.
- */
- last_cp = cp;
-
- while (--cp > path && *cp != '/')
- continue;
-
- while (cp > path && cp[-1] == '/')
- --cp;
-#endif /* ENOENT && ENOTDIR */
- }
- return OK;
-}
-
-static int directory_walk(request_rec *r)
-{
- core_server_config *sconf = ap_get_module_config(r->server->module_config,
- &core_module);
- void *per_dir_defaults = r->server->lookup_defaults;
- void **sec = (void **) sconf->sec->elts;
- int num_sec = sconf->sec->nelts;
- char *test_filename;
- char *test_dirname;
- int res;
- unsigned i, num_dirs, iStart;
- int j, test_filename_len;
-
- /*
- * Are we dealing with a file? If not, we can (hopefuly) safely assume we
- * have a handler that doesn't require one, but for safety's sake, and so
- * we have something find_types() can get something out of, fake one. But
- * don't run through the directory entries.
- */
-
- if (r->filename == NULL) {
- r->filename = ap_pstrdup(r->pool, r->uri);
- r->finfo.protection = 0; /* Not really a file... */
- r->finfo.filetype = APR_NOFILE;
- r->per_dir_config = per_dir_defaults;
-
- return OK;
- }
-
- /*
- * Go down the directory hierarchy. Where we have to check for symlinks,
- * do so. Where a .htaccess file has permission to override anything,
- * try to find one. If either of these things fails, we could poke
- * around, see why, and adjust the lookup_rec accordingly --- this might
- * save us a call to get_path_info (with the attendant stat()s); however,
- * for the moment, that's not worth the trouble.
- *
- * Fake filenames (i.e. proxy:) only match Directory sections.
- */
-
- if (!ap_os_is_path_absolute(r->filename))
- {
- void *this_conf, *entry_config;
- core_dir_config *entry_core;
- char *entry_dir;
-
- for (j = 0; j < num_sec; ++j) {
-
- entry_config = sec[j];
-
- entry_core = (core_dir_config *)
- ap_get_module_config(entry_config, &core_module);
- entry_dir = entry_core->d;
-
- this_conf = NULL;
- if (entry_core->r) {
- if (!ap_regexec(entry_core->r, r->filename, 0, NULL, 0))
- this_conf = entry_config;
- }
- else if (entry_core->d_is_fnmatch) {
- if (!ap_fnmatch(entry_dir, r->filename, 0))
- this_conf = entry_config;
- }
- else if (!strncmp(r->filename, entry_dir, strlen(entry_dir)))
- this_conf = entry_config;
-
- if (this_conf)
- per_dir_defaults = ap_merge_per_dir_configs(r->pool,
- per_dir_defaults,
- this_conf);
- }
-
- r->per_dir_config = per_dir_defaults;
-
- return OK;
- }
-
- r->filename = ap_os_case_canonical_filename(r->pool, r->filename);
-
- res = get_path_info(r);
- if (res != OK) {
- return res;
- }
-
- r->filename = ap_os_canonical_filename(r->pool, r->filename);
-
- test_filename = ap_pstrdup(r->pool, r->filename);
-
- ap_no2slash(test_filename);
- num_dirs = ap_count_dirs(test_filename);
-
- if (!ap_os_is_filename_valid(r->filename)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Filename is not valid: %s", r->filename);
- return HTTP_FORBIDDEN;
- }
-
- if ((res = check_safe_file(r))) {
- return res;
- }
-
- test_filename_len = strlen(test_filename);
- if (test_filename[test_filename_len - 1] == '/')
- --num_dirs;
-
- if (r->finfo.filetype == APR_DIR)
- ++num_dirs;
-
- /*
- * We will use test_dirname as scratch space while we build directory
- * names during the walk. Profiling shows directory_walk to be a busy
- * function so we try to avoid allocating lots of extra memory here.
- * We need 2 extra bytes, one for trailing \0 and one because
- * make_dirstr_prefix will add potentially one extra /.
- */
- test_dirname = ap_palloc(r->pool, test_filename_len + 2);
-
- iStart = 1;
-#ifdef WIN32
- /* If the name is a UNC name, then do not walk through the
- * machine and share name (e.g. \\machine\share\)
- */
- if (num_dirs > 3 && test_filename[0] == '/' && test_filename[1] == '/')
- iStart = 4;
-#endif
-
- /* j keeps track of which section we're on, see core_reorder_directories */
- j = 0;
- for (i = iStart; i <= num_dirs; ++i) {
- int overrides_here;
- core_dir_config *core_dir = (core_dir_config *)
- ap_get_module_config(per_dir_defaults, &core_module);
-
- /*
- * XXX: this could be made faster by only copying the next component
- * rather than copying the entire thing all over.
- */
- ap_make_dirstr_prefix(test_dirname, test_filename, i);
-
- /*
- * Do symlink checks first, because they are done with the
- * permissions appropriate to the *parent* directory...
- */
-
- if ((res = check_symlinks(test_dirname, core_dir->opts))) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Symbolic link not allowed: %s", test_dirname);
- return res;
- }
-
- /*
- * Begin *this* level by looking for matching <Directory> sections
- * from access.conf.
- */
-
- for (; j < num_sec; ++j) {
- void *entry_config = sec[j];
- core_dir_config *entry_core;
- char *entry_dir;
- void *this_conf;
-
- entry_core = (core_dir_config *)
- ap_get_module_config(entry_config, &core_module);
- entry_dir = entry_core->d;
-
- if (entry_core->r
- || !ap_os_is_path_absolute(entry_dir)
- || entry_core->d_components > i)
- break;
-
- this_conf = NULL;
- if (entry_core->d_is_fnmatch) {
- if (!ap_fnmatch(entry_dir, test_dirname, FNM_PATHNAME)) {
- this_conf = entry_config;
- }
- }
- else if (!strcmp(test_dirname, entry_dir))
- this_conf = entry_config;
-
- if (this_conf) {
- per_dir_defaults = ap_merge_per_dir_configs(r->pool,
- per_dir_defaults,
- this_conf);
- core_dir = (core_dir_config *)
- ap_get_module_config(per_dir_defaults, &core_module);
- }
- }
- overrides_here = core_dir->override;
-
- /* If .htaccess files are enabled, check for one. */
-
- if (overrides_here) {
- void *htaccess_conf = NULL;
-
- res = ap_parse_htaccess(&htaccess_conf, r, overrides_here,
- ap_pstrdup(r->pool, test_dirname),
- sconf->access_name);
- if (res)
- return res;
-
- if (htaccess_conf) {
- per_dir_defaults = ap_merge_per_dir_configs(r->pool,
- per_dir_defaults,
- htaccess_conf);
- r->per_dir_config = per_dir_defaults;
- }
- }
- }
-
- /*
- * There's two types of IS_SPECIAL sections (see http_core.c), and we've
- * already handled the proxy:-style stuff. Now we'll deal with the
- * regexes.
- */
- for (; j < num_sec; ++j) {
- void *entry_config = sec[j];
- core_dir_config *entry_core;
-
- entry_core = (core_dir_config *)
- ap_get_module_config(entry_config, &core_module);
-
- if (entry_core->r) {
- if (!ap_regexec(entry_core->r, test_dirname, 0, NULL, REG_NOTEOL)) {
- per_dir_defaults =
- ap_merge_per_dir_configs(r->pool, per_dir_defaults,
- entry_config);
- }
- }
- }
- r->per_dir_config = per_dir_defaults;
-
- /*
- * Symlink permissions are determined by the parent. If the request is
- * for a directory then applying the symlink test here would use the
- * permissions of the directory as opposed to its parent. Consider a
- * symlink pointing to a dir with a .htaccess disallowing symlinks. If
- * you access /symlink (or /symlink/) you would get a 403 without this
- * S_ISDIR test. But if you accessed /symlink/index.html, for example,
- * you would *not* get the 403.
- */
- if (r->finfo.filetype != APR_DIR
- && (res = check_symlinks(r->filename, ap_allow_options(r)))) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Symbolic link not allowed: %s", r->filename);
- return res;
- }
- return OK; /* Can only "fail" if access denied by the
- * symlink goop. */
-}
-
-static int location_walk(request_rec *r)
-{
- core_server_config *sconf = ap_get_module_config(r->server->module_config,
- &core_module);
- void *per_dir_defaults = r->per_dir_config;
- void **url = (void **) sconf->sec_url->elts;
- int len, num_url = sconf->sec_url->nelts;
- char *test_location;
- void *this_conf, *entry_config;
- core_dir_config *entry_core;
- char *entry_url;
- int j;
-
- if (!num_url) {
- return OK;
- }
-
- /* Location and LocationMatch differ on their behaviour w.r.t. multiple
- * slashes. Location matches multiple slashes with a single slash,
- * LocationMatch doesn't. An exception, for backwards brokenness is
- * absoluteURIs... in which case neither match multiple slashes.
- */
- if (r->uri[0] != '/') {
- test_location = r->uri;
- }
- else {
- test_location = ap_pstrdup(r->pool, r->uri);
- ap_no2slash(test_location);
- }
-
- /* Go through the location entries, and check for matches. */
-
- /* we apply the directive sections in some order;
- * should really try them with the most general first.
- */
- for (j = 0; j < num_url; ++j) {
-
- entry_config = url[j];
-
- entry_core = (core_dir_config *)
- ap_get_module_config(entry_config, &core_module);
- entry_url = entry_core->d;
-
- len = strlen(entry_url);
-
- this_conf = NULL;
-
- if (entry_core->r) {
- if (!ap_regexec(entry_core->r, r->uri, 0, NULL, 0))
- this_conf = entry_config;
- }
- else if (entry_core->d_is_fnmatch) {
- if (!ap_fnmatch(entry_url, test_location, FNM_PATHNAME)) {
- this_conf = entry_config;
- }
- }
- else if (!strncmp(test_location, entry_url, len) &&
- (entry_url[len - 1] == '/' ||
- test_location[len] == '/' || test_location[len] == '\0'))
- this_conf = entry_config;
-
- if (this_conf)
- per_dir_defaults = ap_merge_per_dir_configs(r->pool,
- per_dir_defaults, this_conf);
- }
- r->per_dir_config = per_dir_defaults;
-
- return OK;
-}
-
-static int file_walk(request_rec *r)
-{
- core_dir_config *conf = ap_get_module_config(r->per_dir_config, &core_module);
- void *per_dir_defaults = r->per_dir_config;
- void **file = (void **) conf->sec->elts;
- int num_files = conf->sec->nelts;
- char *test_file;
-
- /* get the basename */
- test_file = strrchr(r->filename, '/');
- if (test_file == NULL) {
- test_file = r->filename;
- }
- else {
- ++test_file;
- }
-
- /* Go through the file entries, and check for matches. */
-
- if (num_files) {
- void *this_conf, *entry_config;
- core_dir_config *entry_core;
- char *entry_file;
- int j;
-
- /* we apply the directive sections in some order;
- * should really try them with the most general first.
- */
- for (j = 0; j < num_files; ++j) {
-
- entry_config = file[j];
-
- entry_core = (core_dir_config *)
- ap_get_module_config(entry_config, &core_module);
- entry_file = entry_core->d;
-
- this_conf = NULL;
-
- if (entry_core->r) {
- if (!ap_regexec(entry_core->r, test_file, 0, NULL, 0))
- this_conf = entry_config;
- }
- else if (entry_core->d_is_fnmatch) {
- if (!ap_fnmatch(entry_file, test_file, FNM_PATHNAME)) {
- this_conf = entry_config;
- }
- }
- else if (!strcmp(test_file, entry_file)) {
- this_conf = entry_config;
- }
-
- if (this_conf)
- per_dir_defaults = ap_merge_per_dir_configs(r->pool,
- per_dir_defaults,
- this_conf);
- }
- r->per_dir_config = per_dir_defaults;
- }
- return OK;
-}
-
-/*****************************************************************
- *
- * The sub_request mechanism.
- *
- * Fns to look up a relative URI from, e.g., a map file or SSI document.
- * These do all access checks, etc., but don't actually run the transaction
- * ... use run_sub_req below for that. Also, be sure to use destroy_sub_req
- * as appropriate if you're likely to be creating more than a few of these.
- * (An early Apache version didn't destroy the sub_reqs used in directory
- * indexing. The result, when indexing a directory with 800-odd files in
- * it, was massively excessive storage allocation).
- *
- * Note more manipulation of protocol-specific vars in the request
- * structure...
- */
-
-static request_rec *make_sub_request(const request_rec *r)
-{
- ap_context_t *rrp;
- request_rec *rr;
-
- ap_create_context(&rrp, r->pool);
- rr = ap_pcalloc(rrp, sizeof(request_rec));
- rr->pool = rrp;
- return rr;
-}
-
-API_EXPORT(request_rec *) ap_sub_req_method_uri(const char *method,
- const char *new_file,
- const request_rec *r)
-{
- request_rec *rnew;
- int res;
- char *udir;
-
- rnew = make_sub_request(r);
- rnew->hostname = r->hostname;
- rnew->request_time = r->request_time;
- rnew->connection = r->connection;
- rnew->server = r->server;
- rnew->request_config = ap_create_request_config(rnew->pool);
- rnew->htaccess = r->htaccess;
- rnew->per_dir_config = r->server->lookup_defaults;
-
- ap_set_sub_req_protocol(rnew, r);
-
- /* would be nicer to pass "method" to ap_set_sub_req_protocol */
- rnew->method = method;
- rnew->method_number = ap_method_number_of(method);
-
- if (new_file[0] == '/')
- ap_parse_uri(rnew, new_file);
- else {
- udir = ap_make_dirstr_parent(rnew->pool, r->uri);
- udir = ap_escape_uri(rnew->pool, udir); /* re-escape it */
- ap_parse_uri(rnew, ap_make_full_path(rnew->pool, udir, new_file));
- }
-
- res = ap_unescape_url(rnew->uri);
- if (res) {
- rnew->status = res;
- return rnew;
- }
-
- ap_getparents(rnew->uri);
-
- if ((res = location_walk(rnew))) {
- rnew->status = res;
- return rnew;
- }
-
- res = ap_run_translate_name(rnew);
- if (res) {
- rnew->status = res;
- return rnew;
- }
-
- /*
- * We could be clever at this point, and avoid calling directory_walk,
- * etc. However, we'd need to test that the old and new filenames contain
- * the same directory components, so it would require duplicating the
- * start of translate_name. Instead we rely on the cache of .htaccess
- * results.
- *
- * NB: directory_walk() clears the per_dir_config, so we don't inherit
- * from location_walk() above
- */
-
- if ((res = directory_walk(rnew))
- || (res = file_walk(rnew))
- || (res = location_walk(rnew))
- || ((ap_satisfies(rnew) == SATISFY_ALL
- || ap_satisfies(rnew) == SATISFY_NOSPEC)
- ? ((res = ap_run_access_checker(rnew))
- || (ap_some_auth_required(rnew)
- && ((res = ap_run_check_user_id(rnew))
- || (res = ap_run_auth_checker(rnew)))))
- : ((res = ap_run_access_checker(rnew))
- && (!ap_some_auth_required(rnew)
- || ((res = ap_run_check_user_id(rnew))
- || (res = ap_run_auth_checker(rnew)))))
- )
- || (res = ap_run_type_checker(rnew))
- || (res = ap_run_fixups(rnew))
- ) {
- rnew->status = res;
- }
- return rnew;
-}
-
-API_EXPORT(request_rec *) ap_sub_req_lookup_uri(const char *new_file,
- const request_rec *r)
-{
- return ap_sub_req_method_uri("GET", new_file, r);
-}
-
-API_EXPORT(request_rec *) ap_sub_req_lookup_file(const char *new_file,
- const request_rec *r)
-{
- request_rec *rnew;
- int res;
- char *fdir;
-
- rnew = make_sub_request(r);
- rnew->hostname = r->hostname;
- rnew->request_time = r->request_time;
- rnew->connection = r->connection;
- rnew->server = r->server;
- rnew->request_config = ap_create_request_config(rnew->pool);
- rnew->htaccess = r->htaccess;
- rnew->chunked = r->chunked;
-
- ap_set_sub_req_protocol(rnew, r);
- fdir = ap_make_dirstr_parent(rnew->pool, r->filename);
-
- /*
- * Check for a special case... if there are no '/' characters in new_file
- * at all, then we are looking at a relative lookup in the same
- * directory. That means we won't have to redo directory_walk, and we may
- * not even have to redo access checks.
- */
-
- if (strchr(new_file, '/') == NULL) {
- char *udir = ap_make_dirstr_parent(rnew->pool, r->uri);
-
- rnew->uri = ap_make_full_path(rnew->pool, udir, new_file);
- rnew->filename = ap_make_full_path(rnew->pool, fdir, new_file);
- ap_parse_uri(rnew, rnew->uri); /* fill in parsed_uri values */
-
- if (ap_stat(&rnew->finfo, rnew->filename, rnew->pool) != APR_SUCCESS) {
- rnew->finfo.protection = 0;
- }
-
- if ((res = check_safe_file(rnew))) {
- rnew->status = res;
- return rnew;
- }
-
- rnew->per_dir_config = r->per_dir_config;
-
- /*
- * no matter what, if it's a subdirectory, we need to re-run
- * directory_walk
- */
- if (rnew->finfo.filetype == APR_DIR) {
- res = directory_walk(rnew);
- if (!res) {
- res = file_walk(rnew);
- }
- }
- else {
- if ((res = check_symlinks(rnew->filename, ap_allow_options(rnew)))) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, rnew,
- "Symbolic link not allowed: %s", rnew->filename);
- rnew->status = res;
- return rnew;
- }
- /*
- * do a file_walk, if it doesn't change the per_dir_config then
- * we know that we don't have to redo all the access checks
- */
- if ((res = file_walk(rnew))) {
- rnew->status = res;
- return rnew;
- }
- if (rnew->per_dir_config == r->per_dir_config) {
- if ((res = ap_run_type_checker(rnew)) || (res = ap_run_fixups(rnew))) {
- rnew->status = res;
- }
- return rnew;
- }
- }
- }
- else {
- /* XXX: @@@: What should be done with the parsed_uri values? */
- ap_parse_uri(rnew, new_file); /* fill in parsed_uri values */
- /*
- * XXX: this should be set properly like it is in the same-dir case
- * but it's actually sometimes to impossible to do it... because the
- * file may not have a uri associated with it -djg
- */
- rnew->uri = "INTERNALLY GENERATED file-relative req";
- rnew->filename = ((ap_os_is_path_absolute(new_file)) ?
- ap_pstrdup(rnew->pool, new_file) :
- ap_make_full_path(rnew->pool, fdir, new_file));
- rnew->per_dir_config = r->server->lookup_defaults;
- res = directory_walk(rnew);
- if (!res) {
- res = file_walk(rnew);
- }
- }
-
- if (res
- || ((ap_satisfies(rnew) == SATISFY_ALL
- || ap_satisfies(rnew) == SATISFY_NOSPEC)
- ? ((res = ap_run_access_checker(rnew))
- || (ap_some_auth_required(rnew)
- && ((res = ap_run_check_user_id(rnew))
- || (res = ap_run_auth_checker(rnew)))))
- : ((res = ap_run_access_checker(rnew))
- && (!ap_some_auth_required(rnew)
- || ((res = ap_run_check_user_id(rnew))
- || (res = ap_run_auth_checker(rnew)))))
- )
- || (res = ap_run_type_checker(rnew))
- || (res = ap_run_fixups(rnew))
- ) {
- rnew->status = res;
- }
- return rnew;
-}
-
-API_EXPORT(int) ap_run_sub_req(request_rec *r)
-{
-#ifndef CHARSET_EBCDIC
- int retval = ap_invoke_handler(r);
-#else /*CHARSET_EBCDIC*/
- /* Save the EBCDIC conversion setting of the caller across subrequests */
- int convert = ap_bgetflag(r->connection->client, B_EBCDIC2ASCII);
- int retval = ap_invoke_handler(r);
- ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert);
-#endif /*CHARSET_EBCDIC*/
- ap_finalize_sub_req_protocol(r);
- return retval;
-}
-
-API_EXPORT(void) ap_destroy_sub_req(request_rec *r)
-{
- /* Reclaim the space */
- ap_destroy_pool(r->pool);
-}
-
-/*****************************************************************
- *
- * Mainline request processing...
- */
-
-API_EXPORT(void) ap_die(int type, request_rec *r)
-{
- int error_index = ap_index_of_response(type);
- char *custom_response = ap_response_code_string(r, error_index);
- int recursive_error = 0;
-
- if (type == DONE) {
- ap_finalize_request_protocol(r);
- return;
- }
-
- /*
- * The following takes care of Apache redirects to custom response URLs
- * Note that if we are already dealing with the response to some other
- * error condition, we just report on the original error, and give up on
- * any attempt to handle the other thing "intelligently"...
- */
-
- if (r->status != HTTP_OK) {
- recursive_error = type;
-
- while (r->prev && (r->prev->status != HTTP_OK))
- r = r->prev; /* Get back to original error */
-
- type = r->status;
- custom_response = NULL; /* Do NOT retry the custom thing! */
- }
-
- r->status = type;
-
- /*
- * This test is done here so that none of the auth modules needs to know
- * about proxy authentication. They treat it like normal auth, and then
- * we tweak the status.
- */
- if (r->status == AUTH_REQUIRED && r->proxyreq) {
- r->status = HTTP_PROXY_AUTHENTICATION_REQUIRED;
- }
-
- /*
- * If we want to keep the connection, be sure that the request body
- * (if any) has been read.
- */
- if ((r->status != HTTP_NOT_MODIFIED) && (r->status != HTTP_NO_CONTENT)
- && !ap_status_drops_connection(r->status)
- && r->connection && (r->connection->keepalive != -1)) {
-
- (void) ap_discard_request_body(r);
- }
-
- /*
- * Two types of custom redirects --- plain text, and URLs. Plain text has
- * a leading '"', so the URL code, here, is triggered on its absence
- */
-
- if (custom_response && custom_response[0] != '"') {
-
- if (ap_is_url(custom_response)) {
- /*
- * The URL isn't local, so lets drop through the rest of this
- * apache code, and continue with the usual REDIRECT handler.
- * But note that the client will ultimately see the wrong
- * status...
- */
- r->status = REDIRECT;
- ap_table_setn(r->headers_out, "Location", custom_response);
- }
- else if (custom_response[0] == '/') {
- const char *error_notes;
- r->no_local_copy = 1; /* Do NOT send USE_LOCAL_COPY for
- * error documents! */
- /*
- * This redirect needs to be a GET no matter what the original
- * method was.
- */
- ap_table_setn(r->subprocess_env, "REQUEST_METHOD", r->method);
-
- /*
- * Provide a special method for modules to communicate
- * more informative (than the plain canned) messages to us.
- * Propagate them to ErrorDocuments via the ERROR_NOTES variable:
- */
- if ((error_notes = ap_table_get(r->notes, "error-notes")) != NULL) {
- ap_table_setn(r->subprocess_env, "ERROR_NOTES", error_notes);
- }
- r->method = ap_pstrdup(r->pool, "GET");
- r->method_number = M_GET;
- ap_internal_redirect(custom_response, r);
- return;
- }
- else {
- /*
- * Dumb user has given us a bad url to redirect to --- fake up
- * dying with a recursive server error...
- */
- recursive_error = SERVER_ERROR;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Invalid error redirection directive: %s",
- custom_response);
- }
- }
- ap_send_error_response(r, recursive_error);
-}
-
-static void decl_die(int status, char *phase, request_rec *r)
-{
- if (status == DECLINED) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_CRIT, 0, r,
- "configuration error: couldn't %s: %s", phase, r->uri);
- ap_die(SERVER_ERROR, r);
- }
- else
- ap_die(status, r);
-}
-
-API_EXPORT(int) ap_some_auth_required(request_rec *r)
-{
- /* Is there a require line configured for the type of *this* req? */
-
- const ap_array_header_t *reqs_arr = ap_requires(r);
- require_line *reqs;
- int i;
-
- if (!reqs_arr)
- return 0;
-
- reqs = (require_line *) reqs_arr->elts;
-
- for (i = 0; i < reqs_arr->nelts; ++i)
- if (reqs[i].method_mask & (1 << r->method_number))
- return 1;
-
- return 0;
-}
-
-static void process_request_internal(request_rec *r)
-{
- int access_status;
-
- /* Ignore embedded %2F's in path for proxy requests */
- if (!r->proxyreq && r->parsed_uri.path) {
- access_status = ap_unescape_url(r->parsed_uri.path);
- if (access_status) {
- ap_die(access_status, r);
- return;
- }
- }
-
- ap_getparents(r->uri); /* OK --- shrinking transformations... */
-
- if ((access_status = location_walk(r))) {
- ap_die(access_status, r);
- return;
- }
-
- if ((access_status = ap_run_translate_name(r))) {
- decl_die(access_status, "translate", r);
- return;
- }
-
- if (!r->proxyreq) {
- /*
- * We don't want TRACE to run through the normal handler set, we
- * handle it specially.
- */
- if (r->method_number == M_TRACE) {
- if ((access_status = ap_send_http_trace(r)))
- ap_die(access_status, r);
- else
- ap_finalize_request_protocol(r);
- return;
- }
- }
-
- if (r->proto_num > HTTP_VERSION(1,0) && ap_table_get(r->subprocess_env, "downgrade-1.0")) {
- r->proto_num = HTTP_VERSION(1,0);
- }
-
- /*
- * NB: directory_walk() clears the per_dir_config, so we don't inherit
- * from location_walk() above
- */
-
- if ((access_status = directory_walk(r))) {
- ap_die(access_status, r);
- return;
- }
-
- if ((access_status = file_walk(r))) {
- ap_die(access_status, r);
- return;
- }
-
- if ((access_status = location_walk(r))) {
- ap_die(access_status, r);
- return;
- }
-
- if ((access_status = ap_run_header_parser(r))) {
- ap_die(access_status, r);
- return;
- }
-
- switch (ap_satisfies(r)) {
- case SATISFY_ALL:
- case SATISFY_NOSPEC:
- if ((access_status = ap_run_access_checker(r)) != 0) {
- decl_die(access_status, "check access", r);
- return;
- }
- if (ap_some_auth_required(r)) {
- if (((access_status = ap_run_check_user_id(r)) != 0) || !ap_auth_type(r)) {
- decl_die(access_status, ap_auth_type(r)
- ? "check user. No user file?"
- : "perform authentication. AuthType not set!", r);
- return;
- }
- if (((access_status = ap_run_auth_checker(r)) != 0) || !ap_auth_type(r)) {
- decl_die(access_status, ap_auth_type(r)
- ? "check access. No groups file?"
- : "perform authentication. AuthType not set!", r);
- return;
- }
- }
- break;
- case SATISFY_ANY:
- if (((access_status = ap_run_access_checker(r)) != 0) || !ap_auth_type(r)) {
- if (!ap_some_auth_required(r)) {
- decl_die(access_status, ap_auth_type(r)
- ? "check access"
- : "perform authentication. AuthType not set!", r);
- return;
- }
- if (((access_status = ap_run_check_user_id(r)) != 0) || !ap_auth_type(r)) {
- decl_die(access_status, ap_auth_type(r)
- ? "check user. No user file?"
- : "perform authentication. AuthType not set!", r);
- return;
- }
- if (((access_status = ap_run_auth_checker(r)) != 0) || !ap_auth_type(r)) {
- decl_die(access_status, ap_auth_type(r)
- ? "check access. No groups file?"
- : "perform authentication. AuthType not set!", r);
- return;
- }
- }
- break;
- }
-
- if (! (r->proxyreq
- && r->parsed_uri.scheme != NULL
- && strcmp(r->parsed_uri.scheme, "http") == 0) ) {
- if ((access_status = ap_run_type_checker(r)) != 0) {
- decl_die(access_status, "find types", r);
- return;
- }
- }
-
- if ((access_status = ap_run_fixups(r)) != 0) {
- ap_die(access_status, r);
- return;
- }
-
- if ((access_status = ap_invoke_handler(r)) != 0) {
- ap_die(access_status, r);
- return;
- }
-
- /* Take care of little things that need to happen when we're done */
- ap_finalize_request_protocol(r);
-}
-
-void ap_process_request(request_rec *r)
-{
- process_request_internal(r);
-
- /*
- * We want to flush the last packet if this isn't a pipelining connection
- * *before* we start into logging. Suppose that the logging causes a DNS
- * lookup to occur, which may have a high latency. If we hold off on
- * this packet, then it'll appear like the link is stalled when really
- * it's the application that's stalled.
- */
- /* TODO: reimplement ap_bhalfduplex... not sure how yet */
- /* //ap_bhalfduplex(r->connection->client); */
- ap_run_log_transaction(r);
-}
-
-static ap_table_t *rename_original_env(ap_context_t *p, ap_table_t *t)
-{
- ap_array_header_t *env_arr = ap_table_elts(t);
- ap_table_entry_t *elts = (ap_table_entry_t *) env_arr->elts;
- ap_table_t *new = ap_make_table(p, env_arr->nalloc);
- int i;
-
- for (i = 0; i < env_arr->nelts; ++i) {
- if (!elts[i].key)
- continue;
- ap_table_setn(new, ap_pstrcat(p, "REDIRECT_", elts[i].key, NULL),
- elts[i].val);
- }
-
- return new;
-}
-
-static request_rec *internal_internal_redirect(const char *new_uri, request_rec *r)
-{
- int access_status;
- request_rec *new = (request_rec *) ap_pcalloc(r->pool, sizeof(request_rec));
-
- new->connection = r->connection;
- new->server = r->server;
- new->pool = r->pool;
-
- /*
- * A whole lot of this really ought to be shared with http_protocol.c...
- * another missing cleanup. It's particularly inappropriate to be
- * setting header_only, etc., here.
- */
-
- new->method = r->method;
- new->method_number = r->method_number;
- ap_parse_uri(new, new_uri);
- new->request_config = ap_create_request_config(r->pool);
- new->per_dir_config = r->server->lookup_defaults;
-
- new->prev = r;
- r->next = new;
-
- /* Inherit the rest of the protocol info... */
-
- new->the_request = r->the_request;
-
- new->allowed = r->allowed;
-
- new->status = r->status;
- new->assbackwards = r->assbackwards;
- new->header_only = r->header_only;
- new->protocol = r->protocol;
- new->proto_num = r->proto_num;
- new->hostname = r->hostname;
- new->request_time = r->request_time;
- new->main = r->main;
-
- new->headers_in = r->headers_in;
- new->headers_out = ap_make_table(r->pool, 12);
- new->err_headers_out = r->err_headers_out;
- new->subprocess_env = rename_original_env(r->pool, r->subprocess_env);
- new->notes = ap_make_table(r->pool, 5);
-
- new->htaccess = r->htaccess;
- new->no_cache = r->no_cache;
- new->expecting_100 = r->expecting_100;
- new->no_local_copy = r->no_local_copy;
- new->read_length = r->read_length; /* We can only read it once */
- new->vlist_validator = r->vlist_validator;
-
- ap_table_setn(new->subprocess_env, "REDIRECT_STATUS",
- ap_psprintf(r->pool, "%d", r->status));
-
- /*
- * XXX: hmm. This is because mod_setenvif and mod_unique_id really need
- * to do their thing on internal redirects as well. Perhaps this is a
- * misnamed function.
- */
- if ((access_status = ap_run_post_read_request(new))) {
- ap_die(access_status, new);
- return NULL;
- }
-
- return new;
-}
-
-API_EXPORT(void) ap_internal_redirect(const char *new_uri, request_rec *r)
-{
- request_rec *new = internal_internal_redirect(new_uri, r);
- process_request_internal(new);
-}
-
-/* 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.
- */
-API_EXPORT(void) ap_internal_redirect_handler(const char *new_uri, request_rec *r)
-{
- request_rec *new = internal_internal_redirect(new_uri, r);
- if (r->handler)
- new->content_type = r->content_type;
- process_request_internal(new);
-}
-
-/*
- * Is it the initial main request, which we only get *once* per HTTP request?
- */
-API_EXPORT(int) ap_is_initial_req(request_rec *r)
-{
- return
- (r->main == NULL) /* otherwise, this is a sub-request */
- &&
- (r->prev == NULL); /* otherwise, this is an internal redirect */
-}
-
-/*
- * Function to set the r->mtime field to the specified value if it's later
- * than what's already there.
- */
-API_EXPORT(void) ap_update_mtime(request_rec *r, ap_time_t dependency_mtime)
-{
- if (r->mtime < dependency_mtime) {
- r->mtime = dependency_mtime;
- }
-}
diff --git a/modules/http/mod_mime.c b/modules/http/mod_mime.c
deleted file mode 100644
index e3478119ea..0000000000
--- a/modules/http/mod_mime.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_mime.c: Sends/gets MIME headers for requests
- *
- * Rob McCool
- *
- */
-
-#define MIME_PRIVATE
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-#include "http_request.h"
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-typedef struct handlers_info {
- char *name;
-} handlers_info;
-
-typedef struct {
- ap_table_t *forced_types; /* Additional AddTyped stuff */
- ap_table_t *encoding_types; /* Added with AddEncoding... */
- ap_table_t *language_types; /* Added with AddLanguage... */
- ap_table_t *handlers; /* Added with AddHandler... */
- ap_array_header_t *handlers_remove; /* List of handlers to remove */
-
- char *type; /* Type forced with ForceType */
- char *handler; /* Handler forced with SetHandler */
- char *default_language; /* Language if no AddLanguage ext found */
-} mime_dir_config;
-
-module MODULE_VAR_EXPORT mime_module;
-
-static void *create_mime_dir_config(ap_context_t *p, char *dummy)
-{
- mime_dir_config *new =
- (mime_dir_config *) ap_palloc(p, sizeof(mime_dir_config));
-
- new->forced_types = ap_make_table(p, 4);
- new->encoding_types = ap_make_table(p, 4);
- new->language_types = ap_make_table(p, 4);
- new->handlers = ap_make_table(p, 4);
- new->handlers_remove = ap_make_array(p, 4, sizeof(handlers_info));
-
- new->type = NULL;
- new->handler = NULL;
- new->default_language = NULL;
-
- return new;
-}
-
-static void *merge_mime_dir_configs(ap_context_t *p, void *basev, void *addv)
-{
- mime_dir_config *base = (mime_dir_config *) basev;
- mime_dir_config *add = (mime_dir_config *) addv;
- mime_dir_config *new =
- (mime_dir_config *) ap_palloc(p, sizeof(mime_dir_config));
- int i;
- handlers_info *hand;
-
- hand = (handlers_info *) add->handlers_remove->elts;
- for (i = 0; i < add->handlers_remove->nelts; i++) {
- ap_table_unset(base->handlers, hand[i].name);
- }
-
- new->forced_types = ap_overlay_tables(p, add->forced_types,
- base->forced_types);
- new->encoding_types = ap_overlay_tables(p, add->encoding_types,
- base->encoding_types);
- new->language_types = ap_overlay_tables(p, add->language_types,
- base->language_types);
- new->handlers = ap_overlay_tables(p, add->handlers,
- base->handlers);
-
- new->type = add->type ? add->type : base->type;
- new->handler = add->handler ? add->handler : base->handler;
- new->default_language = add->default_language ?
- add->default_language : base->default_language;
-
- return new;
-}
-
-static const char *add_type(cmd_parms *cmd, mime_dir_config * m, char *ct,
- char *ext)
-{
- if (*ext == '.')
- ++ext;
- ap_str_tolower(ct);
- ap_table_setn(m->forced_types, ext, ct);
- return NULL;
-}
-
-static const char *add_encoding(cmd_parms *cmd, mime_dir_config * m, char *enc,
- char *ext)
-{
- if (*ext == '.')
- ++ext;
- ap_str_tolower(enc);
- ap_table_setn(m->encoding_types, ext, enc);
- return NULL;
-}
-
-static const char *add_language(cmd_parms *cmd, mime_dir_config * m, char *lang,
- char *ext)
-{
- if (*ext == '.')
- ++ext;
- ap_str_tolower(lang);
- ap_table_setn(m->language_types, ext, lang);
- return NULL;
-}
-
-static const char *add_handler(cmd_parms *cmd, mime_dir_config * m, char *hdlr,
- char *ext)
-{
- if (*ext == '.')
- ++ext;
- ap_str_tolower(hdlr);
- ap_table_setn(m->handlers, ext, hdlr);
- return NULL;
-}
-
-/*
- * Note handler names that should be un-added for this location. This
- * will keep the association from being inherited, as well, but not
- * from being re-added at a subordinate level.
- */
-static const char *remove_handler(cmd_parms *cmd, void *m, char *ext)
-{
- mime_dir_config *mcfg = (mime_dir_config *) m;
- handlers_info *hand;
-
- if (*ext == '.') {
- ++ext;
- }
- hand = (handlers_info *) ap_push_array(mcfg->handlers_remove);
- hand->name = ap_pstrdup(cmd->pool, ext);
- return NULL;
-}
-
-/* The sole bit of server configuration that the MIME module has is
- * the name of its config file, so...
- */
-
-static const char *set_types_config(cmd_parms *cmd, void *dummy, char *arg)
-{
- ap_set_module_config(cmd->server->module_config, &mime_module, arg);
- return NULL;
-}
-
-static const command_rec mime_cmds[] =
-{
- {"AddType", add_type, NULL, OR_FILEINFO, ITERATE2,
- "a mime type followed by one or more file extensions"},
- {"AddEncoding", add_encoding, NULL, OR_FILEINFO, ITERATE2,
- "an encoding (e.g., gzip), followed by one or more file extensions"},
- {"AddLanguage", add_language, NULL, OR_FILEINFO, ITERATE2,
- "a language (e.g., fr), followed by one or more file extensions"},
- {"AddHandler", add_handler, NULL, OR_FILEINFO, ITERATE2,
- "a handler name followed by one or more file extensions"},
- {"ForceType", ap_set_string_slot_lower,
- (void *)XtOffsetOf(mime_dir_config, type), OR_FILEINFO, TAKE1,
- "a media type"},
- {"RemoveHandler", remove_handler, NULL, OR_FILEINFO, ITERATE,
- "one or more file extensions"},
- {"SetHandler", ap_set_string_slot_lower,
- (void *)XtOffsetOf(mime_dir_config, handler), OR_FILEINFO, TAKE1,
- "a handler name"},
- {"TypesConfig", set_types_config, NULL, RSRC_CONF, TAKE1,
- "the MIME types config file"},
- {"DefaultLanguage", ap_set_string_slot,
- (void*)XtOffsetOf(mime_dir_config, default_language), OR_FILEINFO, TAKE1,
- "language to use for documents with no other language file extension" },
- {NULL}
-};
-
-/* Hash ap_table_t --- only one of these per daemon; virtual hosts can
- * get private versions through AddType...
- */
-
-#define MIME_HASHSIZE (32)
-#define hash(i) (ap_tolower(i) % MIME_HASHSIZE)
-
-static ap_table_t *hash_buckets[MIME_HASHSIZE];
-
-static void mime_post_config(ap_context_t *p, ap_context_t *plog, ap_context_t *ptemp, server_rec *s)
-{
- configfile_t *f;
- char l[MAX_STRING_LEN];
- int x;
- const char *types_confname = ap_get_module_config(s->module_config, &mime_module);
- ap_status_t status;
-
- if (!types_confname)
- types_confname = AP_TYPES_CONFIG_FILE;
-
- types_confname = ap_server_root_relative(p, types_confname);
-
- if ((status = ap_pcfg_openfile(&f, p, types_confname)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, status, s,
- "could not open mime types log file %s.", types_confname);
- exit(1);
- }
-
- for (x = 0; x < MIME_HASHSIZE; x++)
- hash_buckets[x] = ap_make_table(p, 10);
-
- while (!(ap_cfg_getline(l, MAX_STRING_LEN, f))) {
- const char *ll = l, *ct;
-
- if (l[0] == '#')
- continue;
- ct = ap_getword_conf(p, &ll);
-
- while (ll[0]) {
- char *ext = ap_getword_conf(p, &ll);
- ap_str_tolower(ext); /* ??? */
- ap_table_setn(hash_buckets[hash(ext[0])], ext, ct);
- }
- }
- ap_cfg_closefile(f);
-}
-
-static int find_ct(request_rec *r)
-{
- const char *fn = strrchr(r->filename, '/');
- mime_dir_config *conf =
- (mime_dir_config *) ap_get_module_config(r->per_dir_config, &mime_module);
- char *ext;
- const char *orighandler = r->handler;
- const char *type;
-
- if (r->finfo.filetype == APR_DIR) {
- r->content_type = DIR_MAGIC_TYPE;
- return OK;
- }
-
- /* TM -- FIXME
- * if r->filename does not contain a '/', the following passes a null
- * pointer to getword, causing a SEGV ..
- */
-
- if (fn == NULL)
- fn = r->filename;
-
- /* Parse filename extensions, which can be in any order */
- while ((ext = ap_getword(r->pool, &fn, '.')) && *ext) {
- int found = 0;
-
- /* Check for Content-Type */
- if ((type = ap_table_get(conf->forced_types, ext))
- || (type = ap_table_get(hash_buckets[hash(*ext)], ext))) {
- r->content_type = type;
- found = 1;
- }
-
- /* Check for Content-Language */
- if ((type = ap_table_get(conf->language_types, ext))) {
- const char **new;
-
- r->content_language = type; /* back compat. only */
- if (!r->content_languages)
- r->content_languages = ap_make_array(r->pool, 2, sizeof(char *));
- new = (const char **) ap_push_array(r->content_languages);
- *new = type;
- found = 1;
- }
-
- /* Check for Content-Encoding */
- if ((type = ap_table_get(conf->encoding_types, ext))) {
- if (!r->content_encoding)
- r->content_encoding = type;
- else
- r->content_encoding = ap_pstrcat(r->pool, r->content_encoding,
- ", ", type, NULL);
- found = 1;
- }
-
- /* Check for a special handler, but not for proxy request */
- if ((type = ap_table_get(conf->handlers, ext)) && !r->proxyreq) {
- r->handler = type;
- found = 1;
- }
-
- /* This is to deal with cases such as foo.gif.bak, which we want
- * to not have a type. So if we find an unknown extension, we
- * zap the type/language/encoding and reset the handler
- */
-
- if (!found) {
- r->content_type = NULL;
- r->content_language = NULL;
- r->content_languages = NULL;
- r->content_encoding = NULL;
- r->handler = orighandler;
- }
-
- }
-
- /* Set default language, if none was specified by the extensions
- * and we have a DefaultLanguage setting in force
- */
-
- if (!r->content_languages && conf->default_language) {
- const char **new;
-
- r->content_language = conf->default_language; /* back compat. only */
- if (!r->content_languages)
- r->content_languages = ap_make_array(r->pool, 2, sizeof(char *));
- new = (const char **) ap_push_array(r->content_languages);
- *new = conf->default_language;
- }
-
- /* Check for overrides with ForceType/SetHandler */
-
- if (conf->type && strcmp(conf->type, "none"))
- r->content_type = conf->type;
- if (conf->handler && strcmp(conf->handler, "none"))
- r->handler = conf->handler;
-
- if (!r->content_type)
- return DECLINED;
-
- return OK;
-}
-
-static void register_hooks(void)
-{
- ap_hook_type_checker(find_ct,NULL,NULL,HOOK_MIDDLE);
- ap_hook_post_config(mime_post_config,NULL,NULL,HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT mime_module = {
- STANDARD20_MODULE_STUFF,
- create_mime_dir_config, /* create per-directory config structure */
- merge_mime_dir_configs, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- mime_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/http/mod_mime.exp b/modules/http/mod_mime.exp
deleted file mode 100644
index f2e38dbdda..0000000000
--- a/modules/http/mod_mime.exp
+++ /dev/null
@@ -1 +0,0 @@
-mime_module
diff --git a/modules/loggers/.indent.pro b/modules/loggers/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/loggers/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/loggers/mod_log_config.c b/modules/loggers/mod_log_config.c
deleted file mode 100644
index fd4fadec0b..0000000000
--- a/modules/loggers/mod_log_config.c
+++ /dev/null
@@ -1,1160 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * Modified by djm@va.pubnix.com:
- * If no TransferLog is given explicitly, decline to log.
- *
- * This is module implements the TransferLog directive (same as the
- * common log module), and additional directives, LogFormat and CustomLog.
- *
- *
- * Syntax:
- *
- * TransferLog fn Logs transfers to fn in standard log format, unless
- * a custom format is set with LogFormat
- * LogFormat format Set a log format from TransferLog files
- * CustomLog fn format
- * Log to file fn with format given by the format
- * argument
- *
- * CookieLog fn For backwards compatability with old Cookie
- * logging module - now deprecated.
- *
- * There can be any number of TransferLog and CustomLog
- * commands. Each request will be logged to _ALL_ the
- * named files, in the appropriate format.
- *
- * If no TransferLog or CustomLog directive appears in a VirtualHost,
- * the request will be logged to the log file(s) defined outside
- * the virtual host section. If a TransferLog or CustomLog directive
- * appears in the VirtualHost section, the log files defined outside
- * the VirtualHost will _not_ be used. This makes this module compatable
- * with the CLF and config log modules, where the use of TransferLog
- * inside the VirtualHost section overrides its use outside.
- *
- * Examples:
- *
- * TransferLog logs/access_log
- * <VirtualHost>
- * LogFormat "... custom format ..."
- * TransferLog log/virtual_only
- * CustomLog log/virtual_useragents "%t %{user-agent}i"
- * </VirtualHost>
- *
- * This will log using CLF to access_log any requests handled by the
- * main server, while any requests to the virtual host will be logged
- * with the "... custom format..." to virtual_only _AND_ using
- * the custom user-agent log to virtual_useragents.
- *
- * Note that the NCSA referer and user-agent logs are easily added with
- * CustomLog:
- * CustomLog logs/referer "%{referer}i -> %U"
- * CustomLog logs/agent "%{user-agent}i"
- *
- * RefererIgnore functionality can be obtained with conditional
- * logging (SetEnvIf and CustomLog ... env=!VAR).
- *
- * But using this method allows much easier modification of the
- * log format, e.g. to log hosts along with UA:
- * CustomLog logs/referer "%{referer}i %U %h"
- *
- * The argument to LogFormat and CustomLog is a string, which can include
- * literal characters copied into the log files, and '%' directives as
- * follows:
- *
- * %...b: bytes sent, excluding HTTP headers.
- * %...{FOOBAR}e: The contents of the environment variable FOOBAR
- * %...f: filename
- * %...h: remote host
- * %...a: remote IP-address
- * %...A: local IP-address
- * %...{Foobar}i: The contents of Foobar: header line(s) in the request
- * sent to the client.
- * %...l: remote logname (from identd, if supplied)
- * %...{Foobar}n: The contents of note "Foobar" from another module.
- * %...{Foobar}o: The contents of Foobar: header line(s) in the reply.
- * %...p: the port the request was served to
- * %...P: the process ID of the child that serviced the request.
- * %...r: first line of request
- * %...s: status. For requests that got internally redirected, this
- * is status of the *original* request --- %...>s for the last.
- * %...t: time, in common log format time format
- * %...{format}t: The time, in the form given by format, which should
- * be in strftime(3) format.
- * %...T: the time taken to serve the request, in seconds.
- * %...u: remote user (from auth; may be bogus if return status (%s) is 401)
- * %...U: the URL path requested.
- * %...v: the configured name of the server (i.e. which virtual host?)
- * %...V: the server name according to the UseCanonicalName setting
- *
- * The '...' can be nothing at all (e.g. "%h %u %r %s %b"), or it can
- * indicate conditions for inclusion of the item (which will cause it
- * to be replaced with '-' if the condition is not met). Note that
- * there is no escaping performed on the strings from %r, %...i and
- * %...o; some with long memories may remember that I thought this was
- * a bad idea, once upon a time, and I'm still not comfortable with
- * it, but it is difficult to see how to "do the right thing" with all
- * of '%..i', unless we URL-escape everything and break with CLF.
- *
- * The forms of condition are a list of HTTP status codes, which may
- * or may not be preceded by '!'. Thus, '%400,501{User-agent}i' logs
- * User-agent: on 400 errors and 501 errors (Bad Request, Not
- * Implemented) only; '%!200,304,302{Referer}i' logs Referer: on all
- * requests which did *not* return some sort of normal status.
- *
- * The default LogFormat reproduces CLF; see below.
- *
- * The way this is supposed to work with virtual hosts is as follows:
- * a virtual host can have its own LogFormat, or its own TransferLog.
- * If it doesn't have its own LogFormat, it inherits from the main
- * server. If it doesn't have its own TransferLog, it writes to the
- * same descriptor (meaning the same process for "| ...").
- *
- * --- rst */
-
-#define DEFAULT_LOG_FORMAT "%h %l %u %t \"%r\" %>s %b"
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h" /* For REMOTE_NAME */
-#include "http_log.h"
-#include "http_protocol.h"
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
-module MODULE_VAR_EXPORT config_log_module;
-
-static int xfer_flags = (APR_WRITE | APR_APPEND | APR_CREATE);
-#if defined(OS2) || defined(WIN32)
-/* OS/2 dosen't support users and groups */
-static mode_t xfer_mode = (S_IREAD | S_IWRITE);
-#else
-static mode_t xfer_mode = (APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD);
-#endif
-
-/* POSIX.1 defines PIPE_BUF as the maximum number of bytes that is
- * guaranteed to be atomic when writing a pipe. And PIPE_BUF >= 512
- * is guaranteed. So we'll just guess 512 in the event the system
- * doesn't have this. Now, for file writes there is actually no limit,
- * the entire write is atomic. Whether all systems implement this
- * correctly is another question entirely ... so we'll just use PIPE_BUF
- * because it's probably a good guess as to what is implemented correctly
- * everywhere.
- */
-#ifdef PIPE_BUF
-#define LOG_BUFSIZE PIPE_BUF
-#else
-#define LOG_BUFSIZE (512)
-#endif
-
-/*
- * multi_log_state is our per-(virtual)-server configuration. We store
- * an array of the logs we are going to use, each of type config_log_state.
- * If a default log format is given by LogFormat, store in default_format
- * (backward compat. with mod_log_config). We also store for each virtual
- * server a pointer to the logs specified for the main server, so that if this
- * vhost has no logs defined, we can use the main server's logs instead.
- *
- * So, for the main server, config_logs contains a list of the log files
- * and server_config_logs in empty. For a vhost, server_config_logs
- * points to the same array as config_logs in the main server, and
- * config_logs points to the array of logs defined inside this vhost,
- * which might be empty.
- */
-
-typedef struct {
- char *default_format_string;
- ap_array_header_t *default_format;
- ap_array_header_t *config_logs;
- ap_array_header_t *server_config_logs;
- ap_table_t *formats;
-} multi_log_state;
-
-/*
- * config_log_state holds the status of a single log file. fname might
- * be NULL, which means this module does no logging for this
- * request. format might be NULL, in which case the default_format
- * from the multi_log_state should be used, or if that is NULL as
- * well, use the CLF. log_fd is NULL before the log file is opened and
- * set to a valid fd after it is opened.
- */
-
-typedef struct {
- char *fname;
- char *format_string;
- ap_array_header_t *format;
- ap_file_t *log_fd;
- char *condition_var;
-#ifdef BUFFERED_LOGS
- int outcnt;
- char outbuf[LOG_BUFSIZE];
-#endif
-} config_log_state;
-
-/*
- * Format items...
- * Note that many of these could have ap_sprintfs replaced with static buffers.
- */
-
-typedef const char *(*item_key_func) (request_rec *, char *);
-
-typedef struct {
- item_key_func func;
- char *arg;
- int condition_sense;
- int want_orig;
- ap_array_header_t *conditions;
-} log_format_item;
-
-static char *format_integer(ap_context_t *p, int i)
-{
- return ap_psprintf(p, "%d", i);
-}
-
-static char *pfmt(ap_context_t *p, int i)
-{
- if (i <= 0) {
- return "-";
- }
- else {
- return format_integer(p, i);
- }
-}
-
-static const char *constant_item(request_rec *dummy, char *stuff)
-{
- return stuff;
-}
-
-static const char *log_remote_host(request_rec *r, char *a)
-{
- return ap_get_remote_host(r->connection, r->per_dir_config,
- REMOTE_NAME);
-}
-
-static const char *log_remote_address(request_rec *r, char *a)
-{
- return r->connection->remote_ip;
-}
-
-static const char *log_local_address(request_rec *r, char *a)
-{
- return r->connection->local_ip;
-}
-
-static const char *log_remote_logname(request_rec *r, char *a)
-{
- return ap_get_remote_logname(r);
-}
-
-static const char *log_remote_user(request_rec *r, char *a)
-{
- char *rvalue = r->user;
-
- if (rvalue == NULL) {
- rvalue = "-";
- }
- else if (strlen(rvalue) == 0) {
- rvalue = "\"\"";
- }
- return rvalue;
-}
-
-static const char *log_request_line(request_rec *r, char *a)
-{
- /* NOTE: If the original request contained a password, we
- * re-write the request line here to contain XXXXXX instead:
- * (note the truncation before the protocol string for HTTP/0.9 requests)
- * (note also that r->the_request contains the unmodified request)
- */
- return (r->parsed_uri.password) ? ap_pstrcat(r->pool, r->method, " ",
- ap_unparse_uri_components(r->pool, &r->parsed_uri, 0),
- r->assbackwards ? NULL : " ", r->protocol, NULL)
- : r->the_request;
-}
-
-static const char *log_request_file(request_rec *r, char *a)
-{
- return r->filename;
-}
-static const char *log_request_uri(request_rec *r, char *a)
-{
- return r->uri;
-}
-static const char *log_status(request_rec *r, char *a)
-{
- return pfmt(r->pool, r->status);
-}
-
-static const char *log_bytes_sent(request_rec *r, char *a)
-{
- if (!r->sent_bodyct) {
- return "-";
- }
- else {
- long int bs;
- ap_bgetopt(r->connection->client, BO_BYTECT, &bs);
- return ap_psprintf(r->pool, "%ld", bs);
- }
-}
-
-static const char *log_header_in(request_rec *r, char *a)
-{
- return ap_table_get(r->headers_in, a);
-}
-
-static const char *log_header_out(request_rec *r, char *a)
-{
- const char *cp = ap_table_get(r->headers_out, a);
- if (!strcasecmp(a, "Content-type") && r->content_type) {
- cp = r->content_type;
- }
- if (cp) {
- return cp;
- }
- return ap_table_get(r->err_headers_out, a);
-}
-
-static const char *log_note(request_rec *r, char *a)
-{
- return ap_table_get(r->notes, a);
-}
-static const char *log_env_var(request_rec *r, char *a)
-{
- return ap_table_get(r->subprocess_env, a);
-}
-
-static const char *log_request_time(request_rec *r, char *a)
-{
- ap_exploded_time_t xt;
- ap_size_t retcode;
- char tstr[MAX_STRING_LEN];
-
- /*
- hi. i think getting the time again at the end of the request
- just for logging is dumb. i know it's "required" for CLF.
- folks writing log parsing tools don't realise that out of order
- times have always been possible (consider what happens if one
- process calculates the time to log, but then there's a context
- switch before it writes and before that process is run again the
- log rotation occurs) and they should just fix their tools rather
- than force the server to pay extra cpu cycles. if you've got
- a problem with this, you can set the define. -djg
- */
-#ifdef I_INSIST_ON_EXTRA_CYCLES_FOR_CLF_COMPLIANCE
- ap_explode_localtime(&xt, ap_now());
-#else
- ap_explode_localtime(&xt, r->request_time);
-#endif
- if (a && *a) { /* Custom format */
- ap_strftime(tstr, &retcode, MAX_STRING_LEN, a, &xt);
- }
- else { /* CLF format */
- char sign;
- int timz;
-
- timz = xt.tm_gmtoff;
- if (timz < 0) {
- timz = -timz;
- sign = '-';
- }
- else {
- sign = '+';
- }
-
- ap_snprintf(tstr, sizeof(tstr), "[%02d/%s/%d:%02d:%02d:%02d %c%.2d%.2d]",
- xt.tm_mday, ap_month_snames[xt.tm_mon], xt.tm_year+1900,
- xt.tm_hour, xt.tm_min, xt.tm_sec,
- sign, timz / (60*60), timz % (60*60));
- }
-
- return ap_pstrdup(r->pool, tstr);
-}
-
-static const char *log_request_duration(request_rec *r, char *a)
-{
- return ap_psprintf(r->pool, "%ld", (ap_now() - r->request_time) / AP_USEC_PER_SEC);
-}
-
-/* These next two routines use the canonical name:port so that log
- * parsers don't need to duplicate all the vhost parsing crud.
- */
-static const char *log_virtual_host(request_rec *r, char *a)
-{
- return r->server->server_hostname;
-}
-
-static const char *log_server_port(request_rec *r, char *a)
-{
- return ap_psprintf(r->pool, "%u",
- r->server->port ? r->server->port : ap_default_port(r));
-}
-
-/* This respects the setting of UseCanonicalName so that
- * the dynamic mass virtual hosting trick works better.
- */
-static const char *log_server_name(request_rec *r, char *a)
-{
- return ap_get_server_name(r);
-}
-
-static const char *log_child_pid(request_rec *r, char *a)
-{
- return ap_psprintf(r->pool, "%ld", (long) getpid());
-}
-
-/*****************************************************************
- *
- * Parsing the log format string
- */
-
-static struct log_item_list {
- char ch;
- item_key_func func;
- int want_orig_default;
-} log_item_keys[] = {
-
- {
- 'h', log_remote_host, 0
- },
- {
- 'a', log_remote_address, 0
- },
- {
- 'A', log_local_address, 0
- },
- {
- 'l', log_remote_logname, 0
- },
- {
- 'u', log_remote_user, 0
- },
- {
- 't', log_request_time, 0
- },
- {
- 'T', log_request_duration, 1
- },
- {
- 'r', log_request_line, 1
- },
- {
- 'f', log_request_file, 0
- },
- {
- 'U', log_request_uri, 1
- },
- {
- 's', log_status, 1
- },
- {
- 'b', log_bytes_sent, 0
- },
- {
- 'i', log_header_in, 0
- },
- {
- 'o', log_header_out, 0
- },
- {
- 'n', log_note, 0
- },
- {
- 'e', log_env_var, 0
- },
- {
- 'V', log_server_name, 0
- },
- {
- 'v', log_virtual_host, 0
- },
- {
- 'p', log_server_port, 0
- },
- {
- 'P', log_child_pid, 0
- },
- {
- '\0'
- }
-};
-
-static struct log_item_list *find_log_func(char k)
-{
- int i;
-
- for (i = 0; log_item_keys[i].ch; ++i)
- if (k == log_item_keys[i].ch) {
- return &log_item_keys[i];
- }
-
- return NULL;
-}
-
-static char *parse_log_misc_string(ap_context_t *p, log_format_item *it,
- const char **sa)
-{
- const char *s;
- char *d;
-
- it->func = constant_item;
- it->conditions = NULL;
-
- s = *sa;
- while (*s && *s != '%') {
- s++;
- }
- /*
- * This might allocate a few chars extra if there's a backslash
- * escape in the format string.
- */
- it->arg = ap_palloc(p, s - *sa + 1);
-
- d = it->arg;
- s = *sa;
- while (*s && *s != '%') {
- if (*s != '\\') {
- *d++ = *s++;
- }
- else {
- s++;
- switch (*s) {
- case '\\':
- *d++ = '\\';
- s++;
- break;
- case 'n':
- *d++ = '\n';
- s++;
- break;
- case 't':
- *d++ = '\t';
- s++;
- break;
- default:
- /* copy verbatim */
- *d++ = '\\';
- /*
- * Allow the loop to deal with this *s in the normal
- * fashion so that it handles end of string etc.
- * properly.
- */
- break;
- }
- }
- }
- *d = '\0';
-
- *sa = s;
- return NULL;
-}
-
-static char *parse_log_item(ap_context_t *p, log_format_item *it, const char **sa)
-{
- const char *s = *sa;
-
- if (*s != '%') {
- return parse_log_misc_string(p, it, sa);
- }
-
- ++s;
- it->condition_sense = 0;
- it->conditions = NULL;
- it->want_orig = -1;
- it->arg = ""; /* For safety's sake... */
-
- while (*s) {
- int i;
- struct log_item_list *l;
-
- switch (*s) {
- case '!':
- ++s;
- it->condition_sense = !it->condition_sense;
- break;
-
- case '<':
- ++s;
- it->want_orig = 1;
- break;
-
- case '>':
- ++s;
- it->want_orig = 0;
- break;
-
- case ',':
- ++s;
- break;
-
- case '{':
- ++s;
- it->arg = ap_getword(p, &s, '}');
- break;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- i = *s - '0';
- while (ap_isdigit(*++s)) {
- i = i * 10 + (*s) - '0';
- }
- if (!it->conditions) {
- it->conditions = ap_make_array(p, 4, sizeof(int));
- }
- *(int *) ap_push_array(it->conditions) = i;
- break;
-
- default:
- l = find_log_func(*s++);
- if (!l) {
- char dummy[2];
-
- dummy[0] = s[-1];
- dummy[1] = '\0';
- return ap_pstrcat(p, "Unrecognized LogFormat directive %",
- dummy, NULL);
- }
- it->func = l->func;
- if (it->want_orig == -1) {
- it->want_orig = l->want_orig_default;
- }
- *sa = s;
- return NULL;
- }
- }
-
- return "Ran off end of LogFormat parsing args to some directive";
-}
-
-static ap_array_header_t *parse_log_string(ap_context_t *p, const char *s, const char **err)
-{
- ap_array_header_t *a = ap_make_array(p, 30, sizeof(log_format_item));
- char *res;
-
- while (*s) {
- if ((res = parse_log_item(p, (log_format_item *) ap_push_array(a), &s))) {
- *err = res;
- return NULL;
- }
- }
-
- s = "\n";
- parse_log_item(p, (log_format_item *) ap_push_array(a), &s);
- return a;
-}
-
-/*****************************************************************
- *
- * Actually logging.
- */
-
-static const char *process_item(request_rec *r, request_rec *orig,
- log_format_item *item)
-{
- const char *cp;
-
- /* First, see if we need to process this thing at all... */
-
- if (item->conditions && item->conditions->nelts != 0) {
- int i;
- int *conds = (int *) item->conditions->elts;
- int in_list = 0;
-
- for (i = 0; i < item->conditions->nelts; ++i) {
- if (r->status == conds[i]) {
- in_list = 1;
- break;
- }
- }
-
- if ((item->condition_sense && in_list)
- || (!item->condition_sense && !in_list)) {
- return "-";
- }
- }
-
- /* We do. Do it... */
-
- cp = (*item->func) (item->want_orig ? orig : r, item->arg);
- return cp ? cp : "-";
-}
-
-#ifdef BUFFERED_LOGS
-static void flush_log(config_log_state *cls)
-{
- if (cls->outcnt && cls->log_fd != NULL) {
- ap_write(cls->log_fd, cls->outbuf, cls->outcnt);
- cls->outcnt = 0;
- }
-}
-#endif
-
-static int config_log_transaction(request_rec *r, config_log_state *cls,
- ap_array_header_t *default_format)
-{
- log_format_item *items;
- char *str, *s;
- const char **strs;
- int *strl;
- request_rec *orig;
- int i;
- ap_ssize_t len = 0;
- ap_array_header_t *format;
- char *envar;
-
- if (cls->fname == NULL) {
- return DECLINED;
- }
-
- /*
- * See if we've got any conditional envariable-controlled logging decisions
- * to make.
- */
- if (cls->condition_var != NULL) {
- envar = cls->condition_var;
- if (*envar != '!') {
- if (ap_table_get(r->subprocess_env, envar) == NULL) {
- return DECLINED;
- }
- }
- else {
- if (ap_table_get(r->subprocess_env, &envar[1]) != NULL) {
- return DECLINED;
- }
- }
- }
-
- format = cls->format ? cls->format : default_format;
-
- strs = ap_palloc(r->pool, sizeof(char *) * (format->nelts));
- strl = ap_palloc(r->pool, sizeof(int) * (format->nelts));
- items = (log_format_item *) format->elts;
-
- orig = r;
- while (orig->prev) {
- orig = orig->prev;
- }
- while (r->next) {
- r = r->next;
- }
-
- for (i = 0; i < format->nelts; ++i) {
- strs[i] = process_item(r, orig, &items[i]);
- }
-
- for (i = 0; i < format->nelts; ++i) {
- len += strl[i] = strlen(strs[i]);
- }
-
-#ifdef BUFFERED_LOGS
- if (len + cls->outcnt > LOG_BUFSIZE) {
- flush_log(cls);
- }
- if (len >= LOG_BUFSIZE) {
- str = ap_palloc(r->pool, len + 1);
- for (i = 0, s = str; i < format->nelts; ++i) {
- memcpy(s, strs[i], strl[i]);
- s += strl[i];
- }
- ap_write(cls->log_fd, str, len);
- }
- else {
- for (i = 0, s = &cls->outbuf[cls->outcnt]; i < format->nelts; ++i) {
- memcpy(s, strs[i], strl[i]);
- s += strl[i];
- }
- cls->outcnt += len;
- }
-#else
- str = ap_palloc(r->pool, len + 1);
-
- for (i = 0, s = str; i < format->nelts; ++i) {
- memcpy(s, strs[i], strl[i]);
- s += strl[i];
- }
-
- ap_write(cls->log_fd, str, &len);
-#endif
-
- return OK;
-}
-
-static int multi_log_transaction(request_rec *r)
-{
- multi_log_state *mls = ap_get_module_config(r->server->module_config,
- &config_log_module);
- config_log_state *clsarray;
- int i;
-
- /*
- * Log this transaction..
- */
- if (mls->config_logs->nelts) {
- clsarray = (config_log_state *) mls->config_logs->elts;
- for (i = 0; i < mls->config_logs->nelts; ++i) {
- config_log_state *cls = &clsarray[i];
-
- config_log_transaction(r, cls, mls->default_format);
- }
- }
- else if (mls->server_config_logs) {
- clsarray = (config_log_state *) mls->server_config_logs->elts;
- for (i = 0; i < mls->server_config_logs->nelts; ++i) {
- config_log_state *cls = &clsarray[i];
-
- config_log_transaction(r, cls, mls->default_format);
- }
- }
-
- return OK;
-}
-
-/*****************************************************************
- *
- * Module glue...
- */
-
-static void *make_config_log_state(ap_context_t *p, server_rec *s)
-{
- multi_log_state *mls;
-
- mls = (multi_log_state *) ap_palloc(p, sizeof(multi_log_state));
- mls->config_logs = ap_make_array(p, 1, sizeof(config_log_state));
- mls->default_format_string = NULL;
- mls->default_format = NULL;
- mls->server_config_logs = NULL;
- mls->formats = ap_make_table(p, 4);
- ap_table_setn(mls->formats, "CLF", DEFAULT_LOG_FORMAT);
-
- return mls;
-}
-
-/*
- * Use the merger to simply add a pointer from the vhost log state
- * to the log of logs specified for the non-vhost configuration. Make sure
- * vhosts inherit any globally-defined format names.
- */
-
-static void *merge_config_log_state(ap_context_t *p, void *basev, void *addv)
-{
- multi_log_state *base = (multi_log_state *) basev;
- multi_log_state *add = (multi_log_state *) addv;
-
- add->server_config_logs = base->config_logs;
- if (!add->default_format) {
- add->default_format_string = base->default_format_string;
- add->default_format = base->default_format;
- }
- add->formats = ap_overlay_tables(p, base->formats, add->formats);
-
- return add;
-}
-
-/*
- * Set the default logfile format, or define a nickname for a format string.
- */
-static const char *log_format(cmd_parms *cmd, void *dummy, char *fmt,
- char *name)
-{
- const char *err_string = NULL;
- multi_log_state *mls = ap_get_module_config(cmd->server->module_config,
- &config_log_module);
-
- /*
- * If we were given two arguments, the second is a name to be given to the
- * format. This syntax just defines the nickname - it doesn't actually
- * make the format the default.
- */
- if (name != NULL) {
- parse_log_string(cmd->pool, fmt, &err_string);
- if (err_string == NULL) {
- ap_table_setn(mls->formats, name, fmt);
- }
- }
- else {
- mls->default_format_string = fmt;
- mls->default_format = parse_log_string(cmd->pool, fmt, &err_string);
- }
- return err_string;
-}
-
-
-static const char *add_custom_log(cmd_parms *cmd, void *dummy, char *fn,
- char *fmt, char *envclause)
-{
- const char *err_string = NULL;
- multi_log_state *mls = ap_get_module_config(cmd->server->module_config,
- &config_log_module);
- config_log_state *cls;
-
- cls = (config_log_state *) ap_push_array(mls->config_logs);
- cls->condition_var = NULL;
- if (envclause != NULL) {
- if (strncasecmp(envclause, "env=", 4) != 0) {
- return "error in condition clause";
- }
- if ((envclause[4] == '\0')
- || ((envclause[4] == '!') && (envclause[5] == '\0'))) {
- return "missing environment variable name";
- }
- cls->condition_var = ap_pstrdup(cmd->pool, &envclause[4]);
- }
-
- cls->fname = fn;
- cls->format_string = fmt;
- if (fmt == NULL) {
- cls->format = NULL;
- }
- else {
- cls->format = parse_log_string(cmd->pool, fmt, &err_string);
- }
- cls->log_fd = NULL;
-
- return err_string;
-}
-
-static const char *set_transfer_log(cmd_parms *cmd, void *dummy, char *fn)
-{
- return add_custom_log(cmd, dummy, fn, NULL, NULL);
-}
-
-static const char *set_cookie_log(cmd_parms *cmd, void *dummy, char *fn)
-{
- return add_custom_log(cmd, dummy, fn, "%{Cookie}n \"%r\" %t", NULL);
-}
-
-static const command_rec config_log_cmds[] =
-{
- {"CustomLog", add_custom_log, NULL, RSRC_CONF, TAKE23,
- "a file name, a custom log format string or format name, "
- "and an optional \"env=\" clause (see docs)"},
- {"TransferLog", set_transfer_log, NULL, RSRC_CONF, TAKE1,
- "the filename of the access log"},
- {"LogFormat", log_format, NULL, RSRC_CONF, TAKE12,
- "a log format string (see docs) and an optional format name"},
- {"CookieLog", set_cookie_log, NULL, RSRC_CONF, TAKE1,
- "the filename of the cookie log"},
- {NULL}
-};
-
-static config_log_state *open_config_log(server_rec *s, ap_context_t *p,
- config_log_state *cls,
- ap_array_header_t *default_format)
-{
- ap_status_t status;
-
- if (cls->log_fd != NULL) {
- return cls; /* virtual config shared w/main server */
- }
-
- if (cls->fname == NULL) {
- return cls; /* Leave it NULL to decline. */
- }
-
- if (*cls->fname == '|') {
- piped_log *pl;
-
- pl = ap_open_piped_log(p, cls->fname + 1);
- if (pl == NULL) {
- exit(1);
- }
- cls->log_fd = ap_piped_log_write_fd(pl);
- }
- else {
- const char *fname = ap_server_root_relative(p, cls->fname);
- if ((status = ap_open(&cls->log_fd, fname, xfer_flags, xfer_mode, p))
- != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, status, s,
- "could not open transfer log file %s.", fname);
- exit(1);
- }
- }
-#ifdef BUFFERED_LOGS
- cls->outcnt = 0;
-#endif
-
- return cls;
-}
-
-static config_log_state *open_multi_logs(server_rec *s, ap_context_t *p)
-{
- int i;
- multi_log_state *mls = ap_get_module_config(s->module_config,
- &config_log_module);
- config_log_state *clsarray;
- const char *dummy;
- const char *format;
-
- if (mls->default_format_string) {
- format = ap_table_get(mls->formats, mls->default_format_string);
- if (format) {
- mls->default_format = parse_log_string(p, format, &dummy);
- }
- }
-
- if (!mls->default_format) {
- mls->default_format = parse_log_string(p, DEFAULT_LOG_FORMAT, &dummy);
- }
-
- if (mls->config_logs->nelts) {
- clsarray = (config_log_state *) mls->config_logs->elts;
- for (i = 0; i < mls->config_logs->nelts; ++i) {
- config_log_state *cls = &clsarray[i];
-
- if (cls->format_string) {
- format = ap_table_get(mls->formats, cls->format_string);
- if (format) {
- cls->format = parse_log_string(p, format, &dummy);
- }
- }
-
- cls = open_config_log(s, p, cls, mls->default_format);
- }
- }
- else if (mls->server_config_logs) {
- clsarray = (config_log_state *) mls->server_config_logs->elts;
- for (i = 0; i < mls->server_config_logs->nelts; ++i) {
- config_log_state *cls = &clsarray[i];
-
- if (cls->format_string) {
- format = ap_table_get(mls->formats, cls->format_string);
- if (format) {
- cls->format = parse_log_string(p, format, &dummy);
- }
- }
-
- cls = open_config_log(s, p, cls, mls->default_format);
- }
- }
-
- return NULL;
-}
-
-static void init_config_log(ap_context_t *pc, ap_context_t *p, ap_context_t *pt, server_rec *s)
-{
- /* First, do "physical" server, which gets default log fd and format
- * for the virtual servers, if they don't override...
- */
-
- open_multi_logs(s, p);
-
- /* Then, virtual servers */
-
- for (s = s->next; s; s = s->next) {
- open_multi_logs(s, p);
- }
-#ifdef BUFFERED_LOGS
- /* Now register the last buffer flush with the cleanup engine */
- ap_register_cleanup(p , s, flush_all_logs, flush_all_logs);
-#endif
-}
-
-#ifdef BUFFERED_LOGS
-static void flush_all_logs(server_rec *s)
-{
- multi_log_state *mls;
- ap_array_header_t *log_list;
- config_log_state *clsarray;
- int i;
-
- for (; s; s = s->next) {
- mls = ap_get_module_config(s->module_config, &config_log_module);
- log_list = NULL;
- if (mls->config_logs->nelts) {
- log_list = mls->config_logs;
- }
- else if (mls->server_config_logs) {
- log_list = mls->server_config_logs;
- }
- if (log_list) {
- clsarray = (config_log_state *) log_list->elts;
- for (i = 0; i < log_list->nelts; ++i) {
- flush_log(&clsarray[i]);
- }
- }
- }
-}
-#endif
-
-static void register_hooks(void)
-{
- ap_hook_open_logs(init_config_log,NULL,NULL,HOOK_MIDDLE);
- ap_hook_log_transaction(multi_log_transaction,NULL,NULL,HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT config_log_module =
-{
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-dir config */
- NULL, /* merge per-dir config */
- make_config_log_state, /* server config */
- merge_config_log_state, /* merge server config */
- config_log_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/loggers/mod_log_config.exp b/modules/loggers/mod_log_config.exp
deleted file mode 100644
index 01b926f4bb..0000000000
--- a/modules/loggers/mod_log_config.exp
+++ /dev/null
@@ -1 +0,0 @@
-config_log_module
diff --git a/modules/mappers/.indent.pro b/modules/mappers/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/mappers/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/mappers/mod_actions.c b/modules/mappers/mod_actions.c
deleted file mode 100644
index abf9318252..0000000000
--- a/modules/mappers/mod_actions.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_actions.c: executes scripts based on MIME type or HTTP method
- *
- * by Alexei Kosut; based on mod_cgi.c, mod_mime.c and mod_includes.c,
- * adapted by rst from original NCSA code by Rob McCool
- *
- * Usage instructions:
- *
- * Action mime/type /cgi-bin/script
- *
- * will activate /cgi-bin/script when a file of content type mime/type is
- * requested. It sends the URL and file path of the requested document using
- * the standard CGI PATH_INFO and PATH_TRANSLATED environment variables.
- *
- * Script PUT /cgi-bin/script
- *
- * will activate /cgi-bin/script when a request is received with the
- * HTTP method "PUT". The available method names are defined in httpd.h.
- * If the method is GET, the script will only be activated if the requested
- * URI includes query information (stuff after a ?-mark).
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "util_script.h"
-
-typedef struct {
- ap_table_t *action_types; /* Added with Action... */
- char *scripted[METHODS]; /* Added with Script... */
-} action_dir_config;
-
-module action_module;
-
-static void *create_action_dir_config(ap_context_t *p, char *dummy)
-{
- action_dir_config *new =
- (action_dir_config *) ap_palloc(p, sizeof(action_dir_config));
-
- new->action_types = ap_make_table(p, 4);
- memset(new->scripted, 0, sizeof(new->scripted));
-
- return new;
-}
-
-static void *merge_action_dir_configs(ap_context_t *p, void *basev, void *addv)
-{
- action_dir_config *base = (action_dir_config *) basev;
- action_dir_config *add = (action_dir_config *) addv;
- action_dir_config *new = (action_dir_config *) ap_palloc(p,
- sizeof(action_dir_config));
- int i;
-
- new->action_types = ap_overlay_tables(p, add->action_types,
- base->action_types);
-
- for (i = 0; i < METHODS; ++i) {
- new->scripted[i] = add->scripted[i] ? add->scripted[i]
- : base->scripted[i];
- }
- return new;
-}
-
-static const char *add_action(cmd_parms *cmd, action_dir_config * m, char *type,
- char *script)
-{
- ap_table_setn(m->action_types, type, script);
- return NULL;
-}
-
-static const char *set_script(cmd_parms *cmd, action_dir_config * m,
- char *method, char *script)
-{
- int methnum;
-
- methnum = ap_method_number_of(method);
- if (methnum == M_TRACE)
- return "TRACE not allowed for Script";
- else if (methnum == M_INVALID)
- return "Unknown method type for Script";
- else
- m->scripted[methnum] = script;
-
- return NULL;
-}
-
-static const command_rec action_cmds[] =
-{
- {"Action", add_action, NULL, OR_FILEINFO, TAKE2,
- "a media type followed by a script name"},
- {"Script", set_script, NULL, ACCESS_CONF | RSRC_CONF, TAKE2,
- "a method followed by a script name"},
- {NULL}
-};
-
-static int action_handler(request_rec *r)
-{
- action_dir_config *conf = (action_dir_config *)
- ap_get_module_config(r->per_dir_config, &action_module);
- const char *t, *action = r->handler ? r->handler : r->content_type;
- const char *script;
- int i;
-
- /* Set allowed stuff */
- for (i = 0; i < METHODS; ++i) {
- if (conf->scripted[i])
- r->allowed |= (1 << i);
- }
-
- /* First, check for the method-handling scripts */
- if (r->method_number == M_GET) {
- if (r->args)
- script = conf->scripted[M_GET];
- else
- script = NULL;
- }
- else {
- script = conf->scripted[r->method_number];
- }
-
- /* Check for looping, which can happen if the CGI script isn't */
- if (script && r->prev && r->prev->prev)
- return DECLINED;
-
- /* Second, check for actions (which override the method scripts) */
- if ((t = ap_table_get(conf->action_types,
- action ? action : ap_default_type(r)))) {
- script = t;
- if (r->finfo.protection == 0) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "File does not exist: %s", r->filename);
- return NOT_FOUND;
- }
- }
-
- if (script == NULL)
- return DECLINED;
-
- ap_internal_redirect_handler(ap_pstrcat(r->pool, script, ap_escape_uri(r->pool,
- r->uri), r->args ? "?" : NULL, r->args, NULL), r);
- return OK;
-}
-
-static const handler_rec action_handlers[] =
-{
- {"*/*", action_handler},
- {NULL}
-};
-
-module action_module =
-{
- STANDARD20_MODULE_STUFF,
- create_action_dir_config, /* dir config creater */
- merge_action_dir_configs, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- action_cmds, /* command ap_table_t */
- action_handlers, /* handlers */
- NULL /* register hooks */
-};
diff --git a/modules/mappers/mod_actions.exp b/modules/mappers/mod_actions.exp
deleted file mode 100644
index 815dff29a8..0000000000
--- a/modules/mappers/mod_actions.exp
+++ /dev/null
@@ -1 +0,0 @@
-action_module
diff --git a/modules/mappers/mod_alias.c b/modules/mappers/mod_alias.c
deleted file mode 100644
index d2f3179226..0000000000
--- a/modules/mappers/mod_alias.c
+++ /dev/null
@@ -1,417 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_alias.c: Stuff for dealing with directory aliases
- *
- * Original by Rob McCool, rewritten in succession by David Robinson
- * and rst.
- *
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-
-typedef struct {
- char *real;
- char *fake;
- char *handler;
- regex_t *regexp;
- int redir_status; /* 301, 302, 303, 410, etc */
-} alias_entry;
-
-typedef struct {
- ap_array_header_t *aliases;
- ap_array_header_t *redirects;
-} alias_server_conf;
-
-typedef struct {
- ap_array_header_t *redirects;
-} alias_dir_conf;
-
-module MODULE_VAR_EXPORT alias_module;
-
-static void *create_alias_config(ap_context_t *p, server_rec *s)
-{
- alias_server_conf *a =
- (alias_server_conf *) ap_pcalloc(p, sizeof(alias_server_conf));
-
- a->aliases = ap_make_array(p, 20, sizeof(alias_entry));
- a->redirects = ap_make_array(p, 20, sizeof(alias_entry));
- return a;
-}
-
-static void *create_alias_dir_config(ap_context_t *p, char *d)
-{
- alias_dir_conf *a =
- (alias_dir_conf *) ap_pcalloc(p, sizeof(alias_dir_conf));
- a->redirects = ap_make_array(p, 2, sizeof(alias_entry));
- return a;
-}
-
-static void *merge_alias_config(ap_context_t *p, void *basev, void *overridesv)
-{
- alias_server_conf *a =
- (alias_server_conf *) ap_pcalloc(p, sizeof(alias_server_conf));
- alias_server_conf *base = (alias_server_conf *) basev, *overrides = (alias_server_conf *) overridesv;
-
- a->aliases = ap_append_arrays(p, overrides->aliases, base->aliases);
- a->redirects = ap_append_arrays(p, overrides->redirects, base->redirects);
- return a;
-}
-
-static void *merge_alias_dir_config(ap_context_t *p, void *basev, void *overridesv)
-{
- alias_dir_conf *a =
- (alias_dir_conf *) ap_pcalloc(p, sizeof(alias_dir_conf));
- alias_dir_conf *base = (alias_dir_conf *) basev, *overrides = (alias_dir_conf *) overridesv;
- a->redirects = ap_append_arrays(p, overrides->redirects, base->redirects);
- return a;
-}
-
-static const char *add_alias_internal(cmd_parms *cmd, void *dummy, char *f, char *r,
- int use_regex)
-{
- server_rec *s = cmd->server;
- alias_server_conf *conf =
- (alias_server_conf *) ap_get_module_config(s->module_config, &alias_module);
- alias_entry *new = ap_push_array(conf->aliases);
-
- /* XX r can NOT be relative to DocumentRoot here... compat bug. */
-
- if (use_regex) {
- new->regexp = ap_pregcomp(cmd->pool, f, REG_EXTENDED);
- if (new->regexp == NULL)
- return "Regular expression could not be compiled.";
- }
-
- new->fake = f;
- new->real = r;
- new->handler = cmd->info;
-
- return NULL;
-}
-
-static const char *add_alias(cmd_parms *cmd, void *dummy, char *f, char *r)
-{
- return add_alias_internal(cmd, dummy, f, r, 0);
-}
-
-static const char *add_alias_regex(cmd_parms *cmd, void *dummy, char *f, char *r)
-{
- return add_alias_internal(cmd, dummy, f, r, 1);
-}
-
-static const char *add_redirect_internal(cmd_parms *cmd, alias_dir_conf * dirconf,
- char *arg1, char *arg2, char *arg3,
- int use_regex)
-{
- alias_entry *new;
- server_rec *s = cmd->server;
- alias_server_conf *serverconf =
- (alias_server_conf *) ap_get_module_config(s->module_config, &alias_module);
- int status = (int) (long) cmd->info;
- regex_t *r = NULL;
- char *f = arg2;
- char *url = arg3;
-
- if (!strcasecmp(arg1, "gone"))
- status = HTTP_GONE;
- else if (!strcasecmp(arg1, "permanent"))
- status = HTTP_MOVED_PERMANENTLY;
- else if (!strcasecmp(arg1, "temp"))
- status = HTTP_MOVED_TEMPORARILY;
- else if (!strcasecmp(arg1, "seeother"))
- status = HTTP_SEE_OTHER;
- else if (ap_isdigit(*arg1))
- status = atoi(arg1);
- else {
- f = arg1;
- url = arg2;
- }
-
- if (use_regex) {
- r = ap_pregcomp(cmd->pool, f, REG_EXTENDED);
- if (r == NULL)
- return "Regular expression could not be compiled.";
- }
-
- if (ap_is_HTTP_REDIRECT(status)) {
- if (!url)
- return "URL to redirect to is missing";
- if (!use_regex && !ap_is_url(url))
- return "Redirect to non-URL";
- }
- else {
- if (url)
- return "Redirect URL not valid for this status";
- }
-
- if (cmd->path)
- new = ap_push_array(dirconf->redirects);
- else
- new = ap_push_array(serverconf->redirects);
-
- new->fake = f;
- new->real = url;
- new->regexp = r;
- new->redir_status = status;
- return NULL;
-}
-
-static const char *add_redirect(cmd_parms *cmd, alias_dir_conf * dirconf, char *arg1,
- char *arg2, char *arg3)
-{
- return add_redirect_internal(cmd, dirconf, arg1, arg2, arg3, 0);
-}
-
-static const char *add_redirect_regex(cmd_parms *cmd, alias_dir_conf * dirconf,
- char *arg1, char *arg2, char *arg3)
-{
- return add_redirect_internal(cmd, dirconf, arg1, arg2, arg3, 1);
-}
-
-static const command_rec alias_cmds[] =
-{
- {"Alias", add_alias, NULL, RSRC_CONF, TAKE2,
- "a fakename and a realname"},
- {"ScriptAlias", add_alias, "cgi-script", RSRC_CONF, TAKE2,
- "a fakename and a realname"},
- {"Redirect", add_redirect, (void *) HTTP_MOVED_TEMPORARILY,
- OR_FILEINFO, TAKE23,
- "an optional status, then document to be redirected and destination URL"},
- {"AliasMatch", add_alias_regex, NULL, RSRC_CONF, TAKE2,
- "a regular expression and a filename"},
- {"ScriptAliasMatch", add_alias_regex, "cgi-script", RSRC_CONF, TAKE2,
- "a regular expression and a filename"},
- {"RedirectMatch", add_redirect_regex, (void *) HTTP_MOVED_TEMPORARILY,
- OR_FILEINFO, TAKE23,
- "an optional status, then a regular expression and destination URL"},
- {"RedirectTemp", add_redirect, (void *) HTTP_MOVED_TEMPORARILY,
- OR_FILEINFO, TAKE2,
- "a document to be redirected, then the destination URL"},
- {"RedirectPermanent", add_redirect, (void *) HTTP_MOVED_PERMANENTLY,
- OR_FILEINFO, TAKE2,
- "a document to be redirected, then the destination URL"},
- {NULL}
-};
-
-static int alias_matches(const char *uri, const char *alias_fakename)
-{
- const char *end_fakename = alias_fakename + strlen(alias_fakename);
- const char *aliasp = alias_fakename, *urip = uri;
-
- while (aliasp < end_fakename) {
- if (*aliasp == '/') {
- /* any number of '/' in the alias matches any number in
- * the supplied URI, but there must be at least one...
- */
- if (*urip != '/')
- return 0;
-
- while (*aliasp == '/')
- ++aliasp;
- while (*urip == '/')
- ++urip;
- }
- else {
- /* Other characters are compared literally */
- if (*urip++ != *aliasp++)
- return 0;
- }
- }
-
- /* Check last alias path component matched all the way */
-
- if (aliasp[-1] != '/' && *urip != '\0' && *urip != '/')
- return 0;
-
- /* Return number of characters from URI which matched (may be
- * greater than length of alias, since we may have matched
- * doubled slashes)
- */
-
- return urip - uri;
-}
-
-static char *try_alias_list(request_rec *r, ap_array_header_t *aliases, int doesc, int *status)
-{
- alias_entry *entries = (alias_entry *) aliases->elts;
- regmatch_t regm[10];
- char *found = NULL;
- int i;
-
- for (i = 0; i < aliases->nelts; ++i) {
- alias_entry *p = &entries[i];
- int l;
-
- if (p->regexp) {
- if (!ap_regexec(p->regexp, r->uri, p->regexp->re_nsub + 1, regm, 0)) {
- if (p->real) {
- found = ap_pregsub(r->pool, p->real, r->uri,
- p->regexp->re_nsub + 1, regm);
- if (found && doesc) {
- found = ap_escape_uri(r->pool, found);
- }
- }
- else {
- /* need something non-null */
- found = ap_pstrdup(r->pool, "");
- }
- }
- }
- else {
- l = alias_matches(r->uri, p->fake);
-
- if (l > 0) {
- if (doesc) {
- char *escurl;
- escurl = ap_os_escape_path(r->pool, r->uri + l, 1);
-
- found = ap_pstrcat(r->pool, p->real, escurl, NULL);
- }
- else
- found = ap_pstrcat(r->pool, p->real, r->uri + l, NULL);
- }
- }
-
- if (found) {
- if (p->handler) { /* Set handler, and leave a note for mod_cgi */
- r->handler = p->handler;
- ap_table_setn(r->notes, "alias-forced-type", r->handler);
- }
-
- *status = p->redir_status;
-
- return found;
- }
-
- }
-
- return NULL;
-}
-
-static int translate_alias_redir(request_rec *r)
-{
- void *sconf = r->server->module_config;
- alias_server_conf *serverconf =
- (alias_server_conf *) ap_get_module_config(sconf, &alias_module);
- char *ret;
- int status;
-
- if (r->uri[0] != '/' && r->uri[0] != '\0')
- return DECLINED;
-
- if ((ret = try_alias_list(r, serverconf->redirects, 1, &status)) != NULL) {
- if (ap_is_HTTP_REDIRECT(status)) {
- /* include QUERY_STRING if any */
- if (r->args) {
- ret = ap_pstrcat(r->pool, ret, "?", r->args, NULL);
- }
- ap_table_setn(r->headers_out, "Location", ret);
- }
- return status;
- }
-
- if ((ret = try_alias_list(r, serverconf->aliases, 0, &status)) != NULL) {
- r->filename = ret;
- return OK;
- }
-
- return DECLINED;
-}
-
-static int fixup_redir(request_rec *r)
-{
- void *dconf = r->per_dir_config;
- alias_dir_conf *dirconf =
- (alias_dir_conf *) ap_get_module_config(dconf, &alias_module);
- char *ret;
- int status;
-
- /* It may have changed since last time, so try again */
-
- if ((ret = try_alias_list(r, dirconf->redirects, 1, &status)) != NULL) {
- if (ap_is_HTTP_REDIRECT(status))
- ap_table_setn(r->headers_out, "Location", ret);
- return status;
- }
-
- return DECLINED;
-}
-
-static void register_hooks(void)
-{
- static const char * const aszPre[]={ "mod_userdir.c",NULL };
-
- ap_hook_translate_name(translate_alias_redir,aszPre,NULL,HOOK_MIDDLE);
- ap_hook_fixups(fixup_redir,NULL,NULL,HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT alias_module =
-{
- STANDARD20_MODULE_STUFF,
- create_alias_dir_config, /* dir config creater */
- merge_alias_dir_config, /* dir merger --- default is to override */
- create_alias_config, /* server config */
- merge_alias_config, /* merge server configs */
- alias_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/mappers/mod_alias.exp b/modules/mappers/mod_alias.exp
deleted file mode 100644
index ac386ec3fa..0000000000
--- a/modules/mappers/mod_alias.exp
+++ /dev/null
@@ -1 +0,0 @@
-alias_module
diff --git a/modules/mappers/mod_dir.c b/modules/mappers/mod_dir.c
deleted file mode 100644
index bff9b3b0d4..0000000000
--- a/modules/mappers/mod_dir.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_dir.c: handle default index files, and trailing-/ redirects
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_request.h"
-#include "http_protocol.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "util_script.h"
-
-module MODULE_VAR_EXPORT dir_module;
-
-typedef struct dir_config_struct {
- ap_array_header_t *index_names;
-} dir_config_rec;
-
-#define DIR_CMD_PERMS OR_INDEXES
-
-static const char *add_index(cmd_parms *cmd, void *dummy, char *arg)
-{
- dir_config_rec *d = dummy;
-
- if (!d->index_names) {
- d->index_names = ap_make_array(cmd->pool, 2, sizeof(char *));
- }
- *(char **)ap_push_array(d->index_names) = arg;
- return NULL;
-}
-
-static const command_rec dir_cmds[] =
-{
- {"DirectoryIndex", add_index, NULL,
- DIR_CMD_PERMS, ITERATE,
- "a list of file names"},
- {NULL}
-};
-
-static void *create_dir_config(ap_context_t *p, char *dummy)
-{
- dir_config_rec *new =
- (dir_config_rec *) ap_pcalloc(p, sizeof(dir_config_rec));
-
- new->index_names = NULL;
- return (void *) new;
-}
-
-static void *merge_dir_configs(ap_context_t *p, void *basev, void *addv)
-{
- dir_config_rec *new = (dir_config_rec *) ap_pcalloc(p, sizeof(dir_config_rec));
- dir_config_rec *base = (dir_config_rec *) basev;
- dir_config_rec *add = (dir_config_rec *) addv;
-
- new->index_names = add->index_names ? add->index_names : base->index_names;
- return new;
-}
-
-static int handle_dir(request_rec *r)
-{
- dir_config_rec *d =
- (dir_config_rec *) ap_get_module_config(r->per_dir_config,
- &dir_module);
- char *dummy_ptr[1];
- char **names_ptr;
- int num_names;
- int error_notfound = 0;
-
- if (r->uri[0] == '\0' || r->uri[strlen(r->uri) - 1] != '/') {
- char *ifile;
- if (r->args != NULL)
- ifile = ap_pstrcat(r->pool, ap_escape_uri(r->pool, r->uri),
- "/", "?", r->args, NULL);
- else
- ifile = ap_pstrcat(r->pool, ap_escape_uri(r->pool, r->uri),
- "/", NULL);
-
- ap_table_setn(r->headers_out, "Location",
- ap_construct_url(r->pool, ifile, r));
- return HTTP_MOVED_PERMANENTLY;
- }
-
- /* KLUDGE --- make the sub_req lookups happen in the right directory.
- * Fixing this in the sub_req_lookup functions themselves is difficult,
- * and would probably break virtual includes...
- */
-
- if (r->filename[strlen(r->filename) - 1] != '/') {
- r->filename = ap_pstrcat(r->pool, r->filename, "/", NULL);
- }
-
- if (d->index_names) {
- names_ptr = (char **)d->index_names->elts;
- num_names = d->index_names->nelts;
- }
- else {
- dummy_ptr[0] = AP_DEFAULT_INDEX;
- names_ptr = dummy_ptr;
- num_names = 1;
- }
-
- for (; num_names; ++names_ptr, --num_names) {
- char *name_ptr = *names_ptr;
- request_rec *rr = ap_sub_req_lookup_uri(name_ptr, r);
-
- if (rr->status == HTTP_OK && rr->finfo.filetype == APR_REG) {
- char *new_uri = ap_escape_uri(r->pool, rr->uri);
-
- if (rr->args != NULL)
- new_uri = ap_pstrcat(r->pool, new_uri, "?", rr->args, NULL);
- else if (r->args != NULL)
- new_uri = ap_pstrcat(r->pool, new_uri, "?", r->args, NULL);
-
- ap_destroy_sub_req(rr);
- ap_internal_redirect(new_uri, r);
- return OK;
- }
-
- /* If the request returned a redirect, propagate it to the client */
-
- if (ap_is_HTTP_REDIRECT(rr->status) ||
- (rr->status == HTTP_NOT_ACCEPTABLE && num_names == 1)) {
-
- ap_pool_join(r->pool, rr->pool);
- error_notfound = rr->status;
- r->notes = ap_overlay_tables(r->pool, r->notes, rr->notes);
- r->headers_out = ap_overlay_tables(r->pool, r->headers_out,
- rr->headers_out);
- r->err_headers_out = ap_overlay_tables(r->pool, r->err_headers_out,
- rr->err_headers_out);
- return error_notfound;
- }
-
- /* If the request returned something other than 404 (or 200),
- * it means the module encountered some sort of problem. To be
- * secure, we should return the error, rather than create
- * along a (possibly unsafe) directory index.
- *
- * So we store the error, and if none of the listed files
- * exist, we return the last error response we got, instead
- * of a directory listing.
- */
- if (rr->status && rr->status != HTTP_NOT_FOUND && rr->status != HTTP_OK)
- error_notfound = rr->status;
-
- ap_destroy_sub_req(rr);
- }
-
- if (error_notfound)
- return error_notfound;
-
- if (r->method_number != M_GET)
- return DECLINED;
-
- /* nothing for us to do, pass on through */
-
- return DECLINED;
-}
-
-
-static const handler_rec dir_handlers[] =
-{
- {DIR_MAGIC_TYPE, handle_dir},
- {NULL}
-};
-
-module MODULE_VAR_EXPORT dir_module = {
- STANDARD20_MODULE_STUFF,
- create_dir_config, /* create per-directory config structure */
- merge_dir_configs, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- dir_cmds, /* command ap_table_t */
- dir_handlers, /* handlers */
- NULL /* register hooks */
-};
diff --git a/modules/mappers/mod_dir.exp b/modules/mappers/mod_dir.exp
deleted file mode 100644
index 5fbf772991..0000000000
--- a/modules/mappers/mod_dir.exp
+++ /dev/null
@@ -1 +0,0 @@
-dir_module
diff --git a/modules/mappers/mod_imap.c b/modules/mappers/mod_imap.c
deleted file mode 100644
index a6eadbb6f4..0000000000
--- a/modules/mappers/mod_imap.c
+++ /dev/null
@@ -1,912 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * IT'S 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * This imagemap module started as a port of the original imagemap.c
- * written by Rob McCool (11/13/93 robm@ncsa.uiuc.edu).
- * This version includes the mapping algorithms found in version 1.3
- * of imagemap.c.
- *
- * Contributors to this code include:
- *
- * Kevin Hughes, kevinh@pulua.hcc.hawaii.edu
- *
- * Eric Haines, erich@eye.com
- * "macmartinized" polygon code copyright 1992 by Eric Haines, erich@eye.com
- *
- * Randy Terbush, randy@zyzzyva.com
- * port to Apache module format, "base_uri" and support for relative URLs
- *
- * James H. Cloos, Jr., cloos@jhcloos.com
- * Added point datatype, using code in NCSA's version 1.8 imagemap.c
- * program, as distributed with version 1.4.1 of their server.
- * The point code is originally added by Craig Milo Rogers, Rogers@ISI.Edu
- *
- * Nathan Kurz, nate@tripod.com
- * Rewrite/reorganization. New handling of default, base and relative URLs.
- * New Configuration directives:
- * ImapMenu {none, formatted, semiformatted, unformatted}
- * ImapDefault {error, nocontent, referer, menu, URL}
- * ImapBase {map, referer, URL}
- * Support for creating non-graphical menu added. (backwards compatible):
- * Old: directive URL [x,y ...]
- * New: directive URL "Menu text" [x,y ...]
- * or: directive URL x,y ... "Menu text"
- * Map format and menu concept courtesy Joshua Bell, jsbell@acs.ucalgary.ca.
- *
- * Mark Cox, mark@ukweb.com, Allow relative URLs even when no base specified
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "util_script.h"
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#define IMAP_MAGIC_TYPE "application/x-httpd-imap"
-#define MAXVERTS 100
-#define X 0
-#define Y 1
-
-#define IMAP_MENU_DEFAULT "formatted"
-#define IMAP_DEFAULT_DEFAULT "nocontent"
-#define IMAP_BASE_DEFAULT "map"
-
-#ifdef SUNOS4
-double strtod(); /* SunOS needed this */
-#endif
-
-module MODULE_VAR_EXPORT imap_module;
-
-typedef struct {
- char *imap_menu;
- char *imap_default;
- char *imap_base;
-} imap_conf_rec;
-
-static void *create_imap_dir_config(ap_context_t *p, char *dummy)
-{
- imap_conf_rec *icr =
- (imap_conf_rec *) ap_palloc(p, sizeof(imap_conf_rec));
-
- icr->imap_menu = NULL;
- icr->imap_default = NULL;
- icr->imap_base = NULL;
-
- return icr;
-}
-
-static void *merge_imap_dir_configs(ap_context_t *p, void *basev, void *addv)
-{
- imap_conf_rec *new = (imap_conf_rec *) ap_pcalloc(p, sizeof(imap_conf_rec));
- imap_conf_rec *base = (imap_conf_rec *) basev;
- imap_conf_rec *add = (imap_conf_rec *) addv;
-
- new->imap_menu = add->imap_menu ? add->imap_menu : base->imap_menu;
- new->imap_default = add->imap_default ? add->imap_default
- : base->imap_default;
- new->imap_base = add->imap_base ? add->imap_base : base->imap_base;
-
- return new;
-}
-
-
-static const command_rec imap_cmds[] =
-{
- {"ImapMenu", ap_set_string_slot,
- (void *) XtOffsetOf(imap_conf_rec, imap_menu), OR_INDEXES, TAKE1,
- "the type of menu generated: none, formatted, semiformatted, unformatted"},
- {"ImapDefault", ap_set_string_slot,
- (void *) XtOffsetOf(imap_conf_rec, imap_default), OR_INDEXES, TAKE1,
- "the action taken if no match: error, nocontent, referer, menu, URL"},
- {"ImapBase", ap_set_string_slot,
- (void *) XtOffsetOf(imap_conf_rec, imap_base), OR_INDEXES, TAKE1,
- "the base for all URL's: map, referer, URL (or start of)"},
- {NULL}
-};
-
-static int pointinrect(const double point[2], double coords[MAXVERTS][2])
-{
- double max[2], min[2];
- if (coords[0][X] > coords[1][X]) {
- max[0] = coords[0][X];
- min[0] = coords[1][X];
- }
- else {
- max[0] = coords[1][X];
- min[0] = coords[0][X];
- }
-
- if (coords[0][Y] > coords[1][Y]) {
- max[1] = coords[0][Y];
- min[1] = coords[1][Y];
- }
- else {
- max[1] = coords[1][Y];
- min[1] = coords[0][Y];
- }
-
- return ((point[X] >= min[0] && point[X] <= max[0]) &&
- (point[Y] >= min[1] && point[Y] <= max[1]));
-}
-
-static int pointincircle(const double point[2], double coords[MAXVERTS][2])
-{
- double radius1, radius2;
-
- radius1 = ((coords[0][Y] - coords[1][Y]) * (coords[0][Y] - coords[1][Y]))
- + ((coords[0][X] - coords[1][X]) * (coords[0][X] - coords[1][X]));
-
- radius2 = ((coords[0][Y] - point[Y]) * (coords[0][Y] - point[Y]))
- + ((coords[0][X] - point[X]) * (coords[0][X] - point[X]));
-
- return (radius2 <= radius1);
-}
-
-#define fmin(a,b) (((a)>(b))?(b):(a))
-#define fmax(a,b) (((a)>(b))?(a):(b))
-
-static int pointinpoly(const double point[2], double pgon[MAXVERTS][2])
-{
- int i, numverts, crossings = 0;
- double x = point[X], y = point[Y];
-
- for (numverts = 0; pgon[numverts][X] != -1 && numverts < MAXVERTS;
- numverts++) {
- /* just counting the vertexes */
- }
-
- for (i = 0; i < numverts; i++) {
- double x1=pgon[i][X];
- double y1=pgon[i][Y];
- double x2=pgon[(i + 1) % numverts][X];
- double y2=pgon[(i + 1) % numverts][Y];
- double d=(y - y1) * (x2 - x1) - (x - x1) * (y2 - y1);
-
- if ((y1 >= y) != (y2 >= y)) {
- crossings +=y2 - y1 >= 0 ? d >= 0 : d <= 0;
- }
- if (!d && fmin(x1,x2) <= x && x <= fmax(x1,x2)
- && fmin(y1,y2) <= y && y <= fmax(y1,y2)) {
- return 1;
- }
- }
- return crossings & 0x01;
-}
-
-
-static int is_closer(const double point[2], double coords[MAXVERTS][2],
- double *closest)
-{
- double dist_squared = ((point[X] - coords[0][X])
- * (point[X] - coords[0][X]))
- + ((point[Y] - coords[0][Y])
- * (point[Y] - coords[0][Y]));
-
- if (point[X] < 0 || point[Y] < 0) {
- return (0); /* don't mess around with negative coordinates */
- }
-
- if (*closest < 0 || dist_squared < *closest) {
- *closest = dist_squared;
- return (1); /* if this is the first point or is the closest yet
- set 'closest' equal to this distance^2 */
- }
-
- return (0); /* if it's not the first or closest */
-
-}
-
-static double get_x_coord(const char *args)
-{
- char *endptr; /* we want it non-null */
- double x_coord = -1; /* -1 is returned if no coordinate is given */
-
- if (args == NULL) {
- return (-1); /* in case we aren't passed anything */
- }
-
- while (*args && !ap_isdigit(*args) && *args != ',') {
- args++; /* jump to the first digit, but not past
- a comma or end */
- }
-
- x_coord = strtod(args, &endptr);
-
- if (endptr > args) { /* if a conversion was made */
- return (x_coord);
- }
-
- return (-1); /* else if no conversion was made,
- or if no args was given */
-}
-
-static double get_y_coord(const char *args)
-{
- char *endptr; /* we want it non-null */
- char *start_of_y = NULL;
- double y_coord = -1; /* -1 is returned on error */
-
- if (args == NULL) {
- return (-1); /* in case we aren't passed anything */
- }
-
- start_of_y = strchr(args, ','); /* the comma */
-
- if (start_of_y) {
-
- start_of_y++; /* start looking at the character after
- the comma */
-
- while (*start_of_y && !ap_isdigit(*start_of_y)) {
- start_of_y++; /* jump to the first digit, but not
- past the end */
- }
-
- y_coord = strtod(start_of_y, &endptr);
-
- if (endptr > start_of_y) {
- return (y_coord);
- }
- }
-
- return (-1); /* if no conversion was made, or
- no comma was found in args */
-}
-
-
-/* See if string has a "quoted part", and if so set *quoted_part to
- * the first character of the quoted part, then hammer a \0 onto the
- * trailing quote, and set *string to point at the first character
- * past the second quote.
- *
- * Otherwise set *quoted_part to NULL, and leave *string alone.
- */
-static void read_quoted(char **string, char **quoted_part)
-{
- char *strp = *string;
-
- /* assume there's no quoted part */
- *quoted_part = NULL;
-
- while (ap_isspace(*strp)) {
- strp++; /* go along string until non-whitespace */
- }
-
- if (*strp == '"') { /* if that character is a double quote */
- strp++; /* step over it */
- *quoted_part = strp; /* note where the quoted part begins */
-
- while (*strp && *strp != '"') {
- ++strp; /* skip the quoted portion */
- }
-
- *strp = '\0'; /* end the string with a NUL */
-
- strp++; /* step over the last double quote */
- *string = strp;
- }
-}
-
-/*
- * returns the mapped URL or NULL.
- */
-static char *imap_url(request_rec *r, const char *base, const char *value)
-{
-/* translates a value into a URL. */
- int slen, clen;
- char *string_pos = NULL;
- const char *string_pos_const = NULL;
- char *directory = NULL;
- const char *referer = NULL;
- char *my_base;
-
- if (!strcasecmp(value, "map") || !strcasecmp(value, "menu")) {
- return ap_construct_url(r->pool, r->uri, r);
- }
-
- if (!strcasecmp(value, "nocontent") || !strcasecmp(value, "error")) {
- return ap_pstrdup(r->pool, value); /* these are handled elsewhere,
- so just copy them */
- }
-
- if (!strcasecmp(value, "referer")) {
- referer = ap_table_get(r->headers_in, "Referer");
- if (referer && *referer) {
- return ap_pstrdup(r->pool, referer);
- }
- else {
- /* XXX: This used to do *value = '\0'; ... which is totally bogus
- * because it hammers the passed in value, which can be a string
- * constant, or part of a config, or whatever. Total garbage.
- * This works around that without changing the rest of this
- * code much
- */
- value = ""; /* if 'referer' but no referring page,
- null the value */
- }
- }
-
- string_pos_const = value;
- while (ap_isalpha(*string_pos_const)) {
- string_pos_const++; /* go along the URL from the map
- until a non-letter */
- }
- if (*string_pos_const == ':') {
- /* if letters and then a colon (like http:) */
- /* it's an absolute URL, so use it! */
- return ap_pstrdup(r->pool, value);
- }
-
- if (!base || !*base) {
- if (value && *value) {
- return ap_pstrdup(r->pool, value); /* no base: use what is given */
- }
- /* no base, no value: pick a simple default */
- return ap_construct_url(r->pool, "/", r);
- }
-
- /* must be a relative URL to be combined with base */
- if (strchr(base, '/') == NULL && (!strncmp(value, "../", 3)
- || !strcmp(value, ".."))) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "invalid base directive in map file: %s", r->uri);
- return NULL;
- }
- my_base = ap_pstrdup(r->pool, base);
- string_pos = my_base;
- while (*string_pos) {
- if (*string_pos == '/' && *(string_pos + 1) == '/') {
- string_pos += 2; /* if there are two slashes, jump over them */
- continue;
- }
- if (*string_pos == '/') { /* the first single slash */
- if (value[0] == '/') {
- *string_pos = '\0';
- } /* if the URL from the map starts from root,
- end the base URL string at the first single
- slash */
- else {
- directory = string_pos; /* save the start of
- the directory portion */
-
- string_pos = strrchr(string_pos, '/'); /* now reuse
- string_pos */
- string_pos++; /* step over that last slash */
- *string_pos = '\0';
- } /* but if the map url is relative, leave the
- slash on the base (if there is one) */
- break;
- }
- string_pos++; /* until we get to the end of my_base without
- finding a slash by itself */
- }
-
- while (!strncmp(value, "../", 3) || !strcmp(value, "..")) {
-
- if (directory && (slen = strlen(directory))) {
-
- /* for each '..', knock a directory off the end
- by ending the string right at the last slash.
- But only consider the directory portion: don't eat
- into the server name. And only try if a directory
- portion was found */
-
- clen = slen - 1;
-
- while ((slen - clen) == 1) {
-
- if ((string_pos = strrchr(directory, '/'))) {
- *string_pos = '\0';
- }
- clen = strlen(directory);
- if (clen == 0) {
- break;
- }
- }
-
- value += 2; /* jump over the '..' that we found in the
- value */
- }
- else if (directory) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "invalid directory name in map file: %s", r->uri);
- return NULL;
- }
-
- if (!strncmp(value, "/../", 4) || !strcmp(value, "/..")) {
- value++; /* step over the '/' if there are more '..'
- to do. This way, we leave the starting
- '/' on value after the last '..', but get
- rid of it otherwise */
- }
-
- } /* by this point, value does not start
- with '..' */
-
- if (value && *value) {
- return ap_pstrcat(r->pool, my_base, value, NULL);
- }
- return my_base;
-}
-
-static int imap_reply(request_rec *r, char *redirect)
-{
- if (!strcasecmp(redirect, "error")) {
- return SERVER_ERROR; /* they actually requested an error! */
- }
- if (!strcasecmp(redirect, "nocontent")) {
- return HTTP_NO_CONTENT; /* tell the client to keep the page it has */
- }
- if (redirect && *redirect) {
- ap_table_setn(r->headers_out, "Location", redirect);
- return REDIRECT; /* must be a URL, so redirect to it */
- }
- return SERVER_ERROR;
-}
-
-static void menu_header(request_rec *r, char *menu)
-{
- r->content_type = "text/html";
- ap_send_http_header(r);
-
-
- ap_rvputs(r, DOCTYPE_HTML_3_2, "<html><head>\n<title>Menu for ", r->uri,
- "</title>\n</head><body>\n", NULL);
-
- if (!strcasecmp(menu, "formatted")) {
- ap_rvputs(r, "<h1>Menu for ", r->uri, "</h1>\n<hr>\n\n", NULL);
- }
-
- return;
-}
-
-static void menu_blank(request_rec *r, char *menu)
-{
- if (!strcasecmp(menu, "formatted")) {
- ap_rputs("\n", r);
- }
- if (!strcasecmp(menu, "semiformatted")) {
- ap_rputs("<br>\n", r);
- }
- if (!strcasecmp(menu, "unformatted")) {
- ap_rputs("\n", r);
- }
- return;
-}
-
-static void menu_comment(request_rec *r, char *menu, char *comment)
-{
- if (!strcasecmp(menu, "formatted")) {
- ap_rputs("\n", r); /* print just a newline if 'formatted' */
- }
- if (!strcasecmp(menu, "semiformatted") && *comment) {
- ap_rvputs(r, comment, "\n", NULL);
- }
- if (!strcasecmp(menu, "unformatted") && *comment) {
- ap_rvputs(r, comment, "\n", NULL);
- }
- return; /* comments are ignored in the
- 'formatted' form */
-}
-
-static void menu_default(request_rec *r, char *menu, char *href, char *text)
-{
- if (!strcasecmp(href, "error") || !strcasecmp(href, "nocontent")) {
- return; /* don't print such lines, these aren't
- really href's */
- }
- if (!strcasecmp(menu, "formatted")) {
- ap_rvputs(r, "<pre>(Default) <a href=\"", href, "\">", text,
- "</a></pre>\n", NULL);
- }
- if (!strcasecmp(menu, "semiformatted")) {
- ap_rvputs(r, "<pre>(Default) <a href=\"", href, "\">", text,
- "</a></pre>\n", NULL);
- }
- if (!strcasecmp(menu, "unformatted")) {
- ap_rvputs(r, "<a href=\"", href, "\">", text, "</a>", NULL);
- }
- return;
-}
-
-static void menu_directive(request_rec *r, char *menu, char *href, char *text)
-{
- if (!strcasecmp(href, "error") || !strcasecmp(href, "nocontent")) {
- return; /* don't print such lines, as this isn't
- really an href */
- }
- if (!strcasecmp(menu, "formatted")) {
- ap_rvputs(r, "<pre> <a href=\"", href, "\">", text,
- "</a></pre>\n", NULL);
- }
- if (!strcasecmp(menu, "semiformatted")) {
- ap_rvputs(r, "<pre> <a href=\"", href, "\">", text,
- "</a></pre>\n", NULL);
- }
- if (!strcasecmp(menu, "unformatted")) {
- ap_rvputs(r, "<a href=\"", href, "\">", text, "</a>", NULL);
- }
- return;
-}
-
-static void menu_footer(request_rec *r)
-{
- ap_rputs("\n\n</body>\n</html>\n", r); /* finish the menu */
-}
-
-static int imap_handler(request_rec *r)
-{
- char input[MAX_STRING_LEN];
- char *directive;
- char *value;
- char *href_text;
- char *base;
- char *redirect;
- char *mapdflt;
- char *closest = NULL;
- double closest_yet = -1;
- ap_status_t status;
-
- double testpoint[2];
- double pointarray[MAXVERTS + 1][2];
- int vertex;
-
- char *string_pos;
- int showmenu = 0;
-
- imap_conf_rec *icr = ap_get_module_config(r->per_dir_config, &imap_module);
-
- char *imap_menu = icr->imap_menu ? icr->imap_menu : IMAP_MENU_DEFAULT;
- char *imap_default = icr->imap_default
- ? icr->imap_default : IMAP_DEFAULT_DEFAULT;
- char *imap_base = icr->imap_base ? icr->imap_base : IMAP_BASE_DEFAULT;
-
- configfile_t *imap;
-
- if (r->method_number != M_GET) {
- return DECLINED;
- }
-
- status = ap_pcfg_openfile(&imap, r->pool, r->filename);
-
- if (status != APR_SUCCESS) {
- return NOT_FOUND;
- }
-
- base = imap_url(r, NULL, imap_base); /* set base according
- to default */
- if (!base) {
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- mapdflt = imap_url(r, NULL, imap_default); /* and default to
- global default */
- if (!mapdflt) {
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- testpoint[X] = get_x_coord(r->args);
- testpoint[Y] = get_y_coord(r->args);
-
- if ((testpoint[X] == -1 || testpoint[Y] == -1) ||
- (testpoint[X] == 0 && testpoint[Y] == 0)) {
- /* if either is -1 or if both are zero (new Lynx) */
- /* we don't have valid coordinates */
- testpoint[X] = -1;
- testpoint[Y] = -1;
- if (strncasecmp(imap_menu, "none", 2)) {
- showmenu = 1; /* show the menu _unless_ ImapMenu is
- 'none' or 'no' */
- }
- }
-
- if (showmenu) { /* send start of imagemap menu if
- we're going to */
- menu_header(r, imap_menu);
- }
-
- while (!ap_cfg_getline(input, sizeof(input), imap)) {
- if (!input[0]) {
- if (showmenu) {
- menu_blank(r, imap_menu);
- }
- continue;
- }
-
- if (input[0] == '#') {
- if (showmenu) {
- menu_comment(r, imap_menu, input + 1);
- }
- continue;
- } /* blank lines and comments are ignored
- if we aren't printing a menu */
-
- /* find the first two space delimited fields, recall that
- * ap_cfg_getline has removed leading/trailing whitespace.
- *
- * note that we're tokenizing as we go... if we were to use the
- * ap_getword() class of functions we would end up allocating extra
- * memory for every line of the map file
- */
- string_pos = input;
- if (!*string_pos) { /* need at least two fields */
- goto need_2_fields;
- }
-
- directive = string_pos;
- while (*string_pos && !ap_isspace(*string_pos)) { /* past directive */
- ++string_pos;
- }
- if (!*string_pos) { /* need at least two fields */
- goto need_2_fields;
- }
- *string_pos++ = '\0';
-
- if (!*string_pos) { /* need at least two fields */
- goto need_2_fields;
- }
- while(*string_pos && ap_isspace(*string_pos)) { /* past whitespace */
- ++string_pos;
- }
-
- value = string_pos;
- while (*string_pos && !ap_isspace(*string_pos)) { /* past value */
- ++string_pos;
- }
- if (ap_isspace(*string_pos)) {
- *string_pos++ = '\0';
- }
- else {
- /* end of input, don't advance past it */
- *string_pos = '\0';
- }
-
- if (!strncasecmp(directive, "base", 4)) { /* base, base_uri */
- base = imap_url(r, NULL, value);
- if (!base) {
- goto menu_bail;
- }
- continue; /* base is never printed to a menu */
- }
-
- read_quoted(&string_pos, &href_text);
-
- if (!strcasecmp(directive, "default")) { /* default */
- mapdflt = imap_url(r, NULL, value);
- if (!mapdflt) {
- goto menu_bail;
- }
- if (showmenu) { /* print the default if there's a menu */
- redirect = imap_url(r, base, mapdflt);
- if (!redirect) {
- goto menu_bail;
- }
- menu_default(r, imap_menu, redirect,
- href_text ? href_text : mapdflt);
- }
- continue;
- }
-
- vertex = 0;
- while (vertex < MAXVERTS &&
- sscanf(string_pos, "%lf%*[, ]%lf",
- &pointarray[vertex][X], &pointarray[vertex][Y]) == 2) {
- /* Now skip what we just read... we can't use ANSIism %n */
- while (ap_isspace(*string_pos)) { /* past whitespace */
- string_pos++;
- }
- while (ap_isdigit(*string_pos)) { /* and the 1st number */
- string_pos++;
- }
- string_pos++; /* skip the ',' */
- while (ap_isspace(*string_pos)) { /* past any more whitespace */
- string_pos++;
- }
- while (ap_isdigit(*string_pos)) { /* 2nd number */
- string_pos++;
- }
- vertex++;
- } /* so long as there are more vertices to
- read, and we have room, read them in.
- We start where we left off of the last
- sscanf, not at the beginning. */
-
- pointarray[vertex][X] = -1; /* signals the end of vertices */
-
- if (showmenu) {
- if (!href_text) {
- read_quoted(&string_pos, &href_text); /* href text could
- be here instead */
- }
- redirect = imap_url(r, base, value);
- if (!redirect) {
- goto menu_bail;
- }
- menu_directive(r, imap_menu, redirect,
- href_text ? href_text : value);
- continue;
- }
- /* note that we don't make it past here if we are making a menu */
-
- if (testpoint[X] == -1 || pointarray[0][X] == -1) {
- continue; /* don't try the following tests if testpoints
- are invalid, or if there are no
- coordinates */
- }
-
- if (!strcasecmp(directive, "poly")) { /* poly */
-
- if (pointinpoly(testpoint, pointarray)) {
- ap_cfg_closefile(imap);
- redirect = imap_url(r, base, value);
- if (!redirect) {
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- return (imap_reply(r, redirect));
- }
- continue;
- }
-
- if (!strcasecmp(directive, "circle")) { /* circle */
-
- if (pointincircle(testpoint, pointarray)) {
- ap_cfg_closefile(imap);
- redirect = imap_url(r, base, value);
- if (!redirect) {
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- return (imap_reply(r, redirect));
- }
- continue;
- }
-
- if (!strcasecmp(directive, "rect")) { /* rect */
-
- if (pointinrect(testpoint, pointarray)) {
- ap_cfg_closefile(imap);
- redirect = imap_url(r, base, value);
- if (!redirect) {
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- return (imap_reply(r, redirect));
- }
- continue;
- }
-
- if (!strcasecmp(directive, "point")) { /* point */
-
- if (is_closer(testpoint, pointarray, &closest_yet)) {
- closest = ap_pstrdup(r->pool, value);
- }
-
- continue;
- } /* move on to next line whether it's
- closest or not */
-
- } /* nothing matched, so we get another line! */
-
- ap_cfg_closefile(imap); /* we are done with the map file; close it */
-
- if (showmenu) {
- menu_footer(r); /* finish the menu and we are done */
- return OK;
- }
-
- if (closest) { /* if a 'point' directive has been seen */
- redirect = imap_url(r, base, closest);
- if (!redirect) {
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- return (imap_reply(r, redirect));
- }
-
- if (mapdflt) { /* a default should be defined, even if
- only 'nocontent' */
- redirect = imap_url(r, base, mapdflt);
- if (!redirect) {
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- return (imap_reply(r, redirect));
- }
-
- return HTTP_INTERNAL_SERVER_ERROR; /* If we make it this far,
- we failed. They lose! */
-
-need_2_fields:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "map file %s, line %d syntax error: requires at "
- "least two fields", r->uri, imap->line_number);
- /* fall through */
-menu_bail:
- ap_cfg_closefile(imap);
- if (showmenu) {
- /* There's not much else we can do ... we've already sent the headers
- * to the client.
- */
- ap_rputs("\n\n[an internal server error occured]\n", r);
- menu_footer(r);
- return OK;
- }
- return HTTP_INTERNAL_SERVER_ERROR;
-}
-
-
-static const handler_rec imap_handlers[] =
-{
- {IMAP_MAGIC_TYPE, imap_handler},
- {"imap-file", imap_handler},
- {NULL}
-};
-
-module MODULE_VAR_EXPORT imap_module =
-{
- STANDARD20_MODULE_STUFF,
- create_imap_dir_config, /* dir config creater */
- merge_imap_dir_configs, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- imap_cmds, /* command ap_table_t */
- imap_handlers, /* handlers */
- NULL /* register hooks */
-};
diff --git a/modules/mappers/mod_imap.exp b/modules/mappers/mod_imap.exp
deleted file mode 100644
index 1e0e0b83d0..0000000000
--- a/modules/mappers/mod_imap.exp
+++ /dev/null
@@ -1 +0,0 @@
-imap_module
diff --git a/modules/mappers/mod_negotiation.c b/modules/mappers/mod_negotiation.c
deleted file mode 100644
index d5301db7e9..0000000000
--- a/modules/mappers/mod_negotiation.c
+++ /dev/null
@@ -1,2754 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_negotiation.c: keeps track of MIME types the client is willing to
- * accept, and contains code to handle type arbitration.
- *
- * rst
- */
-
-#include "ap_config.h"
-#include "apr_file_io.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_protocol.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "util_script.h"
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#define MAP_FILE_MAGIC_TYPE "application/x-type-map"
-
-/* Commands --- configuring document caching on a per (virtual?)
- * server basis...
- */
-
-typedef struct {
- ap_array_header_t *language_priority;
-} neg_dir_config;
-
-module MODULE_VAR_EXPORT negotiation_module;
-
-static void *create_neg_dir_config(ap_context_t *p, char *dummy)
-{
- neg_dir_config *new = (neg_dir_config *) ap_palloc(p, sizeof(neg_dir_config));
-
- new->language_priority = ap_make_array(p, 4, sizeof(char *));
- return new;
-}
-
-static void *merge_neg_dir_configs(ap_context_t *p, void *basev, void *addv)
-{
- neg_dir_config *base = (neg_dir_config *) basev;
- neg_dir_config *add = (neg_dir_config *) addv;
- neg_dir_config *new = (neg_dir_config *) ap_palloc(p, sizeof(neg_dir_config));
-
- /* give priority to the config in the subdirectory */
- new->language_priority = ap_append_arrays(p, add->language_priority,
- base->language_priority);
- return new;
-}
-
-static const char *set_language_priority(cmd_parms *cmd, void *n, char *lang)
-{
- ap_array_header_t *arr = ((neg_dir_config *) n)->language_priority;
- char **langp = (char **) ap_push_array(arr);
-
- *langp = lang;
- return NULL;
-}
-
-static const char *cache_negotiated_docs(cmd_parms *cmd, void *dummy,
- char *dummy2)
-{
- void *server_conf = cmd->server->module_config;
-
- ap_set_module_config(server_conf, &negotiation_module, "Cache");
- return NULL;
-}
-
-static int do_cache_negotiated_docs(server_rec *s)
-{
- return (ap_get_module_config(s->module_config, &negotiation_module) != NULL);
-}
-
-static const command_rec negotiation_cmds[] =
-{
- {"CacheNegotiatedDocs", cache_negotiated_docs, NULL, RSRC_CONF, NO_ARGS,
- "no arguments (either present or absent)"},
- {"LanguagePriority", set_language_priority, NULL, OR_FILEINFO, ITERATE,
- "space-delimited list of MIME language abbreviations"},
- {NULL}
-};
-
-/*
- * Record of available info on a media type specified by the client
- * (we also use 'em for encodings and languages)
- */
-
-typedef struct accept_rec {
- char *name; /* MUST be lowercase */
- float quality;
- float level;
- char *charset; /* for content-type only */
-} accept_rec;
-
-/*
- * Record of available info on a particular variant
- *
- * Note that a few of these fields are updated by the actual negotiation
- * code. These are:
- *
- * level_matched --- initialized to zero. Set to the value of level
- * if the client actually accepts this media type at that
- * level (and *not* if it got in on a wildcard). See level_cmp
- * below.
- * mime_stars -- initialized to zero. Set to the number of stars
- * present in the best matching Accept header element.
- * 1 for star/star, 2 for type/star and 3 for
- * type/subtype.
- *
- * definite -- initialized to 1. Set to 0 if there is a match which
- * makes the variant non-definite according to the rules
- * in rfc2296.
- */
-
-typedef struct var_rec {
- request_rec *sub_req; /* May be NULL (is, for map files) */
- char *mime_type; /* MUST be lowercase */
- char *file_name;
- const char *content_encoding;
- ap_array_header_t *content_languages; /* list of languages for this variant */
- char *content_charset;
- char *description;
-
- /* The next five items give the quality values for the dimensions
- * of negotiation for this variant. They are obtained from the
- * appropriate header lines, except for source_quality, which
- * is obtained from the variant itself (the 'qs' parameter value
- * from the variant's mime-type). Apart from source_quality,
- * these values are set when we find the quality for each variant
- * (see best_match()). source_quality is set from the 'qs' parameter
- * of the variant description or mime type: see set_mime_fields().
- */
- float lang_quality; /* quality of this variant's language */
- float encoding_quality; /* ditto encoding */
- float charset_quality; /* ditto charset */
- float mime_type_quality; /* ditto media type */
- float source_quality; /* source quality for this variant */
-
- /* Now some special values */
- float level; /* Auxiliary to content-type... */
- float bytes; /* content length, if known */
- int lang_index; /* pre HTTP/1.1 language priority stuff */
- int is_pseudo_html; /* text/html, *or* the INCLUDES_MAGIC_TYPEs */
-
- /* Above are all written-once properties of the variant. The
- * three fields below are changed during negotiation:
- */
-
- float level_matched;
- int mime_stars;
- int definite;
-} var_rec;
-
-/* Something to carry around the state of negotiation (and to keep
- * all of this thread-safe)...
- */
-
-typedef struct {
- ap_context_t *pool;
- request_rec *r;
- char *dir_name;
- int accept_q; /* 1 if an Accept item has a q= param */
- float default_lang_quality; /* fiddle lang q for variants with no lang */
-
- /* the array pointers below are NULL if the corresponding accept
- * headers are not present
- */
- ap_array_header_t *accepts; /* accept_recs */
- ap_array_header_t *accept_encodings; /* accept_recs */
- ap_array_header_t *accept_charsets; /* accept_recs */
- ap_array_header_t *accept_langs; /* accept_recs */
-
- ap_array_header_t *avail_vars; /* available variants */
-
- int count_multiviews_variants; /* number of variants found on disk */
-
- int is_transparent; /* 1 if this resource is trans. negotiable */
-
- int dont_fiddle_headers; /* 1 if we may not fiddle with accept hdrs */
- int ua_supports_trans; /* 1 if ua supports trans negotiation */
- int send_alternates; /* 1 if we want to send an Alternates header */
- int may_choose; /* 1 if we may choose a variant for the client */
- int use_rvsa; /* 1 if we must use RVSA/1.0 negotiation algo */
-} negotiation_state;
-
-/* A few functions to manipulate var_recs.
- * Cleaning out the fields...
- */
-
-static void clean_var_rec(var_rec *mime_info)
-{
- mime_info->sub_req = NULL;
- mime_info->mime_type = "";
- mime_info->file_name = "";
- mime_info->content_encoding = NULL;
- mime_info->content_languages = NULL;
- mime_info->content_charset = "";
- mime_info->description = "";
-
- mime_info->is_pseudo_html = 0;
- mime_info->level = 0.0f;
- mime_info->level_matched = 0.0f;
- mime_info->bytes = 0.0f;
- mime_info->lang_index = -1;
- mime_info->mime_stars = 0;
- mime_info->definite = 1;
-
- mime_info->charset_quality = 1.0f;
- mime_info->encoding_quality = 1.0f;
- mime_info->lang_quality = 1.0f;
- mime_info->mime_type_quality = 1.0f;
- mime_info->source_quality = 0.0f;
-}
-
-/* Initializing the relevant fields of a variant record from the
- * accept_info read out of its content-type, one way or another.
- */
-
-static void set_mime_fields(var_rec *var, accept_rec *mime_info)
-{
- var->mime_type = mime_info->name;
- var->source_quality = mime_info->quality;
- var->level = mime_info->level;
- var->content_charset = mime_info->charset;
-
- var->is_pseudo_html = (!strcmp(var->mime_type, "text/html")
- || !strcmp(var->mime_type, INCLUDES_MAGIC_TYPE)
- || !strcmp(var->mime_type, INCLUDES_MAGIC_TYPE3));
-}
-
-/* Create a variant list validator in r using info from vlistr. */
-
-static void set_vlist_validator(request_rec *r, request_rec *vlistr)
-{
- /* Calculating the variant list validator is similar to
- * calculating an etag for the source of the variant list
- * information, so we use ap_make_etag(). Note that this
- * validator can be 'weak' in extreme case.
- */
- ap_update_mtime(vlistr, vlistr->finfo.mtime);
- r->vlist_validator = ap_make_etag(vlistr, 0);
-
- /* ap_set_etag will later take r->vlist_validator into account
- * when creating the etag header
- */
-}
-
-
-/*****************************************************************
- *
- * Parsing (lists of) media types and their parameters, as seen in
- * HTTPD header lines and elsewhere.
- */
-
-/*
- * Get a single mime type entry --- one media type and parameters;
- * enter the values we recognize into the argument accept_rec
- */
-
-static const char *get_entry(ap_context_t *p, accept_rec *result,
- const char *accept_line)
-{
- result->quality = 1.0f;
- result->level = 0.0f;
- result->charset = "";
-
- /*
- * Note that this handles what I gather is the "old format",
- *
- * Accept: text/html text/plain moo/zot
- *
- * without any compatibility kludges --- if the token after the
- * MIME type begins with a semicolon, we know we're looking at parms,
- * otherwise, we know we aren't. (So why all the pissing and moaning
- * in the CERN server code? I must be missing something).
- */
-
- result->name = ap_get_token(p, &accept_line, 0);
- ap_str_tolower(result->name); /* You want case insensitive,
- * you'll *get* case insensitive.
- */
-
- /* KLUDGE!!! Default HTML to level 2.0 unless the browser
- * *explicitly* says something else.
- */
-
- if (!strcmp(result->name, "text/html") && (result->level == 0.0)) {
- result->level = 2.0f;
- }
- else if (!strcmp(result->name, INCLUDES_MAGIC_TYPE)) {
- result->level = 2.0f;
- }
- else if (!strcmp(result->name, INCLUDES_MAGIC_TYPE3)) {
- result->level = 3.0f;
- }
-
- while (*accept_line == ';') {
- /* Parameters ... */
-
- char *parm;
- char *cp;
- char *end;
-
- ++accept_line;
- parm = ap_get_token(p, &accept_line, 1);
-
- /* Look for 'var = value' --- and make sure the var is in lcase. */
-
- for (cp = parm; (*cp && !ap_isspace(*cp) && *cp != '='); ++cp) {
- *cp = ap_tolower(*cp);
- }
-
- if (!*cp) {
- continue; /* No '='; just ignore it. */
- }
-
- *cp++ = '\0'; /* Delimit var */
- while (*cp && (ap_isspace(*cp) || *cp == '=')) {
- ++cp;
- }
-
- if (*cp == '"') {
- ++cp;
- for (end = cp;
- (*end && *end != '\n' && *end != '\r' && *end != '\"');
- end++);
- }
- else {
- for (end = cp; (*end && !ap_isspace(*end)); end++);
- }
- if (*end) {
- *end = '\0'; /* strip ending quote or return */
- }
- ap_str_tolower(cp);
-
- if (parm[0] == 'q'
- && (parm[1] == '\0' || (parm[1] == 's' && parm[2] == '\0'))) {
- result->quality = atof(cp);
- }
- else if (parm[0] == 'l' && !strcmp(&parm[1], "evel")) {
- result->level = atof(cp);
- }
- else if (!strcmp(parm, "charset")) {
- result->charset = cp;
- }
- }
-
- if (*accept_line == ',') {
- ++accept_line;
- }
-
- return accept_line;
-}
-
-/*****************************************************************
- *
- * Dealing with header lines ...
- *
- * Accept, Accept-Charset, Accept-Language and Accept-Encoding
- * are handled by do_header_line() - they all have the same
- * basic structure of a list of items of the format
- * name; q=N; charset=TEXT
- *
- * where charset is only valid in Accept.
- */
-
-static ap_array_header_t *do_header_line(ap_context_t *p, const char *accept_line)
-{
- ap_array_header_t *accept_recs;
-
- if (!accept_line) {
- return NULL;
- }
-
- accept_recs = ap_make_array(p, 40, sizeof(accept_rec));
-
- while (*accept_line) {
- accept_rec *new = (accept_rec *) ap_push_array(accept_recs);
- accept_line = get_entry(p, new, accept_line);
- }
-
- return accept_recs;
-}
-
-/* Given the text of the Content-Languages: line from the var map file,
- * return an array containing the languages of this variant
- */
-
-static ap_array_header_t *do_languages_line(ap_context_t *p, const char **lang_line)
-{
- ap_array_header_t *lang_recs = ap_make_array(p, 2, sizeof(char *));
-
- if (!lang_line) {
- return lang_recs;
- }
-
- while (**lang_line) {
- char **new = (char **) ap_push_array(lang_recs);
- *new = ap_get_token(p, lang_line, 0);
- ap_str_tolower(*new);
- if (**lang_line == ',' || **lang_line == ';') {
- ++(*lang_line);
- }
- }
-
- return lang_recs;
-}
-
-/*****************************************************************
- *
- * Handling header lines from clients...
- */
-
-static negotiation_state *parse_accept_headers(request_rec *r)
-{
- negotiation_state *new =
- (negotiation_state *) ap_pcalloc(r->pool, sizeof(negotiation_state));
- accept_rec *elts;
- ap_table_t *hdrs = r->headers_in;
- int i;
-
- new->pool = r->pool;
- new->r = r;
- new->dir_name = ap_make_dirstr_parent(r->pool, r->filename);
-
- new->accepts = do_header_line(r->pool, ap_table_get(hdrs, "Accept"));
-
- /* calculate new->accept_q value */
- if (new->accepts) {
- elts = (accept_rec *) new->accepts->elts;
-
- for (i = 0; i < new->accepts->nelts; ++i) {
- if (elts[i].quality < 1.0) {
- new->accept_q = 1;
- }
- }
- }
-
- new->accept_encodings =
- do_header_line(r->pool, ap_table_get(hdrs, "Accept-Encoding"));
- new->accept_langs =
- do_header_line(r->pool, ap_table_get(hdrs, "Accept-Language"));
- new->accept_charsets =
- do_header_line(r->pool, ap_table_get(hdrs, "Accept-Charset"));
-
- new->avail_vars = ap_make_array(r->pool, 40, sizeof(var_rec));
-
- return new;
-}
-
-
-static void parse_negotiate_header(request_rec *r, negotiation_state *neg)
-{
- const char *negotiate = ap_table_get(r->headers_in, "Negotiate");
- char *tok;
-
- /* First, default to no TCN, no Alternates, and the original Apache
- * negotiation algorithm with fiddles for broken browser configs.
- *
- * To save network bandwidth, we do not configure to send an
- * Alternates header to the user agent by default. User
- * agents that want an Alternates header for agent-driven
- * negotiation will have to request it by sending an
- * appropriate Negotiate header.
- */
- neg->ua_supports_trans = 0;
- neg->send_alternates = 0;
- neg->may_choose = 1;
- neg->use_rvsa = 0;
- neg->dont_fiddle_headers = 0;
-
- if (!negotiate)
- return;
-
- if (strcmp(negotiate, "trans") == 0) {
- /* Lynx 2.7 and 2.8 send 'negotiate: trans' even though they
- * do not support transparent content negotiation, so for Lynx we
- * ignore the negotiate header when its contents are exactly "trans".
- * If future versions of Lynx ever need to say 'negotiate: trans',
- * they can send the equivalent 'negotiate: trans, trans' instead
- * to avoid triggering the workaround below.
- */
- const char *ua = ap_table_get(r->headers_in, "User-Agent");
-
- if (ua && (strncmp(ua, "Lynx", 4) == 0))
- return;
- }
-
- neg->may_choose = 0; /* An empty Negotiate would require 300 response */
-
- while ((tok = ap_get_list_item(neg->pool, &negotiate)) != NULL) {
-
- if (strcmp(tok, "trans") == 0 ||
- strcmp(tok, "vlist") == 0 ||
- strcmp(tok, "guess-small") == 0 ||
- ap_isdigit(tok[0]) ||
- strcmp(tok, "*") == 0) {
-
- /* The user agent supports transparent negotiation */
- neg->ua_supports_trans = 1;
-
- /* Send-alternates could be configurable, but note
- * that it must be 1 if we have 'vlist' in the
- * negotiate header.
- */
- neg->send_alternates = 1;
-
- if (strcmp(tok, "1.0") == 0) {
- /* we may use the RVSA/1.0 algorithm, configure for it */
- neg->may_choose = 1;
- neg->use_rvsa = 1;
- neg->dont_fiddle_headers = 1;
- }
- else if (tok[0] == '*') {
- /* we may use any variant selection algorithm, configure
- * to use the Apache algorithm
- */
- neg->may_choose = 1;
-
- /* We disable header fiddles on the assumption that a
- * client sending Negotiate knows how to send correct
- * headers which don't need fiddling.
- */
- neg->dont_fiddle_headers = 1;
- }
- }
- }
-
-#ifdef NEG_DEBUG
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "dont_fiddle_headers=%d use_rvsa=%d ua_supports_trans=%d "
- "send_alternates=%d, may_choose=%d",
- neg->dont_fiddle_headers, neg->use_rvsa,
- neg->ua_supports_trans, neg->send_alternates, neg->may_choose);
-#endif
-
-}
-
-/* Sometimes clients will give us no Accept info at all; this routine sets
- * up the standard default for that case, and also arranges for us to be
- * willing to run a CGI script if we find one. (In fact, we set up to
- * dramatically prefer CGI scripts in cases where that's appropriate,
- * e.g., POST or when URI includes query args or extra path info).
- */
-static void maybe_add_default_accepts(negotiation_state *neg,
- int prefer_scripts)
-{
- accept_rec *new_accept;
-
- if (!neg->accepts) {
- neg->accepts = ap_make_array(neg->pool, 4, sizeof(accept_rec));
-
- new_accept = (accept_rec *) ap_push_array(neg->accepts);
-
- new_accept->name = "*/*";
- new_accept->quality = 1.0f;
- new_accept->level = 0.0f;
- }
-
- new_accept = (accept_rec *) ap_push_array(neg->accepts);
-
- new_accept->name = CGI_MAGIC_TYPE;
- if (neg->use_rvsa) {
- new_accept->quality = 0;
- }
- else {
- new_accept->quality = prefer_scripts ? 2.0f : 0.001f;
- }
- new_accept->level = 0.0f;
-}
-
-/*****************************************************************
- *
- * Parsing type-map files, in Roy's meta/http format augmented with
- * #-comments.
- */
-
-/* Reading RFC822-style header lines, ignoring #-comments and
- * handling continuations.
- */
-
-enum header_state {
- header_eof, header_seen, header_sep
-};
-
-static enum header_state get_header_line(char *buffer, int len, ap_file_t *map)
-{
- char *buf_end = buffer + len;
- char *cp;
- char c;
-
- /* Get a noncommented line */
-
- do {
- if (ap_fgets(buffer, MAX_STRING_LEN, map) != APR_SUCCESS) {
- return header_eof;
- }
- } while (buffer[0] == '#');
-
- /* If blank, just return it --- this ends information on this variant */
-
- for (cp = buffer; (*cp && ap_isspace(*cp)); ++cp) {
- continue;
- }
-
- if (*cp == '\0') {
- return header_sep;
- }
-
- /* If non-blank, go looking for header lines, but note that we still
- * have to treat comments specially...
- */
-
- cp += strlen(cp);
-
- while (ap_getc(&c, map) != APR_EOF) {
- if (c == '#') {
- /* Comment line */
- while (ap_getc(&c, map) != EOF && c != '\n') {
- continue;
- }
- }
- else if (ap_isspace(c)) {
- /* Leading whitespace. POSSIBLE continuation line
- * Also, possibly blank --- if so, we ungetc() the final newline
- * so that we will pick up the blank line the next time 'round.
- */
-
- while (c != '\n' && ap_isspace(c)) {
- if(ap_getc(&c, map) != APR_SUCCESS)
- break;
- }
-
- ap_ungetc(c, map);
-
- if (c == '\n') {
- return header_seen; /* Blank line */
- }
-
- /* Continuation */
-
- while (cp < buf_end - 2 && (ap_getc(&c, map)) != EOF && c != '\n') {
- *cp++ = c;
- }
-
- *cp++ = '\n';
- *cp = '\0';
- }
- else {
-
- /* Line beginning with something other than whitespace */
-
- ap_ungetc(c, map);
- return header_seen;
- }
- }
-
- return header_seen;
-}
-
-/* Stripping out RFC822 comments */
-
-static void strip_paren_comments(char *hdr)
-{
- /* Hmmm... is this correct? In Roy's latest draft, (comments) can nest! */
- /* Nope, it isn't correct. Fails to handle backslash escape as well. */
-
- while (*hdr) {
- if (*hdr == '"') {
- hdr = strchr(hdr, '"');
- if (hdr == NULL) {
- return;
- }
- ++hdr;
- }
- else if (*hdr == '(') {
- while (*hdr && *hdr != ')') {
- *hdr++ = ' ';
- }
-
- if (*hdr) {
- *hdr++ = ' ';
- }
- }
- else {
- ++hdr;
- }
- }
-}
-
-/* Getting to a header body from the header */
-
-static char *lcase_header_name_return_body(char *header, request_rec *r)
-{
- char *cp = header;
-
- for ( ; *cp && *cp != ':' ; ++cp) {
- *cp = ap_tolower(*cp);
- }
-
- if (!*cp) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Syntax error in type map --- no ':': %s", r->filename);
- return NULL;
- }
-
- do {
- ++cp;
- } while (*cp && ap_isspace(*cp));
-
- if (!*cp) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Syntax error in type map --- no header body: %s",
- r->filename);
- return NULL;
- }
-
- return cp;
-}
-
-static int read_type_map(negotiation_state *neg, request_rec *rr)
-{
- request_rec *r = neg->r;
- ap_file_t *map = NULL;
- ap_status_t status;
- char buffer[MAX_STRING_LEN];
- enum header_state hstate;
- struct var_rec mime_info;
- int has_content;
-
- /* We are not using multiviews */
- neg->count_multiviews_variants = 0;
-
- if ((status = ap_open(&map, rr->filename, APR_READ | APR_BUFFERED,
- APR_OS_DEFAULT, neg->pool)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
- "cannot access type map file: %s", rr->filename);
- return HTTP_FORBIDDEN;
- }
-
- clean_var_rec(&mime_info);
- has_content = 0;
-
- do {
- hstate = get_header_line(buffer, MAX_STRING_LEN, map);
-
- if (hstate == header_seen) {
- char *body1 = lcase_header_name_return_body(buffer, neg->r);
- const char *body;
-
- if (body1 == NULL) {
- return SERVER_ERROR;
- }
-
- strip_paren_comments(body1);
- body = body1;
-
- if (!strncmp(buffer, "uri:", 4)) {
- mime_info.file_name = ap_get_token(neg->pool, &body, 0);
- }
- else if (!strncmp(buffer, "content-type:", 13)) {
- struct accept_rec accept_info;
-
- get_entry(neg->pool, &accept_info, body);
- set_mime_fields(&mime_info, &accept_info);
- has_content = 1;
- }
- else if (!strncmp(buffer, "content-length:", 15)) {
- mime_info.bytes = atof(body);
- has_content = 1;
- }
- else if (!strncmp(buffer, "content-language:", 17)) {
- mime_info.content_languages = do_languages_line(neg->pool,
- &body);
- has_content = 1;
- }
- else if (!strncmp(buffer, "content-encoding:", 17)) {
- mime_info.content_encoding = ap_get_token(neg->pool, &body, 0);
- has_content = 1;
- }
- else if (!strncmp(buffer, "description:", 12)) {
- char *desc = ap_pstrdup(neg->pool, body);
- char *cp;
-
- for (cp = desc; *cp; ++cp) {
- if (*cp=='\n') *cp=' ';
- }
- if (cp>desc) *(cp-1)=0;
- mime_info.description = desc;
- }
- }
- else {
- if (*mime_info.file_name && has_content) {
- void *new_var = ap_push_array(neg->avail_vars);
-
- memcpy(new_var, (void *) &mime_info, sizeof(var_rec));
- }
-
- clean_var_rec(&mime_info);
- has_content = 0;
- }
- } while (hstate != header_eof);
-
- ap_close(map);
-
- set_vlist_validator(r, rr);
-
- return OK;
-}
-
-
-/* Sort function used by read_types_multi. */
-static int variantsortf(var_rec *a, var_rec *b) {
-
- /* First key is the source quality, sort in descending order. */
-
- /* XXX: note that we currently implement no method of setting the
- * source quality for multiviews variants, so we are always comparing
- * 1.0 to 1.0 for now
- */
- if (a->source_quality < b->source_quality)
- return 1;
- if (a->source_quality > b->source_quality)
- return -1;
-
- /* Second key is the variant name */
- return strcmp(a->file_name, b->file_name);
-}
-
-/*****************************************************************
- *
- * Same as read_type_map, except we use a filtered directory listing
- * as the map...
- */
-
-static int read_types_multi(negotiation_state *neg)
-{
- request_rec *r = neg->r;
-
- char *filp;
- int prefix_len;
- ap_dir_t *dirp;
- ap_status_t status;
- struct var_rec mime_info;
- struct accept_rec accept_info;
- void *new_var;
-
- clean_var_rec(&mime_info);
-
- if (!(filp = strrchr(r->filename, '/'))) {
- return DECLINED; /* Weird... */
- }
-
- if (strncmp(r->filename, "proxy:", 6) == 0) {
- return DECLINED;
- }
-
- ++filp;
- prefix_len = strlen(filp);
-
- if ((status = ap_opendir(&dirp, neg->dir_name, neg->pool)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
- "cannot read directory for multi: %s", neg->dir_name);
- return HTTP_FORBIDDEN;
- }
-
- while (ap_readdir(dirp) == APR_SUCCESS) {
- request_rec *sub_req;
- char *d_name;
-
- ap_get_dir_filename(&d_name, dirp);
- /* Do we have a match? */
-
- if (strncmp(d_name, filp, prefix_len)) {
- continue;
- }
- if (d_name[prefix_len] != '.') {
- continue;
- }
-
- /* Yep. See if it's something which we have access to, and
- * which has a known type and encoding (as opposed to something
- * which we'll be slapping default_type on later).
- */
-
- sub_req = ap_sub_req_lookup_file(d_name, r);
-
- /* If it has a handler, we'll pretend it's a CGI script,
- * since that's a good indication of the sort of thing it
- * might be doing.
- */
- if (sub_req->handler && !sub_req->content_type) {
- sub_req->content_type = CGI_MAGIC_TYPE;
- }
-
- if (sub_req->status != HTTP_OK || !sub_req->content_type) {
- ap_destroy_sub_req(sub_req);
- continue;
- }
-
- /* If it's a map file, we use that instead of the map
- * we're building...
- */
-
- if (((sub_req->content_type) &&
- !strcmp(sub_req->content_type, MAP_FILE_MAGIC_TYPE)) ||
- ((sub_req->handler) &&
- !strcmp(sub_req->handler, "type-map"))) {
-
- ap_closedir(dirp);
- neg->avail_vars->nelts = 0;
- if (sub_req->status != HTTP_OK) {
- return sub_req->status;
- }
- return read_type_map(neg, sub_req);
- }
-
- /* Have reasonable variant --- gather notes. */
-
- mime_info.sub_req = sub_req;
- mime_info.file_name = ap_pstrdup(neg->pool, d_name);
- if (sub_req->content_encoding) {
- mime_info.content_encoding = sub_req->content_encoding;
- }
- if (sub_req->content_languages) {
- mime_info.content_languages = sub_req->content_languages;
- }
-
- get_entry(neg->pool, &accept_info, sub_req->content_type);
- set_mime_fields(&mime_info, &accept_info);
-
- new_var = ap_push_array(neg->avail_vars);
- memcpy(new_var, (void *) &mime_info, sizeof(var_rec));
-
- neg->count_multiviews_variants++;
-
- clean_var_rec(&mime_info);
- }
-
- ap_closedir(dirp);
-
- set_vlist_validator(r, r);
-
- /* Sort the variants into a canonical order. The negotiation
- * result sometimes depends on the order of the variants. By
- * sorting the variants into a canonical order, rather than using
- * the order in which readdir() happens to return them, we ensure
- * that the negotiation result will be consistent over filesystem
- * backup/restores and over all mirror sites.
- */
-
- qsort((void *) neg->avail_vars->elts, neg->avail_vars->nelts,
- sizeof(var_rec), (int (*)(const void *, const void *)) variantsortf);
-
- return OK;
-}
-
-
-/*****************************************************************
- * And now for the code you've been waiting for... actually
- * finding a match to the client's requirements.
- */
-
-/* Matching MIME types ... the star/star and foo/star commenting conventions
- * are implemented here. (You know what I mean by star/star, but just
- * try mentioning those three characters in a C comment). Using strcmp()
- * is legit, because everything has already been smashed to lowercase.
- *
- * Note also that if we get an exact match on the media type, we update
- * level_matched for use in level_cmp below...
- *
- * We also give a value for mime_stars, which is used later. It should
- * be 1 for star/star, 2 for type/star and 3 for type/subtype.
- */
-
-static int mime_match(accept_rec *accept_r, var_rec *avail)
-{
- char *accept_type = accept_r->name;
- char *avail_type = avail->mime_type;
- int len = strlen(accept_type);
-
- if (accept_type[0] == '*') { /* Anything matches star/star */
- if (avail->mime_stars < 1) {
- avail->mime_stars = 1;
- }
- return 1;
- }
- else if ((accept_type[len - 1] == '*') &&
- !strncmp(accept_type, avail_type, len - 2)) {
- if (avail->mime_stars < 2) {
- avail->mime_stars = 2;
- }
- return 1;
- }
- else if (!strcmp(accept_type, avail_type)
- || (!strcmp(accept_type, "text/html")
- && (!strcmp(avail_type, INCLUDES_MAGIC_TYPE)
- || !strcmp(avail_type, INCLUDES_MAGIC_TYPE3)))) {
- if (accept_r->level >= avail->level) {
- avail->level_matched = avail->level;
- avail->mime_stars = 3;
- return 1;
- }
- }
-
- return OK;
-}
-
-/* This code implements a piece of the tie-breaking algorithm between
- * variants of equal quality. This piece is the treatment of variants
- * of the same base media type, but different levels. What we want to
- * return is the variant at the highest level that the client explicitly
- * claimed to accept.
- *
- * If all the variants available are at a higher level than that, or if
- * the client didn't say anything specific about this media type at all
- * and these variants just got in on a wildcard, we prefer the lowest
- * level, on grounds that that's the one that the client is least likely
- * to choke on.
- *
- * (This is all motivated by treatment of levels in HTML --- we only
- * want to give level 3 to browsers that explicitly ask for it; browsers
- * that don't, including HTTP/0.9 browsers that only get the implicit
- * "Accept: * / *" [space added to avoid confusing cpp --- no, that
- * syntax doesn't really work] should get HTML2 if available).
- *
- * (Note that this code only comes into play when we are choosing among
- * variants of equal quality, where the draft standard gives us a fair
- * bit of leeway about what to do. It ain't specified by the standard;
- * rather, it is a choice made by this server about what to do in cases
- * where the standard does not specify a unique course of action).
- */
-
-static int level_cmp(var_rec *var1, var_rec *var2)
-{
- /* Levels are only comparable between matching media types */
-
- if (var1->is_pseudo_html && !var2->is_pseudo_html) {
- return 0;
- }
-
- if (!var1->is_pseudo_html && strcmp(var1->mime_type, var2->mime_type)) {
- return 0;
- }
- /* The result of the above if statements is that, if we get to
- * here, both variants have the same mime_type or both are
- * pseudo-html.
- */
-
- /* Take highest level that matched, if either did match. */
-
- if (var1->level_matched > var2->level_matched) {
- return 1;
- }
- if (var1->level_matched < var2->level_matched) {
- return -1;
- }
-
- /* Neither matched. Take lowest level, if there's a difference. */
-
- if (var1->level < var2->level) {
- return 1;
- }
- if (var1->level > var2->level) {
- return -1;
- }
-
- /* Tied */
-
- return 0;
-}
-
-/* Finding languages. The main entry point is set_language_quality()
- * which is called for each variant. It sets two elements in the
- * variant record:
- * language_quality - the 'q' value of the 'best' matching language
- * from Accept-Language: header (HTTP/1.1)
- * lang_index - Pre HTTP/1.1 language priority, using
- * position of language on the Accept-Language:
- * header, if present, else LanguagePriority
- * directive order.
- *
- * When we do the variant checking for best variant, we use language
- * quality first, and if a tie, language_index next (this only applies
- * when _not_ using the RVSA/1.0 algorithm). If using the RVSA/1.0
- * algorithm, lang_index is never used.
- *
- * set_language_quality() calls find_lang_index() and find_default_index()
- * to set lang_index.
- */
-
-static int find_lang_index(ap_array_header_t *accept_langs, char *lang)
-{
- accept_rec *accs;
- int i;
-
- if (!lang || !accept_langs) {
- return -1;
- }
-
- accs = (accept_rec *) accept_langs->elts;
-
- for (i = 0; i < accept_langs->nelts; ++i) {
- if (!strncmp(lang, accs[i].name, strlen(accs[i].name))) {
- return i;
- }
- }
-
- return -1;
-}
-
-/* This function returns the priority of a given language
- * according to LanguagePriority. It is used in case of a tie
- * between several languages.
- */
-
-static int find_default_index(neg_dir_config *conf, char *lang)
-{
- ap_array_header_t *arr;
- int nelts;
- char **elts;
- int i;
-
- if (!lang) {
- return -1;
- }
-
- arr = conf->language_priority;
- nelts = arr->nelts;
- elts = (char **) arr->elts;
-
- for (i = 0; i < nelts; ++i) {
- if (!strcasecmp(elts[i], lang)) {
- return i;
- }
- }
-
- return -1;
-}
-
-/* set_default_lang_quality() sets the quality we apply to variants
- * which have no language assigned to them. If none of the variants
- * have a language, we are not negotiating on language, so all are
- * acceptable, and we set the default q value to 1.0. However if
- * some of the variants have languages, we set this default to 0.001.
- * The value of this default will be applied to all variants with
- * no explicit language -- which will have the effect of making them
- * acceptable, but only if no variants with an explicit language
- * are acceptable. The default q value set here is assigned to variants
- * with no language type in set_language_quality().
- *
- * Note that if using the RVSA/1.0 algorithm, we don't use this
- * fiddle.
- */
-
-static void set_default_lang_quality(negotiation_state *neg)
-{
- var_rec *avail_recs = (var_rec *) neg->avail_vars->elts;
- int j;
-
- if (!neg->dont_fiddle_headers) {
- for (j = 0; j < neg->avail_vars->nelts; ++j) {
- var_rec *variant = &avail_recs[j];
- if (variant->content_languages &&
- variant->content_languages->nelts) {
- neg->default_lang_quality = 0.001f;
- return;
- }
- }
- }
-
- neg->default_lang_quality = 1.0f;
-}
-
-/* Set the language_quality value in the variant record. Also
- * assigns lang_index for back-compat.
- *
- * To find the language_quality value, we look for the 'q' value
- * of the 'best' matching language on the Accept-Language
- * header. The 'best' match is the language on Accept-Language
- * header which matches the language of this variant either fully,
- * or as far as the prefix marker (-). If two or more languages
- * match, use the longest string from the Accept-Language header
- * (see HTTP/1.1 [14.4])
- *
- * When a variant has multiple languages, we find the 'best'
- * match for each variant language tag as above, then select the
- * one with the highest q value. Because both the accept-header
- * and variant can have multiple languages, we now have a hairy
- * loop-within-a-loop here.
- *
- * If the variant has no language and we have no Accept-Language
- * items, leave the quality at 1.0 and return.
- *
- * If the variant has no language, we use the default as set by
- * set_default_lang_quality() (1.0 if we are not negotiating on
- * language, 0.001 if we are).
- *
- * Following the setting of the language quality, we drop through to
- * set the old 'lang_index'. This is set based on either the order
- * of the languages on the Accept-Language header, or the
- * order on the LanguagePriority directive. This is only used
- * in the negotiation if the language qualities tie.
- */
-
-static void set_language_quality(negotiation_state *neg, var_rec *variant)
-{
- char *firstlang;
- int idx;
-
- if (!variant->content_languages || !variant->content_languages->nelts) {
- /* This variant has no content-language, so use the default
- * quality factor for variants with no content-language
- * (previously set by set_default_lang_quality()).
- * Leave the factor alone (it remains at 1.0) when we may not fiddle
- * with the headers.
- */
- if (!neg->dont_fiddle_headers) {
- variant->lang_quality = neg->default_lang_quality;
- }
- if (!neg->accept_langs) {
- return; /* no accept-language header */
- }
-
- }
- else {
- /* Variant has one (or more) languages. Look for the best
- * match. We do this by going through each language on the
- * variant description looking for a match on the
- * Accept-Language header. The best match is the longest
- * matching language on the header. The final result is the
- * best q value from all the languages on the variant
- * description.
- */
-
- if (!neg->accept_langs) {
- /* no accept-language header makes the variant indefinite */
- variant->definite = 0;
- }
- else { /* There is an accept-language with 0 or more items */
- accept_rec *accs = (accept_rec *) neg->accept_langs->elts;
- accept_rec *best = NULL, *star = NULL;
- accept_rec *bestthistag;
- char *lang, *p;
- float fiddle_q = 0.0f;
- int any_match_on_star = 0;
- int i, j, alen, longest_lang_range_len;
-
- for (j = 0; j < variant->content_languages->nelts; ++j) {
- p = NULL;
- bestthistag = NULL;
- longest_lang_range_len = 0;
- alen = 0;
-
- /* lang is the variant's language-tag, which is the one
- * we are allowed to use the prefix of in HTTP/1.1
- */
- lang = ((char **) (variant->content_languages->elts))[j];
-
- /* now find the best (i.e. longest) matching
- * Accept-Language header language. We put the best match
- * for this tag in bestthistag. We cannot update the
- * overall best (based on q value) because the best match
- * for this tag is the longest language item on the accept
- * header, not necessarily the highest q.
- */
- for (i = 0; i < neg->accept_langs->nelts; ++i) {
- if (!strcmp(accs[i].name, "*")) {
- if (!star) {
- star = &accs[i];
- }
- continue;
- }
- /* Find language. We match if either the variant
- * language tag exactly matches the language range
- * from the accept header, or a prefix of the variant
- * language tag up to a '-' character matches the
- * whole of the language range in the Accept-Language
- * header. Note that HTTP/1.x allows any number of
- * '-' characters in a tag or range, currently only
- * tags with zero or one '-' characters are defined
- * for general use (see rfc1766).
- *
- * We only use language range in the Accept-Language
- * header the best match for the variant language tag
- * if it is longer than the previous best match.
- */
-
- alen = strlen(accs[i].name);
-
- if ((strlen(lang) >= alen) &&
- !strncmp(lang, accs[i].name, alen) &&
- ((lang[alen] == 0) || (lang[alen] == '-')) ) {
-
- if (alen > longest_lang_range_len) {
- longest_lang_range_len = alen;
- bestthistag = &accs[i];
- }
- }
-
- if (!bestthistag && !neg->dont_fiddle_headers) {
- /* The next bit is a fiddle. Some browsers might
- * be configured to send more specific language
- * ranges than desirable. For example, an
- * Accept-Language of en-US should never match
- * variants with languages en or en-GB. But US
- * English speakers might pick en-US as their
- * language choice. So this fiddle checks if the
- * language range has a prefix, and if so, it
- * matches variants which match that prefix with a
- * priority of 0.001. So a request for en-US would
- * match variants of types en and en-GB, but at
- * much lower priority than matches of en-US
- * directly, or of any other language listed on
- * the Accept-Language header. Note that this
- * fiddle does not handle multi-level prefixes.
- */
- if ((p = strchr(accs[i].name, '-'))) {
- int plen = p - accs[i].name;
-
- if (!strncmp(lang, accs[i].name, plen)) {
- fiddle_q = 0.001f;
- }
- }
- }
- }
- /* Finished looking at Accept-Language headers, the best
- * (longest) match is in bestthistag, or NULL if no match
- */
- if (!best ||
- (bestthistag && bestthistag->quality > best->quality)) {
- best = bestthistag;
- }
-
- /* See if the tag matches on a * in the Accept-Language
- * header. If so, record this fact for later use
- */
- if (!bestthistag && star) {
- any_match_on_star = 1;
- }
- }
-
- /* If one of the language tags of the variant matched on *, we
- * need to see if its q is better than that of any non-* match
- * on any other tag of the variant. If so the * match takes
- * precedence and the overall match is not definite.
- */
- if ( any_match_on_star &&
- ((best && star->quality > best->quality) ||
- (!best)) ) {
- best = star;
- variant->definite = 0;
- }
-
- variant->lang_quality = best ? best->quality : fiddle_q;
- }
- }
-
- /* Now set the old lang_index field. Since this is old
- * stuff anyway, don't bother with handling multiple languages
- * per variant, just use the first one assigned to it
- */
- idx = 0;
- if (variant->content_languages && variant->content_languages->nelts) {
- firstlang = ((char **) variant->content_languages->elts)[0];
- }
- else {
- firstlang = "";
- }
- if (!neg->accept_langs) { /* Client doesn't care */
- idx = find_default_index((neg_dir_config *) ap_get_module_config(
- neg->r->per_dir_config, &negotiation_module),
- firstlang);
- }
- else { /* Client has Accept-Language */
- idx = find_lang_index(neg->accept_langs, firstlang);
- }
- variant->lang_index = idx;
-
- return;
-}
-
-/* Determining the content length --- if the map didn't tell us,
- * we have to do a stat() and remember for next time.
- *
- * Grump. For Apache, even the first stat here may well be
- * redundant (for multiviews) with a stat() done by the sub_req
- * machinery. At some point, that ought to be fixed.
- */
-
-static float find_content_length(negotiation_state *neg, var_rec *variant)
-{
- ap_finfo_t statb;
-
- if (variant->bytes == 0) {
- char *fullname = ap_make_full_path(neg->pool, neg->dir_name,
- variant->file_name);
-
- if (ap_stat(&statb, fullname, neg->pool) == APR_SUCCESS) {
- /* Note, precision may be lost */
- variant->bytes = (float) statb.size;
- }
- }
-
- return variant->bytes;
-}
-
-/* For a given variant, find the best matching Accept: header
- * and assign the Accept: header's quality value to the
- * mime_type_quality field of the variant, for later use in
- * determining the best matching variant.
- */
-
-static void set_accept_quality(negotiation_state *neg, var_rec *variant)
-{
- int i;
- accept_rec *accept_recs;
- float q = 0.0f;
- int q_definite = 1;
-
- /* if no Accept: header, leave quality alone (will
- * remain at the default value of 1)
- *
- * XXX: This if is currently never true because of the effect of
- * maybe_add_default_accepts().
- */
- if (!neg->accepts) {
- if (variant->mime_type && *variant->mime_type)
- variant->definite = 0;
- return;
- }
-
- accept_recs = (accept_rec *) neg->accepts->elts;
-
- /*
- * Go through each of the ranges on the Accept: header,
- * looking for the 'best' match with this variant's
- * content-type. We use the best match's quality
- * value (from the Accept: header) for this variant's
- * mime_type_quality field.
- *
- * The best match is determined like this:
- * type/type is better than type/ * is better than * / *
- * if match is type/type, use the level mime param if available
- */
- for (i = 0; i < neg->accepts->nelts; ++i) {
-
- accept_rec *type = &accept_recs[i];
- int prev_mime_stars;
-
- prev_mime_stars = variant->mime_stars;
-
- if (!mime_match(type, variant)) {
- continue; /* didn't match the content type at all */
- }
- else {
- /* did match - see if there were less or more stars than
- * in previous match
- */
- if (prev_mime_stars == variant->mime_stars) {
- continue; /* more stars => not as good a match */
- }
- }
-
- /* If we are allowed to mess with the q-values
- * and have no explicit q= parameters in the accept header,
- * make wildcards very low, so we have a low chance
- * of ending up with them if there's something better.
- */
-
- if (!neg->dont_fiddle_headers && !neg->accept_q &&
- variant->mime_stars == 1) {
- q = 0.01f;
- }
- else if (!neg->dont_fiddle_headers && !neg->accept_q &&
- variant->mime_stars == 2) {
- q = 0.02f;
- }
- else {
- q = type->quality;
- }
-
- q_definite = (variant->mime_stars == 3);
- }
- variant->mime_type_quality = q;
- variant->definite = variant->definite && q_definite;
-
-}
-
-/* For a given variant, find the 'q' value of the charset given
- * on the Accept-Charset line. If no charsets are listed,
- * assume value of '1'.
- */
-static void set_charset_quality(negotiation_state *neg, var_rec *variant)
-{
- int i;
- accept_rec *accept_recs;
- char *charset = variant->content_charset;
- accept_rec *star = NULL;
-
- /* if no Accept-Charset: header, leave quality alone (will
- * remain at the default value of 1)
- */
- if (!neg->accept_charsets) {
- if (charset && *charset)
- variant->definite = 0;
- return;
- }
-
- accept_recs = (accept_rec *) neg->accept_charsets->elts;
-
- if (charset == NULL || !*charset) {
- /* Charset of variant not known */
-
- /* if not a text / * type, leave quality alone */
- if (!(!strncmp(variant->mime_type, "text/", 5)
- || !strcmp(variant->mime_type, INCLUDES_MAGIC_TYPE)
- || !strcmp(variant->mime_type, INCLUDES_MAGIC_TYPE3)
- ))
- return;
-
- /* Don't go guessing if we are in strict header mode,
- * e.g. when running the rvsa, as any guess won't be reflected
- * in the variant list or content-location headers.
- */
- if (neg->dont_fiddle_headers)
- return;
-
- charset = "iso-8859-1"; /* The default charset for HTTP text types */
- }
-
- /*
- * Go through each of the items on the Accept-Charset header,
- * looking for a match with this variant's charset. If none
- * match, charset is unacceptable, so set quality to 0.
- */
- for (i = 0; i < neg->accept_charsets->nelts; ++i) {
-
- accept_rec *type = &accept_recs[i];
-
- if (!strcmp(type->name, charset)) {
- variant->charset_quality = type->quality;
- return;
- }
- else if (strcmp(type->name, "*") == 0) {
- star = type;
- }
- }
- /* No explicit match */
- if (star) {
- variant->charset_quality = star->quality;
- variant->definite = 0;
- return;
- }
- /* If this variant is in charset iso-8859-1, the default is 1.0 */
- if (strcmp(charset, "iso-8859-1") == 0) {
- variant->charset_quality = 1.0f;
- }
- else {
- variant->charset_quality = 0.0f;
- }
-}
-
-
-/* is_identity_encoding is included for back-compat, but does anyone
- * use 7bit, 8bin or binary in their var files??
- */
-
-static int is_identity_encoding(const char *enc)
-{
- return (!enc || !enc[0] || !strcmp(enc, "7bit") || !strcmp(enc, "8bit")
- || !strcmp(enc, "binary"));
-}
-
-/*
- * set_encoding_quality determines whether the encoding for a particular
- * variant is acceptable for the user-agent.
- *
- * The rules for encoding are that if the user-agent does not supply
- * any Accept-Encoding header, then all encodings are allowed but a
- * variant with no encoding should be preferred.
- * If there is an empty Accept-Encoding header, then no encodings are
- * acceptable. If there is a non-empty Accept-Encoding header, then
- * any of the listed encodings are acceptable, as well as no encoding
- * unless the "identity" encoding is specifically excluded.
- */
-static void set_encoding_quality(negotiation_state *neg, var_rec *variant)
-{
- accept_rec *accept_recs;
- const char *enc = variant->content_encoding;
- accept_rec *star = NULL;
- float value_if_not_found = 0.0f;
- int i;
-
- if (!neg->accept_encodings) {
- /* We had no Accept-Encoding header, assume that all
- * encodings are acceptable with a low quality,
- * but we prefer no encoding if available.
- */
- if (!enc || is_identity_encoding(enc))
- variant->encoding_quality = 1.0f;
- else
- variant->encoding_quality = 0.5f;
-
- return;
- }
-
- if (!enc || is_identity_encoding(enc)) {
- enc = "identity";
- value_if_not_found = 0.0001f;
- }
-
- accept_recs = (accept_rec *) neg->accept_encodings->elts;
-
- /* Go through each of the encodings on the Accept-Encoding: header,
- * looking for a match with our encoding. x- prefixes are ignored.
- */
- if (enc[0] == 'x' && enc[1] == '-') {
- enc += 2;
- }
- for (i = 0; i < neg->accept_encodings->nelts; ++i) {
-
- char *name = accept_recs[i].name;
-
- if (name[0] == 'x' && name[1] == '-') {
- name += 2;
- }
-
- if (!strcmp(name, enc)) {
- variant->encoding_quality = accept_recs[i].quality;
- return;
- }
-
- if (strcmp(name, "*") == 0) {
- star = &accept_recs[i];
- }
-
- }
- /* No explicit match */
- if (star) {
- variant->encoding_quality = star->quality;
- return;
- }
-
- /* Encoding not found on Accept-Encoding: header, so it is
- * _not_ acceptable unless it is the identity (no encoding)
- */
- variant->encoding_quality = value_if_not_found;
-}
-
-/*************************************************************
- * Possible results of the variant selection algorithm
- */
-enum algorithm_results {
- alg_choice = 1, /* choose variant */
- alg_list /* list variants */
-};
-
-/* Below is the 'best_match' function. It returns an int, which has
- * one of the two values alg_choice or alg_list, which give the result
- * of the variant selection algorithm. alg_list means that no best
- * variant was found by the algorithm, alg_choice means that a best
- * variant was found and should be returned. The list/choice
- * terminology comes from TCN (rfc2295), but is used in a more generic
- * way here. The best variant is returned in *pbest. best_match has
- * two possible algorithms for determining the best variant: the
- * RVSA/1.0 algorithm (from RFC2296), and the standard Apache
- * algorithm. These are split out into separate functions
- * (is_variant_better_rvsa() and is_variant_better()). Selection of
- * one is through the neg->use_rvsa flag.
- *
- * The call to best_match also creates full information, including
- * language, charset, etc quality for _every_ variant. This is needed
- * for generating a correct Vary header, and can be used for the
- * Alternates header, the human-readable list responses and 406 errors.
- */
-
-/* Firstly, the RVSA/1.0 (HTTP Remote Variant Selection Algorithm
- * v1.0) from rfc2296. This is the algorithm that goes together with
- * transparent content negotiation (TCN).
- */
-static int is_variant_better_rvsa(negotiation_state *neg, var_rec *variant,
- var_rec *best, float *p_bestq)
-{
- float bestq = *p_bestq, q;
-
- /* TCN does not cover negotiation on content-encoding. For now,
- * we ignore the encoding unless it was explicitly excluded.
- */
- if (variant->encoding_quality == 0.0f)
- return 0;
-
- q = variant->mime_type_quality *
- variant->source_quality *
- variant->charset_quality *
- variant->lang_quality;
-
- /* RFC 2296 calls for the result to be rounded to 5 decimal places,
- * but we don't do that because it serves no useful purpose other
- * than to ensure that a remote algorithm operates on the same
- * precision as ours. That is silly, since what we obviously want
- * is for the algorithm to operate on the best available precision
- * regardless of who runs it. Since the above calculation may
- * result in significant variance at 1e-12, rounding would be bogus.
- */
-
-#ifdef NEG_DEBUG
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Variant: file=%s type=%s lang=%s sourceq=%1.3f "
- "mimeq=%1.3f langq=%1.3f charq=%1.3f encq=%1.3f "
- "q=%1.5f definite=%d",
- (variant->file_name ? variant->file_name : ""),
- (variant->mime_type ? variant->mime_type : ""),
- (variant->content_languages
- ? ap_array_pstrcat(neg->pool, variant->content_languages, ',')
- : ""),
- variant->source_quality,
- variant->mime_type_quality,
- variant->lang_quality,
- variant->charset_quality,
- variant->encoding_quality,
- q,
- variant->definite);
-#endif
-
- if (q <= 0.0f) {
- return 0;
- }
- if (q > bestq) {
- *p_bestq = q;
- return 1;
- }
- if (q == bestq) {
- /* If the best variant's encoding is of lesser quality than
- * this variant, then we prefer this variant
- */
- if (variant->encoding_quality > best->encoding_quality) {
- *p_bestq = q;
- return 1;
- }
- }
- return 0;
-}
-
-/* Negotiation algorithm as used by previous versions of Apache
- * (just about).
- */
-
-static int is_variant_better(negotiation_state *neg, var_rec *variant,
- var_rec *best, float *p_bestq)
-{
- float bestq = *p_bestq, q;
- int levcmp;
-
- /* For non-transparent negotiation, server can choose how
- * to handle the negotiation. We'll use the following in
- * order: content-type, language, content-type level, charset,
- * content encoding, content length.
- *
- * For each check, we have three possible outcomes:
- * This variant is worse than current best: return 0
- * This variant is better than the current best:
- * assign this variant's q to *p_bestq, and return 1
- * This variant is just as desirable as the current best:
- * drop through to the next test.
- *
- * This code is written in this long-winded way to allow future
- * customisation, either by the addition of additional
- * checks, or to allow the order of the checks to be determined
- * by configuration options (e.g. we might prefer to check
- * language quality _before_ content type).
- */
-
- /* First though, eliminate this variant if it is not
- * acceptable by type, charset, encoding or language.
- */
-
-#ifdef NEG_DEBUG
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Variant: file=%s type=%s lang=%s sourceq=%1.3f "
- "mimeq=%1.3f langq=%1.3f langidx=%d charq=%1.3f encq=%1.3f ",
- (variant->file_name ? variant->file_name : ""),
- (variant->mime_type ? variant->mime_type : ""),
- (variant->content_languages
- ? ap_array_pstrcat(neg->pool, variant->content_languages, ',')
- : ""),
- variant->source_quality,
- variant->mime_type_quality,
- variant->lang_quality,
- variant->lang_index,
- variant->charset_quality,
- variant->encoding_quality);
-#endif
-
- if (variant->encoding_quality == 0.0f ||
- variant->lang_quality == 0.0f ||
- variant->source_quality == 0.0f ||
- variant->charset_quality == 0.0f ||
- variant->mime_type_quality == 0.0f) {
- return 0; /* don't consider unacceptables */
- }
-
- q = variant->mime_type_quality * variant->source_quality;
- if (q == 0.0 || q < bestq) {
- return 0;
- }
- if (q > bestq || !best) {
- *p_bestq = q;
- return 1;
- }
-
- /* language */
- if (variant->lang_quality < best->lang_quality) {
- return 0;
- }
- if (variant->lang_quality > best->lang_quality) {
- *p_bestq = q;
- return 1;
- }
-
- /* if language qualities were equal, try the LanguagePriority stuff */
- if (best->lang_index != -1 &&
- (variant->lang_index == -1 || variant->lang_index > best->lang_index)) {
- return 0;
- }
- if (variant->lang_index != -1 &&
- (best->lang_index == -1 || variant->lang_index < best->lang_index)) {
- *p_bestq = q;
- return 1;
- }
-
- /* content-type level (sometimes used with text/html, though we
- * support it on other types too)
- */
- levcmp = level_cmp(variant, best);
- if (levcmp == -1) {
- return 0;
- }
- if (levcmp == 1) {
- *p_bestq = q;
- return 1;
- }
-
- /* charset */
- if (variant->charset_quality < best->charset_quality) {
- return 0;
- }
- /* If the best variant's charset is ISO-8859-1 and this variant has
- * the same charset quality, then we prefer this variant
- */
-
- if (variant->charset_quality > best->charset_quality ||
- ((variant->content_charset != NULL &&
- *variant->content_charset != '\0' &&
- strcmp(variant->content_charset, "iso-8859-1") != 0) &&
- (best->content_charset == NULL ||
- *best->content_charset == '\0' ||
- strcmp(best->content_charset, "iso-8859-1") == 0))) {
- *p_bestq = q;
- return 1;
- }
-
- /* Prefer the highest value for encoding_quality.
- */
- if (variant->encoding_quality < best->encoding_quality) {
- return 0;
- }
- if (variant->encoding_quality > best->encoding_quality) {
- *p_bestq = q;
- return 1;
- }
-
- /* content length if all else equal */
- if (find_content_length(neg, variant) >= find_content_length(neg, best)) {
- return 0;
- }
-
- /* ok, to get here means every thing turned out equal, except
- * we have a shorter content length, so use this variant
- */
- *p_bestq = q;
- return 1;
-}
-
-static int best_match(negotiation_state *neg, var_rec **pbest)
-{
- int j;
- var_rec *best = NULL;
- float bestq = 0.0f;
- enum algorithm_results algorithm_result;
-
- var_rec *avail_recs = (var_rec *) neg->avail_vars->elts;
-
- set_default_lang_quality(neg);
-
- /*
- * Find the 'best' variant
- */
-
- for (j = 0; j < neg->avail_vars->nelts; ++j) {
- var_rec *variant = &avail_recs[j];
-
- /* Find all the relevant 'quality' values from the
- * Accept... headers, and store in the variant. This also
- * prepares for sending an Alternates header etc so we need to
- * do it even if we do not actually plan to find a best
- * variant.
- */
- set_accept_quality(neg, variant);
- set_language_quality(neg, variant);
- set_encoding_quality(neg, variant);
- set_charset_quality(neg, variant);
-
- /* Only do variant selection if we may actually choose a
- * variant for the client
- */
- if (neg->may_choose) {
-
- /* Now find out if this variant is better than the current
- * best, either using the RVSA/1.0 algorithm, or Apache's
- * internal server-driven algorithm. Presumably other
- * server-driven algorithms are possible, and could be
- * implemented here.
- */
-
- if (neg->use_rvsa) {
- if (is_variant_better_rvsa(neg, variant, best, &bestq)) {
- best = variant;
- }
- }
- else {
- if (is_variant_better(neg, variant, best, &bestq)) {
- best = variant;
- }
- }
- }
- }
-
- /* We now either have a best variant, or no best variant */
-
- if (neg->use_rvsa) {
- /* calculate result for RVSA/1.0 algorithm:
- * only a choice response if the best variant has q>0
- * and is definite
- */
- algorithm_result = (best && best->definite) && (bestq > 0) ?
- alg_choice : alg_list;
- }
- else {
- /* calculate result for Apache negotiation algorithm */
- algorithm_result = bestq > 0 ? alg_choice : alg_list;
- }
-
- /* Returning a choice response with a non-neighboring variant is a
- * protocol security error in TCN (see rfc2295). We do *not*
- * verify here that the variant and URI are neighbors, even though
- * we may return alg_choice. We depend on the environment (the
- * caller) to only declare the resource transparently negotiable if
- * all variants are neighbors.
- */
- *pbest = best;
- return algorithm_result;
-}
-
-/* Sets response headers for a negotiated response.
- * neg->is_transparent determines whether a transparently negotiated
- * response or a plain `server driven negotiation' response is
- * created. Applicable headers are Alternates, Vary, and TCN.
- *
- * The Vary header we create is sometimes longer than is required for
- * the correct caching of negotiated results by HTTP/1.1 caches. For
- * example if we have 3 variants x.html, x.ps.en and x.ps.nl, and if
- * the Accept: header assigns a 0 quality to .ps, then the results of
- * the two server-side negotiation algorithms we currently implement
- * will never depend on Accept-Language so we could return `Vary:
- * negotiate, accept' instead of the longer 'Vary: negotiate, accept,
- * accept-language' which the code below will return. A routine for
- * computing the exact minimal Vary header would be a huge pain to code
- * and maintain though, especially because we need to take all possible
- * twiddles in the server-side negotiation algorithms into account.
- */
-static void set_neg_headers(request_rec *r, negotiation_state *neg,
- int alg_result)
-{
- ap_table_t *hdrs;
- var_rec *avail_recs = (var_rec *) neg->avail_vars->elts;
- const char *sample_type = NULL;
- const char *sample_language = NULL;
- const char *sample_encoding = NULL;
- const char *sample_charset = NULL;
- char *lang;
- char *qstr;
- char *lenstr;
- long len;
- ap_array_header_t *arr;
- int max_vlist_array = (neg->avail_vars->nelts * 21);
- int first_variant = 1;
- int vary_by_type = 0;
- int vary_by_language = 0;
- int vary_by_charset = 0;
- int vary_by_encoding = 0;
- int j;
-
- /* In order to avoid O(n^2) memory copies in building Alternates,
- * we preallocate a ap_table_t with the maximum substrings possible,
- * fill it with the variant list, and then concatenate the entire array.
- * Note that if you change the number of substrings pushed, you also
- * need to change the calculation of max_vlist_array above.
- */
- if (neg->send_alternates && neg->avail_vars->nelts)
- arr = ap_make_array(r->pool, max_vlist_array, sizeof(char *));
- else
- arr = NULL;
-
- /* Put headers into err_headers_out, since send_http_header()
- * outputs both headers_out and err_headers_out.
- */
- hdrs = r->err_headers_out;
-
- for (j = 0; j < neg->avail_vars->nelts; ++j) {
- var_rec *variant = &avail_recs[j];
-
- if (variant->content_languages && variant->content_languages->nelts) {
- lang = ap_array_pstrcat(r->pool, variant->content_languages, ',');
- }
- else {
- lang = NULL;
- }
-
- /* Calculate Vary by looking for any difference between variants */
-
- if (first_variant) {
- sample_type = variant->mime_type;
- sample_charset = variant->content_charset;
- sample_language = lang;
- sample_encoding = variant->content_encoding;
- }
- else {
- if (!vary_by_type &&
- strcmp(sample_type ? sample_type : "",
- variant->mime_type ? variant->mime_type : "")) {
- vary_by_type = 1;
- }
- if (!vary_by_charset &&
- strcmp(sample_charset ? sample_charset : "",
- variant->content_charset ?
- variant->content_charset : "")) {
- vary_by_charset = 1;
- }
- if (!vary_by_language &&
- strcmp(sample_language ? sample_language : "",
- lang ? lang : "")) {
- vary_by_language = 1;
- }
- if (!vary_by_encoding &&
- strcmp(sample_encoding ? sample_encoding : "",
- variant->content_encoding ?
- variant->content_encoding : "")) {
- vary_by_encoding = 1;
- }
- }
- first_variant = 0;
-
- if (!neg->send_alternates)
- continue;
-
- /* Generate the string components for this Alternates entry */
-
- *((const char **) ap_push_array(arr)) = "{\"";
- *((const char **) ap_push_array(arr)) = variant->file_name;
- *((const char **) ap_push_array(arr)) = "\" ";
-
- qstr = (char *) ap_palloc(r->pool, 6);
- ap_snprintf(qstr, 6, "%1.3f", variant->source_quality);
-
- /* Strip trailing zeros (saves those valuable network bytes) */
- if (qstr[4] == '0') {
- qstr[4] = '\0';
- if (qstr[3] == '0') {
- qstr[3] = '\0';
- if (qstr[2] == '0') {
- qstr[1] = '\0';
- }
- }
- }
- *((const char **) ap_push_array(arr)) = qstr;
-
- if (variant->mime_type && *variant->mime_type) {
- *((const char **) ap_push_array(arr)) = " {type ";
- *((const char **) ap_push_array(arr)) = variant->mime_type;
- *((const char **) ap_push_array(arr)) = "}";
- }
- if (variant->content_charset && *variant->content_charset) {
- *((const char **) ap_push_array(arr)) = " {charset ";
- *((const char **) ap_push_array(arr)) = variant->content_charset;
- *((const char **) ap_push_array(arr)) = "}";
- }
- if (lang) {
- *((const char **) ap_push_array(arr)) = " {language ";
- *((const char **) ap_push_array(arr)) = lang;
- *((const char **) ap_push_array(arr)) = "}";
- }
- if (variant->content_encoding && *variant->content_encoding) {
- /* Strictly speaking, this is non-standard, but so is TCN */
-
- *((const char **) ap_push_array(arr)) = " {encoding ";
- *((const char **) ap_push_array(arr)) = variant->content_encoding;
- *((const char **) ap_push_array(arr)) = "}";
- }
-
- /* Note that the Alternates specification (in rfc2295) does
- * not require that we include {length x}, so we could omit it
- * if determining the length is too expensive. We currently
- * always include it though. 22 bytes is enough for 2^64.
- *
- * If the variant is a CGI script, find_content_length would
- * return the length of the script, not the output it
- * produces, so we check for the presence of a handler and if
- * there is one we don't add a length.
- *
- * XXX: TODO: This check does not detect a CGI script if we
- * get the variant from a type map. This needs to be fixed
- * (without breaking things if the type map specifies a
- * content-length, which currently leads to the correct result).
- */
- if (!(variant->sub_req && variant->sub_req->handler)
- && (len = find_content_length(neg, variant)) != 0) {
-
- lenstr = (char *) ap_palloc(r->pool, 22);
- ap_snprintf(lenstr, 22, "%ld", len);
- *((const char **) ap_push_array(arr)) = " {length ";
- *((const char **) ap_push_array(arr)) = lenstr;
- *((const char **) ap_push_array(arr)) = "}";
- }
-
- *((const char **) ap_push_array(arr)) = "}";
- *((const char **) ap_push_array(arr)) = ", "; /* trimmed below */
- }
-
- if (neg->send_alternates && neg->avail_vars->nelts) {
- arr->nelts--; /* remove last comma */
- ap_table_mergen(hdrs, "Alternates",
- ap_array_pstrcat(r->pool, arr, '\0'));
- }
-
- if (neg->is_transparent || vary_by_type || vary_by_language ||
- vary_by_language || vary_by_charset || vary_by_encoding) {
-
- ap_table_mergen(hdrs, "Vary", 2 + ap_pstrcat(r->pool,
- neg->is_transparent ? ", negotiate" : "",
- vary_by_type ? ", accept" : "",
- vary_by_language ? ", accept-language" : "",
- vary_by_charset ? ", accept-charset" : "",
- vary_by_encoding ? ", accept-encoding" : "", NULL));
- }
-
- if (neg->is_transparent) { /* Create TCN response header */
- ap_table_setn(hdrs, "TCN",
- alg_result == alg_list ? "list" : "choice");
- }
-}
-
-/**********************************************************************
- *
- * Return an HTML list of variants. This is output as part of the
- * choice response or 406 status body.
- */
-
-static char *make_variant_list(request_rec *r, negotiation_state *neg)
-{
- ap_array_header_t *arr;
- int i;
- int max_vlist_array = (neg->avail_vars->nelts * 15) + 2;
-
- /* In order to avoid O(n^2) memory copies in building the list,
- * we preallocate a ap_table_t with the maximum substrings possible,
- * fill it with the variant list, and then concatenate the entire array.
- */
- arr = ap_make_array(r->pool, max_vlist_array, sizeof(char *));
-
- *((const char **) ap_push_array(arr)) = "Available variants:\n<ul>\n";
-
- for (i = 0; i < neg->avail_vars->nelts; ++i) {
- var_rec *variant = &((var_rec *) neg->avail_vars->elts)[i];
- char *filename = variant->file_name ? variant->file_name : "";
- ap_array_header_t *languages = variant->content_languages;
- char *description = variant->description ? variant->description : "";
-
- /* The format isn't very neat, and it would be nice to make
- * the tags human readable (eg replace 'language en' with 'English').
- * Note that if you change the number of substrings pushed, you also
- * need to change the calculation of max_vlist_array above.
- */
- *((const char **) ap_push_array(arr)) = "<li><a href=\"";
- *((const char **) ap_push_array(arr)) = filename;
- *((const char **) ap_push_array(arr)) = "\">";
- *((const char **) ap_push_array(arr)) = filename;
- *((const char **) ap_push_array(arr)) = "</a> ";
- *((const char **) ap_push_array(arr)) = description;
-
- if (variant->mime_type && *variant->mime_type) {
- *((const char **) ap_push_array(arr)) = ", type ";
- *((const char **) ap_push_array(arr)) = variant->mime_type;
- }
- if (languages && languages->nelts) {
- *((const char **) ap_push_array(arr)) = ", language ";
- *((const char **) ap_push_array(arr)) = ap_array_pstrcat(r->pool,
- languages, ',');
- }
- if (variant->content_charset && *variant->content_charset) {
- *((const char **) ap_push_array(arr)) = ", charset ";
- *((const char **) ap_push_array(arr)) = variant->content_charset;
- }
- if (variant->content_encoding) {
- *((const char **) ap_push_array(arr)) = ", encoding ";
- *((const char **) ap_push_array(arr)) = variant->content_encoding;
- }
- *((const char **) ap_push_array(arr)) = "\n";
- }
- *((const char **) ap_push_array(arr)) = "</ul>\n";
-
- return ap_array_pstrcat(r->pool, arr, '\0');
-}
-
-static void store_variant_list(request_rec *r, negotiation_state *neg)
-{
- if (r->main == NULL) {
- ap_table_setn(r->notes, "variant-list", make_variant_list(r, neg));
- }
- else {
- ap_table_setn(r->main->notes, "variant-list",
- make_variant_list(r->main, neg));
- }
-}
-
-/* Called if we got a "Choice" response from the variant selection algorithm.
- * It checks the result of the chosen variant to see if it
- * is itself negotiated (if so, return error VARIANT_ALSO_VARIES).
- * Otherwise, add the appropriate headers to the current response.
- */
-
-static int setup_choice_response(request_rec *r, negotiation_state *neg,
- var_rec *variant)
-{
- request_rec *sub_req;
- const char *sub_vary;
-
- if (!variant->sub_req) {
- int status;
-
- sub_req = ap_sub_req_lookup_file(variant->file_name, r);
- status = sub_req->status;
-
- if (status != HTTP_OK &&
- !ap_table_get(sub_req->err_headers_out, "TCN")) {
- ap_destroy_sub_req(sub_req);
- return status;
- }
- variant->sub_req = sub_req;
- }
- else {
- sub_req = variant->sub_req;
- }
-
- /* The variant selection algorithm told us to return a "Choice"
- * response. This is the normal variant response, with
- * some extra headers. First, ensure that the chosen
- * variant did or will not itself engage in transparent negotiation.
- * If not, set the appropriate headers, and fall through to
- * the normal variant handling
- */
-
- /* This catches the error that a transparent type map selects a
- * transparent multiviews resource as the best variant.
- *
- * XXX: We do not signal an error if a transparent type map
- * selects a _non_transparent multiviews resource as the best
- * variant, because we can generate a legal negotiation response
- * in this case. In this case, the vlist_validator of the
- * nontransparent subrequest will be lost however. This could
- * lead to cases in which a change in the set of variants or the
- * negotiation algorithm of the nontransparent resource is never
- * propagated up to a HTTP/1.1 cache which interprets Vary. To be
- * completely on the safe side we should return VARIANT_ALSO_VARIES
- * for this type of recursive negotiation too.
- */
- if (neg->is_transparent &&
- ap_table_get(sub_req->err_headers_out, "TCN")) {
- return VARIANT_ALSO_VARIES;
- }
-
- /* This catches the error that a transparent type map recursively
- * selects, as the best variant, another type map which itself
- * causes transparent negotiation to be done.
- *
- * XXX: Actually, we catch this error by catching all cases of
- * type map recursion. There are some borderline recursive type
- * map arrangements which would not produce transparent
- * negotiation protocol errors or lack of cache propagation
- * problems, but such arrangements are very hard to detect at this
- * point in the control flow, so we do not bother to single them
- * out.
- *
- * Recursive type maps imply a recursive arrangement of negotiated
- * resources which is visible to outside clients, and this is not
- * supported by the transparent negotiation caching protocols, so
- * if we are to have generic support for recursive type maps, we
- * have to create some configuration setting which makes all type
- * maps non-transparent when recursion is enabled. Also, if we
- * want recursive type map support which ensures propagation of
- * type map changes into HTTP/1.1 caches that handle Vary, we
- * would have to extend the current mechanism for generating
- * variant list validators.
- */
- if (sub_req->handler && strcmp(sub_req->handler, "type-map") == 0) {
- return VARIANT_ALSO_VARIES;
- }
-
- /* This adds an appropriate Variant-Vary header if the subrequest
- * is a multiviews resource.
- *
- * XXX: TODO: Note that this does _not_ handle any Vary header
- * returned by a CGI if sub_req is a CGI script, because we don't
- * see that Vary header yet at this point in the control flow.
- * This won't cause any cache consistency problems _unless_ the
- * CGI script also returns a Cache-Control header marking the
- * response as cachable. This needs to be fixed, also there are
- * problems if a CGI returns an Etag header which also need to be
- * fixed.
- */
- if ((sub_vary = ap_table_get(sub_req->err_headers_out, "Vary")) != NULL) {
- ap_table_setn(r->err_headers_out, "Variant-Vary", sub_vary);
-
- /* Move the subreq Vary header into the main request to
- * prevent having two Vary headers in the response, which
- * would be legal but strange.
- */
- ap_table_setn(r->err_headers_out, "Vary", sub_vary);
- ap_table_unset(sub_req->err_headers_out, "Vary");
- }
-
- ap_table_setn(r->err_headers_out, "Content-Location",
- ap_pstrdup(r->pool, variant->file_name));
-
- set_neg_headers(r, neg, alg_choice); /* add Alternates and Vary */
-
- /* Still to do by caller: add Expires */
-
- return 0;
-}
-
-/****************************************************************
- *
- * Executive...
- */
-
-static int do_negotiation(request_rec *r, negotiation_state *neg,
- var_rec **bestp, int prefer_scripts)
-{
- var_rec *avail_recs = (var_rec *) neg->avail_vars->elts;
- int alg_result; /* result of variant selection algorithm */
- int res;
- int j;
-
- /* Decide if resource is transparently negotiable */
-
- /* GET or HEAD? (HEAD has same method number as GET) */
- if (r->method_number == M_GET) {
-
- /* maybe this should be configurable, see also the comment
- * about recursive type maps in setup_choice_response()
- */
- neg->is_transparent = 1;
-
- /* We can't be transparent if we are a map file in the middle
- * of the request URI.
- */
- if (r->path_info && *r->path_info)
- neg->is_transparent = 0;
-
- for (j = 0; j < neg->avail_vars->nelts; ++j) {
- var_rec *variant = &avail_recs[j];
-
- /* We can't be transparent, because of internal
- * assumptions in best_match(), if there is a
- * non-neighboring variant. We can have a non-neighboring
- * variant when processing a type map.
- */
- if (strchr(variant->file_name, '/'))
- neg->is_transparent = 0;
- }
- }
-
- if (neg->is_transparent) {
- parse_negotiate_header(r, neg);
- }
- else { /* configure negotiation on non-transparent resource */
- neg->may_choose = 1;
- }
-
- maybe_add_default_accepts(neg, prefer_scripts);
-
- alg_result = best_match(neg, bestp);
-
- /* alg_result is one of
- * alg_choice: a best variant is chosen
- * alg_list: no best variant is chosen
- */
-
- if (alg_result == alg_list) {
- /* send a list response or NOT_ACCEPTABLE error response */
-
- neg->send_alternates = 1; /* always include Alternates header */
- set_neg_headers(r, neg, alg_result);
- store_variant_list(r, neg);
-
- if (neg->is_transparent && neg->ua_supports_trans) {
- /* XXX todo: expires? cachability? */
-
- /* Some HTTP/1.0 clients are known to choke when they get
- * a 300 (multiple choices) response without a Location
- * header. However the 300 code response we are are about
- * to generate will only reach 1.0 clients which support
- * transparent negotiation, and they should be OK. The
- * response should never reach older 1.0 clients, even if
- * we have CacheNegotiatedDocs enabled, because no 1.0
- * proxy cache (we know of) will cache and return 300
- * responses (they certainly won't if they conform to the
- * HTTP/1.0 specification).
- */
- return MULTIPLE_CHOICES;
- }
-
- if (!*bestp) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "no acceptable variant: %s", r->filename);
- return NOT_ACCEPTABLE;
- }
- }
-
- /* Variant selection chose a variant */
-
- /* XXX todo: merge the two cases in the if statement below */
- if (neg->is_transparent) {
-
- if ((res = setup_choice_response(r, neg, *bestp)) != 0) {
- return res; /* return if error */
- }
- }
- else {
- set_neg_headers(r, neg, alg_result);
- }
-
- /* Make sure caching works - Vary should handle HTTP/1.1, but for
- * HTTP/1.0, we can't allow caching at all.
- */
-
- /* XXX: Note that we only set r->no_cache to 1, which causes
- * Expires: <now> to be added, when responding to a HTTP/1.0
- * client. If we return the response to a 1.1 client, we do not
- * add Expires <now>, because doing so would degrade 1.1 cache
- * performance by preventing re-use of the response without prior
- * revalidation. On the other hand, if the 1.1 client is a proxy
- * which was itself contacted by a 1.0 client, or a proxy cache
- * which can be contacted later by 1.0 clients, then we currently
- * rely on this 1.1 proxy to add the Expires: <now> when it
- * forwards the response.
- *
- * XXX: TODO: Find out if the 1.1 spec requires proxies and
- * tunnels to add Expires: <now> when forwarding the response to
- * 1.0 clients. I (kh) recall it is rather vague on this point.
- * Testing actual 1.1 proxy implementations would also be nice. If
- * Expires: <now> is not added by proxies then we need to always
- * include Expires: <now> ourselves to ensure correct caching, but
- * this would degrade HTTP/1.1 cache efficiency unless we also add
- * Cache-Control: max-age=N, which we currently don't.
- *
- * Roy: No, we are not going to screw over HTTP future just to
- * ensure that people who can't be bothered to upgrade their
- * clients will always receive perfect server-side negotiation.
- * Hell, those clients are sending bogus accept headers anyway.
- *
- * Manual setting of cache-control/expires always overrides this
- * automated kluge, on purpose.
- */
-
- if ((!do_cache_negotiated_docs(r->server)
- && (r->proto_num < HTTP_VERSION(1,1)))
- && neg->count_multiviews_variants != 1) {
- r->no_cache = 1;
- }
-
- return OK;
-}
-
-static int handle_map_file(request_rec *r)
-{
- negotiation_state *neg = parse_accept_headers(r);
- var_rec *best;
- int res;
-
- char *udir;
-
- if ((res = read_type_map(neg, r))) {
- return res;
- }
-
- res = do_negotiation(r, neg, &best, 0);
- if (res != 0) return res;
-
- if (r->path_info && *r->path_info) {
- r->uri[ap_find_path_info(r->uri, r->path_info)] = '\0';
- }
- udir = ap_make_dirstr_parent(r->pool, r->uri);
- udir = ap_escape_uri(r->pool, udir);
- ap_internal_redirect(ap_pstrcat(r->pool, udir, best->file_name,
- r->path_info, NULL), r);
- return OK;
-}
-
-static int handle_multi(request_rec *r)
-{
- negotiation_state *neg;
- var_rec *best, *avail_recs;
- request_rec *sub_req;
- int res;
- int j;
-
- if (r->finfo.protection != 0 || !(ap_allow_options(r) & OPT_MULTI)) {
- return DECLINED;
- }
-
- neg = parse_accept_headers(r);
-
- if ((res = read_types_multi(neg))) {
- return_from_multi:
- /* free all allocated memory from subrequests */
- avail_recs = (var_rec *) neg->avail_vars->elts;
- for (j = 0; j < neg->avail_vars->nelts; ++j) {
- var_rec *variant = &avail_recs[j];
- if (variant->sub_req) {
- ap_destroy_sub_req(variant->sub_req);
- }
- }
- return res;
- }
- if (neg->avail_vars->nelts == 0) {
- return DECLINED;
- }
-
- res = do_negotiation(r, neg, &best,
- (r->method_number != M_GET) || r->args ||
- (r->path_info && *r->path_info));
- if (res != 0)
- goto return_from_multi;
-
- if (!(sub_req = best->sub_req)) {
- /* We got this out of a map file, so we don't actually have
- * a sub_req structure yet. Get one now.
- */
-
- sub_req = ap_sub_req_lookup_file(best->file_name, r);
- if (sub_req->status != HTTP_OK) {
- res = sub_req->status;
- ap_destroy_sub_req(sub_req);
- goto return_from_multi;
- }
- }
-
- /* BLECH --- don't multi-resolve non-ordinary files */
-
- if (sub_req->finfo.filetype != APR_REG) {
- res = NOT_FOUND;
- goto return_from_multi;
- }
-
- /* Otherwise, use it. */
-
- /* now do a "fast redirect" ... promote the sub_req into the main req */
- /* We need to tell POOL_DEBUG that we're guaranteeing that sub_req->pool
- * will exist as long as r->pool. Otherwise we run into troubles because
- * some values in this request will be allocated in r->pool, and others in
- * sub_req->pool.
- */
- ap_pool_join(r->pool, sub_req->pool);
- r->mtime = 0; /* reset etag info for subrequest */
- r->filename = sub_req->filename;
- r->handler = sub_req->handler;
- r->content_type = sub_req->content_type;
- r->content_encoding = sub_req->content_encoding;
- r->content_languages = sub_req->content_languages;
- r->content_language = sub_req->content_language;
- r->finfo = sub_req->finfo;
- r->per_dir_config = sub_req->per_dir_config;
- /* copy output headers from subrequest, but leave negotiation headers */
- r->notes = ap_overlay_tables(r->pool, sub_req->notes, r->notes);
- r->headers_out = ap_overlay_tables(r->pool, sub_req->headers_out,
- r->headers_out);
- r->err_headers_out = ap_overlay_tables(r->pool, sub_req->err_headers_out,
- r->err_headers_out);
- r->subprocess_env = ap_overlay_tables(r->pool, sub_req->subprocess_env,
- r->subprocess_env);
- avail_recs = (var_rec *) neg->avail_vars->elts;
- for (j = 0; j < neg->avail_vars->nelts; ++j) {
- var_rec *variant = &avail_recs[j];
- if (variant != best && variant->sub_req) {
- ap_destroy_sub_req(variant->sub_req);
- }
- }
- return OK;
-}
-
-/**********************************************************************
- * There is a problem with content-encoding, as some clients send and
- * expect an x- token (e.g. x-gzip) while others expect the plain token
- * (i.e. gzip). To try and deal with this as best as possible we do
- * the following: if the client sent an Accept-Encoding header and it
- * contains a plain token corresponding to the content encoding of the
- * response, then set content encoding using the plain token. Else if
- * the A-E header contains the x- token use the x- token in the C-E
- * header. Else don't do anything.
- *
- * Note that if no A-E header was sent, or it does not contain a token
- * compatible with the final content encoding, then the token in the
- * C-E header will be whatever was specified in the AddEncoding
- * directive.
- */
-static int fix_encoding(request_rec *r)
-{
- const char *enc = r->content_encoding;
- char *x_enc = NULL;
- ap_array_header_t *accept_encodings;
- accept_rec *accept_recs;
- int i;
-
- if (!enc || !*enc) {
- return DECLINED;
- }
-
- if (enc[0] == 'x' && enc[1] == '-') {
- enc += 2;
- }
-
- if ((accept_encodings = do_header_line(r->pool,
- ap_table_get(r->headers_in, "Accept-Encoding"))) == NULL) {
- return DECLINED;
- }
-
- accept_recs = (accept_rec *) accept_encodings->elts;
-
- for (i = 0; i < accept_encodings->nelts; ++i) {
- char *name = accept_recs[i].name;
-
- if (!strcmp(name, enc)) {
- r->content_encoding = name;
- return OK;
- }
-
- if (name[0] == 'x' && name[1] == '-' && !strcmp(name+2, enc)) {
- x_enc = name;
- }
- }
-
- if (x_enc) {
- r->content_encoding = x_enc;
- return OK;
- }
-
- return DECLINED;
-}
-
-static const handler_rec negotiation_handlers[] =
-{
- {MAP_FILE_MAGIC_TYPE, handle_map_file},
- {"type-map", handle_map_file},
- {NULL}
-};
-
-static void register_hooks(void)
-{
- ap_hook_fixups(fix_encoding,NULL,NULL,HOOK_MIDDLE);
- ap_hook_type_checker(handle_multi,NULL,NULL,HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT negotiation_module =
-{
- STANDARD20_MODULE_STUFF,
- create_neg_dir_config, /* dir config creator */
- merge_neg_dir_configs, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- negotiation_cmds, /* command ap_table_t */
- negotiation_handlers, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/mappers/mod_negotiation.exp b/modules/mappers/mod_negotiation.exp
deleted file mode 100644
index a7c18da1de..0000000000
--- a/modules/mappers/mod_negotiation.exp
+++ /dev/null
@@ -1 +0,0 @@
-negotiation_module
diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c
deleted file mode 100644
index f355382d66..0000000000
--- a/modules/mappers/mod_rewrite.c
+++ /dev/null
@@ -1,4321 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-
-/* _ _ _
-** _ __ ___ ___ __| | _ __ _____ ___ __(_) |_ ___
-** | '_ ` _ \ / _ \ / _` | | '__/ _ \ \ /\ / / '__| | __/ _ \
-** | | | | | | (_) | (_| | | | | __/\ V V /| | | | || __/
-** |_| |_| |_|\___/ \__,_|___|_| \___| \_/\_/ |_| |_|\__\___|
-** |_____|
-**
-** URL Rewriting Module
-**
-** This module uses a rule-based rewriting engine (based on a
-** regular-expression parser) to rewrite requested URLs on the fly.
-**
-** It supports an unlimited number of additional rule conditions (which can
-** operate on a lot of variables, even on HTTP headers) for granular
-** matching and even external database lookups (either via plain text
-** tables, DBM hash files or even external processes) for advanced URL
-** substitution.
-**
-** It operates on the full URLs (including the PATH_INFO part) both in
-** per-server context (httpd.conf) and per-dir context (.htaccess) and even
-** can generate QUERY_STRING parts on result. The rewriting result finally
-** can lead to internal subprocessing, external request redirection or even
-** to internal proxy throughput.
-**
-** This module was originally written in April 1996 and
-** gifted exclusively to the The Apache Group in July 1997 by
-**
-** Ralf S. Engelschall
-** rse@engelschall.com
-** www.engelschall.com
-*/
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_protocol.h"
-#include "mod_rewrite.h"
-
-#if !defined(OS2) && !defined(WIN32)
-#include "unixd.h"
-#endif
-
-#ifndef NO_WRITEV
-#ifndef NETWARE
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#endif
-#ifdef HAVE_SYS_UIO_H
-#include <sys/uio.h>
-#endif
-#endif
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | static module configuration
-** | |
-** +-------------------------------------------------------+
-*/
-
-
-/*
-** Our interface to the Apache server kernel:
-**
-** o Runtime logic of a request is as following:
-** while(request or subrequest)
-** foreach(stage #0...#9)
-** foreach(module) (**)
-** try to run hook
-**
-** o the order of modules at (**) is the inverted order as
-** given in the "Configuration" file, i.e. the last module
-** specified is the first one called for each hook!
-** The core module is always the last!
-**
-** o there are two different types of result checking and
-** continue processing:
-** for hook #0,#1,#4,#5,#6,#8:
-** hook run loop stops on first modules which gives
-** back a result != DECLINED, i.e. it usually returns OK
-** which says "OK, module has handled this _stage_" and for #1
-** this have not to mean "Ok, the filename is now valid".
-** for hook #2,#3,#7,#9:
-** all hooks are run, independend of result
-**
-** o at the last stage, the core module always
-** - says "BAD_REQUEST" if r->filename does not begin with "/"
-** - prefix URL with document_root or replaced server_root
-** with document_root and sets r->filename
-** - always return a "OK" independed if the file really exists
-** or not!
-*/
-
- /* The section for the Configure script:
- * MODULE-DEFINITION-START
- * Name: rewrite_module
- * ConfigStart
- . ./helpers/find-dbm-lib
- if [ "x$found_dbm" = "x1" ]; then
- echo " enabling DBM support for mod_rewrite"
- else
- echo " disabling DBM support for mod_rewrite"
- echo " (perhaps you need to add -ldbm, -lndbm or -lgdbm to EXTRA_LIBS)"
- CFLAGS="$CFLAGS -DNO_DBM_REWRITEMAP"
- fi
- * ConfigEnd
- * MODULE-DEFINITION-END
- */
-
- /* the ap_table_t of commands we provide */
-static const command_rec command_table[] = {
- { "RewriteEngine", cmd_rewriteengine, NULL, OR_FILEINFO, FLAG,
- "On or Off to enable or disable (default) the whole rewriting engine" },
- { "RewriteOptions", cmd_rewriteoptions, NULL, OR_FILEINFO, ITERATE,
- "List of option strings to set" },
- { "RewriteBase", cmd_rewritebase, NULL, OR_FILEINFO, TAKE1,
- "the base URL of the per-directory context" },
- { "RewriteCond", cmd_rewritecond, NULL, OR_FILEINFO, RAW_ARGS,
- "an input string and a to be applied regexp-pattern" },
- { "RewriteRule", cmd_rewriterule, NULL, OR_FILEINFO, RAW_ARGS,
- "an URL-applied regexp-pattern and a substitution URL" },
- { "RewriteMap", cmd_rewritemap, NULL, RSRC_CONF, TAKE2,
- "a mapname and a filename" },
- { "RewriteLock", cmd_rewritelock, NULL, RSRC_CONF, TAKE1,
- "the filename of a lockfile used for inter-process synchronization"},
- { "RewriteLog", cmd_rewritelog, NULL, RSRC_CONF, TAKE1,
- "the filename of the rewriting logfile" },
- { "RewriteLogLevel", cmd_rewriteloglevel, NULL, RSRC_CONF, TAKE1,
- "the level of the rewriting logfile verbosity "
- "(0=none, 1=std, .., 9=max)" },
- { NULL }
-};
-
- /* the ap_table_t of content handlers we provide */
-static const handler_rec handler_table[] = {
- { "redirect-handler", handler_redirect },
- { NULL }
-};
-
-static void register_hooks(void)
-{
- ap_hook_post_config(init_module,NULL,NULL,HOOK_MIDDLE);
- ap_hook_child_init(init_child,NULL,NULL,HOOK_MIDDLE);
-
- ap_hook_fixups(hook_fixup,NULL,NULL,HOOK_FIRST);
- ap_hook_translate_name(hook_uri2file,NULL,NULL,HOOK_FIRST);
- ap_hook_type_checker(hook_mimetype,NULL,NULL,HOOK_MIDDLE);
-}
-
- /* the main config structure */
-module MODULE_VAR_EXPORT rewrite_module = {
- STANDARD20_MODULE_STUFF,
- config_perdir_create, /* create per-dir config structures */
- config_perdir_merge, /* merge per-dir config structures */
- config_server_create, /* create per-server config structures */
- config_server_merge, /* merge per-server config structures */
- command_table, /* ap_table_t of config file commands */
- handler_table, /* [#8] MIME-typed-dispatched handlers */
- register_hooks /* register hooks */
-};
-
- /* the cache */
-static cache *cachep;
-
- /* whether proxy module is available or not */
-static int proxy_available;
-static int once_through = 0;
-
-static const char *lockname;
-static ap_file_t *lockfd = NULL;
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | configuration directive handling
-** | |
-** +-------------------------------------------------------+
-*/
-
-/*
-**
-** per-server configuration structure handling
-**
-*/
-
-static void *config_server_create(ap_context_t *p, server_rec *s)
-{
- rewrite_server_conf *a;
-
- a = (rewrite_server_conf *)ap_pcalloc(p, sizeof(rewrite_server_conf));
-
- a->state = ENGINE_DISABLED;
- a->options = OPTION_NONE;
- a->rewritelogfile = NULL;
- a->rewritelogfp = NULL;
- a->rewriteloglevel = 0;
- a->rewritemaps = ap_make_array(p, 2, sizeof(rewritemap_entry));
- a->rewriteconds = ap_make_array(p, 2, sizeof(rewritecond_entry));
- a->rewriterules = ap_make_array(p, 2, sizeof(rewriterule_entry));
- a->server = s;
-
- return (void *)a;
-}
-
-static void *config_server_merge(ap_context_t *p, void *basev, void *overridesv)
-{
- rewrite_server_conf *a, *base, *overrides;
-
- a = (rewrite_server_conf *)ap_pcalloc(p, sizeof(rewrite_server_conf));
- base = (rewrite_server_conf *)basev;
- overrides = (rewrite_server_conf *)overridesv;
-
- a->state = overrides->state;
- a->options = overrides->options;
- a->server = overrides->server;
-
- if (a->options & OPTION_INHERIT) {
- /*
- * local directives override
- * and anything else is inherited
- */
- a->rewriteloglevel = overrides->rewriteloglevel != 0
- ? overrides->rewriteloglevel
- : base->rewriteloglevel;
- a->rewritelogfile = overrides->rewritelogfile != NULL
- ? overrides->rewritelogfile
- : base->rewritelogfile;
- a->rewritelogfp = overrides->rewritelogfp != NULL
- ? overrides->rewritelogfp
- : base->rewritelogfp;
- a->rewritemaps = ap_append_arrays(p, overrides->rewritemaps,
- base->rewritemaps);
- a->rewriteconds = ap_append_arrays(p, overrides->rewriteconds,
- base->rewriteconds);
- a->rewriterules = ap_append_arrays(p, overrides->rewriterules,
- base->rewriterules);
- }
- else {
- /*
- * local directives override
- * and anything else gets defaults
- */
- a->rewriteloglevel = overrides->rewriteloglevel;
- a->rewritelogfile = overrides->rewritelogfile;
- a->rewritelogfp = overrides->rewritelogfp;
- a->rewritemaps = overrides->rewritemaps;
- a->rewriteconds = overrides->rewriteconds;
- a->rewriterules = overrides->rewriterules;
- }
-
- return (void *)a;
-}
-
-
-/*
-**
-** per-directory configuration structure handling
-**
-*/
-
-static void *config_perdir_create(ap_context_t *p, char *path)
-{
- rewrite_perdir_conf *a;
-
- a = (rewrite_perdir_conf *)ap_pcalloc(p, sizeof(rewrite_perdir_conf));
-
- a->state = ENGINE_DISABLED;
- a->options = OPTION_NONE;
- a->baseurl = NULL;
- a->rewriteconds = ap_make_array(p, 2, sizeof(rewritecond_entry));
- a->rewriterules = ap_make_array(p, 2, sizeof(rewriterule_entry));
-
- if (path == NULL) {
- a->directory = NULL;
- }
- else {
- /* make sure it has a trailing slash */
- if (path[strlen(path)-1] == '/') {
- a->directory = ap_pstrdup(p, path);
- }
- else {
- a->directory = ap_pstrcat(p, path, "/", NULL);
- }
- }
-
- return (void *)a;
-}
-
-static void *config_perdir_merge(ap_context_t *p, void *basev, void *overridesv)
-{
- rewrite_perdir_conf *a, *base, *overrides;
-
- a = (rewrite_perdir_conf *)ap_pcalloc(p,
- sizeof(rewrite_perdir_conf));
- base = (rewrite_perdir_conf *)basev;
- overrides = (rewrite_perdir_conf *)overridesv;
-
- a->state = overrides->state;
- a->options = overrides->options;
- a->directory = overrides->directory;
- a->baseurl = overrides->baseurl;
-
- if (a->options & OPTION_INHERIT) {
- a->rewriteconds = ap_append_arrays(p, overrides->rewriteconds,
- base->rewriteconds);
- a->rewriterules = ap_append_arrays(p, overrides->rewriterules,
- base->rewriterules);
- }
- else {
- a->rewriteconds = overrides->rewriteconds;
- a->rewriterules = overrides->rewriterules;
- }
-
- return (void *)a;
-}
-
-
-/*
-**
-** the configuration commands
-**
-*/
-
-static const char *cmd_rewriteengine(cmd_parms *cmd,
- rewrite_perdir_conf *dconf, int flag)
-{
- rewrite_server_conf *sconf;
-
- sconf =
- (rewrite_server_conf *)ap_get_module_config(cmd->server->module_config,
- &rewrite_module);
-
- if (cmd->path == NULL) { /* is server command */
- sconf->state = (flag ? ENGINE_ENABLED : ENGINE_DISABLED);
- }
- else /* is per-directory command */ {
- dconf->state = (flag ? ENGINE_ENABLED : ENGINE_DISABLED);
- }
-
- return NULL;
-}
-
-static const char *cmd_rewriteoptions(cmd_parms *cmd,
- rewrite_perdir_conf *dconf, char *option)
-{
- rewrite_server_conf *sconf;
- const char *err;
-
- sconf = (rewrite_server_conf *)
- ap_get_module_config(cmd->server->module_config, &rewrite_module);
-
- if (cmd->path == NULL) { /* is server command */
- err = cmd_rewriteoptions_setoption(cmd->pool,
- &(sconf->options), option);
- }
- else { /* is per-directory command */
- err = cmd_rewriteoptions_setoption(cmd->pool,
- &(dconf->options), option);
- }
-
- return err;
-}
-
-static const char *cmd_rewriteoptions_setoption(ap_context_t *p, int *options,
- char *name)
-{
- if (strcasecmp(name, "inherit") == 0) {
- *options |= OPTION_INHERIT;
- }
- else {
- return ap_pstrcat(p, "RewriteOptions: unknown option '",
- name, "'\n", NULL);
- }
- return NULL;
-}
-
-static const char *cmd_rewritelog(cmd_parms *cmd, void *dconf, char *a1)
-{
- rewrite_server_conf *sconf;
-
- sconf = (rewrite_server_conf *)
- ap_get_module_config(cmd->server->module_config, &rewrite_module);
-
- sconf->rewritelogfile = a1;
-
- return NULL;
-}
-
-static const char *cmd_rewriteloglevel(cmd_parms *cmd, void *dconf, char *a1)
-{
- rewrite_server_conf *sconf;
-
- sconf = (rewrite_server_conf *)
- ap_get_module_config(cmd->server->module_config, &rewrite_module);
-
- sconf->rewriteloglevel = atoi(a1);
-
- return NULL;
-}
-
-static const char *cmd_rewritemap(cmd_parms *cmd, void *dconf, char *a1,
- char *a2)
-{
- rewrite_server_conf *sconf;
- rewritemap_entry *newmap;
- struct stat st;
-
- sconf = (rewrite_server_conf *)
- ap_get_module_config(cmd->server->module_config, &rewrite_module);
-
- newmap = ap_push_array(sconf->rewritemaps);
-
- newmap->name = a1;
- newmap->func = NULL;
- if (strncmp(a2, "txt:", 4) == 0) {
- newmap->type = MAPTYPE_TXT;
- newmap->datafile = a2+4;
- newmap->checkfile = a2+4;
- }
- else if (strncmp(a2, "rnd:", 4) == 0) {
- newmap->type = MAPTYPE_RND;
- newmap->datafile = a2+4;
- newmap->checkfile = a2+4;
- }
- else if (strncmp(a2, "dbm:", 4) == 0) {
-#ifndef NO_DBM_REWRITEMAP
- newmap->type = MAPTYPE_DBM;
- newmap->datafile = a2+4;
- newmap->checkfile = ap_pstrcat(cmd->pool, a2+4, NDBM_FILE_SUFFIX, NULL);
-#else
- return ap_pstrdup(cmd->pool, "RewriteMap: cannot use NDBM mapfile, "
- "because no NDBM support is compiled in");
-#endif
- }
- else if (strncmp(a2, "prg:", 4) == 0) {
- newmap->type = MAPTYPE_PRG;
- newmap->datafile = a2+4;
- newmap->checkfile = a2+4;
- }
- else if (strncmp(a2, "int:", 4) == 0) {
- newmap->type = MAPTYPE_INT;
- newmap->datafile = NULL;
- newmap->checkfile = NULL;
- if (strcmp(a2+4, "tolower") == 0) {
- newmap->func = rewrite_mapfunc_tolower;
- }
- else if (strcmp(a2+4, "toupper") == 0) {
- newmap->func = rewrite_mapfunc_toupper;
- }
- else if (strcmp(a2+4, "escape") == 0) {
- newmap->func = rewrite_mapfunc_escape;
- }
- else if (strcmp(a2+4, "unescape") == 0) {
- newmap->func = rewrite_mapfunc_unescape;
- }
- else if (sconf->state == ENGINE_ENABLED) {
- return ap_pstrcat(cmd->pool, "RewriteMap: internal map not found:",
- a2+4, NULL);
- }
- }
- else {
- newmap->type = MAPTYPE_TXT;
- newmap->datafile = a2;
- newmap->checkfile = a2;
- }
- newmap->fpin = NULL;
- newmap->fpout = NULL;
-
- if (newmap->checkfile && (sconf->state == ENGINE_ENABLED)
- && (stat(newmap->checkfile, &st) == -1)) {
- return ap_pstrcat(cmd->pool,
- "RewriteMap: map file or program not found:",
- newmap->checkfile, NULL);
- }
-
- return NULL;
-}
-
-static const char *cmd_rewritelock(cmd_parms *cmd, void *dconf, char *a1)
-{
- const char *error;
-
- if ((error = ap_check_cmd_context(cmd, GLOBAL_ONLY)) != NULL)
- return error;
-
- lockname = a1;
-
- return NULL;
-}
-
-static const char *cmd_rewritebase(cmd_parms *cmd, rewrite_perdir_conf *dconf,
- char *a1)
-{
- if (cmd->path == NULL || dconf == NULL) {
- return "RewriteBase: only valid in per-directory config files";
- }
- if (a1[0] == '\0') {
- return "RewriteBase: empty URL not allowed";
- }
- if (a1[0] != '/') {
- return "RewriteBase: argument is not a valid URL";
- }
-
- dconf->baseurl = a1;
-
- return NULL;
-}
-
-static const char *cmd_rewritecond(cmd_parms *cmd, rewrite_perdir_conf *dconf,
- char *str)
-{
- rewrite_server_conf *sconf;
- rewritecond_entry *newcond;
- regex_t *regexp;
- char *a1;
- char *a2;
- char *a3;
- char *cp;
- const char *err;
- int rc;
-
- sconf = (rewrite_server_conf *)
- ap_get_module_config(cmd->server->module_config, &rewrite_module);
-
- /* make a new entry in the internal temporary rewrite rule list */
- if (cmd->path == NULL) { /* is server command */
- newcond = ap_push_array(sconf->rewriteconds);
- }
- else { /* is per-directory command */
- newcond = ap_push_array(dconf->rewriteconds);
- }
-
- /* parse the argument line ourself */
- if (parseargline(str, &a1, &a2, &a3)) {
- return ap_pstrcat(cmd->pool, "RewriteCond: bad argument line '", str,
- "'\n", NULL);
- }
-
- /* arg1: the input string */
- newcond->input = ap_pstrdup(cmd->pool, a1);
-
- /* arg3: optional flags field
- (this have to be first parsed, because we need to
- know if the regex should be compiled with ICASE!) */
- newcond->flags = CONDFLAG_NONE;
- if (a3 != NULL) {
- if ((err = cmd_rewritecond_parseflagfield(cmd->pool, newcond,
- a3)) != NULL) {
- return err;
- }
- }
-
- /* arg2: the pattern
- try to compile the regexp to test if is ok */
- cp = a2;
- if (cp[0] == '!') {
- newcond->flags |= CONDFLAG_NOTMATCH;
- cp++;
- }
-
- /* now be careful: Under the POSIX regex library
- we can compile the pattern for case insensitive matching,
- under the old V8 library we have to do it self via a hack */
- if (newcond->flags & CONDFLAG_NOCASE) {
- rc = ((regexp = ap_pregcomp(cmd->pool, cp, REG_EXTENDED|REG_ICASE))
- == NULL);
- }
- else {
- rc = ((regexp = ap_pregcomp(cmd->pool, cp, REG_EXTENDED)) == NULL);
- }
- if (rc) {
- return ap_pstrcat(cmd->pool,
- "RewriteCond: cannot compile regular expression '",
- a2, "'\n", NULL);
- }
-
- newcond->pattern = ap_pstrdup(cmd->pool, cp);
- newcond->regexp = regexp;
-
- return NULL;
-}
-
-static const char *cmd_rewritecond_parseflagfield(ap_context_t *p,
- rewritecond_entry *cfg,
- char *str)
-{
- char *cp;
- char *cp1;
- char *cp2;
- char *cp3;
- char *key;
- char *val;
- const char *err;
-
- if (str[0] != '[' || str[strlen(str)-1] != ']') {
- return "RewriteCond: bad flag delimiters";
- }
-
- cp = str+1;
- str[strlen(str)-1] = ','; /* for simpler parsing */
- for ( ; *cp != '\0'; ) {
- /* skip whitespaces */
- for ( ; (*cp == ' ' || *cp == '\t') && *cp != '\0'; cp++)
- ;
- if (*cp == '\0') {
- break;
- }
- cp1 = cp;
- if ((cp2 = strchr(cp, ',')) != NULL) {
- cp = cp2+1;
- for ( ; (*(cp2-1) == ' ' || *(cp2-1) == '\t'); cp2--)
- ;
- *cp2 = '\0';
- if ((cp3 = strchr(cp1, '=')) != NULL) {
- *cp3 = '\0';
- key = cp1;
- val = cp3+1;
- }
- else {
- key = cp1;
- val = "";
- }
- if ((err = cmd_rewritecond_setflag(p, cfg, key, val)) != NULL) {
- return err;
- }
- }
- else {
- break;
- }
- }
-
- return NULL;
-}
-
-static const char *cmd_rewritecond_setflag(ap_context_t *p, rewritecond_entry *cfg,
- char *key, char *val)
-{
- if ( strcasecmp(key, "nocase") == 0
- || strcasecmp(key, "NC") == 0 ) {
- cfg->flags |= CONDFLAG_NOCASE;
- }
- else if ( strcasecmp(key, "ornext") == 0
- || strcasecmp(key, "OR") == 0 ) {
- cfg->flags |= CONDFLAG_ORNEXT;
- }
- else {
- return ap_pstrcat(p, "RewriteCond: unknown flag '", key, "'\n", NULL);
- }
- return NULL;
-}
-
-static const char *cmd_rewriterule(cmd_parms *cmd, rewrite_perdir_conf *dconf,
- char *str)
-{
- rewrite_server_conf *sconf;
- rewriterule_entry *newrule;
- regex_t *regexp;
- char *a1;
- char *a2;
- char *a3;
- char *cp;
- const char *err;
- int mode;
-
- sconf = (rewrite_server_conf *)
- ap_get_module_config(cmd->server->module_config, &rewrite_module);
-
- /* make a new entry in the internal rewrite rule list */
- if (cmd->path == NULL) { /* is server command */
- newrule = ap_push_array(sconf->rewriterules);
- }
- else { /* is per-directory command */
- newrule = ap_push_array(dconf->rewriterules);
- }
-
- /* parse the argument line ourself */
- if (parseargline(str, &a1, &a2, &a3)) {
- return ap_pstrcat(cmd->pool, "RewriteRule: bad argument line '", str,
- "'\n", NULL);
- }
-
- /* arg3: optional flags field */
- newrule->forced_mimetype = NULL;
- newrule->forced_responsecode = HTTP_MOVED_TEMPORARILY;
- newrule->flags = RULEFLAG_NONE;
- newrule->env[0] = NULL;
- newrule->skip = 0;
- if (a3 != NULL) {
- if ((err = cmd_rewriterule_parseflagfield(cmd->pool, newrule,
- a3)) != NULL) {
- return err;
- }
- }
-
- /* arg1: the pattern
- * try to compile the regexp to test if is ok
- */
- cp = a1;
- if (cp[0] == '!') {
- newrule->flags |= RULEFLAG_NOTMATCH;
- cp++;
- }
- mode = REG_EXTENDED;
- if (newrule->flags & RULEFLAG_NOCASE) {
- mode |= REG_ICASE;
- }
- if ((regexp = ap_pregcomp(cmd->pool, cp, mode)) == NULL) {
- return ap_pstrcat(cmd->pool,
- "RewriteRule: cannot compile regular expression '",
- a1, "'\n", NULL);
- }
- newrule->pattern = ap_pstrdup(cmd->pool, cp);
- newrule->regexp = regexp;
-
- /* arg2: the output string
- * replace the $<N> by \<n> which is needed by the currently
- * used Regular Expression library
- */
- newrule->output = ap_pstrdup(cmd->pool, a2);
-
- /* now, if the server or per-dir config holds an
- * array of RewriteCond entries, we take it for us
- * and clear the array
- */
- if (cmd->path == NULL) { /* is server command */
- newrule->rewriteconds = sconf->rewriteconds;
- sconf->rewriteconds = ap_make_array(cmd->pool, 2,
- sizeof(rewritecond_entry));
- }
- else { /* is per-directory command */
- newrule->rewriteconds = dconf->rewriteconds;
- dconf->rewriteconds = ap_make_array(cmd->pool, 2,
- sizeof(rewritecond_entry));
- }
-
- return NULL;
-}
-
-static const char *cmd_rewriterule_parseflagfield(ap_context_t *p,
- rewriterule_entry *cfg,
- char *str)
-{
- char *cp;
- char *cp1;
- char *cp2;
- char *cp3;
- char *key;
- char *val;
- const char *err;
-
- if (str[0] != '[' || str[strlen(str)-1] != ']') {
- return "RewriteRule: bad flag delimiters";
- }
-
- cp = str+1;
- str[strlen(str)-1] = ','; /* for simpler parsing */
- for ( ; *cp != '\0'; ) {
- /* skip whitespaces */
- for ( ; (*cp == ' ' || *cp == '\t') && *cp != '\0'; cp++)
- ;
- if (*cp == '\0') {
- break;
- }
- cp1 = cp;
- if ((cp2 = strchr(cp, ',')) != NULL) {
- cp = cp2+1;
- for ( ; (*(cp2-1) == ' ' || *(cp2-1) == '\t'); cp2--)
- ;
- *cp2 = '\0';
- if ((cp3 = strchr(cp1, '=')) != NULL) {
- *cp3 = '\0';
- key = cp1;
- val = cp3+1;
- }
- else {
- key = cp1;
- val = "";
- }
- if ((err = cmd_rewriterule_setflag(p, cfg, key, val)) != NULL) {
- return err;
- }
- }
- else {
- break;
- }
- }
-
- return NULL;
-}
-
-static const char *cmd_rewriterule_setflag(ap_context_t *p, rewriterule_entry *cfg,
- char *key, char *val)
-{
- int status = 0;
- int i;
-
- if ( strcasecmp(key, "redirect") == 0
- || strcasecmp(key, "R") == 0 ) {
- cfg->flags |= RULEFLAG_FORCEREDIRECT;
- if (strlen(val) > 0) {
- if (strcasecmp(val, "permanent") == 0) {
- status = HTTP_MOVED_PERMANENTLY;
- }
- else if (strcasecmp(val, "temp") == 0) {
- status = HTTP_MOVED_TEMPORARILY;
- }
- else if (strcasecmp(val, "seeother") == 0) {
- status = HTTP_SEE_OTHER;
- }
- else if (ap_isdigit(*val)) {
- status = atoi(val);
- }
- if (!ap_is_HTTP_REDIRECT(status)) {
- return "RewriteRule: invalid HTTP response code "
- "for flag 'R'";
- }
- cfg->forced_responsecode = status;
- }
- }
- else if ( strcasecmp(key, "last") == 0
- || strcasecmp(key, "L") == 0 ) {
- cfg->flags |= RULEFLAG_LASTRULE;
- }
- else if ( strcasecmp(key, "next") == 0
- || strcasecmp(key, "N") == 0 ) {
- cfg->flags |= RULEFLAG_NEWROUND;
- }
- else if ( strcasecmp(key, "chain") == 0
- || strcasecmp(key, "C") == 0 ) {
- cfg->flags |= RULEFLAG_CHAIN;
- }
- else if ( strcasecmp(key, "type") == 0
- || strcasecmp(key, "T") == 0 ) {
- cfg->forced_mimetype = ap_pstrdup(p, val);
- ap_str_tolower(cfg->forced_mimetype);
- }
- else if ( strcasecmp(key, "env") == 0
- || strcasecmp(key, "E") == 0 ) {
- for (i = 0; (cfg->env[i] != NULL) && (i < MAX_ENV_FLAGS); i++)
- ;
- if (i < MAX_ENV_FLAGS) {
- cfg->env[i] = ap_pstrdup(p, val);
- cfg->env[i+1] = NULL;
- }
- else {
- return "RewriteRule: too many environment flags 'E'";
- }
- }
- else if ( strcasecmp(key, "nosubreq") == 0
- || strcasecmp(key, "NS") == 0 ) {
- cfg->flags |= RULEFLAG_IGNOREONSUBREQ;
- }
- else if ( strcasecmp(key, "proxy") == 0
- || strcasecmp(key, "P") == 0 ) {
- cfg->flags |= RULEFLAG_PROXY;
- }
- else if ( strcasecmp(key, "passthrough") == 0
- || strcasecmp(key, "PT") == 0 ) {
- cfg->flags |= RULEFLAG_PASSTHROUGH;
- }
- else if ( strcasecmp(key, "skip") == 0
- || strcasecmp(key, "S") == 0 ) {
- cfg->skip = atoi(val);
- }
- else if ( strcasecmp(key, "forbidden") == 0
- || strcasecmp(key, "F") == 0 ) {
- cfg->flags |= RULEFLAG_FORBIDDEN;
- }
- else if ( strcasecmp(key, "gone") == 0
- || strcasecmp(key, "G") == 0 ) {
- cfg->flags |= RULEFLAG_GONE;
- }
- else if ( strcasecmp(key, "qsappend") == 0
- || strcasecmp(key, "QSA") == 0 ) {
- cfg->flags |= RULEFLAG_QSAPPEND;
- }
- else if ( strcasecmp(key, "nocase") == 0
- || strcasecmp(key, "NC") == 0 ) {
- cfg->flags |= RULEFLAG_NOCASE;
- }
- else {
- return ap_pstrcat(p, "RewriteRule: unknown flag '", key, "'\n", NULL);
- }
- return NULL;
-}
-
-
-/*
-**
-** Global Module Initialization
-** [called from read_config() after all
-** config commands were already called]
-**
-*/
-
-static void init_module(ap_context_t *p,
- ap_context_t *plog,
- ap_context_t *ptemp,
- server_rec *s)
-{
- /* check if proxy module is available */
- proxy_available = (ap_find_linked_module("mod_proxy.c") != NULL);
-
- /* create the rewriting lockfile in the parent */
- rewritelock_create(s, p);
- ap_register_cleanup(p, (void *)s, rewritelock_remove, ap_null_cleanup);
-
- /* step through the servers and
- * - open each rewriting logfile
- * - open the RewriteMap prg:xxx programs
- */
- for (; s; s = s->next) {
- open_rewritelog(s, p);
- if (once_through > 0)
- run_rewritemap_programs(s, p);
- }
-
- once_through++;
-}
-
-
-/*
-**
-** Per-Child Module Initialization
-** [called after a child process is spawned]
-**
-*/
-
-static void init_child(ap_context_t *p, server_rec *s)
-{
- /* open the rewriting lockfile */
- rewritelock_open(s, p);
-
- /* create the lookup cache */
- cachep = init_cache(p);
-}
-
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | runtime hooks
-** | |
-** +-------------------------------------------------------+
-*/
-
-/*
-**
-** URI-to-filename hook
-**
-** [used for the rewriting engine triggered by
-** the per-server 'RewriteRule' directives]
-**
-*/
-
-static int hook_uri2file(request_rec *r)
-{
- void *sconf;
- rewrite_server_conf *conf;
- const char *var;
- const char *thisserver;
- char *thisport;
- const char *thisurl;
- char buf[512];
- char docroot[512];
- char *cp, *cp2;
- const char *ccp;
- struct stat finfo;
- unsigned int port;
- int n;
- int l;
-
- /*
- * retrieve the config structures
- */
- sconf = r->server->module_config;
- conf = (rewrite_server_conf *)ap_get_module_config(sconf,
- &rewrite_module);
-
- /*
- * only do something under runtime if the engine is really enabled,
- * else return immediately!
- */
- if (conf->state == ENGINE_DISABLED) {
- return DECLINED;
- }
-
- /*
- * check for the ugly API case of a virtual host section where no
- * mod_rewrite directives exists. In this situation we became no chance
- * by the API to setup our default per-server config so we have to
- * on-the-fly assume we have the default config. But because the default
- * config has a disabled rewriting engine we are lucky because can
- * just stop operating now.
- */
- if (conf->server != r->server) {
- return DECLINED;
- }
-
- /*
- * add the SCRIPT_URL variable to the env. this is a bit complicated
- * due to the fact that apache uses subrequests and internal redirects
- */
-
- if (r->main == NULL) {
- var = ap_pstrcat(r->pool, "REDIRECT_", ENVVAR_SCRIPT_URL, NULL);
- var = ap_table_get(r->subprocess_env, var);
- if (var == NULL) {
- ap_table_setn(r->subprocess_env, ENVVAR_SCRIPT_URL, r->uri);
- }
- else {
- ap_table_setn(r->subprocess_env, ENVVAR_SCRIPT_URL, var);
- }
- }
- else {
- var = ap_table_get(r->main->subprocess_env, ENVVAR_SCRIPT_URL);
- ap_table_setn(r->subprocess_env, ENVVAR_SCRIPT_URL, var);
- }
-
- /*
- * create the SCRIPT_URI variable for the env
- */
-
- /* add the canonical URI of this URL */
- thisserver = ap_get_server_name(r);
- port = ap_get_server_port(r);
- if (ap_is_default_port(port, r)) {
- thisport = "";
- }
- else {
- ap_snprintf(buf, sizeof(buf), ":%u", port);
- thisport = buf;
- }
- thisurl = ap_table_get(r->subprocess_env, ENVVAR_SCRIPT_URL);
-
- /* set the variable */
- var = ap_pstrcat(r->pool, ap_http_method(r), "://", thisserver, thisport,
- thisurl, NULL);
- ap_table_setn(r->subprocess_env, ENVVAR_SCRIPT_URI, var);
-
- /* if filename was not initially set,
- * we start with the requested URI
- */
- if (r->filename == NULL) {
- r->filename = ap_pstrdup(r->pool, r->uri);
- rewritelog(r, 2, "init rewrite engine with requested uri %s",
- r->filename);
- }
-
- /*
- * now apply the rules ...
- */
- if (apply_rewrite_list(r, conf->rewriterules, NULL)) {
-
- if (strlen(r->filename) > 6 &&
- strncmp(r->filename, "proxy:", 6) == 0) {
- /* it should be go on as an internal proxy request */
-
- /* check if the proxy module is enabled, so
- * we can actually use it!
- */
- if (!proxy_available) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "attempt to make remote request from mod_rewrite "
- "without proxy enabled: %s", r->filename);
- return FORBIDDEN;
- }
-
- /* make sure the QUERY_STRING and
- * PATH_INFO parts get incorporated
- */
- if (r->path_info != NULL) {
- r->filename = ap_pstrcat(r->pool, r->filename,
- r->path_info, NULL);
- }
- if (r->args != NULL &&
- r->uri == r->unparsed_uri) {
- /* see proxy_http:proxy_http_canon() */
- r->filename = ap_pstrcat(r->pool, r->filename,
- "?", r->args, NULL);
- }
-
- /* now make sure the request gets handled by the proxy handler */
- r->proxyreq = 1;
- r->handler = "proxy-server";
-
- rewritelog(r, 1, "go-ahead with proxy request %s [OK]",
- r->filename);
- return OK;
- }
- else if ( (strlen(r->filename) > 7 &&
- strncasecmp(r->filename, "http://", 7) == 0)
- || (strlen(r->filename) > 8 &&
- strncasecmp(r->filename, "https://", 8) == 0)
- || (strlen(r->filename) > 9 &&
- strncasecmp(r->filename, "gopher://", 9) == 0)
- || (strlen(r->filename) > 6 &&
- strncasecmp(r->filename, "ftp://", 6) == 0)
- || (strlen(r->filename) > 5 &&
- strncasecmp(r->filename, "ldap:", 5) == 0)
- || (strlen(r->filename) > 5 &&
- strncasecmp(r->filename, "news:", 5) == 0)
- || (strlen(r->filename) > 7 &&
- strncasecmp(r->filename, "mailto:", 7) == 0)) {
- /* it was finally rewritten to a remote URL */
-
- /* skip 'scheme:' */
- for (cp = r->filename; *cp != ':' && *cp != '\0'; cp++)
- ;
- /* skip '://' */
- cp += 3;
- /* skip host part */
- for ( ; *cp != '/' && *cp != '\0'; cp++)
- ;
- if (*cp != '\0') {
- rewritelog(r, 1, "escaping %s for redirect", r->filename);
- cp2 = ap_escape_uri(r->pool, cp);
- *cp = '\0';
- r->filename = ap_pstrcat(r->pool, r->filename, cp2, NULL);
- }
-
- /* append the QUERY_STRING part */
- if (r->args != NULL) {
- r->filename = ap_pstrcat(r->pool, r->filename, "?",
- ap_escape_uri(r->pool, r->args), NULL);
- }
-
- /* determine HTTP redirect response code */
- if (ap_is_HTTP_REDIRECT(r->status)) {
- n = r->status;
- r->status = HTTP_OK; /* make Apache kernel happy */
- }
- else {
- n = REDIRECT;
- }
-
- /* now do the redirection */
- ap_table_setn(r->headers_out, "Location", r->filename);
- rewritelog(r, 1, "redirect to %s [REDIRECT/%d]", r->filename, n);
- return n;
- }
- else if (strlen(r->filename) > 10 &&
- strncmp(r->filename, "forbidden:", 10) == 0) {
- /* This URLs is forced to be forbidden for the requester */
- return FORBIDDEN;
- }
- else if (strlen(r->filename) > 5 &&
- strncmp(r->filename, "gone:", 5) == 0) {
- /* This URLs is forced to be gone */
- return HTTP_GONE;
- }
- else if (strlen(r->filename) > 12 &&
- strncmp(r->filename, "passthrough:", 12) == 0) {
- /*
- * Hack because of underpowered API: passing the current
- * rewritten filename through to other URL-to-filename handlers
- * just as it were the requested URL. This is to enable
- * post-processing by mod_alias, etc. which always act on
- * r->uri! The difference here is: We do not try to
- * add the document root
- */
- r->uri = ap_pstrdup(r->pool, r->filename+12);
- return DECLINED;
- }
- else {
- /* it was finally rewritten to a local path */
-
- /* expand "/~user" prefix */
-#if !defined(WIN32) && !defined(NETWARE)
- r->filename = expand_tildepaths(r, r->filename);
-#endif
- rewritelog(r, 2, "local path result: %s", r->filename);
-
- /* the filename has to start with a slash! */
- if (r->filename[0] != '/') {
- return BAD_REQUEST;
- }
-
- /* if there is no valid prefix, we have
- * to emulate the translator from the core and
- * prefix the filename with document_root
- *
- * NOTICE:
- * We cannot leave out the prefix_stat because
- * - when we always prefix with document_root
- * then no absolute path can be created, e.g. via
- * emulating a ScriptAlias directive, etc.
- * - when we always NOT prefix with document_root
- * then the files under document_root have to
- * be references directly and document_root
- * gets never used and will be a dummy parameter -
- * this is also bad
- *
- * BUT:
- * Under real Unix systems this is no problem,
- * because we only do stat() on the first directory
- * and this gets cached by the kernel for along time!
- */
- n = prefix_stat(r->filename, &finfo);
- if (n == 0) {
- if ((ccp = ap_document_root(r)) != NULL) {
- l = ap_cpystrn(docroot, ccp, sizeof(docroot)) - docroot;
-
- /* always NOT have a trailing slash */
- if (docroot[l-1] == '/') {
- docroot[l-1] = '\0';
- }
- if (r->server->path
- && !strncmp(r->filename, r->server->path,
- r->server->pathlen)) {
- r->filename = ap_pstrcat(r->pool, docroot,
- (r->filename +
- r->server->pathlen), NULL);
- }
- else {
- r->filename = ap_pstrcat(r->pool, docroot,
- r->filename, NULL);
- }
- rewritelog(r, 2, "prefixed with document_root to %s",
- r->filename);
- }
- }
-
- rewritelog(r, 1, "go-ahead with %s [OK]", r->filename);
- return OK;
- }
- }
- else {
- rewritelog(r, 1, "pass through %s", r->filename);
- return DECLINED;
- }
-}
-
-
-/*
-**
-** MIME-type hook
-**
-** [used to support the forced-MIME-type feature]
-**
-*/
-
-static int hook_mimetype(request_rec *r)
-{
- const char *t;
-
- /* now check if we have to force a MIME-type */
- t = ap_table_get(r->notes, REWRITE_FORCED_MIMETYPE_NOTEVAR);
- if (t == NULL) {
- return DECLINED;
- }
- else {
- rewritelog(r, 1, "force filename %s to have MIME-type '%s'",
- r->filename, t);
- r->content_type = t;
- return OK;
- }
-}
-
-
-/*
-**
-** Fixup hook
-**
-** [used for the rewriting engine triggered by
-** the per-directory 'RewriteRule' directives]
-**
-*/
-
-static int hook_fixup(request_rec *r)
-{
- rewrite_perdir_conf *dconf;
- char *cp;
- char *cp2;
- const char *ccp;
- char *prefix;
- int l;
- int n;
- char *ofilename;
-
- dconf = (rewrite_perdir_conf *)ap_get_module_config(r->per_dir_config,
- &rewrite_module);
-
- /* if there is no per-dir config we return immediately */
- if (dconf == NULL) {
- return DECLINED;
- }
-
- /* we shouldn't do anything in subrequests */
- if (r->main != NULL) {
- return DECLINED;
- }
-
- /* if there are no real (i.e. no RewriteRule directives!)
- per-dir config of us, we return also immediately */
- if (dconf->directory == NULL) {
- return DECLINED;
- }
-
- /*
- * only do something under runtime if the engine is really enabled,
- * for this directory, else return immediately!
- */
- if (!(ap_allow_options(r) & (OPT_SYM_LINKS | OPT_SYM_OWNER))) {
- /* FollowSymLinks is mandatory! */
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Options FollowSymLinks or SymLinksIfOwnerMatch is off "
- "which implies that RewriteRule directive is forbidden: "
- "%s", r->filename);
- return FORBIDDEN;
- }
- else {
- /* FollowSymLinks is given, but the user can
- * still turn off the rewriting engine
- */
- if (dconf->state == ENGINE_DISABLED) {
- return DECLINED;
- }
- }
-
- /*
- * remember the current filename before rewriting for later check
- * to prevent deadlooping because of internal redirects
- * on final URL/filename which can be equal to the inital one.
- */
- ofilename = r->filename;
-
- /*
- * now apply the rules ...
- */
- if (apply_rewrite_list(r, dconf->rewriterules, dconf->directory)) {
-
- if (strlen(r->filename) > 6 &&
- strncmp(r->filename, "proxy:", 6) == 0) {
- /* it should go on as an internal proxy request */
-
- /* make sure the QUERY_STRING and
- * PATH_INFO parts get incorporated
- * (r->path_info was already appended by the
- * rewriting engine because of the per-dir context!)
- */
- if (r->args != NULL) {
- r->filename = ap_pstrcat(r->pool, r->filename,
- "?", r->args, NULL);
- }
-
- /* now make sure the request gets handled by the proxy handler */
- r->proxyreq = 1;
- r->handler = "proxy-server";
-
- rewritelog(r, 1, "[per-dir %s] go-ahead with proxy request "
- "%s [OK]", dconf->directory, r->filename);
- return OK;
- }
- else if ( (strlen(r->filename) > 7 &&
- strncasecmp(r->filename, "http://", 7) == 0)
- || (strlen(r->filename) > 8 &&
- strncasecmp(r->filename, "https://", 8) == 0)
- || (strlen(r->filename) > 9 &&
- strncasecmp(r->filename, "gopher://", 9) == 0)
- || (strlen(r->filename) > 6 &&
- strncasecmp(r->filename, "ftp://", 6) == 0)
- || (strlen(r->filename) > 5 &&
- strncasecmp(r->filename, "ldap:", 5) == 0)
- || (strlen(r->filename) > 5 &&
- strncasecmp(r->filename, "news:", 5) == 0)
- || (strlen(r->filename) > 7 &&
- strncasecmp(r->filename, "mailto:", 7) == 0)) {
- /* it was finally rewritten to a remote URL */
-
- /* because we are in a per-dir context
- * first try to replace the directory with its base-URL
- * if there is a base-URL available
- */
- if (dconf->baseurl != NULL) {
- /* skip 'scheme:' */
- for (cp = r->filename; *cp != ':' && *cp != '\0'; cp++)
- ;
- /* skip '://' */
- cp += 3;
- if ((cp = strchr(cp, '/')) != NULL) {
- rewritelog(r, 2,
- "[per-dir %s] trying to replace "
- "prefix %s with %s",
- dconf->directory, dconf->directory,
- dconf->baseurl);
- cp2 = subst_prefix_path(r, cp, dconf->directory,
- dconf->baseurl);
- if (strcmp(cp2, cp) != 0) {
- *cp = '\0';
- r->filename = ap_pstrcat(r->pool, r->filename,
- cp2, NULL);
- }
- }
- }
-
- /* now prepare the redirect... */
-
- /* skip 'scheme:' */
- for (cp = r->filename; *cp != ':' && *cp != '\0'; cp++)
- ;
- /* skip '://' */
- cp += 3;
- /* skip host part */
- for ( ; *cp != '/' && *cp != '\0'; cp++)
- ;
- if (*cp != '\0') {
- rewritelog(r, 1, "[per-dir %s] escaping %s for redirect",
- dconf->directory, r->filename);
- cp2 = ap_escape_uri(r->pool, cp);
- *cp = '\0';
- r->filename = ap_pstrcat(r->pool, r->filename, cp2, NULL);
- }
-
- /* append the QUERY_STRING part */
- if (r->args != NULL) {
- r->filename = ap_pstrcat(r->pool, r->filename, "?",
- ap_escape_uri(r->pool, r->args), NULL);
- }
-
- /* determine HTTP redirect response code */
- if (ap_is_HTTP_REDIRECT(r->status)) {
- n = r->status;
- r->status = HTTP_OK; /* make Apache kernel happy */
- }
- else {
- n = REDIRECT;
- }
-
- /* now do the redirection */
- ap_table_setn(r->headers_out, "Location", r->filename);
- rewritelog(r, 1, "[per-dir %s] redirect to %s [REDIRECT/%d]",
- dconf->directory, r->filename, n);
- return n;
- }
- else if (strlen(r->filename) > 10 &&
- strncmp(r->filename, "forbidden:", 10) == 0) {
- /* This URL is forced to be forbidden for the requester */
- return FORBIDDEN;
- }
- else if (strlen(r->filename) > 5 &&
- strncmp(r->filename, "gone:", 5) == 0) {
- /* This URL is forced to be gone */
- return HTTP_GONE;
- }
- else {
- /* it was finally rewritten to a local path */
-
- /* if someone used the PASSTHROUGH flag in per-dir
- * context we just ignore it. It is only useful
- * in per-server context
- */
- if (strlen(r->filename) > 12 &&
- strncmp(r->filename, "passthrough:", 12) == 0) {
- r->filename = ap_pstrdup(r->pool, r->filename+12);
- }
-
- /* the filename has to start with a slash! */
- if (r->filename[0] != '/') {
- return BAD_REQUEST;
- }
-
- /* Check for deadlooping:
- * At this point we KNOW that at least one rewriting
- * rule was applied, but when the resulting URL is
- * the same as the initial URL, we are not allowed to
- * use the following internal redirection stuff because
- * this would lead to a deadloop.
- */
- if (strcmp(r->filename, ofilename) == 0) {
- rewritelog(r, 1, "[per-dir %s] initial URL equal rewritten "
- "URL: %s [IGNORING REWRITE]",
- dconf->directory, r->filename);
- return OK;
- }
-
- /* if there is a valid base-URL then substitute
- * the per-dir prefix with this base-URL if the
- * current filename still is inside this per-dir
- * context. If not then treat the result as a
- * plain URL
- */
- if (dconf->baseurl != NULL) {
- rewritelog(r, 2,
- "[per-dir %s] trying to replace prefix %s with %s",
- dconf->directory, dconf->directory, dconf->baseurl);
- r->filename = subst_prefix_path(r, r->filename,
- dconf->directory,
- dconf->baseurl);
- }
- else {
- /* if no explicit base-URL exists we assume
- * that the directory prefix is also a valid URL
- * for this webserver and only try to remove the
- * document_root if it is prefix
- */
- if ((ccp = ap_document_root(r)) != NULL) {
- prefix = ap_pstrdup(r->pool, ccp);
- /* always NOT have a trailing slash */
- l = strlen(prefix);
- if (prefix[l-1] == '/') {
- prefix[l-1] = '\0';
- l--;
- }
- if (strncmp(r->filename, prefix, l) == 0) {
- rewritelog(r, 2,
- "[per-dir %s] strip document_root "
- "prefix: %s -> %s",
- dconf->directory, r->filename,
- r->filename+l);
- r->filename = ap_pstrdup(r->pool, r->filename+l);
- }
- }
- }
-
- /* now initiate the internal redirect */
- rewritelog(r, 1, "[per-dir %s] internal redirect with %s "
- "[INTERNAL REDIRECT]", dconf->directory, r->filename);
- r->filename = ap_pstrcat(r->pool, "redirect:", r->filename, NULL);
- r->handler = "redirect-handler";
- return OK;
- }
- }
- else {
- rewritelog(r, 1, "[per-dir %s] pass through %s",
- dconf->directory, r->filename);
- return DECLINED;
- }
-}
-
-
-/*
-**
-** Content-Handlers
-**
-** [used for redirect support]
-**
-*/
-
-static int handler_redirect(request_rec *r)
-{
- /* just make sure that we are really meant! */
- if (strncmp(r->filename, "redirect:", 9) != 0) {
- return DECLINED;
- }
-
- /* now do the internal redirect */
- ap_internal_redirect(ap_pstrcat(r->pool, r->filename+9,
- r->args ? "?" : NULL, r->args, NULL), r);
-
- /* and return gracefully */
- return OK;
-}
-
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | the rewriting engine
-** | |
-** +-------------------------------------------------------+
-*/
-
-/*
- * Apply a complete rule set,
- * i.e. a list of rewrite rules
- */
-static int apply_rewrite_list(request_rec *r, ap_array_header_t *rewriterules,
- char *perdir)
-{
- rewriterule_entry *entries;
- rewriterule_entry *p;
- int i;
- int changed;
- int rc;
- int s;
-
- /*
- * Iterate over all existing rules
- */
- entries = (rewriterule_entry *)rewriterules->elts;
- changed = 0;
- loop:
- for (i = 0; i < rewriterules->nelts; i++) {
- p = &entries[i];
-
- /*
- * Ignore this rule on subrequests if we are explicitly
- * asked to do so or this is a proxy-throughput or a
- * forced redirect rule.
- */
- if (r->main != NULL &&
- (p->flags & RULEFLAG_IGNOREONSUBREQ ||
- p->flags & RULEFLAG_PROXY ||
- p->flags & RULEFLAG_FORCEREDIRECT )) {
- continue;
- }
-
- /*
- * Apply the current rule.
- */
- rc = apply_rewrite_rule(r, p, perdir);
- if (rc) {
- /*
- * Indicate a change if this was not a match-only rule.
- */
- if (rc != 2) {
- changed = 1;
- }
-
- /*
- * Pass-Through Feature (`RewriteRule .. .. [PT]'):
- * Because the Apache 1.x API is very limited we
- * need this hack to pass the rewritten URL to other
- * modules like mod_alias, mod_userdir, etc.
- */
- if (p->flags & RULEFLAG_PASSTHROUGH) {
- rewritelog(r, 2, "forcing '%s' to get passed through "
- "to next API URI-to-filename handler", r->filename);
- r->filename = ap_pstrcat(r->pool, "passthrough:",
- r->filename, NULL);
- changed = 1;
- break;
- }
-
- /*
- * Rule has the "forbidden" flag set which means that
- * we stop processing and indicate this to the caller.
- */
- if (p->flags & RULEFLAG_FORBIDDEN) {
- rewritelog(r, 2, "forcing '%s' to be forbidden", r->filename);
- r->filename = ap_pstrcat(r->pool, "forbidden:",
- r->filename, NULL);
- changed = 1;
- break;
- }
-
- /*
- * Rule has the "gone" flag set which means that
- * we stop processing and indicate this to the caller.
- */
- if (p->flags & RULEFLAG_GONE) {
- rewritelog(r, 2, "forcing '%s' to be gone", r->filename);
- r->filename = ap_pstrcat(r->pool, "gone:", r->filename, NULL);
- changed = 1;
- break;
- }
-
- /*
- * Stop processing also on proxy pass-through and
- * last-rule and new-round flags.
- */
- if (p->flags & RULEFLAG_PROXY) {
- break;
- }
- if (p->flags & RULEFLAG_LASTRULE) {
- break;
- }
-
- /*
- * On "new-round" flag we just start from the top of
- * the rewriting ruleset again.
- */
- if (p->flags & RULEFLAG_NEWROUND) {
- goto loop;
- }
-
- /*
- * If we are forced to skip N next rules, do it now.
- */
- if (p->skip > 0) {
- s = p->skip;
- while ( i < rewriterules->nelts
- && s > 0) {
- i++;
- p = &entries[i];
- s--;
- }
- }
- }
- else {
- /*
- * If current rule is chained with next rule(s),
- * skip all this next rule(s)
- */
- while ( i < rewriterules->nelts
- && p->flags & RULEFLAG_CHAIN) {
- i++;
- p = &entries[i];
- }
- }
- }
- return changed;
-}
-
-/*
- * Apply a single(!) rewrite rule
- */
-static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p,
- char *perdir)
-{
- char *uri;
- char *output;
- const char *vary;
- char newuri[MAX_STRING_LEN];
- char env[MAX_STRING_LEN];
- regex_t *regexp;
- regmatch_t regmatch[MAX_NMATCH];
- backrefinfo *briRR = NULL;
- backrefinfo *briRC = NULL;
- int prefixstrip;
- int failed;
- ap_array_header_t *rewriteconds;
- rewritecond_entry *conds;
- rewritecond_entry *c;
- int i;
- int rc;
-
- /*
- * Initialisation
- */
- uri = r->filename;
- regexp = p->regexp;
- output = p->output;
-
- /*
- * Add (perhaps splitted away) PATH_INFO postfix to URL to
- * make sure we really match against the complete URL.
- */
- if (perdir != NULL && r->path_info != NULL && r->path_info[0] != '\0') {
- rewritelog(r, 3, "[per-dir %s] add path info postfix: %s -> %s%s",
- perdir, uri, uri, r->path_info);
- uri = ap_pstrcat(r->pool, uri, r->path_info, NULL);
- }
-
- /*
- * On per-directory context (.htaccess) strip the location
- * prefix from the URL to make sure patterns apply only to
- * the local part. Additionally indicate this special
- * threatment in the logfile.
- */
- prefixstrip = 0;
- if (perdir != NULL) {
- if ( strlen(uri) >= strlen(perdir)
- && strncmp(uri, perdir, strlen(perdir)) == 0) {
- rewritelog(r, 3, "[per-dir %s] strip per-dir prefix: %s -> %s",
- perdir, uri, uri+strlen(perdir));
- uri = uri+strlen(perdir);
- prefixstrip = 1;
- }
- }
-
- /*
- * Try to match the URI against the RewriteRule pattern
- * and exit immeddiately if it didn't apply.
- */
- if (perdir == NULL) {
- rewritelog(r, 3, "applying pattern '%s' to uri '%s'",
- p->pattern, uri);
- }
- else {
- rewritelog(r, 3, "[per-dir %s] applying pattern '%s' to uri '%s'",
- perdir, p->pattern, uri);
- }
- rc = (ap_regexec(regexp, uri, regexp->re_nsub+1, regmatch, 0) == 0);
- if (! (( rc && !(p->flags & RULEFLAG_NOTMATCH)) ||
- (!rc && (p->flags & RULEFLAG_NOTMATCH)) ) ) {
- return 0;
- }
-
- /*
- * Else create the RewriteRule `regsubinfo' structure which
- * holds the substitution information.
- */
- briRR = (backrefinfo *)ap_palloc(r->pool, sizeof(backrefinfo));
- if (!rc && (p->flags & RULEFLAG_NOTMATCH)) {
- /* empty info on negative patterns */
- briRR->source = "";
- briRR->nsub = 0;
- }
- else {
- briRR->source = ap_pstrdup(r->pool, uri);
- briRR->nsub = regexp->re_nsub;
- memcpy((void *)(briRR->regmatch), (void *)(regmatch),
- sizeof(regmatch));
- }
-
- /*
- * Initiallally create the RewriteCond backrefinfo with
- * empty backrefinfo, i.e. not subst parts
- * (this one is adjusted inside apply_rewrite_cond() later!!)
- */
- briRC = (backrefinfo *)ap_pcalloc(r->pool, sizeof(backrefinfo));
- briRC->source = "";
- briRC->nsub = 0;
-
- /*
- * Ok, we already know the pattern has matched, but we now
- * additionally have to check for all existing preconditions
- * (RewriteCond) which have to be also true. We do this at
- * this very late stage to avoid unnessesary checks which
- * would slow down the rewriting engine!!
- */
- rewriteconds = p->rewriteconds;
- conds = (rewritecond_entry *)rewriteconds->elts;
- failed = 0;
- for (i = 0; i < rewriteconds->nelts; i++) {
- c = &conds[i];
- rc = apply_rewrite_cond(r, c, perdir, briRR, briRC);
- if (c->flags & CONDFLAG_ORNEXT) {
- /*
- * The "OR" case
- */
- if (rc == 0) {
- /* One condition is false, but another can be
- * still true, so we have to continue...
- */
- ap_table_unset(r->notes, VARY_KEY_THIS);
- continue;
- }
- else {
- /* One true condition is enough in "or" case, so
- * skip the other conditions which are "ornext"
- * chained
- */
- while ( i < rewriteconds->nelts
- && c->flags & CONDFLAG_ORNEXT) {
- i++;
- c = &conds[i];
- }
- continue;
- }
- }
- else {
- /*
- * The "AND" case, i.e. no "or" flag,
- * so a single failure means total failure.
- */
- if (rc == 0) {
- failed = 1;
- break;
- }
- }
- vary = ap_table_get(r->notes, VARY_KEY_THIS);
- if (vary != NULL) {
- ap_table_merge(r->notes, VARY_KEY, vary);
- ap_table_unset(r->notes, VARY_KEY_THIS);
- }
- }
- /* if any condition fails the complete rule fails */
- if (failed) {
- ap_table_unset(r->notes, VARY_KEY);
- ap_table_unset(r->notes, VARY_KEY_THIS);
- return 0;
- }
-
- /*
- * Regardless of what we do next, we've found a match. Check to see
- * if any of the request header fields were involved, and add them
- * to the Vary field of the response.
- */
- if ((vary = ap_table_get(r->notes, VARY_KEY)) != NULL) {
- ap_table_merge(r->headers_out, "Vary", vary);
- ap_table_unset(r->notes, VARY_KEY);
- }
-
- /*
- * If this is a pure matching rule (`RewriteRule <pat> -')
- * we stop processing and return immediately. The only thing
- * we have not to forget are the environment variables
- * (`RewriteRule <pat> - [E=...]')
- */
- if (strcmp(output, "-") == 0) {
- for (i = 0; p->env[i] != NULL; i++) {
- /* 1. take the string */
- ap_cpystrn(env, p->env[i], sizeof(env));
- /* 2. expand $N (i.e. backrefs to RewriteRule pattern) */
- expand_backref_inbuffer(r->pool, env, sizeof(env), briRR, '$');
- /* 3. expand %N (i.e. backrefs to latest RewriteCond pattern) */
- expand_backref_inbuffer(r->pool, env, sizeof(env), briRC, '%');
- /* 4. expand %{...} (i.e. variables) */
- expand_variables_inbuffer(r, env, sizeof(env));
- /* 5. expand ${...} (RewriteMap lookups) */
- expand_map_lookups(r, env, sizeof(env));
- /* and add the variable to Apache's structures */
- add_env_variable(r, env);
- }
- if (p->forced_mimetype != NULL) {
- if (perdir == NULL) {
- /* In the per-server context we can force the MIME-type
- * the correct way by notifying our MIME-type hook handler
- * to do the job when the MIME-type API stage is reached.
- */
- rewritelog(r, 2, "remember %s to have MIME-type '%s'",
- r->filename, p->forced_mimetype);
- ap_table_setn(r->notes, REWRITE_FORCED_MIMETYPE_NOTEVAR,
- p->forced_mimetype);
- }
- else {
- /* In per-directory context we operate in the Fixup API hook
- * which is after the MIME-type hook, so our MIME-type handler
- * has no chance to set r->content_type. And because we are
- * in the situation where no substitution takes place no
- * sub-request will happen (which could solve the
- * restriction). As a workaround we do it ourself now
- * immediately although this is not strictly API-conforming.
- * But it's the only chance we have...
- */
- rewritelog(r, 1, "[per-dir %s] force %s to have MIME-type "
- "'%s'", perdir, r->filename, p->forced_mimetype);
- r->content_type = p->forced_mimetype;
- }
- }
- return 2;
- }
-
- /*
- * Ok, now we finally know all patterns have matched and
- * that there is something to replace, so we create the
- * substitution URL string in `newuri'.
- */
- /* 1. take the output string */
- ap_cpystrn(newuri, output, sizeof(newuri));
- /* 2. expand $N (i.e. backrefs to RewriteRule pattern) */
- expand_backref_inbuffer(r->pool, newuri, sizeof(newuri), briRR, '$');
- /* 3. expand %N (i.e. backrefs to latest RewriteCond pattern) */
- expand_backref_inbuffer(r->pool, newuri, sizeof(newuri), briRC, '%');
- /* 4. expand %{...} (i.e. variables) */
- expand_variables_inbuffer(r, newuri, sizeof(newuri));
- /* 5. expand ${...} (RewriteMap lookups) */
- expand_map_lookups(r, newuri, sizeof(newuri));
- /* and log the result... */
- if (perdir == NULL) {
- rewritelog(r, 2, "rewrite %s -> %s", uri, newuri);
- }
- else {
- rewritelog(r, 2, "[per-dir %s] rewrite %s -> %s", perdir, uri, newuri);
- }
-
- /*
- * Additionally do expansion for the environment variable
- * strings (`RewriteRule .. .. [E=<string>]').
- */
- for (i = 0; p->env[i] != NULL; i++) {
- /* 1. take the string */
- ap_cpystrn(env, p->env[i], sizeof(env));
- /* 2. expand $N (i.e. backrefs to RewriteRule pattern) */
- expand_backref_inbuffer(r->pool, env, sizeof(env), briRR, '$');
- /* 3. expand %N (i.e. backrefs to latest RewriteCond pattern) */
- expand_backref_inbuffer(r->pool, env, sizeof(env), briRC, '%');
- /* 4. expand %{...} (i.e. variables) */
- expand_variables_inbuffer(r, env, sizeof(env));
- /* 5. expand ${...} (RewriteMap lookups) */
- expand_map_lookups(r, env, sizeof(env));
- /* and add the variable to Apache's structures */
- add_env_variable(r, env);
- }
-
- /*
- * Now replace API's knowledge of the current URI:
- * Replace r->filename with the new URI string and split out
- * an on-the-fly generated QUERY_STRING part into r->args
- */
- r->filename = ap_pstrdup(r->pool, newuri);
- splitout_queryargs(r, p->flags & RULEFLAG_QSAPPEND);
-
- /*
- * Again add the previously stripped per-directory location
- * prefix if the new URI is not a new one for this
- * location, i.e. if it's not starting with either a slash
- * or a fully qualified URL scheme.
- */
- i = strlen(r->filename);
- if ( prefixstrip
- && !( r->filename[0] == '/'
- || ( (i > 7 && strncasecmp(r->filename, "http://", 7) == 0)
- || (i > 8 && strncasecmp(r->filename, "https://", 8) == 0)
- || (i > 9 && strncasecmp(r->filename, "gopher://", 9) == 0)
- || (i > 6 && strncasecmp(r->filename, "ftp://", 6) == 0)
- || (i > 5 && strncasecmp(r->filename, "ldap:", 5) == 0)
- || (i > 5 && strncasecmp(r->filename, "news:", 5) == 0)
- || (i > 7 && strncasecmp(r->filename, "mailto:", 7) == 0)))) {
- rewritelog(r, 3, "[per-dir %s] add per-dir prefix: %s -> %s%s",
- perdir, r->filename, perdir, r->filename);
- r->filename = ap_pstrcat(r->pool, perdir, r->filename, NULL);
- }
-
- /*
- * If this rule is forced for proxy throughput
- * (`RewriteRule ... ... [P]') then emulate mod_proxy's
- * URL-to-filename handler to be sure mod_proxy is triggered
- * for this URL later in the Apache API. But make sure it is
- * a fully-qualified URL. (If not it is qualified with
- * ourself).
- */
- if (p->flags & RULEFLAG_PROXY) {
- fully_qualify_uri(r);
- if (perdir == NULL) {
- rewritelog(r, 2, "forcing proxy-throughput with %s", r->filename);
- }
- else {
- rewritelog(r, 2, "[per-dir %s] forcing proxy-throughput with %s",
- perdir, r->filename);
- }
- r->filename = ap_pstrcat(r->pool, "proxy:", r->filename, NULL);
- return 1;
- }
-
- /*
- * If this rule is explicitly forced for HTTP redirection
- * (`RewriteRule .. .. [R]') then force an external HTTP
- * redirect. But make sure it is a fully-qualified URL. (If
- * not it is qualified with ourself).
- */
- if (p->flags & RULEFLAG_FORCEREDIRECT) {
- fully_qualify_uri(r);
- if (perdir == NULL) {
- rewritelog(r, 2,
- "explicitly forcing redirect with %s", r->filename);
- }
- else {
- rewritelog(r, 2,
- "[per-dir %s] explicitly forcing redirect with %s",
- perdir, r->filename);
- }
- r->status = p->forced_responsecode;
- return 1;
- }
-
- /*
- * Special Rewriting Feature: Self-Reduction
- * We reduce the URL by stripping a possible
- * http[s]://<ourhost>[:<port>] prefix, i.e. a prefix which
- * corresponds to ourself. This is to simplify rewrite maps
- * and to avoid recursion, etc. When this prefix is not a
- * coincidence then the user has to use [R] explicitly (see
- * above).
- */
- reduce_uri(r);
-
- /*
- * If this rule is still implicitly forced for HTTP
- * redirection (`RewriteRule .. <scheme>://...') then
- * directly force an external HTTP redirect.
- */
- i = strlen(r->filename);
- if ( (i > 7 && strncasecmp(r->filename, "http://", 7) == 0)
- || (i > 8 && strncasecmp(r->filename, "https://", 8) == 0)
- || (i > 9 && strncasecmp(r->filename, "gopher://", 9) == 0)
- || (i > 6 && strncasecmp(r->filename, "ftp://", 6) == 0)
- || (i > 5 && strncasecmp(r->filename, "ldap:", 5) == 0)
- || (i > 5 && strncasecmp(r->filename, "news:", 5) == 0)
- || (i > 7 && strncasecmp(r->filename, "mailto:", 7) == 0) ) {
- if (perdir == NULL) {
- rewritelog(r, 2,
- "implicitly forcing redirect (rc=%d) with %s",
- p->forced_responsecode, r->filename);
- }
- else {
- rewritelog(r, 2, "[per-dir %s] implicitly forcing redirect "
- "(rc=%d) with %s", perdir, p->forced_responsecode,
- r->filename);
- }
- r->status = p->forced_responsecode;
- return 1;
- }
-
- /*
- * Now we are sure it is not a fully qualified URL. But
- * there is still one special case left: A local rewrite in
- * per-directory context, i.e. a substitution URL which does
- * not start with a slash. Here we add again the initially
- * stripped per-directory prefix.
- */
- if (prefixstrip && r->filename[0] != '/') {
- rewritelog(r, 3, "[per-dir %s] add per-dir prefix: %s -> %s%s",
- perdir, r->filename, perdir, r->filename);
- r->filename = ap_pstrcat(r->pool, perdir, r->filename, NULL);
- }
-
- /*
- * Finally we had to remember if a MIME-type should be
- * forced for this URL (`RewriteRule .. .. [T=<type>]')
- * Later in the API processing phase this is forced by our
- * MIME API-hook function. This time its no problem even for
- * the per-directory context (where the MIME-type hook was
- * already processed) because a sub-request happens ;-)
- */
- if (p->forced_mimetype != NULL) {
- ap_table_setn(r->notes, REWRITE_FORCED_MIMETYPE_NOTEVAR,
- p->forced_mimetype);
- if (perdir == NULL) {
- rewritelog(r, 2, "remember %s to have MIME-type '%s'",
- r->filename, p->forced_mimetype);
- }
- else {
- rewritelog(r, 2,
- "[per-dir %s] remember %s to have MIME-type '%s'",
- perdir, r->filename, p->forced_mimetype);
- }
- }
-
- /*
- * Puuhhhhhhhh... WHAT COMPLICATED STUFF ;_)
- * But now we're done for this particular rule.
- */
- return 1;
-}
-
-static int apply_rewrite_cond(request_rec *r, rewritecond_entry *p,
- char *perdir, backrefinfo *briRR,
- backrefinfo *briRC)
-{
- char input[MAX_STRING_LEN];
- struct stat sb;
- request_rec *rsub;
- regmatch_t regmatch[MAX_NMATCH];
- int rc;
-
- /*
- * Construct the string we match against
- */
-
- /* 1. take the string */
- ap_cpystrn(input, p->input, sizeof(input));
- /* 2. expand $N (i.e. backrefs to RewriteRule pattern) */
- expand_backref_inbuffer(r->pool, input, sizeof(input), briRR, '$');
- /* 3. expand %N (i.e. backrefs to latest RewriteCond pattern) */
- expand_backref_inbuffer(r->pool, input, sizeof(input), briRC, '%');
- /* 4. expand %{...} (i.e. variables) */
- expand_variables_inbuffer(r, input, sizeof(input));
- /* 5. expand ${...} (RewriteMap lookups) */
- expand_map_lookups(r, input, sizeof(input));
-
- /*
- * Apply the patterns
- */
-
- rc = 0;
- if (strcmp(p->pattern, "-f") == 0) {
- if (stat(input, &sb) == 0) {
- if (S_ISREG(sb.st_mode)) {
- rc = 1;
- }
- }
- }
- else if (strcmp(p->pattern, "-s") == 0) {
- if (stat(input, &sb) == 0) {
- if (S_ISREG(sb.st_mode) && sb.st_size > 0) {
- rc = 1;
- }
- }
- }
- else if (strcmp(p->pattern, "-l") == 0) {
-#if !defined(OS2) && !defined(WIN32)
- if (lstat(input, &sb) == 0) {
- if (S_ISLNK(sb.st_mode)) {
- rc = 1;
- }
- }
-#endif
- }
- else if (strcmp(p->pattern, "-d") == 0) {
- if (stat(input, &sb) == 0) {
- if (S_ISDIR(sb.st_mode)) {
- rc = 1;
- }
- }
- }
- else if (strcmp(p->pattern, "-U") == 0) {
- /* avoid infinite subrequest recursion */
- if (strlen(input) > 0 /* nonempty path, and */
- && ( r->main == NULL /* - either not in a subrequest */
- || ( r->main->uri != NULL /* - or in a subrequest... */
- && r->uri != NULL /* ...and URIs aren't NULL... */
- /* ...and sub/main URIs differ */
- && strcmp(r->main->uri, r->uri) != 0) ) ) {
-
- /* run a URI-based subrequest */
- rsub = ap_sub_req_lookup_uri(input, r);
-
- /* URI exists for any result up to 3xx, redirects allowed */
- if (rsub->status < 400)
- rc = 1;
-
- /* log it */
- rewritelog(r, 5, "RewriteCond URI (-U) check: "
- "path=%s -> status=%d", input, rsub->status);
-
- /* cleanup by destroying the subrequest */
- ap_destroy_sub_req(rsub);
- }
- }
- else if (strcmp(p->pattern, "-F") == 0) {
- /* avoid infinite subrequest recursion */
- if (strlen(input) > 0 /* nonempty path, and */
- && ( r->main == NULL /* - either not in a subrequest */
- || ( r->main->uri != NULL /* - or in a subrequest... */
- && r->uri != NULL /* ...and URIs aren't NULL... */
- /* ...and sub/main URIs differ */
- && strcmp(r->main->uri, r->uri) != 0) ) ) {
-
- /* process a file-based subrequest:
- * this differs from -U in that no path translation is done.
- */
- rsub = ap_sub_req_lookup_file(input, r);
-
- /* file exists for any result up to 2xx, no redirects */
- if (rsub->status < 300 &&
- /* double-check that file exists since default result is 200 */
- stat(rsub->filename, &sb) == 0) {
- rc = 1;
- }
-
- /* log it */
- rewritelog(r, 5, "RewriteCond file (-F) check: path=%s "
- "-> file=%s status=%d", input, rsub->filename,
- rsub->status);
-
- /* cleanup by destroying the subrequest */
- ap_destroy_sub_req(rsub);
- }
- }
- else if (strlen(p->pattern) > 1 && *(p->pattern) == '>') {
- rc = (compare_lexicography(input, p->pattern+1) == 1 ? 1 : 0);
- }
- else if (strlen(p->pattern) > 1 && *(p->pattern) == '<') {
- rc = (compare_lexicography(input, p->pattern+1) == -1 ? 1 : 0);
- }
- else if (strlen(p->pattern) > 1 && *(p->pattern) == '=') {
- if (strcmp(p->pattern+1, "\"\"") == 0) {
- rc = (*input == '\0');
- }
- else {
- rc = (strcmp(input, p->pattern+1) == 0 ? 1 : 0);
- }
- }
- else {
- /* it is really a regexp pattern, so apply it */
- rc = (ap_regexec(p->regexp, input,
- p->regexp->re_nsub+1, regmatch,0) == 0);
-
- /* if it isn't a negated pattern and really matched
- we update the passed-through regex subst info structure */
- if (rc && !(p->flags & CONDFLAG_NOTMATCH)) {
- briRC->source = ap_pstrdup(r->pool, input);
- briRC->nsub = p->regexp->re_nsub;
- memcpy((void *)(briRC->regmatch), (void *)(regmatch),
- sizeof(regmatch));
- }
- }
-
- /* if this is a non-matching regexp, just negate the result */
- if (p->flags & CONDFLAG_NOTMATCH) {
- rc = !rc;
- }
-
- rewritelog(r, 4, "RewriteCond: input='%s' pattern='%s%s' => %s",
- input, (p->flags & CONDFLAG_NOTMATCH ? "!" : ""),
- p->pattern, rc ? "matched" : "not-matched");
-
- /* end just return the result */
- return rc;
-}
-
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | URL transformation functions
-** | |
-** +-------------------------------------------------------+
-*/
-
-/*
-**
-** split out a QUERY_STRING part from
-** the current URI string
-**
-*/
-
-static void splitout_queryargs(request_rec *r, int qsappend)
-{
- char *q;
- char *olduri;
-
- q = strchr(r->filename, '?');
- if (q != NULL) {
- olduri = ap_pstrdup(r->pool, r->filename);
- *q++ = '\0';
- if (qsappend) {
- r->args = ap_pstrcat(r->pool, q, "&", r->args, NULL);
- }
- else {
- r->args = ap_pstrdup(r->pool, q);
- }
- if (strlen(r->args) == 0) {
- r->args = NULL;
- rewritelog(r, 3, "split uri=%s -> uri=%s, args=<none>", olduri,
- r->filename);
- }
- else {
- if (r->args[strlen(r->args)-1] == '&') {
- r->args[strlen(r->args)-1] = '\0';
- }
- rewritelog(r, 3, "split uri=%s -> uri=%s, args=%s", olduri,
- r->filename, r->args);
- }
- }
- return;
-}
-
-
-/*
-**
-** strip 'http[s]://ourhost/' from URI
-**
-*/
-
-static void reduce_uri(request_rec *r)
-{
- char *cp;
- unsigned short port;
- char *portp;
- char *hostp;
- char *url;
- char c;
- char host[LONG_STRING_LEN];
- char buf[MAX_STRING_LEN];
- char *olduri;
- int l;
-
- cp = (char *)ap_http_method(r);
- l = strlen(cp);
- if ( strlen(r->filename) > l+3
- && strncasecmp(r->filename, cp, l) == 0
- && r->filename[l] == ':'
- && r->filename[l+1] == '/'
- && r->filename[l+2] == '/' ) {
- /* there was really a rewrite to a remote path */
-
- olduri = ap_pstrdup(r->pool, r->filename); /* save for logging */
-
- /* cut the hostname and port out of the URI */
- ap_cpystrn(buf, r->filename+(l+3), sizeof(buf));
- hostp = buf;
- for (cp = hostp; *cp != '\0' && *cp != '/' && *cp != ':'; cp++)
- ;
- if (*cp == ':') {
- /* set host */
- *cp++ = '\0';
- ap_cpystrn(host, hostp, sizeof(host));
- /* set port */
- portp = cp;
- for (; *cp != '\0' && *cp != '/'; cp++)
- ;
- c = *cp;
- *cp = '\0';
- port = atoi(portp);
- *cp = c;
- /* set remaining url */
- url = cp;
- }
- else if (*cp == '/') {
- /* set host */
- *cp = '\0';
- ap_cpystrn(host, hostp, sizeof(host));
- *cp = '/';
- /* set port */
- port = ap_default_port(r);
- /* set remaining url */
- url = cp;
- }
- else {
- /* set host */
- ap_cpystrn(host, hostp, sizeof(host));
- /* set port */
- port = ap_default_port(r);
- /* set remaining url */
- url = "/";
- }
-
- /* now check whether we could reduce it to a local path... */
- if (ap_matches_request_vhost(r, host, port)) {
- /* this is our host, so only the URL remains */
- r->filename = ap_pstrdup(r->pool, url);
- rewritelog(r, 3, "reduce %s -> %s", olduri, r->filename);
- }
- }
- return;
-}
-
-
-/*
-**
-** add 'http[s]://ourhost[:ourport]/' to URI
-** if URI is still not fully qualified
-**
-*/
-
-static void fully_qualify_uri(request_rec *r)
-{
- int i;
- char buf[32];
- const char *thisserver;
- char *thisport;
- int port;
-
- i = strlen(r->filename);
- if (!( (i > 7 && strncasecmp(r->filename, "http://", 7) == 0)
- || (i > 8 && strncasecmp(r->filename, "https://", 8) == 0)
- || (i > 9 && strncasecmp(r->filename, "gopher://", 9) == 0)
- || (i > 6 && strncasecmp(r->filename, "ftp://", 6) == 0)
- || (i > 5 && strncasecmp(r->filename, "ldap:", 5) == 0)
- || (i > 5 && strncasecmp(r->filename, "news:", 5) == 0)
- || (i > 7 && strncasecmp(r->filename, "mailto:", 7) == 0))) {
-
- thisserver = ap_get_server_name(r);
- port = ap_get_server_port(r);
- if (ap_is_default_port(port,r)) {
- thisport = "";
- }
- else {
- ap_snprintf(buf, sizeof(buf), ":%u", port);
- thisport = buf;
- }
-
- if (r->filename[0] == '/') {
- r->filename = ap_psprintf(r->pool, "%s://%s%s%s",
- ap_http_method(r), thisserver,
- thisport, r->filename);
- }
- else {
- r->filename = ap_psprintf(r->pool, "%s://%s%s/%s",
- ap_http_method(r), thisserver,
- thisport, r->filename);
- }
- }
- return;
-}
-
-
-/*
-**
-** Expand the %0-%9 or $0-$9 regex backreferences
-**
-*/
-
-static void expand_backref_inbuffer(ap_context_t *p, char *buf, int nbuf,
- backrefinfo *bri, char c)
-{
- register int i;
-
- /* protect existing $N and & backrefs and replace <c>N with $N backrefs */
- for (i = 0; buf[i] != '\0' && i < nbuf; i++) {
- if (buf[i] == '\\' && (buf[i+1] != '\0' && i < (nbuf-1))) {
- i++; /* protect next */
- }
- else if (buf[i] == '&') {
- buf[i] = '\001';
- }
- else if (c != '$' && buf[i] == '$' && (buf[i+1] >= '0' && buf[i+1] <= '9')) {
- buf[i] = '\002';
- i++; /* speedup */
- }
- else if (buf[i] == c && (buf[i+1] >= '0' && buf[i+1] <= '9')) {
- buf[i] = '$';
- i++; /* speedup */
- }
- }
-
- /* now apply the standard regex substitution function */
- ap_cpystrn(buf, ap_pregsub(p, buf, bri->source,
- bri->nsub+1, bri->regmatch), nbuf);
-
- /* restore the original $N and & backrefs */
- for (i = 0; buf[i] != '\0' && i < nbuf; i++) {
- if (buf[i] == '\001') {
- buf[i] = '&';
- }
- else if (buf[i] == '\002') {
- buf[i] = '$';
- }
- }
-}
-
-
-/*
-**
-** Expand tilde-paths (/~user) through
-** Unix /etc/passwd database information
-**
-*/
-#if !defined(WIN32) && !defined(NETWARE)
-static char *expand_tildepaths(request_rec *r, char *uri)
-{
- char user[LONG_STRING_LEN];
- struct passwd *pw;
- char *newuri;
- int i, j;
-
- newuri = uri;
- if (uri != NULL && strlen(uri) > 2 && uri[0] == '/' && uri[1] == '~') {
- /* cut out the username */
- for (j = 0, i = 2; j < sizeof(user)-1
- && uri[i] != '\0'
- && uri[i] != '/' ; ) {
- user[j++] = uri[i++];
- }
- user[j] = '\0';
-
- /* lookup username in systems passwd file */
- if ((pw = getpwnam(user)) != NULL) {
- /* ok, user was found, so expand the ~user string */
- if (uri[i] != '\0') {
- /* ~user/anything... has to be expanded */
- if (pw->pw_dir[strlen(pw->pw_dir)-1] == '/') {
- pw->pw_dir[strlen(pw->pw_dir)-1] = '\0';
- }
- newuri = ap_pstrcat(r->pool, pw->pw_dir, uri+i, NULL);
- }
- else {
- /* only ~user has to be expanded */
- newuri = ap_pstrdup(r->pool, pw->pw_dir);
- }
- }
- }
- return newuri;
-}
-#endif
-
-/*
-**
-** mapfile expansion support
-** i.e. expansion of MAP lookup directives
-** ${<mapname>:<key>} in RewriteRule rhs
-**
-*/
-
-#define limit_length(n) (n > LONG_STRING_LEN-1 ? LONG_STRING_LEN-1 : n)
-
-static void expand_map_lookups(request_rec *r, char *uri, int uri_len)
-{
- char newuri[MAX_STRING_LEN];
- char *cpI;
- char *cpIE;
- char *cpO;
- char *cpT;
- char *cpT2;
- char mapname[LONG_STRING_LEN];
- char mapkey[LONG_STRING_LEN];
- char defaultvalue[LONG_STRING_LEN];
- int n;
-
- cpI = uri;
- cpIE = cpI+strlen(cpI);
- cpO = newuri;
- while (cpI < cpIE) {
- if (cpI+6 < cpIE && strncmp(cpI, "${", 2) == 0) {
- /* missing delimiter -> take it as plain text */
- if ( strchr(cpI+2, ':') == NULL
- || strchr(cpI+2, '}') == NULL) {
- memcpy(cpO, cpI, 2);
- cpO += 2;
- cpI += 2;
- continue;
- }
- cpI += 2;
-
- cpT = strchr(cpI, ':');
- n = cpT-cpI;
- memcpy(mapname, cpI, limit_length(n));
- mapname[limit_length(n)] = '\0';
- cpI += n+1;
-
- cpT2 = strchr(cpI, '|');
- cpT = strchr(cpI, '}');
- if (cpT2 != NULL && cpT2 < cpT) {
- n = cpT2-cpI;
- memcpy(mapkey, cpI, limit_length(n));
- mapkey[limit_length(n)] = '\0';
- cpI += n+1;
-
- n = cpT-cpI;
- memcpy(defaultvalue, cpI, limit_length(n));
- defaultvalue[limit_length(n)] = '\0';
- cpI += n+1;
- }
- else {
- n = cpT-cpI;
- memcpy(mapkey, cpI, limit_length(n));
- mapkey[limit_length(n)] = '\0';
- cpI += n+1;
-
- defaultvalue[0] = '\0';
- }
-
- cpT = lookup_map(r, mapname, mapkey);
- if (cpT != NULL) {
- n = strlen(cpT);
- if (cpO + n >= newuri + sizeof(newuri)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR,
- 0, r, "insufficient space in "
- "expand_map_lookups, aborting");
- return;
- }
- memcpy(cpO, cpT, n);
- cpO += n;
- }
- else {
- n = strlen(defaultvalue);
- if (cpO + n >= newuri + sizeof(newuri)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR,
- 0, r, "insufficient space in "
- "expand_map_lookups, aborting");
- return;
- }
- memcpy(cpO, defaultvalue, n);
- cpO += n;
- }
- }
- else {
- cpT = strstr(cpI, "${");
- if (cpT == NULL)
- cpT = cpI+strlen(cpI);
- n = cpT-cpI;
- if (cpO + n >= newuri + sizeof(newuri)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR,
- 0, r, "insufficient space in "
- "expand_map_lookups, aborting");
- return;
- }
- memcpy(cpO, cpI, n);
- cpO += n;
- cpI += n;
- }
- }
- *cpO = '\0';
- ap_cpystrn(uri, newuri, uri_len);
- return;
-}
-
-#undef limit_length
-
-
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | DBM hashfile support
-** | |
-** +-------------------------------------------------------+
-*/
-
-
-static char *lookup_map(request_rec *r, char *name, char *key)
-{
- void *sconf;
- rewrite_server_conf *conf;
- ap_array_header_t *rewritemaps;
- rewritemap_entry *entries;
- rewritemap_entry *s;
- char *value;
- struct stat st;
- int i;
-
- /* get map configuration */
- sconf = r->server->module_config;
- conf = (rewrite_server_conf *)ap_get_module_config(sconf,
- &rewrite_module);
- rewritemaps = conf->rewritemaps;
-
- entries = (rewritemap_entry *)rewritemaps->elts;
- for (i = 0; i < rewritemaps->nelts; i++) {
- s = &entries[i];
- if (strcmp(s->name, name) == 0) {
- if (s->type == MAPTYPE_TXT) {
- if (stat(s->checkfile, &st) == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- "mod_rewrite: can't access text RewriteMap "
- "file %s", s->checkfile);
- rewritelog(r, 1, "can't open RewriteMap file, "
- "see error log");
- return NULL;
- }
- value = get_cache_string(cachep, s->name, CACHEMODE_TS,
- st.st_mtime, key);
- if (value == NULL) {
- rewritelog(r, 6, "cache lookup FAILED, forcing new "
- "map lookup");
- if ((value =
- lookup_map_txtfile(r, s->datafile, key)) != NULL) {
- rewritelog(r, 5, "map lookup OK: map=%s key=%s[txt] "
- "-> val=%s", s->name, key, value);
- set_cache_string(cachep, s->name, CACHEMODE_TS,
- st.st_mtime, key, value);
- return value;
- }
- else {
- rewritelog(r, 5, "map lookup FAILED: map=%s[txt] "
- "key=%s", s->name, key);
- set_cache_string(cachep, s->name, CACHEMODE_TS,
- st.st_mtime, key, "");
- return NULL;
- }
- }
- else {
- rewritelog(r, 5, "cache lookup OK: map=%s[txt] key=%s "
- "-> val=%s", s->name, key, value);
- return value[0] != '\0' ? value : NULL;
- }
- }
- else if (s->type == MAPTYPE_DBM) {
-#ifndef NO_DBM_REWRITEMAP
- if (stat(s->checkfile, &st) == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "mod_rewrite: can't access DBM RewriteMap "
- "file %s", s->checkfile);
- rewritelog(r, 1, "can't open DBM RewriteMap file, "
- "see error log");
- return NULL;
- }
- value = get_cache_string(cachep, s->name, CACHEMODE_TS,
- st.st_mtime, key);
- if (value == NULL) {
- rewritelog(r, 6,
- "cache lookup FAILED, forcing new map lookup");
- if ((value =
- lookup_map_dbmfile(r, s->datafile, key)) != NULL) {
- rewritelog(r, 5, "map lookup OK: map=%s[dbm] key=%s "
- "-> val=%s", s->name, key, value);
- set_cache_string(cachep, s->name, CACHEMODE_TS,
- st.st_mtime, key, value);
- return value;
- }
- else {
- rewritelog(r, 5, "map lookup FAILED: map=%s[dbm] "
- "key=%s", s->name, key);
- set_cache_string(cachep, s->name, CACHEMODE_TS,
- st.st_mtime, key, "");
- return NULL;
- }
- }
- else {
- rewritelog(r, 5, "cache lookup OK: map=%s[dbm] key=%s "
- "-> val=%s", s->name, key, value);
- return value[0] != '\0' ? value : NULL;
- }
-#else
- return NULL;
-#endif
- }
- else if (s->type == MAPTYPE_PRG) {
- if ((value =
- lookup_map_program(r, s->fpin, s->fpout, key)) != NULL) {
- rewritelog(r, 5, "map lookup OK: map=%s key=%s -> val=%s",
- s->name, key, value);
- return value;
- }
- else {
- rewritelog(r, 5, "map lookup FAILED: map=%s key=%s",
- s->name, key);
- }
- }
- else if (s->type == MAPTYPE_INT) {
- if ((value = lookup_map_internal(r, s->func, key)) != NULL) {
- rewritelog(r, 5, "map lookup OK: map=%s key=%s -> val=%s",
- s->name, key, value);
- return value;
- }
- else {
- rewritelog(r, 5, "map lookup FAILED: map=%s key=%s",
- s->name, key);
- }
- }
- else if (s->type == MAPTYPE_RND) {
- if (stat(s->checkfile, &st) == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "mod_rewrite: can't access text RewriteMap "
- "file %s", s->checkfile);
- rewritelog(r, 1, "can't open RewriteMap file, "
- "see error log");
- return NULL;
- }
- value = get_cache_string(cachep, s->name, CACHEMODE_TS,
- st.st_mtime, key);
- if (value == NULL) {
- rewritelog(r, 6, "cache lookup FAILED, forcing new "
- "map lookup");
- if ((value =
- lookup_map_txtfile(r, s->datafile, key)) != NULL) {
- rewritelog(r, 5, "map lookup OK: map=%s key=%s[txt] "
- "-> val=%s", s->name, key, value);
- set_cache_string(cachep, s->name, CACHEMODE_TS,
- st.st_mtime, key, value);
- }
- else {
- rewritelog(r, 5, "map lookup FAILED: map=%s[txt] "
- "key=%s", s->name, key);
- set_cache_string(cachep, s->name, CACHEMODE_TS,
- st.st_mtime, key, "");
- return NULL;
- }
- }
- else {
- rewritelog(r, 5, "cache lookup OK: map=%s[txt] key=%s "
- "-> val=%s", s->name, key, value);
- }
- if (value[0] != '\0') {
- value = select_random_value_part(r, value);
- rewritelog(r, 5, "randomly choosen the subvalue `%s'", value);
- }
- else {
- value = NULL;
- }
- return value;
- }
- }
- }
- return NULL;
-}
-
-static char *lookup_map_txtfile(request_rec *r, char *file, char *key)
-{
- ap_file_t *fp = NULL;
- ap_status_t rc;
- char line[1024];
- char *value = NULL;
- char *cpT;
- size_t skip;
- char *curkey;
- char *curval;
-
- rc = ap_open(&fp, file, APR_READ | APR_BUFFERED, APR_OS_DEFAULT, r->pool);
- if (rc != APR_SUCCESS) {
- return NULL;
- }
-
- while (ap_fgets(line, sizeof(line), fp) == APR_SUCCESS) {
- if (line[0] == '#')
- continue; /* ignore comments */
- cpT = line;
- curkey = cpT;
- skip = strcspn(cpT," \t\r\n");
- if (skip == 0)
- continue; /* ignore lines that start with a space, tab, CR, or LF */
- cpT += skip;
- *cpT = '\0';
- if (strcmp(curkey, key) != 0)
- continue; /* key does not match... */
-
- /* found a matching key; now extract and return the value */
- ++cpT;
- skip = strspn(cpT, " \t\r\n");
- cpT += skip;
- curval = cpT;
- skip = strcspn(cpT, " \t\r\n");
- if (skip == 0)
- continue; /* no value... */
- cpT += skip;
- *cpT = '\0';
- value = ap_pstrdup(r->pool, curval);
- break;
- }
- ap_close(fp);
- return value;
-}
-
-#ifndef NO_DBM_REWRITEMAP
-static char *lookup_map_dbmfile(request_rec *r, char *file, char *key)
-{
- DBM *dbmfp = NULL;
- datum dbmkey;
- datum dbmval;
- char *value = NULL;
- char buf[MAX_STRING_LEN];
-
- dbmkey.dptr = key;
- dbmkey.dsize = strlen(key);
- if ((dbmfp = dbm_open(file, O_RDONLY, 0666)) != NULL) {
- dbmval = dbm_fetch(dbmfp, dbmkey);
- if (dbmval.dptr != NULL) {
- memcpy(buf, dbmval.dptr,
- dbmval.dsize < sizeof(buf)-1 ?
- dbmval.dsize : sizeof(buf)-1 );
- buf[dbmval.dsize] = '\0';
- value = ap_pstrdup(r->pool, buf);
- }
- dbm_close(dbmfp);
- }
- return value;
-}
-#endif
-
-static char *lookup_map_program(request_rec *r, ap_file_t *fpin,
- ap_file_t *fpout, char *key)
-{
- char buf[LONG_STRING_LEN];
- char c;
- int i;
- ap_size_t nbytes;
-
-#ifndef NO_WRITEV
- ap_iovec_t *iov;
- struct iovec iova[2];
- ap_size_t niov;
-#endif
-
- /* when `RewriteEngine off' was used in the per-server
- * context then the rewritemap-programs were not spawned.
- * In this case using such a map (usually in per-dir context)
- * is useless because it is not available.
- */
- if (fpin == NULL || fpout == NULL) {
- return NULL;
- }
-
- /* take the lock */
- rewritelock_alloc(r);
-
- /* write out the request key */
-#ifdef NO_WRITEV
- ap_write(fpin, key, strlen(key));
- ap_write(fpin, "\n", 1);
-#else
- iova[0].iov_base = key;
- iova[0].iov_len = strlen(key);
- iova[1].iov_base = "\n";
- iova[1].iov_len = 1;
-
- ap_make_iov(&iov, iova, r->pool);
- niov = 2;
- ap_writev(fpin, iov, niov, &nbytes);
-#endif
-
- /* read in the response value */
- i = 0;
- nbytes = 1;
- ap_read(fpout, &c, &nbytes);
- while (nbytes == 1 && (i < LONG_STRING_LEN-1)) {
- if (c == '\n') {
- break;
- }
- buf[i++] = c;
-
- ap_read(fpout, &c, &nbytes);
- }
- buf[i] = '\0';
-
- /* give the lock back */
- rewritelock_free(r);
-
- if (strcasecmp(buf, "NULL") == 0) {
- return NULL;
- }
- else {
- return ap_pstrdup(r->pool, buf);
- }
-}
-
-static char *lookup_map_internal(request_rec *r,
- char *(*func)(request_rec *, char *),
- char *key)
-{
- /* currently we just let the function convert
- the key to a corresponding value */
- return func(r, key);
-}
-
-static char *rewrite_mapfunc_toupper(request_rec *r, char *key)
-{
- char *value, *cp;
-
- for (cp = value = ap_pstrdup(r->pool, key); cp != NULL && *cp != '\0';
- cp++) {
- *cp = ap_toupper(*cp);
- }
- return value;
-}
-
-static char *rewrite_mapfunc_tolower(request_rec *r, char *key)
-{
- char *value, *cp;
-
- for (cp = value = ap_pstrdup(r->pool, key); cp != NULL && *cp != '\0';
- cp++) {
- *cp = ap_tolower(*cp);
- }
- return value;
-}
-
-static char *rewrite_mapfunc_escape(request_rec *r, char *key)
-{
- char *value;
-
- value = ap_escape_uri(r->pool, key);
- return value;
-}
-
-static char *rewrite_mapfunc_unescape(request_rec *r, char *key)
-{
- char *value;
-
- value = ap_pstrdup(r->pool, key);
- ap_unescape_url(value);
- return value;
-}
-
-static int rewrite_rand_init_done = 0;
-
-static void rewrite_rand_init(void)
-{
- if (!rewrite_rand_init_done) {
- srand((unsigned)(getpid()));
- rewrite_rand_init_done = 1;
- }
- return;
-}
-
-static int rewrite_rand(int l, int h)
-{
- rewrite_rand_init();
-
- /* Get [0,1) and then scale to the appropriate range. Note that using
- * a floating point value ensures that we use all bits of the rand()
- * result. Doing an integer modulus would only use the lower-order bits
- * which may not be as uniformly random.
- */
- return ((double)(rand() % RAND_MAX) / RAND_MAX) * (h - l + 1) + l;
-}
-
-static char *select_random_value_part(request_rec *r, char *value)
-{
- char *buf;
- int n, i, k;
-
- /* count number of distinct values */
- for (n = 1, i = 0; value[i] != '\0'; i++) {
- if (value[i] == '|') {
- n++;
- }
- }
-
- /* when only one value we have no option to choose */
- if (n == 1) {
- return value;
- }
-
- /* else randomly select one */
- k = rewrite_rand(1, n);
-
- /* and grep it out */
- for (n = 1, i = 0; value[i] != '\0'; i++) {
- if (n == k) {
- break;
- }
- if (value[i] == '|') {
- n++;
- }
- }
- buf = ap_pstrdup(r->pool, &value[i]);
- for (i = 0; buf[i] != '\0' && buf[i] != '|'; i++)
- ;
- buf[i] = '\0';
- return buf;
-}
-
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | rewriting logfile support
-** | |
-** +-------------------------------------------------------+
-*/
-
-
-static void open_rewritelog(server_rec *s, ap_context_t *p)
-{
- rewrite_server_conf *conf;
- const char *fname;
- ap_status_t rc;
- piped_log *pl;
- int rewritelog_flags = ( APR_WRITE | APR_APPEND | APR_CREATE );
- mode_t rewritelog_mode = ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD );
-
- conf = ap_get_module_config(s->module_config, &rewrite_module);
-
- if (conf->rewritelogfile == NULL) {
- return;
- }
- if (*(conf->rewritelogfile) == '\0') {
- return;
- }
- if (conf->rewritelogfp != NULL) {
- return; /* virtual log shared w/ main server */
- }
-
- fname = ap_server_root_relative(p, conf->rewritelogfile);
-
- if (*conf->rewritelogfile == '|') {
- if ((pl = ap_open_piped_log(p, conf->rewritelogfile+1)) == NULL) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
- "mod_rewrite: could not open reliable pipe "
- "to RewriteLog filter %s", conf->rewritelogfile+1);
- exit(1);
- }
- conf->rewritelogfp = ap_piped_log_write_fd(pl);
- }
- else if (*conf->rewritelogfile != '\0') {
- rc = ap_open(&conf->rewritelogfp, fname, rewritelog_flags, rewritelog_mode, p);
- if (rc != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
- "mod_rewrite: could not open RewriteLog "
- "file %s", fname);
- exit(1);
- }
- }
- return;
-}
-
-static void rewritelog(request_rec *r, int level, const char *text, ...)
-{
- rewrite_server_conf *conf;
- conn_rec *conn;
- char *str1;
- char str2[512];
- char str3[1024];
- char type[20];
- char redir[20];
- va_list ap;
- int i;
- ap_size_t nbytes;
- request_rec *req;
- char *ruser;
- const char *rhost;
-
- va_start(ap, text);
- conf = ap_get_module_config(r->server->module_config, &rewrite_module);
- conn = r->connection;
-
- if (conf->rewritelogfp == NULL) {
- return;
- }
- if (conf->rewritelogfile == NULL) {
- return;
- }
- if (*(conf->rewritelogfile) == '\0') {
- return;
- }
-
- if (level > conf->rewriteloglevel) {
- return;
- }
-
- if (r->user == NULL) {
- ruser = "-";
- }
- else if (strlen(r->user) != 0) {
- ruser = r->user;
- }
- else {
- ruser = "\"\"";
- }
-
- rhost = ap_get_remote_host(conn, r->server->module_config,
- REMOTE_NOLOOKUP);
- if (rhost == NULL) {
- rhost = "UNKNOWN-HOST";
- }
-
- str1 = ap_pstrcat(r->pool, rhost, " ",
- (conn->remote_logname != NULL ?
- conn->remote_logname : "-"), " ",
- ruser, NULL);
- ap_vsnprintf(str2, sizeof(str2), text, ap);
-
- if (r->main == NULL) {
- strcpy(type, "initial");
- }
- else {
- strcpy(type, "subreq");
- }
-
- for (i = 0, req = r; req->prev != NULL; req = req->prev) {
- i++;
- }
- if (i == 0) {
- redir[0] = '\0';
- }
- else {
- ap_snprintf(redir, sizeof(redir), "/redir#%d", i);
- }
-
- ap_snprintf(str3, sizeof(str3),
- "%s %s [%s/sid#%lx][rid#%lx/%s%s] (%d) %s\n", str1,
- current_logtime(r), ap_get_server_name(r),
- (unsigned long)(r->server), (unsigned long)r,
- type, redir, level, str2);
-
- fd_lock(r, conf->rewritelogfp);
- nbytes = strlen(str3);
- ap_write(conf->rewritelogfp, str3, &nbytes);
- fd_unlock(r, conf->rewritelogfp);
-
- va_end(ap);
- return;
-}
-
-static char *current_logtime(request_rec *r)
-{
- ap_exploded_time_t t;
- char tstr[80];
- ap_size_t len;
-
- ap_explode_localtime(&t, ap_now());
-
- ap_strftime(tstr, &len, 80, "[%d/%b/%Y:%H:%M:%S ", &t);
- ap_snprintf(tstr + strlen(tstr), 80-strlen(tstr), "%c%.2d%.2d]",
- t.tm_gmtoff < 0 ? '-' : '+',
- t.tm_gmtoff / (60*60), t.tm_gmtoff % (60*60));
- return ap_pstrdup(r->pool, tstr);
-}
-
-
-
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | rewriting lockfile support
-** | |
-** +-------------------------------------------------------+
-*/
-
-#define REWRITELOCK_MODE ( APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD )
-
-static void rewritelock_create(server_rec *s, ap_context_t *p)
-{
- rewrite_server_conf *conf;
- ap_status_t rc;
-
- conf = ap_get_module_config(s->module_config, &rewrite_module);
-
- /* only operate if a lockfile is used */
- if (lockname == NULL || *(lockname) == '\0') {
- return;
- }
-
- /* fixup the path, especially for rewritelock_remove() */
- lockname = ap_server_root_relative(p, lockname);
-
- /* create the lockfile */
- unlink(lockname);
- rc = ap_open(&lockfd, lockname, APR_WRITE | APR_CREATE, REWRITELOCK_MODE, p);
- if (rc != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
- "mod_rewrite: Parent could not create RewriteLock "
- "file %s", lockname);
- exit(1);
- }
-#if !defined(OS2) && !defined(WIN32) && !defined(NETWARE)
- /* make sure the childs have access to this file */
- if (geteuid() == 0 /* is superuser */)
- chown(lockname, unixd_config.user_id, -1 /* no gid change */);
-#endif
-
- return;
-}
-
-static void rewritelock_open(server_rec *s, ap_context_t *p)
-{
- rewrite_server_conf *conf;
- ap_status_t rc;
-
- conf = ap_get_module_config(s->module_config, &rewrite_module);
-
- /* only operate if a lockfile is used */
- if (lockname == NULL || *(lockname) == '\0') {
- return;
- }
-
- /* open the lockfile (once per child) to get a unique fd */
- rc = ap_open(&lockfd, lockname, APR_WRITE | APR_CREATE, REWRITELOCK_MODE, p);
- if (rc != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
- "mod_rewrite: Child could not open RewriteLock "
- "file %s", lockname);
- exit(1);
- }
- return;
-}
-
-static ap_status_t rewritelock_remove(void *data)
-{
- /* only operate if a lockfile is used */
- if (lockname == NULL || *(lockname) == '\0') {
- return(-1);
- }
-
- /* remove the lockfile */
- unlink(lockname);
- lockname = NULL;
- lockfd = NULL;
- return(0);
-}
-
-static void rewritelock_alloc(request_rec *r)
-{
- if (lockfd != NULL) {
- fd_lock(r, lockfd);
- }
- return;
-}
-
-static void rewritelock_free(request_rec *r)
-{
- if (lockfd != NULL) {
- fd_unlock(r, lockfd);
- }
- return;
-}
-
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | program map support
-** | |
-** +-------------------------------------------------------+
-*/
-
-static void run_rewritemap_programs(server_rec *s, ap_context_t *p)
-{
- rewrite_server_conf *conf;
- ap_file_t *fpin = NULL;
- ap_file_t *fpout = NULL;
- ap_file_t *fperr = NULL;
- ap_array_header_t *rewritemaps;
- rewritemap_entry *entries;
- rewritemap_entry *map;
- int i;
- int rc;
-
- conf = ap_get_module_config(s->module_config, &rewrite_module);
-
- /* If the engine isn't turned on,
- * don't even try to do anything.
- */
- if (conf->state == ENGINE_DISABLED) {
- return;
- }
-
- rewritemaps = conf->rewritemaps;
- entries = (rewritemap_entry *)rewritemaps->elts;
- for (i = 0; i < rewritemaps->nelts; i++) {
- map = &entries[i];
- if (map->type != MAPTYPE_PRG) {
- continue;
- }
- if (map->datafile == NULL
- || *(map->datafile) == '\0'
- || map->fpin != NULL
- || map->fpout != NULL ) {
- continue;
- }
- fpin = NULL;
- fpout = NULL;
- rc = rewritemap_program_child(p, map->datafile,
- &fpout, &fpin, &fperr);
- if (rc != APR_SUCCESS || fpin == NULL || fpout == NULL) {
- ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
- "mod_rewrite: could not fork child for "
- "RewriteMap process. %d", rc);
- exit(1);
- }
- map->fpin = fpin;
- map->fpout = fpout;
- map->fperr = fperr;
- }
- return;
-}
-
-/* child process code */
-static int rewritemap_program_child(ap_context_t *p, char *progname,
- ap_file_t **fpout, ap_file_t **fpin,
- ap_file_t **fperr)
-{
- int rc = -1;
- ap_procattr_t *procattr;
- ap_proc_t *procnew;
-
- ap_block_alarms();
-
-#ifdef SIGHUP
- signal(SIGHUP, SIG_IGN);
-#endif
-
-
- if ((ap_createprocattr_init(&procattr, p) != APR_SUCCESS) ||
- (ap_setprocattr_io(procattr, APR_FULL_BLOCK,
- APR_FULL_NONBLOCK,
- APR_FULL_NONBLOCK) != APR_SUCCESS) ||
- (ap_setprocattr_dir(procattr, ap_make_dirstr_parent(p, progname))
- != APR_SUCCESS) ||
- (ap_setprocattr_cmdtype(procattr, APR_PROGRAM) != APR_SUCCESS)) {
- /* Something bad happened, give up and go away. */
- rc = -1;
- }
- else {
- rc = ap_create_process(&procnew, progname, NULL, NULL, procattr, p);
-
- if (rc == APR_SUCCESS) {
- ap_note_subprocess(p, procnew, kill_after_timeout);
-
- if (fpin) {
- ap_get_childin(fpin, procnew);
- }
-
- if (fpout) {
- ap_get_childout(fpout, procnew);
- }
-
- if (fperr) {
- ap_get_childerr(fperr, procnew);
- }
- }
- }
-
- ap_unblock_alarms();
-
- return (rc);
-}
-
-
-
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | environment variable support
-** | |
-** +-------------------------------------------------------+
-*/
-
-
-static void expand_variables_inbuffer(request_rec *r, char *buf, int buf_len)
-{
- char *newbuf;
- newbuf = expand_variables(r, buf);
- if (strcmp(newbuf, buf) != 0) {
- ap_cpystrn(buf, newbuf, buf_len);
- }
- return;
-}
-
-static char *expand_variables(request_rec *r, char *str)
-{
- char output[MAX_STRING_LEN];
- char input[MAX_STRING_LEN];
- char *cp;
- char *cp2;
- char *cp3;
- int expanded;
- char *outp;
- char *endp;
-
- ap_cpystrn(input, str, sizeof(input));
- output[0] = '\0';
- outp = output;
- endp = output + sizeof(output);
- expanded = 0;
- for (cp = input; cp < input+MAX_STRING_LEN; ) {
- if ((cp2 = strstr(cp, "%{")) != NULL) {
- if ((cp3 = strstr(cp2, "}")) != NULL) {
- *cp2 = '\0';
- outp = ap_cpystrn(outp, cp, endp - outp);
-
- cp2 += 2;
- *cp3 = '\0';
- outp = ap_cpystrn(outp, lookup_variable(r, cp2), endp - outp);
-
- cp = cp3+1;
- expanded = 1;
- continue;
- }
- }
- outp = ap_cpystrn(outp, cp, endp - outp);
- break;
- }
- return expanded ? ap_pstrdup(r->pool, output) : str;
-}
-
-static char *lookup_variable(request_rec *r, char *var)
-{
- const char *result;
- char resultbuf[LONG_STRING_LEN];
- ap_exploded_time_t tm;
- request_rec *rsub;
-#ifndef WIN32
- struct passwd *pw;
- struct group *gr;
- struct stat finfo;
-#endif
-
- result = NULL;
-
- /* HTTP headers */
- if (strcasecmp(var, "HTTP_USER_AGENT") == 0) {
- result = lookup_header(r, "User-Agent");
- }
- else if (strcasecmp(var, "HTTP_REFERER") == 0) {
- result = lookup_header(r, "Referer");
- }
- else if (strcasecmp(var, "HTTP_COOKIE") == 0) {
- result = lookup_header(r, "Cookie");
- }
- else if (strcasecmp(var, "HTTP_FORWARDED") == 0) {
- result = lookup_header(r, "Forwarded");
- }
- else if (strcasecmp(var, "HTTP_HOST") == 0) {
- result = lookup_header(r, "Host");
- }
- else if (strcasecmp(var, "HTTP_PROXY_CONNECTION") == 0) {
- result = lookup_header(r, "Proxy-Connection");
- }
- else if (strcasecmp(var, "HTTP_ACCEPT") == 0) {
- result = lookup_header(r, "Accept");
- }
- /* all other headers from which we are still not know about */
- else if (strlen(var) > 5 && strncasecmp(var, "HTTP:", 5) == 0) {
- result = lookup_header(r, var+5);
- }
-
- /* connection stuff */
- else if (strcasecmp(var, "REMOTE_ADDR") == 0) {
- result = r->connection->remote_ip;
- }
- else if (strcasecmp(var, "REMOTE_HOST") == 0) {
- result = (char *)ap_get_remote_host(r->connection,
- r->per_dir_config, REMOTE_NAME);
- }
- else if (strcasecmp(var, "REMOTE_USER") == 0) {
- result = r->user;
- }
- else if (strcasecmp(var, "REMOTE_IDENT") == 0) {
- result = (char *)ap_get_remote_logname(r);
- }
-
- /* request stuff */
- else if (strcasecmp(var, "THE_REQUEST") == 0) { /* non-standard */
- result = r->the_request;
- }
- else if (strcasecmp(var, "REQUEST_METHOD") == 0) {
- result = r->method;
- }
- else if (strcasecmp(var, "REQUEST_URI") == 0) { /* non-standard */
- result = r->uri;
- }
- else if (strcasecmp(var, "SCRIPT_FILENAME") == 0 ||
- strcasecmp(var, "REQUEST_FILENAME") == 0 ) {
- result = r->filename;
- }
- else if (strcasecmp(var, "PATH_INFO") == 0) {
- result = r->path_info;
- }
- else if (strcasecmp(var, "QUERY_STRING") == 0) {
- result = r->args;
- }
- else if (strcasecmp(var, "AUTH_TYPE") == 0) {
- result = r->ap_auth_type;
- }
- else if (strcasecmp(var, "IS_SUBREQ") == 0) { /* non-standard */
- result = (r->main != NULL ? "true" : "false");
- }
-
- /* internal server stuff */
- else if (strcasecmp(var, "DOCUMENT_ROOT") == 0) {
- result = ap_document_root(r);
- }
- else if (strcasecmp(var, "SERVER_ADMIN") == 0) {
- result = r->server->server_admin;
- }
- else if (strcasecmp(var, "SERVER_NAME") == 0) {
- result = ap_get_server_name(r);
- }
- else if (strcasecmp(var, "SERVER_ADDR") == 0) { /* non-standard */
- result = r->connection->local_ip;
- }
- else if (strcasecmp(var, "SERVER_PORT") == 0) {
- ap_snprintf(resultbuf, sizeof(resultbuf), "%u", ap_get_server_port(r));
- result = resultbuf;
- }
- else if (strcasecmp(var, "SERVER_PROTOCOL") == 0) {
- result = r->protocol;
- }
- else if (strcasecmp(var, "SERVER_SOFTWARE") == 0) {
- result = ap_get_server_version();
- }
- else if (strcasecmp(var, "API_VERSION") == 0) { /* non-standard */
- ap_snprintf(resultbuf, sizeof(resultbuf), "%d:%d",
- MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
- result = resultbuf;
- }
-
-/* XXX: wow this has gotta be slow if you actually use it for a lot, recalculates exploded time for each variable */
- /* underlaying Unix system stuff */
- else if (strcasecmp(var, "TIME_YEAR") == 0) {
- ap_explode_localtime(&tm, ap_now());
- ap_snprintf(resultbuf, sizeof(resultbuf), "%04d", tm.tm_year + 1900);
- result = resultbuf;
- }
-#define MKTIMESTR(format, tmfield) \
- ap_explode_localtime(&tm, ap_now()); \
- ap_snprintf(resultbuf, sizeof(resultbuf), format, tm.tmfield); \
- result = resultbuf;
- else if (strcasecmp(var, "TIME_MON") == 0) {
- MKTIMESTR("%02d", tm_mon+1)
- }
- else if (strcasecmp(var, "TIME_DAY") == 0) {
- MKTIMESTR("%02d", tm_mday)
- }
- else if (strcasecmp(var, "TIME_HOUR") == 0) {
- MKTIMESTR("%02d", tm_hour)
- }
- else if (strcasecmp(var, "TIME_MIN") == 0) {
- MKTIMESTR("%02d", tm_min)
- }
- else if (strcasecmp(var, "TIME_SEC") == 0) {
- MKTIMESTR("%02d", tm_sec)
- }
- else if (strcasecmp(var, "TIME_WDAY") == 0) {
- MKTIMESTR("%d", tm_wday)
- }
- else if (strcasecmp(var, "TIME") == 0) {
- ap_explode_localtime(&tm, ap_now());
- ap_snprintf(resultbuf, sizeof(resultbuf),
- "%04d%02d%02d%02d%02d%02d", tm.tm_year + 1900,
- tm.tm_mon+1, tm.tm_mday,
- tm.tm_hour, tm.tm_min, tm.tm_sec);
- result = resultbuf;
- rewritelog(r, 1, "RESULT='%s'", result);
- }
-
- /* all other env-variables from the parent Apache process */
- else if (strlen(var) > 4 && strncasecmp(var, "ENV:", 4) == 0) {
- /* first try the internal Apache notes structure */
- result = ap_table_get(r->notes, var+4);
- /* second try the internal Apache env structure */
- if (result == NULL) {
- result = ap_table_get(r->subprocess_env, var+4);
- }
- /* third try the external OS env */
- if (result == NULL) {
- result = getenv(var+4);
- }
- }
-
-#define LOOKAHEAD(subrecfunc) \
- if ( \
- /* filename is safe to use */ \
- r->filename != NULL \
- /* - and we're either not in a subrequest */ \
- && ( r->main == NULL \
- /* - or in a subrequest where paths are non-NULL... */ \
- || ( r->main->uri != NULL && r->uri != NULL \
- /* ...and sub and main paths differ */ \
- && strcmp(r->main->uri, r->uri) != 0))) { \
- /* process a file-based subrequest */ \
- rsub = subrecfunc(r->filename, r); \
- /* now recursively lookup the variable in the sub_req */ \
- result = lookup_variable(rsub, var+5); \
- /* copy it up to our scope before we destroy sub_req's ap_context_t */ \
- result = ap_pstrdup(r->pool, result); \
- /* cleanup by destroying the subrequest */ \
- ap_destroy_sub_req(rsub); \
- /* log it */ \
- rewritelog(r, 5, "lookahead: path=%s var=%s -> val=%s", \
- r->filename, var+5, result); \
- /* return ourself to prevent re-pstrdup */ \
- return (char *)result; \
- }
-
- /* look-ahead for parameter through URI-based sub-request */
- else if (strlen(var) > 5 && strncasecmp(var, "LA-U:", 5) == 0) {
- LOOKAHEAD(ap_sub_req_lookup_uri)
- }
- /* look-ahead for parameter through file-based sub-request */
- else if (strlen(var) > 5 && strncasecmp(var, "LA-F:", 5) == 0) {
- LOOKAHEAD(ap_sub_req_lookup_file)
- }
-
-#if !defined(WIN32) && !defined(NETWARE)
- /* Win32 has a rather different view of file ownerships.
- For now, just forget it */
-
- /* file stuff */
- else if (strcasecmp(var, "SCRIPT_USER") == 0) {
- result = "<unknown>";
- if (r->finfo.protection != 0) {
- if ((pw = getpwuid(r->finfo.user)) != NULL) {
- result = pw->pw_name;
- }
- }
- else {
- if (stat(r->filename, &finfo) == 0) {
- if ((pw = getpwuid(finfo.st_uid)) != NULL) {
- result = pw->pw_name;
- }
- }
- }
- }
- else if (strcasecmp(var, "SCRIPT_GROUP") == 0) {
- result = "<unknown>";
- if (r->finfo.protection != 0) {
- if ((gr = getgrgid(r->finfo.group)) != NULL) {
- result = gr->gr_name;
- }
- }
- else {
- if (stat(r->filename, &finfo) == 0) {
- if ((gr = getgrgid(finfo.st_gid)) != NULL) {
- result = gr->gr_name;
- }
- }
- }
- }
-#endif /* ndef WIN32 && NETWARE*/
-
- if (result == NULL) {
- return ap_pstrdup(r->pool, "");
- }
- else {
- return ap_pstrdup(r->pool, result);
- }
-}
-
-static char *lookup_header(request_rec *r, const char *name)
-{
- ap_array_header_t *hdrs_arr;
- ap_table_entry_t *hdrs;
- int i;
-
- hdrs_arr = ap_table_elts(r->headers_in);
- hdrs = (ap_table_entry_t *)hdrs_arr->elts;
- for (i = 0; i < hdrs_arr->nelts; ++i) {
- if (hdrs[i].key == NULL) {
- continue;
- }
- if (strcasecmp(hdrs[i].key, name) == 0) {
- ap_table_merge(r->notes, VARY_KEY_THIS, name);
- return hdrs[i].val;
- }
- }
- return NULL;
-}
-
-
-
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | caching support
-** | |
-** +-------------------------------------------------------+
-*/
-
-
-static cache *init_cache(ap_context_t *p)
-{
- cache *c;
-
- c = (cache *)ap_palloc(p, sizeof(cache));
- if (ap_create_context(&c->pool, p) != APR_SUCCESS)
- return NULL;
- c->lists = ap_make_array(c->pool, 2, sizeof(cachelist));
- return c;
-}
-
-static void set_cache_string(cache *c, char *res, int mode, time_t t,
- char *key, char *value)
-{
- cacheentry ce;
-
- ce.time = t;
- ce.key = key;
- ce.value = value;
- store_cache_string(c, res, &ce);
- return;
-}
-
-static char *get_cache_string(cache *c, char *res, int mode,
- time_t t, char *key)
-{
- cacheentry *ce;
-
- ce = retrieve_cache_string(c, res, key);
- if (ce == NULL) {
- return NULL;
- }
- if (mode & CACHEMODE_TS) {
- if (t != ce->time) {
- return NULL;
- }
- }
- else if (mode & CACHEMODE_TTL) {
- if (t > ce->time) {
- return NULL;
- }
- }
- return ap_pstrdup(c->pool, ce->value);
-}
-
-static int cache_tlb_hash(char *key)
-{
- unsigned long n;
- char *p;
-
- n = 0;
- for (p=key; *p != '\0'; ++p) {
- n = n * 53711 + 134561 + (unsigned)(*p & 0xff);
- }
-
- return n % CACHE_TLB_ROWS;
-}
-
-static cacheentry *cache_tlb_lookup(cachetlbentry *tlb, cacheentry *elt,
- char *key)
-{
- int ix = cache_tlb_hash(key);
- int i;
- int j;
-
- for (i=0; i < CACHE_TLB_COLS; ++i) {
- j = tlb[ix].t[i];
- if (j < 0)
- return NULL;
- if (strcmp(elt[j].key, key) == 0)
- return &elt[j];
- }
- return NULL;
-}
-
-static void cache_tlb_replace(cachetlbentry *tlb, cacheentry *elt,
- cacheentry *e)
-{
- int ix = cache_tlb_hash(e->key);
- int i;
-
- tlb = &tlb[ix];
-
- for (i=1; i < CACHE_TLB_COLS; ++i)
- tlb->t[i] = tlb->t[i-1];
-
- tlb->t[0] = e - elt;
-}
-
-static void store_cache_string(cache *c, char *res, cacheentry *ce)
-{
- int i;
- int j;
- cachelist *l;
- cacheentry *e;
- cachetlbentry *t;
- int found_list;
-
- found_list = 0;
- /* first try to edit an existing entry */
- for (i = 0; i < c->lists->nelts; i++) {
- l = &(((cachelist *)c->lists->elts)[i]);
- if (strcmp(l->resource, res) == 0) {
- found_list = 1;
-
- e = cache_tlb_lookup((cachetlbentry *)l->tlb->elts,
- (cacheentry *)l->entries->elts, ce->key);
- if (e != NULL) {
- e->time = ce->time;
- e->value = ap_pstrdup(c->pool, ce->value);
- return;
- }
-
- for (j = 0; j < l->entries->nelts; j++) {
- e = &(((cacheentry *)l->entries->elts)[j]);
- if (strcmp(e->key, ce->key) == 0) {
- e->time = ce->time;
- e->value = ap_pstrdup(c->pool, ce->value);
- cache_tlb_replace((cachetlbentry *)l->tlb->elts,
- (cacheentry *)l->entries->elts, e);
- return;
- }
- }
- }
- }
-
- /* create a needed new list */
- if (!found_list) {
- l = ap_push_array(c->lists);
- l->resource = ap_pstrdup(c->pool, res);
- l->entries = ap_make_array(c->pool, 2, sizeof(cacheentry));
- l->tlb = ap_make_array(c->pool, CACHE_TLB_ROWS,
- sizeof(cachetlbentry));
- for (i=0; i<CACHE_TLB_ROWS; ++i) {
- t = &((cachetlbentry *)l->tlb->elts)[i];
- for (j=0; j<CACHE_TLB_COLS; ++j)
- t->t[j] = -1;
- }
- }
-
- /* create the new entry */
- for (i = 0; i < c->lists->nelts; i++) {
- l = &(((cachelist *)c->lists->elts)[i]);
- if (strcmp(l->resource, res) == 0) {
- e = ap_push_array(l->entries);
- e->time = ce->time;
- e->key = ap_pstrdup(c->pool, ce->key);
- e->value = ap_pstrdup(c->pool, ce->value);
- cache_tlb_replace((cachetlbentry *)l->tlb->elts,
- (cacheentry *)l->entries->elts, e);
- return;
- }
- }
-
- /* not reached, but when it is no problem... */
- return;
-}
-
-static cacheentry *retrieve_cache_string(cache *c, char *res, char *key)
-{
- int i;
- int j;
- cachelist *l;
- cacheentry *e;
-
- for (i = 0; i < c->lists->nelts; i++) {
- l = &(((cachelist *)c->lists->elts)[i]);
- if (strcmp(l->resource, res) == 0) {
-
- e = cache_tlb_lookup((cachetlbentry *)l->tlb->elts,
- (cacheentry *)l->entries->elts, key);
- if (e != NULL)
- return e;
-
- for (j = 0; j < l->entries->nelts; j++) {
- e = &(((cacheentry *)l->entries->elts)[j]);
- if (strcmp(e->key, key) == 0) {
- return e;
- }
- }
- }
- }
- return NULL;
-}
-
-
-
-
-/*
-** +-------------------------------------------------------+
-** | |
-** | misc functions
-** | |
-** +-------------------------------------------------------+
-*/
-
-static char *subst_prefix_path(request_rec *r, char *input, char *match,
- char *subst)
-{
- char matchbuf[LONG_STRING_LEN];
- char substbuf[LONG_STRING_LEN];
- char *output;
- int l;
-
- output = input;
-
- /* first create a match string which always has a trailing slash */
- l = ap_cpystrn(matchbuf, match, sizeof(matchbuf)) - matchbuf;
- if (matchbuf[l-1] != '/') {
- matchbuf[l] = '/';
- matchbuf[l+1] = '\0';
- l++;
- }
- /* now compare the prefix */
- if (strncmp(input, matchbuf, l) == 0) {
- rewritelog(r, 5, "strip matching prefix: %s -> %s", output, output+l);
- output = ap_pstrdup(r->pool, output+l);
-
- /* and now add the base-URL as replacement prefix */
- l = ap_cpystrn(substbuf, subst, sizeof(substbuf)) - substbuf;
- if (substbuf[l-1] != '/') {
- substbuf[l] = '/';
- substbuf[l+1] = '\0';
- l++;
- }
- if (output[0] == '/') {
- rewritelog(r, 4, "add subst prefix: %s -> %s%s",
- output, substbuf, output+1);
- output = ap_pstrcat(r->pool, substbuf, output+1, NULL);
- }
- else {
- rewritelog(r, 4, "add subst prefix: %s -> %s%s",
- output, substbuf, output);
- output = ap_pstrcat(r->pool, substbuf, output, NULL);
- }
- }
- return output;
-}
-
-
-/*
-**
-** own command line parser which don't have the '\\' problem
-**
-*/
-
-static int parseargline(char *str, char **a1, char **a2, char **a3)
-{
- char *cp;
- int isquoted;
-
-#define SKIP_WHITESPACE(cp) \
- for ( ; *cp == ' ' || *cp == '\t'; ) { \
- cp++; \
- };
-
-#define CHECK_QUOTATION(cp,isquoted) \
- isquoted = 0; \
- if (*cp == '"') { \
- isquoted = 1; \
- cp++; \
- }
-
-#define DETERMINE_NEXTSTRING(cp,isquoted) \
- for ( ; *cp != '\0'; cp++) { \
- if ( (isquoted && (*cp == ' ' || *cp == '\t')) \
- || (*cp == '\\' && (*(cp+1) == ' ' || *(cp+1) == '\t'))) { \
- cp++; \
- continue; \
- } \
- if ( (!isquoted && (*cp == ' ' || *cp == '\t')) \
- || (isquoted && *cp == '"') ) { \
- break; \
- } \
- }
-
- cp = str;
- SKIP_WHITESPACE(cp);
-
- /* determine first argument */
- CHECK_QUOTATION(cp, isquoted);
- *a1 = cp;
- DETERMINE_NEXTSTRING(cp, isquoted);
- if (*cp == '\0') {
- return 1;
- }
- *cp++ = '\0';
-
- SKIP_WHITESPACE(cp);
-
- /* determine second argument */
- CHECK_QUOTATION(cp, isquoted);
- *a2 = cp;
- DETERMINE_NEXTSTRING(cp, isquoted);
- if (*cp == '\0') {
- *cp++ = '\0';
- *a3 = NULL;
- return 0;
- }
- *cp++ = '\0';
-
- SKIP_WHITESPACE(cp);
-
- /* again check if there are only two arguments */
- if (*cp == '\0') {
- *cp++ = '\0';
- *a3 = NULL;
- return 0;
- }
-
- /* determine second argument */
- CHECK_QUOTATION(cp, isquoted);
- *a3 = cp;
- DETERMINE_NEXTSTRING(cp, isquoted);
- *cp++ = '\0';
-
- return 0;
-}
-
-
-static void add_env_variable(request_rec *r, char *s)
-{
- char var[MAX_STRING_LEN];
- char val[MAX_STRING_LEN];
- char *cp;
- int n;
-
- if ((cp = strchr(s, ':')) != NULL) {
- n = ((cp-s) > MAX_STRING_LEN-1 ? MAX_STRING_LEN-1 : (cp-s));
- memcpy(var, s, n);
- var[n] = '\0';
- ap_cpystrn(val, cp+1, sizeof(val));
- ap_table_set(r->subprocess_env, var, val);
- rewritelog(r, 5, "setting env variable '%s' to '%s'", var, val);
- }
-}
-
-
-
-/*
-**
-** stat() for only the prefix of a path
-**
-*/
-
-static int prefix_stat(const char *path, struct stat *sb)
-{
- char curpath[LONG_STRING_LEN];
- char *cp;
-
- ap_cpystrn(curpath, path, sizeof(curpath));
- if (curpath[0] != '/') {
- return 0;
- }
- if ((cp = strchr(curpath+1, '/')) != NULL) {
- *cp = '\0';
- }
- if (stat(curpath, sb) == 0) {
- return 1;
- }
- else {
- return 0;
- }
-}
-
-
-/*
-**
-** File locking
-**
-*/
-
-#ifdef USE_FCNTL
-static struct flock lock_it;
-static struct flock unlock_it;
-#endif
-
-static void fd_lock(request_rec *r, ap_file_t *fd)
-{
- int rc;
- int sys_file;
-
-#ifdef USE_FCNTL
- lock_it.l_whence = SEEK_SET; /* from current point */
- lock_it.l_start = 0; /* -"- */
- lock_it.l_len = 0; /* until end of file */
- lock_it.l_type = F_WRLCK; /* set exclusive/write lock */
- lock_it.l_pid = 0; /* pid not actually interesting */
-
- ap_get_os_file(&sys_file, fd);
- while ( ((rc = fcntl(sys_file, F_SETLKW, &lock_it)) < 0)
- && (errno == EINTR) ) {
- continue;
- }
-#endif
-#ifdef USE_FLOCK
- ap_get_os_file(fd, &sys_file);
- while ( ((rc = flock(sys_file, LOCK_EX)) < 0)
- && (errno == EINTR) ) {
- continue;
- }
-#endif
-#ifdef USE_LOCKING
- /* Lock the first byte, always, assume we want to append
- and seek to the end afterwards */
- ap_seek(fd, APR_SET, 0);
- ap_get_os_file(&sys_file, fd);
- rc = _locking(sys_file, _LK_LOCK, 1);
- ap_seek(fd, APR_END, 0);
-#endif
-
- if (rc < 0) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "mod_rewrite: failed to lock file descriptor");
- exit(1);
- }
- return;
-}
-
-static void fd_unlock(request_rec *r, ap_file_t *fd)
-{
- int rc;
- int sys_file;
-
-#ifdef USE_FCNTL
- unlock_it.l_whence = SEEK_SET; /* from current point */
- unlock_it.l_start = 0; /* -"- */
- unlock_it.l_len = 0; /* until end of file */
- unlock_it.l_type = F_UNLCK; /* unlock */
- unlock_it.l_pid = 0; /* pid not actually interesting */
-
- ap_get_os_file(&sys_file, fd);
- rc = fcntl(sys_file, F_SETLKW, &unlock_it);
-#endif
-#ifdef USE_FLOCK
- ap_get_os_file(fd, &sys_file);
- rc = flock(sys_file, LOCK_UN);
-#endif
-#ifdef USE_LOCKING
- ap_seek(fd, APR_SET, 0);
- ap_get_os_file(&sys_file, fd);
- rc = _locking(sys_file, _LK_UNLCK, 1);
- ap_seek(fd, APR_END, 0);
-#endif
-
- if (rc < 0) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
- "mod_rewrite: failed to unlock file descriptor");
- exit(1);
- }
-}
-
-/*
-**
-** Lexicographic Compare
-**
-*/
-
-static int compare_lexicography(char *cpNum1, char *cpNum2)
-{
- int i;
- int n1, n2;
-
- n1 = strlen(cpNum1);
- n2 = strlen(cpNum2);
- if (n1 > n2) {
- return 1;
- }
- if (n1 < n2) {
- return -1;
- }
- for (i = 0; i < n1; i++) {
- if (cpNum1[i] > cpNum2[i]) {
- return 1;
- }
- if (cpNum1[i] < cpNum2[i]) {
- return -1;
- }
- }
- return 0;
-}
-
-#ifdef NETWARE
-int main(int argc, char *argv[])
-{
- ExitThread(TSR_THREAD, 0);
-}
-#endif
-
-/*EOF*/
diff --git a/modules/mappers/mod_rewrite.dsp b/modules/mappers/mod_rewrite.dsp
deleted file mode 100644
index cbf1bb06e5..0000000000
--- a/modules/mappers/mod_rewrite.dsp
+++ /dev/null
@@ -1,117 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheModuleRewrite" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheModuleRewrite - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleRewrite.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleRewrite.mak"\
- CFG="ApacheModuleRewrite - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheModuleRewrite - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheModuleRewrite - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheModuleRewrite - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\Release"
-# PROP BASE Intermediate_Dir ".\Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\ApacheModuleRewriteR"
-# PROP Intermediate_Dir ".\ApacheModuleRewriteR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "NO_DBM_REWRITEMAP" /D "SHARED_MODULE" /D "WIN32_LEAN_AND_MEAN" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ..\..\CoreR\ApacheCore.lib ..\..\lib\apr\Release\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ws2_32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheModuleRewrite - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\Debug"
-# PROP BASE Intermediate_Dir ".\Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\ApacheModuleRewriteD"
-# PROP Intermediate_Dir ".\ApacheModuleRewriteD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "NO_DBM_REWRITEMAP" /D "SHARED_MODULE" /D "WIN32_LEAN_AND_MEAN" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ..\..\CoreD\ApacheCore.lib ..\..\lib\apr\Debug\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ws2_32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheModuleRewrite - Win32 Release"
-# Name "ApacheModuleRewrite - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=..\..\modules\standard\mod_rewrite.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\passwd.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\readdir.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/modules/mappers/mod_rewrite.exp b/modules/mappers/mod_rewrite.exp
deleted file mode 100644
index 8f2165bfe0..0000000000
--- a/modules/mappers/mod_rewrite.exp
+++ /dev/null
@@ -1 +0,0 @@
-rewrite_module
diff --git a/modules/mappers/mod_rewrite.h b/modules/mappers/mod_rewrite.h
deleted file mode 100644
index a5fc511259..0000000000
--- a/modules/mappers/mod_rewrite.h
+++ /dev/null
@@ -1,504 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-
-#ifndef _MOD_REWRITE_H
-#define _MOD_REWRITE_H 1
-
-/*
-** _ _ _
-** _ __ ___ ___ __| | _ __ _____ ___ __(_) |_ ___
-** | '_ ` _ \ / _ \ / _` | | '__/ _ \ \ /\ / / '__| | __/ _ \
-** | | | | | | (_) | (_| | | | | __/\ V V /| | | | || __/
-** |_| |_| |_|\___/ \__,_|___|_| \___| \_/\_/ |_| |_|\__\___|
-** |_____|
-**
-** URL Rewriting Module
-**
-** This module uses a rule-based rewriting engine (based on a
-** regular-expression parser) to rewrite requested URLs on the fly.
-**
-** It supports an unlimited number of additional rule conditions (which can
-** operate on a lot of variables, even on HTTP headers) for granular
-** matching and even external database lookups (either via plain text
-** tables, DBM hash files or even external processes) for advanced URL
-** substitution.
-**
-** It operates on the full URLs (including the PATH_INFO part) both in
-** per-server context (httpd.conf) and per-dir context (.htaccess) and even
-** can generate QUERY_STRING parts on result. The rewriting result finally
-** can lead to internal subprocessing, external request redirection or even
-** to internal proxy throughput.
-**
-** This module was originally written in April 1996 and
-** gifted exclusively to the The Apache Group in July 1997 by
-**
-** Ralf S. Engelschall
-** rse@engelschall.com
-** www.engelschall.com
-*/
-
-
- /* Include from the underlaying Unix system ... */
-#include <string.h>
-#include <stdarg.h>
-#include <stdlib.h>
-#include <time.h>
-#include <signal.h>
-#include <errno.h>
-#include <ctype.h>
-#ifndef NETWARE
-#include <sys/types.h>
-#endif
-#include <sys/stat.h>
-
- /* Include from the Apache server ... */
-#define CORE_PRIVATE
-#include "httpd.h"
-#include "http_config.h"
-#include "http_conf_globals.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_vhost.h"
-
- /*
- * The key in the r->notes ap_table_t wherein we store our accumulated
- * Vary values, and the one used for per-condition checks in a chain.
- */
-#define VARY_KEY "rewrite-Vary"
-#define VARY_KEY_THIS "rewrite-Vary-this"
-
- /* The NDBM support:
- * We support only NDBM files.
- * But we have to stat the file for the mtime,
- * so we also need to know the file extension
- */
-#ifndef NO_DBM_REWRITEMAP
-#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) \
- && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
-#include <db1/ndbm.h>
-#else
-#include <ndbm.h>
-#endif
-#if defined(DBM_SUFFIX)
-#define NDBM_FILE_SUFFIX DBM_SUFFIX
-#elif defined(__FreeBSD__) || (defined(DB_LOCK) && defined(DB_SHMEM))
-#define NDBM_FILE_SUFFIX ".db"
-#else
-#define NDBM_FILE_SUFFIX ".pag"
-#endif
-#endif
-
-
- /* The locking support:
- * Try to determine whether we should use fcntl() or flock().
- * Would be better ap_config.h could provide this... :-(
- */
-#if defined(USE_FCNTL_SERIALIZED_ACCEPT)
-#define USE_FCNTL 1
-#include <fcntl.h>
-#endif
-#if defined(USE_FLOCK_SERIALIZED_ACCEPT)
-#define USE_FLOCK 1
-#include <sys/file.h>
-#endif
-#if !defined(USE_FCNTL) && !defined(USE_FLOCK)
-#define USE_FLOCK 1
-#if !defined(MPE) && !defined(WIN32) && !defined(__TANDEM) && !defined(NETWARE)
-#include <sys/file.h>
-#endif
-#ifndef LOCK_UN
-#undef USE_FLOCK
-#define USE_FCNTL 1
-#include <fcntl.h>
-#endif
-#endif
-#ifdef AIX
-#undef USE_FLOCK
-#define USE_FCNTL 1
-#include <fcntl.h>
-#endif
-#ifdef WIN32
-#undef USE_FCNTL
-#define USE_LOCKING
-#include <sys/locking.h>
-#endif
-
-
-/*
-**
-** Some defines
-**
-*/
-
-#define ENVVAR_SCRIPT_URL "SCRIPT_URL"
-#define ENVVAR_SCRIPT_URI "SCRIPT_URI"
-
-#ifndef SUPPORT_DBM_REWRITEMAP
-#define SUPPORT_DBM_REWRITEMAP 0
-#endif
-
-#define REWRITE_FORCED_MIMETYPE_NOTEVAR "rewrite-forced-mimetype"
-
-#define CONDFLAG_NONE 1<<0
-#define CONDFLAG_NOCASE 1<<1
-#define CONDFLAG_NOTMATCH 1<<2
-#define CONDFLAG_ORNEXT 1<<3
-
-#define RULEFLAG_NONE 1<<0
-#define RULEFLAG_FORCEREDIRECT 1<<1
-#define RULEFLAG_LASTRULE 1<<2
-#define RULEFLAG_NEWROUND 1<<3
-#define RULEFLAG_CHAIN 1<<4
-#define RULEFLAG_IGNOREONSUBREQ 1<<5
-#define RULEFLAG_NOTMATCH 1<<6
-#define RULEFLAG_PROXY 1<<7
-#define RULEFLAG_PASSTHROUGH 1<<8
-#define RULEFLAG_FORBIDDEN 1<<9
-#define RULEFLAG_GONE 1<<10
-#define RULEFLAG_QSAPPEND 1<<11
-#define RULEFLAG_NOCASE 1<<12
-
-#define MAPTYPE_TXT 1<<0
-#define MAPTYPE_DBM 1<<1
-#define MAPTYPE_PRG 1<<2
-#define MAPTYPE_INT 1<<3
-#define MAPTYPE_RND 1<<4
-
-#define ENGINE_DISABLED 1<<0
-#define ENGINE_ENABLED 1<<1
-
-#define OPTION_NONE 1<<0
-#define OPTION_INHERIT 1<<1
-
-#define CACHEMODE_TS 1<<0
-#define CACHEMODE_TTL 1<<1
-
-#define CACHE_TLB_ROWS 1024
-#define CACHE_TLB_COLS 4
-
-#ifndef FALSE
-#define FALSE 0
-#define TRUE !FALSE
-#endif
-
-#ifndef NO
-#define NO FALSE
-#define YES TRUE
-#endif
-
-#ifndef RAND_MAX
-#define RAND_MAX 32767
-#endif
-
-#ifndef LONG_STRING_LEN
-#define LONG_STRING_LEN 2048
-#endif
-
-#define MAX_ENV_FLAGS 15
-
-#define MAX_NMATCH 10
-
-/*
-**
-** our private data structures we handle with
-**
-*/
-
- /* the list structures for holding the mapfile information
- * and the rewrite rules
- */
-typedef struct {
- char *name; /* the name of the map */
- char *datafile; /* filename for map data files */
- char *checkfile; /* filename to check for map existence */
- int type; /* the type of the map */
- ap_file_t *fpin; /* in file pointer for program maps */
- ap_file_t *fpout; /* out file pointer for program maps */
- ap_file_t *fperr; /* err file pointer for program maps */
- char *(*func)(request_rec *, /* function pointer for internal maps */
- char *);
-} rewritemap_entry;
-
-typedef struct {
- char *input; /* Input string of RewriteCond */
- char *pattern; /* the RegExp pattern string */
- regex_t *regexp;
- int flags; /* Flags which control the match */
-} rewritecond_entry;
-
-typedef struct {
- ap_array_header_t *rewriteconds; /* the corresponding RewriteCond entries */
- char *pattern; /* the RegExp pattern string */
- regex_t *regexp; /* the RegExp pattern compilation */
- char *output; /* the Substitution string */
- int flags; /* Flags which control the substitution */
- char *forced_mimetype; /* forced MIME type of substitution */
- int forced_responsecode; /* forced HTTP redirect response status */
- char *env[MAX_ENV_FLAGS+1]; /* added environment variables */
- int skip; /* number of next rules to skip */
-} rewriterule_entry;
-
-
- /* the per-server or per-virtual-server configuration
- * statically generated once on startup for every server
- */
-typedef struct {
- int state; /* the RewriteEngine state */
- int options; /* the RewriteOption state */
- char *rewritelogfile; /* the RewriteLog filename */
- ap_file_t *rewritelogfp; /* the RewriteLog open filepointer */
- int rewriteloglevel; /* the RewriteLog level of verbosity */
- ap_array_header_t *rewritemaps; /* the RewriteMap entries */
- ap_array_header_t *rewriteconds; /* the RewriteCond entries (temporary) */
- ap_array_header_t *rewriterules; /* the RewriteRule entries */
- server_rec *server; /* the corresponding server indicator */
-} rewrite_server_conf;
-
-
- /* the per-directory configuration
- * generated on-the-fly by Apache server for current request
- */
-typedef struct {
- int state; /* the RewriteEngine state */
- int options; /* the RewriteOption state */
- ap_array_header_t *rewriteconds; /* the RewriteCond entries (temporary) */
- ap_array_header_t *rewriterules; /* the RewriteRule entries */
- char *directory; /* the directory where it applies */
- char *baseurl; /* the base-URL where it applies */
-} rewrite_perdir_conf;
-
-
- /* the cache structures,
- * a 4-way hash ap_table_t with LRU functionality
- */
-typedef struct cacheentry {
- time_t time;
- char *key;
- char *value;
-} cacheentry;
-
-typedef struct tlbentry {
- int t[CACHE_TLB_COLS];
-} cachetlbentry;
-
-typedef struct cachelist {
- char *resource;
- ap_array_header_t *entries;
- ap_array_header_t *tlb;
-} cachelist;
-
-typedef struct cache {
- ap_context_t *pool;
- ap_array_header_t *lists;
-} cache;
-
-
- /* the regex structure for the
- * substitution of backreferences
- */
-typedef struct backrefinfo {
- char *source;
- int nsub;
- regmatch_t regmatch[10];
-} backrefinfo;
-
-
-/*
-**
-** forward declarations
-**
-*/
-
- /* config structure handling */
-static void *config_server_create(ap_context_t *p, server_rec *s);
-static void *config_server_merge (ap_context_t *p, void *basev, void *overridesv);
-static void *config_perdir_create(ap_context_t *p, char *path);
-static void *config_perdir_merge (ap_context_t *p, void *basev, void *overridesv);
-
- /* config directive handling */
-static const char *cmd_rewriteengine(cmd_parms *cmd,
- rewrite_perdir_conf *dconf, int flag);
-static const char *cmd_rewriteoptions(cmd_parms *cmd,
- rewrite_perdir_conf *dconf,
- char *option);
-static const char *cmd_rewriteoptions_setoption(ap_context_t *p, int *options,
- char *name);
-static const char *cmd_rewritelog (cmd_parms *cmd, void *dconf, char *a1);
-static const char *cmd_rewriteloglevel(cmd_parms *cmd, void *dconf, char *a1);
-static const char *cmd_rewritemap (cmd_parms *cmd, void *dconf, char *a1,
- char *a2);
-static const char *cmd_rewritelock(cmd_parms *cmd, void *dconf, char *a1);
-static const char *cmd_rewritebase(cmd_parms *cmd, rewrite_perdir_conf *dconf,
- char *a1);
-static const char *cmd_rewritecond(cmd_parms *cmd, rewrite_perdir_conf *dconf,
- char *str);
-static const char *cmd_rewritecond_parseflagfield(ap_context_t *p,
- rewritecond_entry *new,
- char *str);
-static const char *cmd_rewritecond_setflag(ap_context_t *p, rewritecond_entry *cfg,
- char *key, char *val);
-static const char *cmd_rewriterule(cmd_parms *cmd, rewrite_perdir_conf *dconf,
- char *str);
-static const char *cmd_rewriterule_parseflagfield(ap_context_t *p,
- rewriterule_entry *new,
- char *str);
-static const char *cmd_rewriterule_setflag(ap_context_t *p, rewriterule_entry *cfg,
- char *key, char *val);
-
- /* initialisation */
-static void init_module(ap_context_t *p,
- ap_context_t *plog,
- ap_context_t *ptemp,
- server_rec *s);
-static void init_child(ap_context_t *p, server_rec *s);
-
- /* runtime hooks */
-static int hook_uri2file (request_rec *r);
-static int hook_mimetype (request_rec *r);
-static int hook_fixup (request_rec *r);
-static int handler_redirect(request_rec *r);
-
- /* rewriting engine */
-static int apply_rewrite_list(request_rec *r, ap_array_header_t *rewriterules,
- char *perdir);
-static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p,
- char *perdir);
-static int apply_rewrite_cond(request_rec *r, rewritecond_entry *p,
- char *perdir, backrefinfo *briRR,
- backrefinfo *briRC);
-
- /* URI transformation function */
-static void splitout_queryargs(request_rec *r, int qsappend);
-static void fully_qualify_uri(request_rec *r);
-static void reduce_uri(request_rec *r);
-static void expand_backref_inbuffer(ap_context_t *p, char *buf, int nbuf,
- backrefinfo *bri, char c);
-static char *expand_tildepaths(request_rec *r, char *uri);
-static void expand_map_lookups(request_rec *r, char *uri, int uri_len);
-
- /* rewrite map support functions */
-static char *lookup_map(request_rec *r, char *name, char *key);
-static char *lookup_map_txtfile(request_rec *r, char *file, char *key);
-#ifndef NO_DBM_REWRITEMAP
-static char *lookup_map_dbmfile(request_rec *r, char *file, char *key);
-#endif
-static char *lookup_map_program(request_rec *r, ap_file_t *fpin,
- ap_file_t *fpout, char *key);
-static char *lookup_map_internal(request_rec *r,
- char *(*func)(request_rec *r, char *key),
- char *key);
-static char *rewrite_mapfunc_toupper(request_rec *r, char *key);
-static char *rewrite_mapfunc_tolower(request_rec *r, char *key);
-static char *rewrite_mapfunc_escape(request_rec *r, char *key);
-static char *rewrite_mapfunc_unescape(request_rec *r, char *key);
-static char *select_random_value_part(request_rec *r, char *value);
-static void rewrite_rand_init(void);
-static int rewrite_rand(int l, int h);
-
- /* rewriting logfile support */
-static void open_rewritelog(server_rec *s, ap_context_t *p);
-static void rewritelog(request_rec *r, int level, const char *text, ...)
- __attribute__((format(printf,3,4)));
-static char *current_logtime(request_rec *r);
-
- /* rewriting lockfile support */
-static void rewritelock_create(server_rec *s, ap_context_t *p);
-static void rewritelock_open(server_rec *s, ap_context_t *p);
-static ap_status_t rewritelock_remove(void *data);
-static void rewritelock_alloc(request_rec *r);
-static void rewritelock_free(request_rec *r);
-
- /* program map support */
-static void run_rewritemap_programs(server_rec *s, ap_context_t *p);
-static int rewritemap_program_child(ap_context_t *p, char *progname,
- ap_file_t **fpout, ap_file_t **fpin,
- ap_file_t **fperr);
-
- /* env variable support */
-static void expand_variables_inbuffer(request_rec *r, char *buf, int buf_len);
-static char *expand_variables(request_rec *r, char *str);
-static char *lookup_variable(request_rec *r, char *var);
-static char *lookup_header(request_rec *r, const char *name);
-
- /* caching functions */
-static cache *init_cache(ap_context_t *p);
-static char *get_cache_string(cache *c, char *res, int mode, time_t mtime,
- char *key);
-static void set_cache_string(cache *c, char *res, int mode, time_t mtime,
- char *key, char *value);
-static cacheentry *retrieve_cache_string(cache *c, char *res, char *key);
-static void store_cache_string(cache *c, char *res, cacheentry *ce);
-
- /* misc functions */
-static char *subst_prefix_path(request_rec *r, char *input, char *match,
- char *subst);
-static int parseargline(char *str, char **a1, char **a2, char **a3);
-static int prefix_stat(const char *path, struct stat *sb);
-static void add_env_variable(request_rec *r, char *s);
-
- /* File locking */
-static void fd_lock(request_rec *r, ap_file_t *fd);
-static void fd_unlock(request_rec *r, ap_file_t *fd);
-
- /* Lexicographic Comparison */
-static int compare_lexicography(char *cpNum1, char *cpNum2);
-
-#endif /* _MOD_REWRITE_H */
-
-/*EOF*/
diff --git a/modules/mappers/mod_so.c b/modules/mappers/mod_so.c
deleted file mode 100644
index 9d122c41c0..0000000000
--- a/modules/mappers/mod_so.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * This module is used to load Apache modules at runtime. This means that the
- * server functionality can be extended without recompiling and even without
- * taking the server down at all. Only a HUP or WINCH signal needs to be send
- * to the server to reload the dynamically loaded modules.
- *
- * To use, you'll first need to build your module as a shared library, then
- * update your configuration (httpd.conf) to get the Apache core to load the
- * module at start-up.
- *
- * The easiest way to build a module as a shared library is to use the
- * `SharedModule' command in the Configuration file, instead of `AddModule'.
- * You should also change the file extension from `.o' to `.so'. So, for
- * example, to build the status module as a shared library edit Configuration
- * and change
- * AddModule modules/standard/mod_status.o
- * to
- * SharedModule modules/standard/mod_status.so
- *
- * Run Configure and make. Now Apache's httpd binary will _not_ include
- * mod_status. Instead a shared object called mod_status.so will be build, in
- * the modules/standard directory. You can build most of the modules as shared
- * libraries like this.
- *
- * To use the shared module, move the .so file(s) into an appropriate
- * directory. You might like to create a directory called "modules" under you
- * server root for this (e.g. /usr/local/httpd/modules).
- *
- * Then edit your conf/httpd.conf file, and add LoadModule lines. For
- * example
- * LoadModule status_module modules/mod_status.so
- *
- * The first argument is the module's structure name (look at the end of the
- * module source to find this). The second option is the path to the module
- * file, relative to the server root. Put these directives right at the top
- * of your httpd.conf file.
- *
- * Now you can start Apache. A message will be logged at "debug" level to your
- * error_log to confirm that the module(s) are loaded (use "LogLevel debug"
- * directive to get these log messages).
- *
- * If you edit the LoadModule directives while the server is live you can get
- * Apache to re-load the modules by sending it a HUP or WINCH signal as normal.
- * You can use this to dynamically change the capability of your server
- * without bringing it down.
- *
- * Because currently there is only limited builtin support in the Configure
- * script for creating the shared library files (`.so'), please consult your
- * vendors cc(1), ld(1) and dlopen(3) manpages to find out the appropriate
- * compiler and linker flags and insert them manually into the Configuration
- * file under CFLAGS_SHLIB, LDFLAGS_SHLIB and LDFLAGS_SHLIB_EXPORT.
- *
- * If you still have problems figuring out the flags both try the paper
- * http://developer.netscape.com/library/documentation/enterprise
- * /unix/svrplug.htm#1013807
- * or install a Perl 5 interpreter on your platform and then run the command
- *
- * $ perl -V:usedl -V:ccdlflags -V:cccdlflags -V:lddlflags
- *
- * This gives you what type of dynamic loading Perl 5 uses on your platform
- * and which compiler and linker flags Perl 5 uses to create the shared object
- * files.
- *
- * Another location where you can find useful hints is the `ltconfig' script
- * of the GNU libtool 1.2 package. Search for your platform name inside the
- * various "case" constructs.
- *
- */
-
-
-#define CORE_PRIVATE
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-#include "ap_config.h"
-
-module MODULE_VAR_EXPORT so_module;
-
-
-/*
- * Server configuration to keep track of actually
- * loaded modules and the corresponding module name.
- */
-
-typedef struct moduleinfo {
- char *name;
- module *modp;
-} moduleinfo;
-
-typedef struct so_server_conf {
- ap_array_header_t *loaded_modules;
-} so_server_conf;
-
-static void *so_sconf_create(ap_context_t *p, server_rec *s)
-{
- so_server_conf *soc;
-
- soc = (so_server_conf *)ap_pcalloc(p, sizeof(so_server_conf));
- soc->loaded_modules = ap_make_array(p, DYNAMIC_MODULE_LIMIT,
- sizeof(moduleinfo));
-#ifndef NO_DLOPEN
- ap_os_dso_init();
-#endif
-
- return (void *)soc;
-}
-
-#ifndef NO_DLOPEN
-
-/*
- * This is the cleanup for a loaded shared object. It unloads the module.
- * This is called as a cleanup function from the core.
- */
-
-static ap_status_t unload_module(moduleinfo *modi)
-{
- /* only unload if module information is still existing */
- if (modi->modp == NULL)
- return APR_SUCCESS;
-
- /* remove the module pointer from the core structure */
- ap_remove_loaded_module(modi->modp);
-
- /* unload the module space itself */
- ap_os_dso_unload((ap_os_dso_handle_t)modi->modp->dynamic_load_handle);
-
- /* destroy the module information */
- modi->modp = NULL;
- modi->name = NULL;
- return APR_SUCCESS;
-}
-
-/*
- * This is the cleanup routine for files loaded by
- * load_file(). Unfortunately we don't keep a record of the filename
- * that was loaded, so we can't report the unload for debug purposes
- * or include the filename in error message.
- */
-
-static ap_status_t unload_file(void *handle)
-{
- ap_os_dso_unload((ap_os_dso_handle_t)handle);
- return APR_SUCCESS;
-}
-
-/*
- * This is called for the directive LoadModule and actually loads
- * a shared object file into the address space of the server process.
- */
-
-static const char *load_module(cmd_parms *cmd, void *dummy,
- char *modname, char *filename)
-{
- ap_os_dso_handle_t modhandle;
- module *modp;
- const char *szModuleFile=ap_server_root_relative(cmd->pool, filename);
- so_server_conf *sconf;
- moduleinfo *modi;
- moduleinfo *modie;
- int i;
-
- /*
- * check for already existing module
- * If it already exists, we have nothing to do
- */
- sconf = (so_server_conf *)ap_get_module_config(cmd->server->module_config,
- &so_module);
- modie = (moduleinfo *)sconf->loaded_modules->elts;
- for (i = 0; i < sconf->loaded_modules->nelts; i++) {
- modi = &modie[i];
- if (modi->name != NULL && strcmp(modi->name, modname) == 0)
- return NULL;
- }
- modi = ap_push_array(sconf->loaded_modules);
- modi->name = modname;
-
- /*
- * Load the file into the Apache address space
- */
- if (!(modhandle = ap_os_dso_load(szModuleFile))) {
- const char *my_error = ap_os_dso_error();
- return ap_pstrcat (cmd->pool, "Cannot load ", szModuleFile,
- " into server: ",
- my_error ? my_error : "(reason unknown)",
- NULL);
- }
- ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, NULL,
- "loaded module %s", modname);
-
- /*
- * Retrieve the pointer to the module structure through the module name:
- * First with the hidden variant (prefix `AP_') and then with the plain
- * symbol name.
- */
- if (!(modp = (module *)(ap_os_dso_sym(modhandle, modname)))) {
- return ap_pstrcat(cmd->pool, "Can't locate API module structure `", modname,
- "' in file ", szModuleFile, ": ", ap_os_dso_error(), NULL);
- }
- modi->modp = modp;
- modp->dynamic_load_handle = (void *)modhandle;
-
- /*
- * Make sure the found module structure is really a module structure
- *
- */
- if (modp->magic != MODULE_MAGIC_COOKIE) {
- return ap_pstrcat(cmd->pool, "API module structure `", modname,
- "' in file ", szModuleFile, " is garbled -"
- " perhaps this is not an Apache module DSO?", NULL);
- }
-
- /*
- * Add this module to the Apache core structures
- */
- ap_add_loaded_module(modp);
-
- /*
- * Register a cleanup in the config ap_context_t (normally pconf). When
- * we do a restart (or shutdown) this cleanup will cause the
- * shared object to be unloaded.
- */
- ap_register_cleanup(cmd->pool, modi,
- (ap_status_t (*)(void*))unload_module, ap_null_cleanup);
-
- /*
- * Finally we need to run the configuration process for the module
- */
- ap_single_module_configure(cmd->pool, cmd->server, modp);
-
- return NULL;
-}
-
-/*
- * This implements the LoadFile directive and loads an arbitrary
- * shared object file into the adress space of the server process.
- */
-
-static const char *load_file(cmd_parms *cmd, void *dummy, char *filename)
-{
- ap_os_dso_handle_t handle;
- const char *file;
-
- file = ap_server_root_relative(cmd->pool, filename);
-
- if (!(handle = ap_os_dso_load(file))) {
- const char *my_error = ap_os_dso_error();
- return ap_pstrcat (cmd->pool, "Cannot load ", filename,
- " into server:",
- my_error ? my_error : "(reason unknown)",
- NULL);
- }
-
- ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, NULL,
- "loaded file %s", filename);
-
- ap_register_cleanup(cmd->pool, (void *)handle, unload_file, ap_null_cleanup);
-
- return NULL;
-}
-
-#else /* not NO_DLOPEN */
-
-static const char *load_file(cmd_parms *cmd, void *dummy, char *filename)
-{
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: LoadFile not supported on this platform");
- return NULL;
-}
-
-static const char *load_module(cmd_parms *cmd, void *dummy,
- char *modname, char *filename)
-{
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: LoadModule not supported on this platform");
- return NULL;
-}
-
-#endif /* NO_DLOPEN */
-
-static const command_rec so_cmds[] = {
- { "LoadModule", load_module, NULL, RSRC_CONF, TAKE2,
- "a module name and the name of a shared object file to load it from"},
- { "LoadFile", load_file, NULL, RSRC_CONF, ITERATE,
- "shared object file or library to load into the server at runtime"},
- { NULL }
-};
-
-module MODULE_VAR_EXPORT so_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-dir config */
- NULL, /* merge per-dir config */
- so_sconf_create, /* server config */
- NULL, /* merge server config */
- so_cmds, /* command ap_table_t */
- NULL, /* handlers */
- NULL /* register hooks */
-};
diff --git a/modules/mappers/mod_speling.c b/modules/mappers/mod_speling.c
deleted file mode 100644
index 82a27a6ed6..0000000000
--- a/modules/mappers/mod_speling.c
+++ /dev/null
@@ -1,565 +0,0 @@
-#define WANT_BASENAME_MATCH
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#include "httpd.h"
-#include "http_core.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_log.h"
-#include "apr_file_io.h"
-
-/* mod_speling.c - by Alexei Kosut <akosut@organic.com> June, 1996
- *
- * 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 <Martin.Kraemer@Mch.SNI.De>
- * 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"
- */
-
-MODULE_VAR_EXPORT module speling_module;
-
-typedef struct {
- int enabled;
-} 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.
- */
-
-static void *mkconfig(ap_context_t *p)
-{
- spconfig *cfg = ap_pcalloc(p, sizeof(spconfig));
-
- cfg->enabled = 0;
- return cfg;
-}
-
-/*
- * Respond to a callback to create configuration record for a server or
- * vhost environment.
- */
-static void *create_mconfig_for_server(ap_context_t *p, server_rec *s)
-{
- return mkconfig(p);
-}
-
-/*
- * Respond to a callback to create a config record for a specific directory.
- */
-static void *create_mconfig_for_directory(ap_context_t *p, char *dir)
-{
- return mkconfig(p);
-}
-
-/*
- * Handler for the CheckSpelling directive, which is FLAG.
- */
-static const char *set_speling(cmd_parms *cmd, void *mconfig, int arg)
-{
- spconfig *cfg = (spconfig *) mconfig;
-
- cfg->enabled = arg;
- return NULL;
-}
-
-/*
- * Define the directives specific to this module. This structure is referenced
- * later by the 'module' structure.
- */
-static const command_rec speling_cmds[] =
-{
- { "CheckSpelling", set_speling, NULL, OR_OPTIONS, FLAG,
- "whether or not to fix miscapitalized/misspelled requests" },
- { NULL }
-};
-
-typedef enum {
- SP_IDENTICAL = 0,
- SP_MISCAPITALIZED = 1,
- SP_TRANSPOSITION = 2,
- SP_MISSINGCHAR = 3,
- SP_EXTRACHAR = 4,
- SP_SIMPLETYPO = 5,
- SP_VERYDIFFERENT = 6
-} sp_reason;
-
-static const char *sp_reason_str[] =
-{
- "identical",
- "miscapitalized",
- "transposed characters",
- "character missing",
- "extra character",
- "mistyped character",
- "common basename",
-};
-
-typedef struct {
- const char *name;
- sp_reason quality;
-} 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.
- */
-
-static sp_reason spdist(const char *s, const char *t)
-{
- for (; ap_tolower(*s) == ap_tolower(*t); t++, s++) {
- if (*t == '\0') {
- return SP_MISCAPITALIZED; /* exact match (sans case) */
- }
- }
- if (*s) {
- if (*t) {
- if (s[1] && t[1] && ap_tolower(*s) == ap_tolower(t[1])
- && ap_tolower(*t) == ap_tolower(s[1])
- && strcasecmp(s + 2, t + 2) == 0) {
- return SP_TRANSPOSITION; /* transposition */
- }
- if (strcasecmp(s + 1, t + 1) == 0) {
- return SP_SIMPLETYPO; /* 1 char mismatch */
- }
- }
- if (strcasecmp(s + 1, t) == 0) {
- return SP_EXTRACHAR; /* extra character */
- }
- }
- if (*t && strcasecmp(s, t + 1) == 0) {
- return SP_MISSINGCHAR; /* missing character */
- }
- return SP_VERYDIFFERENT; /* distance too large to fix. */
-}
-
-static int sort_by_quality(const void *left, const void *rite)
-{
- return (int) (((misspelled_file *) left)->quality)
- - (int) (((misspelled_file *) rite)->quality);
-}
-
-static int check_speling(request_rec *r)
-{
- spconfig *cfg;
- char *good, *bad, *postgood, *url, *fname;
- int filoc, dotloc, urlen, pglen;
- ap_array_header_t *candidates = NULL;
- ap_dir_t *dir;
-
- cfg = ap_get_module_config(r->per_dir_config, &speling_module);
- if (!cfg->enabled) {
- return DECLINED;
- }
-
- /* We only want to worry about GETs */
- if (r->method_number != M_GET) {
- return DECLINED;
- }
-
- /* We've already got a file of some kind or another */
- if (r->proxyreq || (r->finfo.protection != 0)) {
- return DECLINED;
- }
-
- /* This is a sub request - don't mess with it */
- if (r->main) {
- return DECLINED;
- }
-
- /*
- * 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 || strcmp(r->uri, "/") == 0) {
- return DECLINED;
- }
-
- /* good = /correct-file */
- good = ap_pstrndup(r->pool, r->filename, filoc);
- /* bad = mispelling */
- bad = ap_pstrdup(r->pool, r->filename + filoc + 1);
- /* postgood = mispelling/more */
- postgood = ap_pstrcat(r->pool, bad, r->path_info, NULL);
-
- urlen = strlen(r->uri);
- pglen = strlen(postgood);
-
- /* Check to see if the URL pieces add up */
- if (strcmp(postgood, r->uri + (urlen - pglen))) {
- return DECLINED;
- }
-
- /* url = /correct-url */
- url = ap_pstrndup(r->pool, r->uri, (urlen - pglen));
-
- /* Now open the directory and do ourselves a check... */
- if (ap_opendir(&dir, good, r->pool) != APR_SUCCESS) {
- /* Oops, not a directory... */
- return DECLINED;
- }
-
- candidates = ap_make_array(r->pool, 2, sizeof(misspelled_file));
-
- dotloc = ap_ind(bad, '.');
- if (dotloc == -1) {
- dotloc = strlen(bad);
- }
-
- /* NOTE: ap_get_dir_filename() fills fname with a ap_palloc()ed copy
- * of the found directory name already. We don't need to copy it.
- * @@@: Copying *ALL* found file names is wasted energy (and memory)!
- */
- while (ap_readdir(dir) == APR_SUCCESS &&
- ap_get_dir_filename(&fname, dir) == APR_SUCCESS) {
- sp_reason q;
-
- /*
- * 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 (strcmp(bad, fname) == 0) {
- ap_closedir(dir);
- return OK;
- }
-
- /*
- * miscapitalization errors are checked first (like, e.g., lower case
- * file, upper case request)
- */
- else if (strcasecmp(bad, fname) == 0) {
- misspelled_file *sp_new;
-
- sp_new = (misspelled_file *) ap_push_array(candidates);
- sp_new->name = fname;
- sp_new->quality = SP_MISCAPITALIZED;
- }
-
- /*
- * simple typing errors are checked next (like, e.g.,
- * missing/extra/transposed char)
- */
- else if ((q = spdist(bad, fname)) != SP_VERYDIFFERENT) {
- misspelled_file *sp_new;
-
- sp_new = (misspelled_file *) ap_push_array(candidates);
- sp_new->name = fname;
- sp_new->quality = q;
- }
-
- /*
- * 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 <Martin.Kraemer@Mch.SNI.De>
- *
- * 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 {
-#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.
- */
- int entloc = ap_ind(fname, '.');
- if (entloc == -1) {
- entloc = strlen(fname);
- }
-
- if ((dotloc == entloc)
- && !strncasecmp(bad, fname, dotloc)) {
- misspelled_file *sp_new;
-
- sp_new = (misspelled_file *) ap_push_array(candidates);
- sp_new->name = fname;
- sp_new->quality = SP_VERYDIFFERENT;
- }
-#endif
- }
- }
- ap_closedir(dir);
-
- if (candidates->nelts != 0) {
- /* Wow... we found us a mispelling. Construct a fixed url */
- char *nuri;
- const char *ref;
- misspelled_file *variant = (misspelled_file *) candidates->elts;
- int i;
-
- ref = ap_table_get(r->headers_in, "Referer");
-
- qsort((void *) candidates->elts, candidates->nelts,
- sizeof(misspelled_file), sort_by_quality);
-
- /*
- * 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.
- */
- if (variant[0].quality != SP_VERYDIFFERENT
- && (candidates->nelts == 1
- || variant[0].quality != variant[1].quality)) {
-
- nuri = ap_escape_uri(r->pool, ap_pstrcat(r->pool, url,
- variant[0].name,
- r->path_info, NULL));
- if (r->parsed_uri.query)
- nuri = ap_pstrcat(r->pool, nuri, "?", r->parsed_uri.query, NULL);
-
- ap_table_setn(r->headers_out, "Location",
- ap_construct_url(r->pool, nuri, r));
-
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, APR_SUCCESS,
- r,
- ref ? "Fixed spelling: %s to %s from %s"
- : "Fixed spelling: %s to %s",
- r->uri, nuri, ref);
-
- return HTTP_MOVED_PERMANENTLY;
- }
- /*
- * Otherwise, a "[300] Multiple Choices" list with the variants is
- * returned.
- */
- else {
- ap_context_t *p;
- ap_table_t *notes;
- ap_context_t *sub_pool;
- ap_array_header_t *t;
- ap_array_header_t *v;
-
-
- if (r->main == NULL) {
- p = r->pool;
- notes = r->notes;
- }
- else {
- p = r->main->pool;
- notes = r->main->notes;
- }
-
- if (ap_create_context(&sub_pool, p) != APR_SUCCESS)
- return DECLINED;
-
- t = ap_make_array(sub_pool, candidates->nelts * 8 + 8,
- sizeof(char *));
- v = ap_make_array(sub_pool, candidates->nelts * 5,
- sizeof(char *));
-
- /* Generate the response text. */
-
- *(const char **)ap_push_array(t) =
- "The document name you requested (<code>";
- *(const char **)ap_push_array(t) = r->uri;
- *(const char **)ap_push_array(t) =
- "</code>) could not be found on this server.\n"
- "However, we found documents with names similar "
- "to the one you requested.<p>"
- "Available documents:\n<ul>\n";
-
- for (i = 0; i < candidates->nelts; ++i) {
- char *vuri;
- const char *reason;
-
- reason = sp_reason_str[(int) (variant[i].quality)];
- /* The format isn't very neat... */
- vuri = ap_pstrcat(sub_pool, url, variant[i].name, r->path_info,
- (r->parsed_uri.query != NULL) ? "?" : "",
- (r->parsed_uri.query != NULL)
- ? r->parsed_uri.query : "",
- NULL);
- *(const char **)ap_push_array(v) = "\"";
- *(const char **)ap_push_array(v) = vuri;
- *(const char **)ap_push_array(v) = "\";\"";
- *(const char **)ap_push_array(v) = reason;
- *(const char **)ap_push_array(v) = "\"";
-
- *(const char **)ap_push_array(t) = "<li><a href=\"";
- *(const char **)ap_push_array(t) = vuri;
- *(const char **)ap_push_array(t) = "\">";
- *(const char **)ap_push_array(t) = vuri;
- *(const char **)ap_push_array(t) = "</a> (";
- *(const char **)ap_push_array(t) = reason;
- *(const char **)ap_push_array(t) = ")\n";
-
- /*
- * 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 && i < candidates->nelts - 1
- && variant[i].quality != SP_VERYDIFFERENT
- && variant[i + 1].quality == SP_VERYDIFFERENT) {
- *(const char **)ap_push_array(t) =
- "</ul>\nFurthermore, the following related "
- "documents were found:\n<ul>\n";
- }
- }
- *(const char **)ap_push_array(t) = "</ul>\n";
-
- /* If we know there was a referring page, add a note: */
- if (ref != NULL) {
- *(const char **)ap_push_array(t) =
- "Please consider informing the owner of the "
- "<a href=\"";
- *(const char **)ap_push_array(t) = ref;
- *(const char **)ap_push_array(t) = "\">referring page</a> "
- "about the broken link.\n";
- }
-
-
- /* Pass our ap_table_t to http_protocol.c (see mod_negotiation): */
- ap_table_setn(notes, "variant-list", ap_array_pstrcat(p, t, 0));
-
- ap_table_mergen(r->subprocess_env, "VARIANTS",
- ap_array_pstrcat(p, v, ','));
-
- ap_destroy_pool(sub_pool);
-
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, 0, r,
- ref ? "Spelling fix: %s: %d candidates from %s"
- : "Spelling fix: %s: %d candidates",
- r->uri, candidates->nelts, ref);
-
- return HTTP_MULTIPLE_CHOICES;
- }
- }
-
- return OK;
-}
-
-static void register_hooks(void)
-{
- ap_hook_fixups(check_speling,NULL,NULL,HOOK_LAST);
-}
-
-module MODULE_VAR_EXPORT speling_module =
-{
- STANDARD20_MODULE_STUFF,
- create_mconfig_for_directory, /* create per-dir config */
- NULL, /* merge per-dir config */
- create_mconfig_for_server, /* server config */
- NULL, /* merge server config */
- speling_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/mappers/mod_speling.dsp b/modules/mappers/mod_speling.dsp
deleted file mode 100644
index 904054ae66..0000000000
--- a/modules/mappers/mod_speling.dsp
+++ /dev/null
@@ -1,113 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheModuleSpeling" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheModuleSpeling - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleSpeling.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleSpeling.mak"\
- CFG="ApacheModuleSpeling - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheModuleSpeling - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheModuleSpeling - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheModuleSpeling - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\Release"
-# PROP BASE Intermediate_Dir ".\Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\ApacheModuleSpelingR"
-# PROP Intermediate_Dir ".\ApacheModuleSpelingR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ..\..\CoreR\ApacheCore.lib ..\..\lib\apr\Release\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheModuleSpeling - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\Debug"
-# PROP BASE Intermediate_Dir ".\Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\ApacheModuleSpelingD"
-# PROP Intermediate_Dir ".\ApacheModuleSpelingD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ..\..\CoreD\ApacheCore.lib ..\..\lib\apr\Debug\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheModuleSpeling - Win32 Release"
-# Name "ApacheModuleSpeling - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=..\..\modules\standard\mod_speling.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\readdir.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/modules/mappers/mod_speling.exp b/modules/mappers/mod_speling.exp
deleted file mode 100644
index a6ee8b5034..0000000000
--- a/modules/mappers/mod_speling.exp
+++ /dev/null
@@ -1 +0,0 @@
-speling_module
diff --git a/modules/mappers/mod_userdir.c b/modules/mappers/mod_userdir.c
deleted file mode 100644
index ec27429b13..0000000000
--- a/modules/mappers/mod_userdir.c
+++ /dev/null
@@ -1,356 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_userdir... implement the UserDir command. Broken away from the
- * Alias stuff for a couple of good and not-so-good reasons:
- *
- * 1) It shows a real minimal working example of how to do something like
- * this.
- * 2) I know people who are actually interested in changing this *particular*
- * aspect of server functionality without changing the rest of it. That's
- * what this whole modular arrangement is supposed to be good at...
- *
- * Modified by Alexei Kosut to support the following constructs
- * (server running at www.foo.com, request for /~bar/one/two.html)
- *
- * UserDir public_html -> ~bar/public_html/one/two.html
- * UserDir /usr/web -> /usr/web/bar/one/two.html
- * UserDir /home/ * /www -> /home/bar/www/one/two.html
- * NOTE: theses ^ ^ space only added allow it to work in a comment, ignore
- * UserDir http://x/users -> (302) http://x/users/bar/one/two.html
- * UserDir http://x/ * /y -> (302) http://x/bar/y/one/two.html
- * NOTE: here also ^ ^
- *
- * In addition, you can use multiple entries, to specify alternate
- * user directories (a la Directory Index). For example:
- *
- * UserDir public_html /usr/web http://www.xyz.com/users
- *
- * Modified by Ken Coar to provide for the following:
- *
- * UserDir disable[d] username ...
- * UserDir enable[d] username ...
- *
- * If "disabled" has no other arguments, *all* ~<username> references are
- * disabled, except those explicitly turned on with the "enabled" keyword.
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-
-/* The default directory in user's home dir */
-#ifndef DEFAULT_USER_DIR
-#define DEFAULT_USER_DIR "public_html"
-#endif
-
-module userdir_module;
-
-typedef struct userdir_config {
- int globally_disabled;
- char *userdir;
- ap_table_t *enabled_users;
- ap_table_t *disabled_users;
-} userdir_config;
-
-/*
- * Server config for this module: global disablement flag, a list of usernames
- * ineligible for UserDir access, a list of those immune to global (but not
- * explicit) disablement, and the replacement string for all others.
- */
-
-static void *create_userdir_config(ap_context_t *p, server_rec *s)
-{
- userdir_config
- * newcfg = (userdir_config *) ap_pcalloc(p, sizeof(userdir_config));
-
- newcfg->globally_disabled = 0;
- newcfg->userdir = DEFAULT_USER_DIR;
- newcfg->enabled_users = ap_make_table(p, 4);
- newcfg->disabled_users = ap_make_table(p, 4);
- return (void *) newcfg;
-}
-
-#define O_DEFAULT 0
-#define O_ENABLE 1
-#define O_DISABLE 2
-
-static const char *set_user_dir(cmd_parms *cmd, void *dummy, char *arg)
-{
- userdir_config
- * s_cfg = (userdir_config *) ap_get_module_config
- (
- cmd->server->module_config,
- &userdir_module
- );
- char *username;
- const char
- *usernames = arg;
- char *kw = ap_getword_conf(cmd->pool, &usernames);
- ap_table_t *usertable;
-
- /*
- * Let's do the comparisons once.
- */
- if ((!strcasecmp(kw, "disable")) || (!strcasecmp(kw, "disabled"))) {
- /*
- * If there are no usernames specified, this is a global disable - we
- * need do no more at this point than record the fact.
- */
- if (strlen(usernames) == 0) {
- s_cfg->globally_disabled = 1;
- return NULL;
- }
- usertable = s_cfg->disabled_users;
- }
- else if ((!strcasecmp(kw, "enable")) || (!strcasecmp(kw, "enabled"))) {
- /*
- * The "disable" keyword can stand alone or take a list of names, but
- * the "enable" keyword requires the list. Whinge if it doesn't have
- * it.
- */
- if (strlen(usernames) == 0) {
- return "UserDir \"enable\" keyword requires a list of usernames";
- }
- usertable = s_cfg->enabled_users;
- }
- else {
- /*
- * If the first (only?) value isn't one of our keywords, just copy
- * the string to the userdir string.
- */
- s_cfg->userdir = ap_pstrdup(cmd->pool, arg);
- return NULL;
- }
- /*
- * Now we just take each word in turn from the command line and add it to
- * the appropriate table.
- */
- while (*usernames) {
- username = ap_getword_conf(cmd->pool, &usernames);
- ap_table_setn(usertable, username, kw);
- }
- return NULL;
-}
-
-static const command_rec userdir_cmds[] = {
- {"UserDir", set_user_dir, NULL, RSRC_CONF, RAW_ARGS,
- "the public subdirectory in users' home directories, or 'disabled', or 'disabled username username...', or 'enabled username username...'"},
- {NULL}
-};
-
-static int translate_userdir(request_rec *r)
-{
- void *server_conf = r->server->module_config;
- const userdir_config *s_cfg =
- (userdir_config *) ap_get_module_config(server_conf, &userdir_module);
- char *name = r->uri;
- const char *userdirs = s_cfg->userdir;
- const char *w, *dname;
- char *redirect;
- char *x = NULL;
- ap_finfo_t statbuf;
-
- /*
- * If the URI doesn't match our basic pattern, we've nothing to do with
- * it.
- */
- if (
- (s_cfg->userdir == NULL) ||
- (name[0] != '/') ||
- (name[1] != '~')
- ) {
- return DECLINED;
- }
-
- dname = name + 2;
- w = ap_getword(r->pool, &dname, '/');
-
- /*
- * The 'dname' funny business involves backing it up to capture the '/'
- * delimiting the "/~user" part from the rest of the URL, in case there
- * was one (the case where there wasn't being just "GET /~user HTTP/1.0",
- * for which we don't want to tack on a '/' onto the filename).
- */
-
- if (dname[-1] == '/') {
- --dname;
- }
-
- /*
- * If there's no username, it's not for us. Ignore . and .. as well.
- */
- if (w[0] == '\0' || (w[1] == '.' && (w[2] == '\0' || (w[2] == '.' && w[3] == '\0')))) {
- return DECLINED;
- }
- /*
- * Nor if there's an username but it's in the disabled list.
- */
- if (ap_table_get(s_cfg->disabled_users, w) != NULL) {
- return DECLINED;
- }
- /*
- * If there's a global interdiction on UserDirs, check to see if this
- * name is one of the Blessed.
- */
- if (
- s_cfg->globally_disabled &&
- (ap_table_get(s_cfg->enabled_users, w) == NULL)
- ) {
- return DECLINED;
- }
-
- /*
- * Special cases all checked, onward to normal substitution processing.
- */
-
- while (*userdirs) {
- const char *userdir = ap_getword_conf(r->pool, &userdirs);
- char *filename = NULL;
-
- if (strchr(userdir, '*'))
- x = ap_getword(r->pool, &userdir, '*');
-
- if (userdir[0] == '\0' || ap_os_is_path_absolute(userdir)) {
- if (x) {
-#ifdef HAVE_DRIVE_LETTERS
- /*
- * Crummy hack. Need to figure out whether we have been
- * redirected to a URL or to a file on some drive. Since I
- * know of no protocols that are a single letter, if the : is
- * the second character, I will assume a file was specified
- */
- if (strchr(x + 2, ':'))
-#else
- if (strchr(x, ':'))
-#endif /* WIN32 */
- {
- redirect = ap_pstrcat(r->pool, x, w, userdir, dname, NULL);
- ap_table_setn(r->headers_out, "Location", redirect);
- return REDIRECT;
- }
- else
- filename = ap_pstrcat(r->pool, x, w, userdir, NULL);
- }
- else
- filename = ap_pstrcat(r->pool, userdir, "/", w, NULL);
- }
- else if (strchr(userdir, ':')) {
- redirect = ap_pstrcat(r->pool, userdir, "/", w, dname, NULL);
- ap_table_setn(r->headers_out, "Location", redirect);
- return REDIRECT;
- }
- else {
-#ifdef WIN32
- /* Need to figure out home dirs on NT */
- return DECLINED;
-#else /* WIN32 */
- struct passwd *pw;
- if ((pw = getpwnam(w))) {
-#ifdef OS2
- /* Need to manually add user name for OS/2 */
- filename = ap_pstrcat(r->pool, pw->pw_dir, w, "/", userdir, NULL);
-#else
- filename = ap_pstrcat(r->pool, pw->pw_dir, "/", userdir, NULL);
-#endif
- }
-#endif /* WIN32 */
- }
-
- /*
- * Now see if it exists, or we're at the last entry. If we are at the
- * last entry, then use the filename generated (if there is one)
- * anyway, in the hope that some handler might handle it. This can be
- * used, for example, to run a CGI script for the user.
- */
- if (filename && (!*userdirs ||
- ap_stat(&statbuf, filename, r->pool) == APR_SUCCESS)) {
- r->filename = ap_pstrcat(r->pool, filename, dname, NULL);
- /* when statbuf contains info on r->filename we can save a syscall
- * by copying it to r->finfo
- */
- if (*userdirs && dname[0] == 0)
- r->finfo = statbuf;
- return OK;
- }
- }
-
- return DECLINED;
-}
-
-static void register_hooks(void)
-{
- static const char * const aszSucc[]={ "mod_alias.c",NULL };
-
- ap_hook_translate_name(translate_userdir,NULL,aszSucc,HOOK_MIDDLE);
-}
-
-module userdir_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- create_userdir_config, /* server config */
- NULL, /* merge server config */
- userdir_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/mappers/mod_userdir.exp b/modules/mappers/mod_userdir.exp
deleted file mode 100644
index 6b8b81d5c3..0000000000
--- a/modules/mappers/mod_userdir.exp
+++ /dev/null
@@ -1 +0,0 @@
-userdir_module
diff --git a/modules/mappers/mod_vhost_alias.c b/modules/mappers/mod_vhost_alias.c
deleted file mode 100644
index a8335386c9..0000000000
--- a/modules/mappers/mod_vhost_alias.c
+++ /dev/null
@@ -1,476 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_vhost_alias.c: support for dynamically configured mass virtual hosting
- *
- * Copyright (c) 1998-1999 Demon Internet Ltd.
- *
- * This software was submitted by Demon Internet to the Apache Group
- * in May 1999. Future revisions and derivatives of this source code
- * must acknowledge Demon Internet as the original contributor of
- * this module. All other licensing and usage conditions are those
- * of the Apache Group.
- *
- * Originally written by Tony Finch <fanf@demon.net> <dot@dotat.at>.
- *
- * Implementation ideas were taken from mod_alias.c. The overall
- * concept is derived from the OVERRIDE_DOC_ROOT/OVERRIDE_CGIDIR
- * patch to Apache 1.3b3 and a similar feature in Demon's thttpd,
- * both written by James Grinter <jrg@blodwen.demon.co.uk>.
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-
-
-module MODULE_VAR_EXPORT vhost_alias_module;
-
-
-/*
- * basic configuration things
- * we abbreviate "mod_vhost_alias" to "mva" for shorter names
- */
-
-typedef enum {
- VHOST_ALIAS_UNSET, VHOST_ALIAS_NONE, VHOST_ALIAS_NAME, VHOST_ALIAS_IP
-} mva_mode_e;
-
-/*
- * Per-server module config record.
- */
-typedef struct mva_sconf_t {
- char *doc_root;
- char *cgi_root;
- mva_mode_e doc_root_mode;
- mva_mode_e cgi_root_mode;
-} mva_sconf_t;
-
-static void *mva_create_server_config(ap_context_t *p, server_rec *s)
-{
- mva_sconf_t *conf;
-
- conf = (mva_sconf_t *) ap_pcalloc(p, sizeof(mva_sconf_t));
- conf->doc_root = NULL;
- conf->cgi_root = NULL;
- conf->doc_root_mode = VHOST_ALIAS_UNSET;
- conf->cgi_root_mode = VHOST_ALIAS_UNSET;
- return conf;
-}
-
-static void *mva_merge_server_config(ap_context_t *p, void *parentv, void *childv)
-{
- mva_sconf_t *parent = (mva_sconf_t *) parentv;
- mva_sconf_t *child = (mva_sconf_t *) childv;
- mva_sconf_t *conf;
-
- conf = (mva_sconf_t *) ap_pcalloc(p, sizeof(*conf));
- if (child->doc_root_mode == VHOST_ALIAS_UNSET) {
- conf->doc_root_mode = parent->doc_root_mode;
- conf->doc_root = parent->doc_root;
- }
- else {
- conf->doc_root_mode = child->doc_root_mode;
- conf->doc_root = child->doc_root;
- }
- if (child->cgi_root_mode == VHOST_ALIAS_UNSET) {
- conf->cgi_root_mode = parent->cgi_root_mode;
- conf->cgi_root = parent->cgi_root;
- }
- else {
- conf->cgi_root_mode = child->cgi_root_mode;
- conf->cgi_root = child->cgi_root;
- }
- return conf;
-}
-
-
-/*
- * These are just here to tell us what vhost_alias_set should do.
- * We don't put anything into them; we just use the cell addresses.
- */
-static int vhost_alias_set_doc_root_ip,
- vhost_alias_set_cgi_root_ip,
- vhost_alias_set_doc_root_name,
- vhost_alias_set_cgi_root_name;
-
-static const char *vhost_alias_set(cmd_parms *cmd, void *dummy, char *map)
-{
- mva_sconf_t *conf;
- mva_mode_e mode, *pmode;
- char **pmap;
- char *p;
-
- conf = (mva_sconf_t *) ap_get_module_config(cmd->server->module_config,
- &vhost_alias_module);
- /* there ought to be a better way of doing this */
- if (&vhost_alias_set_doc_root_ip == cmd->info) {
- mode = VHOST_ALIAS_IP;
- pmap = &conf->doc_root;
- pmode = &conf->doc_root_mode;
- }
- else if (&vhost_alias_set_cgi_root_ip == cmd->info) {
- mode = VHOST_ALIAS_IP;
- pmap = &conf->cgi_root;
- pmode = &conf->cgi_root_mode;
- }
- else if (&vhost_alias_set_doc_root_name == cmd->info) {
- mode = VHOST_ALIAS_NAME;
- pmap = &conf->doc_root;
- pmode = &conf->doc_root_mode;
- }
- else if (&vhost_alias_set_cgi_root_name == cmd->info) {
- mode = VHOST_ALIAS_NAME;
- pmap = &conf->cgi_root;
- pmode = &conf->cgi_root_mode;
- }
- else {
- return "INTERNAL ERROR: unknown command info";
- }
-
- if (*map != '/') {
- if (strcasecmp(map, "none")) {
- return "format string must start with '/' or be 'none'";
- }
- *pmap = NULL;
- *pmode = VHOST_ALIAS_NONE;
- return NULL;
- }
-
- /* sanity check */
- p = map;
- while (*p != '\0') {
- if (*p++ != '%') {
- continue;
- }
- /* we just found a '%' */
- if (*p == 'p' || *p == '%') {
- ++p;
- continue;
- }
- /* optional dash */
- if (*p == '-') {
- ++p;
- }
- /* digit N */
- if (ap_isdigit(*p)) {
- ++p;
- }
- else {
- return "syntax error in format string";
- }
- /* optional plus */
- if (*p == '+') {
- ++p;
- }
- /* do we end here? */
- if (*p != '.') {
- continue;
- }
- ++p;
- /* optional dash */
- if (*p == '-') {
- ++p;
- }
- /* digit M */
- if (ap_isdigit(*p)) {
- ++p;
- }
- else {
- return "syntax error in format string";
- }
- /* optional plus */
- if (*p == '+') {
- ++p;
- }
- }
- *pmap = map;
- *pmode = mode;
- return NULL;
-}
-
-static const command_rec mva_commands[] =
-{
- {"VirtualScriptAlias", vhost_alias_set, &vhost_alias_set_cgi_root_name,
- RSRC_CONF, TAKE1, "how to create a ScriptAlias based on the host"},
- {"VirtualDocumentRoot", vhost_alias_set, &vhost_alias_set_doc_root_name,
- RSRC_CONF, TAKE1, "how to create the DocumentRoot based on the host"},
- {"VirtualScriptAliasIP", vhost_alias_set, &vhost_alias_set_cgi_root_ip,
- RSRC_CONF, TAKE1, "how to create a ScriptAlias based on the host"},
- {"VirtualDocumentRootIP", vhost_alias_set, &vhost_alias_set_doc_root_ip,
- RSRC_CONF, TAKE1, "how to create the DocumentRoot based on the host"},
- { NULL }
-};
-
-
-/*
- * This really wants to be a nested function
- * but C is too feeble to support them.
- */
-static ap_inline void vhost_alias_checkspace(request_rec *r, char *buf,
- char **pdest, int size)
-{
- /* XXX: what if size > HUGE_STRING_LEN? */
- if (*pdest + size > buf + HUGE_STRING_LEN) {
- **pdest = '\0';
- if (r->filename) {
- r->filename = ap_pstrcat(r->pool, r->filename, buf, NULL);
- }
- else {
- r->filename = ap_pstrdup(r->pool, buf);
- }
- *pdest = buf;
- }
-}
-
-static void vhost_alias_interpolate(request_rec *r, const char *name,
- const char *map, const char *uri)
-{
- /* 0..9 9..0 */
- enum { MAXDOTS = 19 };
- const char *dots[MAXDOTS+1];
- int ndots;
-
- char buf[HUGE_STRING_LEN];
- char *dest, last;
-
- int N, M, Np, Mp, Nd, Md;
- const char *start, *end;
-
- const char *p;
-
- ndots = 0;
- dots[ndots++] = name-1; /* slightly naughty */
- for (p = name; *p; ++p){
- if (*p == '.' && ndots < MAXDOTS) {
- dots[ndots++] = p;
- }
- }
- dots[ndots] = p;
-
- r->filename = NULL;
-
- dest = buf;
- last = '\0';
- while (*map) {
- if (*map != '%') {
- /* normal characters */
- vhost_alias_checkspace(r, buf, &dest, 1);
- last = *dest++ = *map++;
- continue;
- }
- /* we are in a format specifier */
- ++map;
- /* can't be a slash */
- last = '\0';
- /* %% -> % */
- if (*map == '%') {
- ++map;
- vhost_alias_checkspace(r, buf, &dest, 1);
- *dest++ = '%';
- continue;
- }
- /* port number */
- if (*map == 'p') {
- ++map;
- /* no. of decimal digits in a short plus one */
- vhost_alias_checkspace(r, buf, &dest, 7);
- dest += ap_snprintf(dest, 7, "%d", ap_get_server_port(r));
- continue;
- }
- /* deal with %-N+.-M+ -- syntax is already checked */
- N = M = 0; /* value */
- Np = Mp = 0; /* is there a plus? */
- Nd = Md = 0; /* is there a dash? */
- if (*map == '-') ++map, Nd = 1;
- N = *map++ - '0';
- if (*map == '+') ++map, Np = 1;
- if (*map == '.') {
- ++map;
- if (*map == '-') {
- ++map, Md = 1;
- }
- M = *map++ - '0';
- if (*map == '+') {
- ++map, Mp = 1;
- }
- }
- /* note that N and M are one-based indices, not zero-based */
- start = dots[0]+1; /* ptr to the first character */
- end = dots[ndots]; /* ptr to the character after the last one */
- if (N != 0) {
- if (N > ndots) {
- start = "_";
- end = start+1;
- }
- else if (!Nd) {
- start = dots[N-1]+1;
- if (!Np) {
- end = dots[N];
- }
- }
- else {
- if (!Np) {
- start = dots[ndots-N]+1;
- }
- end = dots[ndots-N+1];
- }
- }
- if (M != 0) {
- if (M > end - start) {
- start = "_";
- end = start+1;
- }
- else if (!Md) {
- start = start+M-1;
- if (!Mp) {
- end = start+1;
- }
- }
- else {
- if (!Mp) {
- start = end-M;
- }
- end = end-M+1;
- }
- }
- vhost_alias_checkspace(r, buf, &dest, end - start);
- for (p = start; p < end; ++p) {
- *dest++ = ap_tolower(*p);
- }
- }
- *dest = '\0';
- /* no double slashes */
- if (last == '/') {
- ++uri;
- }
- if (r->filename) {
- r->filename = ap_pstrcat(r->pool, r->filename, buf, uri, NULL);
- }
- else {
- r->filename = ap_pstrcat(r->pool, buf, uri, NULL);
- }
-}
-
-static int mva_translate(request_rec *r)
-{
- mva_sconf_t *conf;
- const char *name, *map, *uri;
- mva_mode_e mode;
- int cgi;
-
- conf = (mva_sconf_t *) ap_get_module_config(r->server->module_config,
- &vhost_alias_module);
- if (!strncmp(r->uri, "/cgi-bin/", 9)) {
- mode = conf->cgi_root_mode;
- map = conf->cgi_root;
- uri = r->uri + 8;
- /*
- * can't force cgi immediately because we might not handle this
- * call if the mode is wrong
- */
- cgi = 1;
- }
- else if (r->uri[0] == '/') {
- mode = conf->doc_root_mode;
- map = conf->doc_root;
- uri = r->uri;
- cgi = 0;
- }
- else {
- return DECLINED;
- }
-
- if (mode == VHOST_ALIAS_NAME) {
- name = ap_get_server_name(r);
- }
- else if (mode == VHOST_ALIAS_IP) {
- name = r->connection->local_ip;
- }
- else {
- return DECLINED;
- }
-
- vhost_alias_interpolate(r, name, map, uri);
-
- if (cgi) {
- /* see is_scriptaliased() in mod_cgi */
- r->handler = "cgi-script";
- ap_table_setn(r->notes, "alias-forced-type", r->handler);
- }
-
- return OK;
-}
-
-static void register_hooks(void)
-{
- ap_hook_translate_name(mva_translate, NULL, NULL, HOOK_MIDDLE);
-};
-
-module MODULE_VAR_EXPORT vhost_alias_module =
-{
- STANDARD20_MODULE_STUFF,
- NULL, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- mva_create_server_config, /* server config */
- mva_merge_server_config, /* merge server configs */
- mva_commands, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
-
diff --git a/modules/metadata/.indent.pro b/modules/metadata/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/metadata/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/metadata/mod_cern_meta.c b/modules/metadata/mod_cern_meta.c
deleted file mode 100644
index dc4d0999a9..0000000000
--- a/modules/metadata/mod_cern_meta.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * IT'S 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_cern_meta.c
- * version 0.1.0
- * status beta
- *
- * Andrew Wilson <Andrew.Wilson@cm.cf.ac.uk> 25.Jan.96
- *
- * *** IMPORTANT ***
- * This version of mod_cern_meta.c controls Meta File behaviour on a
- * per-directory basis. Previous versions of the module defined behaviour
- * on a per-server basis. The upshot is that you'll need to revisit your
- * configuration files in order to make use of the new module.
- * ***
- *
- * Emulate the CERN HTTPD Meta file semantics. Meta files are HTTP
- * headers that can be output in addition to the normal range of
- * headers for each file accessed. They appear rather like the Apache
- * .asis files, and are able to provide a crude way of influencing
- * the Expires: header, as well as providing other curiosities.
- * There are many ways to manage meta information, this one was
- * chosen because there is already a large number of CERN users
- * who can exploit this module. It should be noted that there are probably
- * more sensitive ways of managing the Expires: header specifically.
- *
- * The module obeys the following directives, which can appear
- * in the server's .conf files and in .htaccess files.
- *
- * MetaFiles <on|off>
- *
- * turns on|off meta file processing for any directory.
- * Default value is off
- *
- * # turn on MetaFiles in this directory
- * MetaFiles on
- *
- * MetaDir <directory name>
- *
- * specifies the name of the directory in which Apache can find
- * meta information files. The directory is usually a 'hidden'
- * subdirectory of the directory that contains the file being
- * accessed. eg:
- *
- * # .meta files are in the *same* directory as the
- * # file being accessed
- * MetaDir .
- *
- * the default is to look in a '.web' subdirectory. This is the
- * same as for CERN 3.+ webservers and behaviour is the same as
- * for the directive:
- *
- * MetaDir .web
- *
- * MetaSuffix <meta file suffix>
- *
- * specifies the file name suffix for the file containing the
- * meta information. eg:
- *
- * # our meta files are suffixed with '.cern_meta'
- * MetaSuffix .cern_meta
- *
- * the default is to look for files with the suffix '.meta'. This
- * behaviour is the same as for the directive:
- *
- * MetaSuffix .meta
- *
- * When accessing the file
- *
- * DOCUMENT_ROOT/somedir/index.html
- *
- * this module will look for the file
- *
- * DOCUMENT_ROOT/somedir/.web/index.html.meta
- *
- * and will use its contents to generate additional MIME header
- * information.
- *
- * For more information on the CERN Meta file semantics see:
- *
- * http://www.w3.org/hypertext/WWW/Daemon/User/Config/General.html#MetaDir
- *
- * Change-log:
- * 29.Jan.96 pfopen/pfclose instead of fopen/fclose
- * DECLINE when real file not found, we may be checking each
- * of the index.html/index.shtml/index.htm variants and don't
- * need to report missing ones as spurious errors.
- * 31.Jan.96 log_error reports about a malformed .meta file, rather
- * than a script error.
- * 20.Jun.96 MetaFiles <on|off> default off, added, so that module
- * can be configured per-directory. Prior to this the module
- * was running for each request anywhere on the server, naughty..
- * 29.Jun.96 All directives made per-directory.
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "util_script.h"
-#include "http_log.h"
-#include "http_request.h"
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#define DIR_CMD_PERMS OR_INDEXES
-
-#define DEFAULT_METADIR ".web"
-#define DEFAULT_METASUFFIX ".meta"
-#define DEFAULT_METAFILES 0
-
-module MODULE_VAR_EXPORT cern_meta_module;
-
-typedef struct {
- char *metadir;
- char *metasuffix;
- char *metafiles;
-} cern_meta_dir_config;
-
-static void *create_cern_meta_dir_config(ap_context_t *p, char *dummy)
-{
- cern_meta_dir_config *new =
- (cern_meta_dir_config *) ap_palloc(p, sizeof(cern_meta_dir_config));
-
- new->metadir = NULL;
- new->metasuffix = NULL;
- new->metafiles = DEFAULT_METAFILES;
-
- return new;
-}
-
-static void *merge_cern_meta_dir_configs(ap_context_t *p, void *basev, void *addv)
-{
- cern_meta_dir_config *base = (cern_meta_dir_config *) basev;
- cern_meta_dir_config *add = (cern_meta_dir_config *) addv;
- cern_meta_dir_config *new =
- (cern_meta_dir_config *) ap_palloc(p, sizeof(cern_meta_dir_config));
-
- new->metadir = add->metadir ? add->metadir : base->metadir;
- new->metasuffix = add->metasuffix ? add->metasuffix : base->metasuffix;
- new->metafiles = add->metafiles;
-
- return new;
-}
-
-static const char *set_metadir(cmd_parms *parms, cern_meta_dir_config * dconf, char *arg)
-{
- dconf->metadir = arg;
- return NULL;
-}
-
-static const char *set_metasuffix(cmd_parms *parms, cern_meta_dir_config * dconf, char *arg)
-{
- dconf->metasuffix = arg;
- return NULL;
-}
-
-static const char *set_metafiles(cmd_parms *parms, cern_meta_dir_config * dconf, char *arg)
-{
- dconf->metafiles = arg;
- return NULL;
-}
-
-
-static const command_rec cern_meta_cmds[] =
-{
- {"MetaFiles", set_metafiles, NULL, DIR_CMD_PERMS, FLAG,
- "Limited to 'on' or 'off'"},
- {"MetaDir", set_metadir, NULL, DIR_CMD_PERMS, TAKE1,
- "the name of the directory containing meta files"},
- {"MetaSuffix", set_metasuffix, NULL, DIR_CMD_PERMS, TAKE1,
- "the filename suffix for meta files"},
- {NULL}
-};
-
-/* XXX: this is very similar to ap_scan_script_header_err_core...
- * are the differences deliberate, or just a result of bit rot?
- */
-static int scan_meta_file(request_rec *r, ap_file_t *f)
-{
- char w[MAX_STRING_LEN];
- char *l;
- int p;
- ap_table_t *tmp_headers;
-
- tmp_headers = ap_make_table(r->pool, 5);
- while (ap_fgets(w, MAX_STRING_LEN - 1, f) != APR_SUCCESS) {
-
- /* Delete terminal (CR?)LF */
-
- p = strlen(w);
- if (p > 0 && w[p - 1] == '\n') {
- if (p > 1 && w[p - 2] == '\015')
- w[p - 2] = '\0';
- else
- w[p - 1] = '\0';
- }
-
- if (w[0] == '\0') {
- return OK;
- }
-
- /* if we see a bogus header don't ignore it. Shout and scream */
-
- if (!(l = strchr(w, ':'))) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "malformed header in meta file: %s", r->filename);
- return SERVER_ERROR;
- }
-
- *l++ = '\0';
- while (*l && ap_isspace(*l))
- ++l;
-
- if (!strcasecmp(w, "Content-type")) {
- char *tmp;
- /* Nuke trailing whitespace */
-
- char *endp = l + strlen(l) - 1;
- while (endp > l && ap_isspace(*endp))
- *endp-- = '\0';
-
- tmp = ap_pstrdup(r->pool, l);
- ap_content_type_tolower(tmp);
- r->content_type = tmp;
- }
- else if (!strcasecmp(w, "Status")) {
- sscanf(l, "%d", &r->status);
- r->status_line = ap_pstrdup(r->pool, l);
- }
- else {
- ap_table_set(tmp_headers, w, l);
- }
- }
- ap_overlap_tables(r->headers_out, tmp_headers, AP_OVERLAP_TABLES_SET);
- return OK;
-}
-
-static int add_cern_meta_data(request_rec *r)
-{
- char *metafilename;
- char *last_slash;
- char *real_file;
- char *scrap_book;
- ap_file_t *f = NULL;
- ap_status_t retcode;
- cern_meta_dir_config *dconf;
- int rv;
- request_rec *rr;
-
- dconf = ap_get_module_config(r->per_dir_config, &cern_meta_module);
-
- if (!dconf->metafiles) {
- return DECLINED;
- };
-
- /* if ./.web/$1.meta exists then output 'asis' */
-
- if (r->finfo.protection == 0) {
- return DECLINED;
- };
-
- /* is this a directory? */
- if (r->finfo.filetype == APR_DIR || r->uri[strlen(r->uri) - 1] == '/') {
- return DECLINED;
- };
-
- /* what directory is this file in? */
- scrap_book = ap_pstrdup(r->pool, r->filename);
- /* skip leading slash, recovered in later processing */
- scrap_book++;
- last_slash = strrchr(scrap_book, '/');
- if (last_slash != NULL) {
- /* skip over last slash */
- real_file = last_slash;
- real_file++;
- *last_slash = '\0';
- }
- else {
- /* no last slash, buh?! */
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "internal error in mod_cern_meta: %s", r->filename);
- /* should really barf, but hey, let's be friends... */
- return DECLINED;
- };
-
- metafilename = ap_pstrcat(r->pool, "/", scrap_book, "/",
- dconf->metadir ? dconf->metadir : DEFAULT_METADIR,
- "/", real_file,
- dconf->metasuffix ? dconf->metasuffix : DEFAULT_METASUFFIX,
- NULL);
-
- /* XXX: it sucks to require this subrequest to complete, because this
- * means people must leave their meta files accessible to the world.
- * A better solution might be a "safe open" feature of pfopen to avoid
- * pipes, symlinks, and crap like that.
- */
- rr = ap_sub_req_lookup_file(metafilename, r);
- if (rr->status != HTTP_OK) {
- ap_destroy_sub_req(rr);
- return DECLINED;
- }
- ap_destroy_sub_req(rr);
-
- retcode = ap_open(&f, metafilename, APR_READ | APR_CREATE, APR_OS_DEFAULT, r->pool);
- if (retcode != APR_SUCCESS) {
- if (errno == ENOENT) {
- return DECLINED;
- }
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- "meta file permissions deny server access: %s", metafilename);
- return FORBIDDEN;
- };
-
- /* read the headers in */
- rv = scan_meta_file(r, f);
- ap_close(f);
-
- return rv;
-}
-static void register_hooks(void)
-{
- ap_hook_fixups(add_cern_meta_data,NULL,NULL,HOOK_MIDDLE);
-}
-module MODULE_VAR_EXPORT cern_meta_module =
-{
- STANDARD20_MODULE_STUFF,
- create_cern_meta_dir_config,/* dir config creater */
- merge_cern_meta_dir_configs,/* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server configs */
- cern_meta_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/metadata/mod_cern_meta.dsp b/modules/metadata/mod_cern_meta.dsp
deleted file mode 100644
index 8dd632e72f..0000000000
--- a/modules/metadata/mod_cern_meta.dsp
+++ /dev/null
@@ -1,113 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheModuleCERNMeta" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheModuleCERNMeta - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleCERNMeta.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleCERNMeta.mak"\
- CFG="ApacheModuleCERNMeta - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheModuleCERNMeta - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheModuleCERNMeta - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheModuleCERNMeta - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\Release"
-# PROP BASE Intermediate_Dir ".\Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\ApacheModuleCERNMetaR"
-# PROP Intermediate_Dir ".\ApacheModuleCERNMetaR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ..\..\CoreR\ApacheCore.lib ..\..\lib\apr\Release\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheModuleCERNMeta - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\Debug"
-# PROP BASE Intermediate_Dir ".\Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\ApacheModuleCERNMetaD"
-# PROP Intermediate_Dir ".\ApacheModuleCERNMetaD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ..\..\CoreD\ApacheCore.lib ..\..\lib\apr\Debug\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheModuleCERNMeta - Win32 Release"
-# Name "ApacheModuleCERNMeta - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=..\..\modules\standard\mod_cern_meta.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\readdir.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/modules/metadata/mod_cern_meta.exp b/modules/metadata/mod_cern_meta.exp
deleted file mode 100644
index d36e2be6a8..0000000000
--- a/modules/metadata/mod_cern_meta.exp
+++ /dev/null
@@ -1 +0,0 @@
-cern_meta_module
diff --git a/modules/metadata/mod_env.c b/modules/metadata/mod_env.c
deleted file mode 100644
index 1645807d11..0000000000
--- a/modules/metadata/mod_env.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * IT'S 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_env.c
- * version 0.0.5
- * status beta
- * Pass environment variables to CGI/SSI scripts.
- *
- * Andrew Wilson <Andrew.Wilson@cm.cf.ac.uk> 06.Dec.95
- *
- * Change log:
- * 08.Dec.95 Now allows PassEnv directive to appear more than once in
- * conf files.
- * 10.Dec.95 optimisation. getenv() only called at startup and used
- * to build a fast-to-access table. ap_table_t used to build
- * per-server environment for each request.
- * robustness. better able to handle errors in configuration
- * files:
- * 1) PassEnv directive present, but no environment variable listed
- * 2) PassEnv FOO present, but $FOO not present in environment
- * 3) no PassEnv directive present
- * 23.Dec.95 Now allows SetEnv directive with same semantics as 'sh' setenv:
- * SetEnv Var sets Var to the empty string
- * SetEnv Var Val sets Var to the value Val
- * Values containing whitespace should be quoted, eg:
- * SetEnv Var "this is some text"
- * Environment variables take their value from the last instance
- * of PassEnv / SetEnv to be reached in the configuration file.
- * For example, the sequence:
- * PassEnv FOO
- * SetEnv FOO override
- * Causes FOO to take the value 'override'.
- * 23.Feb.96 Added UnsetEnv directive to allow environment variables
- * to be removed.
- * Virtual hosts now 'inherit' parent server environment which
- * they're able to overwrite with their own directives or
- * selectively ignore with UnsetEnv.
- * *** IMPORTANT - the way that virtual hosts inherit their ***
- * *** environment variables from the default server's ***
- * *** configuration has changed. You should test your ***
- * *** configuration carefully before accepting this ***
- * *** version of the module in a live webserver which used ***
- * *** older versions of the module. ***
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-typedef struct {
- ap_table_t *vars;
- char *unsetenv;
- int vars_present;
-} env_dir_config_rec;
-
-module MODULE_VAR_EXPORT env_module;
-
-static void *create_env_dir_config(ap_context_t *p, char *dummy)
-{
- env_dir_config_rec *new =
- (env_dir_config_rec *) ap_palloc(p, sizeof(env_dir_config_rec));
- new->vars = ap_make_table(p, 50);
- new->unsetenv = "";
- new->vars_present = 0;
- return (void *) new;
-}
-
-static void *merge_env_dir_configs(ap_context_t *p, void *basev, void *addv)
-{
- env_dir_config_rec *base = (env_dir_config_rec *) basev;
- env_dir_config_rec *add = (env_dir_config_rec *) addv;
- env_dir_config_rec *new =
- (env_dir_config_rec *) ap_palloc(p, sizeof(env_dir_config_rec));
-
- ap_table_t *new_table;
- ap_table_entry_t *elts;
- ap_array_header_t *arr;
-
- int i;
- const char *uenv, *unset;
-
- /*
- * new_table = copy_table( p, base->vars );
- * foreach $element ( @add->vars ) {
- * table_set( new_table, $element.key, $element.val );
- * };
- * foreach $unsetenv ( @UNSETENV ) {
- * table_unset( new_table, $unsetenv );
- * }
- */
-
- new_table = ap_copy_table(p, base->vars);
-
- arr = ap_table_elts(add->vars);
- elts = (ap_table_entry_t *)arr->elts;
-
- for (i = 0; i < arr->nelts; ++i) {
- ap_table_setn(new_table, elts[i].key, elts[i].val);
- }
-
- unset = add->unsetenv;
- uenv = ap_getword_conf(p, &unset);
- while (uenv[0] != '\0') {
- ap_table_unset(new_table, uenv);
- uenv = ap_getword_conf(p, &unset);
- }
-
- new->vars = new_table;
-
- new->vars_present = base->vars_present || add->vars_present;
-
- return new;
-}
-
-static const char *add_env_module_vars_passed(cmd_parms *cmd,
- env_dir_config_rec *sconf,
- const char *arg)
-{
- ap_table_t *vars = sconf->vars;
- char *env_var;
- char *name_ptr;
-
- while (*arg) {
- name_ptr = ap_getword_conf(cmd->pool, &arg);
- env_var = getenv(name_ptr);
- if (env_var != NULL) {
- sconf->vars_present = 1;
- ap_table_setn(vars, name_ptr, ap_pstrdup(cmd->pool, env_var));
- }
- }
- return NULL;
-}
-
-static const char *add_env_module_vars_set(cmd_parms *cmd,
- env_dir_config_rec *sconf,
- const char *arg)
-{
- ap_table_t *vars = sconf->vars;
- char *name, *value;
-
- name = ap_getword_conf(cmd->pool, &arg);
- value = ap_getword_conf(cmd->pool, &arg);
-
- /* name is mandatory, value is optional. no value means
- * set the variable to an empty string
- */
-
-
- if ((*name == '\0') || (*arg != '\0')) {
- return "SetEnv takes one or two arguments. An environment variable name and an optional value to pass to CGI.";
- }
-
- sconf->vars_present = 1;
- ap_table_setn(vars, name, value);
-
- return NULL;
-}
-
-static const char *add_env_module_vars_unset(cmd_parms *cmd,
- env_dir_config_rec *sconf,
- char *arg)
-{
- sconf->unsetenv = sconf->unsetenv ?
- ap_pstrcat(cmd->pool, sconf->unsetenv, " ", arg, NULL) :
- arg;
- return NULL;
-}
-
-static const command_rec env_module_cmds[] =
-{
- {"PassEnv", add_env_module_vars_passed, NULL,
- OR_FILEINFO, RAW_ARGS, "a list of environment variables to pass to CGI."},
- {"SetEnv", add_env_module_vars_set, NULL,
- OR_FILEINFO, RAW_ARGS, "an environment variable name and a value to pass to CGI."},
- {"UnsetEnv", add_env_module_vars_unset, NULL,
- OR_FILEINFO, RAW_ARGS, "a list of variables to remove from the CGI environment."},
- {NULL},
-};
-
-static int fixup_env_module(request_rec *r)
-{
- ap_table_t *e = r->subprocess_env;
- env_dir_config_rec *sconf = ap_get_module_config(r->per_dir_config,
- &env_module);
- ap_table_t *vars = sconf->vars;
-
- if (!sconf->vars_present)
- return DECLINED;
-
- r->subprocess_env = ap_overlay_tables(r->pool, e, vars);
-
- return OK;
-}
-
-static void register_hooks(void)
-{
- ap_hook_fixups(fixup_env_module,NULL,NULL,HOOK_MIDDLE);
-}
-
-
-module MODULE_VAR_EXPORT env_module =
-{
- STANDARD20_MODULE_STUFF,
- create_env_dir_config, /* dir config creater */
- merge_env_dir_configs, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server configs */
- env_module_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/metadata/mod_env.exp b/modules/metadata/mod_env.exp
deleted file mode 100644
index b487bf09c8..0000000000
--- a/modules/metadata/mod_env.exp
+++ /dev/null
@@ -1 +0,0 @@
-env_module
diff --git a/modules/metadata/mod_expires.c b/modules/metadata/mod_expires.c
deleted file mode 100644
index b94ec6a261..0000000000
--- a/modules/metadata/mod_expires.c
+++ /dev/null
@@ -1,508 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * IT'S 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_expires.c
- * version 0.0.11
- * status beta
- *
- * Andrew Wilson <Andrew.Wilson@cm.cf.ac.uk> 26.Jan.96
- *
- * This module allows you to control the form of the Expires: header
- * that Apache issues for each access. Directives can appear in
- * configuration files or in .htaccess files so expiry semantics can
- * be defined on a per-directory basis.
- *
- * DIRECTIVE SYNTAX
- *
- * Valid directives are:
- *
- * ExpiresActive on | off
- * ExpiresDefault <code><seconds>
- * ExpiresByType type/encoding <code><seconds>
- *
- * Valid values for <code> are:
- *
- * 'M' expires header shows file modification date + <seconds>
- * 'A' expires header shows access time + <seconds>
- *
- * [I'm not sure which of these is best under different
- * circumstances, I guess it's for other people to explore.
- * The effects may be indistinguishable for a number of cases]
- *
- * <seconds> should be an integer value [acceptable to atoi()]
- *
- * There is NO space between the <code> and <seconds>.
- *
- * For example, a directory which contains information which changes
- * frequently might contain:
- *
- * # reports generated by cron every hour. don't let caches
- * # hold onto stale information
- * ExpiresDefault M3600
- *
- * Another example, our html pages can change all the time, the gifs
- * tend not to change often:
- *
- * # pages are hot (1 week), images are cold (1 month)
- * ExpiresByType text/html A604800
- * ExpiresByType image/gif A2592000
- *
- * Expires can be turned on for all URLs on the server by placing the
- * following directive in a conf file:
- *
- * ExpiresActive on
- *
- * ExpiresActive can also appear in .htaccess files, enabling the
- * behaviour to be turned on or off for each chosen directory.
- *
- * # turn off Expires behaviour in this directory
- * # and subdirectories
- * ExpiresActive off
- *
- * Directives defined for a directory are valid in subdirectories
- * unless explicitly overridden by new directives in the subdirectory
- * .htaccess files.
- *
- * ALTERNATIVE DIRECTIVE SYNTAX
- *
- * Directives can also be defined in a more readable syntax of the form:
- *
- * ExpiresDefault "<base> [plus] {<num> <type>}*"
- * ExpiresByType type/encoding "<base> [plus] {<num> <type>}*"
- *
- * where <base> is one of:
- * access
- * now equivalent to 'access'
- * modification
- *
- * where the 'plus' keyword is optional
- *
- * where <num> should be an integer value [acceptable to atoi()]
- *
- * where <type> is one of:
- * years
- * months
- * weeks
- * days
- * hours
- * minutes
- * seconds
- *
- * For example, any of the following directives can be used to make
- * documents expire 1 month after being accessed, by default:
- *
- * ExpiresDefault "access plus 1 month"
- * ExpiresDefault "access plus 4 weeks"
- * ExpiresDefault "access plus 30 days"
- *
- * The expiry time can be fine-tuned by adding several '<num> <type>'
- * clauses:
- *
- * ExpiresByType text/html "access plus 1 month 15 days 2 hours"
- * ExpiresByType image/gif "modification plus 5 hours 3 minutes"
- *
- * ---
- *
- * Change-log:
- * 29.Jan.96 Hardened the add_* functions. Server will now bail out
- * if bad directives are given in the conf files.
- * 02.Feb.96 Returns DECLINED if not 'ExpiresActive on', giving other
- * expires-aware modules a chance to play with the same
- * directives. [Michael Rutman]
- * 03.Feb.96 Call tzset() before localtime(). Trying to get the module
- * to work properly in non GMT timezones.
- * 12.Feb.96 Modified directive syntax to allow more readable commands:
- * ExpiresDefault "now plus 10 days 20 seconds"
- * ExpiresDefault "access plus 30 days"
- * ExpiresDefault "modification plus 1 year 10 months 30 days"
- * 13.Feb.96 Fix call to table_get() with NULL 2nd parameter [Rob Hartill]
- * 19.Feb.96 Call gm_timestr_822() to get time formatted correctly, can't
- * rely on presence of HTTP_TIME_FORMAT in Apache 1.1+.
- * 21.Feb.96 This version (0.0.9) reverses assumptions made in 0.0.8
- * about star/star handlers. Reverting to 0.0.7 behaviour.
- * 08.Jun.96 allows ExpiresDefault to be used with responses that use
- * the DefaultType by not DECLINING, but instead skipping
- * the table_get check and then looking for an ExpiresDefault.
- * [Rob Hartill]
- * 04.Nov.96 'const' definitions added.
- *
- * TODO
- * add support for Cache-Control: max-age=20 from the HTTP/1.1
- * proposal (in this case, a ttl of 20 seconds) [ask roy]
- * add per-file expiry and explicit expiry times - duplicates some
- * of the mod_cern_meta.c functionality. eg:
- * ExpiresExplicit index.html "modification plus 30 days"
- *
- * BUGS
- * Hi, welcome to the internet.
- */
-
-#include "ap_config.h"
-#ifdef HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-#include "http_request.h"
-
-typedef struct {
- int active;
- char *expiresdefault;
- ap_table_t *expiresbytype;
-} expires_dir_config;
-
-/* from mod_dir, why is this alias used?
- */
-#define DIR_CMD_PERMS OR_INDEXES
-
-#define ACTIVE_ON 1
-#define ACTIVE_OFF 0
-#define ACTIVE_DONTCARE 2
-
-module MODULE_VAR_EXPORT expires_module;
-
-static void *create_dir_expires_config(ap_context_t *p, char *dummy)
-{
- expires_dir_config *new =
- (expires_dir_config *) ap_pcalloc(p, sizeof(expires_dir_config));
- new->active = ACTIVE_DONTCARE;
- new->expiresdefault = "";
- new->expiresbytype = ap_make_table(p, 4);
- return (void *) new;
-}
-
-static const char *set_expiresactive(cmd_parms *cmd, expires_dir_config * dir_config, int arg)
-{
- /* if we're here at all it's because someone explicitly
- * set the active flag
- */
- dir_config->active = ACTIVE_ON;
- if (arg == 0) {
- dir_config->active = ACTIVE_OFF;
- };
- return NULL;
-}
-
-/* check_code() parse 'code' and return NULL or an error response
- * string. If we return NULL then real_code contains code converted
- * to the cnnnn format.
- */
-static char *check_code(ap_context_t *p, const char *code, char **real_code)
-{
- char *word;
- char base = 'X';
- int modifier = 0;
- int num = 0;
- int factor = 0;
-
- /* 0.0.4 compatibility?
- */
- if ((code[0] == 'A') || (code[0] == 'M')) {
- *real_code = (char *)code;
- return NULL;
- };
-
- /* <base> [plus] {<num> <type>}*
- */
-
- /* <base>
- */
- word = ap_getword_conf(p, &code);
- if (!strncasecmp(word, "now", 1) ||
- !strncasecmp(word, "access", 1)) {
- base = 'A';
- }
- else if (!strncasecmp(word, "modification", 1)) {
- base = 'M';
- }
- else {
- return ap_pstrcat(p, "bad expires code, unrecognised <base> '",
- word, "'", NULL);
- };
-
- /* [plus]
- */
- word = ap_getword_conf(p, &code);
- if (!strncasecmp(word, "plus", 1)) {
- word = ap_getword_conf(p, &code);
- };
-
- /* {<num> <type>}*
- */
- while (word[0]) {
- /* <num>
- */
- if (ap_isdigit(word[0])) {
- num = atoi(word);
- }
- else {
- return ap_pstrcat(p, "bad expires code, numeric value expected <num> '",
- word, "'", NULL);
- };
-
- /* <type>
- */
- word = ap_getword_conf(p, &code);
- if (word[0]) {
- /* do nothing */
- }
- else {
- return ap_pstrcat(p, "bad expires code, missing <type>", NULL);
- };
-
- factor = 0;
- if (!strncasecmp(word, "years", 1)) {
- factor = 60 * 60 * 24 * 365;
- }
- else if (!strncasecmp(word, "months", 2)) {
- factor = 60 * 60 * 24 * 30;
- }
- else if (!strncasecmp(word, "weeks", 1)) {
- factor = 60 * 60 * 24 * 7;
- }
- else if (!strncasecmp(word, "days", 1)) {
- factor = 60 * 60 * 24;
- }
- else if (!strncasecmp(word, "hours", 1)) {
- factor = 60 * 60;
- }
- else if (!strncasecmp(word, "minutes", 2)) {
- factor = 60;
- }
- else if (!strncasecmp(word, "seconds", 1)) {
- factor = 1;
- }
- else {
- return ap_pstrcat(p, "bad expires code, unrecognised <type>",
- "'", word, "'", NULL);
- };
-
- modifier = modifier + factor * num;
-
- /* next <num>
- */
- word = ap_getword_conf(p, &code);
- };
-
- *real_code = ap_psprintf(p, "%c%d", base, modifier);
-
- return NULL;
-}
-
-static const char *set_expiresbytype(cmd_parms *cmd, expires_dir_config * dir_config, char *mime, char *code)
-{
- char *response, *real_code;
-
- if ((response = check_code(cmd->pool, code, &real_code)) == NULL) {
- ap_table_setn(dir_config->expiresbytype, mime, real_code);
- return NULL;
- };
- return ap_pstrcat(cmd->pool,
- "'ExpiresByType ", mime, " ", code, "': ", response, NULL);
-}
-
-static const char *set_expiresdefault(cmd_parms *cmd, expires_dir_config * dir_config, char *code)
-{
- char *response, *real_code;
-
- if ((response = check_code(cmd->pool, code, &real_code)) == NULL) {
- dir_config->expiresdefault = real_code;
- return NULL;
- };
- return ap_pstrcat(cmd->pool,
- "'ExpiresDefault ", code, "': ", response, NULL);
-}
-
-static const command_rec expires_cmds[] =
-{
- {"ExpiresActive", set_expiresactive, NULL, DIR_CMD_PERMS, FLAG,
- "Limited to 'on' or 'off'"},
- {"ExpiresBytype", set_expiresbytype, NULL, DIR_CMD_PERMS, TAKE2,
- "a MIME type followed by an expiry date code"},
- {"ExpiresDefault", set_expiresdefault, NULL, DIR_CMD_PERMS, TAKE1,
- "an expiry date code"},
- {NULL}
-};
-
-static void *merge_expires_dir_configs(ap_context_t *p, void *basev, void *addv)
-{
- expires_dir_config *new = (expires_dir_config *) ap_pcalloc(p, sizeof(expires_dir_config));
- expires_dir_config *base = (expires_dir_config *) basev;
- expires_dir_config *add = (expires_dir_config *) addv;
-
- if (add->active == ACTIVE_DONTCARE) {
- new->active = base->active;
- }
- else {
- new->active = add->active;
- };
-
- if (add->expiresdefault != '\0') {
- new->expiresdefault = add->expiresdefault;
- };
-
- new->expiresbytype = ap_overlay_tables(p, add->expiresbytype,
- base->expiresbytype);
- return new;
-}
-
-static int add_expires(request_rec *r)
-{
- expires_dir_config *conf;
- char *code;
- ap_time_t base;
- ap_time_t additional;
- ap_time_t expires;
- char *timestr;
-
- if (ap_is_HTTP_ERROR(r->status)) /* Don't add Expires headers to errors */
- return DECLINED;
-
- if (r->main != NULL) /* Say no to subrequests */
- return DECLINED;
-
- conf = (expires_dir_config *) ap_get_module_config(r->per_dir_config, &expires_module);
- if (conf == NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "internal error: %s", r->filename);
- return SERVER_ERROR;
- };
-
- if (conf->active != ACTIVE_ON)
- return DECLINED;
-
- /* we perhaps could use the default_type(r) in its place but that
- * may be 2nd guesing the desired configuration... calling table_get
- * with a NULL key will SEGV us
- *
- * I still don't know *why* r->content_type would ever be NULL, this
- * is possibly a result of fixups being called in many different
- * places. Fixups is probably the wrong place to be doing all this
- * work... Bah.
- *
- * Changed as of 08.Jun.96 don't DECLINE, look for an ExpiresDefault.
- */
- if (r->content_type == NULL)
- code = NULL;
- else
- code = (char *) ap_table_get(conf->expiresbytype, r->content_type);
-
- if (code == NULL) {
- /* no expires defined for that type, is there a default? */
- code = conf->expiresdefault;
-
- if (code[0] == '\0')
- return OK;
- };
-
- /* we have our code */
-
- switch (code[0]) {
- case 'M':
- if (r->finfo.protection == 0) {
- /* file doesn't exist on disk, so we can't do anything based on
- * modification time. Note that this does _not_ log an error.
- */
- return DECLINED;
- }
- base = r->finfo.mtime;
- additional = atoi(&code[1]);
- break;
- case 'A':
- /* there's been some discussion and it's possible that
- * 'access time' will be stored in request structure
- */
- base = r->request_time;
- additional = atoi(&code[1]);
- break;
- default:
- /* expecting the add_* routines to be case-hardened this
- * is just a reminder that module is beta
- */
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "internal error: bad expires code: %s", r->filename);
- return SERVER_ERROR;
- };
-
- expires = base + additional;
- ap_table_setn(r->headers_out, "Cache-Control",
- ap_psprintf(r->pool, "max-age=%qd",
- (expires - r->request_time) / AP_USEC_PER_SEC));
- timestr = ap_palloc(r->pool, AP_RFC822_DATE_LEN);
- ap_rfc822_date(timestr, expires);
- ap_table_setn(r->headers_out, "Expires", timestr);
- return OK;
-}
-
-static void register_hooks(void)
-{
- ap_hook_fixups(add_expires,NULL,NULL,HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT expires_module =
-{
- STANDARD20_MODULE_STUFF,
- create_dir_expires_config, /* dir config creater */
- merge_expires_dir_configs, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server configs */
- expires_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/metadata/mod_expires.dsp b/modules/metadata/mod_expires.dsp
deleted file mode 100644
index 4dd2fb3873..0000000000
--- a/modules/metadata/mod_expires.dsp
+++ /dev/null
@@ -1,113 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheModuleExpires" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheModuleExpires - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleExpires.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleExpires.mak"\
- CFG="ApacheModuleExpires - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheModuleExpires - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheModuleExpires - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheModuleExpires - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\Release"
-# PROP BASE Intermediate_Dir ".\Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\ApacheModuleExpiresR"
-# PROP Intermediate_Dir ".\ApacheModuleExpiresR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ..\..\CoreR\ApacheCore.lib ..\..\lib\apr\Release\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheModuleExpires - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\Debug"
-# PROP BASE Intermediate_Dir ".\Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\ApacheModuleExpiresD"
-# PROP Intermediate_Dir ".\ApacheModuleExpiresD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ..\..\CoreD\ApacheCore.lib ..\..\lib\apr\Debug\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheModuleExpires - Win32 Release"
-# Name "ApacheModuleExpires - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=..\..\modules\standard\mod_expires.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\readdir.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/modules/metadata/mod_expires.exp b/modules/metadata/mod_expires.exp
deleted file mode 100644
index 863a96878e..0000000000
--- a/modules/metadata/mod_expires.exp
+++ /dev/null
@@ -1 +0,0 @@
-expires_module
diff --git a/modules/metadata/mod_headers.c b/modules/metadata/mod_headers.c
deleted file mode 100644
index 1865b2cc7c..0000000000
--- a/modules/metadata/mod_headers.c
+++ /dev/null
@@ -1,258 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_headers.c: Add/append/remove HTTP response headers
- * Written by Paul Sutton, paul@ukweb.com, 1 Oct 1996
- *
- * New directive, Header, can be used to add/replace/remove HTTP headers.
- * Valid in both per-server and per-dir configurations.
- *
- * Syntax is:
- *
- * Header action header value
- *
- * Where action is one of:
- * set - set this header, replacing any old value
- * add - add this header, possible resulting in two or more
- * headers with the same name
- * append - append this text onto any existing header of this same
- * unset - remove this header
- *
- * Where action is unset, the third argument (value) should not be given.
- * The header name can include the colon, or not.
- *
- * The Header directive can only be used where allowed by the FileInfo
- * override.
- *
- * When the request is processed, the header directives are processed in
- * this order: firstly, the main server, then the virtual server handling
- * this request (if any), then any <Directory> sections (working downwards
- * from the root dir), then an <Location> sections (working down from
- * shortest URL component), the any <File> sections. This order is
- * important if any 'set' or 'unset' actions are used. For example,
- * the following two directives have different effect if applied in
- * the reverse order:
- *
- * Header append Author "John P. Doe"
- * Header unset Author
- *
- * Examples:
- *
- * To set the "Author" header, use
- * Header add Author "John P. Doe"
- *
- * To remove a header:
- * Header unset Author
- *
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-
-typedef enum {
- hdr_add = 'a', /* add header (could mean multiple hdrs) */
- hdr_set = 's', /* set (replace old value) */
- hdr_append = 'm', /* append (merge into any old value) */
- hdr_unset = 'u' /* unset header */
-} hdr_actions;
-
-typedef struct {
- hdr_actions action;
- char *header;
- char *value;
-} header_entry;
-
-/*
- * headers_conf is our per-module configuration. This is used as both
- * a per-dir and per-server config
- */
-typedef struct {
- ap_array_header_t *headers;
-} headers_conf;
-
-module MODULE_VAR_EXPORT headers_module;
-
-static void *create_headers_config(ap_context_t *p, server_rec *s)
-{
- headers_conf *a =
- (headers_conf *) ap_pcalloc(p, sizeof(headers_conf));
-
- a->headers = ap_make_array(p, 2, sizeof(header_entry));
- return a;
-}
-
-static void *create_headers_dir_config(ap_context_t *p, char *d)
-{
- return (headers_conf *) create_headers_config(p, NULL);
-}
-
-static void *merge_headers_config(ap_context_t *p, void *basev, void *overridesv)
-{
- headers_conf *a =
- (headers_conf *) ap_pcalloc(p, sizeof(headers_conf));
- headers_conf *base = (headers_conf *) basev, *overrides = (headers_conf *) overridesv;
-
- a->headers = ap_append_arrays(p, base->headers, overrides->headers);
-
- return a;
-}
-
-
-static const char *header_cmd(cmd_parms *cmd, headers_conf * dirconf, char *action, char *hdr, char *value)
-{
- header_entry *new;
- server_rec *s = cmd->server;
- headers_conf *serverconf =
- (headers_conf *) ap_get_module_config(s->module_config, &headers_module);
- char *colon;
-
- if (cmd->path) {
- new = (header_entry *) ap_push_array(dirconf->headers);
- }
- else {
- new = (header_entry *) ap_push_array(serverconf->headers);
- }
-
- if (!strcasecmp(action, "set"))
- new->action = hdr_set;
- else if (!strcasecmp(action, "add"))
- new->action = hdr_add;
- else if (!strcasecmp(action, "append"))
- new->action = hdr_append;
- else if (!strcasecmp(action, "unset"))
- new->action = hdr_unset;
- else
- return "first argument must be add, set, append or unset.";
-
- if (new->action == hdr_unset) {
- if (value)
- return "Header unset takes two arguments";
- }
- else if (!value)
- return "Header requires three arguments";
-
- if ((colon = strchr(hdr, ':')))
- *colon = '\0';
-
- new->header = hdr;
- new->value = value;
-
- return NULL;
-}
-
-static const command_rec headers_cmds[] =
-{
- {"Header", header_cmd, NULL, OR_FILEINFO, TAKE23,
- "an action, header and value"},
- {NULL}
-};
-
-static void do_headers_fixup(request_rec *r, ap_array_header_t *headers)
-{
- int i;
-
- for (i = 0; i < headers->nelts; ++i) {
- header_entry *hdr = &((header_entry *) (headers->elts))[i];
- switch (hdr->action) {
- case hdr_add:
- ap_table_addn(r->headers_out, hdr->header, hdr->value);
- break;
- case hdr_append:
- ap_table_mergen(r->headers_out, hdr->header, hdr->value);
- break;
- case hdr_set:
- ap_table_setn(r->headers_out, hdr->header, hdr->value);
- break;
- case hdr_unset:
- ap_table_unset(r->headers_out, hdr->header);
- break;
- }
- }
-
-}
-
-static int fixup_headers(request_rec *r)
-{
- void *sconf = r->server->module_config;
- headers_conf *serverconf =
- (headers_conf *) ap_get_module_config(sconf, &headers_module);
- void *dconf = r->per_dir_config;
- headers_conf *dirconf =
- (headers_conf *) ap_get_module_config(dconf, &headers_module);
-
- do_headers_fixup(r, serverconf->headers);
- do_headers_fixup(r, dirconf->headers);
-
- return DECLINED;
-}
-static void register_hooks(void)
-{
- ap_hook_fixups(fixup_headers,NULL,NULL,HOOK_MIDDLE);
-}
-module MODULE_VAR_EXPORT headers_module =
-{
- STANDARD20_MODULE_STUFF,
- create_headers_dir_config, /* dir config creater */
- merge_headers_config, /* dir merger --- default is to override */
- create_headers_config, /* server config */
- merge_headers_config, /* merge server configs */
- headers_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/metadata/mod_headers.dsp b/modules/metadata/mod_headers.dsp
deleted file mode 100644
index 42cb96f67f..0000000000
--- a/modules/metadata/mod_headers.dsp
+++ /dev/null
@@ -1,113 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheModuleHeaders" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheModuleHeaders - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleHeaders.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleHeaders.mak"\
- CFG="ApacheModuleHeaders - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheModuleHeaders - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheModuleHeaders - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheModuleHeaders - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\Release"
-# PROP BASE Intermediate_Dir ".\Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\ApacheModuleHeadersR"
-# PROP Intermediate_Dir ".\ApacheModuleHeadersR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ..\..\CoreR\ApacheCore.lib ..\..\lib\apr\Release\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheModuleHeaders - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\Debug"
-# PROP BASE Intermediate_Dir ".\Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\ApacheModuleHeadersD"
-# PROP Intermediate_Dir ".\ApacheModuleHeadersD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ..\..\CoreD\ApacheCore.lib ..\..\lib\apr\Debug\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheModuleHeaders - Win32 Release"
-# Name "ApacheModuleHeaders - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=..\..\modules\standard\mod_headers.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\readdir.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/modules/metadata/mod_headers.exp b/modules/metadata/mod_headers.exp
deleted file mode 100644
index 3f3063808a..0000000000
--- a/modules/metadata/mod_headers.exp
+++ /dev/null
@@ -1 +0,0 @@
-headers_module
diff --git a/modules/metadata/mod_mime_magic.c b/modules/metadata/mod_mime_magic.c
deleted file mode 100644
index a285413a2d..0000000000
--- a/modules/metadata/mod_mime_magic.c
+++ /dev/null
@@ -1,2509 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_mime_magic: MIME type lookup via file magic numbers
- * Copyright (c) 1996-1997 Cisco Systems, Inc.
- *
- * This software was submitted by Cisco Systems to the Apache Group in July
- * 1997. Future revisions and derivatives of this source code must
- * acknowledge Cisco Systems as the original contributor of this module.
- * All other licensing and usage conditions are those of the Apache Group.
- *
- * Some of this code is derived from the free version of the file command
- * originally posted to comp.sources.unix. Copyright info for that program
- * is included below as required.
- * ---------------------------------------------------------------------------
- * - Copyright (c) Ian F. Darwin, 1987. Written by Ian F. Darwin.
- *
- * This software is not subject to any license of the American Telephone and
- * Telegraph Company or of the Regents of the University of California.
- *
- * Permission is granted to anyone to use this software for any purpose on any
- * computer system, and to alter it and redistribute it freely, subject to
- * the following restrictions:
- *
- * 1. The author is not responsible for the consequences of use of this
- * software, no matter how awful, even if they arise from flaws in it.
- *
- * 2. The origin of this software must not be misrepresented, either by
- * explicit claim or by omission. Since few users ever read sources, credits
- * must appear in the documentation.
- *
- * 3. Altered versions must be plainly marked as such, and must not be
- * misrepresented as being the original software. Since few users ever read
- * sources, credits must appear in the documentation.
- *
- * 4. This notice may not be removed or altered.
- * -------------------------------------------------------------------------
- *
- * For compliance with Mr Darwin's terms: this has been very significantly
- * modified from the free "file" command.
- * - all-in-one file for compilation convenience when moving from one
- * version of Apache to the next.
- * - Memory allocation is done through the Apache API's ap_context_t structure.
- * - All functions have had necessary Apache API request or server
- * structures passed to them where necessary to call other Apache API
- * routines. (i.e. usually for logging, files, or memory allocation in
- * itself or a called function.)
- * - struct magic has been converted from an array to a single-ended linked
- * list because it only grows one record at a time, it's only accessed
- * sequentially, and the Apache API has no equivalent of realloc().
- * - Functions have been changed to get their parameters from the server
- * configuration instead of globals. (It should be reentrant now but has
- * not been tested in a threaded environment.)
- * - Places where it used to print results to stdout now saves them in a
- * list where they're used to set the MIME type in the Apache request
- * record.
- * - Command-line flags have been removed since they will never be used here.
- *
- * Ian Kluft <ikluft@cisco.com>
- * Engineering Information Framework
- * Central Engineering
- * Cisco Systems, Inc.
- * San Jose, CA, USA
- *
- * Initial installation July/August 1996
- * Misc bug fixes May 1997
- * Submission to Apache Group July 1997
- *
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_request.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_protocol.h"
-#include "util_script.h"
-#ifdef HAVE_UTIME_H
-#include <utime.h>
-#endif
-
-/*
- * data structures and related constants
- */
-
-#define MODNAME "mod_mime_magic"
-#define MIME_MAGIC_DEBUG 0
-
-#define MIME_BINARY_UNKNOWN "application/octet-stream"
-#define MIME_TEXT_UNKNOWN "text/plain"
-
-#define MAXMIMESTRING 256
-
-/* HOWMANY must be at least 4096 to make gzip -dcq work */
-#define HOWMANY 4096
-/* SMALL_HOWMANY limits how much work we do to figure out text files */
-#define SMALL_HOWMANY 1024
-#define MAXDESC 50 /* max leng of text description */
-#define MAXstring 64 /* max leng of "string" types */
-
-struct magic {
- struct magic *next; /* link to next entry */
- int lineno; /* line number from magic file */
-
- short flag;
-#define INDIR 1 /* if '>(...)' appears, */
-#define UNSIGNED 2 /* comparison is unsigned */
- short cont_level; /* level of ">" */
- struct {
- char type; /* byte short long */
- long offset; /* offset from indirection */
- } in;
- long offset; /* offset to magic number */
- unsigned char reln; /* relation (0=eq, '>'=gt, etc) */
- char type; /* int, short, long or string. */
- char vallen; /* length of string value, if any */
-#define BYTE 1
-#define SHORT 2
-#define LONG 4
-#define STRING 5
-#define DATE 6
-#define BESHORT 7
-#define BELONG 8
-#define BEDATE 9
-#define LESHORT 10
-#define LELONG 11
-#define LEDATE 12
- union VALUETYPE {
- unsigned char b;
- unsigned short h;
- unsigned long l;
- char s[MAXstring];
- unsigned char hs[2]; /* 2 bytes of a fixed-endian "short" */
- unsigned char hl[4]; /* 2 bytes of a fixed-endian "long" */
- } value; /* either number or string */
- unsigned long mask; /* mask before comparison with value */
- char nospflag; /* supress space character */
-
- /* NOTE: this string is suspected of overrunning - find it! */
- char desc[MAXDESC]; /* description */
-};
-
-/*
- * data structures for tar file recognition
- * --------------------------------------------------------------------------
- * Header file for public domain tar (tape archive) program.
- *
- * @(#)tar.h 1.20 86/10/29 Public Domain. Created 25 August 1985 by John
- * Gilmore, ihnp4!hoptoad!gnu.
- *
- * Header block on tape.
- *
- * I'm going to use traditional DP naming conventions here. A "block" is a big
- * chunk of stuff that we do I/O on. A "record" is a piece of info that we
- * care about. Typically many "record"s fit into a "block".
- */
-#define RECORDSIZE 512
-#define NAMSIZ 100
-#define TUNMLEN 32
-#define TGNMLEN 32
-
-union record {
- char charptr[RECORDSIZE];
- struct header {
- char name[NAMSIZ];
- char mode[8];
- char uid[8];
- char gid[8];
- char size[12];
- char mtime[12];
- char chksum[8];
- char linkflag;
- char linkname[NAMSIZ];
- char magic[8];
- char uname[TUNMLEN];
- char gname[TGNMLEN];
- char devmajor[8];
- char devminor[8];
- } header;
-};
-
-/* The magic field is filled with this if uname and gname are valid. */
-#define TMAGIC "ustar " /* 7 chars and a null */
-
-/*
- * file-function prototypes
- */
-static int ascmagic(request_rec *, unsigned char *, int);
-static int is_tar(unsigned char *, int);
-static int softmagic(request_rec *, unsigned char *, int);
-static void tryit(request_rec *, unsigned char *, int, int);
-static int zmagic(request_rec *, unsigned char *, int);
-
-static int getvalue(server_rec *, struct magic *, char **);
-static int hextoint(int);
-static char *getstr(server_rec *, char *, char *, int, int *);
-static int parse(server_rec *, ap_context_t *p, char *, int);
-
-static int match(request_rec *, unsigned char *, int);
-static int mget(request_rec *, union VALUETYPE *, unsigned char *,
- struct magic *, int);
-static int mcheck(request_rec *, union VALUETYPE *, struct magic *);
-static void mprint(request_rec *, union VALUETYPE *, struct magic *);
-
-static int uncompress(request_rec *, int,
- unsigned char **, int);
-static long from_oct(int, char *);
-static int fsmagic(request_rec *r, const char *fn);
-
-/*
- * includes for ASCII substring recognition formerly "names.h" in file
- * command
- *
- * Original notes: names and types used by ascmagic in file(1). These tokens are
- * here because they can appear anywhere in the first HOWMANY bytes, while
- * tokens in /etc/magic must appear at fixed offsets into the file. Don't
- * make HOWMANY too high unless you have a very fast CPU.
- */
-
-/* these types are used to index the ap_table_t 'types': keep em in sync! */
-/* HTML inserted in first because this is a web server module now */
-#define L_HTML 0 /* HTML */
-#define L_C 1 /* first and foremost on UNIX */
-#define L_FORT 2 /* the oldest one */
-#define L_MAKE 3 /* Makefiles */
-#define L_PLI 4 /* PL/1 */
-#define L_MACH 5 /* some kinda assembler */
-#define L_ENG 6 /* English */
-#define L_PAS 7 /* Pascal */
-#define L_MAIL 8 /* Electronic mail */
-#define L_NEWS 9 /* Usenet Netnews */
-
-static char *types[] =
-{
- "text/html", /* HTML */
- "text/plain", /* "c program text", */
- "text/plain", /* "fortran program text", */
- "text/plain", /* "make commands text", */
- "text/plain", /* "pl/1 program text", */
- "text/plain", /* "assembler program text", */
- "text/plain", /* "English text", */
- "text/plain", /* "pascal program text", */
- "message/rfc822", /* "mail text", */
- "message/news", /* "news text", */
- "application/binary", /* "can't happen error on names.h/types", */
- 0
-};
-
-static struct names {
- char *name;
- short type;
-} names[] = {
-
- /* These must be sorted by eye for optimal hit rate */
- /* Add to this list only after substantial meditation */
- {
- "<html>", L_HTML
- },
- {
- "<HTML>", L_HTML
- },
- {
- "<head>", L_HTML
- },
- {
- "<HEAD>", L_HTML
- },
- {
- "<title>", L_HTML
- },
- {
- "<TITLE>", L_HTML
- },
- {
- "<h1>", L_HTML
- },
- {
- "<H1>", L_HTML
- },
- {
- "<!--", L_HTML
- },
- {
- "<!DOCTYPE HTML", L_HTML
- },
- {
- "/*", L_C
- }, /* must precede "The", "the", etc. */
- {
- "#include", L_C
- },
- {
- "char", L_C
- },
- {
- "The", L_ENG
- },
- {
- "the", L_ENG
- },
- {
- "double", L_C
- },
- {
- "extern", L_C
- },
- {
- "float", L_C
- },
- {
- "real", L_C
- },
- {
- "struct", L_C
- },
- {
- "union", L_C
- },
- {
- "CFLAGS", L_MAKE
- },
- {
- "LDFLAGS", L_MAKE
- },
- {
- "all:", L_MAKE
- },
- {
- ".PRECIOUS", L_MAKE
- },
- /*
- * Too many files of text have these words in them. Find another way to
- * recognize Fortrash.
- */
-#ifdef NOTDEF
- {
- "subroutine", L_FORT
- },
- {
- "function", L_FORT
- },
- {
- "block", L_FORT
- },
- {
- "common", L_FORT
- },
- {
- "dimension", L_FORT
- },
- {
- "integer", L_FORT
- },
- {
- "data", L_FORT
- },
-#endif /* NOTDEF */
- {
- ".ascii", L_MACH
- },
- {
- ".asciiz", L_MACH
- },
- {
- ".byte", L_MACH
- },
- {
- ".even", L_MACH
- },
- {
- ".globl", L_MACH
- },
- {
- "clr", L_MACH
- },
- {
- "(input,", L_PAS
- },
- {
- "dcl", L_PLI
- },
- {
- "Received:", L_MAIL
- },
- {
- ">From", L_MAIL
- },
- {
- "Return-Path:", L_MAIL
- },
- {
- "Cc:", L_MAIL
- },
- {
- "Newsgroups:", L_NEWS
- },
- {
- "Path:", L_NEWS
- },
- {
- "Organization:", L_NEWS
- },
- {
- NULL, 0
- }
-};
-
-#define NNAMES ((sizeof(names)/sizeof(struct names)) - 1)
-
-/*
- * Result String List (RSL)
- *
- * The file(1) command prints its output. Instead, we store the various
- * "printed" strings in a list (allocating memory as we go) and concatenate
- * them at the end when we finally know how much space they'll need.
- */
-
-typedef struct magic_rsl_s {
- char *str; /* string, possibly a fragment */
- struct magic_rsl_s *next; /* pointer to next fragment */
-} magic_rsl;
-
-/*
- * Apache module configuration structures
- */
-
-/* per-server info */
-typedef struct {
- char *magicfile; /* where magic be found */
- struct magic *magic; /* head of magic config list */
- struct magic *last;
-} magic_server_config_rec;
-
-/* per-request info */
-typedef struct {
- magic_rsl *head; /* result string list */
- magic_rsl *tail;
- unsigned suf_recursion; /* recursion depth in suffix check */
-} magic_req_rec;
-
-/*
- * configuration functions - called by Apache API routines
- */
-
-module mime_magic_module;
-
-static void *create_magic_server_config(ap_context_t *p, server_rec *d)
-{
- /* allocate the config - use pcalloc because it needs to be zeroed */
- return ap_pcalloc(p, sizeof(magic_server_config_rec));
-}
-
-static void *merge_magic_server_config(ap_context_t *p, void *basev, void *addv)
-{
- magic_server_config_rec *base = (magic_server_config_rec *) basev;
- magic_server_config_rec *add = (magic_server_config_rec *) addv;
- magic_server_config_rec *new = (magic_server_config_rec *)
- ap_palloc(p, sizeof(magic_server_config_rec));
-
- new->magicfile = add->magicfile ? add->magicfile : base->magicfile;
- new->magic = NULL;
- new->last = NULL;
- return new;
-}
-
-static const char *set_magicfile(cmd_parms *cmd, char *d, char *arg)
-{
- magic_server_config_rec *conf = (magic_server_config_rec *)
- ap_get_module_config(cmd->server->module_config,
- &mime_magic_module);
-
- if (!conf) {
- return MODNAME ": server structure not allocated";
- }
- conf->magicfile = arg;
- return NULL;
-}
-
-/*
- * configuration file commands - exported to Apache API
- */
-
-static const command_rec mime_magic_cmds[] =
-{
- {"MimeMagicFile", set_magicfile, NULL, RSRC_CONF, TAKE1,
- "Path to MIME Magic file (in file(1) format)"},
- {NULL}
-};
-
-/*
- * RSL (result string list) processing routines
- *
- * These collect strings that would have been printed in fragments by file(1)
- * into a list of magic_rsl structures with the strings. When complete,
- * they're concatenated together to become the MIME content and encoding
- * types.
- *
- * return value conventions for these functions: functions which return int:
- * failure = -1, other = result functions which return pointers: failure = 0,
- * other = result
- */
-
-/* allocate a per-request structure and put it in the request record */
-static magic_req_rec *magic_set_config(request_rec *r)
-{
- magic_req_rec *req_dat = (magic_req_rec *) ap_palloc(r->pool,
- sizeof(magic_req_rec));
-
- req_dat->head = req_dat->tail = (magic_rsl *) NULL;
- ap_set_module_config(r->request_config, &mime_magic_module, req_dat);
- return req_dat;
-}
-
-/* add a string to the result string list for this request */
-/* it is the responsibility of the caller to allocate "str" */
-static int magic_rsl_add(request_rec *r, char *str)
-{
- magic_req_rec *req_dat = (magic_req_rec *)
- ap_get_module_config(r->request_config, &mime_magic_module);
- magic_rsl *rsl;
-
- /* make sure we have a list to put it in */
- if (!req_dat) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, APR_EINVAL, r,
- MODNAME ": request config should not be NULL");
- if (!(req_dat = magic_set_config(r))) {
- /* failure */
- return -1;
- }
- }
-
- /* allocate the list entry */
- rsl = (magic_rsl *) ap_palloc(r->pool, sizeof(magic_rsl));
-
- /* fill it */
- rsl->str = str;
- rsl->next = (magic_rsl *) NULL;
-
- /* append to the list */
- if (req_dat->head && req_dat->tail) {
- req_dat->tail->next = rsl;
- req_dat->tail = rsl;
- }
- else {
- req_dat->head = req_dat->tail = rsl;
- }
-
- /* success */
- return 0;
-}
-
-/* RSL hook for puts-type functions */
-static int magic_rsl_puts(request_rec *r, char *str)
-{
- return magic_rsl_add(r, str);
-}
-
-/* RSL hook for printf-type functions */
-static int magic_rsl_printf(request_rec *r, char *str,...)
-{
- va_list ap;
-
- char buf[MAXMIMESTRING];
-
- /* assemble the string into the buffer */
- va_start(ap, str);
- ap_vsnprintf(buf, sizeof(buf), str, ap);
- va_end(ap);
-
- /* add the buffer to the list */
- return magic_rsl_add(r, strdup(buf));
-}
-
-/* RSL hook for putchar-type functions */
-static int magic_rsl_putchar(request_rec *r, char c)
-{
- char str[2];
-
- /* high overhead for 1 char - just hope they don't do this much */
- str[0] = c;
- str[1] = '\0';
- return magic_rsl_add(r, str);
-}
-
-/* allocate and copy a contiguous string from a result string list */
-static char *rsl_strdup(request_rec *r, int start_frag, int start_pos, int len)
-{
- char *result; /* return value */
- int cur_frag, /* current fragment number/counter */
- cur_pos, /* current position within fragment */
- res_pos; /* position in result string */
- magic_rsl *frag; /* list-traversal pointer */
- magic_req_rec *req_dat = (magic_req_rec *)
- ap_get_module_config(r->request_config, &mime_magic_module);
-
- /* allocate the result string */
- result = (char *) ap_palloc(r->pool, len + 1);
-
- /* loop through and collect the string */
- res_pos = 0;
- for (frag = req_dat->head, cur_frag = 0;
- frag->next;
- frag = frag->next, cur_frag++) {
- /* loop to the first fragment */
- if (cur_frag < start_frag)
- continue;
-
- /* loop through and collect chars */
- for (cur_pos = (cur_frag == start_frag) ? start_pos : 0;
- frag->str[cur_pos];
- cur_pos++) {
- if (cur_frag >= start_frag
- && cur_pos >= start_pos
- && res_pos <= len) {
- result[res_pos++] = frag->str[cur_pos];
- if (res_pos > len) {
- break;
- }
- }
- }
- }
-
- /* clean up and return */
- result[res_pos] = 0;
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": rsl_strdup() %d chars: %s", res_pos - 1, result);
-#endif
- return result;
-}
-
-/* states for the state-machine algorithm in magic_rsl_to_request() */
-typedef enum {
- rsl_leading_space, rsl_type, rsl_subtype, rsl_separator, rsl_encoding
-} rsl_states;
-
-/* process the RSL and set the MIME info in the request record */
-static int magic_rsl_to_request(request_rec *r)
-{
- int cur_frag, /* current fragment number/counter */
- cur_pos, /* current position within fragment */
- type_frag, /* content type starting point: fragment */
- type_pos, /* content type starting point: position */
- type_len, /* content type length */
- encoding_frag, /* content encoding starting point: fragment */
- encoding_pos, /* content encoding starting point: position */
- encoding_len; /* content encoding length */
-
- magic_rsl *frag; /* list-traversal pointer */
- rsl_states state;
-
- magic_req_rec *req_dat = (magic_req_rec *)
- ap_get_module_config(r->request_config, &mime_magic_module);
-
- /* check if we have a result */
- if (!req_dat || !req_dat->head) {
- /* empty - no match, we defer to other Apache modules */
- return DECLINED;
- }
-
- /* start searching for the type and encoding */
- state = rsl_leading_space;
- type_frag = type_pos = type_len = 0;
- encoding_frag = encoding_pos = encoding_len = 0;
- for (frag = req_dat->head, cur_frag = 0;
- frag && frag->next;
- frag = frag->next, cur_frag++) {
- /* loop through the characters in the fragment */
- for (cur_pos = 0; frag->str[cur_pos]; cur_pos++) {
- if (ap_isspace(frag->str[cur_pos])) {
- /* process whitespace actions for each state */
- if (state == rsl_leading_space) {
- /* eat whitespace in this state */
- continue;
- }
- else if (state == rsl_type) {
- /* whitespace: type has no slash! */
- return DECLINED;
- }
- else if (state == rsl_subtype) {
- /* whitespace: end of MIME type */
- state++;
- continue;
- }
- else if (state == rsl_separator) {
- /* eat whitespace in this state */
- continue;
- }
- else if (state == rsl_encoding) {
- /* whitespace: end of MIME encoding */
- /* we're done */
- frag = req_dat->tail;
- break;
- }
- else {
- /* should not be possible */
- /* abandon malfunctioning module */
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, r,
- MODNAME ": bad state %d (ws)", state);
- return DECLINED;
- }
- /* NOTREACHED */
- }
- else if (state == rsl_type &&
- frag->str[cur_pos] == '/') {
- /* copy the char and go to rsl_subtype state */
- type_len++;
- state++;
- }
- else {
- /* process non-space actions for each state */
- if (state == rsl_leading_space) {
- /* non-space: begin MIME type */
- state++;
- type_frag = cur_frag;
- type_pos = cur_pos;
- type_len = 1;
- continue;
- }
- else if (state == rsl_type ||
- state == rsl_subtype) {
- /* non-space: adds to type */
- type_len++;
- continue;
- }
- else if (state == rsl_separator) {
- /* non-space: begin MIME encoding */
- state++;
- encoding_frag = cur_frag;
- encoding_pos = cur_pos;
- encoding_len = 1;
- continue;
- }
- else if (state == rsl_encoding) {
- /* non-space: adds to encoding */
- encoding_len++;
- continue;
- }
- else {
- /* should not be possible */
- /* abandon malfunctioning module */
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, r,
- MODNAME ": bad state %d (ns)", state);
- return DECLINED;
- }
- /* NOTREACHED */
- }
- /* NOTREACHED */
- }
- }
-
- /* if we ended prior to state rsl_subtype, we had incomplete info */
- if (state != rsl_subtype && state != rsl_separator &&
- state != rsl_encoding) {
- /* defer to other modules */
- return DECLINED;
- }
-
- /* save the info in the request record */
- if (state == rsl_subtype || state == rsl_encoding ||
- state == rsl_encoding) {
- char *tmp;
- tmp = rsl_strdup(r, type_frag, type_pos, type_len);
- /* XXX: this could be done at config time I'm sure... but I'm
- * confused by all this magic_rsl stuff. -djg */
- ap_content_type_tolower(tmp);
- r->content_type = tmp;
- }
- if (state == rsl_encoding) {
- char *tmp;
- tmp = rsl_strdup(r, encoding_frag,
- encoding_pos, encoding_len);
- /* XXX: this could be done at config time I'm sure... but I'm
- * confused by all this magic_rsl stuff. -djg */
- ap_str_tolower(tmp);
- r->content_encoding = tmp;
- }
-
- /* detect memory allocation errors */
- if (!r->content_type ||
- (state == rsl_encoding && !r->content_encoding)) {
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- /* success! */
- return OK;
-}
-
-/*
- * magic_process - process input file r Apache API request record
- * (formerly called "process" in file command, prefix added for clarity) Opens
- * the file and reads a fixed-size buffer to begin processing the contents.
- */
-static int magic_process(request_rec *r)
-{
- ap_file_t *fd = NULL;
- unsigned char buf[HOWMANY + 1]; /* one extra for terminating '\0' */
- int nbytes = 0; /* number of bytes read from a datafile */
- int result;
-
- /*
- * first try judging the file based on its filesystem status
- */
- switch ((result = fsmagic(r, r->filename))) {
- case DONE:
- magic_rsl_putchar(r, '\n');
- return OK;
- case OK:
- break;
- default:
- /* fatal error, bail out */
- return result;
- }
-
- if (ap_open(&fd, r->filename, APR_READ, APR_OS_DEFAULT, r->pool) != APR_SUCCESS) {
- /* We can't open it, but we were able to stat it. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
- MODNAME ": can't read `%s'", r->filename);
- /* let some other handler decide what the problem is */
- return DECLINED;
- }
-
- /*
- * try looking at the first HOWMANY bytes
- */
- nbytes = sizeof(buf) - 1;
- if ((result = ap_read(fd, (char *) buf, &nbytes)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, result, r,
- MODNAME ": read failed: %s", r->filename);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- if (nbytes == 0)
- magic_rsl_puts(r, MIME_TEXT_UNKNOWN);
- else {
- buf[nbytes++] = '\0'; /* null-terminate it */
- tryit(r, buf, nbytes, 1);
- }
-
- (void) ap_close(fd);
- (void) magic_rsl_putchar(r, '\n');
-
- return OK;
-}
-
-
-static void tryit(request_rec *r, unsigned char *buf, int nb, int checkzmagic)
-{
- /*
- * Try compression stuff
- */
- if (checkzmagic == 1) {
- if (zmagic(r, buf, nb) == 1)
- return;
- }
-
- /*
- * try tests in /etc/magic (or surrogate magic file)
- */
- if (softmagic(r, buf, nb) == 1)
- return;
-
- /*
- * try known keywords, check for ascii-ness too.
- */
- if (ascmagic(r, buf, nb) == 1)
- return;
-
- /*
- * abandon hope, all ye who remain here
- */
- magic_rsl_puts(r, MIME_BINARY_UNKNOWN);
-}
-
-#define EATAB {while (ap_isspace((unsigned char) *l)) ++l;}
-
-/*
- * apprentice - load configuration from the magic file r
- * API request record
- */
-static int apprentice(server_rec *s, ap_context_t *p)
-{
- ap_file_t *f = NULL;
- ap_status_t result;
- char line[BUFSIZ + 1];
- int errs = 0;
- int lineno;
-#if MIME_MAGIC_DEBUG
- int rule = 0;
- struct magic *m, *prevm;
-#endif
- magic_server_config_rec *conf = (magic_server_config_rec *)
- ap_get_module_config(s->module_config, &mime_magic_module);
-
- const char *fname = ap_server_root_relative(p, conf->magicfile);
- result = ap_open(&f, fname, APR_READ | APR_BUFFERED, APR_OS_DEFAULT, p);
- if (result != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, result, s,
- MODNAME ": can't read magic file %s", fname);
- return -1;
- }
-
- /* set up the magic list (empty) */
- conf->magic = conf->last = NULL;
-
- /* parse it */
- for (lineno = 1; ap_fgets(line, BUFSIZ, f) == APR_SUCCESS; lineno++) {
- int ws_offset;
-
- /* delete newline */
- if (line[0]) {
- line[strlen(line) - 1] = '\0';
- }
-
- /* skip leading whitespace */
- ws_offset = 0;
- while (line[ws_offset] && ap_isspace(line[ws_offset])) {
- ws_offset++;
- }
-
- /* skip blank lines */
- if (line[ws_offset] == 0) {
- continue;
- }
-
- /* comment, do not parse */
- if (line[ws_offset] == '#')
- continue;
-
-#if MIME_MAGIC_DEBUG
- /* if we get here, we're going to use it so count it */
- rule++;
-#endif
-
- /* parse it */
- if (parse(s, p, line + ws_offset, lineno) != 0)
- ++errs;
- }
-
- (void) ap_close(f);
-
-#if MIME_MAGIC_DEBUG
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, s,
- MODNAME ": apprentice conf=%x file=%s m=%s m->next=%s last=%s",
- conf,
- conf->magicfile ? conf->magicfile : "NULL",
- conf->magic ? "set" : "NULL",
- (conf->magic && conf->magic->next) ? "set" : "NULL",
- conf->last ? "set" : "NULL");
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, s,
- MODNAME ": apprentice read %d lines, %d rules, %d errors",
- lineno, rule, errs);
-#endif
-
-#if MIME_MAGIC_DEBUG
- prevm = 0;
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, s,
- MODNAME ": apprentice test");
- for (m = conf->magic; m; m = m->next) {
- if (ap_isprint((((unsigned long) m) >> 24) & 255) &&
- ap_isprint((((unsigned long) m) >> 16) & 255) &&
- ap_isprint((((unsigned long) m) >> 8) & 255) &&
- ap_isprint(((unsigned long) m) & 255)) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, s,
- MODNAME ": apprentice: POINTER CLOBBERED! "
- "m=\"%c%c%c%c\" line=%d",
- (((unsigned long) m) >> 24) & 255,
- (((unsigned long) m) >> 16) & 255,
- (((unsigned long) m) >> 8) & 255,
- ((unsigned long) m) & 255,
- prevm ? prevm->lineno : -1);
- break;
- }
- prevm = m;
- }
-#endif
-
- return (errs ? -1 : 0);
-}
-
-/*
- * extend the sign bit if the comparison is to be signed
- */
-static unsigned long signextend(server_rec *s, struct magic *m, unsigned long v)
-{
- if (!(m->flag & UNSIGNED))
- switch (m->type) {
- /*
- * Do not remove the casts below. They are vital. When later
- * compared with the data, the sign extension must have happened.
- */
- case BYTE:
- v = (char) v;
- break;
- case SHORT:
- case BESHORT:
- case LESHORT:
- v = (short) v;
- break;
- case DATE:
- case BEDATE:
- case LEDATE:
- case LONG:
- case BELONG:
- case LELONG:
- v = (long) v;
- break;
- case STRING:
- break;
- default:
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, s,
- MODNAME ": can't happen: m->type=%d", m->type);
- return -1;
- }
- return v;
-}
-
-/*
- * parse one line from magic file, put into magic[index++] if valid
- */
-static int parse(server_rec *serv, ap_context_t *p, char *l, int lineno)
-{
- struct magic *m;
- char *t, *s;
- magic_server_config_rec *conf = (magic_server_config_rec *)
- ap_get_module_config(serv->module_config, &mime_magic_module);
-
- /* allocate magic structure entry */
- m = (struct magic *) ap_pcalloc(p, sizeof(struct magic));
-
- /* append to linked list */
- m->next = NULL;
- if (!conf->magic || !conf->last) {
- conf->magic = conf->last = m;
- }
- else {
- conf->last->next = m;
- conf->last = m;
- }
-
- /* set values in magic structure */
- m->flag = 0;
- m->cont_level = 0;
- m->lineno = lineno;
-
- while (*l == '>') {
- ++l; /* step over */
- m->cont_level++;
- }
-
- if (m->cont_level != 0 && *l == '(') {
- ++l; /* step over */
- m->flag |= INDIR;
- }
-
- /* get offset, then skip over it */
- m->offset = (int) strtol(l, &t, 0);
- if (l == t) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, serv,
- MODNAME ": offset %s invalid", l);
- }
- l = t;
-
- if (m->flag & INDIR) {
- m->in.type = LONG;
- m->in.offset = 0;
- /*
- * read [.lbs][+-]nnnnn)
- */
- if (*l == '.') {
- switch (*++l) {
- case 'l':
- m->in.type = LONG;
- break;
- case 's':
- m->in.type = SHORT;
- break;
- case 'b':
- m->in.type = BYTE;
- break;
- default:
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, serv,
- MODNAME ": indirect offset type %c invalid", *l);
- break;
- }
- l++;
- }
- s = l;
- if (*l == '+' || *l == '-')
- l++;
- if (ap_isdigit((unsigned char) *l)) {
- m->in.offset = strtol(l, &t, 0);
- if (*s == '-')
- m->in.offset = -m->in.offset;
- }
- else
- t = l;
- if (*t++ != ')') {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, serv,
- MODNAME ": missing ')' in indirect offset");
- }
- l = t;
- }
-
-
- while (ap_isdigit((unsigned char) *l))
- ++l;
- EATAB;
-
-#define NBYTE 4
-#define NSHORT 5
-#define NLONG 4
-#define NSTRING 6
-#define NDATE 4
-#define NBESHORT 7
-#define NBELONG 6
-#define NBEDATE 6
-#define NLESHORT 7
-#define NLELONG 6
-#define NLEDATE 6
-
- if (*l == 'u') {
- ++l;
- m->flag |= UNSIGNED;
- }
-
- /* get type, skip it */
- if (strncmp(l, "byte", NBYTE) == 0) {
- m->type = BYTE;
- l += NBYTE;
- }
- else if (strncmp(l, "short", NSHORT) == 0) {
- m->type = SHORT;
- l += NSHORT;
- }
- else if (strncmp(l, "long", NLONG) == 0) {
- m->type = LONG;
- l += NLONG;
- }
- else if (strncmp(l, "string", NSTRING) == 0) {
- m->type = STRING;
- l += NSTRING;
- }
- else if (strncmp(l, "date", NDATE) == 0) {
- m->type = DATE;
- l += NDATE;
- }
- else if (strncmp(l, "beshort", NBESHORT) == 0) {
- m->type = BESHORT;
- l += NBESHORT;
- }
- else if (strncmp(l, "belong", NBELONG) == 0) {
- m->type = BELONG;
- l += NBELONG;
- }
- else if (strncmp(l, "bedate", NBEDATE) == 0) {
- m->type = BEDATE;
- l += NBEDATE;
- }
- else if (strncmp(l, "leshort", NLESHORT) == 0) {
- m->type = LESHORT;
- l += NLESHORT;
- }
- else if (strncmp(l, "lelong", NLELONG) == 0) {
- m->type = LELONG;
- l += NLELONG;
- }
- else if (strncmp(l, "ledate", NLEDATE) == 0) {
- m->type = LEDATE;
- l += NLEDATE;
- }
- else {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, serv,
- MODNAME ": type %s invalid", l);
- return -1;
- }
- /* New-style anding: "0 byte&0x80 =0x80 dynamically linked" */
- if (*l == '&') {
- ++l;
- m->mask = signextend(serv, m, strtol(l, &l, 0));
- }
- else
- m->mask = ~0L;
- EATAB;
-
- switch (*l) {
- case '>':
- case '<':
- /* Old-style anding: "0 byte &0x80 dynamically linked" */
- case '&':
- case '^':
- case '=':
- m->reln = *l;
- ++l;
- break;
- case '!':
- if (m->type != STRING) {
- m->reln = *l;
- ++l;
- break;
- }
- /* FALL THROUGH */
- default:
- if (*l == 'x' && ap_isspace((unsigned char) l[1])) {
- m->reln = *l;
- ++l;
- goto GetDesc; /* Bill The Cat */
- }
- m->reln = '=';
- break;
- }
- EATAB;
-
- if (getvalue(serv, m, &l))
- return -1;
- /*
- * now get last part - the description
- */
- GetDesc:
- EATAB;
- if (l[0] == '\b') {
- ++l;
- m->nospflag = 1;
- }
- else if ((l[0] == '\\') && (l[1] == 'b')) {
- ++l;
- ++l;
- m->nospflag = 1;
- }
- else
- m->nospflag = 0;
- strncpy(m->desc, l, sizeof(m->desc) - 1);
- m->desc[sizeof(m->desc) - 1] = '\0';
-
-#if MIME_MAGIC_DEBUG
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, serv,
- MODNAME ": parse line=%d m=%x next=%x cont=%d desc=%s",
- lineno, m, m->next, m->cont_level, m->desc);
-#endif /* MIME_MAGIC_DEBUG */
-
- return 0;
-}
-
-/*
- * Read a numeric value from a pointer, into the value union of a magic
- * pointer, according to the magic type. Update the string pointer to point
- * just after the number read. Return 0 for success, non-zero for failure.
- */
-static int getvalue(server_rec *s, struct magic *m, char **p)
-{
- int slen;
-
- if (m->type == STRING) {
- *p = getstr(s, *p, m->value.s, sizeof(m->value.s), &slen);
- m->vallen = slen;
- }
- else if (m->reln != 'x')
- m->value.l = signextend(s, m, strtol(*p, p, 0));
- return 0;
-}
-
-/*
- * Convert a string containing C character escapes. Stop at an unescaped
- * space or tab. Copy the converted version to "p", returning its length in
- * *slen. Return updated scan pointer as function result.
- */
-static char *getstr(server_rec *serv, register char *s, register char *p,
- int plen, int *slen)
-{
- char *origs = s, *origp = p;
- char *pmax = p + plen - 1;
- register int c;
- register int val;
-
- while ((c = *s++) != '\0') {
- if (ap_isspace((unsigned char) c))
- break;
- if (p >= pmax) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, serv,
- MODNAME ": string too long: %s", origs);
- break;
- }
- if (c == '\\') {
- switch (c = *s++) {
-
- case '\0':
- goto out;
-
- default:
- *p++ = (char) c;
- break;
-
- case 'n':
- *p++ = '\n';
- break;
-
- case 'r':
- *p++ = '\r';
- break;
-
- case 'b':
- *p++ = '\b';
- break;
-
- case 't':
- *p++ = '\t';
- break;
-
- case 'f':
- *p++ = '\f';
- break;
-
- case 'v':
- *p++ = '\v';
- break;
-
- /* \ and up to 3 octal digits */
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- val = c - '0';
- c = *s++; /* try for 2 */
- if (c >= '0' && c <= '7') {
- val = (val << 3) | (c - '0');
- c = *s++; /* try for 3 */
- if (c >= '0' && c <= '7')
- val = (val << 3) | (c - '0');
- else
- --s;
- }
- else
- --s;
- *p++ = (char) val;
- break;
-
- /* \x and up to 3 hex digits */
- case 'x':
- val = 'x'; /* Default if no digits */
- c = hextoint(*s++); /* Get next char */
- if (c >= 0) {
- val = c;
- c = hextoint(*s++);
- if (c >= 0) {
- val = (val << 4) + c;
- c = hextoint(*s++);
- if (c >= 0) {
- val = (val << 4) + c;
- }
- else
- --s;
- }
- else
- --s;
- }
- else
- --s;
- *p++ = (char) val;
- break;
- }
- }
- else
- *p++ = (char) c;
- }
- out:
- *p = '\0';
- *slen = p - origp;
- return s;
-}
-
-
-/* Single hex char to int; -1 if not a hex char. */
-static int hextoint(int c)
-{
- if (ap_isdigit((unsigned char) c))
- return c - '0';
- if ((c >= 'a') && (c <= 'f'))
- return c + 10 - 'a';
- if ((c >= 'A') && (c <= 'F'))
- return c + 10 - 'A';
- return -1;
-}
-
-
-/*
- * return DONE to indicate it's been handled
- * return OK to indicate it's a regular file still needing handling
- * other returns indicate a failure of some sort
- */
-static int fsmagic(request_rec *r, const char *fn)
-{
- switch (r->finfo.protection & S_IFMT) {
- case S_IFDIR:
- magic_rsl_puts(r, DIR_MAGIC_TYPE);
- return DONE;
- case S_IFCHR:
- /*
- * (void) magic_rsl_printf(r,"character special (%d/%d)",
- * major(sb->st_rdev), minor(sb->st_rdev));
- */
- (void) magic_rsl_puts(r, MIME_BINARY_UNKNOWN);
- return DONE;
-#ifdef S_IFBLK
- case S_IFBLK:
- /*
- * (void) magic_rsl_printf(r,"block special (%d/%d)",
- * major(sb->st_rdev), minor(sb->st_rdev));
- */
- (void) magic_rsl_puts(r, MIME_BINARY_UNKNOWN);
- return DONE;
- /* TODO add code to handle V7 MUX and Blit MUX files */
-#endif
-#ifdef S_IFIFO
- case S_IFIFO:
- /*
- * magic_rsl_puts(r,"fifo (named pipe)");
- */
- (void) magic_rsl_puts(r, MIME_BINARY_UNKNOWN);
- return DONE;
-#endif
-#ifdef S_IFLNK
- case S_IFLNK:
- /* We used stat(), the only possible reason for this is that the
- * symlink is broken.
- */
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, r,
- MODNAME ": broken symlink (%s)", fn);
- return HTTP_INTERNAL_SERVER_ERROR;
-#endif
-#ifdef S_IFSOCK
-#ifndef __COHERENT__
- case S_IFSOCK:
- magic_rsl_puts(r, MIME_BINARY_UNKNOWN);
- return DONE;
-#endif
-#endif
- case S_IFREG:
- break;
- default:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, r,
- MODNAME ": invalid mode 0%o.", (unsigned int)r->finfo.protection);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- /*
- * regular file, check next possibility
- */
- if (r->finfo.size == 0) {
- magic_rsl_puts(r, MIME_TEXT_UNKNOWN);
- return DONE;
- }
- return OK;
-}
-
-/*
- * softmagic - lookup one file in database (already read from /etc/magic by
- * apprentice.c). Passed the name and FILE * of one file to be typed.
- */
- /* ARGSUSED1 *//* nbytes passed for regularity, maybe need later */
-static int softmagic(request_rec *r, unsigned char *buf, int nbytes)
-{
- if (match(r, buf, nbytes))
- return 1;
-
- return 0;
-}
-
-/*
- * Go through the whole list, stopping if you find a match. Process all the
- * continuations of that match before returning.
- *
- * We support multi-level continuations:
- *
- * At any time when processing a successful top-level match, there is a current
- * continuation level; it represents the level of the last successfully
- * matched continuation.
- *
- * Continuations above that level are skipped as, if we see one, it means that
- * the continuation that controls them - i.e, the lower-level continuation
- * preceding them - failed to match.
- *
- * Continuations below that level are processed as, if we see one, it means
- * we've finished processing or skipping higher-level continuations under the
- * control of a successful or unsuccessful lower-level continuation, and are
- * now seeing the next lower-level continuation and should process it. The
- * current continuation level reverts to the level of the one we're seeing.
- *
- * Continuations at the current level are processed as, if we see one, there's
- * no lower-level continuation that may have failed.
- *
- * If a continuation matches, we bump the current continuation level so that
- * higher-level continuations are processed.
- */
-static int match(request_rec *r, unsigned char *s, int nbytes)
-{
-#if MIME_MAGIC_DEBUG
- int rule_counter = 0;
-#endif
- int cont_level = 0;
- int need_separator = 0;
- union VALUETYPE p;
- magic_server_config_rec *conf = (magic_server_config_rec *)
- ap_get_module_config(r->server->module_config, &mime_magic_module);
- struct magic *m;
-
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": match conf=%x file=%s m=%s m->next=%s last=%s",
- conf,
- conf->magicfile ? conf->magicfile : "NULL",
- conf->magic ? "set" : "NULL",
- (conf->magic && conf->magic->next) ? "set" : "NULL",
- conf->last ? "set" : "NULL");
-#endif
-
-#if MIME_MAGIC_DEBUG
- for (m = conf->magic; m; m = m->next) {
- if (ap_isprint((((unsigned long) m) >> 24) & 255) &&
- ap_isprint((((unsigned long) m) >> 16) & 255) &&
- ap_isprint((((unsigned long) m) >> 8) & 255) &&
- ap_isprint(((unsigned long) m) & 255)) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": match: POINTER CLOBBERED! "
- "m=\"%c%c%c%c\"",
- (((unsigned long) m) >> 24) & 255,
- (((unsigned long) m) >> 16) & 255,
- (((unsigned long) m) >> 8) & 255,
- ((unsigned long) m) & 255);
- break;
- }
- }
-#endif
-
- for (m = conf->magic; m; m = m->next) {
-#if MIME_MAGIC_DEBUG
- rule_counter++;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": line=%d desc=%s", m->lineno, m->desc);
-#endif
-
- /* check if main entry matches */
- if (!mget(r, &p, s, m, nbytes) ||
- !mcheck(r, &p, m)) {
- struct magic *m_cont;
-
- /*
- * main entry didn't match, flush its continuations
- */
- if (!m->next || (m->next->cont_level == 0)) {
- continue;
- }
-
- m_cont = m->next;
- while (m_cont && (m_cont->cont_level != 0)) {
-#if MIME_MAGIC_DEBUG
- rule_counter++;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": line=%d mc=%x mc->next=%x cont=%d desc=%s",
- m_cont->lineno, m_cont,
- m_cont->next, m_cont->cont_level,
- m_cont->desc);
-#endif
- /*
- * this trick allows us to keep *m in sync when the continue
- * advances the pointer
- */
- m = m_cont;
- m_cont = m_cont->next;
- }
- continue;
- }
-
- /* if we get here, the main entry rule was a match */
- /* this will be the last run through the loop */
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": rule matched, line=%d type=%d %s",
- m->lineno, m->type,
- (m->type == STRING) ? m->value.s : "");
-#endif
-
- /* print the match */
- mprint(r, &p, m);
-
- /*
- * If we printed something, we'll need to print a blank before we
- * print something else.
- */
- if (m->desc[0])
- need_separator = 1;
- /* and any continuations that match */
- cont_level++;
- /*
- * while (m && m->next && m->next->cont_level != 0 && ( m = m->next
- * ))
- */
- m = m->next;
- while (m && (m->cont_level != 0)) {
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": match line=%d cont=%d type=%d %s",
- m->lineno, m->cont_level, m->type,
- (m->type == STRING) ? m->value.s : "");
-#endif
- if (cont_level >= m->cont_level) {
- if (cont_level > m->cont_level) {
- /*
- * We're at the end of the level "cont_level"
- * continuations.
- */
- cont_level = m->cont_level;
- }
- if (mget(r, &p, s, m, nbytes) &&
- mcheck(r, &p, m)) {
- /*
- * This continuation matched. Print its message, with a
- * blank before it if the previous item printed and this
- * item isn't empty.
- */
- /* space if previous printed */
- if (need_separator
- && (m->nospflag == 0)
- && (m->desc[0] != '\0')
- ) {
- (void) magic_rsl_putchar(r, ' ');
- need_separator = 0;
- }
- mprint(r, &p, m);
- if (m->desc[0])
- need_separator = 1;
-
- /*
- * If we see any continuations at a higher level, process
- * them.
- */
- cont_level++;
- }
- }
-
- /* move to next continuation record */
- m = m->next;
- }
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": matched after %d rules", rule_counter);
-#endif
- return 1; /* all through */
- }
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": failed after %d rules", rule_counter);
-#endif
- return 0; /* no match at all */
-}
-
-static void mprint(request_rec *r, union VALUETYPE *p, struct magic *m)
-{
- char *pp, *rt;
- unsigned long v;
-
- switch (m->type) {
- case BYTE:
- v = p->b;
- break;
-
- case SHORT:
- case BESHORT:
- case LESHORT:
- v = p->h;
- break;
-
- case LONG:
- case BELONG:
- case LELONG:
- v = p->l;
- break;
-
- case STRING:
- if (m->reln == '=') {
- (void) magic_rsl_printf(r, m->desc, m->value.s);
- }
- else {
- (void) magic_rsl_printf(r, m->desc, p->s);
- }
- return;
-
- case DATE:
- case BEDATE:
- case LEDATE:
- /* XXX: not multithread safe */
- pp = ctime((time_t *) & p->l);
- if ((rt = strchr(pp, '\n')) != NULL)
- *rt = '\0';
- (void) magic_rsl_printf(r, m->desc, pp);
- return;
- default:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, r,
- MODNAME ": invalid m->type (%d) in mprint().",
- m->type);
- return;
- }
-
- v = signextend(r->server, m, v) & m->mask;
- (void) magic_rsl_printf(r, m->desc, (unsigned long) v);
-}
-
-/*
- * Convert the byte order of the data we are looking at
- */
-static int mconvert(request_rec *r, union VALUETYPE *p, struct magic *m)
-{
- char *rt;
-
- switch (m->type) {
- case BYTE:
- case SHORT:
- case LONG:
- case DATE:
- return 1;
- case STRING:
- /* Null terminate and eat the return */
- p->s[sizeof(p->s) - 1] = '\0';
- if ((rt = strchr(p->s, '\n')) != NULL)
- *rt = '\0';
- return 1;
- case BESHORT:
- p->h = (short) ((p->hs[0] << 8) | (p->hs[1]));
- return 1;
- case BELONG:
- case BEDATE:
- p->l = (long)
- ((p->hl[0] << 24) | (p->hl[1] << 16) | (p->hl[2] << 8) | (p->hl[3]));
- return 1;
- case LESHORT:
- p->h = (short) ((p->hs[1] << 8) | (p->hs[0]));
- return 1;
- case LELONG:
- case LEDATE:
- p->l = (long)
- ((p->hl[3] << 24) | (p->hl[2] << 16) | (p->hl[1] << 8) | (p->hl[0]));
- return 1;
- default:
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, r,
- MODNAME ": invalid type %d in mconvert().", m->type);
- return 0;
- }
-}
-
-
-static int mget(request_rec *r, union VALUETYPE *p, unsigned char *s,
- struct magic *m, int nbytes)
-{
- long offset = m->offset;
-
- if (offset + sizeof(union VALUETYPE) > nbytes)
- return 0;
-
- memcpy(p, s + offset, sizeof(union VALUETYPE));
-
- if (!mconvert(r, p, m))
- return 0;
-
- if (m->flag & INDIR) {
-
- switch (m->in.type) {
- case BYTE:
- offset = p->b + m->in.offset;
- break;
- case SHORT:
- offset = p->h + m->in.offset;
- break;
- case LONG:
- offset = p->l + m->in.offset;
- break;
- }
-
- if (offset + sizeof(union VALUETYPE) > nbytes)
- return 0;
-
- memcpy(p, s + offset, sizeof(union VALUETYPE));
-
- if (!mconvert(r, p, m))
- return 0;
- }
- return 1;
-}
-
-static int mcheck(request_rec *r, union VALUETYPE *p, struct magic *m)
-{
- register unsigned long l = m->value.l;
- register unsigned long v;
- int matched;
-
- if ((m->value.s[0] == 'x') && (m->value.s[1] == '\0')) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, r,
- MODNAME ": BOINK");
- return 1;
- }
-
- switch (m->type) {
- case BYTE:
- v = p->b;
- break;
-
- case SHORT:
- case BESHORT:
- case LESHORT:
- v = p->h;
- break;
-
- case LONG:
- case BELONG:
- case LELONG:
- case DATE:
- case BEDATE:
- case LEDATE:
- v = p->l;
- break;
-
- case STRING:
- l = 0;
- /*
- * What we want here is: v = strncmp(m->value.s, p->s, m->vallen);
- * but ignoring any nulls. bcmp doesn't give -/+/0 and isn't
- * universally available anyway.
- */
- v = 0;
- {
- register unsigned char *a = (unsigned char *) m->value.s;
- register unsigned char *b = (unsigned char *) p->s;
- register int len = m->vallen;
-
- while (--len >= 0)
- if ((v = *b++ - *a++) != 0)
- break;
- }
- break;
- default:
- /* bogosity, pretend that it just wasn't a match */
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, r,
- MODNAME ": invalid type %d in mcheck().", m->type);
- return 0;
- }
-
- v = signextend(r->server, m, v) & m->mask;
-
- switch (m->reln) {
- case 'x':
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- "%lu == *any* = 1", v);
-#endif
- matched = 1;
- break;
-
- case '!':
- matched = v != l;
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- "%lu != %lu = %d", v, l, matched);
-#endif
- break;
-
- case '=':
- matched = v == l;
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- "%lu == %lu = %d", v, l, matched);
-#endif
- break;
-
- case '>':
- if (m->flag & UNSIGNED) {
- matched = v > l;
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- "%lu > %lu = %d", v, l, matched);
-#endif
- }
- else {
- matched = (long) v > (long) l;
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- "%ld > %ld = %d", v, l, matched);
-#endif
- }
- break;
-
- case '<':
- if (m->flag & UNSIGNED) {
- matched = v < l;
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- "%lu < %lu = %d", v, l, matched);
-#endif
- }
- else {
- matched = (long) v < (long) l;
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- "%ld < %ld = %d", v, l, matched);
-#endif
- }
- break;
-
- case '&':
- matched = (v & l) == l;
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- "((%lx & %lx) == %lx) = %d", v, l, l, matched);
-#endif
- break;
-
- case '^':
- matched = (v & l) != l;
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- "((%lx & %lx) != %lx) = %d", v, l, l, matched);
-#endif
- break;
-
- default:
- /* bogosity, pretend it didn't match */
- matched = 0;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_ERR, 0, r,
- MODNAME ": mcheck: can't happen: invalid relation %d.",
- m->reln);
- break;
- }
-
- return matched;
-}
-
-/* an optimization over plain strcmp() */
-#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
-
-static int ascmagic(request_rec *r, unsigned char *buf, int nbytes)
-{
- int has_escapes = 0;
- unsigned char *s;
- char nbuf[HOWMANY + 1]; /* one extra for terminating '\0' */
- char *token;
- register struct names *p;
- int small_nbytes;
-
- /* these are easy, do them first */
-
- /*
- * for troff, look for . + letter + letter or .\"; this must be done to
- * disambiguate tar archives' ./file and other trash from real troff
- * input.
- */
- if (*buf == '.') {
- unsigned char *tp = buf + 1;
-
- while (ap_isspace(*tp))
- ++tp; /* skip leading whitespace */
- if ((ap_isalnum(*tp) || *tp == '\\') &&
- (ap_isalnum(*(tp + 1)) || *tp == '"')) {
- magic_rsl_puts(r, "application/x-troff");
- return 1;
- }
- }
- if ((*buf == 'c' || *buf == 'C') && ap_isspace(*(buf + 1))) {
- /* Fortran */
- magic_rsl_puts(r, "text/plain");
- return 1;
- }
-
- /* look for tokens from names.h - this is expensive!, so we'll limit
- * ourselves to only SMALL_HOWMANY bytes */
- small_nbytes = (nbytes > SMALL_HOWMANY) ? SMALL_HOWMANY : nbytes;
- /* make a copy of the buffer here because strtok() will destroy it */
- s = (unsigned char *) memcpy(nbuf, buf, small_nbytes);
- s[small_nbytes] = '\0';
- has_escapes = (memchr(s, '\033', small_nbytes) != NULL);
- /* XXX: not multithread safe */
- while ((token = strtok((char *) s, " \t\n\r\f")) != NULL) {
- s = NULL; /* make strtok() keep on tokin' */
- for (p = names; p < names + NNAMES; p++) {
- if (STREQ(p->name, token)) {
- magic_rsl_puts(r, types[p->type]);
- if (has_escapes)
- magic_rsl_puts(r, " (with escape sequences)");
- return 1;
- }
- }
- }
-
- switch (is_tar(buf, nbytes)) {
- case 1:
- /* V7 tar archive */
- magic_rsl_puts(r, "application/x-tar");
- return 1;
- case 2:
- /* POSIX tar archive */
- magic_rsl_puts(r, "application/x-tar");
- return 1;
- }
-
- /* all else fails, but it is ascii... */
- if (has_escapes) {
- /* text with escape sequences */
- /* we leave this open for further differentiation later */
- magic_rsl_puts(r, "text/plain");
- }
- else {
- /* plain text */
- magic_rsl_puts(r, "text/plain");
- }
- return 1;
-}
-
-
-/*
- * compress routines: zmagic() - returns 0 if not recognized, uncompresses
- * and prints information if recognized uncompress(s, method, old, n, newch)
- * - uncompress old into new, using method, return sizeof new
- */
-
-static struct {
- char *magic;
- int maglen;
- char *argv[3];
- int silent;
- char *encoding; /* MUST be lowercase */
-} compr[] = {
-
- /* we use gzip here rather than uncompress because we have to pass
- * it a full filename -- and uncompress only considers filenames
- * ending with .Z
- */
- {
- "\037\235", 2, {
- "gzip", "-dcq", NULL
- }, 0, "x-compress"
- },
- {
- "\037\213", 2, {
- "gzip", "-dcq", NULL
- }, 1, "x-gzip"
- },
- /*
- * XXX pcat does not work, cause I don't know how to make it read stdin,
- * so we use gzip
- */
- {
- "\037\036", 2, {
- "gzip", "-dcq", NULL
- }, 0, "x-gzip"
- },
-};
-
-static int ncompr = sizeof(compr) / sizeof(compr[0]);
-
-static int zmagic(request_rec *r, unsigned char *buf, int nbytes)
-{
- unsigned char *newbuf;
- int newsize;
- int i;
-
- for (i = 0; i < ncompr; i++) {
- if (nbytes < compr[i].maglen)
- continue;
- if (memcmp(buf, compr[i].magic, compr[i].maglen) == 0)
- break;
- }
-
- if (i == ncompr)
- return 0;
-
- if ((newsize = uncompress(r, i, &newbuf, nbytes)) > 0) {
- tryit(r, newbuf, newsize, 0);
-
- /* set encoding type in the request record */
- r->content_encoding = compr[i].encoding;
- }
- return 1;
-}
-
-
-struct uncompress_parms {
- request_rec *r;
- int method;
-};
-
-static int uncompress_child(struct uncompress_parms *parm, ap_context_t *cntxt,
- BUFF **script_in)
-{
- int rc = 1;
- char *new_argv[4];
- char **env;
- request_rec *r = parm->r;
- ap_context_t *child_context = cntxt;
- ap_procattr_t *procattr;
- ap_proc_t *procnew = NULL;
- ap_file_t *file = NULL;
- ap_iol *iol;
-
- ap_block_alarms();
-
- env = ap_create_environment(child_context, r->subprocess_env);
-
- if ((ap_createprocattr_init(&procattr, child_context) != APR_SUCCESS) ||
- (ap_setprocattr_io(procattr, APR_FULL_BLOCK,
- APR_FULL_BLOCK, APR_NO_PIPE) != APR_SUCCESS) ||
- (ap_setprocattr_dir(procattr, r->filename) != APR_SUCCESS) ||
- (ap_setprocattr_cmdtype(procattr, APR_PROGRAM) != APR_SUCCESS)) {
- /* Something bad happened, tell the world. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_ENOPROC, r,
- "couldn't setup child process: %s", r->filename);
- }
- else {
- new_argv[0] = compr[parm->method].argv[0];
- new_argv[1] = compr[parm->method].argv[1];
- new_argv[2] = r->filename;
- new_argv[3] = NULL;
-
- if (compr[parm->method].silent) {
- close(STDERR_FILENO);
- }
-
- rc = ap_create_process(&procnew, compr[parm->method].argv[0],
- new_argv, env, procattr, child_context);
-
- if (rc != APR_SUCCESS) {
- /* Bad things happened. Everyone should have cleaned up. */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, APR_ENOPROC, r,
- MODNAME ": could not execute `%s'.",
- compr[parm->method].argv[0]);
- }
- else {
- ap_note_subprocess(child_context, procnew, kill_after_timeout);
- /* Fill in BUFF structure for parents pipe to child's stdout */
- ap_get_childout(&file, procnew);
- iol = ap_create_file_iol(file);
- if (!iol)
- return APR_EBADF;
- if (script_in) {
- *script_in = ap_bcreate(child_context, B_RD);
- }
- ap_bpush_iol(*script_in, iol);
- }
- }
- ap_unblock_alarms();
-
- return (rc);
-}
-
-static int uncompress(request_rec *r, int method,
- unsigned char **newch, int n)
-{
- struct uncompress_parms parm;
- BUFF *bout = NULL;
- ap_context_t *sub_context;
- ap_status_t rv;
-
- parm.r = r;
- parm.method = method;
-
- /* We make a sub_pool so that we can collect our child early, otherwise
- * there are cases (i.e. generating directory indicies with mod_autoindex)
- * where we would end up with LOTS of zombies.
- */
- if (ap_create_context(&sub_context, r->pool) != APR_SUCCESS)
- return -1;
-
- if ((rv = uncompress_child(&parm, sub_context, &bout)) != APR_SUCCESS) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- MODNAME ": couldn't spawn uncompress process: %s", r->uri);
- return -1;
- }
-
- *newch = (unsigned char *) ap_palloc(r->pool, n);
- rv = ap_bread(bout, *newch, n, &n);
- if (n == 0) {
- ap_destroy_context(sub_context);
- ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
- MODNAME ": read failed %s", r->filename);
- return -1;
- }
- ap_destroy_context(sub_context);
- return n;
-}
-
-/*
- * is_tar() -- figure out whether file is a tar archive.
- *
- * Stolen (by author of file utility) from the public domain tar program: Public
- * Domain version written 26 Aug 1985 John Gilmore (ihnp4!hoptoad!gnu).
- *
- * @(#)list.c 1.18 9/23/86 Public Domain - gnu $Id: mod_mime_magic.c,v 1.7
- * 1997/06/24 00:41:02 ikluft Exp ikluft $
- *
- * Comments changed and some code/comments reformatted for file command by Ian
- * Darwin.
- */
-
-#define isodigit(c) ( ((c) >= '0') && ((c) <= '7') )
-
-/*
- * Return 0 if the checksum is bad (i.e., probably not a tar archive), 1 for
- * old UNIX tar file, 2 for Unix Std (POSIX) tar file.
- */
-
-static int is_tar(unsigned char *buf, int nbytes)
-{
- register union record *header = (union record *) buf;
- register int i;
- register long sum, recsum;
- register char *p;
-
- if (nbytes < sizeof(union record))
- return 0;
-
- recsum = from_oct(8, header->header.chksum);
-
- sum = 0;
- p = header->charptr;
- for (i = sizeof(union record); --i >= 0;) {
- /*
- * We can't use unsigned char here because of old compilers, e.g. V7.
- */
- sum += 0xFF & *p++;
- }
-
- /* Adjust checksum to count the "chksum" field as blanks. */
- for (i = sizeof(header->header.chksum); --i >= 0;)
- sum -= 0xFF & header->header.chksum[i];
- sum += ' ' * sizeof header->header.chksum;
-
- if (sum != recsum)
- return 0; /* Not a tar archive */
-
- if (0 == strcmp(header->header.magic, TMAGIC))
- return 2; /* Unix Standard tar archive */
-
- return 1; /* Old fashioned tar archive */
-}
-
-
-/*
- * Quick and dirty octal conversion.
- *
- * Result is -1 if the field is invalid (all blank, or nonoctal).
- */
-static long from_oct(int digs, char *where)
-{
- register long value;
-
- while (ap_isspace(*where)) { /* Skip spaces */
- where++;
- if (--digs <= 0)
- return -1; /* All blank field */
- }
- value = 0;
- while (digs > 0 && isodigit(*where)) { /* Scan til nonoctal */
- value = (value << 3) | (*where++ - '0');
- --digs;
- }
-
- if (digs > 0 && *where && !ap_isspace(*where))
- return -1; /* Ended on non-space/nul */
-
- return value;
-}
-
-/*
- * Check for file-revision suffix
- *
- * This is for an obscure document control system used on an intranet.
- * The web representation of each file's revision has an @1, @2, etc
- * appended with the revision number. This needs to be stripped off to
- * find the file suffix, which can be recognized by sending the name back
- * through a sub-request. The base file name (without the @num suffix)
- * must exist because its type will be used as the result.
- */
-static int revision_suffix(request_rec *r)
-{
- int suffix_pos, result;
- char *sub_filename;
- request_rec *sub;
-
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": revision_suffix checking %s", r->filename);
-#endif /* MIME_MAGIC_DEBUG */
-
- /* check for recognized revision suffix */
- suffix_pos = strlen(r->filename) - 1;
- if (!ap_isdigit(r->filename[suffix_pos])) {
- return 0;
- }
- while (suffix_pos >= 0 && ap_isdigit(r->filename[suffix_pos]))
- suffix_pos--;
- if (suffix_pos < 0 || r->filename[suffix_pos] != '@') {
- return 0;
- }
-
- /* perform sub-request for the file name without the suffix */
- result = 0;
- sub_filename = ap_pstrndup(r->pool, r->filename, suffix_pos);
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": subrequest lookup for %s", sub_filename);
-#endif /* MIME_MAGIC_DEBUG */
- sub = ap_sub_req_lookup_file(sub_filename, r);
-
- /* extract content type/encoding/language from sub-request */
- if (sub->content_type) {
- r->content_type = ap_pstrdup(r->pool, sub->content_type);
-#if MIME_MAGIC_DEBUG
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r,
- MODNAME ": subrequest %s got %s",
- sub_filename, r->content_type);
-#endif /* MIME_MAGIC_DEBUG */
- if (sub->content_encoding)
- r->content_encoding =
- ap_pstrdup(r->pool, sub->content_encoding);
- if (sub->content_language)
- r->content_language =
- ap_pstrdup(r->pool, sub->content_language);
- result = 1;
- }
-
- /* clean up */
- ap_destroy_sub_req(sub);
-
- return result;
-}
-
-/*
- * initialize the module
- */
-static void magic_init(ap_context_t *p, ap_context_t *plog, ap_context_t *ptemp, server_rec *main_server)
-{
- int result;
- magic_server_config_rec *conf;
- magic_server_config_rec *main_conf;
- server_rec *s;
-#if MIME_MAGIC_DEBUG
- struct magic *m, *prevm;
-#endif /* MIME_MAGIC_DEBUG */
-
- main_conf = ap_get_module_config(main_server->module_config, &mime_magic_module);
- for (s = main_server; s; s = s->next) {
- conf = ap_get_module_config(s->module_config, &mime_magic_module);
- if (conf->magicfile == NULL && s != main_server) {
- /* inherits from the parent */
- *conf = *main_conf;
- }
- else if (conf->magicfile) {
- result = apprentice(s, p);
- if (result == -1)
- return;
-#if MIME_MAGIC_DEBUG
- prevm = 0;
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, s,
- MODNAME ": magic_init 1 test");
- for (m = conf->magic; m; m = m->next) {
- if (ap_isprint((((unsigned long) m) >> 24) & 255) &&
- ap_isprint((((unsigned long) m) >> 16) & 255) &&
- ap_isprint((((unsigned long) m) >> 8) & 255) &&
- ap_isprint(((unsigned long) m) & 255)) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, s,
- MODNAME ": magic_init 1: POINTER CLOBBERED! "
- "m=\"%c%c%c%c\" line=%d",
- (((unsigned long) m) >> 24) & 255,
- (((unsigned long) m) >> 16) & 255,
- (((unsigned long) m) >> 8) & 255,
- ((unsigned long) m) & 255,
- prevm ? prevm->lineno : -1);
- break;
- }
- prevm = m;
- }
-#endif
- }
- }
-}
-
-/*
- * Find the Content-Type from any resource this module has available
- */
-
-static int magic_find_ct(request_rec *r)
-{
- int result;
- magic_server_config_rec *conf;
-
- /* the file has to exist */
- if (r->finfo.protection == 0 || !r->filename) {
- return DECLINED;
- }
-
- /* was someone else already here? */
- if (r->content_type) {
- return DECLINED;
- }
-
- conf = ap_get_module_config(r->server->module_config, &mime_magic_module);
- if (!conf || !conf->magic) {
- return DECLINED;
- }
-
- /* initialize per-request info */
- if (!magic_set_config(r)) {
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- /* try excluding file-revision suffixes */
- if (revision_suffix(r) != 1) {
- /* process it based on the file contents */
- if ((result = magic_process(r)) != OK) {
- return result;
- }
- }
-
- /* if we have any results, put them in the request structure */
- return magic_rsl_to_request(r);
-}
-
-static void register_hooks(void)
-{
- static const char * const aszPre[]={ "mod_mime.c", NULL };
-
- /* mod_mime_magic should be run after mod_mime, if at all. */
-
- ap_hook_type_checker(magic_find_ct, aszPre, NULL, HOOK_MIDDLE);
- ap_hook_post_config(magic_init, NULL, NULL, HOOK_FIRST);
-}
-
-/*
- * Apache API module interface
- */
-
-module mime_magic_module =
-{
- STANDARD20_MODULE_STUFF,
- NULL, /* dir config creator */
- NULL, /* dir merger --- default is to override */
- create_magic_server_config, /* server config */
- merge_magic_server_config, /* merge server config */
- mime_magic_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
-
-
diff --git a/modules/metadata/mod_mime_magic.exp b/modules/metadata/mod_mime_magic.exp
deleted file mode 100644
index 42068a4342..0000000000
--- a/modules/metadata/mod_mime_magic.exp
+++ /dev/null
@@ -1 +0,0 @@
-mime_magic_module
diff --git a/modules/metadata/mod_setenvif.c b/modules/metadata/mod_setenvif.c
deleted file mode 100644
index 01e5e6ac38..0000000000
--- a/modules/metadata/mod_setenvif.c
+++ /dev/null
@@ -1,420 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * IT'S 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_setenvif.c
- * Set environment variables based on matching request headers or
- * attributes against regex strings
- *
- * Paul Sutton <paul@ukweb.com> 27 Oct 1996
- * Based on mod_browser by Alexei Kosut <akosut@organic.com>
- */
-
-/*
- * Used to set environment variables based on the incoming request headers,
- * or some selected other attributes of the request (e.g., the remote host
- * name).
- *
- * Usage:
- *
- * SetEnvIf name regex var ...
- *
- * where name is either a HTTP request header name, or one of the
- * special values (see below). The 'value' of the header (or the
- * value of the special value from below) are compared against the
- * regex argument. If this is a simple string, a simple sub-string
- * match is performed. Otherwise, a request expression match is
- * done. If the value matches the string or regular expression, the
- * environment variables listed as var ... are set. Each var can
- * be in one of three formats: var, which sets the named variable
- * (the value value "1"); var=value, which sets the variable to
- * the given value; or !var, which unsets the variable is it has
- * been previously set.
- *
- * Normally the strings are compared with regard to case. To ignore
- * case, use the directive SetEnvIfNoCase instead.
- *
- * Special values for 'name' are:
- *
- * remote_host Remote host name (if available)
- * remote_addr Remote IP address
- * remote_user Remote authenticated user (if any)
- * request_method Request method (GET, POST, etc)
- * request_uri Requested URI
- *
- * Examples:
- *
- * To set the enviroment variable LOCALHOST if the client is the local
- * machine:
- *
- * SetEnvIf remote_addr 127.0.0.1 LOCALHOST
- *
- * To set LOCAL if the client is the local host, or within our company's
- * domain (192.168.10):
- *
- * SetEnvIf remote_addr 192.168.10. LOCAL
- * SetEnvIf remote_addr 127.0.0.1 LOCALHOST
- *
- * This could be written as:
- *
- * SetEnvIf remote_addr (127.0.0.1|192.168.10.) LOCAL
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_protocol.h"
-
-enum special {
- SPECIAL_NOT,
- SPECIAL_REMOTE_ADDR,
- SPECIAL_REMOTE_HOST,
- SPECIAL_REMOTE_USER,
- SPECIAL_REQUEST_URI,
- SPECIAL_REQUEST_METHOD,
- SPECIAL_REQUEST_PROTOCOL
-};
-typedef struct {
- char *name; /* header name */
- char *regex; /* regex to match against */
- regex_t *preg; /* compiled regex */
- ap_table_t *features; /* env vars to set (or unset) */
- ENUM_BITFIELD( /* is it a "special" header ? */
- enum special,
- special_type,4);
- unsigned icase : 1; /* ignoring case? */
-} sei_entry;
-
-typedef struct {
- ap_array_header_t *conditionals;
-} sei_cfg_rec;
-
-module MODULE_VAR_EXPORT setenvif_module;
-
-static void *create_setenvif_config(ap_context_t *p, server_rec *dummy)
-{
- sei_cfg_rec *new = (sei_cfg_rec *) ap_palloc(p, sizeof(sei_cfg_rec));
-
- new->conditionals = ap_make_array(p, 20, sizeof(sei_entry));
- return (void *) new;
-}
-
-static void *merge_setenvif_config(ap_context_t *p, void *basev, void *overridesv)
-{
- sei_cfg_rec *a = ap_pcalloc(p, sizeof(sei_cfg_rec));
- sei_cfg_rec *base = basev, *overrides = overridesv;
-
- a->conditionals = ap_append_arrays(p, base->conditionals,
- overrides->conditionals);
- return a;
-}
-
-/* any non-NULL magic constant will do... used to indicate if REG_ICASE should
- * be used
- */
-#define ICASE_MAGIC ((void *)(&setenvif_module))
-
-static const char *add_setenvif_core(cmd_parms *cmd, void *mconfig,
- char *fname, const char *args)
-{
- char *regex;
- const char *feature;
- sei_cfg_rec *sconf = ap_get_module_config(cmd->server->module_config,
- &setenvif_module);
- sei_entry *new, *entries = (sei_entry *) sconf->conditionals->elts;
- char *var;
- int i;
- int beenhere = 0;
- unsigned icase;
-
- /* get regex */
- regex = ap_getword_conf(cmd->pool, &args);
- if (!*regex) {
- return ap_pstrcat(cmd->pool, "Missing regular expression for ",
- cmd->cmd->name, NULL);
- }
-
- /*
- * If we've already got a sei_entry with the same name we want to
- * just copy the name pointer... so that later on we can compare
- * two header names just by comparing the pointers.
- */
-
- for (i = 0; i < sconf->conditionals->nelts; ++i) {
- new = &entries[i];
- if (!strcasecmp(new->name, fname)) {
- fname = new->name;
- break;
- }
- }
-
- /* if the last entry has an idential headername and regex then
- * merge with it
- */
- i = sconf->conditionals->nelts - 1;
- icase = cmd->info == ICASE_MAGIC;
- if (i < 0
- || entries[i].name != fname
- || entries[i].icase != icase
- || strcmp(entries[i].regex, regex)) {
-
- /* no match, create a new entry */
-
- new = ap_push_array(sconf->conditionals);
- new->name = fname;
- new->regex = regex;
- new->icase = icase;
- new->preg = ap_pregcomp(cmd->pool, regex,
- (REG_EXTENDED | REG_NOSUB
- | (icase ? REG_ICASE : 0)));
- if (new->preg == NULL) {
- return ap_pstrcat(cmd->pool, cmd->cmd->name,
- " regex could not be compiled.", NULL);
- }
- new->features = ap_make_table(cmd->pool, 2);
-
- if (!strcasecmp(fname, "remote_addr")) {
- new->special_type = SPECIAL_REMOTE_ADDR;
- }
- else if (!strcasecmp(fname, "remote_host")) {
- new->special_type = SPECIAL_REMOTE_HOST;
- }
- else if (!strcasecmp(fname, "remote_user")) {
- new->special_type = SPECIAL_REMOTE_USER;
- }
- else if (!strcasecmp(fname, "request_uri")) {
- new->special_type = SPECIAL_REQUEST_URI;
- }
- else if (!strcasecmp(fname, "request_method")) {
- new->special_type = SPECIAL_REQUEST_METHOD;
- }
- else if (!strcasecmp(fname, "request_protocol")) {
- new->special_type = SPECIAL_REQUEST_PROTOCOL;
- }
- else {
- new->special_type = SPECIAL_NOT;
- }
- }
- else {
- new = &entries[i];
- }
-
- for ( ; ; ) {
- feature = ap_getword_conf(cmd->pool, &args);
- if (!*feature) {
- break;
- }
- beenhere++;
-
- var = ap_getword(cmd->pool, &feature, '=');
- if (*feature) {
- ap_table_setn(new->features, var, feature);
- }
- else if (*var == '!') {
- ap_table_setn(new->features, var + 1, "!");
- }
- else {
- ap_table_setn(new->features, var, "1");
- }
- }
-
- if (!beenhere) {
- return ap_pstrcat(cmd->pool, "Missing envariable expression for ",
- cmd->cmd->name, NULL);
- }
-
- return NULL;
-}
-
-static const char *add_setenvif(cmd_parms *cmd, void *mconfig,
- const char *args)
-{
- char *fname;
-
- /* get header name */
- fname = ap_getword_conf(cmd->pool, &args);
- if (!*fname) {
- return ap_pstrcat(cmd->pool, "Missing header-field name for ",
- cmd->cmd->name, NULL);
- }
- return add_setenvif_core(cmd, mconfig, fname, args);
-}
-
-/*
- * This routine handles the BrowserMatch* directives. It simply turns around
- * and feeds them, with the appropriate embellishments, to the general-purpose
- * command handler.
- */
-static const char *add_browser(cmd_parms *cmd, void *mconfig, const char *args)
-{
- return add_setenvif_core(cmd, mconfig, "User-Agent", args);
-}
-
-static const command_rec setenvif_module_cmds[] =
-{
- { "SetEnvIf", add_setenvif, NULL,
- RSRC_CONF, RAW_ARGS, "A header-name, regex and a list of variables." },
- { "SetEnvIfNoCase", add_setenvif, ICASE_MAGIC,
- RSRC_CONF, RAW_ARGS, "a header-name, regex and a list of variables." },
- { "BrowserMatch", add_browser, NULL,
- RSRC_CONF, RAW_ARGS, "A browser regex and a list of variables." },
- { "BrowserMatchNoCase", add_browser, ICASE_MAGIC,
- RSRC_CONF, RAW_ARGS, "A browser regex and a list of variables." },
- { NULL },
-};
-
-static int match_headers(request_rec *r)
-{
- server_rec *s = r->server;
- sei_cfg_rec *sconf;
- sei_entry *entries;
- ap_table_entry_t *elts;
- const char *val;
- int i, j;
- char *last_name;
-
- sconf = (sei_cfg_rec *) ap_get_module_config(s->module_config,
- &setenvif_module);
- entries = (sei_entry *) sconf->conditionals->elts;
- last_name = NULL;
- val = NULL;
- for (i = 0; i < sconf->conditionals->nelts; ++i) {
- sei_entry *b = &entries[i];
-
- /* Optimize the case where a bunch of directives in a row use the
- * same header. Remember we don't need to strcmp the two header
- * names because we made sure the pointers were equal during
- * configuration.
- */
- if (b->name != last_name) {
- last_name = b->name;
- switch (b->special_type) {
- case SPECIAL_REMOTE_ADDR:
- val = r->connection->remote_ip;
- break;
- case SPECIAL_REMOTE_HOST:
- val = ap_get_remote_host(r->connection, r->per_dir_config,
- REMOTE_NAME);
- break;
- case SPECIAL_REMOTE_USER:
- val = r->user;
- break;
- case SPECIAL_REQUEST_URI:
- val = r->uri;
- break;
- case SPECIAL_REQUEST_METHOD:
- val = r->method;
- break;
- case SPECIAL_REQUEST_PROTOCOL:
- val = r->protocol;
- break;
- case SPECIAL_NOT:
- val = ap_table_get(r->headers_in, b->name);
- if (val == NULL) {
- val = ap_table_get(r->subprocess_env, b->name);
- }
- break;
- }
- }
-
- /*
- * A NULL value indicates that the header field or special entity
- * wasn't present or is undefined. Represent that as an empty string
- * so that REs like "^$" will work and allow envariable setting
- * based on missing or empty field.
- */
- if (val == NULL) {
- val = "";
- }
-
- if (!ap_regexec(b->preg, val, 0, NULL, 0)) {
- ap_array_header_t *arr = ap_table_elts(b->features);
- elts = (ap_table_entry_t *) arr->elts;
-
- for (j = 0; j < arr->nelts; ++j) {
- if (!strcmp(elts[j].val, "!")) {
- ap_table_unset(r->subprocess_env, elts[j].key);
- }
- else {
- ap_table_setn(r->subprocess_env, elts[j].key, elts[j].val);
- }
- }
- }
- }
-
- return DECLINED;
-}
-
-static void register_hooks(void)
-{
- ap_hook_post_read_request(match_headers,NULL,NULL,HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT setenvif_module =
-{
- STANDARD20_MODULE_STUFF,
- NULL, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- create_setenvif_config, /* server config */
- merge_setenvif_config, /* merge server configs */
- setenvif_module_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
-
diff --git a/modules/metadata/mod_setenvif.exp b/modules/metadata/mod_setenvif.exp
deleted file mode 100644
index 4f3800e3a8..0000000000
--- a/modules/metadata/mod_setenvif.exp
+++ /dev/null
@@ -1 +0,0 @@
-setenvif_module
diff --git a/modules/metadata/mod_unique_id.c b/modules/metadata/mod_unique_id.c
deleted file mode 100644
index 49deb2bb55..0000000000
--- a/modules/metadata/mod_unique_id.c
+++ /dev/null
@@ -1,411 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_unique_id.c: generate a unique identifier for each request
- *
- * Original author: Dean Gaudet <dgaudet@arctic.org>
- * UUencoding modified by: Alvaro Martinez Echevarria <alvaro@lander.es>
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-
-typedef struct {
- unsigned int stamp;
- unsigned int in_addr;
- unsigned int pid;
- unsigned short counter;
- unsigned int thread_index;
-} unique_id_rec;
-
-/* We are using thread_index (the index into the scoreboard), because we
- * cannont garauntee the thread_id will be an integer.
- *
- * This code looks like it won't give a unique ID with the new thread logic.
- * It will. The reason is, we don't increment the counter in a thread_safe
- * manner. Because the thread_index is also in the unique ID now, this does
- * not matter. In order for the id to not be unique, the same thread would
- * have to get the same counter twice in the same second.
- */
-
-/* Comments:
- *
- * We want an identifier which is unique across all hits, everywhere.
- * "everywhere" includes multiple httpd instances on the same machine, or on
- * multiple machines. Essentially "everywhere" should include all possible
- * httpds across all servers at a particular "site". We make some assumptions
- * that if the site has a cluster of machines then their time is relatively
- * synchronized. We also assume that the first address returned by a
- * gethostbyname (gethostname()) is unique across all the machines at the
- * "site".
- *
- * We also further assume that pids fit in 32-bits. If something uses more
- * than 32-bits, the fix is trivial, but it requires the unrolled uuencoding
- * loop to be extended. * A similar fix is needed to support multithreaded
- * servers, using a pid/tid combo.
- *
- * Together, the in_addr and pid are assumed to absolutely uniquely identify
- * this one child from all other currently running children on all servers
- * (including this physical server if it is running multiple httpds) from each
- * other.
- *
- * The stamp and counter are used to distinguish all hits for a particular
- * (in_addr,pid) pair. The stamp is updated using r->request_time,
- * saving cpu cycles. The counter is never reset, and is used to permit up to
- * 64k requests in a single second by a single child.
- *
- * The 112-bits of unique_id_rec are encoded using the alphabet
- * [A-Za-z0-9@-], resulting in 19 bytes of printable characters. That is then
- * stuffed into the environment variable UNIQUE_ID so that it is available to
- * other modules. The alphabet choice differs from normal base64 encoding
- * [A-Za-z0-9+/] because + and / are special characters in URLs and we want to
- * make it easy to use UNIQUE_ID in URLs.
- *
- * Note that UNIQUE_ID should be considered an opaque token by other
- * applications. No attempt should be made to dissect its internal components.
- * It is an abstraction that may change in the future as the needs of this
- * module change.
- *
- * It is highly desirable that identifiers exist for "eternity". But future
- * needs (such as much faster webservers, moving to 64-bit pids, or moving to a
- * multithreaded server) may dictate a need to change the contents of
- * unique_id_rec. Such a future implementation should ensure that the first
- * field is still a time_t stamp. By doing that, it is possible for a site to
- * have a "flag second" in which they stop all of their old-format servers,
- * wait one entire second, and then start all of their new-servers. This
- * procedure will ensure that the new space of identifiers is completely unique
- * from the old space. (Since the first four unencoded bytes always differ.)
- */
-/*
- * Sun Jun 7 05:43:49 CEST 1998 -- Alvaro
- * More comments:
- * 1) The UUencoding prodecure is now done in a general way, avoiding the problems
- * with sizes and paddings that can arise depending on the architecture. Now the
- * offsets and sizes of the elements of the unique_id_rec structure are calculated
- * in unique_id_global_init; and then used to duplicate the structure without the
- * paddings that might exist. The multithreaded server fix should be now very easy:
- * just add a new "tid" field to the unique_id_rec structure, and increase by one
- * UNIQUE_ID_REC_MAX.
- * 2) unique_id_rec.stamp has been changed from "time_t" to "unsigned int", because
- * its size is 64bits on some platforms (linux/alpha), and this caused problems with
- * htonl/ntohl. Well, this shouldn't be a problem till year 2106.
- */
-
-static unsigned global_in_addr;
-
-static unique_id_rec cur_unique_id;
-
-/*
- * Number of elements in the structure unique_id_rec.
- */
-#define UNIQUE_ID_REC_MAX 5
-
-static unsigned short unique_id_rec_offset[UNIQUE_ID_REC_MAX],
- unique_id_rec_size[UNIQUE_ID_REC_MAX],
- unique_id_rec_total_size,
- unique_id_rec_size_uu;
-
-static void unique_id_global_init(ap_context_t *p, ap_context_t *plog, ap_context_t *ptemp, server_rec *main_server)
-{
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif
- char str[MAXHOSTNAMELEN + 1];
- struct hostent *hent;
-#ifdef HAVE_GETTIMEOFDAY
- struct timeval tv;
-#endif
-
- /*
- * Calculate the sizes and offsets in cur_unique_id.
- */
- unique_id_rec_offset[0] = XtOffsetOf(unique_id_rec, stamp);
- unique_id_rec_size[0] = sizeof(cur_unique_id.stamp);
- unique_id_rec_offset[1] = XtOffsetOf(unique_id_rec, in_addr);
- unique_id_rec_size[1] = sizeof(cur_unique_id.in_addr);
- unique_id_rec_offset[2] = XtOffsetOf(unique_id_rec, pid);
- unique_id_rec_size[2] = sizeof(cur_unique_id.pid);
- unique_id_rec_offset[3] = XtOffsetOf(unique_id_rec, counter);
- unique_id_rec_size[3] = sizeof(cur_unique_id.counter);
- unique_id_rec_offset[4] = XtOffsetOf(unique_id_rec, thread_index);
- unique_id_rec_size[4] = sizeof(cur_unique_id.thread_index);
- unique_id_rec_total_size = unique_id_rec_size[0] + unique_id_rec_size[1] +
- unique_id_rec_size[2] + unique_id_rec_size[3] +
- unique_id_rec_size[4];
-
- /*
- * Calculate the size of the structure when encoded.
- */
- unique_id_rec_size_uu = (unique_id_rec_total_size*8+5)/6;
-
- /*
- * Now get the global in_addr. Note that it is not sufficient to use one
- * of the addresses from the main_server, since those aren't as likely to
- * be unique as the physical address of the machine
- */
- if (gethostname(str, sizeof(str) - 1) != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, errno, main_server,
- "gethostname: mod_unique_id requires the hostname of the server");
- exit(1);
- }
- str[sizeof(str) - 1] = '\0';
-
- if ((hent = gethostbyname(str)) == NULL) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, h_errno, main_server,
- "mod_unique_id: unable to gethostbyname(\"%s\")", str);
- exit(1);
- }
-
- global_in_addr = ((struct in_addr *) hent->h_addr_list[0])->s_addr;
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, main_server,
- "mod_unique_id: using ip addr %s",
- inet_ntoa(*(struct in_addr *) hent->h_addr_list[0]));
-
- /*
- * If the server is pummelled with restart requests we could possibly end
- * up in a situation where we're starting again during the same second
- * that has been used in previous identifiers. Avoid that situation.
- *
- * In truth, for this to actually happen not only would it have to restart
- * in the same second, but it would have to somehow get the same pids as
- * one of the other servers that was running in that second. Which would
- * mean a 64k wraparound on pids ... not very likely at all.
- *
- * But protecting against it is relatively cheap. We just sleep into the
- * next second.
- */
-#ifndef HAVE_GETTIMEOFDAY
- sleep(1);
-#else
- if (gettimeofday(&tv, NULL) == -1) {
- sleep(1);
- }
- else if (tv.tv_usec) {
- tv.tv_sec = 0;
- tv.tv_usec = 1000000 - tv.tv_usec;
- select(0, NULL, NULL, NULL, &tv);
- }
-#endif
-}
-
-static void unique_id_child_init(ap_context_t *p, server_rec *s)
-{
- pid_t pid;
-#ifdef HAVE_GETTIMEOFDAY
- struct timeval tv;
-#endif
-
- /*
- * Note that we use the pid because it's possible that on the same
- * physical machine there are multiple servers (i.e. using Listen). But
- * it's guaranteed that none of them will share the same pids between
- * children.
- *
- * XXX: for multithread this needs to use a pid/tid combo and probably
- * needs to be expanded to 32 bits
- */
- pid = getpid();
- cur_unique_id.pid = pid;
-
- /*
- * Test our assumption that the pid is 32-bits. It's possible that
- * 64-bit machines will declare pid_t to be 64 bits but only use 32
- * of them. It would have been really nice to test this during
- * global_init ... but oh well.
- */
- if (cur_unique_id.pid != pid) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_CRIT, 0, s,
- "oh no! pids are greater than 32-bits! I'm broken!");
- }
-
- cur_unique_id.in_addr = global_in_addr;
-
- /*
- * If we use 0 as the initial counter we have a little less protection
- * against restart problems, and a little less protection against a clock
- * going backwards in time.
- */
-#ifdef HAVE_GETTIMEOFDAY
- if (gettimeofday(&tv, NULL) == -1) {
- cur_unique_id.counter = 0;
- }
- else {
- /* Some systems have very low variance on the low end of their
- * system counter, defend against that.
- */
- cur_unique_id.counter = tv.tv_usec / 10;
- }
-#else
- cur_unique_id.counter = 0;
-#endif
-
- /*
- * We must always use network ordering for these bytes, so that
- * identifiers are comparable between machines of different byte
- * orderings. Note in_addr is already in network order.
- */
- cur_unique_id.pid = htonl(cur_unique_id.pid);
- cur_unique_id.counter = htons(cur_unique_id.counter);
-}
-
-/* NOTE: This is *NOT* the same encoding used by base64encode ... the last two
- * characters should be + and /. But those two characters have very special
- * meanings in URLs, and we want to make it easy to use identifiers in
- * URLs. So we replace them with @ and -.
- */
-static const char uuencoder[64] = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '@', '-',
-};
-
-static int gen_unique_id(request_rec *r)
-{
- char *str;
- /*
- * Buffer padded with two final bytes, used to copy the unique_id_red
- * structure without the internal paddings that it could have.
- */
- unique_id_rec new_unique_id;
- struct {
- unique_id_rec foo;
- unsigned char pad[2];
- } paddedbuf;
- unsigned char *x,*y;
- unsigned short counter;
- const char *e;
- int i,j,k;
-
- /* copy the unique_id if this is an internal redirect (we're never
- * actually called for sub requests, so we don't need to test for
- * them) */
- if (r->prev && (e = ap_table_get(r->subprocess_env, "REDIRECT_UNIQUE_ID"))) {
- ap_table_setn(r->subprocess_env, "UNIQUE_ID", e);
- return DECLINED;
- }
-
- new_unique_id.in_addr = cur_unique_id.in_addr;
- new_unique_id.pid = cur_unique_id.pid;
- new_unique_id.counter = cur_unique_id.counter;
-
- new_unique_id.stamp = htonl((unsigned int)r->request_time);
- new_unique_id.thread_index = htonl((unsigned int)r->connection->id);
-
- /* we'll use a temporal buffer to avoid uuencoding the possible internal
- * paddings of the original structure */
- x = (unsigned char *) &paddedbuf;
- y = (unsigned char *) &new_unique_id;
- k = 0;
- for (i = 0; i < UNIQUE_ID_REC_MAX; i++) {
- y = ((unsigned char *) &new_unique_id) + unique_id_rec_offset[i];
- for (j = 0; j < unique_id_rec_size[i]; j++, k++) {
- x[k] = y[j];
- }
- }
- /*
- * We reset two more bytes just in case padding is needed for the uuencoding.
- */
- x[k++] = '\0';
- x[k++] = '\0';
-
- /* alloc str and do the uuencoding */
- str = (char *)ap_palloc(r->pool, unique_id_rec_size_uu + 1);
- k = 0;
- for (i = 0; i < unique_id_rec_total_size; i += 3) {
- y = x + i;
- str[k++] = uuencoder[y[0] >> 2];
- str[k++] = uuencoder[((y[0] & 0x03) << 4) | ((y[1] & 0xf0) >> 4)];
- if (k == unique_id_rec_size_uu) break;
- str[k++] = uuencoder[((y[1] & 0x0f) << 2) | ((y[2] & 0xc0) >> 6)];
- if (k == unique_id_rec_size_uu) break;
- str[k++] = uuencoder[y[2] & 0x3f];
- }
- str[k++] = '\0';
-
- /* set the environment variable */
- ap_table_setn(r->subprocess_env, "UNIQUE_ID", str);
-
- /* and increment the identifier for the next call */
-
- counter = ntohs(new_unique_id.counter) + 1;
- cur_unique_id.counter = htons(counter);
-
- return DECLINED;
-}
-
-static void register_hooks(void)
-{
- ap_hook_post_config(unique_id_global_init, NULL, NULL, HOOK_MIDDLE);
- ap_hook_child_init(unique_id_child_init, NULL, NULL, HOOK_MIDDLE);
- ap_hook_post_read_request(gen_unique_id, NULL, NULL, HOOK_MIDDLE);
-}
-
-module MODULE_VAR_EXPORT unique_id_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server configs */
- NULL, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/metadata/mod_unique_id.exp b/modules/metadata/mod_unique_id.exp
deleted file mode 100644
index 93000f1ee6..0000000000
--- a/modules/metadata/mod_unique_id.exp
+++ /dev/null
@@ -1 +0,0 @@
-unique_id_module
diff --git a/modules/metadata/mod_usertrack.c b/modules/metadata/mod_usertrack.c
deleted file mode 100644
index fb2c731254..0000000000
--- a/modules/metadata/mod_usertrack.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/* User Tracking Module (Was mod_cookies.c)
- *
- * This Apache module is designed to track users paths through a site.
- * It uses the client-side state ("Cookie") protocol developed by Netscape.
- * It is known to work on Netscape browsers, Microsoft Internet
- * Explorer and others currently being developed.
- *
- * Each time a page is requested we look to see if the browser is sending
- * us a Cookie: header that we previously generated.
- *
- * If we don't find one then the user hasn't been to this site since
- * starting their browser or their browser doesn't support cookies. So
- * we generate a unique Cookie for the transaction and send it back to
- * the browser (via a "Set-Cookie" header)
- * Future requests from the same browser should keep the same Cookie line.
- *
- * By matching up all the requests with the same cookie you can
- * work out exactly what path a user took through your site. To log
- * the cookie use the " %{Cookie}n " directive in a custom access log;
- *
- * Example 1 : If you currently use the standard Log file format (CLF)
- * and use the command "TransferLog somefilename", add the line
- * LogFormat "%h %l %u %t \"%r\" %s %b %{Cookie}n"
- * to your config file.
- *
- * Example 2 : If you used to use the old "CookieLog" directive, you
- * can emulate it by adding the following command to your config file
- * CustomLog filename "%{Cookie}n \"%r\" %t"
- *
- * Notes:
- * 1. This code now logs the initial transaction (the one that created
- * the cookie to start with).
- * 2. This module has been designed to not interfere with other Cookies
- * your site may be using; just avoid sending out cookies with
- * the name "Apache=" or things will get confused.
- * 3. If you want you can modify the Set-Cookie line so that the Cookie
- * never expires. You would then get the same Cookie each time the
- * user revisits your site.
- *
- * Mark Cox, mark@ukweb.com, 6 July 95
- *
- * This file replaces mod_cookies.c
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_request.h"
-
-module MODULE_VAR_EXPORT usertrack_module;
-
-typedef struct {
- int always;
- int expires;
-} cookie_log_state;
-
-typedef struct {
- int enabled;
- char *cookie_name;
-} cookie_dir_rec;
-
-/* Make Cookie: Now we have to generate something that is going to be
- * pretty unique. We can base it on the pid, time, hostip */
-
-#define COOKIE_NAME "Apache"
-
-static void make_cookie(request_rec *r)
-{
- cookie_log_state *cls = ap_get_module_config(r->server->module_config,
- &usertrack_module);
- /* 1024 == hardcoded constant */
- char cookiebuf[1024];
- char *new_cookie;
- const char *rname = ap_get_remote_host(r->connection, r->per_dir_config,
- REMOTE_NAME);
- cookie_dir_rec *dcfg;
-
- dcfg = ap_get_module_config(r->per_dir_config, &usertrack_module);
-
- /* XXX: hmm, this should really tie in with mod_unique_id */
- ap_snprintf(cookiebuf, sizeof(cookiebuf), "%s.%qd", rname, ap_now());
-
- if (cls->expires) {
- ap_exploded_time_t tms;
-
- ap_explode_gmt(&tms, r->request_time + cls->expires * AP_USEC_PER_SEC);
-
- /* Cookie with date; as strftime '%a, %d-%h-%y %H:%M:%S GMT' */
- new_cookie = ap_psprintf(r->pool,
- "%s=%s; path=/; expires=%s, %.2d-%s-%.2d %.2d:%.2d:%.2d GMT",
- dcfg->cookie_name, cookiebuf, ap_day_snames[tms.tm_wday],
- tms.tm_mday, ap_month_snames[tms.tm_mon],
- tms.tm_year % 100,
- tms.tm_hour, tms.tm_min, tms.tm_sec);
- }
- else {
- new_cookie = ap_psprintf(r->pool, "%s=%s; path=/",
- dcfg->cookie_name, cookiebuf);
- }
-
- ap_table_setn(r->headers_out, "Set-Cookie", new_cookie);
- ap_table_setn(r->notes, "cookie", ap_pstrdup(r->pool, cookiebuf)); /* log first time */
- return;
-}
-
-static int spot_cookie(request_rec *r)
-{
- cookie_dir_rec *dcfg = ap_get_module_config(r->per_dir_config,
- &usertrack_module);
- const char *cookie;
- char *value;
-
- if (!dcfg->enabled) {
- return DECLINED;
- }
-
- if ((cookie = ap_table_get(r->headers_in, "Cookie")))
- if ((value = strstr(cookie, dcfg->cookie_name))) {
- char *cookiebuf, *cookieend;
-
- value += strlen(dcfg->cookie_name) + 1; /* Skip over the '=' */
- cookiebuf = ap_pstrdup(r->pool, value);
- cookieend = strchr(cookiebuf, ';');
- if (cookieend)
- *cookieend = '\0'; /* Ignore anything after a ; */
-
- /* Set the cookie in a note, for logging */
- ap_table_setn(r->notes, "cookie", cookiebuf);
-
- return DECLINED; /* There's already a cookie, no new one */
- }
- make_cookie(r);
- return OK; /* We set our cookie */
-}
-
-static void *make_cookie_log_state(ap_context_t *p, server_rec *s)
-{
- cookie_log_state *cls =
- (cookie_log_state *) ap_palloc(p, sizeof(cookie_log_state));
-
- cls->expires = 0;
-
- return (void *) cls;
-}
-
-static void *make_cookie_dir(ap_context_t *p, char *d)
-{
- cookie_dir_rec *dcfg;
-
- dcfg = (cookie_dir_rec *) ap_pcalloc(p, sizeof(cookie_dir_rec));
- dcfg->cookie_name = COOKIE_NAME;
- dcfg->enabled = 0;
- return dcfg;
-}
-
-static const char *set_cookie_enable(cmd_parms *cmd, void *mconfig, int arg)
-{
- cookie_dir_rec *dcfg = mconfig;
-
- dcfg->enabled = arg;
- return NULL;
-}
-
-static const char *set_cookie_exp(cmd_parms *parms, void *dummy, const char *arg)
-{
- cookie_log_state *cls = ap_get_module_config(parms->server->module_config,
- &usertrack_module);
- time_t factor, modifier = 0;
- time_t num = 0;
- char *word;
-
- /* The simple case first - all numbers (we assume) */
- if (ap_isdigit(arg[0]) && ap_isdigit(arg[strlen(arg) - 1])) {
- cls->expires = atol(arg);
- return NULL;
- }
-
- /*
- * The harder case - stolen from mod_expires
- *
- * CookieExpires "[plus] {<num> <type>}*"
- */
-
- word = ap_getword_conf(parms->pool, &arg);
- if (!strncasecmp(word, "plus", 1)) {
- word = ap_getword_conf(parms->pool, &arg);
- };
-
- /* {<num> <type>}* */
- while (word[0]) {
- /* <num> */
- if (ap_isdigit(word[0]))
- num = atoi(word);
- else
- return "bad expires code, numeric value expected.";
-
- /* <type> */
- word = ap_getword_conf(parms->pool, &arg);
- if (!word[0])
- return "bad expires code, missing <type>";
-
- factor = 0;
- if (!strncasecmp(word, "years", 1))
- factor = 60 * 60 * 24 * 365;
- else if (!strncasecmp(word, "months", 2))
- factor = 60 * 60 * 24 * 30;
- else if (!strncasecmp(word, "weeks", 1))
- factor = 60 * 60 * 24 * 7;
- else if (!strncasecmp(word, "days", 1))
- factor = 60 * 60 * 24;
- else if (!strncasecmp(word, "hours", 1))
- factor = 60 * 60;
- else if (!strncasecmp(word, "minutes", 2))
- factor = 60;
- else if (!strncasecmp(word, "seconds", 1))
- factor = 1;
- else
- return "bad expires code, unrecognized type";
-
- modifier = modifier + factor * num;
-
- /* next <num> */
- word = ap_getword_conf(parms->pool, &arg);
- }
-
- cls->expires = modifier;
-
- return NULL;
-}
-
-static const char *set_cookie_name(cmd_parms *cmd, void *mconfig, char *name)
-{
- cookie_dir_rec *dcfg = (cookie_dir_rec *) mconfig;
-
- dcfg->cookie_name = ap_pstrdup(cmd->pool, name);
- return NULL;
-}
-
-static const command_rec cookie_log_cmds[] = {
- {"CookieExpires", set_cookie_exp, NULL, RSRC_CONF, TAKE1,
- "an expiry date code"},
- {"CookieTracking", set_cookie_enable, NULL, OR_FILEINFO, FLAG,
- "whether or not to enable cookies"},
- {"CookieName", set_cookie_name, NULL, OR_FILEINFO, TAKE1,
- "name of the tracking cookie"},
- {NULL}
-};
-static void register_hooks(void)
-{
- ap_hook_fixups(spot_cookie,NULL,NULL,HOOK_MIDDLE);
-}
-module MODULE_VAR_EXPORT usertrack_module = {
- STANDARD20_MODULE_STUFF,
- make_cookie_dir, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- make_cookie_log_state, /* server config */
- NULL, /* merge server configs */
- cookie_log_cmds, /* command ap_table_t */
- NULL, /* handlers */
- register_hooks /* register hooks */
-};
diff --git a/modules/metadata/mod_usertrack.dsp b/modules/metadata/mod_usertrack.dsp
deleted file mode 100644
index 962c73ab68..0000000000
--- a/modules/metadata/mod_usertrack.dsp
+++ /dev/null
@@ -1,113 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheModuleUserTrack" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheModuleUserTrack - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleUserTrack.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleUserTrack.mak"\
- CFG="ApacheModuleUserTrack - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheModuleUserTrack - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheModuleUserTrack - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheModuleUserTrack - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\Release"
-# PROP BASE Intermediate_Dir ".\Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\ApacheModuleUserTrackR"
-# PROP Intermediate_Dir ".\ApacheModuleUserTrackR"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ..\..\CoreR\ApacheCore.lib ..\..\lib\apr\Release\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheModuleUserTrack - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\Debug"
-# PROP BASE Intermediate_Dir ".\Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\ApacheModuleUserTrackD"
-# PROP Intermediate_Dir ".\ApacheModuleUserTrackD"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\include" /I ".\\" /I "..\..\lib\apr\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ..\..\CoreD\ApacheCore.lib ..\..\lib\apr\Debug\aprlib.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheModuleUserTrack - Win32 Release"
-# Name "ApacheModuleUserTrack - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=..\..\modules\standard\mod_usertrack.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\readdir.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/modules/metadata/mod_usertrack.exp b/modules/metadata/mod_usertrack.exp
deleted file mode 100644
index 234a5f759d..0000000000
--- a/modules/metadata/mod_usertrack.exp
+++ /dev/null
@@ -1 +0,0 @@
-usertrack_module
diff --git a/modules/proxy/.cvsignore b/modules/proxy/.cvsignore
deleted file mode 100644
index e0eb7a9f30..0000000000
--- a/modules/proxy/.cvsignore
+++ /dev/null
@@ -1,12 +0,0 @@
-Debug
-Release
-ApacheModuleProxy.dsw
-ApacheModuleProxy.mdp
-ApacheModuleProxy.ncb
-ApacheModuleProxy.opt
-ApacheModuleProxy.plg
-Makefile
-*.lo
-*.so
-*.dll
-*.def
diff --git a/modules/proxy/.indent.pro b/modules/proxy/.indent.pro
deleted file mode 100644
index 20c2d83371..0000000000
--- a/modules/proxy/.indent.pro
+++ /dev/null
@@ -1,55 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
--Tproxy_server_conf
diff --git a/modules/proxy/Makefile.libdir b/modules/proxy/Makefile.libdir
deleted file mode 100644
index 7b5254013a..0000000000
--- a/modules/proxy/Makefile.libdir
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a place-holder which indicates to Configure that it shouldn't
-provide the default targets when building the Makefile in this directory.
-Instead it'll just prepend all the important variable definitions, and
-copy the Makefile.tmpl onto the end.
diff --git a/modules/proxy/libproxy.exp b/modules/proxy/libproxy.exp
deleted file mode 100644
index a20f2378f5..0000000000
--- a/modules/proxy/libproxy.exp
+++ /dev/null
@@ -1 +0,0 @@
-proxy_module
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c
deleted file mode 100644
index ef3a2a6d34..0000000000
--- a/modules/proxy/mod_proxy.c
+++ /dev/null
@@ -1,903 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#include "mod_proxy.h"
-
-#define CORE_PRIVATE
-
-#include "http_log.h"
-#include "http_vhost.h"
-#include "http_request.h"
-
-/* Some WWW schemes and their default ports; this is basically /etc/services */
-/* This will become global when the protocol abstraction comes */
-static struct proxy_services defports[] =
-{
- {"http", DEFAULT_HTTP_PORT},
- {"ftp", DEFAULT_FTP_PORT},
- {"https", DEFAULT_HTTPS_PORT},
- {"gopher", DEFAULT_GOPHER_PORT},
- {"nntp", DEFAULT_NNTP_PORT},
- {"wais", DEFAULT_WAIS_PORT},
- {"snews", DEFAULT_SNEWS_PORT},
- {"prospero", DEFAULT_PROSPERO_PORT},
- {NULL, -1} /* unknown port */
-};
-
-/*
- * A Web proxy module. Stages:
- *
- * translate_name: set filename to proxy:<URL>
- * type_checker: set type to PROXY_MAGIC_TYPE if filename begins proxy:
- * fix_ups: convert the URL stored in the filename to the
- * canonical form.
- * handler: handle proxy requests
- */
-
-/* -------------------------------------------------------------- */
-/* Translate the URL into a 'filename' */
-
-static int alias_match(const char *uri, const char *alias_fakename)
-{
- const char *end_fakename = alias_fakename + strlen(alias_fakename);
- const char *aliasp = alias_fakename, *urip = uri;
-
- while (aliasp < end_fakename) {
- if (*aliasp == '/') {
- /* any number of '/' in the alias matches any number in
- * the supplied URI, but there must be at least one...
- */
- if (*urip != '/')
- return 0;
-
- while (*aliasp == '/')
- ++aliasp;
- while (*urip == '/')
- ++urip;
- }
- else {
- /* Other characters are compared literally */
- if (*urip++ != *aliasp++)
- return 0;
- }
- }
-
- /* Check last alias path component matched all the way */
-
- if (aliasp[-1] != '/' && *urip != '\0' && *urip != '/')
- return 0;
-
- /* Return number of characters from URI which matched (may be
- * greater than length of alias, since we may have matched
- * doubled slashes)
- */
-
- return urip - uri;
-}
-
-/* Detect if an absoluteURI should be proxied or not. Note that we
- * have to do this during this phase because later phases are
- * "short-circuiting"... i.e. translate_names will end when the first
- * module returns OK. So for example, if the request is something like:
- *
- * GET http://othervhost/cgi-bin/printenv HTTP/1.0
- *
- * mod_alias will notice the /cgi-bin part and ScriptAlias it and
- * short-circuit the proxy... just because of the ordering in the
- * configuration file.
- */
-static int proxy_detect(request_rec *r)
-{
- void *sconf = r->server->module_config;
- proxy_server_conf *conf;
-
- conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
-
- if (conf->req && r->parsed_uri.scheme) {
- /* but it might be something vhosted */
- if (!(r->parsed_uri.hostname
- && !strcasecmp(r->parsed_uri.scheme, ap_http_method(r))
- && ap_matches_request_vhost(r, r->parsed_uri.hostname,
- r->parsed_uri.port_str ? r->parsed_uri.port : ap_default_port(r)))) {
- r->proxyreq = 1;
- r->uri = r->unparsed_uri;
- r->filename = ap_pstrcat(r->pool, "proxy:", r->uri, NULL);
- r->handler = "proxy-server";
- }
- }
- /* We need special treatment for CONNECT proxying: it has no scheme part */
- else if (conf->req && r->method_number == M_CONNECT
- && r->parsed_uri.hostname
- && r->parsed_uri.port_str) {
- r->proxyreq = 1;
- r->uri = r->unparsed_uri;
- r->filename = ap_pstrcat(r->pool, "proxy:", r->uri, NULL);
- r->handler = "proxy-server";
- }
- return DECLINED;
-}
-
-static int proxy_trans(request_rec *r)
-{
- void *sconf = r->server->module_config;
- proxy_server_conf *conf =
- (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
- int i, len;
- struct proxy_alias *ent = (struct proxy_alias *) conf->aliases->elts;
-
- if (r->proxyreq) {
- /* someone has already set up the proxy, it was possibly ourselves
- * in proxy_detect
- */
- return OK;
- }
-
- /* XXX: since r->uri has been manipulated already we're not really
- * compliant with RFC1945 at this point. But this probably isn't
- * an issue because this is a hybrid proxy/origin server.
- */
-
- for (i = 0; i < conf->aliases->nelts; i++) {
- len = alias_match(r->uri, ent[i].fake);
-
- if (len > 0) {
- r->filename = ap_pstrcat(r->pool, "proxy:", ent[i].real,
- r->uri + len, NULL);
- r->handler = "proxy-server";
- r->proxyreq = 1;
- return OK;
- }
- }
- return DECLINED;
-}
-
-/* -------------------------------------------------------------- */
-/* Fixup the filename */
-
-/*
- * Canonicalise the URL
- */
-static int proxy_fixup(request_rec *r)
-{
- char *url, *p;
-
- if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0)
- return DECLINED;
-
- url = &r->filename[6];
-
-/* canonicalise each specific scheme */
- if (strncasecmp(url, "http:", 5) == 0)
- return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
- else if (strncasecmp(url, "ftp:", 4) == 0)
- return ap_proxy_ftp_canon(r, url + 4);
-
- p = strchr(url, ':');
- if (p == NULL || p == url)
- return HTTP_BAD_REQUEST;
-
- return OK; /* otherwise; we've done the best we can */
-}
-
-static void proxy_init(server_rec *r, ap_context_t *p)
-{
- ap_proxy_garbage_init(r, p);
-}
-
-
-
-/* Send a redirection if the request contains a hostname which is not */
-/* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
-/* servers like Netscape's allow this and access hosts from the local */
-/* domain in this case. I think it is better to redirect to a FQDN, since */
-/* these will later be found in the bookmarks files. */
-/* The "ProxyDomain" directive determines what domain will be appended */
-static int proxy_needsdomain(request_rec *r, const char *url, const char *domain)
-{
- char *nuri;
- const char *ref;
-
- /* We only want to worry about GETs */
- if (!r->proxyreq || r->method_number != M_GET || !r->parsed_uri.hostname)
- return DECLINED;
-
- /* If host does contain a dot already, or it is "localhost", decline */
- if (strchr(r->parsed_uri.hostname, '.') != NULL
- || strcasecmp(r->parsed_uri.hostname, "localhost") == 0)
- return DECLINED; /* host name has a dot already */
-
- ref = ap_table_get(r->headers_in, "Referer");
-
- /* Reassemble the request, but insert the domain after the host name */
- /* Note that the domain name always starts with a dot */
- r->parsed_uri.hostname = ap_pstrcat(r->pool, r->parsed_uri.hostname,
- domain, NULL);
- nuri = ap_unparse_uri_components(r->pool,
- &r->parsed_uri,
- UNP_REVEALPASSWORD);
-
- ap_table_set(r->headers_out, "Location", nuri);
- ap_log_rerror(APLOG_MARK, APLOG_INFO|APLOG_NOERRNO, r,
- "Domain missing: %s sent to %s%s%s", r->uri,
- ap_unparse_uri_components(r->pool, &r->parsed_uri,
- UNP_OMITUSERINFO),
- ref ? " from " : "", ref ? ref : "");
-
- return HTTP_MOVED_PERMANENTLY;
-}
-
-/* -------------------------------------------------------------- */
-/* Invoke handler */
-
-static int proxy_handler(request_rec *r)
-{
- char *url, *scheme, *p;
- void *sconf = r->server->module_config;
- proxy_server_conf *conf =
- (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
- ap_array_header_t *proxies = conf->proxies;
- struct proxy_remote *ents = (struct proxy_remote *) proxies->elts;
- int i, rc;
- cache_req *cr;
- int direct_connect = 0;
- const char *maxfwd_str;
-
- if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0)
- return DECLINED;
-
- if (r->method_number == M_TRACE &&
- (maxfwd_str = ap_table_get(r->headers_in, "Max-Forwards")) != NULL) {
- int maxfwd = strtol(maxfwd_str, NULL, 10);
- if (maxfwd < 1) {
- int access_status;
- r->proxyreq = 0;
- if ((access_status = ap_send_http_trace(r)))
- ap_die(access_status, r);
- else
- ap_finalize_request_protocol(r);
- return OK;
- }
- ap_table_setn(r->headers_in, "Max-Forwards",
- ap_psprintf(r->pool, "%d", (maxfwd > 0) ? maxfwd-1 : 0));
- }
-
- if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
- return rc;
-
- url = r->filename + 6;
- p = strchr(url, ':');
- if (p == NULL)
- return HTTP_BAD_REQUEST;
-
- rc = ap_proxy_cache_check(r, url, &conf->cache, &cr);
- if (rc != DECLINED)
- return rc;
-
- /* If the host doesn't have a domain name, add one and redirect. */
- if (conf->domain != NULL) {
- rc = proxy_needsdomain(r, url, conf->domain);
- if (ap_is_HTTP_REDIRECT(rc))
- return HTTP_MOVED_PERMANENTLY;
- }
-
- *p = '\0';
- scheme = ap_pstrdup(r->pool, url);
- *p = ':';
-
- /* Check URI's destination host against NoProxy hosts */
- /* Bypass ProxyRemote server lookup if configured as NoProxy */
- /* we only know how to handle communication to a proxy via http */
- /*if (strcasecmp(scheme, "http") == 0) */
- {
- int ii;
- struct dirconn_entry *list = (struct dirconn_entry *) conf->dirconn->elts;
-
- for (direct_connect = ii = 0; ii < conf->dirconn->nelts && !direct_connect; ii++) {
- direct_connect = list[ii].matcher(&list[ii], r);
- }
-#if DEBUGGING
- ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r,
- (direct_connect) ? "NoProxy for %s" : "UseProxy for %s",
- r->uri);
-#endif
- }
-
-/* firstly, try a proxy, unless a NoProxy directive is active */
-
- if (!direct_connect)
- for (i = 0; i < proxies->nelts; i++) {
- p = strchr(ents[i].scheme, ':'); /* is it a partial URL? */
- if (strcmp(ents[i].scheme, "*") == 0 ||
- (p == NULL && strcasecmp(scheme, ents[i].scheme) == 0) ||
- (p != NULL &&
- strncasecmp(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) {
- /* CONNECT is a special method that bypasses the normal
- * proxy code.
- */
- if (r->method_number == M_CONNECT)
- rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname,
- ents[i].port);
-/* we only know how to handle communication to a proxy via http */
- else if (strcasecmp(ents[i].protocol, "http") == 0)
- rc = ap_proxy_http_handler(r, cr, url, ents[i].hostname,
- ents[i].port);
- else
- rc = DECLINED;
-
- /* an error or success */
- if (rc != DECLINED && rc != HTTP_BAD_GATEWAY)
- return rc;
- /* we failed to talk to the upstream proxy */
- }
- }
-
-/* otherwise, try it direct */
-/* N.B. what if we're behind a firewall, where we must use a proxy or
- * give up??
- */
- /* handle the scheme */
- if (r->method_number == M_CONNECT)
- return ap_proxy_connect_handler(r, cr, url, NULL, 0);
- if (strcasecmp(scheme, "http") == 0)
- return ap_proxy_http_handler(r, cr, url, NULL, 0);
- if (strcasecmp(scheme, "ftp") == 0)
- return ap_proxy_ftp_handler(r, cr, url);
- else
- return HTTP_FORBIDDEN;
-}
-
-/* -------------------------------------------------------------- */
-/* Setup configurable data */
-
-static void *
- create_proxy_config(ap_context_t *p, server_rec *s)
-{
- proxy_server_conf *ps = ap_pcalloc(p, sizeof(proxy_server_conf));
-
- ps->proxies = ap_make_array(p, 10, sizeof(struct proxy_remote));
- ps->aliases = ap_make_array(p, 10, sizeof(struct proxy_alias));
- ps->raliases = ap_make_array(p, 10, sizeof(struct proxy_alias));
- ps->noproxies = ap_make_array(p, 10, sizeof(struct noproxy_entry));
- ps->dirconn = ap_make_array(p, 10, sizeof(struct dirconn_entry));
- ps->nocaches = ap_make_array(p, 10, sizeof(struct nocache_entry));
- ps->allowed_connect_ports = ap_make_array(p, 10, sizeof(int));
- ps->domain = NULL;
- ps->viaopt = via_off; /* initially backward compatible with 1.3.1 */
- ps->req = 0;
-
- ps->cache.root = NULL;
- ps->cache.space = DEFAULT_CACHE_SPACE;
- ps->cache.maxexpire = DEFAULT_CACHE_MAXEXPIRE;
- ps->cache.defaultexpire = DEFAULT_CACHE_EXPIRE;
- ps->cache.lmfactor = DEFAULT_CACHE_LMFACTOR;
- ps->cache.gcinterval = -1;
- /* at these levels, the cache can have 2^18 directories (256,000) */
- ps->cache.dirlevels = 3;
- ps->cache.dirlength = 1;
- ps->cache.cache_completion = DEFAULT_CACHE_COMPLETION;
-
- return ps;
-}
-
-static const char *
- add_proxy(cmd_parms *cmd, void *dummy, char *f, char *r)
-{
- server_rec *s = cmd->server;
- proxy_server_conf *conf =
- (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
- struct proxy_remote *new;
- char *p, *q;
- int port;
-
- p = strchr(r, ':');
- if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0')
- return "ProxyRemote: Bad syntax for a remote proxy server";
- q = strchr(p + 3, ':');
- if (q != NULL) {
- if (sscanf(q + 1, "%u", &port) != 1 || port > 65535)
- return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)";
- *q = '\0';
- }
- else
- port = -1;
- *p = '\0';
- if (strchr(f, ':') == NULL)
- ap_str_tolower(f); /* lowercase scheme */
- ap_str_tolower(p + 3); /* lowercase hostname */
-
- if (port == -1) {
- int i;
- for (i = 0; defports[i].scheme != NULL; i++)
- if (strcasecmp(defports[i].scheme, r) == 0)
- break;
- port = defports[i].port;
- }
-
- new = ap_push_array(conf->proxies);
- new->scheme = f;
- new->protocol = r;
- new->hostname = p + 3;
- new->port = port;
- return NULL;
-}
-
-static const char *
- add_pass(cmd_parms *cmd, void *dummy, char *f, char *r)
-{
- server_rec *s = cmd->server;
- proxy_server_conf *conf =
- (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
- struct proxy_alias *new;
-
- new = ap_push_array(conf->aliases);
- new->fake = f;
- new->real = r;
- return NULL;
-}
-
-static const char *
- add_pass_reverse(cmd_parms *cmd, void *dummy, char *f, char *r)
-{
- server_rec *s = cmd->server;
- proxy_server_conf *conf;
- struct proxy_alias *new;
-
- conf = (proxy_server_conf *)ap_get_module_config(s->module_config,
- &proxy_module);
- new = ap_push_array(conf->raliases);
- new->fake = f;
- new->real = r;
- return NULL;
-}
-
-static const char *
- set_proxy_exclude(cmd_parms *parms, void *dummy, char *arg)
-{
- server_rec *s = parms->server;
- proxy_server_conf *conf =
- ap_get_module_config(s->module_config, &proxy_module);
- struct noproxy_entry *new;
- struct noproxy_entry *list = (struct noproxy_entry *) conf->noproxies->elts;
- struct hostent hp;
- int found = 0;
- int i;
-
- /* Don't duplicate entries */
- for (i = 0; i < conf->noproxies->nelts; i++) {
- if (strcasecmp(arg, list[i].name) == 0) /* ignore case for host names */
- found = 1;
- }
-
- if (!found) {
- new = ap_push_array(conf->noproxies);
- new->name = arg;
- /* Don't do name lookups on things that aren't dotted */
- if (strchr(arg, '.') != NULL && ap_proxy_host2addr(new->name, &hp) == NULL)
- /*@@@FIXME: This copies only the first of (possibly many) IP addrs */
- memcpy(&new->addr, hp.h_addr, sizeof(struct in_addr));
- else
- new->addr.s_addr = 0;
- }
- return NULL;
-}
-
-/*
- * Set the ports CONNECT can use
- */
-static const char *
- set_allowed_ports(cmd_parms *parms, void *dummy, char *arg)
-{
- server_rec *s = parms->server;
- proxy_server_conf *conf =
- ap_get_module_config(s->module_config, &proxy_module);
- int *New;
-
- if (!ap_isdigit(arg[0]))
- return "AllowCONNECT: port number must be numeric";
-
- New = ap_push_array(conf->allowed_connect_ports);
- *New = atoi(arg);
- return NULL;
-}
-
-/* Similar to set_proxy_exclude(), but defining directly connected hosts,
- * which should never be accessed via the configured ProxyRemote servers
- */
-static const char *
- set_proxy_dirconn(cmd_parms *parms, void *dummy, char *arg)
-{
- server_rec *s = parms->server;
- proxy_server_conf *conf =
- ap_get_module_config(s->module_config, &proxy_module);
- struct dirconn_entry *New;
- struct dirconn_entry *list = (struct dirconn_entry *) conf->dirconn->elts;
- int found = 0;
- int i;
-
- /* Don't duplicate entries */
- for (i = 0; i < conf->dirconn->nelts; i++) {
- if (strcasecmp(arg, list[i].name) == 0)
- found = 1;
- }
-
- if (!found) {
- New = ap_push_array(conf->dirconn);
- New->name = arg;
- New->hostentry = NULL;
-
- if (ap_proxy_is_ipaddr(New, parms->pool)) {
-#if DEBUGGING
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Parsed addr %s", inet_ntoa(New->addr));
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Parsed mask %s", inet_ntoa(New->mask));
-#endif
- }
- else if (ap_proxy_is_domainname(New, parms->pool)) {
- ap_str_tolower(New->name);
-#if DEBUGGING
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Parsed domain %s", New->name);
-#endif
- }
- else if (ap_proxy_is_hostname(New, parms->pool)) {
- ap_str_tolower(New->name);
-#if DEBUGGING
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Parsed host %s", New->name);
-#endif
- }
- else {
- ap_proxy_is_word(New, parms->pool);
-#if DEBUGGING
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Parsed word %s", New->name);
-#endif
- }
- }
- return NULL;
-}
-
-static const char *
- set_proxy_domain(cmd_parms *parms, void *dummy, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
-
- if (arg[0] != '.')
- return "ProxyDomain: domain name must start with a dot.";
-
- psf->domain = arg;
- return NULL;
-}
-
-static const char *
- set_proxy_req(cmd_parms *parms, void *dummy, int flag)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
-
- psf->req = flag;
- return NULL;
-}
-
-
-static const char *
- set_cache_size(cmd_parms *parms, char *struct_ptr, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
- int val;
-
- if (sscanf(arg, "%d", &val) != 1)
- return "CacheSize value must be an integer (kBytes)";
- psf->cache.space = val;
- return NULL;
-}
-
-static const char *
- set_cache_root(cmd_parms *parms, void *dummy, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
-
- psf->cache.root = arg;
-
- return NULL;
-}
-
-static const char *
- set_cache_factor(cmd_parms *parms, void *dummy, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
- double val;
-
- if (sscanf(arg, "%lg", &val) != 1)
- return "CacheLastModifiedFactor value must be a float";
- psf->cache.lmfactor = val;
-
- return NULL;
-}
-
-static const char *
- set_cache_maxex(cmd_parms *parms, void *dummy, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
- double val;
-
- if (sscanf(arg, "%lg", &val) != 1)
- return "CacheMaxExpire value must be a float";
- psf->cache.maxexpire = (int) (val * (double) SEC_ONE_HR);
- return NULL;
-}
-
-static const char *
- set_cache_defex(cmd_parms *parms, void *dummy, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
- double val;
-
- if (sscanf(arg, "%lg", &val) != 1)
- return "CacheDefaultExpire value must be a float";
- psf->cache.defaultexpire = (int) (val * (double) SEC_ONE_HR);
- return NULL;
-}
-
-static const char *
- set_cache_gcint(cmd_parms *parms, void *dummy, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
- double val;
-
- if (sscanf(arg, "%lg", &val) != 1)
- return "CacheGcInterval value must be a float";
- psf->cache.gcinterval = (int) (val * (double) SEC_ONE_HR);
- return NULL;
-}
-
-static const char *
- set_cache_dirlevels(cmd_parms *parms, char *struct_ptr, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
- int val;
-
- val = atoi(arg);
- if (val < 1)
- return "CacheDirLevels value must be an integer greater than 0";
- if (val * psf->cache.dirlength > CACHEFILE_LEN)
- return "CacheDirLevels*CacheDirLength value must not be higher than 20";
- psf->cache.dirlevels = val;
- return NULL;
-}
-
-static const char *
- set_cache_dirlength(cmd_parms *parms, char *struct_ptr, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
- int val;
-
- val = atoi(arg);
- if (val < 1)
- return "CacheDirLength value must be an integer greater than 0";
- if (val * psf->cache.dirlevels > CACHEFILE_LEN)
- return "CacheDirLevels*CacheDirLength value must not be higher than 20";
- psf->cache.dirlength = val;
- return NULL;
-}
-
-static const char *
- set_cache_exclude(cmd_parms *parms, void *dummy, char *arg)
-{
- server_rec *s = parms->server;
- proxy_server_conf *conf =
- ap_get_module_config(s->module_config, &proxy_module);
- struct nocache_entry *new;
- struct nocache_entry *list = (struct nocache_entry *) conf->nocaches->elts;
- struct hostent hp;
- int found = 0;
- int i;
-
- /* Don't duplicate entries */
- for (i = 0; i < conf->nocaches->nelts; i++) {
- if (strcasecmp(arg, list[i].name) == 0) /* ignore case for host names */
- found = 1;
- }
-
- if (!found) {
- new = ap_push_array(conf->nocaches);
- new->name = arg;
- /* Don't do name lookups on things that aren't dotted */
- if (strchr(arg, '.') != NULL && ap_proxy_host2addr(new->name, &hp) == NULL)
- /*@@@FIXME: This copies only the first of (possibly many) IP addrs */
- memcpy(&new->addr, hp.h_addr, sizeof(struct in_addr));
- else
- new->addr.s_addr = 0;
- }
- return NULL;
-}
-
-static const char *
- set_recv_buffer_size(cmd_parms *parms, void *dummy, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
- int s = atoi(arg);
- if (s < 512 && s != 0) {
- return "ProxyReceiveBufferSize must be >= 512 bytes, or 0 for system default.";
- }
-
- psf->recv_buffer_size = s;
- return NULL;
-}
-
-static const char*
- set_cache_completion(cmd_parms *parms, void *dummy, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
- int s = atoi(arg);
- if (s > 100 || s < 0) {
- return "CacheForceCompletion must be <= 100 percent, "
- "or 0 for system default.";
- }
-
- if (s > 0)
- psf->cache.cache_completion = ((float)s / 100);
- return NULL;
-}
-
-static const char*
- set_via_opt(cmd_parms *parms, void *dummy, char *arg)
-{
- proxy_server_conf *psf =
- ap_get_module_config(parms->server->module_config, &proxy_module);
-
- if (strcasecmp(arg, "Off") == 0)
- psf->viaopt = via_off;
- else if (strcasecmp(arg, "On") == 0)
- psf->viaopt = via_on;
- else if (strcasecmp(arg, "Block") == 0)
- psf->viaopt = via_block;
- else if (strcasecmp(arg, "Full") == 0)
- psf->viaopt = via_full;
- else {
- return "ProxyVia must be one of: "
- "off | on | full | block";
- }
-
- return NULL;
-}
-
-static const handler_rec proxy_handlers[] =
-{
- {"proxy-server", proxy_handler},
- {NULL}
-};
-
-static const command_rec proxy_cmds[] =
-{
- {"ProxyRequests", set_proxy_req, NULL, RSRC_CONF, FLAG,
- "on if the true proxy requests should be accepted"},
- {"ProxyRemote", add_proxy, NULL, RSRC_CONF, TAKE2,
- "a scheme, partial URL or '*' and a proxy server"},
- {"ProxyPass", add_pass, NULL, RSRC_CONF, TAKE2,
- "a virtual path and a URL"},
- {"ProxyPassReverse", add_pass_reverse, NULL, RSRC_CONF, TAKE2,
- "a virtual path and a URL for reverse proxy behaviour"},
- {"ProxyBlock", set_proxy_exclude, NULL, RSRC_CONF, ITERATE,
- "A list of names, hosts or domains to which the proxy will not connect"},
- {"ProxyReceiveBufferSize", set_recv_buffer_size, NULL, RSRC_CONF, TAKE1,
- "Receive buffer size for outgoing HTTP and FTP connections in bytes"},
- {"NoProxy", set_proxy_dirconn, NULL, RSRC_CONF, ITERATE,
- "A list of domains, hosts, or subnets to which the proxy will connect directly"},
- {"ProxyDomain", set_proxy_domain, NULL, RSRC_CONF, TAKE1,
- "The default intranet domain name (in absence of a domain in the URL)"},
- {"AllowCONNECT", set_allowed_ports, NULL, RSRC_CONF, ITERATE,
- "A list of ports which CONNECT may connect to"},
- {"CacheRoot", set_cache_root, NULL, RSRC_CONF, TAKE1,
- "The directory to store cache files"},
- {"CacheSize", set_cache_size, NULL, RSRC_CONF, TAKE1,
- "The maximum disk space used by the cache in Kb"},
- {"CacheMaxExpire", set_cache_maxex, NULL, RSRC_CONF, TAKE1,
- "The maximum time in hours to cache a document"},
- {"CacheDefaultExpire", set_cache_defex, NULL, RSRC_CONF, TAKE1,
- "The default time in hours to cache a document"},
- {"CacheLastModifiedFactor", set_cache_factor, NULL, RSRC_CONF, TAKE1,
- "The factor used to estimate Expires date from LastModified date"},
- {"CacheGcInterval", set_cache_gcint, NULL, RSRC_CONF, TAKE1,
- "The interval between garbage collections, in hours"},
- {"CacheDirLevels", set_cache_dirlevels, NULL, RSRC_CONF, TAKE1,
- "The number of levels of subdirectories in the cache"},
- {"CacheDirLength", set_cache_dirlength, NULL, RSRC_CONF, TAKE1,
- "The number of characters in subdirectory names"},
- {"NoCache", set_cache_exclude, NULL, RSRC_CONF, ITERATE,
- "A list of names, hosts or domains for which caching is *not* provided"},
- {"CacheForceCompletion", set_cache_completion, NULL, RSRC_CONF, TAKE1,
- "Force a http cache completion after this percentage is loaded"},
- {"ProxyVia", set_via_opt, NULL, RSRC_CONF, TAKE1,
- "Configure Via: proxy header header to one of: on | off | block | full"},
- {NULL}
-};
-
-module MODULE_VAR_EXPORT proxy_module =
-{
- STANDARD_MODULE_STUFF,
- proxy_init, /* initializer */
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- create_proxy_config, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- proxy_cmds, /* command ap_table_t */
- proxy_handlers, /* handlers */
- proxy_trans, /* translate_handler */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- proxy_fixup, /* pre-run fixups */
- NULL, /* logger */
- NULL, /* header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- proxy_detect /* post read-request */
-};
diff --git a/modules/proxy/mod_proxy.dsp b/modules/proxy/mod_proxy.dsp
deleted file mode 100644
index 6ee5cf30dd..0000000000
--- a/modules/proxy/mod_proxy.dsp
+++ /dev/null
@@ -1,133 +0,0 @@
-# Microsoft Developer Studio Project File - Name="ApacheModuleProxy" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-CFG=ApacheModuleProxy - Win32 Release
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleProxy.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "ApacheModuleProxy.mak"\
- CFG="ApacheModuleProxy - Win32 Release"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ApacheModuleProxy - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "ApacheModuleProxy - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-MTL=midl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ApacheModuleProxy - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir ".\ApacheMo"
-# PROP BASE Intermediate_Dir ".\ApacheMo"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ".\Release"
-# PROP Intermediate_Dir ".\Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /D "WIN32_LEAN_AND_MEAN" /YX /FD /c
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ..\..\CoreR\ApacheCore.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ws2_32.lib /nologo /subsystem:windows /dll /machine:I386
-
-!ELSEIF "$(CFG)" == "ApacheModuleProxy - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir ".\ApacheM0"
-# PROP BASE Intermediate_Dir ".\ApacheM0"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ".\Debug"
-# PROP Intermediate_Dir ".\Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\..\include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /D "WIN32_LEAN_AND_MEAN" /YX /FD /c
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ..\..\CoreD\ApacheCore.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ws2_32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-
-!ENDIF
-
-# Begin Target
-
-# Name "ApacheModuleProxy - Win32 Release"
-# Name "ApacheModuleProxy - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
-# Begin Source File
-
-SOURCE=.\mod_proxy.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\proxy_cache.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\proxy_connect.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\proxy_ftp.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\proxy_http.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\proxy_util.c
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
-# Begin Source File
-
-SOURCE=.\mod_proxy.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h
deleted file mode 100644
index e7064e379f..0000000000
--- a/modules/proxy/mod_proxy.h
+++ /dev/null
@@ -1,316 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef MOD_PROXY_H
-#define MOD_PROXY_H
-
-/*
- * Main include file for the Apache proxy
- */
-
-/*
-
- Note that the Explain() stuff is not yet complete.
- Also note numerous FIXMEs and CHECKMEs which should be eliminated.
-
- If TESTING is set, then garbage collection doesn't delete ... probably a good
- idea when hacking.
-
- This code is still experimental!
-
- Things to do:
-
- 1. Make it garbage collect in the background, not while someone is waiting for
- a response!
-
- 2. Check the logic thoroughly.
-
- 3. Empty directories are only removed the next time round (but this does avoid
- two passes). Consider doing them the first time round.
-
- Ben Laurie <ben@algroup.co.uk> 30 Mar 96
-
- More things to do:
-
- 0. Code cleanup (ongoing)
-
- 1. add 230 response output for ftp now that it works
-
- 2. Make the ftp proxy transparent, also same with (future) gopher & wais
-
- 3. Use protocol handler struct a la Apache module handlers (Dirk van Gulik)
-
- 4. Use a cache expiry database for more efficient GC (Jeremy Wohl)
-
- 5. Bulletproof GC against SIGALRM
-
- Chuck Murcko <chuck@topsail.org> 15 April 1997
-
- */
-
-#define TESTING 0
-#undef EXPLAIN
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_protocol.h"
-
-#include "explain.h"
-
-extern module MODULE_VAR_EXPORT proxy_module;
-
-
-/* for proxy_canonenc() */
-enum enctype {
- enc_path, enc_search, enc_user, enc_fpath, enc_parm
-};
-
-#define HDR_APP (0) /* append header, for proxy_add_header() */
-#define HDR_REP (1) /* replace header, for proxy_add_header() */
-
-/* number of characters in the hash */
-#define HASH_LEN (22*2)
-
-/* maximum 'CacheDirLevels*CacheDirLength' value */
-#define CACHEFILE_LEN 20 /* must be less than HASH_LEN/2 */
-
-#ifdef CHARSET_EBCDIC
-#define CRLF "\r\n"
-#else /*CHARSET_EBCDIC*/
-#define CRLF "\015\012"
-#endif /*CHARSET_EBCDIC*/
-
-
-#define SEC_ONE_DAY 86400 /* one day, in seconds */
-#define SEC_ONE_HR 3600 /* one hour, in seconds */
-
-#define DEFAULT_FTP_DATA_PORT 20
-#define DEFAULT_FTP_PORT 21
-#define DEFAULT_GOPHER_PORT 70
-#define DEFAULT_NNTP_PORT 119
-#define DEFAULT_WAIS_PORT 210
-#define DEFAULT_HTTPS_PORT 443
-#define DEFAULT_SNEWS_PORT 563
-#define DEFAULT_PROSPERO_PORT 1525 /* WARNING: conflict w/Oracle */
-
-/* Some WWW schemes and their default ports; this is basically /etc/services */
-struct proxy_services {
- const char *scheme;
- int port;
-};
-
-/* static information about a remote proxy */
-struct proxy_remote {
- const char *scheme; /* the schemes handled by this proxy, or '*' */
- const char *protocol; /* the scheme used to talk to this proxy */
- const char *hostname; /* the hostname of this proxy */
- int port; /* the port for this proxy */
-};
-
-struct proxy_alias {
- char *real;
- char *fake;
-};
-
-struct dirconn_entry {
- char *name;
- struct in_addr addr, mask;
- struct hostent *hostentry;
- int (*matcher) (struct dirconn_entry * This, request_rec *r);
-};
-
-struct noproxy_entry {
- char *name;
- struct in_addr addr;
-};
-
-struct nocache_entry {
- char *name;
- struct in_addr addr;
-};
-
-#define DEFAULT_CACHE_SPACE 5
-#define DEFAULT_CACHE_MAXEXPIRE SEC_ONE_DAY
-#define DEFAULT_CACHE_EXPIRE SEC_ONE_HR
-#define DEFAULT_CACHE_LMFACTOR (0.1)
-#define DEFAULT_CACHE_COMPLETION (0.9)
-
-/* static information about the local cache */
-struct cache_conf {
- const char *root; /* the location of the cache directory */
- off_t space; /* Maximum cache size (in 1024 bytes) */
- time_t maxexpire; /* Maximum time to keep cached files in secs */
- time_t defaultexpire; /* default time to keep cached file in secs */
- double lmfactor; /* factor for estimating expires date */
- time_t gcinterval; /* garbage collection interval, in seconds */
- int dirlevels; /* Number of levels of subdirectories */
- int dirlength; /* Length of subdirectory names */
- float cache_completion; /* Force cache completion after this point */
-};
-
-typedef struct {
- struct cache_conf cache; /* cache configuration */
- ap_array_header_t *proxies;
- ap_array_header_t *aliases;
- ap_array_header_t *raliases;
- ap_array_header_t *noproxies;
- ap_array_header_t *dirconn;
- ap_array_header_t *nocaches;
- ap_array_header_t *allowed_connect_ports;
- char *domain; /* domain name to use in absence of a domain name in the request */
- int req; /* true if proxy requests are enabled */
- enum {
- via_off,
- via_on,
- via_block,
- via_full
- } viaopt; /* how to deal with proxy Via: headers */
- size_t recv_buffer_size;
-} proxy_server_conf;
-
-struct hdr_entry {
- const char *field;
- const char *value;
-};
-
-/* caching information about a request */
-typedef struct {
- request_rec *req; /* the request */
- char *url; /* the URL requested */
- char *filename; /* name of the cache file, or NULL if no cache */
- char *tempfile; /* name of the temporary file, of NULL if not caching */
- time_t ims; /* if-modified-since date of request; -1 if no header */
- BUFF *fp; /* the cache file descriptor if the file is cached
- and may be returned, or NULL if the file is
- not cached (or must be reloaded) */
- time_t expire; /* calculated expire date of cached entity */
- time_t lmod; /* last-modified date of cached entity */
- time_t date; /* the date the cached file was last touched */
- int version; /* update count of the file */
- off_t len; /* content length */
- char *protocol; /* Protocol, and major/minor number, e.g. HTTP/1.1 */
- int status; /* the status of the cached file */
- unsigned int written; /* total *content* bytes written to cache */
- float cache_completion; /* specific to this request */
- char *resp_line; /* the whole status like (protocol, code + message) */
- ap_table_t *hdrs; /* the HTTP headers of the file */
-} cache_req;
-
-/* Additional information passed to the function called by ap_table_do() */
-struct tbl_do_args {
- request_rec *req;
- cache_req *cache;
-};
-
-/* Function prototypes */
-
-/* proxy_cache.c */
-
-void ap_proxy_cache_tidy(cache_req *c);
-int ap_proxy_cache_check(request_rec *r, char *url, struct cache_conf *conf,
- cache_req **cr);
-int ap_proxy_cache_update(cache_req *c, ap_table_t *resp_hdrs,
- const int is_HTTP1, int nocache);
-void ap_proxy_garbage_coll(request_rec *r);
-
-/* proxy_connect.c */
-
-int ap_proxy_connect_handler(request_rec *r, cache_req *c, char *url,
- const char *proxyhost, int proxyport);
-
-/* proxy_ftp.c */
-
-int ap_proxy_ftp_canon(request_rec *r, char *url);
-int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url);
-
-/* proxy_http.c */
-
-int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme,
- int def_port);
-int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url,
- const char *proxyhost, int proxyport);
-
-/* proxy_util.c */
-
-int ap_proxy_hex2c(const char *x);
-void ap_proxy_c2hex(int ch, char *x);
-char *ap_proxy_canonenc(ap_context_t *p, const char *x, int len, enum enctype t,
- int isenc);
-char *ap_proxy_canon_netloc(ap_context_t *p, char **const urlp, char **userp,
- char **passwordp, char **hostp, int *port);
-const char *ap_proxy_date_canon(ap_context_t *p, const char *x);
-table *ap_proxy_read_headers(request_rec *r, char *buffer, int size, BUFF *f);
-long int ap_proxy_send_fb(BUFF *f, request_rec *r, cache_req *c);
-void ap_proxy_send_headers(request_rec *r, const char *respline, ap_table_t *hdrs);
-int ap_proxy_liststr(const char *list, const char *val);
-void ap_proxy_hash(const char *it, char *val, int ndepth, int nlength);
-int ap_proxy_hex2sec(const char *x);
-void ap_proxy_sec2hex(int t, char *y);
-cache_req *ap_proxy_cache_error(cache_req *r);
-int ap_proxyerror(request_rec *r, int statuscode, const char *message);
-const char *ap_proxy_host2addr(const char *host, struct hostent *reqhp);
-int ap_proxy_is_ipaddr(struct dirconn_entry *This, ap_context_t *p);
-int ap_proxy_is_domainname(struct dirconn_entry *This, ap_context_t *p);
-int ap_proxy_is_hostname(struct dirconn_entry *This, ap_context_t *p);
-int ap_proxy_is_word(struct dirconn_entry *This, ap_context_t *p);
-int ap_proxy_doconnect(int sock, struct sockaddr_in *addr, request_rec *r);
-int ap_proxy_garbage_init(server_rec *, ap_context_t *);
-/* This function is called by ap_table_do() for all header lines */
-int ap_proxy_send_hdr_line(void *p, const char *key, const char *value);
-unsigned ap_proxy_bputs2(const char *data, BUFF *client, cache_req *cache);
-
-#endif /*MOD_PROXY_H*/
diff --git a/modules/proxy/proxy_connect.c b/modules/proxy/proxy_connect.c
deleted file mode 100644
index 82203f2c9e..0000000000
--- a/modules/proxy/proxy_connect.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/* CONNECT method for Apache proxy */
-
-#include "mod_proxy.h"
-#include "http_log.h"
-#include "http_main.h"
-
-#ifdef HAVE_BSTRING_H
-#include <bstring.h> /* for IRIX, FD_SET calls bzero() */
-#endif
-
-DEF_Explain
-
-/*
- * This handles Netscape CONNECT method secure proxy requests.
- * A connection is opened to the specified host and data is
- * passed through between the WWW site and the browser.
- *
- * This code is based on the INTERNET-DRAFT document
- * "Tunneling SSL Through a WWW Proxy" currently at
- * http://www.mcom.com/newsref/std/tunneling_ssl.html.
- *
- * If proxyhost and proxyport are set, we send a CONNECT to
- * the specified proxy..
- *
- * FIXME: this is bad, because it does its own socket I/O
- * instead of using the I/O in buff.c. However,
- * the I/O in buff.c blocks on reads, and because
- * this function doesn't know how much data will
- * be sent either way (or when) it can't use blocking
- * I/O. This may be very implementation-specific
- * (to Linux). Any suggestions?
- * FIXME: this doesn't log the number of bytes sent, but
- * that may be okay, since the data is supposed to
- * be transparent. In fact, this doesn't log at all
- * yet. 8^)
- * FIXME: doesn't check any headers initally sent from the
- * client.
- * FIXME: should allow authentication, but hopefully the
- * generic proxy authentication is good enough.
- * FIXME: no check for r->assbackwards, whatever that is.
- */
-
-static int
-allowed_port(proxy_server_conf *conf, int port)
-{
- int i;
- int *list = (int *) conf->allowed_connect_ports->elts;
-
- for(i = 0; i < conf->allowed_connect_ports->nelts; i++) {
- if(port == list[i])
- return 1;
- }
- return 0;
-}
-
-
-int ap_proxy_connect_handler(request_rec *r, cache_req *c, char *url,
- const char *proxyhost, int proxyport)
-{
- struct sockaddr_in server;
- struct in_addr destaddr;
- struct hostent server_hp;
- const char *host, *err;
- char *p;
- int port, sock;
- char buffer[HUGE_STRING_LEN];
- int nbytes, i, j;
- fd_set fds;
-
- void *sconf = r->server->module_config;
- proxy_server_conf *conf =
- (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
- struct noproxy_entry *npent = (struct noproxy_entry *) conf->noproxies->elts;
-
- memset(&server, '\0', sizeof(server));
- server.sin_family = AF_INET;
-
- /* Break the URL into host:port pairs */
-
- host = url;
- p = strchr(url, ':');
- if (p == NULL)
- port = DEFAULT_HTTPS_PORT;
- else {
- port = atoi(p + 1);
- *p = '\0';
- }
-
-/* check if ProxyBlock directive on this host */
- destaddr.s_addr = ap_inet_addr(host);
- for (i = 0; i < conf->noproxies->nelts; i++) {
- if ((npent[i].name != NULL && strstr(host, npent[i].name) != NULL)
- || destaddr.s_addr == npent[i].addr.s_addr || npent[i].name[0] == '*')
- return ap_proxyerror(r, HTTP_FORBIDDEN,
- "Connect to remote machine blocked");
- }
-
- /* Check if it is an allowed port */
- if (conf->allowed_connect_ports->nelts == 0) {
- /* Default setting if not overridden by AllowCONNECT */
- switch (port) {
- case DEFAULT_HTTPS_PORT:
- case DEFAULT_SNEWS_PORT:
- break;
- default:
- return HTTP_FORBIDDEN;
- }
- } else if(!allowed_port(conf, port))
- return HTTP_FORBIDDEN;
-
- if (proxyhost) {
- Explain2("CONNECT to remote proxy %s on port %d", proxyhost, proxyport);
- }
- else {
- Explain2("CONNECT to %s on port %d", host, port);
- }
-
- server.sin_port = (proxyport ? htons(proxyport) : htons(port));
- err = ap_proxy_host2addr(proxyhost ? proxyhost : host, &server_hp);
-
- if (err != NULL)
- return ap_proxyerror(r,
- proxyhost ? HTTP_BAD_GATEWAY : HTTP_INTERNAL_SERVER_ERROR,
- err);
-
- sock = ap_psocket(r->pool, PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (sock == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "proxy: error creating socket");
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
-#ifdef CHECK_FD_SETSIZE
- if (sock >= FD_SETSIZE) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL,
- "proxy_connect_handler: filedescriptor (%u) "
- "larger than FD_SETSIZE (%u) "
- "found, you probably need to rebuild Apache with a "
- "larger FD_SETSIZE", sock, FD_SETSIZE);
- ap_pclosesocket(r->pool, sock);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-#endif
-
- j = 0;
- while (server_hp.h_addr_list[j] != NULL) {
- memcpy(&server.sin_addr, server_hp.h_addr_list[j],
- sizeof(struct in_addr));
- i = ap_proxy_doconnect(sock, &server, r);
- if (i == 0)
- break;
- j++;
- }
- if (i == -1) {
- ap_pclosesocket(r->pool, sock);
- return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, ap_pstrcat(r->pool,
- "Could not connect to remote machine:<br>",
- strerror(errno), NULL));
- }
-
- /* If we are connecting through a remote proxy, we need to pass
- * the CONNECT request on to it.
- */
- if (proxyport) {
- /* FIXME: We should not be calling write() directly, but we currently
- * have no alternative. Error checking ignored. Also, we force
- * a HTTP/1.0 request to keep things simple.
- */
- Explain0("Sending the CONNECT request to the remote proxy");
- ap_snprintf(buffer, sizeof(buffer), "CONNECT %s HTTP/1.0" CRLF,
- r->uri);
- write(sock, buffer, strlen(buffer));
- ap_snprintf(buffer, sizeof(buffer),
- "Proxy-agent: %s" CRLF CRLF, ap_get_server_version());
- write(sock, buffer, strlen(buffer));
- }
- else {
- Explain0("Returning 200 OK Status");
- ap_rvputs(r, "HTTP/1.0 200 Connection established" CRLF, NULL);
- ap_rvputs(r, "Proxy-agent: ", ap_get_server_version(), CRLF CRLF, NULL);
- ap_bflush(r->connection->client);
- }
-
- while (1) { /* Infinite loop until error (one side closes the connection) */
- FD_ZERO(&fds);
- FD_SET(sock, &fds);
- FD_SET(r->connection->client->fd, &fds);
-
- Explain0("Going to sleep (select)");
- i = ap_select((r->connection->client->fd > sock ?
- r->connection->client->fd + 1 :
- sock + 1), &fds, NULL, NULL, NULL);
- Explain1("Woke from select(), i=%d", i);
-
- if (i) {
- if (FD_ISSET(sock, &fds)) {
- Explain0("sock was set");
- if ((nbytes = read(sock, buffer, HUGE_STRING_LEN)) != 0) {
- if (nbytes == -1)
- break;
- if (write(r->connection->client->fd, buffer, nbytes) == EOF)
- break;
- Explain1("Wrote %d bytes to client", nbytes);
- }
- else
- break;
- }
- else if (FD_ISSET(r->connection->client->fd, &fds)) {
- Explain0("client->fd was set");
- if ((nbytes = read(r->connection->client->fd, buffer,
- HUGE_STRING_LEN)) != 0) {
- if (nbytes == -1)
- break;
- if (write(sock, buffer, nbytes) == EOF)
- break;
- Explain1("Wrote %d bytes to server", nbytes);
- }
- else
- break;
- }
- else
- break; /* Must be done waiting */
- }
- else
- break;
- }
-
- ap_pclosesocket(r->pool, sock);
-
- return OK;
-}
diff --git a/modules/proxy/proxy_ftp.c b/modules/proxy/proxy_ftp.c
deleted file mode 100644
index ae9030dd19..0000000000
--- a/modules/proxy/proxy_ftp.c
+++ /dev/null
@@ -1,1242 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/* FTP routines for Apache proxy */
-
-#include "mod_proxy.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "http_core.h"
-
-#define AUTODETECT_PWD
-
-DEF_Explain
-
-/*
- * Decodes a '%' escaped string, and returns the number of characters
- */
-static int decodeenc(char *x)
-{
- int i, j, ch;
-
- if (x[0] == '\0')
- return 0; /* special case for no characters */
- for (i = 0, j = 0; x[i] != '\0'; i++, j++) {
-/* decode it if not already done */
- ch = x[i];
- if (ch == '%' && ap_isxdigit(x[i + 1]) && ap_isxdigit(x[i + 2])) {
- ch = ap_proxy_hex2c(&x[i + 1]);
- i += 2;
- }
- x[j] = ch;
- }
- x[j] = '\0';
- return j;
-}
-
-/*
- * checks an encoded ftp string for bad characters, namely, CR, LF or
- * non-ascii character
- */
-static int ftp_check_string(const char *x)
-{
- int i, ch;
-
- for (i = 0; x[i] != '\0'; i++) {
- ch = x[i];
- if (ch == '%' && ap_isxdigit(x[i + 1]) && ap_isxdigit(x[i + 2])) {
- ch = ap_proxy_hex2c(&x[i + 1]);
- i += 2;
- }
-#ifndef CHARSET_EBCDIC
- if (ch == '\015' || ch == '\012' || (ch & 0x80))
-#else /*CHARSET_EBCDIC*/
- if (ch == '\r' || ch == '\n' || (os_toascii[ch] & 0x80))
-#endif /*CHARSET_EBCDIC*/
- return 0;
- }
- return 1;
-}
-
-/*
- * Canonicalise ftp URLs.
- */
-int ap_proxy_ftp_canon(request_rec *r, char *url)
-{
- char *user, *password, *host, *path, *parms, *strp, sport[7];
- ap_context_t *p = r->pool;
- const char *err;
- int port;
-
- port = DEFAULT_FTP_PORT;
- err = ap_proxy_canon_netloc(p, &url, &user, &password, &host, &port);
- if (err)
- return HTTP_BAD_REQUEST;
- if (user != NULL && !ftp_check_string(user))
- return HTTP_BAD_REQUEST;
- if (password != NULL && !ftp_check_string(password))
- return HTTP_BAD_REQUEST;
-
-/* now parse path/parameters args, according to rfc1738 */
-/* N.B. if this isn't a true proxy request, then the URL path
- * (but not query args) has already been decoded.
- * This gives rise to the problem of a ; being decoded into the
- * path.
- */
- strp = strchr(url, ';');
- if (strp != NULL) {
- *(strp++) = '\0';
- parms = ap_proxy_canonenc(p, strp, strlen(strp), enc_parm, r->proxyreq);
- if (parms == NULL)
- return HTTP_BAD_REQUEST;
- }
- else
- parms = "";
-
- path = ap_proxy_canonenc(p, url, strlen(url), enc_path, r->proxyreq);
- if (path == NULL)
- return HTTP_BAD_REQUEST;
- if (!ftp_check_string(path))
- return HTTP_BAD_REQUEST;
-
- if (!r->proxyreq && r->args != NULL) {
- if (strp != NULL) {
- strp = ap_proxy_canonenc(p, r->args, strlen(r->args), enc_parm, 1);
- if (strp == NULL)
- return HTTP_BAD_REQUEST;
- parms = ap_pstrcat(p, parms, "?", strp, NULL);
- }
- else {
- strp = ap_proxy_canonenc(p, r->args, strlen(r->args), enc_fpath, 1);
- if (strp == NULL)
- return HTTP_BAD_REQUEST;
- path = ap_pstrcat(p, path, "?", strp, NULL);
- }
- r->args = NULL;
- }
-
-/* now, rebuild URL */
-
- if (port != DEFAULT_FTP_PORT)
- ap_snprintf(sport, sizeof(sport), ":%d", port);
- else
- sport[0] = '\0';
-
- r->filename = ap_pstrcat(p, "proxy:ftp://", (user != NULL) ? user : "",
- (password != NULL) ? ":" : "",
- (password != NULL) ? password : "",
- (user != NULL) ? "@" : "", host, sport, "/", path,
- (parms[0] != '\0') ? ";" : "", parms, NULL);
-
- return OK;
-}
-
-/*
- * Returns the ftp status code;
- * or -1 on I/O error, 0 on data error
- */
-static int ftp_getrc(BUFF *f)
-{
- int len, status;
- char linebuff[100], buff[5];
-
- len = ap_bgets(linebuff, sizeof linebuff, f);
- if (len == -1)
- return -1;
-/* check format */
- if (len < 5 || !ap_isdigit(linebuff[0]) || !ap_isdigit(linebuff[1]) ||
- !ap_isdigit(linebuff[2]) || (linebuff[3] != ' ' && linebuff[3] != '-'))
- status = 0;
- else
- status = 100 * linebuff[0] + 10 * linebuff[1] + linebuff[2] - 111 * '0';
-
- if (linebuff[len - 1] != '\n') {
- (void)ap_bskiplf(f);
- }
-
-/* skip continuation lines */
- if (linebuff[3] == '-') {
- memcpy(buff, linebuff, 3);
- buff[3] = ' ';
- do {
- len = ap_bgets(linebuff, sizeof linebuff, f);
- if (len == -1)
- return -1;
- if (linebuff[len - 1] != '\n') {
- (void)ap_bskiplf(f);
- }
- } while (memcmp(linebuff, buff, 4) != 0);
- }
-
- return status;
-}
-
-/*
- * Like ftp_getrc but returns both the ftp status code and
- * remembers the response message in the supplied buffer
- */
-static int ftp_getrc_msg(BUFF *f, char *msgbuf, int msglen)
-{
- int len, status;
- char linebuff[100], buff[5];
- char *mb = msgbuf,
- *me = &msgbuf[msglen];
-
- len = ap_bgets(linebuff, sizeof linebuff, f);
- if (len == -1)
- return -1;
- if (len < 5 || !ap_isdigit(linebuff[0]) || !ap_isdigit(linebuff[1]) ||
- !ap_isdigit(linebuff[2]) || (linebuff[3] != ' ' && linebuff[3] != '-'))
- status = 0;
- else
- status = 100 * linebuff[0] + 10 * linebuff[1] + linebuff[2] - 111 * '0';
-
- mb = ap_cpystrn(mb, linebuff+4, me - mb);
-
- if (linebuff[len - 1] != '\n')
- (void)ap_bskiplf(f);
-
- if (linebuff[3] == '-') {
- memcpy(buff, linebuff, 3);
- buff[3] = ' ';
- do {
- len = ap_bgets(linebuff, sizeof linebuff, f);
- if (len == -1)
- return -1;
- if (linebuff[len - 1] != '\n') {
- (void)ap_bskiplf(f);
- }
- mb = ap_cpystrn(mb, linebuff+4, me - mb);
- } while (memcmp(linebuff, buff, 4) != 0);
- }
- return status;
-}
-
-static long int send_dir(BUFF *f, request_rec *r, cache_req *c, char *cwd)
-{
- char buf[IOBUFSIZE];
- char buf2[IOBUFSIZE];
- char *filename;
- int searchidx = 0;
- char *searchptr = NULL;
- int firstfile = 1;
- unsigned long total_bytes_sent = 0;
- register int n, o, w;
- conn_rec *con = r->connection;
- char *dir, *path, *reldir, *site;
-
- /* Save "scheme://site" prefix without password */
- site = ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD|UNP_OMITPATHINFO);
- /* ... and path without query args */
- path = ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITSITEPART|UNP_OMITQUERY);
- (void)decodeenc(path);
-
- /* Copy path, strip (all except the last) trailing slashes */
- path = dir = ap_pstrcat(r->pool, path, "/", NULL);
- while ((n = strlen(path)) > 1 && path[n-1] == '/' && path[n-2] == '/')
- path[n-1] = '\0';
-
- /* print "ftp://host/" */
- n = ap_snprintf(buf, sizeof(buf), DOCTYPE_HTML_3_2
- "<HTML><HEAD><TITLE>%s%s</TITLE>\n"
- "<BASE HREF=\"%s%s\"></HEAD>\n"
- "<BODY><H2>Directory of "
- "<A HREF=\"/\">%s</A>/",
- site, path, site, path, site);
- total_bytes_sent += ap_proxy_bputs2(buf, con->client, c);
-
- while ((dir = strchr(dir+1, '/')) != NULL)
- {
- *dir = '\0';
- if ((reldir = strrchr(path+1, '/'))==NULL)
- reldir = path+1;
- else
- ++reldir;
- /* print "path/" component */
- ap_snprintf(buf, sizeof(buf), "<A HREF=\"/%s/\">%s</A>/", path+1, reldir);
- total_bytes_sent += ap_proxy_bputs2(buf, con->client, c);
- *dir = '/';
- }
- /* If the caller has determined the current directory, and it differs */
- /* from what the client requested, then show the real name */
- if (cwd == NULL || strncmp (cwd, path, strlen(cwd)) == 0) {
- ap_snprintf(buf, sizeof(buf), "</H2>\n<HR><PRE>");
- } else {
- ap_snprintf(buf, sizeof(buf), "</H2>\n(%s)\n<HR><PRE>", cwd);
- }
- total_bytes_sent += ap_proxy_bputs2(buf, con->client, c);
-
- while (!con->aborted) {
- n = ap_bgets(buf, sizeof buf, f);
- if (n == -1) { /* input error */
- if (c != NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
- "proxy: error reading from %s", c->url);
- c = ap_proxy_cache_error(c);
- }
- break;
- }
- if (n == 0)
- break; /* EOF */
- if (buf[0] == 'l' && (filename=strstr(buf, " -> ")) != NULL) {
- char *link_ptr = filename;
-
- do {
- filename--;
- } while (filename[0] != ' ');
- *(filename++) = '\0';
- *(link_ptr++) = '\0';
- if ((n = strlen(link_ptr)) > 1 && link_ptr[n - 1] == '\n')
- link_ptr[n - 1] = '\0';
- ap_snprintf(buf2, sizeof(buf2), "%s <A HREF=\"%s\">%s %s</A>\n", buf, filename, filename, link_ptr);
- ap_cpystrn(buf, buf2, sizeof(buf));
- n = strlen(buf);
- }
- else if (buf[0] == 'd' || buf[0] == '-' || buf[0] == 'l' || ap_isdigit(buf[0])) {
- if (ap_isdigit(buf[0])) { /* handle DOS dir */
- searchptr = strchr(buf, '<');
- if (searchptr != NULL)
- *searchptr = '[';
- searchptr = strchr(buf, '>');
- if (searchptr != NULL)
- *searchptr = ']';
- }
-
- filename = strrchr(buf, ' ');
- *(filename++) = 0;
- filename[strlen(filename) - 1] = 0;
-
- /* handle filenames with spaces in 'em */
- if (!strcmp(filename, ".") || !strcmp(filename, "..") || firstfile) {
- firstfile = 0;
- searchidx = filename - buf;
- }
- else if (searchidx != 0 && buf[searchidx] != 0) {
- *(--filename) = ' ';
- buf[searchidx - 1] = 0;
- filename = &buf[searchidx];
- }
-
- /* Special handling for '.' and '..' */
- if (!strcmp(filename, ".") || !strcmp(filename, "..") || buf[0] == 'd') {
- ap_snprintf(buf2, sizeof(buf2), "%s <A HREF=\"%s/\">%s</A>\n",
- buf, filename, filename);
- }
- else {
- ap_snprintf(buf2, sizeof(buf2), "%s <A HREF=\"%s\">%s</A>\n", buf, filename, filename);
- }
- ap_cpystrn(buf, buf2, sizeof(buf));
- n = strlen(buf);
- }
-
- o = 0;
- total_bytes_sent += n;
-
- if (c != NULL && c->fp && ap_bwrite(c->fp, buf, n) != n) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
- "proxy: error writing to %s", c->tempfile);
- c = ap_proxy_cache_error(c);
- }
-
- while (n && !r->connection->aborted) {
- w = ap_bwrite(con->client, &buf[o], n);
- if (w <= 0)
- break;
- n -= w;
- o += w;
- }
- }
-
- total_bytes_sent += ap_proxy_bputs2("</PRE><HR>\n", con->client, c);
- total_bytes_sent += ap_proxy_bputs2(ap_psignature("", r), con->client, c);
- total_bytes_sent += ap_proxy_bputs2("</BODY></HTML>\n", con->client, c);
-
- ap_bflush(con->client);
-
- return total_bytes_sent;
-}
-
-/* Common routine for failed authorization (i.e., missing or wrong password)
- * to an ftp service. This causes most browsers to retry the request
- * with username and password (which was presumably queried from the user)
- * supplied in the Authorization: header.
- * Note that we "invent" a realm name which consists of the
- * ftp://user@host part of the reqest (sans password if supplied but invalid-)
- */
-static int ftp_unauthorized (request_rec *r, int log_it)
-{
- r->proxyreq = 0;
- /* Log failed requests if they supplied a password
- * (log username/password guessing attempts)
- */
- if (log_it)
- ap_log_rerror(APLOG_MARK, APLOG_INFO|APLOG_NOERRNO, r,
- "proxy: missing or failed auth to %s",
- ap_unparse_uri_components(r->pool,
- &r->parsed_uri, UNP_OMITPATHINFO));
-
- ap_table_setn(r->err_headers_out, "WWW-Authenticate",
- ap_pstrcat(r->pool, "Basic realm=\"",
- ap_unparse_uri_components(r->pool, &r->parsed_uri,
- UNP_OMITPASSWORD|UNP_OMITPATHINFO),
- "\"", NULL));
-
- return HTTP_UNAUTHORIZED;
-}
-
-/*
- * Handles direct access of ftp:// URLs
- * Original (Non-PASV) version from
- * Troy Morrison <spiffnet@zoom.com>
- * PASV added by Chuck
- */
-int ap_proxy_ftp_handler(request_rec *r, cache_req *c, char *url)
-{
- char *host, *path, *strp, *parms;
- char *cwd = NULL;
- char *user = NULL;
-/* char *account = NULL; how to supply an account in a URL? */
- const char *password = NULL;
- const char *err;
- int port, i, j, len, sock, dsock, rc, nocache = 0;
- int csd = 0;
- struct sockaddr_in server;
- struct hostent server_hp;
- struct in_addr destaddr;
- ap_table_t *resp_hdrs;
- BUFF *f;
- BUFF *data = NULL;
- ap_context_t *p = r->pool;
- int one = 1;
- const long int zero = 0L;
- NET_SIZE_T clen;
- struct tbl_do_args tdo;
-
- void *sconf = r->server->module_config;
- proxy_server_conf *conf =
- (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
- struct noproxy_entry *npent = (struct noproxy_entry *) conf->noproxies->elts;
- struct nocache_entry *ncent = (struct nocache_entry *) conf->nocaches->elts;
-
-/* stuff for PASV mode */
- unsigned int presult, h0, h1, h2, h3, p0, p1;
- unsigned int paddr;
- unsigned short pport;
- struct sockaddr_in data_addr;
- int pasvmode = 0;
- char pasv[64];
- char *pstr;
-
-/* stuff for responses */
- char resp[MAX_STRING_LEN];
- char *size = NULL;
-
-/* we only support GET and HEAD */
-
- if (r->method_number != M_GET)
- return HTTP_NOT_IMPLEMENTED;
-
-/* We break the URL into host, port, path-search */
-
- host = r->parsed_uri.hostname;
- port = (r->parsed_uri.port != 0)
- ? r->parsed_uri.port
- : ap_default_port_for_request(r);
- path = ap_pstrdup(p, r->parsed_uri.path);
- path = (path != NULL && path[0] != '\0') ? &path[1] : "";
-
- /* The "Authorization:" header must be checked first.
- * We allow the user to "override" the URL-coded user [ & password ]
- * in the Browsers' User&Password Dialog.
- * NOTE that this is only marginally more secure than having the
- * password travel in plain as part of the URL, because Basic Auth
- * simply uuencodes the plain text password.
- * But chances are still smaller that the URL is logged regularly.
- */
- if ((password = ap_table_get(r->headers_in, "Authorization")) != NULL
- && strcasecmp(ap_getword(r->pool, &password, ' '), "Basic") == 0
- && (password = ap_pbase64decode(r->pool, password))[0] != ':') {
- /* Note that this allocation has to be made from r->connection->pool
- * because it has the lifetime of the connection. The other allocations
- * are temporary and can be tossed away any time.
- */
- user = ap_getword_nulls (r->pool, &password, ':');
- r->ap_auth_type = "Basic";
- r->user = r->parsed_uri.user = user;
- nocache = 1; /* This resource only accessible with username/password */
- }
- else if ((user = r->parsed_uri.user) != NULL) {
- user = ap_pstrdup(p, user);
- decodeenc(user);
- if ((password = r->parsed_uri.password) != NULL) {
- char *tmp = ap_pstrdup(p, password);
- decodeenc(tmp);
- password = tmp;
- }
- nocache = 1; /* This resource only accessible with username/password */
- }
- else {
- user = "anonymous";
- password = "apache_proxy@";
- }
-
-/* check if ProxyBlock directive on this host */
- destaddr.s_addr = ap_inet_addr(host);
- for (i = 0; i < conf->noproxies->nelts; i++) {
- if ((npent[i].name != NULL && strstr(host, npent[i].name) != NULL)
- || destaddr.s_addr == npent[i].addr.s_addr || npent[i].name[0] == '*')
- return ap_proxyerror(r, HTTP_FORBIDDEN,
- "Connect to remote machine blocked");
- }
-
- Explain2("FTP: connect to %s:%d", host, port);
-
- parms = strchr(path, ';');
- if (parms != NULL)
- *(parms++) = '\0';
-
- memset(&server, 0, sizeof(struct sockaddr_in));
- server.sin_family = AF_INET;
- server.sin_port = htons(port);
- err = ap_proxy_host2addr(host, &server_hp);
- if (err != NULL)
- return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err);
-
- sock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (sock == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "proxy: error creating socket");
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- if (conf->recv_buffer_size > 0
- && setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
- (const char *) &conf->recv_buffer_size, sizeof(int))
- == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default");
- }
-
- if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *) &one,
- sizeof(one)) == -1) {
-#ifndef _OSD_POSIX /* BS2000 has this option "always on" */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "proxy: error setting reuseaddr option: setsockopt(SO_REUSEADDR)");
- ap_pclosesocket(p, sock);
- return HTTP_INTERNAL_SERVER_ERROR;
-#endif /*_OSD_POSIX*/
- }
-
-#ifdef SINIX_D_RESOLVER_BUG
- {
- struct in_addr *ip_addr = (struct in_addr *) *server_hp.h_addr_list;
-
- for (; ip_addr->s_addr != 0; ++ip_addr) {
- memcpy(&server.sin_addr, ip_addr, sizeof(struct in_addr));
- i = ap_proxy_doconnect(sock, &server, r);
- if (i == 0)
- break;
- }
- }
-#else
- j = 0;
- while (server_hp.h_addr_list[j] != NULL) {
- memcpy(&server.sin_addr, server_hp.h_addr_list[j],
- sizeof(struct in_addr));
- i = ap_proxy_doconnect(sock, &server, r);
- if (i == 0)
- break;
- j++;
- }
-#endif
- if (i == -1) {
- ap_pclosesocket(p, sock);
- return ap_proxyerror(r, HTTP_BAD_GATEWAY, ap_pstrcat(r->pool,
- "Could not connect to remote machine: ",
- strerror(errno), NULL));
- }
-
- f = ap_bcreate(p, B_RDWR | B_SOCKET);
- ap_bpushfd(f, sock);
-/* shouldn't we implement telnet control options here? */
-
-#ifdef CHARSET_EBCDIC
- ap_bsetflag(f, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 1);
-#endif /*CHARSET_EBCDIC*/
-
-/* possible results: */
- /* 120 Service ready in nnn minutes. */
- /* 220 Service ready for new user. */
- /* 421 Service not available, closing control connection. */
- i = ftp_getrc_msg(f, resp, sizeof resp);
- Explain1("FTP: returned status %d", i);
- if (i == -1) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
- }
-#if 0
- if (i == 120) {
- /* RFC2068 states:
- * 14.38 Retry-After
- *
- * The Retry-After response-header field can be used with a 503 (Service
- * Unavailable) response to indicate how long the service is expected to
- * be unavailable to the requesting client. The value of this field can
- * be either an HTTP-date or an integer number of seconds (in decimal)
- * after the time of the response.
- * Retry-After = "Retry-After" ":" ( HTTP-date | delta-seconds )
- */
- ap_set_header("Retry-After", ap_psprintf(p, "%u", 60*wait_mins);
- return ap_proxyerror(r, HTTP_SERVICE_UNAVAILABLE, resp);
- }
-#endif
- if (i != 220) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY, resp);
- }
-
- Explain0("FTP: connected.");
-
- ap_bvputs(f, "USER ", user, CRLF, NULL);
- ap_bflush(f); /* capture any errors */
- Explain1("FTP: USER %s", user);
-
-/* possible results; 230, 331, 332, 421, 500, 501, 530 */
-/* states: 1 - error, 2 - success; 3 - send password, 4,5 fail */
- /* 230 User logged in, proceed. */
- /* 331 User name okay, need password. */
- /* 332 Need account for login. */
- /* 421 Service not available, closing control connection. */
- /* 500 Syntax error, command unrecognized. */
- /* (This may include errors such as command line too long.) */
- /* 501 Syntax error in parameters or arguments. */
- /* 530 Not logged in. */
- i = ftp_getrc(f);
- Explain1("FTP: returned status %d", i);
- if (i == -1) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
- }
- if (i == 530) {
- return ftp_unauthorized (r, 1); /* log it: user name guessing attempt? */
- }
- if (i != 230 && i != 331) {
- return HTTP_BAD_GATEWAY;
- }
-
- if (i == 331) { /* send password */
- if (password == NULL) {
- return ftp_unauthorized (r, 0);
- }
- ap_bvputs(f, "PASS ", password, CRLF, NULL);
- ap_bflush(f);
- Explain1("FTP: PASS %s", password);
-/* possible results 202, 230, 332, 421, 500, 501, 503, 530 */
- /* 230 User logged in, proceed. */
- /* 332 Need account for login. */
- /* 421 Service not available, closing control connection. */
- /* 500 Syntax error, command unrecognized. */
- /* 501 Syntax error in parameters or arguments. */
- /* 503 Bad sequence of commands. */
- /* 530 Not logged in. */
- i = ftp_getrc(f);
- Explain1("FTP: returned status %d", i);
- if (i == -1) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY, "Error reading from remote server");
- }
- if (i == 332) {
- return ap_proxyerror(r, HTTP_UNAUTHORIZED, "Need account for login");
- }
- /* @@@ questionable -- we might as well return a 403 Forbidden here */
- if (i == 530) {
- return ftp_unauthorized (r, 1); /* log it: passwd guessing attempt? */
- }
- if (i != 230 && i != 202) {
- return HTTP_BAD_GATEWAY;
- }
- }
-
-/* set the directory (walk directory component by component):
- * this is what we must do if we don't know the OS type of the remote
- * machine
- */
- for (;;) {
- strp = strchr(path, '/');
- if (strp == NULL)
- break;
- *strp = '\0';
-
- len = decodeenc(path);
- ap_bvputs(f, "CWD ", path, CRLF, NULL);
- ap_bflush(f);
- Explain1("FTP: CWD %s", path);
- *strp = '/';
-/* responses: 250, 421, 500, 501, 502, 530, 550 */
- /* 250 Requested file action okay, completed. */
- /* 421 Service not available, closing control connection. */
- /* 500 Syntax error, command unrecognized. */
- /* 501 Syntax error in parameters or arguments. */
- /* 502 Command not implemented. */
- /* 530 Not logged in. */
- /* 550 Requested action not taken. */
- i = ftp_getrc(f);
- Explain1("FTP: returned status %d", i);
- if (i == -1) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
- }
- if (i == 550) {
- return HTTP_NOT_FOUND;
- }
- if (i != 250) {
- return HTTP_BAD_GATEWAY;
- }
-
- path = strp + 1;
- }
-
- if (parms != NULL && strncmp(parms, "type=", 5) == 0) {
- parms += 5;
- if ((parms[0] != 'd' && parms[0] != 'a' && parms[0] != 'i') ||
- parms[1] != '\0')
- parms = "";
- }
- else
- parms = "";
-
- /* changed to make binary transfers the default */
-
- if (parms[0] != 'a') {
- /* set type to image */
- /* TM - Added \015\012 to the end of TYPE I, otherwise it hangs the
- connection */
- ap_bputs("TYPE I" CRLF, f);
- ap_bflush(f);
- Explain0("FTP: TYPE I");
-/* responses: 200, 421, 500, 501, 504, 530 */
- /* 200 Command okay. */
- /* 421 Service not available, closing control connection. */
- /* 500 Syntax error, command unrecognized. */
- /* 501 Syntax error in parameters or arguments. */
- /* 504 Command not implemented for that parameter. */
- /* 530 Not logged in. */
- i = ftp_getrc(f);
- Explain1("FTP: returned status %d", i);
- if (i == -1) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
- }
- if (i != 200 && i != 504) {
- return HTTP_BAD_GATEWAY;
- }
-/* Allow not implemented */
- if (i == 504)
- parms[0] = '\0';
- }
-
-/* try to set up PASV data connection first */
- dsock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (dsock == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "proxy: error creating PASV socket");
- ap_bclose(f);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- if (conf->recv_buffer_size) {
- if (setsockopt(dsock, SOL_SOCKET, SO_RCVBUF,
- (const char *) &conf->recv_buffer_size, sizeof(int)) == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default");
- }
- }
-
- ap_bputs("PASV" CRLF, f);
- ap_bflush(f);
- Explain0("FTP: PASV command issued");
-/* possible results: 227, 421, 500, 501, 502, 530 */
- /* 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). */
- /* 421 Service not available, closing control connection. */
- /* 500 Syntax error, command unrecognized. */
- /* 501 Syntax error in parameters or arguments. */
- /* 502 Command not implemented. */
- /* 530 Not logged in. */
- i = ap_bgets(pasv, sizeof(pasv), f);
- if (i == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r,
- "PASV: control connection is toast");
- ap_pclosesocket(p, dsock);
- ap_bclose(f);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- else {
- pasv[i - 1] = '\0';
- pstr = strtok(pasv, " "); /* separate result code */
- if (pstr != NULL) {
- presult = atoi(pstr);
- if (*(pstr + strlen(pstr) + 1) == '=')
- pstr += strlen(pstr) + 2;
- else
- {
- pstr = strtok(NULL, "("); /* separate address & port params */
- if (pstr != NULL)
- pstr = strtok(NULL, ")");
- }
- }
- else
- presult = atoi(pasv);
-
- Explain1("FTP: returned status %d", presult);
-
- if (presult == 227 && pstr != NULL && (sscanf(pstr,
- "%d,%d,%d,%d,%d,%d", &h3, &h2, &h1, &h0, &p1, &p0) == 6)) {
- /* pardon the parens, but it makes gcc happy */
- paddr = (((((h3 << 8) + h2) << 8) + h1) << 8) + h0;
- pport = (p1 << 8) + p0;
- Explain5("FTP: contacting host %d.%d.%d.%d:%d",
- h3, h2, h1, h0, pport);
- data_addr.sin_family = AF_INET;
- data_addr.sin_addr.s_addr = htonl(paddr);
- data_addr.sin_port = htons(pport);
- i = ap_proxy_doconnect(dsock, &data_addr, r);
-
- if (i == -1) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- ap_pstrcat(r->pool,
- "Could not connect to remote machine: ",
- strerror(errno), NULL));
- }
- else {
- pasvmode = 1;
- }
- }
- else
- ap_pclosesocket(p, dsock); /* and try the regular way */
- }
-
- if (!pasvmode) { /* set up data connection */
- clen = sizeof(struct sockaddr_in);
- if (getsockname(sock, (struct sockaddr *) &server, &clen) < 0) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "proxy: error getting socket address");
- ap_bclose(f);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- dsock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (dsock == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "proxy: error creating socket");
- ap_bclose(f);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- if (setsockopt(dsock, SOL_SOCKET, SO_REUSEADDR, (void *) &one,
- sizeof(one)) == -1) {
-#ifndef _OSD_POSIX /* BS2000 has this option "always on" */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "proxy: error setting reuseaddr option");
- ap_pclosesocket(p, dsock);
- ap_bclose(f);
- return HTTP_INTERNAL_SERVER_ERROR;
-#endif /*_OSD_POSIX*/
- }
-
- if (bind(dsock, (struct sockaddr *) &server,
- sizeof(struct sockaddr_in)) == -1) {
- char buff[22];
-
- ap_snprintf(buff, sizeof(buff), "%s:%d", inet_ntoa(server.sin_addr), server.sin_port);
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "proxy: error binding to ftp data socket %s", buff);
- ap_bclose(f);
- ap_pclosesocket(p, dsock);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- listen(dsock, 2); /* only need a short queue */
- }
-
-/* set request; "path" holds last path component */
- len = decodeenc(path);
-
- /* TM - if len == 0 then it must be a directory (you can't RETR nothing) */
-
- if (len == 0) {
- parms = "d";
- }
- else {
- ap_bvputs(f, "SIZE ", path, CRLF, NULL);
- ap_bflush(f);
- Explain1("FTP: SIZE %s", path);
- i = ftp_getrc_msg(f, resp, sizeof resp);
- Explain2("FTP: returned status %d with response %s", i, resp);
- if (i != 500) { /* Size command not recognized */
- if (i == 550) { /* Not a regular file */
- Explain0("FTP: SIZE shows this is a directory");
- parms = "d";
- ap_bvputs(f, "CWD ", path, CRLF, NULL);
- ap_bflush(f);
- Explain1("FTP: CWD %s", path);
- i = ftp_getrc(f);
- /* possible results: 250, 421, 500, 501, 502, 530, 550 */
- /* 250 Requested file action okay, completed. */
- /* 421 Service not available, closing control connection. */
- /* 500 Syntax error, command unrecognized. */
- /* 501 Syntax error in parameters or arguments. */
- /* 502 Command not implemented. */
- /* 530 Not logged in. */
- /* 550 Requested action not taken. */
- Explain1("FTP: returned status %d", i);
- if (i == -1) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
- }
- if (i == 550) {
- return HTTP_NOT_FOUND;
- }
- if (i != 250) {
- return HTTP_BAD_GATEWAY;
- }
- path = "";
- len = 0;
- }
- else if (i == 213) { /* Size command ok */
- for (j = 0; j < sizeof resp && ap_isdigit(resp[j]); j++)
- ;
- resp[j] = '\0';
- if (resp[0] != '\0')
- size = ap_pstrdup(p, resp);
- }
- }
- }
-
-#ifdef AUTODETECT_PWD
- ap_bvputs(f, "PWD", CRLF, NULL);
- ap_bflush(f);
- Explain0("FTP: PWD");
-/* responses: 257, 500, 501, 502, 421, 550 */
- /* 257 "<directory-name>" <commentary> */
- /* 421 Service not available, closing control connection. */
- /* 500 Syntax error, command unrecognized. */
- /* 501 Syntax error in parameters or arguments. */
- /* 502 Command not implemented. */
- /* 550 Requested action not taken. */
- i = ftp_getrc_msg(f, resp, sizeof resp);
- Explain1("FTP: PWD returned status %d", i);
- if (i == -1 || i == 421) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
- }
- if (i == 550) {
- return HTTP_NOT_FOUND;
- }
- if (i == 257) {
- const char *dirp = resp;
- cwd = ap_getword_conf(r->pool, &dirp);
- }
-#endif /*AUTODETECT_PWD*/
-
- if (parms[0] == 'd') {
- if (len != 0)
- ap_bvputs(f, "LIST ", path, CRLF, NULL);
- else
- ap_bputs("LIST -lag" CRLF, f);
- Explain1("FTP: LIST %s", (len == 0 ? "" : path));
- }
- else {
- ap_bvputs(f, "RETR ", path, CRLF, NULL);
- Explain1("FTP: RETR %s", path);
- }
- ap_bflush(f);
-/* RETR: 110, 125, 150, 226, 250, 421, 425, 426, 450, 451, 500, 501, 530, 550
- NLST: 125, 150, 226, 250, 421, 425, 426, 450, 451, 500, 501, 502, 530 */
- /* 110 Restart marker reply. */
- /* 125 Data connection already open; transfer starting. */
- /* 150 File status okay; about to open data connection. */
- /* 226 Closing data connection. */
- /* 250 Requested file action okay, completed. */
- /* 421 Service not available, closing control connection. */
- /* 425 Can't open data connection. */
- /* 426 Connection closed; transfer aborted. */
- /* 450 Requested file action not taken. */
- /* 451 Requested action aborted. Local error in processing. */
- /* 500 Syntax error, command unrecognized. */
- /* 501 Syntax error in parameters or arguments. */
- /* 530 Not logged in. */
- /* 550 Requested action not taken. */
- rc = ftp_getrc(f);
- Explain1("FTP: returned status %d", rc);
- if (rc == -1) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
- }
- if (rc == 550) {
- Explain0("FTP: RETR failed, trying LIST instead");
- parms = "d";
- ap_bvputs(f, "CWD ", path, CRLF, NULL);
- ap_bflush(f);
- Explain1("FTP: CWD %s", path);
- /* possible results: 250, 421, 500, 501, 502, 530, 550 */
- /* 250 Requested file action okay, completed. */
- /* 421 Service not available, closing control connection. */
- /* 500 Syntax error, command unrecognized. */
- /* 501 Syntax error in parameters or arguments. */
- /* 502 Command not implemented. */
- /* 530 Not logged in. */
- /* 550 Requested action not taken. */
- rc = ftp_getrc(f);
- Explain1("FTP: returned status %d", rc);
- if (rc == -1) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
- }
- if (rc == 550) {
- return HTTP_NOT_FOUND;
- }
- if (rc != 250) {
- return HTTP_BAD_GATEWAY;
- }
-
-#ifdef AUTODETECT_PWD
- ap_bvputs(f, "PWD", CRLF, NULL);
- ap_bflush(f);
- Explain0("FTP: PWD");
-/* responses: 257, 500, 501, 502, 421, 550 */
- /* 257 "<directory-name>" <commentary> */
- /* 421 Service not available, closing control connection. */
- /* 500 Syntax error, command unrecognized. */
- /* 501 Syntax error in parameters or arguments. */
- /* 502 Command not implemented. */
- /* 550 Requested action not taken. */
- i = ftp_getrc_msg(f, resp, sizeof resp);
- Explain1("FTP: PWD returned status %d", i);
- if (i == -1 || i == 421) {
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
- }
- if (i == 550) {
- return HTTP_NOT_FOUND;
- }
- if (i == 257) {
- const char *dirp = resp;
- cwd = ap_getword_conf(r->pool, &dirp);
- }
-#endif /*AUTODETECT_PWD*/
-
- ap_bputs("LIST -lag" CRLF, f);
- ap_bflush(f);
- Explain0("FTP: LIST -lag");
- rc = ftp_getrc(f);
- Explain1("FTP: returned status %d", rc);
- if (rc == -1)
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
- }
- if (rc != 125 && rc != 150 && rc != 226 && rc != 250)
- return HTTP_BAD_GATEWAY;
-
- r->status = HTTP_OK;
- r->status_line = "200 OK";
-
- resp_hdrs = ap_make_table(p, 2);
- c->hdrs = resp_hdrs;
-
- ap_table_setn(resp_hdrs, "Date", ap_gm_timestr_822(r->pool, r->request_time));
- ap_table_setn(resp_hdrs, "Server", ap_get_server_version());
-
- if (parms[0] == 'd')
- ap_table_setn(resp_hdrs, "Content-Type", "text/html");
- else {
- if (r->content_type != NULL) {
- ap_table_setn(resp_hdrs, "Content-Type", r->content_type);
- Explain1("FTP: Content-Type set to %s", r->content_type);
- }
- else {
- ap_table_setn(resp_hdrs, "Content-Type", ap_default_type(r));
- }
- if (parms[0] != 'a' && size != NULL) {
- /* We "trust" the ftp server to really serve (size) bytes... */
- ap_table_set(resp_hdrs, "Content-Length", size);
- Explain1("FTP: Content-Length set to %s", size);
- }
- }
- if (r->content_encoding != NULL && r->content_encoding[0] != '\0') {
- Explain1("FTP: Content-Encoding set to %s", r->content_encoding);
- ap_table_setn(resp_hdrs, "Content-Encoding", r->content_encoding);
- }
-
-/* check if NoCache directive on this host */
- for (i = 0; i < conf->nocaches->nelts; i++) {
- if ((ncent[i].name != NULL && strstr(host, ncent[i].name) != NULL)
- || destaddr.s_addr == ncent[i].addr.s_addr || ncent[i].name[0] == '*')
- nocache = 1;
- }
-
- i = ap_proxy_cache_update(c, resp_hdrs, 0, nocache);
-
- if (i != DECLINED) {
- ap_pclosesocket(p, dsock);
- ap_bclose(f);
- return i;
- }
-
- if (!pasvmode) { /* wait for connection */
- clen = sizeof(struct sockaddr_in);
- do
- csd = accept(dsock, (struct sockaddr *) &server, &clen);
- while (csd == -1 && errno == EINTR);
- if (csd == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "proxy: failed to accept data connection");
- ap_pclosesocket(p, dsock);
- ap_bclose(f);
- if (c != NULL)
- c = ap_proxy_cache_error(c);
- return HTTP_BAD_GATEWAY;
- }
- ap_note_cleanups_for_socket(p, csd);
- data = ap_bcreate(p, B_RDWR | B_SOCKET);
- ap_bpushfd(data, csd);
- }
- else {
- data = ap_bcreate(p, B_RDWR | B_SOCKET);
- ap_bpushfd(data, dsock);
- }
-
-/* send response */
-/* write status line */
- if (!r->assbackwards)
- ap_rvputs(r, "HTTP/1.0 ", r->status_line, CRLF, NULL);
- if (c != NULL && c->fp != NULL
- && ap_bvputs(c->fp, "HTTP/1.0 ", r->status_line, CRLF, NULL) == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
- "proxy: error writing CRLF to %s", c->tempfile);
- c = ap_proxy_cache_error(c);
- }
-
-/* send headers */
- tdo.req = r;
- tdo.cache = c;
- ap_table_do(ap_proxy_send_hdr_line, &tdo, resp_hdrs, NULL);
-
- if (!r->assbackwards)
- ap_rputs(CRLF, r);
- if (c != NULL && c->fp != NULL && ap_bputs(CRLF, c->fp) == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
- "proxy: error writing CRLF to %s", c->tempfile);
- c = ap_proxy_cache_error(c);
- }
-
- ap_bsetopt(r->connection->client, BO_BYTECT, &zero);
- r->sent_bodyct = 1;
-/* send body */
- if (!r->header_only) {
- if (parms[0] != 'd') {
-/* we need to set this for ap_proxy_send_fb()... */
- if (c != NULL)
- c->cache_completion = 0;
- ap_proxy_send_fb(data, r, c);
- } else
- send_dir(data, r, c, cwd);
-
- if (rc == 125 || rc == 150)
- rc = ftp_getrc(f);
-
- /* XXX: we checked for 125||150||226||250 above. This is redundant. */
- if (rc != 226 && rc != 250)
- /* XXX: we no longer log an "error writing to c->tempfile" - should we? */
- c = ap_proxy_cache_error(c);
- }
- else {
-/* abort the transfer */
- ap_bputs("ABOR" CRLF, f);
- ap_bflush(f);
- if (!pasvmode)
- ap_bclose(data);
- Explain0("FTP: ABOR");
-/* responses: 225, 226, 421, 500, 501, 502 */
- /* 225 Data connection open; no transfer in progress. */
- /* 226 Closing data connection. */
- /* 421 Service not available, closing control connection. */
- /* 500 Syntax error, command unrecognized. */
- /* 501 Syntax error in parameters or arguments. */
- /* 502 Command not implemented. */
- i = ftp_getrc(f);
- Explain1("FTP: returned status %d", i);
- }
-
- ap_proxy_cache_tidy(c);
-
-/* finish */
- ap_bputs("QUIT" CRLF, f);
- ap_bflush(f);
- Explain0("FTP: QUIT");
-/* responses: 221, 500 */
- /* 221 Service closing control connection. */
- /* 500 Syntax error, command unrecognized. */
- i = ftp_getrc(f);
- Explain1("FTP: QUIT: status %d", i);
-
- if (pasvmode)
- ap_bclose(data);
- ap_bclose(f);
-
- ap_rflush(r); /* flush before garbage collection */
-
- ap_proxy_garbage_coll(r);
-
- return OK;
-}
diff --git a/modules/proxy/proxy_http.c b/modules/proxy/proxy_http.c
deleted file mode 100644
index 937b314866..0000000000
--- a/modules/proxy/proxy_http.c
+++ /dev/null
@@ -1,532 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/* HTTP routines for Apache proxy */
-
-#include "mod_proxy.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "http_core.h"
-#include "util_date.h"
-
-/*
- * Canonicalise http-like URLs.
- * scheme is the scheme for the URL
- * url is the URL starting with the first '/'
- * def_port is the default port for this scheme.
- */
-int ap_proxy_http_canon(request_rec *r, char *url, const char *scheme, int def_port)
-{
- char *host, *path, *search, sport[7];
- const char *err;
- int port;
-
-/* do syntatic check.
- * We break the URL into host, port, path, search
- */
- port = def_port;
- err = ap_proxy_canon_netloc(r->pool, &url, NULL, NULL, &host, &port);
- if (err)
- return HTTP_BAD_REQUEST;
-
-/* now parse path/search args, according to rfc1738 */
-/* N.B. if this isn't a true proxy request, then the URL _path_
- * has already been decoded. True proxy requests have r->uri
- * == r->unparsed_uri, and no others have that property.
- */
- if (r->uri == r->unparsed_uri) {
- search = strchr(url, '?');
- if (search != NULL)
- *(search++) = '\0';
- }
- else
- search = r->args;
-
-/* process path */
- path = ap_proxy_canonenc(r->pool, url, strlen(url), enc_path, r->proxyreq);
- if (path == NULL)
- return HTTP_BAD_REQUEST;
-
- if (port != def_port)
- ap_snprintf(sport, sizeof(sport), ":%d", port);
- else
- sport[0] = '\0';
-
- r->filename = ap_pstrcat(r->pool, "proxy:", scheme, "://", host, sport, "/",
- path, (search) ? "?" : "", (search) ? search : "", NULL);
- return OK;
-}
-
-static const char *proxy_location_reverse_map(request_rec *r, const char *url)
-{
- void *sconf;
- proxy_server_conf *conf;
- struct proxy_alias *ent;
- int i, l1, l2;
- char *u;
-
- sconf = r->server->module_config;
- conf = (proxy_server_conf *)ap_get_module_config(sconf, &proxy_module);
- l1 = strlen(url);
- ent = (struct proxy_alias *)conf->raliases->elts;
- for (i = 0; i < conf->raliases->nelts; i++) {
- l2 = strlen(ent[i].real);
- if (l1 >= l2 && strncmp(ent[i].real, url, l2) == 0) {
- u = ap_pstrcat(r->pool, ent[i].fake, &url[l2], NULL);
- return ap_construct_url(r->pool, u, r);
- }
- }
- return url;
-}
-
-/* Clear all connection-based headers from the incoming headers ap_table_t */
-static void clear_connection(ap_context_t *p, ap_table_t *headers)
-{
- const char *name;
- char *next = ap_pstrdup(p, ap_table_get(headers, "Connection"));
-
- ap_table_unset(headers, "Proxy-Connection");
- if (!next)
- return;
-
- while (*next) {
- name = next;
- while (*next && !ap_isspace(*next) && (*next != ','))
- ++next;
- while (*next && (ap_isspace(*next) || (*next == ','))) {
- *next = '\0';
- ++next;
- }
- ap_table_unset(headers, name);
- }
- ap_table_unset(headers, "Connection");
-}
-
-/*
- * This handles http:// URLs, and other URLs using a remote proxy over http
- * If proxyhost is NULL, then contact the server directly, otherwise
- * go via the proxy.
- * Note that if a proxy is used, then URLs other than http: can be accessed,
- * also, if we have trouble which is clearly specific to the proxy, then
- * we return DECLINED so that we can try another proxy. (Or the direct
- * route.)
- */
-int ap_proxy_http_handler(request_rec *r, cache_req *c, char *url,
- const char *proxyhost, int proxyport)
-{
- const char *strp;
- char *strp2;
- const char *err, *desthost;
- int i, j, sock, len, backasswards;
- ap_array_header_t *reqhdrs_arr;
- ap_table_t *resp_hdrs;
- table_entry *reqhdrs;
- struct sockaddr_in server;
- struct in_addr destaddr;
- struct hostent server_hp;
- BUFF *f;
- char buffer[HUGE_STRING_LEN];
- char portstr[32];
- ap_context_t *p = r->pool;
- const long int zero = 0L;
- int destport = 0;
- char *destportstr = NULL;
- const char *urlptr = NULL;
- const char *datestr;
- struct tbl_do_args tdo;
-
- void *sconf = r->server->module_config;
- proxy_server_conf *conf =
- (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
- struct noproxy_entry *npent = (struct noproxy_entry *) conf->noproxies->elts;
- struct nocache_entry *ncent = (struct nocache_entry *) conf->nocaches->elts;
- int nocache = 0;
-
- memset(&server, '\0', sizeof(server));
- server.sin_family = AF_INET;
-
-/* We break the URL into host, port, path-search */
-
- urlptr = strstr(url, "://");
- if (urlptr == NULL)
- return HTTP_BAD_REQUEST;
- urlptr += 3;
- destport = DEFAULT_HTTP_PORT;
- strp = strchr(urlptr, '/');
- if (strp == NULL) {
- desthost = ap_pstrdup(p, urlptr);
- urlptr = "/";
- }
- else {
- char *q = ap_palloc(p, strp - urlptr + 1);
- memcpy(q, urlptr, strp - urlptr);
- q[strp - urlptr] = '\0';
- urlptr = strp;
- desthost = q;
- }
-
- strp2 = strchr(desthost, ':');
- if (strp2 != NULL) {
- *(strp2++) = '\0';
- if (ap_isdigit(*strp2)) {
- destport = atoi(strp2);
- destportstr = strp2;
- }
- }
-
-/* check if ProxyBlock directive on this host */
- destaddr.s_addr = ap_inet_addr(desthost);
- for (i = 0; i < conf->noproxies->nelts; i++) {
- if ((npent[i].name != NULL && strstr(desthost, npent[i].name) != NULL)
- || destaddr.s_addr == npent[i].addr.s_addr || npent[i].name[0] == '*')
- return ap_proxyerror(r, HTTP_FORBIDDEN,
- "Connect to remote machine blocked");
- }
-
- if (proxyhost != NULL) {
- server.sin_port = htons(proxyport);
- err = ap_proxy_host2addr(proxyhost, &server_hp);
- if (err != NULL)
- return DECLINED; /* try another */
- }
- else {
- server.sin_port = htons(destport);
- err = ap_proxy_host2addr(desthost, &server_hp);
- if (err != NULL)
- return ap_proxyerror(r, HTTP_INTERNAL_SERVER_ERROR, err);
- }
-
- sock = ap_psocket(p, PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (sock == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "proxy: error creating socket");
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- if (conf->recv_buffer_size) {
- if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
- (const char *) &conf->recv_buffer_size, sizeof(int))
- == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "setsockopt(SO_RCVBUF): Failed to set ProxyReceiveBufferSize, using default");
- }
- }
-
-#ifdef SINIX_D_RESOLVER_BUG
- {
- struct in_addr *ip_addr = (struct in_addr *) *server_hp.h_addr_list;
-
- for (; ip_addr->s_addr != 0; ++ip_addr) {
- memcpy(&server.sin_addr, ip_addr, sizeof(struct in_addr));
- i = ap_proxy_doconnect(sock, &server, r);
- if (i == 0)
- break;
- }
- }
-#else
- j = 0;
- while (server_hp.h_addr_list[j] != NULL) {
- memcpy(&server.sin_addr, server_hp.h_addr_list[j],
- sizeof(struct in_addr));
- i = ap_proxy_doconnect(sock, &server, r);
- if (i == 0)
- break;
- j++;
- }
-#endif
- if (i == -1) {
- if (proxyhost != NULL)
- return DECLINED; /* try again another way */
- else
- return ap_proxyerror(r, HTTP_BAD_GATEWAY, ap_pstrcat(r->pool,
- "Could not connect to remote machine: ",
- strerror(errno), NULL));
- }
-
- clear_connection(r->pool, r->headers_in); /* Strip connection-based headers */
-
- f = ap_bcreate(p, B_RDWR | B_SOCKET);
- ap_bpushfd(f, sock);
-
- ap_bvputs(f, r->method, " ", proxyhost ? url : urlptr, " HTTP/1.0" CRLF,
- NULL);
- if (destportstr != NULL && destport != DEFAULT_HTTP_PORT)
- ap_bvputs(f, "Host: ", desthost, ":", destportstr, CRLF, NULL);
- else
- ap_bvputs(f, "Host: ", desthost, CRLF, NULL);
-
- if (conf->viaopt == via_block) {
- /* Block all outgoing Via: headers */
- ap_table_unset(r->headers_in, "Via");
- } else if (conf->viaopt != via_off) {
- /* Create a "Via:" request header entry and merge it */
- i = ap_get_server_port(r);
- if (ap_is_default_port(i,r)) {
- strcpy(portstr,"");
- } else {
- ap_snprintf(portstr, sizeof portstr, ":%d", i);
- }
- /* Generate outgoing Via: header with/without server comment: */
- ap_table_mergen(r->headers_in, "Via",
- (conf->viaopt == via_full)
- ? ap_psprintf(p, "%d.%d %s%s (%s)",
- HTTP_VERSION_MAJOR(r->proto_num),
- HTTP_VERSION_MINOR(r->proto_num),
- ap_get_server_name(r), portstr,
- SERVER_BASEVERSION)
- : ap_psprintf(p, "%d.%d %s%s",
- HTTP_VERSION_MAJOR(r->proto_num),
- HTTP_VERSION_MINOR(r->proto_num),
- ap_get_server_name(r), portstr)
- );
- }
-
- reqhdrs_arr = ap_table_elts(r->headers_in);
- reqhdrs = (table_entry *) reqhdrs_arr->elts;
- for (i = 0; i < reqhdrs_arr->nelts; i++) {
- if (reqhdrs[i].key == NULL || reqhdrs[i].val == NULL
- /* Clear out headers not to send */
- || !strcasecmp(reqhdrs[i].key, "Host") /* Already sent */
- /* XXX: @@@ FIXME: "Proxy-Authorization" should *only* be
- * suppressed if THIS server requested the authentication,
- * not when a frontend proxy requested it!
- */
- || !strcasecmp(reqhdrs[i].key, "Proxy-Authorization"))
- continue;
- ap_bvputs(f, reqhdrs[i].key, ": ", reqhdrs[i].val, CRLF, NULL);
- }
-
- ap_bputs(CRLF, f);
-/* send the request data, if any. */
-
- if (ap_should_client_block(r)) {
- while ((i = ap_get_client_block(r, buffer, sizeof buffer)) > 0)
- ap_bwrite(f, buffer, i);
- }
- ap_bflush(f);
-
- len = ap_bgets(buffer, sizeof buffer - 1, f);
- if (len == -1) {
- ap_bclose(f);
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "ap_bgets() - proxy receive - Error reading from remote server %s (length %d)",
- proxyhost ? proxyhost : desthost, len);
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Error reading from remote server");
- } else if (len == 0) {
- ap_bclose(f);
- return ap_proxyerror(r, HTTP_BAD_GATEWAY,
- "Document contains no data");
- }
-
-/* Is it an HTTP/1 response? This is buggy if we ever see an HTTP/1.10 */
- if (ap_checkmask(buffer, "HTTP/#.# ###*")) {
- int major, minor;
- if (2 != sscanf(buffer, "HTTP/%u.%u", &major, &minor)) {
- major = 1;
- minor = 0;
- }
-
-/* If not an HTTP/1 message or if the status line was > 8192 bytes */
- if (buffer[5] != '1' || buffer[len - 1] != '\n') {
- ap_bclose(f);
- return HTTP_BAD_GATEWAY;
- }
- backasswards = 0;
- buffer[--len] = '\0';
-
- buffer[12] = '\0';
- r->status = atoi(&buffer[9]);
- buffer[12] = ' ';
- r->status_line = ap_pstrdup(p, &buffer[9]);
-
-/* read the headers. */
-/* N.B. for HTTP/1.0 clients, we have to fold line-wrapped headers */
-/* Also, take care with headers with multiple occurences. */
-
- resp_hdrs = ap_proxy_read_headers(r, buffer, HUGE_STRING_LEN, f);
- if (resp_hdrs == NULL) {
- ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, r->server,
- "proxy: Bad HTTP/%d.%d header returned by %s (%s)",
- major, minor, r->uri, r->method);
- resp_hdrs = ap_make_table(p, 20);
- nocache = 1; /* do not cache this broken file */
- }
-
- if (conf->viaopt != via_off && conf->viaopt != via_block) {
- /* Create a "Via:" response header entry and merge it */
- i = ap_get_server_port(r);
- if (ap_is_default_port(i,r)) {
- strcpy(portstr,"");
- } else {
- ap_snprintf(portstr, sizeof portstr, ":%d", i);
- }
- ap_table_mergen((table *)resp_hdrs, "Via",
- (conf->viaopt == via_full)
- ? ap_psprintf(p, "%d.%d %s%s (%s)",
- major, minor,
- ap_get_server_name(r), portstr,
- SERVER_BASEVERSION)
- : ap_psprintf(p, "%d.%d %s%s",
- major, minor,
- ap_get_server_name(r), portstr)
- );
- }
-
- clear_connection(p, resp_hdrs); /* Strip Connection hdrs */
- }
- else {
-/* an http/0.9 response */
- backasswards = 1;
- r->status = 200;
- r->status_line = "200 OK";
-
-/* no headers */
- resp_hdrs = ap_make_table(p, 20);
- }
-
- c->hdrs = resp_hdrs;
-
-
-/*
- * HTTP/1.0 requires us to accept 3 types of dates, but only generate
- * one type
- */
- if ((datestr = ap_table_get(resp_hdrs, "Date")) != NULL)
- ap_table_set(resp_hdrs, "Date", ap_proxy_date_canon(p, datestr));
- if ((datestr = ap_table_get(resp_hdrs, "Last-Modified")) != NULL)
- ap_table_set(resp_hdrs, "Last-Modified", ap_proxy_date_canon(p, datestr));
- if ((datestr = ap_table_get(resp_hdrs, "Expires")) != NULL)
- ap_table_set(resp_hdrs, "Expires", ap_proxy_date_canon(p, datestr));
-
- if ((datestr = ap_table_get(resp_hdrs, "Location")) != NULL)
- ap_table_set(resp_hdrs, "Location", proxy_location_reverse_map(r, datestr));
- if ((datestr = ap_table_get(resp_hdrs, "URI")) != NULL)
- ap_table_set(resp_hdrs, "URI", proxy_location_reverse_map(r, datestr));
-
-/* check if NoCache directive on this host */
- for (i = 0; i < conf->nocaches->nelts; i++) {
- if ((ncent[i].name != NULL && strstr(desthost, ncent[i].name) != NULL)
- || destaddr.s_addr == ncent[i].addr.s_addr || ncent[i].name[0] == '*')
- nocache = 1;
- }
-
- i = ap_proxy_cache_update(c, resp_hdrs, !backasswards, nocache);
- if (i != DECLINED) {
- ap_bclose(f);
- return i;
- }
-
-/* write status line */
- if (!r->assbackwards)
- ap_rvputs(r, "HTTP/1.0 ", r->status_line, CRLF, NULL);
- if (c != NULL && c->fp != NULL &&
- ap_bvputs(c->fp, "HTTP/1.0 ", r->status_line, CRLF, NULL) == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
- "proxy: error writing status line to %s", c->tempfile);
- c = ap_proxy_cache_error(c);
- }
-
-/* send headers */
- tdo.req = r;
- tdo.cache = c;
- ap_table_do(ap_proxy_send_hdr_line, &tdo, resp_hdrs, NULL);
-
- if (!r->assbackwards)
- ap_rputs(CRLF, r);
- if (c != NULL && c->fp != NULL && ap_bputs(CRLF, c->fp) == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
- "proxy: error writing CRLF to %s", c->tempfile);
- c = ap_proxy_cache_error(c);
- }
-
- ap_bsetopt(r->connection->client, BO_BYTECT, &zero);
- r->sent_bodyct = 1;
-/* Is it an HTTP/0.9 respose? If so, send the extra data */
- if (backasswards) {
- ap_bwrite(r->connection->client, buffer, len);
- if (c != NULL && c->fp != NULL && ap_bwrite(c->fp, buffer, len) != len) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
- "proxy: error writing extra data to %s", c->tempfile);
- c = ap_proxy_cache_error(c);
- }
- }
-
-#ifdef CHARSET_EBCDIC
- /* What we read/write after the header should not be modified
- * (i.e., the cache copy is ASCII, not EBCDIC, even for text/html)
- */
- ap_bsetflag(f, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 0);
- ap_bsetflag(r->connection->client, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 0);
-#endif
-
-/* send body */
-/* if header only, then cache will be NULL */
-/* HTTP/1.0 tells us to read to EOF, rather than content-length bytes */
- if (!r->header_only) {
-/* we need to set this for ap_proxy_send_fb()... */
- c->cache_completion = conf->cache.cache_completion;
- ap_proxy_send_fb(f, r, c);
- }
-
- ap_proxy_cache_tidy(c);
-
- ap_bclose(f);
-
- ap_proxy_garbage_coll(r);
- return OK;
-}
diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c
deleted file mode 100644
index 2d55a817d0..0000000000
--- a/modules/proxy/proxy_util.c
+++ /dev/null
@@ -1,1283 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/* Utility routines for Apache proxy */
-#include "mod_proxy.h"
-#include "http_main.h"
-#include "ap_md5.h"
-#include "http_log.h"
-#include "util_uri.h"
-#include "util_date.h" /* get ap_checkmask() decl. */
-
-#include <pthread.h>
-
-static int proxy_match_ipaddr(struct dirconn_entry *This, request_rec *r);
-static int proxy_match_domainname(struct dirconn_entry *This, request_rec *r);
-static int proxy_match_hostname(struct dirconn_entry *This, request_rec *r);
-static int proxy_match_word(struct dirconn_entry *This, request_rec *r);
-
-/* already called in the knowledge that the characters are hex digits */
-int ap_proxy_hex2c(const char *x)
-{
- int i, ch;
-
-#ifndef CHARSET_EBCDIC
- ch = x[0];
- if (ap_isdigit(ch))
- i = ch - '0';
- else if (ap_isupper(ch))
- i = ch - ('A' - 10);
- else
- i = ch - ('a' - 10);
- i <<= 4;
-
- ch = x[1];
- if (ap_isdigit(ch))
- i += ch - '0';
- else if (ap_isupper(ch))
- i += ch - ('A' - 10);
- else
- i += ch - ('a' - 10);
- return i;
-#else /*CHARSET_EBCDIC*/
- return (1 == sscanf(x, "%2x", &i)) ? os_toebcdic[i&0xFF] : 0;
-#endif /*CHARSET_EBCDIC*/
-}
-
-void ap_proxy_c2hex(int ch, char *x)
-{
-#ifndef CHARSET_EBCDIC
- int i;
-
- x[0] = '%';
- i = (ch & 0xF0) >> 4;
- if (i >= 10)
- x[1] = ('A' - 10) + i;
- else
- x[1] = '0' + i;
-
- i = ch & 0x0F;
- if (i >= 10)
- x[2] = ('A' - 10) + i;
- else
- x[2] = '0' + i;
-#else /*CHARSET_EBCDIC*/
- static const char ntoa[] = { "0123456789ABCDEF" };
- ch &= 0xFF;
- x[0] = '%';
- x[1] = ntoa[(os_toascii[ch]>>4)&0x0F];
- x[2] = ntoa[os_toascii[ch]&0x0F];
- x[3] = '\0';
-#endif /*CHARSET_EBCDIC*/
-}
-
-/*
- * canonicalise a URL-encoded string
- */
-
-/*
- * Convert a URL-encoded string to canonical form.
- * It decodes characters which need not be encoded,
- * and encodes those which must be encoded, and does not touch
- * those which must not be touched.
- */
-char *
- ap_proxy_canonenc(ap_context_t *p, const char *x, int len, enum enctype t, int isenc)
-{
- int i, j, ch;
- char *y;
- const char *allowed; /* characters which should not be encoded */
- const char *reserved; /* characters which much not be en/de-coded */
-
-/* N.B. in addition to :@&=, this allows ';' in an http path
- * and '?' in an ftp path -- this may be revised
- *
- * Also, it makes a '+' character in a search string reserved, as
- * it may be form-encoded. (Although RFC 1738 doesn't allow this -
- * it only permits ; / ? : @ = & as reserved chars.)
- */
- if (t == enc_path)
- allowed = "$-_.+!*'(),;:@&=";
- else if (t == enc_search)
- allowed = "$-_.!*'(),;:@&=";
- else if (t == enc_user)
- allowed = "$-_.+!*'(),;@&=";
- else if (t == enc_fpath)
- allowed = "$-_.+!*'(),?:@&=";
- else /* if (t == enc_parm) */
- allowed = "$-_.+!*'(),?/:@&=";
-
- if (t == enc_path)
- reserved = "/";
- else if (t == enc_search)
- reserved = "+";
- else
- reserved = "";
-
- y = ap_palloc(p, 3 * len + 1);
-
- for (i = 0, j = 0; i < len; i++, j++) {
-/* always handle '/' first */
- ch = x[i];
- if (strchr(reserved, ch)) {
- y[j] = ch;
- continue;
- }
-/* decode it if not already done */
- if (isenc && ch == '%') {
- if (!ap_isxdigit(x[i + 1]) || !ap_isxdigit(x[i + 2]))
- return NULL;
- ch = ap_proxy_hex2c(&x[i + 1]);
- i += 2;
- if (ch != 0 && strchr(reserved, ch)) { /* keep it encoded */
- ap_proxy_c2hex(ch, &y[j]);
- j += 2;
- continue;
- }
- }
-/* recode it, if necessary */
- if (!ap_isalnum(ch) && !strchr(allowed, ch)) {
- ap_proxy_c2hex(ch, &y[j]);
- j += 2;
- }
- else
- y[j] = ch;
- }
- y[j] = '\0';
- return y;
-}
-
-/*
- * Parses network-location.
- * urlp on input the URL; on output the path, after the leading /
- * user NULL if no user/password permitted
- * password holder for password
- * host holder for host
- * port port number; only set if one is supplied.
- *
- * Returns an error string.
- */
-char *
- ap_proxy_canon_netloc(ap_context_t *p, char **const urlp, char **userp,
- char **passwordp, char **hostp, int *port)
-{
- int i;
- char *strp, *host, *url = *urlp;
- char *user = NULL, *password = NULL;
-
- if (url[0] != '/' || url[1] != '/')
- return "Malformed URL";
- host = url + 2;
- url = strchr(host, '/');
- if (url == NULL)
- url = "";
- else
- *(url++) = '\0'; /* skip seperating '/' */
-
- /* find _last_ '@' since it might occur in user/password part */
- strp = strrchr(host, '@');
-
- if (strp != NULL) {
- *strp = '\0';
- user = host;
- host = strp + 1;
-
-/* find password */
- strp = strchr(user, ':');
- if (strp != NULL) {
- *strp = '\0';
- password = ap_proxy_canonenc(p, strp + 1, strlen(strp + 1), enc_user, 1);
- if (password == NULL)
- return "Bad %-escape in URL (password)";
- }
-
- user = ap_proxy_canonenc(p, user, strlen(user), enc_user, 1);
- if (user == NULL)
- return "Bad %-escape in URL (username)";
- }
- if (userp != NULL) {
- *userp = user;
- }
- if (passwordp != NULL) {
- *passwordp = password;
- }
-
- strp = strrchr(host, ':');
- if (strp != NULL) {
- *(strp++) = '\0';
-
- for (i = 0; strp[i] != '\0'; i++)
- if (!ap_isdigit(strp[i]))
- break;
-
- /* if (i == 0) the no port was given; keep default */
- if (strp[i] != '\0') {
- return "Bad port number in URL";
- } else if (i > 0) {
- *port = atoi(strp);
- if (*port > 65535)
- return "Port number in URL > 65535";
- }
- }
- ap_str_tolower(host); /* DNS names are case insensitive */
- if (*host == '\0')
- return "Missing host in URL";
-/* check hostname syntax */
- for (i = 0; host[i] != '\0'; i++)
- if (!ap_isdigit(host[i]) && host[i] != '.')
- break;
- /* must be an IP address */
-#ifdef WIN32
- if (host[i] == '\0' && (inet_addr(host) == -1))
-#else
- if (host[i] == '\0' && (ap_inet_addr(host) == -1 || inet_network(host) == -1))
-#endif
- {
- return "Bad IP address in URL";
- }
-
-/* if (strchr(host,'.') == NULL && domain != NULL)
- host = pstrcat(p, host, domain, NULL);
- */
- *urlp = url;
- *hostp = host;
-
- return NULL;
-}
-
-static const char * const lwday[7] =
-{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
-
-/*
- * If the date is a valid RFC 850 date or asctime() date, then it
- * is converted to the RFC 1123 format, otherwise it is not modified.
- * This routine is not very fast at doing conversions, as it uses
- * sscanf and sprintf. However, if the date is already correctly
- * formatted, then it exits very quickly.
- */
-const char *
- ap_proxy_date_canon(ap_context_t *p, const char *x)
-{
- int wk, mday, year, hour, min, sec, mon;
- char *q, month[4], zone[4], week[4];
-
- q = strchr(x, ',');
- /* check for RFC 850 date */
- if (q != NULL && q - x > 3 && q[1] == ' ') {
- *q = '\0';
- for (wk = 0; wk < 7; wk++)
- if (strcmp(x, lwday[wk]) == 0)
- break;
- *q = ',';
- if (wk == 7)
- return x; /* not a valid date */
- if (q[4] != '-' || q[8] != '-' || q[11] != ' ' || q[14] != ':' ||
- q[17] != ':' || strcmp(&q[20], " GMT") != 0)
- return x;
- if (sscanf(q + 2, "%u-%3s-%u %u:%u:%u %3s", &mday, month, &year,
- &hour, &min, &sec, zone) != 7)
- return x;
- if (year < 70)
- year += 2000;
- else
- year += 1900;
- }
- else {
-/* check for acstime() date */
- if (x[3] != ' ' || x[7] != ' ' || x[10] != ' ' || x[13] != ':' ||
- x[16] != ':' || x[19] != ' ' || x[24] != '\0')
- return x;
- if (sscanf(x, "%3s %3s %u %u:%u:%u %u", week, month, &mday, &hour,
- &min, &sec, &year) != 7)
- return x;
- for (wk = 0; wk < 7; wk++)
- if (strcmp(week, ap_day_snames[wk]) == 0)
- break;
- if (wk == 7)
- return x;
- }
-
-/* check date */
- for (mon = 0; mon < 12; mon++)
- if (strcmp(month, ap_month_snames[mon]) == 0)
- break;
- if (mon == 12)
- return x;
-
- q = ap_palloc(p, 30);
- ap_snprintf(q, 30, "%s, %.2d %s %d %.2d:%.2d:%.2d GMT", ap_day_snames[wk], mday,
- ap_month_snames[mon], year, hour, min, sec);
- return q;
-}
-
-
-/* NOTE: This routine is taken from http_protocol::getline()
- * because the old code found in the proxy module was too
- * difficult to understand and maintain.
- */
-/* Get a line of protocol input, including any continuation lines
- * caused by MIME folding (or broken clients) if fold != 0, and place it
- * in the buffer s, of size n bytes, without the ending newline.
- *
- * Returns -1 on error, or the length of s.
- *
- * Note: Because bgets uses 1 char for newline and 1 char for NUL,
- * the most we can get is (n - 2) actual characters if it
- * was ended by a newline, or (n - 1) characters if the line
- * length exceeded (n - 1). So, if the result == (n - 1),
- * then the actual input line exceeded the buffer length,
- * and it would be a good idea for the caller to puke 400 or 414.
- */
-static int proxy_getline(char *s, int n, BUFF *in, int fold)
-{
- char *pos, next;
- int retval;
- int total = 0;
-
- pos = s;
-
- do {
- retval = ap_bgets(pos, n, in); /* retval == -1 if error, 0 if EOF */
-
- if (retval <= 0)
- return ((retval < 0) && (total == 0)) ? -1 : total;
-
- /* retval is the number of characters read, not including NUL */
-
- n -= retval; /* Keep track of how much of s is full */
- pos += (retval - 1); /* and where s ends */
- total += retval; /* and how long s has become */
-
- if (*pos == '\n') { /* Did we get a full line of input? */
- *pos = '\0';
- --total;
- ++n;
- }
- else
- return total; /* if not, input line exceeded buffer size */
-
- /* Continue appending if line folding is desired and
- * the last line was not empty and we have room in the buffer and
- * the next line begins with a continuation character.
- */
- } while (fold && (retval != 1) && (n > 1)
- && (ap_blookc(&next, in) == 1)
- && ((next == ' ') || (next == '\t')));
-
- return total;
-}
-
-
-/*
- * Reads headers from a buffer and returns an array of headers.
- * Returns NULL on file error
- * This routine tries to deal with too long lines and continuation lines.
- * @@@: XXX: FIXME: currently the headers are passed thru un-merged.
- * Is that okay, or should they be collapsed where possible?
- */
-table *ap_proxy_read_headers(request_rec *r, char *buffer, int size, BUFF *f)
-{
- ap_table_t *resp_hdrs;
- int len;
- char *value, *end;
- char field[MAX_STRING_LEN];
-
- resp_hdrs = ap_make_table(r->pool, 20);
-
- /*
- * Read header lines until we get the empty separator line, a read error,
- * the connection closes (EOF), or we timeout.
- */
- while ((len = proxy_getline(buffer, size, f, 1)) > 0) {
-
- if (!(value = strchr(buffer, ':'))) { /* Find the colon separator */
-
- /* Buggy MS IIS servers sometimes return invalid headers
- * (an extra "HTTP/1.0 200, OK" line sprinkled in between
- * the usual MIME headers). Try to deal with it in a sensible
- * way, but log the fact.
- * XXX: The mask check is buggy if we ever see an HTTP/1.10 */
-
- if (!ap_checkmask(buffer, "HTTP/#.# ###*")) {
- /* Nope, it wasn't even an extra HTTP header. Give up. */
- return NULL;
- }
-
- ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, r->server,
- "proxy: Ignoring duplicate HTTP header "
- "returned by %s (%s)", r->uri, r->method);
- continue;
- }
-
- *value = '\0';
- ++value;
- /* XXX: RFC2068 defines only SP and HT as whitespace, this test is
- * wrong... and so are many others probably.
- */
- while (ap_isspace(*value))
- ++value; /* Skip to start of value */
-
- /* should strip trailing whitespace as well */
- for (end = &value[strlen(value)-1]; end > value && ap_isspace(*end); --end)
- *end = '\0';
-
- ap_table_add(resp_hdrs, buffer, value);
-
- /* the header was too long; at the least we should skip extra data */
- if (len >= size - 1) {
- while ((len = proxy_getline(field, MAX_STRING_LEN, f, 1))
- >= MAX_STRING_LEN - 1) {
- /* soak up the extra data */
- }
- if (len == 0) /* time to exit the larger loop as well */
- break;
- }
- }
- return resp_hdrs;
-}
-
-long int ap_proxy_send_fb(BUFF *f, request_rec *r, cache_req *c)
-{
- int ok;
- char buf[IOBUFSIZE];
- long total_bytes_rcvd;
- register int n, o, w;
- conn_rec *con = r->connection;
- int alternate_timeouts = 1; /* 1 if we alternate between soft & hard timeouts */
-
- total_bytes_rcvd = 0;
- if (c != NULL)
- c->written = 0;
-
-#ifdef CHARSET_EBCDIC
- /* The cache copy is ASCII, not EBCDIC, even for text/html) */
- ap_bsetflag(f, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 0);
- if (c != NULL && c->fp != NULL)
- ap_bsetflag(c->fp, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 0);
- ap_bsetflag(con->client, B_ASCII2EBCDIC|B_EBCDIC2ASCII, 0);
-#endif
-
- /* Since we are reading from one buffer and writing to another,
- * it is unsafe to do a soft_timeout here, at least until the proxy
- * has its own timeout handler which can set both buffers to EOUT.
- */
-
-#ifdef WIN32
- /* works fine under win32, so leave it */
-#else
- /* CHECKME! Since hard_timeout won't work in unix on sends with partial
- * cache completion, we have to alternate between hard_timeout
- * for reads, and soft_timeout for send. This is because we need
- * to get a return from ap_bwrite to be able to continue caching.
- * BUT, if we *can't* continue anyway, just use hard_timeout.
- */
-
- if (c == NULL || c->len <= 0 || c->cache_completion == 1.0) {
- alternate_timeouts = 0;
- }
-#endif
-
- /* Loop and ap_bread() while we can successfully read and write,
- * or (after the client aborted) while we can successfully
- * read and finish the configured cache_completion.
- */
- for (ok = 1; ok; ) {
- /* Read block from server */
- n = ap_bread(f, buf, IOBUFSIZE);
-
- if (n == -1) { /* input error */
- if (c != NULL) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
- "proxy: error reading from %s", c->url);
- c = ap_proxy_cache_error(c);
- }
- break;
- }
- if (n == 0)
- break; /* EOF */
- o = 0;
- total_bytes_rcvd += n;
-
- /* Write to cache first. */
- /*@@@ XXX FIXME: Assuming that writing the cache file won't time out?!!? */
- if (c != NULL && c->fp != NULL) {
- if (ap_bwrite(c->fp, &buf[0], n) != n) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, c->req,
- "proxy: error writing to %s", c->tempfile);
- c = ap_proxy_cache_error(c);
- } else {
- c->written += n;
- }
- }
-
- /* Write the block to the client, detect aborted transfers */
- while (!con->aborted && n > 0) {
- w = ap_bwrite(con->client, &buf[o], n);
-
- if (w <= 0) {
- if (c != NULL && c->fp != NULL) {
- /* when a send failure occurs, we need to decide
- * whether to continue loading and caching the
- * document, or to abort the whole thing
- */
- ok = (c->len > 0) &&
- (c->cache_completion > 0) &&
- (c->len * c->cache_completion < total_bytes_rcvd);
-
- if (! ok) {
- ap_pclosef(c->req->pool, c->fp->fd);
- c->fp = NULL;
- unlink(c->tempfile);
- c = NULL;
- }
- }
- con->aborted = 1;
- break;
- }
- n -= w;
- o += w;
- } /* while client alive and more data to send */
- } /* loop and ap_bread while "ok" */
-
- if (!con->aborted)
- ap_bflush(con->client);
-
- return total_bytes_rcvd;
-}
-
-/*
- * Sends response line and headers. Uses the client fd and the
- * headers_out array from the passed request_rec to talk to the client
- * and to properly set the headers it sends for things such as logging.
- *
- * A timeout should be set before calling this routine.
- */
-void ap_proxy_send_headers(request_rec *r, const char *respline, ap_table_t *t)
-{
- int i;
- BUFF *fp = r->connection->client;
- table_entry *elts = (table_entry *) ap_table_elts(t)->elts;
-
- ap_bvputs(fp, respline, CRLF, NULL);
-
- for (i = 0; i < ap_table_elts(t)->nelts; ++i) {
- if (elts[i].key != NULL) {
- ap_bvputs(fp, elts[i].key, ": ", elts[i].val, CRLF, NULL);
- ap_table_addn(r->headers_out, elts[i].key, elts[i].val);
- }
- }
-
- ap_bputs(CRLF, fp);
-}
-
-
-/*
- * list is a comma-separated list of case insensitive tokens, with
- * optional whitespace around the tokens.
- * The return returns 1 if the token val is found in the list, or 0
- * otherwise.
- */
-int ap_proxy_liststr(const char *list, const char *val)
-{
- int len, i;
- const char *p;
-
- len = strlen(val);
-
- while (list != NULL) {
- p = strchr(list, ',');
- if (p != NULL) {
- i = p - list;
- do
- p++;
- while (ap_isspace(*p));
- }
- else
- i = strlen(list);
-
- while (i > 0 && ap_isspace(list[i - 1]))
- i--;
- if (i == len && strncasecmp(list, val, len) == 0)
- return 1;
- list = p;
- }
- return 0;
-}
-
-#ifdef CASE_BLIND_FILESYSTEM
-
-/*
- * On some platforms, the file system is NOT case sensitive. So, a == A
- * need to map to smaller set of characters
- */
-void ap_proxy_hash(const char *it, char *val, int ndepth, int nlength)
-{
- AP_MD5_CTX context;
- unsigned char digest[16];
- char tmp[26];
- int i, k, d;
- unsigned int x;
- static const char enc_table[32] = "abcdefghijklmnopqrstuvwxyz012345";
-
- ap_MD5Init(&context);
- ap_MD5Update(&context, (const unsigned char *) it, strlen(it));
- ap_MD5Final(digest, &context);
-
-/* encode 128 bits as 26 characters, using a modified uuencoding */
-/* the encoding is 5 bytes -> 8 characters
- * i.e. 128 bits is 3 x 5 bytes + 1 byte -> 3 * 8 characters + 2 characters
- */
- for (i = 0, k = 0; i < 15; i += 5) {
- x = (digest[i] << 24) | (digest[i + 1] << 16) | (digest[i + 2] << 8) | digest[i + 3];
- tmp[k++] = enc_table[x >> 27];
- tmp[k++] = enc_table[(x >> 22) & 0x1f];
- tmp[k++] = enc_table[(x >> 17) & 0x1f];
- tmp[k++] = enc_table[(x >> 12) & 0x1f];
- tmp[k++] = enc_table[(x >> 7) & 0x1f];
- tmp[k++] = enc_table[(x >> 2) & 0x1f];
- x = ((x & 0x3) << 8) | digest[i + 4];
- tmp[k++] = enc_table[x >> 5];
- tmp[k++] = enc_table[x & 0x1f];
- }
-/* one byte left */
- x = digest[15];
- tmp[k++] = enc_table[x >> 3]; /* use up 5 bits */
- tmp[k++] = enc_table[x & 0x7];
- /* now split into directory levels */
-
- for (i = k = d = 0; d < ndepth; ++d) {
- memcpy(&val[i], &tmp[k], nlength);
- k += nlength;
- val[i + nlength] = '/';
- i += nlength + 1;
- }
- memcpy(&val[i], &tmp[k], 26 - k);
- val[i + 26 - k] = '\0';
-}
-
-#else
-
-void ap_proxy_hash(const char *it, char *val, int ndepth, int nlength)
-{
- AP_MD5_CTX context;
- unsigned char digest[16];
- char tmp[22];
- int i, k, d;
- unsigned int x;
-#if defined(AIX) && defined(__ps2__)
- /* Believe it or not, AIX 1.x does not allow you to name a file '@',
- * so hack around it in the encoding. */
- static const char enc_table[64] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_%";
-#else
- static const char enc_table[64] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_@";
-#endif
-
- ap_MD5Init(&context);
- ap_MD5Update(&context, (const unsigned char *) it, strlen(it));
- ap_MD5Final(digest, &context);
-
-/* encode 128 bits as 22 characters, using a modified uuencoding */
-/* the encoding is 3 bytes -> 4 characters
- * i.e. 128 bits is 5 x 3 bytes + 1 byte -> 5 * 4 characters + 2 characters
- */
- for (i = 0, k = 0; i < 15; i += 3) {
- x = (digest[i] << 16) | (digest[i + 1] << 8) | digest[i + 2];
- tmp[k++] = enc_table[x >> 18];
- tmp[k++] = enc_table[(x >> 12) & 0x3f];
- tmp[k++] = enc_table[(x >> 6) & 0x3f];
- tmp[k++] = enc_table[x & 0x3f];
- }
-/* one byte left */
- x = digest[15];
- tmp[k++] = enc_table[x >> 2]; /* use up 6 bits */
- tmp[k++] = enc_table[(x << 4) & 0x3f];
- /* now split into directory levels */
-
- for (i = k = d = 0; d < ndepth; ++d) {
- memcpy(&val[i], &tmp[k], nlength);
- k += nlength;
- val[i + nlength] = '/';
- i += nlength + 1;
- }
- memcpy(&val[i], &tmp[k], 22 - k);
- val[i + 22 - k] = '\0';
-}
-
-#endif /* CASE_BLIND_FILESYSTEM */
-
-/*
- * Converts 8 hex digits to a time integer
- */
-int ap_proxy_hex2sec(const char *x)
-{
- int i, ch;
- unsigned int j;
-
- for (i = 0, j = 0; i < 8; i++) {
- ch = x[i];
- j <<= 4;
- if (ap_isdigit(ch))
- j |= ch - '0';
- else if (ap_isupper(ch))
- j |= ch - ('A' - 10);
- else
- j |= ch - ('a' - 10);
- }
- if (j == 0xffffffff)
- return -1; /* so that it works with 8-byte ints */
- else
- return j;
-}
-
-/*
- * Converts a time integer to 8 hex digits
- */
-void ap_proxy_sec2hex(int t, char *y)
-{
- int i, ch;
- unsigned int j = t;
-
- for (i = 7; i >= 0; i--) {
- ch = j & 0xF;
- j >>= 4;
- if (ch >= 10)
- y[i] = ch + ('A' - 10);
- else
- y[i] = ch + '0';
- }
- y[8] = '\0';
-}
-
-
-cache_req *ap_proxy_cache_error(cache_req *c)
-{
- if (c != NULL) {
- if (c->fp != NULL) {
- ap_pclosef(c->req->pool, c->fp->fd);
- c->fp = NULL;
- }
- if (c->tempfile) unlink(c->tempfile);
- }
- return NULL;
-}
-
-int ap_proxyerror(request_rec *r, int statuscode, const char *message)
-{
- ap_table_setn(r->notes, "error-notes",
- ap_pstrcat(r->pool,
- "The proxy server could not handle the request "
- "<EM><A HREF=\"", r->uri, "\">",
- r->method, "&nbsp;", r->uri, "</A></EM>.<P>\n"
- "Reason: <STRONG>", message, "</STRONG>", NULL));
-
- /* Allow the "error-notes" string to be printed by ap_send_error_response() */
- ap_table_setn(r->notes, "verbose-error-to", ap_pstrdup(r->pool, "*"));
-
- r->status_line = ap_psprintf(r->pool, "%3.3u Proxy Error", statuscode);
- return statuscode;
-}
-
-/*
- * This routine returns its own error message
- */
-const char *
- ap_proxy_host2addr(const char *host, struct hostent *reqhp)
-{
- int i;
- struct hostent *hp;
-/* XXX - Either get rid of TLS, or use pthread/APR functions */
-#define APACHE_TLS
- static APACHE_TLS struct hostent hpbuf;
- static APACHE_TLS u_long ipaddr;
- static APACHE_TLS char *charpbuf[2];
-
- for (i = 0; host[i] != '\0'; i++)
- if (!ap_isdigit(host[i]) && host[i] != '.')
- break;
-
- if (host[i] != '\0') {
- hp = gethostbyname(host);
- if (hp == NULL)
- return "Host not found";
- }
- else {
- ipaddr = ap_inet_addr(host);
- hp = gethostbyaddr((char *) &ipaddr, sizeof(u_long), AF_INET);
- if (hp == NULL) {
- memset(&hpbuf, 0, sizeof(hpbuf));
- hpbuf.h_name = 0;
- hpbuf.h_addrtype = AF_INET;
- hpbuf.h_length = sizeof(u_long);
- hpbuf.h_addr_list = charpbuf;
- hpbuf.h_addr_list[0] = (char *) &ipaddr;
- hpbuf.h_addr_list[1] = 0;
- hp = &hpbuf;
- }
- }
- *reqhp = *hp;
- return NULL;
-}
-
-static const char *
- proxy_get_host_of_request(request_rec *r)
-{
- char *url, *user = NULL, *password = NULL, *err, *host;
- int port = -1;
-
- if (r->hostname != NULL)
- return r->hostname;
-
- /* Set url to the first char after "scheme://" */
- if ((url = strchr(r->uri, ':')) == NULL
- || url[1] != '/' || url[2] != '/')
- return NULL;
-
- url = ap_pstrdup(r->pool, &url[1]); /* make it point to "//", which is what proxy_canon_netloc expects */
-
- err = ap_proxy_canon_netloc(r->pool, &url, &user, &password, &host, &port);
-
- if (err != NULL)
- ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r,
- "%s", err);
-
- r->hostname = host;
-
- return host; /* ought to return the port, too */
-}
-
-/* Return TRUE if addr represents an IP address (or an IP network address) */
-int ap_proxy_is_ipaddr(struct dirconn_entry *This, ap_context_t *p)
-{
- const char *addr = This->name;
- long ip_addr[4];
- int i, quads;
- long bits;
-
- /* if the address is given with an explicit netmask, use that */
- /* Due to a deficiency in ap_inet_addr(), it is impossible to parse */
- /* "partial" addresses (with less than 4 quads) correctly, i.e. */
- /* 192.168.123 is parsed as 192.168.0.123, which is not what I want. */
- /* I therefore have to parse the IP address manually: */
- /*if (proxy_readmask(This->name, &This->addr.s_addr, &This->mask.s_addr) == 0) */
- /* addr and mask were set by proxy_readmask() */
- /*return 1; */
-
- /* Parse IP addr manually, optionally allowing */
- /* abbreviated net addresses like 192.168. */
-
- /* Iterate over up to 4 (dotted) quads. */
- for (quads = 0; quads < 4 && *addr != '\0'; ++quads) {
- char *tmp;
-
- if (*addr == '/' && quads > 0) /* netmask starts here. */
- break;
-
- if (!ap_isdigit(*addr))
- return 0; /* no digit at start of quad */
-
- ip_addr[quads] = strtol(addr, &tmp, 0);
-
- if (tmp == addr) /* expected a digit, found something else */
- return 0;
-
- if (ip_addr[quads] < 0 || ip_addr[quads] > 255) {
- /* invalid octet */
- return 0;
- }
-
- addr = tmp;
-
- if (*addr == '.' && quads != 3)
- ++addr; /* after the 4th quad, a dot would be illegal */
- }
-
- for (This->addr.s_addr = 0, i = 0; i < quads; ++i)
- This->addr.s_addr |= htonl(ip_addr[i] << (24 - 8 * i));
-
- if (addr[0] == '/' && ap_isdigit(addr[1])) { /* net mask follows: */
- char *tmp;
-
- ++addr;
-
- bits = strtol(addr, &tmp, 0);
-
- if (tmp == addr) /* expected a digit, found something else */
- return 0;
-
- addr = tmp;
-
- if (bits < 0 || bits > 32) /* netmask must be between 0 and 32 */
- return 0;
-
- }
- else {
- /* Determine (i.e., "guess") netmask by counting the */
- /* number of trailing .0's; reduce #quads appropriately */
- /* (so that 192.168.0.0 is equivalent to 192.168.) */
- while (quads > 0 && ip_addr[quads - 1] == 0)
- --quads;
-
- /* "IP Address should be given in dotted-quad form, optionally followed by a netmask (e.g., 192.168.111.0/24)"; */
- if (quads < 1)
- return 0;
-
- /* every zero-byte counts as 8 zero-bits */
- bits = 8 * quads;
-
- if (bits != 32) /* no warning for fully qualified IP address */
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Warning: NetMask not supplied with IP-Addr; guessing: %s/%ld",
- inet_ntoa(This->addr), bits);
- }
-
- This->mask.s_addr = htonl(INADDR_NONE << (32 - bits));
-
- if (*addr == '\0' && (This->addr.s_addr & ~This->mask.s_addr) != 0) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Warning: NetMask and IP-Addr disagree in %s/%ld\n",
- inet_ntoa(This->addr), bits);
- This->addr.s_addr &= This->mask.s_addr;
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " Set to %s/%ld",
- inet_ntoa(This->addr), bits);
- }
-
- if (*addr == '\0') {
- This->matcher = proxy_match_ipaddr;
- return 1;
- }
- else
- return (*addr == '\0'); /* okay iff we've parsed the whole string */
-}
-
-/* Return TRUE if addr represents an IP address (or an IP network address) */
-static int proxy_match_ipaddr(struct dirconn_entry *This, request_rec *r)
-{
- int i;
- int ip_addr[4];
- struct in_addr addr;
- struct in_addr *ip_list;
- char **ip_listptr;
- const char *found;
- const char *host = proxy_get_host_of_request(r);
-
- if (host == NULL) /* oops! */
- return 0;
-
- memset(&addr, '\0', sizeof addr);
- memset(ip_addr, '\0', sizeof ip_addr);
-
- if (4 == sscanf(host, "%d.%d.%d.%d", &ip_addr[0], &ip_addr[1], &ip_addr[2], &ip_addr[3])) {
- for (addr.s_addr = 0, i = 0; i < 4; ++i)
- addr.s_addr |= htonl(ip_addr[i] << (24 - 8 * i));
-
- if (This->addr.s_addr == (addr.s_addr & This->mask.s_addr)) {
-#if DEBUGGING
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "1)IP-Match: %s[%s] <-> ", host, inet_ntoa(addr));
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s/", inet_ntoa(This->addr));
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s", inet_ntoa(This->mask));
-#endif
- return 1;
- }
-#if DEBUGGING
- else {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "1)IP-NoMatch: %s[%s] <-> ", host, inet_ntoa(addr));
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s/", inet_ntoa(This->addr));
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s", inet_ntoa(This->mask));
- }
-#endif
- }
- else {
- struct hostent the_host;
-
- memset(&the_host, '\0', sizeof the_host);
- found = ap_proxy_host2addr(host, &the_host);
-
- if (found != NULL) {
-#if DEBUGGING
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "2)IP-NoMatch: hostname=%s msg=%s", host, found);
-#endif
- return 0;
- }
-
- if (the_host.h_name != NULL)
- found = the_host.h_name;
- else
- found = host;
-
- /* Try to deal with multiple IP addr's for a host */
- for (ip_listptr = the_host.h_addr_list; *ip_listptr; ++ip_listptr) {
- ip_list = (struct in_addr *) *ip_listptr;
- if (This->addr.s_addr == (ip_list->s_addr & This->mask.s_addr)) {
-#if DEBUGGING
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "3)IP-Match: %s[%s] <-> ", found, inet_ntoa(*ip_list));
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s/", inet_ntoa(This->addr));
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s", inet_ntoa(This->mask));
-#endif
- return 1;
- }
-#if DEBUGGING
- else {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "3)IP-NoMatch: %s[%s] <-> ", found, inet_ntoa(*ip_list));
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s/", inet_ntoa(This->addr));
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s", inet_ntoa(This->mask));
- }
-#endif
- }
- }
-
- return 0;
-}
-
-/* Return TRUE if addr represents a domain name */
-int ap_proxy_is_domainname(struct dirconn_entry *This, ap_context_t *p)
-{
- char *addr = This->name;
- int i;
-
- /* Domain name must start with a '.' */
- if (addr[0] != '.')
- return 0;
-
- /* rfc1035 says DNS names must consist of "[-a-zA-Z0-9]" and '.' */
- for (i = 0; ap_isalnum(addr[i]) || addr[i] == '-' || addr[i] == '.'; ++i)
- continue;
-
-#if 0
- if (addr[i] == ':') {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "@@@@ handle optional port in proxy_is_domainname()");
- /* @@@@ handle optional port */
- }
-#endif
-
- if (addr[i] != '\0')
- return 0;
-
- /* Strip trailing dots */
- for (i = strlen(addr) - 1; i > 0 && addr[i] == '.'; --i)
- addr[i] = '\0';
-
- This->matcher = proxy_match_domainname;
- return 1;
-}
-
-/* Return TRUE if host "host" is in domain "domain" */
-static int proxy_match_domainname(struct dirconn_entry *This, request_rec *r)
-{
- const char *host = proxy_get_host_of_request(r);
- int d_len = strlen(This->name), h_len;
-
- if (host == NULL) /* some error was logged already */
- return 0;
-
- h_len = strlen(host);
-
- /* @@@ do this within the setup? */
- /* Ignore trailing dots in domain comparison: */
- while (d_len > 0 && This->name[d_len - 1] == '.')
- --d_len;
- while (h_len > 0 && host[h_len - 1] == '.')
- --h_len;
- return h_len > d_len
- && strncasecmp(&host[h_len - d_len], This->name, d_len) == 0;
-}
-
-/* Return TRUE if addr represents a host name */
-int ap_proxy_is_hostname(struct dirconn_entry *This, ap_context_t *p)
-{
- struct hostent host;
- char *addr = This->name;
- int i;
-
- /* Host names must not start with a '.' */
- if (addr[0] == '.')
- return 0;
-
- /* rfc1035 says DNS names must consist of "[-a-zA-Z0-9]" and '.' */
- for (i = 0; ap_isalnum(addr[i]) || addr[i] == '-' || addr[i] == '.'; ++i);
-
-#if 0
- if (addr[i] == ':') {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "@@@@ handle optional port in proxy_is_hostname()");
- /* @@@@ handle optional port */
- }
-#endif
-
- if (addr[i] != '\0' || ap_proxy_host2addr(addr, &host) != NULL)
- return 0;
-
- This->hostentry = ap_pduphostent (p, &host);
-
- /* Strip trailing dots */
- for (i = strlen(addr) - 1; i > 0 && addr[i] == '.'; --i)
- addr[i] = '\0';
-
- This->matcher = proxy_match_hostname;
- return 1;
-}
-
-/* Return TRUE if host "host" is equal to host2 "host2" */
-static int proxy_match_hostname(struct dirconn_entry *This, request_rec *r)
-{
- char *host = This->name;
- const char *host2 = proxy_get_host_of_request(r);
- int h2_len;
- int h1_len;
-
- if (host == NULL || host2 == NULL)
- return 0; /* oops! */
-
- h2_len = strlen(host2);
- h1_len = strlen(host);
-
-#if 0
- unsigned long *ip_list;
-
- /* Try to deal with multiple IP addr's for a host */
- for (ip_list = *This->hostentry->h_addr_list; *ip_list != 0UL; ++ip_list)
- if (*ip_list == ? ? ? ? ? ? ? ? ? ? ? ? ?)
- return 1;
-#endif
-
- /* Ignore trailing dots in host2 comparison: */
- while (h2_len > 0 && host2[h2_len - 1] == '.')
- --h2_len;
- while (h1_len > 0 && host[h1_len - 1] == '.')
- --h1_len;
- return h1_len == h2_len
- && strncasecmp(host, host2, h1_len) == 0;
-}
-
-/* Return TRUE if addr is to be matched as a word */
-int ap_proxy_is_word(struct dirconn_entry *This, ap_context_t *p)
-{
- This->matcher = proxy_match_word;
- return 1;
-}
-
-/* Return TRUE if string "str2" occurs literally in "str1" */
-static int proxy_match_word(struct dirconn_entry *This, request_rec *r)
-{
- const char *host = proxy_get_host_of_request(r);
- return host != NULL && strstr(host, This->name) != NULL;
-}
-
-int ap_proxy_doconnect(int sock, struct sockaddr_in *addr, request_rec *r)
-{
- int i;
-
- do {
- i = connect(sock, (struct sockaddr *) addr, sizeof(struct sockaddr_in));
-#ifdef WIN32
- if (i == SOCKET_ERROR)
- errno = WSAGetLastError();
-#endif /* WIN32 */
- } while (i == -1 && errno == EINTR);
- if (i == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "proxy connect to %s port %d failed",
- inet_ntoa(addr->sin_addr), ntohs(addr->sin_port));
- }
-
- return i;
-}
-
-/* This function is called by ap_table_do() for all header lines */
-/* (from proxy_http.c and proxy_ftp.c) */
-/* It is passed a table_do_args struct pointer and a MIME field and value pair */
-int ap_proxy_send_hdr_line(void *p, const char *key, const char *value)
-{
- struct tbl_do_args *parm = (struct tbl_do_args *)p;
-
- if (key == NULL || value == NULL || value[0] == '\0')
- return 1;
- if (!parm->req->assbackwards)
- ap_rvputs(parm->req, key, ": ", value, CRLF, NULL);
- if (parm->cache != NULL && parm->cache->fp != NULL &&
- ap_bvputs(parm->cache->fp, key, ": ", value, CRLF, NULL) == -1) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, parm->cache->req,
- "proxy: error writing header to %s", parm->cache->tempfile);
- parm->cache = ap_proxy_cache_error(parm->cache);
- }
- return 1; /* tell ap_table_do() to continue calling us for more headers */
-}
-
-/* send a text line to one or two BUFF's; return line length */
-unsigned ap_proxy_bputs2(const char *data, BUFF *client, cache_req *cache)
-{
- unsigned len = ap_bputs(data, client);
- if (cache != NULL && cache->fp != NULL)
- ap_bputs(data, cache->fp);
- return len;
-}
-
diff --git a/modules/ssl/.indent.pro b/modules/ssl/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/ssl/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/test/.cvsignore b/modules/test/.cvsignore
deleted file mode 100644
index 8b4c6e3da4..0000000000
--- a/modules/test/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-*.lo
-*.so
diff --git a/modules/test/.indent.pro b/modules/test/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/modules/test/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/modules/test/README b/modules/test/README
deleted file mode 100644
index c61763c1dd..0000000000
--- a/modules/test/README
+++ /dev/null
@@ -1,3 +0,0 @@
-This directory is intended to house modules which are used for testing
-server functionality. They're unsupported, and not guaranteed to remain
-consistant between releases. You're on your own completely with these.
diff --git a/modules/test/mod_rndchunk.c b/modules/test/mod_rndchunk.c
deleted file mode 100644
index 041f1af8f9..0000000000
--- a/modules/test/mod_rndchunk.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * This module is intended to be used for testing chunked encoding. It
- * generates a whole whack of output using ap_bputc() and ap_bputs(). It
- * also exercises start_chunk() and end_chunk() in buff.c. To use it
- * you should use a tool like netcat and the src/test/check_chunked
- * tool. Add something like this to your access.conf file:
- *
- * <Location /rndchunk>
- * SetHandler rndchunk
- * </Location>
- *
- * Then fake requests such as:
- *
- * GET /rndchunk?0,1000000 HTTP/1.1
- * Host: localhost
- *
- * The first arg is the random seed, the second is the number of
- * "things" to do. You should try a few seeds.
- *
- * You should also edit main/buff.c and change DEFAULT_BUFSIZE (and
- * CHUNK_HEADER_SIZE). Small values are particularly useful for
- * finding bugs. Try a few different values.
- *
- * -djg
- */
-
-#include "httpd.h"
-#include "http_protocol.h"
-#include "http_config.h"
-#include "http_main.h"
-
-#define MAX_SEGMENT 32
-#define ONE_WEIGHT (256-32)
-
-static int send_rndchunk(request_rec *r)
-{
- const char *args;
- char *endptr;
- unsigned int seed;
- unsigned int count;
- int i;
- char buf[MAX_SEGMENT + 1];
- unsigned int len;
-
- r->allowed |= (1 << M_GET);
- if (r->method_number != M_GET)
- return DECLINED;
-
- r->content_type = "text/html";
- ap_send_http_header(r);
- if(r->header_only) {
- return 0;
- }
- ap_hard_timeout("send_rndchunk", r);
-
- if (!r->chunked) {
- ap_rputs("Not chunked!", r);
- ap_kill_timeout(r);
- return 0;
- }
-
- args = r->args;
- if (!args) {
-error:
- ap_rputs("Must include args! ... of the form <code>?seed,count</code>", r);
- ap_kill_timeout(r);
- return 0;
- }
- seed = strtol(args, &endptr, 0);
- if (!endptr || *endptr != ',') {
- goto error;
- }
- ++endptr;
- count = strtol(endptr, &endptr, 0);
-
- srandom(seed);
- for (i = 0; i < count; ++i) {
- len = random() % (MAX_SEGMENT + ONE_WEIGHT);
- if (len >= MAX_SEGMENT) {
- ap_rputc((i & 1) ? '0' : '1', r);
- }
- else if (len == 0) {
- /* not a really nice thing to do, but we need to test
- * beginning/ending chunks as well
- */
- ap_bsetflag(r->connection->client, B_CHUNK, 0);
- ap_bsetflag(r->connection->client, B_CHUNK, 1);
- }
- else {
- memset(buf, '2' + len, len);
- buf[len] = 0;
- ap_rputs(buf, r);
- }
- }
- ap_kill_timeout(r);
- return 0;
-}
-
-static const handler_rec rndchunk_handlers[] =
-{
- {"rndchunk", send_rndchunk},
- {NULL}
-};
-
-module rndchunk_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- NULL, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- NULL, /* command ap_table_t */
- rndchunk_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL /* header parser */
-};
diff --git a/modules/test/mod_test_util_uri.c b/modules/test/mod_test_util_uri.c
deleted file mode 100644
index b2fe6571a2..0000000000
--- a/modules/test/mod_test_util_uri.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * This module is intended to test the util_uri routines by parsing a
- * bunch of urls and comparing the results with what we expect to
- * see.
- *
- * Usage:
- *
- * <Location /test-util-uri>
- * SetHandler test-util-uri
- * </Location>
- *
- * Then make a request to /test-util-uri. An html ap_table_t of errors will
- * be output... and a total count of errors.
- */
-
-#include "httpd.h"
-#include "http_protocol.h"
-#include "http_config.h"
-#include "http_main.h"
-
-typedef struct {
- const char *scheme;
- const char *user;
- const char *password;
- const char *hostname;
- const char *port_str;
- const char *path;
- const char *query;
- const char *fragment;
-} test_uri_t;
-
-#define T_scheme 0x01
-#define T_user 0x02
-#define T_password 0x04
-#define T_hostname 0x08
-#define T_port_str 0x10
-#define T_path 0x20
-#define T_query 0x40
-#define T_fragment 0x80
-#define T_MAX 0x100
-
-/* The idea is that we list here a bunch of url pieces that we want
- * stitched together in every way that's valid.
- */
-static const test_uri_t uri_tests[] = {
- { "http", "userid", "passwd", "hostname.goes.here", "80", "/path/goes/here", "query-here", "frag-here" },
- { "http", "", "passwd", "hostname.goes.here", "80", "/path/goes/here", "query-here", "frag-here" },
- { "http", "userid", "", "hostname.goes.here", "80", "/path/goes/here", "query-here", "frag-here" },
- { "http", "userid", "passwd", "", "80", "/path/goes/here", "query-here", "frag-here" },
- { "http", "userid", "passwd", "hostname.goes.here", "", "/path/goes/here", "query-here", "frag-here" },
-#if 0
- /* An empty path means two different things depending on whether this is a
- * relative or an absolute uri... consider <a href="#frag"> versus "GET
- * http://hostname HTTP/1.1". So this is why parse_uri_components returns
- * a NULL for path when it doesn't find one, instead of returning an empty
- * string.
- *
- * We don't really need to test it explicitly since path has no explicit
- * character that indicates its precense, and so we test empty paths all
- * the time by varying T_path in the loop. It would just cost us extra
- * code to special case the empty path string...
- */
- { "http", "userid", "passwd", "hostname.goes.here", "80", "", "query-here", "frag-here" },
-#endif
- { "http", "userid", "passwd", "hostname.goes.here", "80", "/path/goes/here", "", "frag-here" },
- { "http", "userid", "passwd", "hostname.goes.here", "80", "/path/goes/here", "query-here", "" },
- { "https", "user@d", "pa:swd", "hostname.goes.here.", "", "/~path/goes/here", "query&query?crud", "frag-here?baby" }
-
-};
-
-static char *my_stpcpy(char *d, const char *s)
-{
- while((*d = *s)) {
- ++d;
- ++s;
- }
- return d;
-}
-
-/* return the number of failures */
-static unsigned iterate_pieces(request_rec *r, const test_uri_t *pieces, int row)
-{
- unsigned u;
- ap_context_t *sub;
- char *input_uri;
- char *strp;
- uri_components result;
- unsigned expect;
- int status;
- unsigned failures;
-
- failures = 0;
-
- input_uri = ap_palloc(r->pool,
- strlen(pieces->scheme) + 3
- + strlen(pieces->user) + 1
- + strlen(pieces->password) + 1
- + strlen(pieces->hostname) + 1
- + strlen(pieces->port_str) + 1
- + strlen(pieces->path) +
- + strlen(pieces->query) + 1
- + strlen(pieces->fragment) + 1
- + 1);
-
- for (u = 0; u < T_MAX; ++u) {
- strp = input_uri;
- expect = 0;
-
- /* a scheme requires a hostinfo and vice versa */
- /* a hostinfo requires a hostname */
- if (u & (T_scheme|T_user|T_password|T_hostname|T_port_str)) {
- expect |= T_scheme;
- strp = my_stpcpy(strp, pieces->scheme);
- *strp++ = ':';
- *strp++ = '/';
- *strp++ = '/';
- /* can't have password without user */
- if (u & (T_user|T_password)) {
- expect |= T_user;
- strp = my_stpcpy(strp, pieces->user);
- if (u & T_password) {
- expect |= T_password;
- *strp++ = ':';
- strp = my_stpcpy(strp, pieces->password);
- }
- *strp++ = '@';
- }
- expect |= T_hostname;
- strp = my_stpcpy(strp, pieces->hostname);
- if (u & T_port_str) {
- expect |= T_port_str;
- *strp++ = ':';
- strp = my_stpcpy(strp, pieces->port_str);
- }
- }
- if (u & T_path) {
- expect |= T_path;
- strp = my_stpcpy(strp, pieces->path);
- }
- if (u & T_query) {
- expect |= T_query;
- *strp++ = '?';
- strp = my_stpcpy(strp, pieces->query);
- }
- if (u & T_fragment) {
- expect |= T_fragment;
- *strp++ = '#';
- strp = my_stpcpy(strp, pieces->fragment);
- }
- *strp = 0;
-
- sub = ap_make_sub_pool(r->pool);
- status = ap_parse_uri_components(sub, input_uri, &result);
- if (status == HTTP_OK) {
-#define CHECK(f) \
- if ((expect & T_##f) \
- && (result.f == NULL || strcmp(result.f, pieces->f))) { \
- status = HTTP_INTERNAL_SERVER_ERROR; \
- } \
- else if (!(expect & T_##f) && result.f != NULL) { \
- status = HTTP_INTERNAL_SERVER_ERROR; \
- }
- CHECK(scheme)
- CHECK(user)
- CHECK(password)
- CHECK(hostname)
- CHECK(port_str)
- CHECK(path)
- CHECK(query)
- CHECK(fragment)
-#undef CHECK
- }
- if (status != HTTP_OK) {
- ap_rprintf(r, "<tr><td>%d</td><td>0x%02x</td><td>0x%02x</td><td>%d</td><td>\"%s\"</td>", row, u, expect, status, input_uri);
-#define DUMP(f) \
- if (result.f) { \
- ap_rvputs(r, "<td>\"", result.f, "\"<br>", NULL); \
- } \
- else { \
- ap_rputs("<td>NULL<br>", r); \
- } \
- if (expect & T_##f) { \
- ap_rvputs(r, "\"", pieces->f, "\"</td>", NULL); \
- } \
- else { \
- ap_rputs("NULL</td>", r); \
- }
- DUMP(scheme);
- DUMP(user);
- DUMP(password);
- DUMP(hostname);
- DUMP(port_str);
- DUMP(path);
- DUMP(query);
- DUMP(fragment);
-#undef DUMP
- ap_rputs("</tr>\n", r);
- ++failures;
- }
- ap_destroy_pool(sub);
- }
- return failures;
-}
-
-static int test_util_uri(request_rec *r)
-{
- unsigned total_failures;
- int i;
-
- r->allowed |= (1 << M_GET);
- if (r->method_number != M_GET)
- return DECLINED;
-
- r->content_type = "text/html";
- ap_send_http_header(r);
- if(r->header_only) {
- return 0;
- }
- ap_hard_timeout("test_util_uri", r);
-
- ap_rputs(
-DOCTYPE_HTML_2_0 "
-<html><body>
-<p>Key:
-<dl>
-<dt>row
-<dd>entry number in the uri_tests array
-<dt>u
-<dd>fields under test
-<dt>expected
-<dd>fields expected in the result
-<dt>status
-<dd>response from parse_uri_components, or 500 if unexpected results
-<dt>input uri
-<dd>the uri given to parse_uri_components
-</dl>
-<p>The remaining fields are the pieces returned from parse_uri_components, and
-the values we expected for each piece (resp.).
-<p>Only failures are displayed.
-<p>
-<table><tr><th>row</th><th>u</th><th>expect</th><th>status</th><th>input uri</th>", r);
-#define HEADER(f) ap_rprintf(r, "<th>" #f "<br>0x%02x</th>", T_##f)
- HEADER(scheme);
- HEADER(user);
- HEADER(password);
- HEADER(hostname);
- HEADER(port_str);
- HEADER(path);
- HEADER(query);
- HEADER(fragment);
-#undef HEADER
-
- if (r->args) {
- i = atoi(r->args);
- total_failures = iterate_pieces(r, &uri_tests[i], i);
- }
- else {
- total_failures = 0;
- for (i = 0; i < sizeof(uri_tests) / sizeof(uri_tests[0]); ++i) {
- total_failures += iterate_pieces(r, &uri_tests[i], i);
- if (total_failures > 256) {
- ap_rprintf(r, "</table>\n<b>Stopped early to save your browser "
- "from certain death!</b>\nTOTAL FAILURES = %u\n",
- total_failures);
- return OK;
- }
- }
- }
- ap_rprintf(r, "</table>\nTOTAL FAILURES = %u\n", total_failures);
-
- return OK;
-}
-
-static const handler_rec test_util_uri_handlers[] =
-{
- {"test-util-uri", test_util_uri},
- {NULL}
-};
-
-module test_util_uri_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- NULL, /* dir config creater */
- NULL, /* dir merger --- default is to override */
- NULL, /* server config */
- NULL, /* merge server config */
- NULL, /* command ap_table_t */
- test_util_uri_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* fixups */
- NULL, /* logger */
- NULL /* header parser */
-};
diff --git a/os/.cvsignore b/os/.cvsignore
deleted file mode 100644
index f3c7a7c5da..0000000000
--- a/os/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-Makefile
diff --git a/os/.indent.pro b/os/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/os/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/os/Makefile.in b/os/Makefile.in
deleted file mode 100644
index 0e62c951ce..0000000000
--- a/os/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-
-DEPTH = ..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-SUBDIRS = $(OS)
-
-include $(topsrcdir)/build/rules.mk
diff --git a/os/beos/Makefile.in b/os/beos/Makefile.in
deleted file mode 100644
index ea86214b21..0000000000
--- a/os/beos/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-
-DEPTH = ../..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-LTLIBRARY_NAME = libos.la
-LTLIBRARY_SOURCES = os.c os-inline.c beosd.c iol_socket.c
-
-include $(topsrcdir)/build/ltlib.mk
diff --git a/os/beos/beosd.c b/os/beos/beosd.c
deleted file mode 100644
index 6e450cec99..0000000000
--- a/os/beos/beosd.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "beosd.h"
-
-beosd_config_rec beosd_config;
-
-void beosd_detach(void)
-{
- pid_t pgrp;
-
- chdir("/");
-
- RAISE_SIGSTOP(DETACH);
-
- if ((pgrp = setsid()) == -1) {
- perror("setsid");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: setsid failed", ap_server_argv0);
- exit(1);
- }
-
- /* close out the standard file descriptors */
- if (freopen("/dev/null", "r", stdin) == NULL) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: unable to replace stdin with /dev/null: %s",
- ap_server_argv0, strerror(errno));
- /* continue anyhow -- note we can't close out descriptor 0 because we
- * have nothing to replace it with, and if we didn't have a descriptor
- * 0 the next file would be created with that value ... leading to
- * havoc.
- */
- }
- if (freopen("/dev/null", "w", stdout) == NULL) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: unable to replace stdout with /dev/null: %s",
- ap_server_argv0, strerror(errno));
- }
- /* stderr is a tricky one, we really want it to be the error_log,
- * but we haven't opened that yet. So leave it alone for now and it'll
- * be reopened moments later.
- */
-}
-
-/* Set group privileges.
- *
- * Note that we use the username as set in the config files, rather than
- * the lookup of to uid --- the same uid may have multiple passwd entries,
- * with different sets of groups for each.
- */
-
-static int set_group_privs(void)
-{
-#if B_BEOS_VERSION < 0x0460
-
- if (!geteuid()) {
- char *name;
-
- /* Get username if passed as a uid */
-
- if (beosd_config.user_name[0] == '#') {
- struct passwd *ent;
- uid_t uid = atoi(&beosd_config.user_name[1]);
-
- if ((ent = getpwuid(uid)) == NULL) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
- "getpwuid: couldn't determine user name from uid %u, "
- "you probably need to modify the User directive",
- (unsigned)uid);
- return -1;
- }
-
- name = ent->pw_name;
- }
- else
- name = beosd_config.user_name;
-
- if (setgid(beosd_config.group_id) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
- "setgid: unable to set group id to Group %u",
- (unsigned)beosd_config.group_id);
- return -1;
- }
-
- /* Reset `groups' attributes. */
-
- if (initgroups(name, beosd_config.group_id) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
- "initgroups: unable to set groups for User %s "
- "and Group %u", name, (unsigned)beosd_config.group_id);
- return -1;
- }
- }
-#endif
- return 0;
-}
-
-
-int beosd_setup_child(void)
-{
- if (set_group_privs()) {
- return -1;
- }
-
- /* Only try to switch if we're running as root */
- if (!geteuid() && (
- setuid(beosd_config.user_id) == -1)) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
- "setuid: unable to change uid");
- return -1;
- }
- return 0;
-}
-
-
-const char *beosd_set_user(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- beosd_config.user_name = arg;
- beosd_config.user_id = ap_uname2id(arg);
-#if !defined (BIG_SECURITY_HOLE) && !defined (OS2)
- if (beosd_config.user_id == 0) {
- return "Error:\tApache has not been designed to serve pages while\n"
- "\trunning as root. There are known race conditions that\n"
- "\twill allow any local user to read any file on the system.\n"
- "\tIf you still desire to serve pages as root then\n"
- "\tadd -DBIG_SECURITY_HOLE to the EXTRA_CFLAGS line in your\n"
- "\tsrc/Configuration file and rebuild the server. It is\n"
- "\tstrongly suggested that you instead modify the User\n"
- "\tdirective in your httpd.conf file to list a non-root\n"
- "\tuser.\n";
- }
-#endif
-
- return NULL;
-}
-
-const char *beosd_set_group(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- beosd_config.group_id = ap_gname2id(arg);
-
- return NULL;
-}
-
-void beosd_pre_config(void)
-{
- beosd_config.user_name = DEFAULT_USER;
- beosd_config.user_id = ap_uname2id(DEFAULT_USER);
- beosd_config.group_id = ap_gname2id(DEFAULT_GROUP);
-}
diff --git a/os/beos/beosd.h b/os/beos/beosd.h
deleted file mode 100644
index 876bb475b2..0000000000
--- a/os/beos/beosd.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef UNIXD_H
-#define UNIXD_H
-
-/* common stuff that beos MPMs will want */
-
-/* Default user name and group name. These may be specified as numbers by
- * placing a # before a number */
-
-#ifndef DEFAULT_USER
-#define DEFAULT_USER "#-1"
-#endif
-#ifndef DEFAULT_GROUP
-#define DEFAULT_GROUP "#-1"
-#endif
-
-typedef struct {
- char *user_name;
- uid_t user_id;
- gid_t group_id;
-} beosd_config_rec;
-extern beosd_config_rec beosd_config;
-
-void beosd_detach(void);
-int beosd_setup_child(void);
-void beosd_pre_config(void);
-const char *beosd_set_user(cmd_parms *cmd, void *dummy, char *arg);
-const char *beosd_set_group(cmd_parms *cmd, void *dummy, char *arg);
-
-#if defined(NSIG)
-#define NumSIG NSIG
-#elif defined(_NSIG)
-#define NumSIG _NSIG
-#elif defined(__NSIG)
-#define NumSIG __NSIG
-#else
-#define NumSIG 32 /* for 1998's unixes, this is still a good assumption */
-#endif
-
-#define INIT_SIGLIST() /* nothing */
-
-#define beosd_killpg(x, y) (kill (-(x), (y)))
-
-#define UNIX_DAEMON_COMMANDS \
-{ "User", beosd_set_user, NULL, RSRC_CONF, TAKE1, \
- "Effective user id for this server"}, \
-{ "Group", beosd_set_group, NULL, RSRC_CONF, TAKE1, \
- "Effective group id for this server"}, \
-
-#endif
diff --git a/os/beos/config.m4 b/os/beos/config.m4
deleted file mode 100644
index 823ac063ab..0000000000
--- a/os/beos/config.m4
+++ /dev/null
@@ -1,3 +0,0 @@
-if test "$OS" = "beos" ; then
- CFLAGS="$CFLAGS -DBEOS"
-fi
diff --git a/os/beos/os.c b/os/beos/os.c
deleted file mode 100644
index 030a21bbcf..0000000000
--- a/os/beos/os.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * This file will include OS specific functions which are not inlineable.
- * Any inlineable functions should be defined in os-inline.c instead.
- */
-
-#include "ap_config.h"
-#include "os.h"
-
-int ap_os_is_path_absolute(const char *file)
-{
- return file[0] == '/';
-}
-
-
-/* some linkers complain unless there's at least one function in each
- * .o file... and extra prototype is for gcc -Wmissing-prototypes
- */
-extern void ap_is_not_here(void);
-void ap_is_not_here(void) {}
-
-/*
- * Abstraction layer for loading
- * Apache modules under run-time via
- * dynamic shared object (DSO) mechanism
- */
-
-void ap_os_dso_init(void)
-{
- /* Nothing required to be done! */
-}
-
-void* ap_os_dso_load(const char *path)
-{
- return (void*) load_add_on(path);
-}
-
-void ap_os_dso_unload(void* handle)
-{
- unload_add_on((image_id)handle);
-}
-
-void *ap_os_dso_sym(void *handle, const char *symname)
-{
- void * retval = 0;
-#if defined(DLSYM_NEEDS_UNDERSCORE)
- char *symbol = (char*)malloc(sizeof(char)*(strlen(symname)+2));
- sprintf(symbol, "_%s", symname);
- get_image_symbol((image_id)handle, symbol, B_SYMBOL_TYPE_ANY, (void **)&retval);
- free(symbol);
- return retval;
-#endif
- get_image_symbol((image_id)handle, symname, B_SYMBOL_TYPE_ANY, (void **)&retval);
- return retval;
-}
-
-const char *ap_os_dso_error(void)
-{
- return NULL;
-}
diff --git a/os/beos/os.h b/os/beos/os.h
deleted file mode 100644
index f9e42e2f4e..0000000000
--- a/os/beos/os.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_OS_H
-#define APACHE_OS_H
-
-#include "ap_config.h"
-#include <kernel/image.h>
-
-#ifndef PLATFORM
-#define PLATFORM "BeOS"
-#endif
-
-/*
- * 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 or os-inline.c
- */
-
-extern int ap_os_is_path_absolute(const char *file);
-#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)
-#define ap_os_is_filename_valid(f) (1)
-#define ap_os_kill(pid, sig) kill(pid, sig)
-
-/*
- * Abstraction layer for loading
- * Apache modules under run-time via
- * dynamic shared object (DSO) mechanism
- */
-
-void *dlopen(const char *, int);
-int dlclose(void *);
-void *dlsym(void *, const char *);
-const char *dlerror(void);
-
-#define RTLD_NOW 1
-#define RTLD_GLOBAL 0
-
-#define ap_os_dso_handle_t image_id *
-void ap_os_dso_init(void);
-void * ap_os_dso_load(const char *);
-void ap_os_dso_unload(void *);
-void * ap_os_dso_sym(void *, const char *);
-const char *ap_os_dso_error(void);
-
-#endif /* !APACHE_OS_H */
diff --git a/os/bs2000/.cvsignore b/os/bs2000/.cvsignore
deleted file mode 100644
index f3c7a7c5da..0000000000
--- a/os/bs2000/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-Makefile
diff --git a/os/bs2000/bs2login.c b/os/bs2000/bs2login.c
deleted file mode 100644
index 3bbf03f7b7..0000000000
--- a/os/bs2000/bs2login.c
+++ /dev/null
@@ -1,297 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifdef _OSD_POSIX
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-#include <ctype.h>
-#include <sys/utsname.h>
-
-#define ACCT_LEN 8
-#define USER_LEN 8
-
-static const char *bs2000_account = NULL;
-typedef enum
-{
- bs2_unknown, /* not initialized yet. */
- bs2_noFORK, /* no fork() because -X flag was specified */
- bs2_FORK, /* only fork() because uid != 0 */
- bs2_FORK_RINI, /* prior to A17, regular fork() and _rini() was used. */
- bs2_RFORK_RINI, /* for A17, use of _rfork() and _rini() was required */
- bs2_UFORK /* As of A18, the new ufork() is used. */
-} bs2_ForkType;
-
-static bs2_ForkType forktype = bs2_unknown;
-
-
-static void ap_pad(char *dest, size_t size, char ch)
-{
- int i = strlen(dest); /* Leave space for trailing '\0' */
-
- while (i < size-1)
- dest[i++] = ch;
-
- dest[size-1] = '\0'; /* Guarantee for trailing '\0' */
-}
-
-static void ap_str_toupper(char *str)
-{
- while (*str) {
- *str = ap_toupper(*str);
- ++str;
- }
-}
-
-/* Determine the method for forking off a child in such a way as to
- * set both the POSIX and BS2000 user id's to the unprivileged user.
- */
-static bs2_ForkType os_forktype(void)
-{
- struct utsname os_version;
-
- /* have we checked the OS version before? If yes return the previous
- * result - the OS release isn't going to change suddenly!
- */
- if (forktype != bs2_unknown) {
- return forktype;
- }
-
- /* If the user is unprivileged, use the normal fork() only. */
- if (getuid() != 0) {
- return forktype = bs2_FORK;
- }
-
- if (uname(&os_version) < 0)
- {
- ap_log_error(APLOG_MARK, APLOG_ALERT, NULL,
- "uname() failed - aborting.");
- exit(APEXIT_CHILDFATAL);
- }
-
- /*
- * Old BS2000/OSD versions (before XPG4 SPEC1170) don't work with Apache.
- * Anyway, simply return a fork().
- */
- if (strcmp(os_version.release, "01.0A") == 0 ||
- strcmp(os_version.release, "02.0A") == 0 ||
- strcmp(os_version.release, "02.1A") == 0)
- {
- ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, NULL,
- "Error: unsupported OS version. "
- "You may encounter problems.");
- forktype = bs2_FORK;
- }
-
- /* The following versions are special:
- * OS versions before A17 needs regular fork() and _rini().
- * A17 requires _rfork() and _rini(),
- * and later versions need ufork().
- */
- else if (strcmp(os_version.release, "01.1A") == 0 ||
- strcmp(os_version.release, "03.0A") == 0 ||
- strcmp(os_version.release, "03.1A") == 0 ||
- strcmp(os_version.release, "04.0A") == 0)
- {
- if (strcmp (os_version.version, "A18") >= 0)
- forktype = bs2_UFORK;
-
- else if (strcmp (os_version.version, "A17") < 0)
- forktype = bs2_FORK_RINI;
-
- else
- forktype = bs2_RFORK_RINI;
- }
-
- /* All later OS versions will hopefully use ufork() only ;-) */
- else
- forktype = bs2_UFORK;
-
- return forktype;
-}
-
-
-
-/* This routine is called by http_core for the BS2000Account directive */
-/* It stores the account name for later use */
-const char *os_set_account(ap_context_t *p, const char *account)
-{
- char account_temp[ACCT_LEN+1];
-
- ap_cpystrn(account_temp, account, sizeof account_temp);
-
- /* Make account all upper case */
- ap_str_toupper(account_temp);
-
- /* Pad to length 8 */
- ap_pad(account_temp, sizeof account_temp, ' ');
-
- bs2000_account = ap_pstrdup(p, account_temp);
- return NULL;
-}
-
-/* This routine complements the setuid() call: it causes the BS2000 job
- * environment to be switched to the target user's user id.
- * That is important if CGI scripts try to execute native BS2000 commands.
- */
-int os_init_job_environment(server_rec *server, const char *user_name, int one_process)
-{
- _rini_struct inittask;
- char username[USER_LEN+1];
- int save_errno;
- bs2_ForkType type = os_forktype();
-
- /* We can be sure that no change to uid==0 is possible because of
- * the checks in http_core.c:set_user()
- */
-
- /* The _rini() function works only after a prior _rfork().
- * In the case of one_process, it would fail.
- */
- if (one_process) {
-
- type = forktype = bs2_noFORK;
-
- ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, server,
- "The debug mode of Apache should only "
- "be started by an unprivileged user!");
- return 0;
- }
-
- /* If no _rini() is required, then return quickly. */
- if (type != bs2_RFORK_RINI && type != bs2_FORK_RINI)
- return 0;
-
- /* An Account is required for _rini() */
- if (bs2000_account == NULL)
- {
- ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, server,
- "No BS2000Account configured - cannot switch to User %s",
- user_name);
- exit(APEXIT_CHILDFATAL);
- }
-
- ap_cpystrn(username, user_name, sizeof username);
-
- /* Make user name all upper case */
- ap_str_toupper(username);
-
- /* Pad to length 8 */
- ap_pad(username, sizeof username, ' ');
-
- inittask.username = username;
- inittask.account = bs2000_account;
- inittask.processor_name = " ";
-
- /* Switch to the new logon user (setuid() and setgid() are done later) */
- /* Only the super user can switch identities. */
- if (_rini(&inittask) != 0) {
-
- ap_log_error(APLOG_MARK, APLOG_ALERT, server,
- "_rini: BS2000 auth failed for user \"%s\" acct \"%s\"",
- inittask.username, inittask.account);
-
- exit(APEXIT_CHILDFATAL);
- }
-
- return 0;
-}
-
-/* BS2000 requires a "special" version of fork() before a setuid()/_rini() call */
-pid_t os_fork(const char *user)
-{
- pid_t pid;
- char username[USER_LEN+1];
-
- switch (os_forktype()) {
- case bs2_FORK:
- case bs2_FORK_RINI:
- pid = fork();
- break;
-
- case bs2_RFORK_RINI:
- pid = _rfork();
- break;
-
- case bs2_UFORK:
- ap_cpystrn(username, user, sizeof username);
-
- /* Make user name all upper case - for some versions of ufork() */
- ap_str_toupper(username);
-
- pid = ufork(username);
- if (pid == -1 && errno == EPERM) {
- ap_log_error(APLOG_MARK, APLOG_EMERG,
- NULL, "ufork: Possible mis-configuration "
- "for user %s - Aborting.", user);
- exit(1);
- }
- break;
-
- default:
- pid = 0;
- break;
- }
-
- return pid;
-}
-
-#else /* _OSD_POSIX */
-void bs2login_is_not_here()
-{
-}
-#endif /* _OSD_POSIX */
diff --git a/os/bs2000/ebcdic.c b/os/bs2000/ebcdic.c
deleted file mode 100644
index 36f3ca5e08..0000000000
--- a/os/bs2000/ebcdic.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-
-#ifdef CHARSET_EBCDIC
-#include "ap_config.h"
-#include "ebcdic.h"
-/*
- Initial Port for Apache-1.3 by <Martin.Kraemer@Mch.SNI.De>
-
-"BS2000 OSD" is a POSIX on a main frame. It is made by Siemens AG, Germany.
-Within the POSIX subsystem, the same character set was chosen as in
-"native BS2000", namely EBCDIC.
-
-EBCDIC Table. (Yes, in EBCDIC, the letters 'a'..'z' are not contiguous!)
-This ap_table_t is bijective, i.e. there are no ambigous or duplicate characters
-00 00 01 02 03 85 09 86 7f 87 8d 8e 0b 0c 0d 0e 0f *................*
-10 10 11 12 13 8f 0a 08 97 18 19 9c 9d 1c 1d 1e 1f *................*
-20 80 81 82 83 84 92 17 1b 88 89 8a 8b 8c 05 06 07 *................*
-30 90 91 16 93 94 95 96 04 98 99 9a 9b 14 15 9e 1a *................*
-40 20 a0 e2 e4 e0 e1 e3 e5 e7 f1 60 2e 3c 28 2b 7c * .........`.<(+|*
-50 26 e9 ea eb e8 ed ee ef ec df 21 24 2a 29 3b 9f *&.........!$*);.*
-60 2d 2f c2 c4 c0 c1 c3 c5 c7 d1 5e 2c 25 5f 3e 3f *-/........^,%_>?*
-70 f8 c9 ca cb c8 cd ce cf cc a8 3a 23 40 27 3d 22 *..........:#@'="*
-80 d8 61 62 63 64 65 66 67 68 69 ab bb f0 fd fe b1 *.abcdefghi......*
-90 b0 6a 6b 6c 6d 6e 6f 70 71 72 aa ba e6 b8 c6 a4 *.jklmnopqr......*
-a0 b5 af 73 74 75 76 77 78 79 7a a1 bf d0 dd de ae *..stuvwxyz......*
-b0 a2 a3 a5 b7 a9 a7 b6 bc bd be ac 5b 5c 5d b4 d7 *...........[\]..*
-c0 f9 41 42 43 44 45 46 47 48 49 ad f4 f6 f2 f3 f5 *.ABCDEFGHI......*
-d0 a6 4a 4b 4c 4d 4e 4f 50 51 52 b9 fb fc db fa ff *.JKLMNOPQR......*
-e0 d9 f7 53 54 55 56 57 58 59 5a b2 d4 d6 d2 d3 d5 *..STUVWXYZ......*
-f0 30 31 32 33 34 35 36 37 38 39 b3 7b dc 7d da 7e *0123456789.{.}.~*
-*/
-
-/* The bijective ebcdic-to-ascii table: */
-const unsigned char os_toascii_strictly[256] = {
-/*00*/ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
- 0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
-/*10*/ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
- 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
-/*20*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
-/*30*/ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
- 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
-/*40*/ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
- 0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
-/*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
- 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
-/*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
- 0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
-/*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
- 0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
-/*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
- 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
-/*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
- 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
-/*a0*/ 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
- 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
-/*b0*/ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
- 0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
-/*c0*/ 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
- 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
-/*d0*/ 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
- 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
-/*e0*/ 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
- 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
-/*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- 0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e /*0123456789.{.}.~*/
-};
-
-/* This ap_table_t is (almost) identical to the previous one. The only difference
- * is the fact that it maps every EBCDIC *except 0x0A* to its ASCII
- * equivalent. The reason for this ap_table_t is simple: Throughout the
- * server, protocol strings are used in the form
- * "Content-Type: text/plain\015\012". Now all the characters in the string
- * are stored as EBCDIC, only the semantics of \012 is completely
- * different from LF (look it up in the ap_table_t above). \015 happens to be
- * mapped to \015 anyway, so there's no special case for it.
- *
- * In THIS table, EBCDIC-\012 is mapped to ASCII-\012.
- * This ap_table_t is therefore used wherever an EBCDIC to ASCII conversion is
- * needed in the server.
- */
-/* ebcdic-to-ascii with \012 mapped to ASCII-\n */
-const unsigned char os_toascii[256] = {
-/*00*/ 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f,
- 0x87, 0x8d, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
-/*10*/ 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97,
- 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
-/*20*/ 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b,
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /*................*/
-/*30*/ 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04,
- 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /*................*/
-/*40*/ 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5,
- 0xe7, 0xf1, 0x60, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* .........`.<(+|*/
-/*50*/ 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef,
- 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x9f, /*&.........!$*);.*/
-/*60*/ 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5,
- 0xc7, 0xd1, 0x5e, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /*-/........^,%_>?*/
-/*70*/ 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf,
- 0xcc, 0xa8, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /*..........:#@'="*/
-/*80*/ 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
- 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /*.abcdefghi......*/
-/*90*/ 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70,
- 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /*.jklmnopqr......*/
-/*a0*/ 0xb5, 0xaf, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
- 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0xdd, 0xde, 0xae, /*..stuvwxyz......*/
-/*b0*/ 0xa2, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc,
- 0xbd, 0xbe, 0xac, 0x5b, 0x5c, 0x5d, 0xb4, 0xd7, /*...........[\]..*/
-/*c0*/ 0xf9, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
- 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /*.ABCDEFGHI......*/
-/*d0*/ 0xa6, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
- 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xdb, 0xfa, 0xff, /*.JKLMNOPQR......*/
-/*e0*/ 0xd9, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
- 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /*..STUVWXYZ......*/
-/*f0*/ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- 0x38, 0x39, 0xb3, 0x7b, 0xdc, 0x7d, 0xda, 0x7e /*0123456789.{.}.~*/
-};
-
-/* The ascii-to-ebcdic table:
-00 00 01 02 03 37 2d 2e 2f 16 05 15 0b 0c 0d 0e 0f *................*
-10 10 11 12 13 3c 3d 32 26 18 19 3f 27 1c 1d 1e 1f *................*
-20 40 5a 7f 7b 5b 6c 50 7d 4d 5d 5c 4e 6b 60 4b 61 * !"#$%&'()*+,-./
-30 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 7a 5e 4c 7e 6e 6f *0123456789:;<=>?*
-40 7c c1 c2 c3 c4 c5 c6 c7 c8 c9 d1 d2 d3 d4 d5 d6 *@ABCDEFGHIJKLMNO*
-50 d7 d8 d9 e2 e3 e4 e5 e6 e7 e8 e9 bb bc bd 6a 6d *PQRSTUVWXYZ[\]^_*
-60 4a 81 82 83 84 85 86 87 88 89 91 92 93 94 95 96 *`abcdefghijklmno*
-70 97 98 99 a2 a3 a4 a5 a6 a7 a8 a9 fb 4f fd ff 07 *pqrstuvwxyz{|}~.*
-80 20 21 22 23 24 04 06 08 28 29 2a 2b 2c 09 0a 14 *................*
-90 30 31 25 33 34 35 36 17 38 39 3a 3b 1a 1b 3e 5f *................*
-a0 41 aa b0 b1 9f b2 d0 b5 79 b4 9a 8a ba ca af a1 *................*
-b0 90 8f ea fa be a0 b6 b3 9d da 9b 8b b7 b8 b9 ab *................*
-c0 64 65 62 66 63 67 9e 68 74 71 72 73 78 75 76 77 *................*
-d0 ac 69 ed ee eb ef ec bf 80 e0 fe dd fc ad ae 59 *................*
-e0 44 45 42 46 43 47 9c 48 54 51 52 53 58 55 56 57 *................*
-f0 8c 49 cd ce cb cf cc e1 70 c0 de db dc 8d 8e df *................*
-*/
-const unsigned char os_toebcdic[256] = {
-/*00*/ 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f,
- 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /*................*/
-/*10*/ 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26,
- 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /*................*/
-/*20*/ 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d,
- 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
-/*30*/ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /*0123456789:;<=>?*/
-/*40*/ 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /*@ABCDEFGHIJKLMNO*/
-/*50*/ 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6,
- 0xe7, 0xe8, 0xe9, 0xbb, 0xbc, 0xbd, 0x6a, 0x6d, /*PQRSTUVWXYZ[\]^_*/
-/*60*/ 0x4a, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
- 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /*`abcdefghijklmno*/
-/*70*/ 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6,
- 0xa7, 0xa8, 0xa9, 0xfb, 0x4f, 0xfd, 0xff, 0x07, /*pqrstuvwxyz{|}~.*/
-/*80*/ 0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08,
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /*................*/
-/*90*/ 0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17,
- 0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0x5f, /*................*/
-/*a0*/ 0x41, 0xaa, 0xb0, 0xb1, 0x9f, 0xb2, 0xd0, 0xb5,
- 0x79, 0xb4, 0x9a, 0x8a, 0xba, 0xca, 0xaf, 0xa1, /*................*/
-/*b0*/ 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3,
- 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /*................*/
-/*c0*/ 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68,
- 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /*................*/
-/*d0*/ 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf,
- 0x80, 0xe0, 0xfe, 0xdd, 0xfc, 0xad, 0xae, 0x59, /*................*/
-/*e0*/ 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48,
- 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /*................*/
-/*f0*/ 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1,
- 0x70, 0xc0, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /*................*/
-};
-
-/* Translate a memory block from EBCDIC (host charset) to ASCII (net charset)
- * dest and srce may be identical, or separate memory blocks, but
- * should not overlap.
- */
-void
-ebcdic2ascii(unsigned char *dest, const unsigned char *srce, size_t count)
-{
- while (count-- != 0) {
- *dest++ = os_toascii[*srce++];
- }
-}
-void
-ebcdic2ascii_strictly(unsigned char *dest, const unsigned char *srce, size_t count)
-{
- while (count-- != 0) {
- *dest++ = os_toascii_strictly[*srce++];
- }
-}
-void
-ascii2ebcdic(unsigned char *dest, const unsigned char *srce, size_t count)
-{
- while (count-- != 0) {
- *dest++ = os_toebcdic[*srce++];
- }
-}
-#endif /*CHARSET_EBCDIC*/
diff --git a/os/bs2000/ebcdic.h b/os/bs2000/ebcdic.h
deleted file mode 100644
index 267f9786df..0000000000
--- a/os/bs2000/ebcdic.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <sys/types.h>
-
-extern const unsigned char os_toascii[256];
-extern const unsigned char os_toebcdic[256];
-void ebcdic2ascii(unsigned char *dest, const unsigned char *srce, size_t count);
-void ebcdic2ascii_strictly(unsigned char *dest, const unsigned char *srce, size_t count);
-void ascii2ebcdic(unsigned char *dest, const unsigned char *srce, size_t count);
-
diff --git a/os/bs2000/os-inline.c b/os/bs2000/os-inline.c
deleted file mode 100644
index e58917af36..0000000000
--- a/os/bs2000/os-inline.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * This file contains functions which can be inlined if the compiler
- * has an "inline" modifier. Because of this, this file is both a
- * header file and a compilable module.
- *
- * Only inlineable functions should be defined in here. They must all
- * include the INLINE modifier.
- *
- * If the compiler supports inline, this file will be #included as a
- * header file from os.h to create all the inline function
- * definitions. INLINE will be defined to whatever is required on
- * function definitions to make them inline declarations.
- *
- * If the compiler does not support inline, this file will be compiled
- * as a normal C file into libos.a (along with os.c). In this case
- * INLINE will _not_ be set so we can use this to test if we are
- * compiling this source file.
- */
-
-#ifndef INLINE
-#define INLINE
-
-/* Anything required only when compiling */
-#include "ap_config.h"
-
-#endif
-
-INLINE int ap_os_is_path_absolute(const char *file)
-{
- return (file && file[0] == '/' ? 1 : 0);
-}
diff --git a/os/bs2000/os.c b/os/bs2000/os.c
deleted file mode 100644
index c33810a2f0..0000000000
--- a/os/bs2000/os.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * This file will include OS specific functions which are not inlineable.
- * Any inlineable functions should be defined in os-inline.c instead.
- */
-
-#include "httpd.h"
-#include "http_core.h"
-#include "os.h"
-
-/* Check the Content-Type to decide if conversion is needed */
-int ap_checkconv(struct request_rec *r)
-{
- int convert_to_ascii;
- const char *type;
-
- /* To make serving of "raw ASCII text" files easy (they serve faster
- * since they don't have to be converted from EBCDIC), a new
- * "magic" type prefix was invented: text/x-ascii-{plain,html,...}
- * If we detect one of these content types here, we simply correct
- * the type to the real text/{plain,html,...} type. Otherwise, we
- * set a flag that translation is required later on.
- */
-
- type = (r->content_type == NULL) ? ap_default_type(r) : r->content_type;
-
- /* If no content type is set then treat it as (ebcdic) text/plain */
- convert_to_ascii = (type == NULL);
-
- /* Conversion is applied to text/ files only, if ever. */
- if (type && (strncasecmp(type, "text/", 5) == 0 ||
- strncasecmp(type, "message/", 8) == 0)) {
- if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX,
- sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0)
- r->content_type = ap_pstrcat(r->pool, "text/",
- type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1,
- NULL);
- else
- /* translate EBCDIC to ASCII */
- convert_to_ascii = 1;
- }
- /* Enable conversion if it's a text document */
- ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert_to_ascii);
-
- return convert_to_ascii;
-}
-
diff --git a/os/bs2000/os.h b/os/bs2000/os.h
deleted file mode 100644
index 1ede0813f2..0000000000
--- a/os/bs2000/os.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef APACHE_OS_H
-#define APACHE_OS_H
-
-#define PLATFORM "BS2000"
-
-/*
- * 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 or os-inline.c
- */
-
-#if !defined(INLINE) && defined(USE_GNU_INLINE)
-/* Compiler supports inline, so include the inlineable functions as
- * part of the header
- */
-#define INLINE extern ap_inline
-
-INLINE int ap_os_is_path_absolute(const char *file);
-
-#include "os-inline.c"
-#endif
-
-#ifndef INLINE
-/* Compiler does not support inline, so prototype the inlineable functions
- * as normal
- */
-extern int ap_os_is_path_absolute(const char *file);
-#endif
-
-/* Other ap_os_ routines not used by this platform */
-
-#define ap_os_is_filename_valid(f) (1)
-#define ap_os_kill(pid, sig) kill(pid, sig)
-
-#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)
-typedef struct {
- char *username;
- char *account;
- char *processor_name;
-} _rini_struct;
-
-extern int _rini(_rini_struct *);
-#endif /* !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) */
-
-/* Sorry if this is ugly, but the include order doesn't allow me
- * to use request_rec here... */
-struct request_rec;
-extern int ap_checkconv(struct request_rec *r);
-extern pid_t os_fork(const char *user);
-
-#endif /*! APACHE_OS_H*/
diff --git a/os/config.m4 b/os/config.m4
deleted file mode 100644
index 2e28b975b4..0000000000
--- a/os/config.m4
+++ /dev/null
@@ -1,18 +0,0 @@
-AC_MSG_CHECKING(for target platform)
-
-#PLATFORM=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`
-PLATFORM=`$ac_config_guess`
-
-case "$PLATFORM" in
-*beos*)
- OS="beos";;
-*pc-os2_emx*)
- OS="os2";;
-*)
- OS="unix";;
-esac
-
-OS_DIR=os/$OS
-
-AC_MSG_RESULT($OS)
-APACHE_FAST_OUTPUT($OS_DIR/Makefile)
diff --git a/os/os2/.cvsignore b/os/os2/.cvsignore
deleted file mode 100644
index f3c7a7c5da..0000000000
--- a/os/os2/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-Makefile
diff --git a/os/os2/Makefile.in b/os/os2/Makefile.in
deleted file mode 100644
index c03ac3fca1..0000000000
--- a/os/os2/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-
-DEPTH = ../..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-LTLIBRARY_NAME = libos.la
-LTLIBRARY_SOURCES = os.c os-inline.c util_os2.c iol_socket.c
-
-include $(topsrcdir)/build/ltlib.mk
diff --git a/os/os2/config.m4 b/os/os2/config.m4
deleted file mode 100644
index d6bab02dd4..0000000000
--- a/os/os2/config.m4
+++ /dev/null
@@ -1,4 +0,0 @@
-if test "$OS" = "os2" ; then
- CFLAGS="$CFLAGS -DOS2 -O2"
- LDFLAGS="$LDFLAGS -Zexe"
-fi
diff --git a/os/os2/os-inline.c b/os/os2/os-inline.c
deleted file mode 100644
index e3ff9f2fb8..0000000000
--- a/os/os2/os-inline.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * This file contains functions which can be inlined if the compiler
- * has an "inline" modifier. Because of this, this file is both a
- * header file and a compilable module.
- *
- * Only inlineable functions should be defined in here. They must all
- * include the INLINE modifier.
- *
- * If the compiler supports inline, this file will be #included as a
- * header file from os.h to create all the inline function
- * definitions. INLINE will be defined to whatever is required on
- * function definitions to make them inline declarations.
- *
- * If the compiler does not support inline, this file will be compiled
- * as a normal C file into libos.a (along with os.c). In this case
- * INLINE will _not_ be set so we can use this to test if we are
- * compiling this source file.
- */
-
-#ifndef INLINE
-#define INLINE
-
-/* Anything required only when compiling */
-#include "ap_config.h"
-
-#endif
-
-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] == ':');
-}
diff --git a/os/os2/os.h b/os/os2/os.h
deleted file mode 100644
index 20ebcec9f4..0000000000
--- a/os/os2/os.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef APACHE_OS_H
-#define APACHE_OS_H
-
-#define PLATFORM "OS/2"
-#define HAVE_CANONICAL_FILENAME
-#define HAVE_DRIVE_LETTERS
-
-#include <apr_general.h>
-
-/*
- * 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 or os-inline.c
- */
-
-#if defined(__GNUC__) && !defined(INLINE)
-/* Compiler supports inline, so include the inlineable functions as
- * part of the header
- */
-#define INLINE extern __inline__
-
-INLINE int ap_os_is_path_absolute(const char *file);
-
-#include "os-inline.c"
-#endif
-
-#ifndef INLINE
-/* Compiler does not support inline, so prototype the inlineable functions
- * as normal
- */
-extern int ap_os_is_path_absolute(const char *file);
-#endif
-
-char *ap_os_canonical_filename(ap_context_t *p, const char *file);
-#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)
-/* FIXME: the following should be implemented on this platform */
-#define ap_os_is_filename_valid(f) (1)
-
-/* Use a specialized kill() function */
-int ap_os_kill(int pid, int sig);
-
-/* Maps an OS error code to an error message */
-char *ap_os_error_message(int err);
-
-/* OS/2 doesn't have symlinks so S_ISLNK is always false */
-#define S_ISLNK(m) 0
-
-/* Dynamic loading functions */
-#define ap_os_dso_handle_t unsigned long
-void ap_os_dso_init(void);
-ap_os_dso_handle_t ap_os_dso_load(const char *);
-void ap_os_dso_unload(ap_os_dso_handle_t);
-void * ap_os_dso_sym(ap_os_dso_handle_t, const char *);
-const char *ap_os_dso_error(void);
-
-#endif /* ! APACHE_OS_H */
diff --git a/os/os2/util_os2.c b/os/os2/util_os2.c
deleted file mode 100644
index 536c40946d..0000000000
--- a/os/os2/util_os2.c
+++ /dev/null
@@ -1,192 +0,0 @@
-#define INCL_DOS
-#define INCL_DOSERRORS
-#include <os2.h>
-#include "httpd.h"
-#include "http_log.h"
-#include "os.h"
-#include <sys/time.h>
-#include <sys/signal.h>
-#include <ctype.h>
-#include <string.h>
-
-
-API_EXPORT(char *)ap_os_canonical_filename(ap_context_t *pPool, const char *szFile)
-{
- char buf[HUGE_STRING_LEN];
- char buf2[HUGE_STRING_LEN];
- int rc, len;
- char *pos;
-
-/* Remove trailing slash unless it's a root directory */
- strcpy(buf, szFile);
- len = strlen(buf);
-
- if (len > 3 && buf[len-1] == '/')
- buf[--len] = 0;
-
- rc = DosQueryPathInfo(buf, FIL_QUERYFULLNAME, buf2, HUGE_STRING_LEN);
-
- if (rc) {
- if ( rc != ERROR_INVALID_NAME ) {
- ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, NULL, "OS/2 error %d for file %s", rc, szFile);
- return ap_pstrdup(pPool, "");
- } else {
- return ap_pstrdup(pPool, szFile);
- }
- }
-
- strlwr(buf2);
-
-/* Switch backslashes to forward */
- for (pos=buf2; *pos; pos++)
- if (*pos == '\\')
- *pos = '/';
-
- return ap_pstrdup(pPool, buf2);
-}
-
-
-
-int ap_os_kill(pid_t pid, int sig)
-{
-/* SIGTERM's don't work too well in OS/2 (only affects other EMX programs).
- CGIs may not be, esp. REXX scripts, so use a native call instead */
-
- int rc;
-
- if ( sig == SIGTERM ) {
- rc = DosSendSignalException( pid, XCPT_SIGNAL_BREAK );
-
- if ( rc ) {
- errno = ESRCH;
- rc = -1;
- }
- } else {
- rc = kill(pid, sig);
- }
-
- return rc;
-}
-
-
-
-char *ap_os_error_message(int err)
-{
- static char result[200];
- unsigned char message[HUGE_STRING_LEN];
- ULONG len;
- char *pos;
- int c;
-
- if (DosGetMessage(NULL, 0, message, HUGE_STRING_LEN, err, "OSO001.MSG", &len) == 0) {
- len--;
- message[len] = 0;
- pos = result;
-
- if (len >= sizeof(result))
- len = sizeof(result-1);
-
- for (c=0; c<len; c++) {
- while (isspace(message[c]) && isspace(message[c+1])) /* skip multiple whitespace */
- c++;
- *(pos++) = isspace(message[c]) ? ' ' : message[c];
- }
-
- *pos = 0;
- } else {
- sprintf(result, "OS/2 error %d", err);
- }
-
- return result;
-}
-
-
-
-
-static int (*os2_select)( int *, int, int, int, long ) = NULL;
-static HMODULE hSO32DLL;
-
-int ap_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
-{
- int *fds, s, fd_count=0, rc;
- int num_read, num_write, num_except;
- long ms_timeout = -1;
-
- if (os2_select == NULL) {
- DosEnterCritSec(); /* Stop two threads doing this at the same time */
-
- if (os2_select == NULL) {
- hSO32DLL = ap_os_dso_load("SO32DLL");
-
- if (hSO32DLL) {
- os2_select = ap_os_dso_sym(hSO32DLL, "SELECT");
- }
- }
- DosExitCritSec();
- }
-
- ap_assert(os2_select != NULL);
- fds = alloca(sizeof(int) * nfds);
-
- if (readfds) {
- for (s=0; s<nfds; s++)
- if (FD_ISSET(s, readfds))
- fds[fd_count++] = _getsockhandle(s);
- }
-
- num_read = fd_count;
-
- if (writefds) {
- for (s=0; s<nfds; s++)
- if (FD_ISSET(s, writefds))
- fds[fd_count++] = _getsockhandle(s);
- }
-
- num_write = fd_count - num_read;
-
- if (exceptfds) {
- for (s=0; s<nfds; s++)
- if (FD_ISSET(s, exceptfds))
- fds[fd_count++] = _getsockhandle(s);
- }
-
- num_except = fd_count - num_read - num_write;
-
- if (timeout)
- ms_timeout = timeout->tv_usec / 1000 + timeout->tv_sec * 1000;
-
- rc = os2_select(fds, num_read, num_write, num_except, ms_timeout);
-
- if (rc > 0) {
- fd_count = 0;
-
- if (readfds) {
- for (s=0; s<nfds; s++) {
- if (FD_ISSET(s, readfds)) {
- if (fds[fd_count++] < 0)
- FD_CLR(s, readfds);
- }
- }
- }
-
- if (writefds) {
- for (s=0; s<nfds; s++) {
- if (FD_ISSET(s, writefds)) {
- if (fds[fd_count++] < 0)
- FD_CLR(s, writefds);
- }
- }
- }
-
- if (exceptfds) {
- for (s=0; s<nfds; s++) {
- if (FD_ISSET(s, exceptfds)) {
- if (fds[fd_count++] < 0)
- FD_CLR(s, exceptfds);
- }
- }
- }
- }
-
- return rc;
-}
diff --git a/os/tpf/TPFExport b/os/tpf/TPFExport
deleted file mode 100644
index 449ebf2f93..0000000000
--- a/os/tpf/TPFExport
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-echo " Setting TPF/c89 environment variables"
-export _C89_CCMODE=1
-# replace the following with the location of your TPF include files
-export _C89_INCDIRS="/u/tpf41/currentmaint/include /u/tpf41/currentmaint/include/oco"
-export TPF=YES
-echo "Done"
diff --git a/os/tpf/ebcdic.c b/os/tpf/ebcdic.c
deleted file mode 100644
index 479ace1de5..0000000000
--- a/os/tpf/ebcdic.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-
-#ifdef CHARSET_EBCDIC
-#include "ap_config.h"
-#include "ebcdic.h"
-/*
-This code does basic character mapping for IBM's TPF operating system.
-It is a modified version of <Martin.Kraemer@Mch.SNI.De>'s code for
-the BS2000 (apache/src/os/bs2000/ebcdic.c).
-*/
-
-/*
-Bijective EBCDIC (character set IBM-1047) to US-ASCII table:
-This ap_table_t is bijective - there are no ambigous or duplicate characters.
-*/
-const unsigned char os_toascii_strictly[256] = {
- 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f: */
- 0x87, 0x8d, 0x8e, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
- 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f: */
- 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f: */
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
- 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f: */
- 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
- 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f: */
- 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* ...........<(+| */
- 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f: */
- 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
- 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f: */
- 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
- 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f: */
- 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
- 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f: */
- 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
- 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f: */
- 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
- 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af: */
- 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
- 0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf: */
- 0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
- 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf: */
- 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
- 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df: */
- 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
- 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef: */
- 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff: */
- 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f /* 0123456789...... */
-};
-
-/*
-Server EBCDIC (character set IBM-1047) to US-ASCII table:
-This ap_table_t is a copy of the os_toascii_strictly bijective ap_table_t above.
-The only change is that hex 0a (\012 octal) is mapped to hex 0a
-(ASCII's line feed) instead of hex 8e. This is done because throughout
-Apache, protocol string definitions hardcode the linefeed as \012 (octal):
-"Content-Type: text/plain\015\012". Without this kludge all protocol
-string definitions would need to be changed from ...\012 to ...\025.
-*/
-const unsigned char os_toascii[256] = {
- 0x00, 0x01, 0x02, 0x03, 0x85, 0x09, 0x86, 0x7f, /* 00-0f: */
- 0x87, 0x8d, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
- 0x10, 0x11, 0x12, 0x13, 0x8f, 0x0a, 0x08, 0x97, /* 10-1f: */
- 0x18, 0x19, 0x9c, 0x9d, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
- 0x80, 0x81, 0x82, 0x83, 0x84, 0x92, 0x17, 0x1b, /* 20-2f: */
- 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x05, 0x06, 0x07, /* ................ */
- 0x90, 0x91, 0x16, 0x93, 0x94, 0x95, 0x96, 0x04, /* 30-3f: */
- 0x98, 0x99, 0x9a, 0x9b, 0x14, 0x15, 0x9e, 0x1a, /* ................ */
- 0x20, 0xa0, 0xe2, 0xe4, 0xe0, 0xe1, 0xe3, 0xe5, /* 40-4f: */
- 0xe7, 0xf1, 0xa2, 0x2e, 0x3c, 0x28, 0x2b, 0x7c, /* ...........<(+| */
- 0x26, 0xe9, 0xea, 0xeb, 0xe8, 0xed, 0xee, 0xef, /* 50-5f: */
- 0xec, 0xdf, 0x21, 0x24, 0x2a, 0x29, 0x3b, 0x5e, /* &.........!$*);^ */
- 0x2d, 0x2f, 0xc2, 0xc4, 0xc0, 0xc1, 0xc3, 0xc5, /* 60-6f: */
- 0xc7, 0xd1, 0xa6, 0x2c, 0x25, 0x5f, 0x3e, 0x3f, /* -/.........,%_>? */
- 0xf8, 0xc9, 0xca, 0xcb, 0xc8, 0xcd, 0xce, 0xcf, /* 70-7f: */
- 0xcc, 0x60, 0x3a, 0x23, 0x40, 0x27, 0x3d, 0x22, /* .........`:#@'=" */
- 0xd8, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, /* 80-8f: */
- 0x68, 0x69, 0xab, 0xbb, 0xf0, 0xfd, 0xfe, 0xb1, /* .abcdefghi...... */
- 0xb0, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, /* 90-9f: */
- 0x71, 0x72, 0xaa, 0xba, 0xe6, 0xb8, 0xc6, 0xa4, /* .jklmnopqr...... */
- 0xb5, 0x7e, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, /* a0-af: */
- 0x79, 0x7a, 0xa1, 0xbf, 0xd0, 0x5b, 0xde, 0xae, /* .~stuvwxyz...[.. */
- 0xac, 0xa3, 0xa5, 0xb7, 0xa9, 0xa7, 0xb6, 0xbc, /* b0-bf: */
- 0xbd, 0xbe, 0xdd, 0xa8, 0xaf, 0x5d, 0xb4, 0xd7, /* .............].. */
- 0x7b, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, /* c0-cf: */
- 0x48, 0x49, 0xad, 0xf4, 0xf6, 0xf2, 0xf3, 0xf5, /* {ABCDEFGHI...... */
- 0x7d, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, /* d0-df: */
- 0x51, 0x52, 0xb9, 0xfb, 0xfc, 0xf9, 0xfa, 0xff, /* }JKLMNOPQR...... */
- 0x5c, 0xf7, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, /* e0-ef: */
- 0x59, 0x5a, 0xb2, 0xd4, 0xd6, 0xd2, 0xd3, 0xd5, /* \.STUVWXYZ...... */
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, /* f0-ff: */
- 0x38, 0x39, 0xb3, 0xdb, 0xdc, 0xd9, 0xda, 0x9f /* 0123456789...... */
-};
-
-/*
-The US-ASCII to EBCDIC (character set IBM-1047) table:
-This ap_table_t is bijective (no ambiguous or duplicate characters)
-*/
-const unsigned char os_toebcdic[256] = {
- 0x00, 0x01, 0x02, 0x03, 0x37, 0x2d, 0x2e, 0x2f, /* 00-0f: */
- 0x16, 0x05, 0x15, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* ................ */
- 0x10, 0x11, 0x12, 0x13, 0x3c, 0x3d, 0x32, 0x26, /* 10-1f: */
- 0x18, 0x19, 0x3f, 0x27, 0x1c, 0x1d, 0x1e, 0x1f, /* ................ */
- 0x40, 0x5a, 0x7f, 0x7b, 0x5b, 0x6c, 0x50, 0x7d, /* 20-2f: */
- 0x4d, 0x5d, 0x5c, 0x4e, 0x6b, 0x60, 0x4b, 0x61, /* !"#$%&'()*+,-./ */
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 30-3f: */
- 0xf8, 0xf9, 0x7a, 0x5e, 0x4c, 0x7e, 0x6e, 0x6f, /* 0123456789:;<=>? */
- 0x7c, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 40-4f: */
- 0xc8, 0xc9, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, /* @ABCDEFGHIJKLMNO */
- 0xd7, 0xd8, 0xd9, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, /* 50-5f: */
- 0xe7, 0xe8, 0xe9, 0xad, 0xe0, 0xbd, 0x5f, 0x6d, /* PQRSTUVWXYZ[\]^_ */
- 0x79, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, /* 60-6f: */
- 0x88, 0x89, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, /* `abcdefghijklmno */
- 0x97, 0x98, 0x99, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, /* 70-7f: */
- 0xa7, 0xa8, 0xa9, 0xc0, 0x4f, 0xd0, 0xa1, 0x07, /* pqrstuvwxyz{|}~. */
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x04, 0x06, 0x08, /* 80-8f: */
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x09, 0x0a, 0x14, /* ................ */
- 0x30, 0x31, 0x25, 0x33, 0x34, 0x35, 0x36, 0x17, /* 90-9f: */
- 0x38, 0x39, 0x3a, 0x3b, 0x1a, 0x1b, 0x3e, 0xff, /* ................ */
- 0x41, 0xaa, 0x4a, 0xb1, 0x9f, 0xb2, 0x6a, 0xb5, /* a0-af: */
- 0xbb, 0xb4, 0x9a, 0x8a, 0xb0, 0xca, 0xaf, 0xbc, /* ................ */
- 0x90, 0x8f, 0xea, 0xfa, 0xbe, 0xa0, 0xb6, 0xb3, /* b0-bf: */
- 0x9d, 0xda, 0x9b, 0x8b, 0xb7, 0xb8, 0xb9, 0xab, /* ................ */
- 0x64, 0x65, 0x62, 0x66, 0x63, 0x67, 0x9e, 0x68, /* c0-cf: */
- 0x74, 0x71, 0x72, 0x73, 0x78, 0x75, 0x76, 0x77, /* ................ */
- 0xac, 0x69, 0xed, 0xee, 0xeb, 0xef, 0xec, 0xbf, /* d0-df: */
- 0x80, 0xfd, 0xfe, 0xfb, 0xfc, 0xba, 0xae, 0x59, /* ................ */
- 0x44, 0x45, 0x42, 0x46, 0x43, 0x47, 0x9c, 0x48, /* e0-ef: */
- 0x54, 0x51, 0x52, 0x53, 0x58, 0x55, 0x56, 0x57, /* ................ */
- 0x8c, 0x49, 0xcd, 0xce, 0xcb, 0xcf, 0xcc, 0xe1, /* f0-ff: */
- 0x70, 0xdd, 0xde, 0xdb, 0xdc, 0x8d, 0x8e, 0xdf /* ................ */
-};
-
-/* Translate a memory block from EBCDIC (host charset) to ASCII (net charset)
- * dest and srce may be identical, or separate memory blocks, but
- * should not overlap.
- */
-void
-ebcdic2ascii(void *dest, const void *srce, size_t count)
-{
- unsigned char *udest = dest;
- const unsigned char *usrce = srce;
- while (count-- != 0) {
- *udest++ = os_toascii[*usrce++];
- }
-}
-void
-ebcdic2ascii_strictly(unsigned char *dest, const unsigned char *srce, size_t count)
-{
- while (count-- != 0) {
- *dest++ = os_toascii_strictly[*srce++];
- }
-}
-void
-ascii2ebcdic(void *dest, const void *srce, size_t count)
-{
- unsigned char *udest = dest;
- const unsigned char *usrce = srce;
-
- while (count-- != 0) {
- *udest++ = os_toebcdic[*usrce++];
- }
-}
-#endif /*CHARSET_EBCDIC*/
-
diff --git a/os/tpf/ebcdic.h b/os/tpf/ebcdic.h
deleted file mode 100644
index e9c4120e1a..0000000000
--- a/os/tpf/ebcdic.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <sys/types.h>
-
-extern const unsigned char os_toascii[256];
-extern const unsigned char os_toebcdic[256];
-void ebcdic2ascii(void *dest, const void *srce, size_t count);
-void ebcdic2ascii_strictly(unsigned char *dest, const unsigned char *srce, size_t count);
-void ascii2ebcdic(void *dest, const void *srce, size_t count);
-
diff --git a/os/tpf/os-inline.c b/os/tpf/os-inline.c
deleted file mode 100644
index e58917af36..0000000000
--- a/os/tpf/os-inline.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * This file contains functions which can be inlined if the compiler
- * has an "inline" modifier. Because of this, this file is both a
- * header file and a compilable module.
- *
- * Only inlineable functions should be defined in here. They must all
- * include the INLINE modifier.
- *
- * If the compiler supports inline, this file will be #included as a
- * header file from os.h to create all the inline function
- * definitions. INLINE will be defined to whatever is required on
- * function definitions to make them inline declarations.
- *
- * If the compiler does not support inline, this file will be compiled
- * as a normal C file into libos.a (along with os.c). In this case
- * INLINE will _not_ be set so we can use this to test if we are
- * compiling this source file.
- */
-
-#ifndef INLINE
-#define INLINE
-
-/* Anything required only when compiling */
-#include "ap_config.h"
-
-#endif
-
-INLINE int ap_os_is_path_absolute(const char *file)
-{
- return (file && file[0] == '/' ? 1 : 0);
-}
diff --git a/os/tpf/os.c b/os/tpf/os.c
deleted file mode 100644
index 79e16dabd6..0000000000
--- a/os/tpf/os.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * This file will include OS specific functions which are not inlineable.
- * Any inlineable functions should be defined in os-inline.c instead.
- */
-
-#include "httpd.h"
-#include "http_core.h"
-#include "os.h"
-#include "scoreboard.h"
-#include "http_log.h"
-#include "http_conf_globals.h"
-
-static FILE *sock_fp;
-
-/* Check the Content-Type to decide if conversion is needed */
-int ap_checkconv(struct request_rec *r)
-{
- int convert_to_ascii;
- const char *type;
-
- /* To make serving of "raw ASCII text" files easy (they serve faster
- * since they don't have to be converted from EBCDIC), a new
- * "magic" type prefix was invented: text/x-ascii-{plain,html,...}
- * If we detect one of these content types here, we simply correct
- * the type to the real text/{plain,html,...} type. Otherwise, we
- * set a flag that translation is required later on.
- */
-
- type = (r->content_type == NULL) ? ap_default_type(r) : r->content_type;
-
- /* If no content type is set then treat it as (ebcdic) text/plain */
- convert_to_ascii = (type == NULL);
-
- /* Conversion is applied to text/ files only, if ever. */
- if (type && (strncasecmp(type, "text/", 5) == 0 ||
- strncasecmp(type, "message/", 8) == 0)) {
- if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX,
- sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0){
- r->content_type = ap_pstrcat(r->pool, "text/",
- type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1, NULL);
- if (r->method_number == M_PUT)
- ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, 0);
- }
-
- else
- /* translate EBCDIC to ASCII */
- convert_to_ascii = 1;
- }
- else{
- if (r->method_number == M_PUT)
- ap_bsetflag(r->connection->client, B_ASCII2EBCDIC, 0);
- /* don't translate non-text files to EBCDIC */
- }
- /* Enable conversion if it's a text document */
- ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert_to_ascii);
-
- return convert_to_ascii;
-}
-
-int tpf_select(int maxfds, fd_set *reads, fd_set *writes, fd_set *excepts, struct timeval *tv)
-{
-/* We're going to force our way through select. We're only interested reads and TPF allows
- 2billion+ socket descriptors for we don't want an fd_set that big. Just assume that maxfds-1
- contains the socket descriptor we're interested in. If it's 0, leave it alone. */
-
- int sockets[1];
- int no_reads = 0;
- int no_writes = 0;
- int no_excepts = 0;
- int timeout = 0;
- int rv;
-
- if(maxfds) {
- if(tv)
- timeout = tv->tv_sec * 1000 + tv->tv_usec;
- sockets[0] = maxfds-1;
- no_reads++;
- }
- else
- sockets[0] = 0;
-
- ap_check_signals();
- rv = select(sockets, no_reads, no_writes, no_excepts, timeout);
- ap_check_signals();
-
- return rv;
-
-}
-
-int tpf_accept(int sockfd, struct sockaddr *peer, int *paddrlen)
-{
- int socks[1];
- int rv;
-
- ap_check_signals();
- socks[0] = sockfd;
- rv = select(socks, 1, 0, 0, 1000);
- errno = sock_errno();
- if(rv>0) {
- ap_check_signals();
- rv = accept(sockfd, peer, paddrlen);
- errno = sock_errno();
- }
- return rv;
-}
-
-/* the getpass function is not usable on TPF */
-char *getpass(const char* prompt)
-{
- errno = EIO;
- return((char *)NULL);
-}
-
-#ifndef __PIPE_
-int pipe(int fildes[2])
-{
- errno = ENOSYS;
- return(-1);
-}
-#endif
-
-/* fork and exec functions are not defined on
- TPF due to the implementation of tpf_fork() */
-
-pid_t fork(void)
-{
- errno = ENOSYS;
- return(-1);
-}
-
-int execl(const char *path, const char *arg0, ...)
-{
- errno = ENOSYS;
- return(-1);
-}
-
-int execle(const char *path, const char *arg0, ...)
-{
- errno = ENOSYS;
- return(-1);
-}
-
-int execve(const char *path, char *const argv[], char *const envp[])
-{
- errno = ENOSYS;
- return(-1);
-}
-
-int execvp(const char *file, char *const argv[])
-{
- errno = ENOSYS;
- return(-1);
-}
-
-
-
-int ap_tpf_spawn_child(ap_context_t *p, int (*func) (void *, child_info *),
- void *data, enum kill_conditions kill_how,
- int *pipe_in, int *pipe_out, int *pipe_err,
- int out_fds[], int in_fds[], int err_fds[])
-
-{
-
- int i, temp_out, temp_in, temp_err, save_errno, pid, result=0;
- int fd_flags_out, fd_flags_in, fd_flags_err;
- struct tpf_fork_input fork_input;
- TPF_FORK_CHILD *cld = (TPF_FORK_CHILD *) data;
- ap_array_header_t *env_arr = ap_table_elts ((array_header *) cld->subprocess_env);
- table_entry *elts = (table_entry *) env_arr->elts;
-
-
-
- if (func) {
- if (result=func(data, NULL)) {
- return 0; /* error from child function */
- }
- }
-
- if (pipe_out) {
- fd_flags_out = fcntl(out_fds[0], F_GETFD);
- fcntl(out_fds[0], F_SETFD, FD_CLOEXEC);
- temp_out = dup(STDOUT_FILENO);
- fcntl(temp_out, F_SETFD, FD_CLOEXEC);
- dup2(out_fds[1], STDOUT_FILENO);
- }
-
-
- if (pipe_in) {
- fd_flags_in = fcntl(in_fds[1], F_GETFD);
- fcntl(in_fds[1], F_SETFD, FD_CLOEXEC);
- temp_in = dup(STDIN_FILENO);
- fcntl(temp_in, F_SETFD, FD_CLOEXEC);
- dup2(in_fds[0], STDIN_FILENO);
- }
-
- if (pipe_err) {
- fd_flags_err = fcntl(err_fds[0], F_GETFD);
- fcntl(err_fds[0], F_SETFD, FD_CLOEXEC);
- temp_err = dup(STDERR_FILENO);
- fcntl(temp_err, F_SETFD, FD_CLOEXEC);
- dup2(err_fds[1], STDERR_FILENO);
- }
-
- if (cld->subprocess_env) {
- for (i = 0; i < env_arr->nelts; ++i) {
- if (!elts[i].key)
- continue;
- setenv (elts[i].key, elts[i].val, 1);
- }
- }
-
- fork_input.program = (const char*) cld->filename;
- fork_input.prog_type = cld->prog_type;
- fork_input.istream = TPF_FORK_IS_BALANCE;
- fork_input.ebw_data_length = 0;
- fork_input.ebw_data = NULL;
- fork_input.parm_data = NULL;
-
-
- if ((pid = tpf_fork(&fork_input)) < 0) {
- save_errno = errno;
- if (pipe_out) {
- close(out_fds[0]);
- }
- if (pipe_in) {
- close(in_fds[1]);
- }
- if (pipe_err) {
- close(err_fds[0]);
- }
- errno = save_errno;
- pid = 0;
- }
-
- if (cld->subprocess_env) {
- for (i = 0; i < env_arr->nelts; ++i) {
- if (!elts[i].key)
- continue;
- unsetenv (elts[i].key);
- }
- }
-
- if (pipe_out) {
- close(out_fds[1]);
- dup2(temp_out, STDOUT_FILENO);
- close(temp_out);
- fcntl(out_fds[0], F_SETFD, fd_flags_out);
- }
-
- if (pipe_in) {
- close(in_fds[0]);
- dup2(temp_in, STDIN_FILENO);
- close(temp_in);
- fcntl(in_fds[1], F_SETFD, fd_flags_in);
- }
-
-
- if (pipe_err) {
- close(err_fds[1]);
- dup2(temp_err, STDERR_FILENO);
- close(temp_err);
- fcntl(err_fds[0], F_SETFD, fd_flags_err);
- }
-
-
- if (pid) {
-
- ap_note_subprocess(p, pid, kill_how);
-
- if (pipe_out) {
- *pipe_out = out_fds[0];
- }
- if (pipe_in) {
- *pipe_in = in_fds[1];
- }
- if (pipe_err) {
- *pipe_err = err_fds[0];
- }
- }
-
- return pid;
-
-}
-
-pid_t os_fork(server_rec *s, int slot)
-{
- struct tpf_fork_input fork_input;
- APACHE_TPF_INPUT input_parms;
- int count;
- listen_rec *lr;
-
- fflush(stdin);
- if (dup2(fileno(sock_fp), STDIN_FILENO) == -1)
- ap_log_error(APLOG_MARK, APLOG_CRIT, s,
- "unable to replace stdin with sock device driver");
- fflush(stdout);
- if (dup2(fileno(sock_fp), STDOUT_FILENO) == -1)
- ap_log_error(APLOG_MARK, APLOG_CRIT, s,
- "unable to replace stdout with sock device driver");
- input_parms.generation = ap_my_generation;
-#ifdef SCOREBOARD_FILE
- input_parms.scoreboard_fd = scoreboard_fd;
-#else /* must be USE_TPF_SCOREBOARD or USE_SHMGET_SCOREBOARD */
- input_parms.scoreboard_heap = ap_scoreboard_image;
-#endif
-
- lr = ap_listeners;
- count = 0;
- do {
- input_parms.listeners[count] = lr->fd;
- lr = lr->next;
- count++;
- } while(lr != ap_listeners);
-
- input_parms.slot = slot;
- input_parms.restart_time = ap_restart_time;
- fork_input.ebw_data = &input_parms;
- fork_input.program = ap_server_argv0;
- fork_input.prog_type = TPF_FORK_NAME;
- fork_input.istream = TPF_FORK_IS_BALANCE;
- fork_input.ebw_data_length = sizeof(input_parms);
- fork_input.parm_data = "-x";
- return tpf_fork(&fork_input);
-}
-
-int os_check_server(char *server) {
- #ifndef USE_TPF_DAEMON
- int rv;
- int *current_acn;
- if((rv = inetd_getServerStatus(server)) == INETD_SERVER_STATUS_INACTIVE)
- return 1;
- else {
- current_acn = (int *)cinfc_fast(CINFC_CMMACNUM);
- if(ecbp2()->ce2acn != *current_acn)
- return 1;
- }
- #endif
- return 0;
-}
-
-void os_note_additional_cleanups(ap_context_t *p, int sd) {
- char sockfilename[50];
- /* write the socket to file so that TPF socket device driver will close socket in case
- we happen to abend. */
- sprintf(sockfilename, "/dev/tpf.socket.file/%.8X", sd);
- sock_fp = fopen(sockfilename, "r+");
- ap_note_cleanups_for_file(p, sock_fp); /* arrange to close on exec or restart */
- fcntl(sd,F_SETFD,FD_CLOEXEC);
-}
-
-void os_tpf_child(APACHE_TPF_INPUT *input_parms) {
- tpf_child = 1;
- ap_my_generation = input_parms->generation;
- ap_restart_time = input_parms->restart_time;
-}
-
-
diff --git a/os/tpf/os.h b/os/tpf/os.h
deleted file mode 100644
index ff65322902..0000000000
--- a/os/tpf/os.h
+++ /dev/null
@@ -1,108 +0,0 @@
-#ifndef APACHE_OS_H
-#define APACHE_OS_H
-
-#define PLATFORM "TPF"
-
-#ifdef errno
-#undef errno
-#endif
-
-/*
- * 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 or os-inline.c
- */
-
-#include "ap_config.h"
-
-#if !defined(INLINE) && defined(USE_GNU_INLINE)
-/* Compiler supports inline, so include the inlineable functions as
- * part of the header
- */
-#define INLINE extern ap_inline
-#include "os-inline.c"
-#endif
-
-#ifndef INLINE
-/* Compiler does not support inline, so prototype the inlineable functions
- * as normal
- */
-extern int ap_os_is_path_absolute(const char *f);
-#endif
-
-/* Other ap_os_ routines not used by this platform */
-
-#define ap_os_is_filename_valid(f) (1)
-#define ap_os_kill(pid, sig) kill(pid, sig)
-
-/* Sorry if this is ugly, but the include order doesn't allow me
- * to use request_rec here... */
-struct request_rec;
-extern int ap_checkconv(struct request_rec *r);
-
-#include <strings.h>
-#ifndef __strings_h
-
-#define FD_SETSIZE 2048
-
-typedef long fd_mask;
-
-#define NBBY 8 /* number of bits in a byte */
-#define NFDBITS (sizeof(fd_mask) * NBBY)
-#define howmany(x, y) (((x)+((y)-1))/(y))
-
-typedef struct fd_set {
- fd_mask fds_bits [howmany(FD_SETSIZE, NFDBITS)];
-} fd_set;
-
-#define FD_CLR(n, p)((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
-#define FD_ISSET(n, p)((p)->fds_bits[(n)/NFDBITS] & (1 <<((n) % NFDBITS)))
-#define FD_ZERO(p) memset((char *)(p), 0, sizeof(*(p)))
-#endif
-
-#ifdef FD_SET
-#undef FD_SET
-#define FD_SET(n, p) (0)
-#endif
-
-#define RESOURCE_KEY ((void*) 0xC1C2C1C3)
-
-/* TPF doesn't have, or need, tzset (it is used in mod_expires.c) */
-#define tzset()
-
-#include <i$netd.h>
-struct apache_input {
- INETD_SERVER_INPUT inetd_server;
- void *scoreboard_heap; /* scoreboard system heap address */
- int scoreboard_fd; /* scoreboard file descriptor */
- int slot; /* child number */
- int generation; /* server generation number */
- int listeners[10];
- time_t restart_time;
-};
-
-typedef struct apache_input APACHE_TPF_INPUT;
-
-typedef struct tpf_fork_child {
- char *filename;
- enum { FORK_NAME = 1, FORK_FILE = 2 } prog_type;
- void *subprocess_env;
-}TPF_FORK_CHILD;
-
-int tpf_accept(int sockfd, struct sockaddr *peer, int *paddrlen);
-extern int tpf_child;
-
-struct server_rec;
-pid_t os_fork(struct server_rec *s, int slot);
-int os_check_server(char *server);
-char *getpass(const char *prompt);
-extern char *ap_server_argv0;
-extern int scoreboard_fd;
-#include <signal.h>
-#ifndef SIGPIPE
-#define SIGPIPE 14
-#endif
-#ifdef NSIG
-#undef NSIG
-#endif
-#endif /*! APACHE_OS_H*/
diff --git a/os/tpf/samples/linkdll.jcl b/os/tpf/samples/linkdll.jcl
deleted file mode 100644
index 16524bf3c9..0000000000
--- a/os/tpf/samples/linkdll.jcl
+++ /dev/null
@@ -1,121 +0,0 @@
-//APACH JOB MSGLEVEL=(1,1),CLASS=A,MSGCLASS=A
-/*ROUTE PRINT XXXXXX.XXXXXX
-/*ROUTE PUNCH XXXXXX.XXXXXX
-/*NOTIFY XXXXXX.XXXXXX
-//CCLE JCLLIB ORDER=(SYS1.CBC.SCBCPRC,SYS1.CEE.SCEEPROC)
-//PRELINK EXEC EDCPL,COND.LKED=(0,NE),
-// PPARM='OMVS,DLLNAME(pppp)',
-// LREGSIZ='2048K',
-// LPARM='AMODE=31,RMODE=ANY,LIST,XREF'
-//PLKED.SYSLIB DD DISP=SHR,DSN=FSE0000.DEVP.STUB.OB
-// DD DISP=SHR,DSN=FSE0000.DEVP.CLIB.OB
-// DD DISP=SHR,DSN=ACP.CLIB.RLSE46.WEB
-// DD DISP=SHR,DSN=ACP.STUB.RLSE46.WEB
-// DD DISP=SHR,DSN=ACP.CLIB.RLSE40
-// DD DISP=SHR,DSN=ACP.STUB.RLSE40
-//PLKED.SYSDEFSD DD DSN=APA0000.DEVP.IMPORTS.DSD(ppppvv),DISP=SHR
-//PLKED.DSD DD DSN=APA0000.DEVP.IMPORTS.DSD,DISP=SHR
-//PLKED.OBJLIB DD DISP=SHR,DSN=FSE0000.DEVP.TEST.OB
-// DD DISP=SHR,DSN=ACP.OBJ.RLSE46.WEB
-// DD DISP=SHR,DSN=ACP.OBJ.INTG98.NBS
-// DD DISP=SHR,DSN=ACP.MAIN.SYST.OBBSS
-// DD DISP=SHR,DSN=ACP.DF.MAIN.SYST.OBBSS
-// DD DISP=SHR,DSN=ACP.OBJ.RLSE40.BSS
-//PLKED.OBJ1 DD PATH='/usr/local/apache/src/ap/ap_cpystrn.o'
-//PLKED.OBJ2 DD PATH='/usr/local/apache/src/ap/ap_execve.o'
-//PLKED.OBJ3 DD PATH='/usr/local/apache/src/ap/ap_signal.o'
-//PLKED.OBJ4 DD PATH='/usr/local/apache/src/ap/ap_slack.o'
-//PLKED.OBJ5 DD PATH='/usr/local/apache/src/ap/ap_snprintf.o'
-//PLKED.OBJ6 DD PATH='/usr/local/apache/src/ap/ap_strings.o'
-//PLKED.OBJ7 DD PATH='/usr/local/apache/src/os/tpf/ebcdic.o'
-//PLKED.OBJ8 DD PATH='/usr/local/apache/src/os/tpf/os.o'
-//PLKED.OBJ9 DD PATH='/usr/local/apache/src/os/tpf/os-inline.o'
-//PLKED.OBJ10 DD PATH='/usr/local/apache/src/regex/regcomp.o'
-//PLKED.OBJ11 DD PATH='/usr/local/apache/src/regex/regerror.o'
-//PLKED.OBJ12 DD PATH='/usr/local/apache/src/regex/regexec.o'
-//PLKED.OBJ13 DD PATH='/usr/local/apache/src/regex/regfree.o'
-//PLKED.OBJ14 DD PATH='/usr/local/apache/src/main/alloc.o'
-//PLKED.OBJ15 DD PATH='/usr/local/apache/src/main/buff.o'
-//PLKED.OBJ16 DD PATH='/usr/local/apache/src/main/fnmatch.o'
-//PLKED.OBJ17 DD PATH='/usr/local/apache/src/main/http_config.o'
-//PLKED.OBJ18 DD PATH='/usr/local/apache/src/main/http_core.o'
-//PLKED.OBJ19 DD PATH='/usr/local/apache/src/main/http_log.o'
-//PLKED.OBJ20 DD PATH='/usr/local/apache/src/main/http_main.o'
-//PLKED.OBJ21 DD PATH='/usr/local/apache/src/main/http_protocol.o'
-//PLKED.OBJ22 DD PATH='/usr/local/apache/src/main/http_request.o'
-//PLKED.OBJ23 DD PATH='/usr/local/apache/src/main/http_vhost.o'
-//PLKED.OBJ24 DD PATH='/usr/local/apache/src/main/md5c.o'
-//PLKED.OBJ25 DD PATH='/usr/local/apache/src/main/rfc1413.o'
-//PLKED.OBJ26 DD PATH='/usr/local/apache/src/main/util.o'
-//PLKED.OBJ27 DD PATH='/usr/local/apache/src/main/util_date.o'
-//PLKED.OBJ28 DD PATH='/usr/local/apache/src/main/util_md5.o'
-//PLKED.OBJ29 DD PATH='/usr/local/apache/src/main/util_script.o'
-//PLKED.OBJ30 DD PATH='/usr/local/apache/src/main/util_uri.o'
-//PLKED.OBJ31 DD PATH='/usr/local/apache/src/modules.o'
-//PLKED.OBJ32 DD PATH='/usr/local/apache/src/buildmark.o'
-//PLKED.OBJ33 DD PATH='/usr/local/apache/src/modules/standard/mod_auto\
-// index.o'
-//PLKED.OBJ34 DD PATH='/usr/local/apache/src/modules/standard/mod_dir.\
-// o'
-//PLKED.OBJ35 DD PATH='/usr/local/apache/src/modules/standard/mod_mime\
-// .o'
-//PLKED.OBJ36 DD PATH='/usr/local/apache/src/modules/standard/mod_sete\
-// nvif.o'
-//PLKED.OBJ37 DD PATH='/usr/local/apache/src/modules/standard/mod_alia\
-// s.o'
-//PLKED.OBJ38 DD PATH='/usr/local/apache/src/modules/standard/mod_acce\
-// ss.o'
-//PLKED.OBJ39 DD PATH='/usr/local/apache/src/modules/standard/mod_user\
-// dir.o'
-//PLKED.OBJ40 DD PATH='/usr/local/apache/src/modules/standard/mod_spel\
-// ing.o'
-//PLKED.OBJ41 DD PATH='/usr/local/apache/src/modules/standard/mod_nego\
-// tiation.o'
-//PLKED.SYSIN DD *
- ORDER @@DLMHDR
- INCLUDE OBJLIB(CSTRTD40)
- INCLUDE OBJ1
- INCLUDE OBJ2
- INCLUDE OBJ3
- INCLUDE OBJ4
- INCLUDE OBJ5
- INCLUDE OBJ6
- INCLUDE OBJ7
- INCLUDE OBJ8
- INCLUDE OBJ9
- INCLUDE OBJ10
- INCLUDE OBJ11
- INCLUDE OBJ12
- INCLUDE OBJ13
- INCLUDE OBJ14
- INCLUDE OBJ15
- INCLUDE OBJ16
- INCLUDE OBJ17
- INCLUDE OBJ18
- INCLUDE OBJ19
- INCLUDE OBJ20
- INCLUDE OBJ21
- INCLUDE OBJ22
- INCLUDE OBJ23
- INCLUDE OBJ24
- INCLUDE OBJ25
- INCLUDE OBJ26
- INCLUDE OBJ27
- INCLUDE OBJ28
- INCLUDE OBJ29
- INCLUDE OBJ30
- INCLUDE OBJ31
- INCLUDE OBJ32
- INCLUDE OBJ33
- INCLUDE OBJ34
- INCLUDE OBJ35
- INCLUDE OBJ36
- INCLUDE OBJ37
- INCLUDE OBJ38
- INCLUDE OBJ39
- INCLUDE OBJ40
- INCLUDE OBJ41
-/*
-//*** WARNING *** NEVER change .LK to .OB in SYSLMOD!!!
-//LKED.SYSLMOD DD DISP=OLD,DSN=xxxxxx.xxxx(ppppvv)
-//
diff --git a/os/tpf/samples/loadset.jcl b/os/tpf/samples/loadset.jcl
deleted file mode 100644
index 405af82847..0000000000
--- a/os/tpf/samples/loadset.jcl
+++ /dev/null
@@ -1,58 +0,0 @@
-//OLDRWEB JOB MSGLEVEL=1,CLASS=A,MSGCLASS=S
-//JOBCAT DD DSN=ICFCAT.ESAWK2,DISP=SHR
-/*ROUTE PRINT xxxxxx.xxxxxxx
-/*ROUTE PUNCH xxxxxx.xxxxxxx
-//TLDR EXEC PGM=TPFLDRCA,REGION=8M,
-// PARM='OLDR,SYS=ACP,CLMSIZE=8000000'
-//STEPLIB DD DSN=ACP.LINK.RLSE46.WEB,DISP=SHR
-// DD DSN=ACP.LINK.RLSE40.BSS,DISP=SHR
-// DD DSN=VIS0000.DEVP.TEST.LK,DISP=SHR
-// DD DSN=SYS1.CEE.SCEERUN,DISP=SHR
-//SALTB DD DSN=ACP.SALTBL.RLSE46.WEB,DISP=SHR
-// DD DSN=ACP.SALTBL.INTG46.WEB,DISP=SHR
-//OBJLIB DD DSN=FSE0000.DEVP.TEST.OB,DISP=SHR
-// DD DSN=APA0000.DEVP.TEST.OB,DISP=SHR
-// DD DSN=ACP.DRVE.TEST.OB,DISP=SHR
-// DD DSN=ACP.OBJ.RLSE46.WEB,DISP=SHR
-// DD DSN=ACP.OBJ.INTG36.DRV,DISP=SHR
-// DD DSN=ACP.OBJ.INTG46.WEB,DISP=SHR
-// DD DSN=ACP.OBJ.INTG40.BSS,DISP=SHR
-//LOADMOD DD DSN=FSE0000.DEVP.TEST.LK,DISP=SHR
-// DD DSN=APA0000.DEVP.TEST.LK,DISP=SHR
-// DD DSN=CWEISS.LINK,DISP=SHR
-// DD DSN=ACP.DRVE.TEST.LK,DISP=SHR
-// DD DSN=ACP.LINK.RLSE46.WEB,DISP=SHR
-// DD DSN=ACP.LINK.INTG98.NBS,DISP=SHR
-// DD DSN=ACP.LINK.INTG46.WEB,DISP=SHR
-// DD DSN=ACP.LINK.INTG36.DRV,DISP=SHR
-// DD DSN=ACP.LINK.INTG40.BSS,DISP=SHR
-//LOADSUM DD DSN=&&LOADSUM,DISP=(NEW,PASS),UNIT=SYSDA,
-// LRECL=133,SPACE=(TRK,(10,10)),RECFM=FBA
-//CPRTEMP DD UNIT=SYSDA,
-// DSN=&&CPRTEMP,SPACE=(TRK,(100,20)),
-// DCB=(RECFM=FB,BLKSIZE=4095,LRECL=4095),
-// DISP=(NEW,DELETE)
-//PROGTEMP DD UNIT=SYSDA,
-// DSN=&&PRTEMP,SPACE=(TRK,(100,20)),
-// DCB=(RECFM=FB,BLKSIZE=4095,LRECL=4095),
-// DISP=(NEW,DELETE)
-//OUTPUT DD DSN=&&VRDROUT,DISP=(NEW,PASS),UNIT=SYSDA,
-// DCB=(RECFM=F,BLKSIZE=4095,LRECL=4095)
-//SYSUDUMP DD DUMMY
-//SYSABEND DD DUMMY
-//SYSOUT DD SYSOUT=A
-//SYSPRINT DD SYSOUT=A
-//PRINTER DD SYSOUT=A
-//CEEDUMP DD SYSOUT=A
-//SYSIN DD *
-SYSID=BSS
-PATVERS=NONE
-SALVERS=40
-LOADER LOADSET lllllll
-LOADER CALL PROG ppppvv
-/*
-//TRANSMIT EXEC PGM=IKJEFT01,
-// PARM='TRANSMIT xxxxxx.xxxxxx DDNAME(SYSTSIN) NOLOG NONOTIFY SEQ'
-//SYSTSIN DD UNIT=SYSDA,
-// DSN=&&VRDROUT,DISP=(OLD,DELETE)
-//SYSTSPRT DD DUMMY
diff --git a/os/unix/.cvsignore b/os/unix/.cvsignore
deleted file mode 100644
index bbc8ba00d1..0000000000
--- a/os/unix/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-Makefile
-.deps
-.libs
-*.lo
-*.la
diff --git a/os/unix/Makefile.in b/os/unix/Makefile.in
deleted file mode 100644
index 82b2dfc8ca..0000000000
--- a/os/unix/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-
-DEPTH = ../..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-LTLIBRARY_NAME = libos.la
-LTLIBRARY_SOURCES = os.c os-inline.c unixd.c iol_socket.c
-
-include $(topsrcdir)/build/ltlib.mk
diff --git a/os/unix/config.m4 b/os/unix/config.m4
deleted file mode 100644
index b968a40bd1..0000000000
--- a/os/unix/config.m4
+++ /dev/null
@@ -1,9 +0,0 @@
-if test "$OS" = "unix" ; then
- AC_CHECK_FUNCS( \
- setsid \
- killpg \
- )
-
- dnl XXX - This doesn't deal with _sys_siglist. Maybe have to roll our own
- AC_DECL_SYS_SIGLIST
-fi
diff --git a/os/unix/os-inline.c b/os/unix/os-inline.c
deleted file mode 100644
index dad7a8444d..0000000000
--- a/os/unix/os-inline.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * This file contains functions which can be inlined if the compiler
- * has an "inline" modifier. Because of this, this file is both a
- * header file and a compilable module.
- *
- * Only inlineable functions should be defined in here. They must all
- * include the INLINE modifier.
- *
- * If the compiler supports inline, this file will be #included as a
- * header file from os.h to create all the inline function
- * definitions. INLINE will be defined to whatever is required on
- * function definitions to make them inline declarations.
- *
- * If the compiler does not support inline, this file will be compiled
- * as a normal C file into libos.a (along with os.c). In this case
- * INLINE will _not_ be set so we can use this to test if we are
- * compiling this source file.
- */
-#include <unistd.h>
-
-#ifndef INLINE
-#define INLINE
-
-/* Anything required only when compiling */
-#include "ap_config.h"
-
-#endif
-
-INLINE int ap_os_is_path_absolute(const char *file)
-{
- return file[0] == '/';
-}
diff --git a/os/unix/os.h b/os/unix/os.h
deleted file mode 100644
index 875a669990..0000000000
--- a/os/unix/os.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_OS_H
-#define APACHE_OS_H
-
-#include "ap_config.h"
-
-#ifndef PLATFORM
-#define PLATFORM "Unix"
-#endif
-
-/*
- * 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 or os-inline.c
- */
-
-#if !defined(INLINE) && defined(USE_GNU_INLINE)
-/* Compiler supports inline, so include the inlineable functions as
- * part of the header
- */
-#define INLINE extern ap_inline
-
-INLINE int ap_os_is_path_absolute(const char *file);
-
-#include "os-inline.c"
-
-#else
-
-/* Compiler does not support inline, so prototype the inlineable functions
- * as normal
- */
-extern int ap_os_is_path_absolute(const char *file);
-#endif
-
-/* Other ap_os_ routines not used by this platform */
-
-#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)
-#define ap_os_is_filename_valid(f) (1)
-#define ap_os_kill(pid, sig) kill(pid, sig)
-
-/*
- * Abstraction layer for loading
- * Apache modules under run-time via
- * dynamic shared object (DSO) mechanism
- */
-
-#ifdef HAVE_DL_H
-#include <dl.h>
-#endif
-
-/*
- * Do not use native AIX DSO support on releases of AIX prior
- * to V4.3
- */
-#ifdef AIX
-#if AIX < 43
-#undef HAVE_DLFCN_H
-#endif
-#endif
-
-#ifdef HAVE_DLFCN_H
-#include <dlfcn.h>
-#else
-void *dlopen(const char *, int);
-int dlclose(void *);
-void *dlsym(void *, const char *);
-const char *dlerror(void);
-#endif
-
-/* probably on an older system that doesn't support RTLD_NOW or RTLD_LAZY.
- * The below define is a lie since we are really doing RTLD_LAZY since the
- * system doesn't support RTLD_NOW.
- */
-#ifndef RTLD_NOW
-#define RTLD_NOW 1
-#endif
-
-#ifndef RTLD_GLOBAL
-#define RTLD_GLOBAL 0
-#endif
-
-#if (defined(__FreeBSD__) ||\
- defined(__OpenBSD__) ||\
- defined(__NetBSD__) ) && !defined(__ELF__)
-#define DLSYM_NEEDS_UNDERSCORE
-#endif
-
-#define ap_os_dso_handle_t void *
-void ap_os_dso_init(void);
-void * ap_os_dso_load(const char *);
-void ap_os_dso_unload(void *);
-void * ap_os_dso_sym(void *, const char *);
-const char *ap_os_dso_error(void);
-
-#endif /* !APACHE_OS_H */
diff --git a/os/unix/unixd.c b/os/unix/unixd.c
deleted file mode 100644
index 2eaa13008b..0000000000
--- a/os/unix/unixd.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "unixd.h"
-#include <pwd.h>
-
-unixd_config_rec unixd_config;
-
-void unixd_detach(void)
-{
- int x;
- pid_t pgrp;
-
- chdir("/");
-#if !defined(MPE) && !defined(OS2) && !defined(TPF)
-/* Don't detach for MPE because child processes can't survive the death of
- the parent. */
- if ((x = fork()) > 0)
- exit(0);
- else if (x == -1) {
- perror("fork");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: unable to fork new process", ap_server_argv0);
- exit(1);
- }
- RAISE_SIGSTOP(DETACH);
-#endif
-#ifdef HAVE_SETSID
- if ((pgrp = setsid()) == -1) {
- perror("setsid");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: setsid failed", ap_server_argv0);
- exit(1);
- }
-#elif defined(NEXT) || defined(NEWSOS)
- if (setpgrp(0, getpid()) == -1 || (pgrp = getpgrp(0)) == -1) {
- perror("setpgrp");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: setpgrp or getpgrp failed", ap_server_argv0);
- exit(1);
- }
-#elif defined(OS2) || defined(TPF)
- /* OS/2 and TPF don't support process group IDs */
- pgrp = getpid();
-#elif defined(MPE)
- /* MPE uses negative pid for process group */
- pgrp = -getpid();
-#else
- if ((pgrp = setpgrp(getpid(), 0)) == -1) {
- perror("setpgrp");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: setpgrp failed", ap_server_argv0);
- exit(1);
- }
-#endif
-
- /* close out the standard file descriptors */
- if (freopen("/dev/null", "r", stdin) == NULL) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: unable to replace stdin with /dev/null: %s",
- ap_server_argv0, strerror(errno));
- /* continue anyhow -- note we can't close out descriptor 0 because we
- * have nothing to replace it with, and if we didn't have a descriptor
- * 0 the next file would be created with that value ... leading to
- * havoc.
- */
- }
- if (freopen("/dev/null", "w", stdout) == NULL) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: unable to replace stdout with /dev/null: %s",
- ap_server_argv0, strerror(errno));
- }
- /* stderr is a tricky one, we really want it to be the error_log,
- * but we haven't opened that yet. So leave it alone for now and it'll
- * be reopened moments later.
- */
-}
-
-/* Set group privileges.
- *
- * Note that we use the username as set in the config files, rather than
- * the lookup of to uid --- the same uid may have multiple passwd entries,
- * with different sets of groups for each.
- */
-
-static int set_group_privs(void)
-{
- if (!geteuid()) {
- char *name;
-
- /* Get username if passed as a uid */
-
- if (unixd_config.user_name[0] == '#') {
- struct passwd *ent;
- uid_t uid = atoi(&unixd_config.user_name[1]);
-
- if ((ent = getpwuid(uid)) == NULL) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
- "getpwuid: couldn't determine user name from uid %u, "
- "you probably need to modify the User directive",
- (unsigned)uid);
- return -1;
- }
-
- name = ent->pw_name;
- }
- else
- name = unixd_config.user_name;
-
-#if !defined(OS2) && !defined(TPF)
- /* OS/2 and TPF don't support groups. */
-
- /*
- * Set the GID before initgroups(), since on some platforms
- * setgid() is known to zap the group list.
- */
- if (setgid(unixd_config.group_id) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
- "setgid: unable to set group id to Group %u",
- (unsigned)unixd_config.group_id);
- return -1;
- }
-
- /* Reset `groups' attributes. */
-
- if (initgroups(name, unixd_config.group_id) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
- "initgroups: unable to set groups for User %s "
- "and Group %u", name, (unsigned)unixd_config.group_id);
- return -1;
- }
-#endif /* !defined(OS2) && !defined(TPF) */
- }
- return 0;
-}
-
-
-int unixd_setup_child(void)
-{
- if (set_group_privs()) {
- return -1;
- }
-#ifdef MPE
- /* Only try to switch if we're running as MANAGER.SYS */
- if (geteuid() == 1 && unixd_config.user_id > 1) {
- GETPRIVMODE();
- if (setuid(unixd_config.user_id) == -1) {
- GETUSERMODE();
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
- "setuid: unable to change to uid: %ld",
- (long) unixd_config.user_id);
- exit(1);
- }
- GETUSERMODE();
- }
-#else
- /* Only try to switch if we're running as root */
- if (!geteuid() && (
-#ifdef _OSD_POSIX
- os_init_job_environment(server_conf, unixd_config.user_name, one_process) != 0 ||
-#endif
- setuid(unixd_config.user_id) == -1)) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
- "setuid: unable to change to uid: %ld",
- (long) unixd_config.user_id);
- return -1;
- }
-#endif
- return 0;
-}
-
-
-const char *unixd_set_user(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- unixd_config.user_name = arg;
- unixd_config.user_id = ap_uname2id(arg);
-#if !defined (BIG_SECURITY_HOLE) && !defined (OS2)
- if (unixd_config.user_id == 0) {
- return "Error:\tApache has not been designed to serve pages while\n"
- "\trunning as root. There are known race conditions that\n"
- "\twill allow any local user to read any file on the system.\n"
- "\tIf you still desire to serve pages as root then\n"
- "\tadd -DBIG_SECURITY_HOLE to the EXTRA_CFLAGS line in your\n"
- "\tsrc/Configuration file and rebuild the server. It is\n"
- "\tstrongly suggested that you instead modify the User\n"
- "\tdirective in your httpd.conf file to list a non-root\n"
- "\tuser.\n";
- }
-#endif
-
- return NULL;
-}
-
-const char *unixd_set_group(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- unixd_config.group_id = ap_gname2id(arg);
-
- return NULL;
-}
-
-void unixd_pre_config(void)
-{
- unixd_config.user_name = DEFAULT_USER;
- unixd_config.user_id = ap_uname2id(DEFAULT_USER);
- unixd_config.group_id = ap_gname2id(DEFAULT_GROUP);
-}
-
-#ifdef NEED_AP_SYS_SIGLIST
-
-const char *ap_sys_siglist[NumSIG];
-
-void unixd_siglist_init(void)
-{
- int sig;
-
- ap_sys_siglist[0] = "Signal 0";
-#ifdef SIGHUP
- ap_sys_siglist[SIGHUP] = "Hangup";
-#endif
-#ifdef SIGINT
- ap_sys_siglist[SIGINT] = "Interrupt";
-#endif
-#ifdef SIGQUIT
- ap_sys_siglist[SIGQUIT] = "Quit";
-#endif
-#ifdef SIGILL
- ap_sys_siglist[SIGILL] = "Illegal instruction";
-#endif
-#ifdef SIGTRAP
- ap_sys_siglist[SIGTRAP] = "Trace/BPT trap";
-#endif
-#ifdef SIGIOT
- ap_sys_siglist[SIGIOT] = "IOT instruction";
-#endif
-#ifdef SIGABRT
- ap_sys_siglist[SIGABRT] = "Abort";
-#endif
-#ifdef SIGEMT
- ap_sys_siglist[SIGEMT] = "Emulator trap";
-#endif
-#ifdef SIGFPE
- ap_sys_siglist[SIGFPE] = "Arithmetic exception";
-#endif
-#ifdef SIGKILL
- ap_sys_siglist[SIGKILL] = "Killed";
-#endif
-#ifdef SIGBUS
- ap_sys_siglist[SIGBUS] = "Bus error";
-#endif
-#ifdef SIGSEGV
- ap_sys_siglist[SIGSEGV] = "Segmentation fault";
-#endif
-#ifdef SIGSYS
- ap_sys_siglist[SIGSYS] = "Bad system call";
-#endif
-#ifdef SIGPIPE
- ap_sys_siglist[SIGPIPE] = "Broken pipe";
-#endif
-#ifdef SIGALRM
- ap_sys_siglist[SIGALRM] = "Alarm clock";
-#endif
-#ifdef SIGTERM
- ap_sys_siglist[SIGTERM] = "Terminated";
-#endif
-#ifdef SIGUSR1
- ap_sys_siglist[SIGUSR1] = "User defined signal 1";
-#endif
-#ifdef SIGUSR2
- ap_sys_siglist[SIGUSR2] = "User defined signal 2";
-#endif
-#ifdef SIGCLD
- ap_sys_siglist[SIGCLD] = "Child status change";
-#endif
-#ifdef SIGCHLD
- ap_sys_siglist[SIGCHLD] = "Child status change";
-#endif
-#ifdef SIGPWR
- ap_sys_siglist[SIGPWR] = "Power-fail restart";
-#endif
-#ifdef SIGWINCH
- ap_sys_siglist[SIGWINCH] = "Window changed";
-#endif
-#ifdef SIGURG
- ap_sys_siglist[SIGURG] = "urgent socket condition";
-#endif
-#ifdef SIGPOLL
- ap_sys_siglist[SIGPOLL] = "Pollable event occurred";
-#endif
-#ifdef SIGIO
- ap_sys_siglist[SIGIO] = "socket I/O possible";
-#endif
-#ifdef SIGSTOP
- ap_sys_siglist[SIGSTOP] = "Stopped (signal)";
-#endif
-#ifdef SIGTSTP
- ap_sys_siglist[SIGTSTP] = "Stopped";
-#endif
-#ifdef SIGCONT
- ap_sys_siglist[SIGCONT] = "Continued";
-#endif
-#ifdef SIGTTIN
- ap_sys_siglist[SIGTTIN] = "Stopped (tty input)";
-#endif
-#ifdef SIGTTOU
- ap_sys_siglist[SIGTTOU] = "Stopped (tty output)";
-#endif
-#ifdef SIGVTALRM
- ap_sys_siglist[SIGVTALRM] = "virtual timer expired";
-#endif
-#ifdef SIGPROF
- ap_sys_siglist[SIGPROF] = "profiling timer expired";
-#endif
-#ifdef SIGXCPU
- ap_sys_siglist[SIGXCPU] = "exceeded cpu limit";
-#endif
-#ifdef SIGXFSZ
- ap_sys_siglist[SIGXFSZ] = "exceeded file size limit";
-#endif
- for (sig=0; sig < sizeof(ap_sys_siglist)/sizeof(ap_sys_siglist[0]); ++sig)
- if (ap_sys_siglist[sig] == NULL)
- ap_sys_siglist[sig] = "";
-}
-#endif /* NEED_AP_SYS_SIGLIST */
-
diff --git a/os/unix/unixd.h b/os/unix/unixd.h
deleted file mode 100644
index 30a74f730c..0000000000
--- a/os/unix/unixd.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef UNIXD_H
-#define UNIXD_H
-
-#include "httpd.h"
-
-/* common stuff that unix MPMs will want */
-
-/* Default user name and group name. These may be specified as numbers by
- * placing a # before a number */
-
-#ifndef DEFAULT_USER
-#define DEFAULT_USER "#-1"
-#endif
-#ifndef DEFAULT_GROUP
-#define DEFAULT_GROUP "#-1"
-#endif
-
-typedef struct {
- char *user_name;
- uid_t user_id;
- gid_t group_id;
-} unixd_config_rec;
-extern unixd_config_rec unixd_config;
-
-void unixd_detach(void);
-int unixd_setup_child(void);
-void unixd_pre_config(void);
-const char *unixd_set_user(cmd_parms *cmd, void *dummy, char *arg);
-const char *unixd_set_group(cmd_parms *cmd, void *dummy, char *arg);
-
-/* Information on signals for the various platforms */
-
-#if defined(NSIG)
-#define NumSIG NSIG
-#elif defined(_NSIG)
-#define NumSIG _NSIG
-#elif defined(__NSIG)
-#define NumSIG __NSIG
-#else
-#define NumSIG 32 /* for 1998's unixes, this is still a good assumption */
-#endif
-
-#ifdef SYS_SIGLIST /* platform has sys_siglist[] */
-#define INIT_SIGLIST() /* nothing */
-#elif defined(SYS_SIGLIST_DECLARED) /* from autoconf */
-#define INIT_SIGLIST() /* nothing */
-#define SYS_SIGLIST sys_siglist
-#else
-#define NEED_AP_SYS_SIGLIST
-extern const char *ap_sys_siglist[NumSIG];
-#define SYS_SIGLIST ap_sys_siglist
-void unixd_siglist_init(void);
-#define INIT_SIGLIST() unixd_siglist_init();
-#endif /* platform has sys_siglist[] */
-
-#ifdef HAVE_KILLPG
-#define unixd_killpg(x, y) (killpg ((x), (y)))
-#else /* HAVE_KILLPG */
-#define unixd_killpg(x, y) (kill (-(x), (y)))
-#endif /* HAVE_KILLPG */
-
-#define UNIX_DAEMON_COMMANDS \
-{ "User", unixd_set_user, NULL, RSRC_CONF, TAKE1, \
- "Effective user id for this server"}, \
-{ "Group", unixd_set_group, NULL, RSRC_CONF, TAKE1, \
- "Effective group id for this server"}, \
-
-#endif
diff --git a/os/win32/.cvsignore b/os/win32/.cvsignore
deleted file mode 100644
index 17564450e9..0000000000
--- a/os/win32/.cvsignore
+++ /dev/null
@@ -1,27 +0,0 @@
-*.mdp
-*.ncb
-*.opt
-*.plg
-*.dsw
-ApacheModuleAuthAnonD
-ApacheModuleAuthAnonR
-ApacheModuleCERNMetaD
-ApacheModuleCERNMetaR
-ApacheModuleDigestD
-ApacheModuleDigestR
-ApacheModuleExpiresD
-ApacheModuleExpiresR
-ApacheModuleHeadersD
-ApacheModuleHeadersR
-ApacheModuleInfoD
-ApacheModuleInfoR
-ApacheModuleRewriteD
-ApacheModuleRewriteR
-ApacheModuleSpelingD
-ApacheModuleSpelingR
-ApacheModuleStatusD
-ApacheModuleStatusR
-ApacheModuleUserTrackD
-ApacheModuleUserTrackR
-ApacheOSR
-ApacheOSD
diff --git a/os/win32/MakeModuleMak.cpp b/os/win32/MakeModuleMak.cpp
deleted file mode 100644
index 9ab9f27221..0000000000
--- a/os/win32/MakeModuleMak.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <fstream.h>
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-void MakeMake(const char *szModule,const char *szSource)
- {
- ifstream ifs("Module.mak.tmpl",ios::nocreate);
- assert(ifs.good());
-
- char buf[1024];
- sprintf(buf,"%s.mak",szModule);
- ofstream ofs(buf,ios::trunc);
- for( ; ; )
- {
- ifs.getline(buf,sizeof buf);
- if(ifs.eof())
- break;
- for(char *s=buf ; *s ; )
- {
- char *p=strchr(s,'%');
- if(!p)
- {
- ofs << s << '\n';
- break;
- }
- if(!strncmp(p,"%Module%",8))
- {
- ofs.write(s,p-s);
- ofs << szModule;
- s=p+8;
- }
- else if(!strncmp(p,"%Source%",8))
- {
- ofs.write(s,p-s);
- ofs << szSource;
- s=p+8;
- }
- else
- {
- ofs.write(s,p-s+1);
- s=p+1;
- }
- }
- }
- }
-
-void main(int argc,char **argv)
- {
- if(argc < 2 || (argc%2) != 1)
- {
- cerr << argv[0] << " [<module name> <source file>]+\n";
- exit(1);
- }
- for(int n=1 ; n < argc ; n+=2)
- MakeMake(argv[n],argv[n+1]);
- }
-
diff --git a/os/win32/Module.mak.tmpl b/os/win32/Module.mak.tmpl
deleted file mode 100644
index 162456f064..0000000000
--- a/os/win32/Module.mak.tmpl
+++ /dev/null
@@ -1,230 +0,0 @@
-# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
-
-!IF "$(CFG)" == ""
-CFG=%Module% - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to %Module% - Win32\
- Debug.
-!ENDIF
-
-!IF "$(CFG)" != "%Module% - Win32 Release" && "$(CFG)" !=\
- "%Module% - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE on this makefile
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "%Module%.mak"\
- CFG="%Module% - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "%Module% - Win32 Release" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE "%Module% - Win32 Debug" (based on\
- "Win32 (x86) Dynamic-Link Library")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-################################################################################
-# Begin Project
-# PROP Target_Last_Scanned "%Module% - Win32 Debug"
-MTL=mktyplib.exe
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "%Module% - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "%Module%R"
-# PROP Intermediate_Dir "%Module%R"
-# PROP Target_Dir ""
-OUTDIR=.\%Module%R
-INTDIR=.\%Module%R
-
-ALL : "$(OUTDIR)\%Module%.dll"
-
-CLEAN :
- -@erase "$(INTDIR)\%Source%.obj"
- -@erase "$(OUTDIR)\%Module%.dll"
- -@erase "$(OUTDIR)\%Module%.exp"
- -@erase "$(OUTDIR)\%Module%.lib"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\regex" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
-CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "..\regex" /D "WIN32" /D "NDEBUG" /D\
- "_WINDOWS" /Fp"$(INTDIR)/%Module%.pch" /YX /Fo"$(INTDIR)/" /c
-CPP_OBJS=.\%Module%R/
-CPP_SBRS=.\.
-# ADD BASE MTL /nologo /D "NDEBUG" /win32
-# ADD MTL /nologo /D "NDEBUG" /win32
-MTL_PROJ=/nologo /D "NDEBUG" /win32
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-BSC32_FLAGS=/nologo /o"$(OUTDIR)/%Module%.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-# ADD LINK32 ..\CoreR\ApacheCore.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
-LINK32_FLAGS=..\CoreR\ApacheCore.lib kernel32.lib user32.lib gdi32.lib\
- winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib\
- uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll\
- /incremental:no /pdb:"$(OUTDIR)/%Module%.pdb" /machine:I386\
- /out:"$(OUTDIR)/%Module%.dll"\
- /implib:"$(OUTDIR)/%Module%.lib"
-LINK32_OBJS= \
- "$(INTDIR)\%Source%.obj"
-
-"$(OUTDIR)\%Module%.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "%Module% - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "%Module%D"
-# PROP Intermediate_Dir "%Module%D"
-# PROP Target_Dir ""
-OUTDIR=.\%Module%D
-INTDIR=.\%Module%D
-
-ALL : "$(OUTDIR)\%Module%.dll"
-
-CLEAN :
- -@erase "$(INTDIR)\%Source%.obj"
- -@erase "$(INTDIR)\vc40.idb"
- -@erase "$(INTDIR)\vc40.pdb"
- -@erase "$(OUTDIR)\%Module%.dll"
- -@erase "$(OUTDIR)\%Module%.exp"
- -@erase "$(OUTDIR)\%Module%.ilk"
- -@erase "$(OUTDIR)\%Module%.lib"
- -@erase "$(OUTDIR)\%Module%.pdb"
-
-"$(OUTDIR)" :
- if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
-
-# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\regex" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
-CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\regex" /D "WIN32" /D "_DEBUG"\
- /D "_WINDOWS" /Fp"$(INTDIR)/%Module%.pch" /YX /Fo"$(INTDIR)/"\
- /Fd"$(INTDIR)/" /c
-CPP_OBJS=.\%Module%D/
-CPP_SBRS=.\.
-# ADD BASE MTL /nologo /D "_DEBUG" /win32
-# ADD MTL /nologo /D "_DEBUG" /win32
-MTL_PROJ=/nologo /D "_DEBUG" /win32
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-BSC32_FLAGS=/nologo /o"$(OUTDIR)/%Module%.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-# ADD LINK32 ..\CoreD\ApacheCore.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
-LINK32_FLAGS=..\CoreD\ApacheCore.lib kernel32.lib user32.lib gdi32.lib\
- winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib\
- uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll\
- /incremental:yes /pdb:"$(OUTDIR)/%Module%.pdb" /debug /machine:I386\
- /out:"$(OUTDIR)/%Module%.dll"\
- /implib:"$(OUTDIR)/%Module%.lib"
-LINK32_OBJS= \
- "$(INTDIR)\%Source%.obj"
-
-"$(OUTDIR)\%Module%.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-.c{$(CPP_OBJS)}.obj:
- $(CPP) $(CPP_PROJ) $<
-
-.cpp{$(CPP_OBJS)}.obj:
- $(CPP) $(CPP_PROJ) $<
-
-.cxx{$(CPP_OBJS)}.obj:
- $(CPP) $(CPP_PROJ) $<
-
-.c{$(CPP_SBRS)}.sbr:
- $(CPP) $(CPP_PROJ) $<
-
-.cpp{$(CPP_SBRS)}.sbr:
- $(CPP) $(CPP_PROJ) $<
-
-.cxx{$(CPP_SBRS)}.sbr:
- $(CPP) $(CPP_PROJ) $<
-
-################################################################################
-# Begin Target
-
-# Name "%Module% - Win32 Release"
-# Name "%Module% - Win32 Debug"
-
-!IF "$(CFG)" == "%Module% - Win32 Release"
-
-!ELSEIF "$(CFG)" == "%Module% - Win32 Debug"
-
-!ENDIF
-
-################################################################################
-# Begin Source File
-
-SOURCE=\work\apache\src\%Source%.c
-DEP_CPP_MOD_A=\
- "..\alloc.h"\
- "..\buff.h"\
- "..\conf.h"\
- "..\http_config.h"\
- "..\http_core.h"\
- "..\http_log.h"\
- "..\http_request.h"\
- "..\httpd.h"\
- "..\regex\regex.h"\
- "..\ap_mmn.h"\
- ".\readdir.h"\
- {$(INCLUDE)}"\sys\stat.h"\
- {$(INCLUDE)}"\sys\types.h"\
-
-NODEP_CPP_MOD_A=\
- "..\sfio.h"\
-
-
-"$(INTDIR)\%Source%.obj" : $(SOURCE) $(DEP_CPP_MOD_A) "$(INTDIR)"
- $(CPP) $(CPP_PROJ) $(SOURCE)
-
-
-# End Source File
-# End Target
-# End Project
-################################################################################
diff --git a/os/win32/apache.ico b/os/win32/apache.ico
deleted file mode 100644
index 161bcf7841..0000000000
--- a/os/win32/apache.ico
+++ /dev/null
Binary files differ
diff --git a/os/win32/apache.rc b/os/win32/apache.rc
deleted file mode 100644
index 6dde63f950..0000000000
--- a/os/win32/apache.rc
+++ /dev/null
@@ -1,84 +0,0 @@
-//Microsoft Developer Studio generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "winresrc.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// Neutral resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEU)
-#ifdef _WIN32
-LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Icon
-//
-
-// Icon with lowest ID value placed first to ensure application icon
-// remains consistent on all systems.
-IDI_APACHE ICON DISCARDABLE "apache.ico"
-#endif // Neutral resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.K.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
-#pragma code_page(1252)
-#endif //_WIN32
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE DISCARDABLE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE DISCARDABLE
-BEGIN
- "#include ""winresrc.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE DISCARDABLE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (U.K.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/os/win32/mod_isapi.c b/os/win32/mod_isapi.c
deleted file mode 100644
index 86aee51558..0000000000
--- a/os/win32/mod_isapi.c
+++ /dev/null
@@ -1,569 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * mod_isapi.c - Internet Server Application (ISA) module for Apache
- * by Alexei Kosut <akosut@apache.org>
- *
- * This module implements Microsoft's ISAPI, allowing Apache (when running
- * under Windows) to load Internet Server Applications (ISAPI extensions).
- * It implements all of the ISAPI 2.0 specification, except for the
- * "Microsoft-only" extensions dealing with asynchronous I/O. All ISAPI
- * extensions that use only synchronous I/O and are compatible with the
- * ISAPI 2.0 specification should work (most ISAPI 1.0 extensions should
- * function as well).
- *
- * To load, simply place the ISA in a location in the document tree.
- * Then add an "AddHandler isapi-isa dll" into your config file.
- * You should now be able to load ISAPI DLLs just be reffering to their
- * URLs. Make sure the ExecCGI option is active in the directory
- * the ISA is in.
- */
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_request.h"
-#include "http_log.h"
-#include "util_script.h"
-
-/* We use the exact same header file as the original */
-#include <HttpExt.h>
-
-/* Seems IIS does not enforce the requirement for \r\n termination on HSE_REQ_SEND_RESPONSE_HEADER,
- define this to conform */
-#define RELAX_HEADER_RULE
-
-module isapi_module;
-
-/* Our "Connection ID" structure */
-
-typedef struct {
- LPEXTENSION_CONTROL_BLOCK ecb;
- request_rec *r;
- int status;
-} isapi_cid;
-
-/* Declare the ISAPI functions */
-
-BOOL WINAPI GetServerVariable (HCONN hConn, LPSTR lpszVariableName,
- LPVOID lpvBuffer, LPDWORD lpdwSizeofBuffer);
-BOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpwdwBytes,
- DWORD dwReserved);
-BOOL WINAPI ReadClient (HCONN ConnID, LPVOID lpvBuffer, LPDWORD lpdwSize);
-BOOL WINAPI ServerSupportFunction (HCONN hConn, DWORD dwHSERequest,
- LPVOID lpvBuffer, LPDWORD lpdwSize,
- LPDWORD lpdwDataType);
-
-/*
- The optimiser blows it totally here. What happens is that autos are addressed relative to the
- stack pointer, which, of course, moves around. The optimiser seems to lose track of it somewhere
- between setting isapi_entry and calling through it. We work around the problem by forcing it to
- use frame pointers.
-*/
-#pragma optimize("y",off)
-
-int isapi_handler (request_rec *r) {
- LPEXTENSION_CONTROL_BLOCK ecb =
- ap_pcalloc(r->pool, sizeof(struct _EXTENSION_CONTROL_BLOCK));
- HSE_VERSION_INFO *pVer = ap_pcalloc(r->pool, sizeof(HSE_VERSION_INFO));
-
- HINSTANCE isapi_handle;
- BOOL (*isapi_version)(HSE_VERSION_INFO *); /* entry point 1 */
- DWORD (*isapi_entry)(LPEXTENSION_CONTROL_BLOCK); /* entry point 2 */
- BOOL (*isapi_term)(DWORD); /* optional entry point 3 */
-
- isapi_cid *cid = ap_pcalloc(r->pool, sizeof(isapi_cid));
- ap_table_t *e = r->subprocess_env;
- int retval;
-
- /* Use similar restrictions as CGIs */
-
- if (!(ap_allow_options(r) & OPT_EXECCGI))
- return FORBIDDEN;
-
- if (r->finfo.st_mode == 0)
- return NOT_FOUND;
-
- if (S_ISDIR(r->finfo.st_mode))
- return FORBIDDEN;
-
- /* Load the module */
-
- if (!(isapi_handle = LoadLibraryEx(r->filename, NULL,
- LOAD_WITH_ALTERED_SEARCH_PATH))) {
- ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
- "Could not load DLL: %s", r->filename);
- return SERVER_ERROR;
- }
-
- if (!(isapi_version =
- (void *)(GetProcAddress(isapi_handle, "GetExtensionVersion")))) {
- ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
- "DLL could not load GetExtensionVersion(): %s", r->filename);
- FreeLibrary(isapi_handle);
- return SERVER_ERROR;
- }
-
- if (!(isapi_entry =
- (void *)(GetProcAddress(isapi_handle, "HttpExtensionProc")))) {
- ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
- "DLL could not load HttpExtensionProc(): %s", r->filename);
- FreeLibrary(isapi_handle);
- return SERVER_ERROR;
- }
-
- isapi_term = (void *)(GetProcAddress(isapi_handle, "TerminateExtension"));
-
- /* Run GetExtensionVersion() */
-
- if (!(*isapi_version)(pVer)) {
- ap_log_rerror(APLOG_MARK, APLOG_ALERT, r,
- "ISAPI GetExtensionVersion() failed: %s", r->filename);
- FreeLibrary(isapi_handle);
- return SERVER_ERROR;
- }
-
- /* Set up variables */
- ap_add_common_vars(r);
- ap_add_cgi_vars(r);
-
- /* Set up connection ID */
- ecb->ConnID = (HCONN)cid;
- cid->ecb = ecb;
- cid->r = r;
- cid->status = 0;
-
- ecb->cbSize = sizeof(struct _EXTENSION_CONTROL_BLOCK);
- ecb->dwVersion = MAKELONG(0, 2);
- ecb->dwHttpStatusCode = 0;
- strcpy(ecb->lpszLogData, "");
- ecb->lpszMethod = r->method;
- ecb->lpszQueryString = ap_table_get(e, "QUERY_STRING");
- ecb->lpszPathInfo = ap_table_get(e, "PATH_INFO");
- ecb->lpszPathTranslated = ap_table_get(e, "PATH_TRANSLATED");
- ecb->lpszContentType = ap_table_get(e, "CONTENT_TYPE");
-
- /* Set up client input */
- if ((retval = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
- if (isapi_term) (*isapi_term)(HSE_TERM_MUST_UNLOAD);
- FreeLibrary(isapi_handle);
- return retval;
- }
-
- if (ap_should_client_block(r)) {
- /* Unlike IIS, which limits this to 48k, we read the whole
- * sucker in. I suppose this could be bad for memory if someone
- * uploaded the complete works of Shakespeare. Well, WebSite
- * does the same thing.
- */
- long to_read = atol(ap_table_get(e, "CONTENT_LENGTH"));
- long read;
-
- /* Actually, let's cap it at 48k, until we figure out what
- * to do with this... we don't want a Content-Length: 1000000000
- * taking out the machine.
- */
-
- if (to_read > 49152) {
- if (isapi_term) (*isapi_term)(HSE_TERM_MUST_UNLOAD);
- FreeLibrary(isapi_handle);
- return HTTP_REQUEST_ENTITY_TOO_LARGE;
- }
-
- ecb->lpbData = ap_pcalloc(r->pool, 1 + to_read);
-
- if ((read = ap_get_client_block(r, ecb->lpbData, to_read)) < 0) {
- if (isapi_term) (*isapi_term)(HSE_TERM_MUST_UNLOAD);
- FreeLibrary(isapi_handle);
- return SERVER_ERROR;
- }
-
- /* Although its not to spec, IIS seems to null-terminate
- * its lpdData string. So we will too. To make sure
- * cbAvailable matches cbTotalBytes, we'll up the latter
- * and equalize them.
- */
- ecb->cbAvailable = ecb->cbTotalBytes = read + 1;
- ecb->lpbData[read] = '\0';
- }
- else {
- ecb->cbTotalBytes = 0;
- ecb->cbAvailable = 0;
- ecb->lpbData = NULL;
- }
-
- /* Set up the callbacks */
-
- ecb->GetServerVariable = &GetServerVariable;
- ecb->WriteClient = &WriteClient;
- ecb->ReadClient = &ReadClient;
- ecb->ServerSupportFunction = &ServerSupportFunction;
-
- /* All right... try and load the sucker */
- retval = (*isapi_entry)(ecb);
-
- /* Set the status (for logging) */
- if (ecb->dwHttpStatusCode)
- r->status = ecb->dwHttpStatusCode;
-
- /* Check for a log message - and log it */
- if (ecb->lpszLogData && strcmp(ecb->lpszLogData, ""))
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "%s: %s", ecb->lpszLogData, r->filename);
-
- /* All done with the DLL... get rid of it */
- if (isapi_term) (*isapi_term)(HSE_TERM_MUST_UNLOAD);
- FreeLibrary(isapi_handle);
-
- switch(retval) {
- case HSE_STATUS_SUCCESS:
- case HSE_STATUS_SUCCESS_AND_KEEP_CONN:
- /* Ignore the keepalive stuff; Apache handles it just fine without
- * the ISA's "advice".
- */
-
- if (cid->status) /* We have a special status to return */
- return cid->status;
-
- return OK;
- case HSE_STATUS_PENDING: /* We don't support this */
- ap_log_rerror(APLOG_MARK, APLOG_WARNING, r,
- "ISAPI asynchronous I/O not supported: %s", r->filename);
- case HSE_STATUS_ERROR:
- default:
- return SERVER_ERROR;
- }
-
-}
-#pragma optimize("",on)
-
-BOOL WINAPI GetServerVariable (HCONN hConn, LPSTR lpszVariableName,
- LPVOID lpvBuffer, LPDWORD lpdwSizeofBuffer) {
- request_rec *r = ((isapi_cid *)hConn)->r;
- ap_table_t *e = r->subprocess_env;
- const char *result;
-
- /* Mostly, we just grab it from the environment, but there are
- * a couple of special cases
- */
-
- if (!strcasecmp(lpszVariableName, "UNMAPPED_REMOTE_USER")) {
- /* We don't support NT users, so this is always the same as
- * REMOTE_USER
- */
- result = ap_table_get(e, "REMOTE_USER");
- }
- else if (!strcasecmp(lpszVariableName, "SERVER_PORT_SECURE")) {
- /* Apache doesn't support secure requests inherently, so
- * we have no way of knowing. We'll be conservative, and say
- * all requests are insecure.
- */
- result = "0";
- }
- else if (!strcasecmp(lpszVariableName, "URL")) {
- result = r->uri;
- }
- else {
- result = ap_table_get(e, lpszVariableName);
- }
-
- if (result) {
- if (strlen(result) > *lpdwSizeofBuffer) {
- *lpdwSizeofBuffer = strlen(result);
- SetLastError(ERROR_INSUFFICIENT_BUFFER);
- return FALSE;
- }
- strncpy(lpvBuffer, result, *lpdwSizeofBuffer);
- return TRUE;
- }
-
- /* Didn't find it */
- SetLastError(ERROR_INVALID_INDEX);
- return FALSE;
-}
-
-BOOL WINAPI WriteClient (HCONN ConnID, LPVOID Buffer, LPDWORD lpwdwBytes,
- DWORD dwReserved) {
- request_rec *r = ((isapi_cid *)ConnID)->r;
- int writ; /* written, actually, but why shouldn't I make up words? */
-
- /* We only support synchronous writing */
- if (dwReserved && dwReserved != HSE_IO_SYNC) {
- ap_log_rerror(APLOG_MARK, APLOG_WARNING, r,
- "ISAPI asynchronous I/O not supported: %s", r->filename);
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- if ((writ = ap_rwrite(Buffer, *lpwdwBytes, r)) == EOF) {
- SetLastError(ERROR); /* XXX: Find the right error code */
- return FALSE;
- }
-
- *lpwdwBytes = writ;
- return TRUE;
-}
-
-BOOL WINAPI ReadClient (HCONN ConnID, LPVOID lpvBuffer, LPDWORD lpdwSize) {
- /* Doesn't need to do anything; we've read all the data already */
- return TRUE;
-}
-
-/* XXX: There is an O(n^2) attack possible here. */
-BOOL WINAPI ServerSupportFunction (HCONN hConn, DWORD dwHSERequest,
- LPVOID lpvBuffer, LPDWORD lpdwSize,
- LPDWORD lpdwDataType) {
- isapi_cid *cid = (isapi_cid *)hConn;
- request_rec *subreq, *r = cid->r;
- char *data;
-
- switch (dwHSERequest) {
- case HSE_REQ_SEND_URL_REDIRECT_RESP:
- /* Set the status to be returned when the HttpExtensionProc()
- * is done.
- */
- ap_table_set (r->headers_out, "Location", lpvBuffer);
- cid->status = cid->r->status = cid->ecb->dwHttpStatusCode = REDIRECT;
- return TRUE;
-
- case HSE_REQ_SEND_URL:
- /* Read any additional input */
-
- if (r->remaining > 0) {
- char argsbuffer[HUGE_STRING_LEN];
-
- while (ap_get_client_block(r, argsbuffer, HUGE_STRING_LEN));
- }
-
- /* Reset the method to GET */
- r->method = ap_pstrdup(r->pool, "GET");
- r->method_number = M_GET;
-
- /* Don't let anyone think there's still data */
- ap_table_unset(r->headers_in, "Content-Length");
-
- ap_internal_redirect((char *)lpvBuffer, r);
- return TRUE;
-
- case HSE_REQ_SEND_RESPONSE_HEADER:
- r->status_line = lpvBuffer ? lpvBuffer : ap_pstrdup(r->pool, "200 OK");
- sscanf(r->status_line, "%d", &r->status);
- cid->ecb->dwHttpStatusCode = r->status;
-
- /* Now fill in the HTTP headers, and the rest of it. Ick.
- * lpdwDataType contains a string that has headers (in MIME
- * format), a blank like, then (possibly) data. We need
- * to parse it.
- *
- * Easy case first:
- */
- if (!lpdwDataType) {
- ap_send_http_header(r);
- return TRUE;
- }
-
- /* Make a copy - don't disturb the original */
- data = ap_pstrdup(r->pool, (char *)lpdwDataType);
-
- /* We *should* break before this while loop ends */
- while (*data) {
- char *value, *lf = strchr(data, '\n');
- int p;
-
-#ifdef RELAX_HEADER_RULE
- if (lf)
- *lf = '\0';
-#else
- if (!lf) { /* Huh? Invalid data, I think */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "ISA sent invalid headers: %s", r->filename);
- SetLastError(ERROR); /* XXX: Find right error */
- return FALSE;
- }
-
- /* Get rid of \n and \r */
- *lf = '\0';
-#endif
- p = strlen(data);
- if (p > 0 && data[p-1] == '\r') data[p-1] = '\0';
-
- /* End of headers */
- if (*data == '\0') {
-#ifdef RELAX_HEADER_RULE
- if (lf)
-#endif
- data = lf + 1; /* Reset data */
- break;
- }
-
- if (!(value = strchr(data, ':'))) {
- SetLastError(ERROR); /* XXX: Find right error */
- ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
- "ISA sent invalid headers", r->filename);
- return FALSE;
- }
-
- *value++ = '\0';
- while (*value && ap_isspace(*value)) ++value;
-
- /* Check all the special-case headers. Similar to what
- * ap_scan_script_header_err() does (see that function for
- * more detail)
- */
-
- if (!strcasecmp(data, "Content-Type")) {
- char *tmp;
- /* Nuke trailing whitespace */
-
- char *endp = value + strlen(value) - 1;
- while (endp > value && ap_isspace(*endp)) *endp-- = '\0';
-
- tmp = ap_pstrdup (r->pool, value);
- ap_str_tolower(tmp);
- r->content_type = tmp;
- }
- else if (!strcasecmp(data, "Content-Length")) {
- ap_table_set(r->headers_out, data, value);
- }
- else if (!strcasecmp(data, "Transfer-Encoding")) {
- ap_table_set(r->headers_out, data, value);
- }
- else if (!strcasecmp(data, "Set-Cookie")) {
- ap_table_add(r->err_headers_out, data, value);
- }
- else {
- ap_table_merge(r->err_headers_out, data, value);
- }
-
- /* Reset data */
-#ifdef RELAX_HEADER_RULE
- if (!lf) {
- data += p;
- break;
- }
-#endif
- data = lf + 1;
- }
-
- /* All the headers should be set now */
-
- ap_send_http_header(r);
-
- /* Any data left should now be sent directly */
- ap_rputs(data, r);
-
- return TRUE;
-
- case HSE_REQ_MAP_URL_TO_PATH:
- /* Map a URL to a filename */
- subreq = ap_sub_req_lookup_uri(ap_pstrndup(r->pool, (char *)lpvBuffer,
- *lpdwSize), r);
-
- GetFullPathName(subreq->filename, *lpdwSize - 1, (char *)lpvBuffer, NULL);
-
- /* IIS puts a trailing slash on directories, Apache doesn't */
-
- if (S_ISDIR (subreq->finfo.st_mode)) {
- int l = strlen((char *)lpvBuffer);
-
- ((char *)lpvBuffer)[l] = '\\';
- ((char *)lpvBuffer)[l + 1] = '\0';
- }
-
- return TRUE;
-
- case HSE_REQ_DONE_WITH_SESSION:
- /* Do nothing... since we don't support async I/O, they'll
- * return from HttpExtensionProc soon
- */
- return TRUE;
-
- /* We don't support all this async I/O, Microsoft-specific stuff */
- case HSE_REQ_IO_COMPLETION:
- case HSE_REQ_TRANSMIT_FILE:
- ap_log_rerror(APLOG_MARK, APLOG_WARNING, r,
- "ISAPI asynchronous I/O not supported: %s", r->filename);
- default:
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-}
-
-handler_rec isapi_handlers[] = {
-{ "isapi-isa", isapi_handler },
-{ NULL}
-};
-
-module isapi_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* initializer */
- NULL, /* create per-dir config */
- NULL, /* merge per-dir config */
- NULL, /* server config */
- NULL, /* merge server config */
- NULL, /* command ap_table_t */
- isapi_handlers, /* handlers */
- NULL, /* filename translation */
- NULL, /* check_user_id */
- NULL, /* check auth */
- NULL, /* check access */
- NULL, /* type_checker */
- NULL, /* logger */
- NULL /* header parser */
-};
diff --git a/os/win32/modules.c b/os/win32/modules.c
deleted file mode 100644
index 8c624c2e80..0000000000
--- a/os/win32/modules.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/* modules.c --- major modules compiled into Apache for Win32.
- * Only insert an entry for a module if it must be compiled into
- * the core server
- */
-
-#include "httpd.h"
-#include "http_config.h"
-
-extern module core_module;
-extern module mpm_winnt_module;
-extern module so_module;
-extern module mime_module;
-extern module access_module;
-extern module auth_module;
-extern module negotiation_module;
-extern module includes_module;
-extern module autoindex_module;
-extern module dir_module;
-extern module cgi_module;
-extern module userdir_module;
-extern module alias_module;
-extern module env_module;
-extern module config_log_module;
-extern module asis_module;
-extern module imap_module;
-extern module action_module;
-extern module setenvif_module;
-//extern module isapi_module;
-
-module *ap_prelinked_modules[] = {
- &core_module,
- &mpm_winnt_module,
- &so_module,
- &mime_module,
- &access_module,
- &auth_module,
- &negotiation_module,
- &includes_module,
- &autoindex_module,
- &dir_module,
- &cgi_module,
- &userdir_module,
- &alias_module,
- &env_module,
- &config_log_module,
- &asis_module,
- &imap_module,
- &action_module,
- &setenvif_module,
-// &isapi_module,
- NULL
-};
-module *ap_preloaded_modules[] = {
- &core_module,
- &mpm_winnt_module,
- &so_module,
- &mime_module,
- &access_module,
- &auth_module,
- &negotiation_module,
- &includes_module,
- &autoindex_module,
- &dir_module,
- &cgi_module,
- &userdir_module,
- &alias_module,
- &env_module,
- &config_log_module,
- &asis_module,
- &imap_module,
- &action_module,
- &setenvif_module,
-// &isapi_module,
- NULL
-};
diff --git a/os/win32/os.h b/os/win32/os.h
deleted file mode 100644
index 05f36302b7..0000000000
--- a/os/win32/os.h
+++ /dev/null
@@ -1,209 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_OS_H
-#define APACHE_OS_H
-/*
- * 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.
- */
-#define _WIN32_WINNT 0x0400
-#include "apr_general.h"
-#include <windows.h>
-#include <winsock2.h>
-#include <mswsock.h>
-#include <process.h>
-#include <malloc.h>
-#include <io.h>
-#include <fcntl.h>
-
-#define 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
-#ifndef STRICT
-#define STRICT
-#endif
-#define CASE_BLIND_FILESYSTEM
-#define NO_WRITEV
-#define NO_USE_SIGACTION
-/* #undef HAVE_TIMES */
-/* #undef HAVE_GETTIMEOFDAY */
-#define USE_LONGJMP
-#define HAVE_MMAP
-#define USE_MMAP_SCOREBOARD
-#define MULTITHREAD
-#define HAVE_CANONICAL_FILENAME
-#define HAVE_DRIVE_LETTERS
-#define HAVE_SENDFILE
-
-typedef int uid_t;
-typedef int gid_t;
-typedef int pid_t;
-typedef int mode_t;
-typedef char * caddr_t;
-
-/*
-Define export types. API_EXPORT_NONSTD is a nasty hack to avoid having to declare
-every configuration function as __stdcall.
-*/
-
-#if 0 /* Handled by APR... */
-#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
-#else
-# define API_VAR_EXPORT __declspec(dllexport)
-# define API_EXPORT(type) __declspec(dllexport) type __stdcall
-# define API_EXPORT_NONSTD(type) __declspec(dllexport) type
-#endif
-#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)
-#define S_ISLNK(m) (0)
-#define S_ISREG(m) ((m & _S_IFREG) == _S_IFREG)
-#ifndef S_ISDIR
-#define S_ISDIR(m) (((m) & S_IFDIR) == S_IFDIR)
-#endif
-
-#if 0
-#ifndef S_ISREG
-#define S_ISREG(m) (((m)&(S_IFREG)) == (S_IFREG))
-#endif
-#endif
-
-#define STDIN_FILENO 0
-#define STDOUT_FILENO 1
-#define STDERR_FILENO 2
-#define JMP_BUF jmp_buf
-#define O_CREAT _O_CREAT
-#define O_RDWR _O_RDWR
-/* Seems Windows is not a subgenius */
-#define NO_SLACK
-#include <stddef.h>
-
-__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[0] == '/' || file[1] == ':';
-}
-
-#define _spawnv(mode,cmdname,argv) os_spawnv(mode,cmdname,argv)
-#define spawnv(mode,cmdname,argv) os_spawnv(mode,cmdname,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)
-#define _spawnle os_spawnle
-#define spawnle os_spawnle
-
-/* OS-dependent filename routines in util_win32.c */
-API_EXPORT(char *) ap_os_canonical_filename(ap_context_t *p, const char *file);
-API_EXPORT(char *) ap_os_case_canonical_filename(ap_context_t *pPool, const char *szFile);
-API_EXPORT(char *) ap_os_systemcase_filename(ap_context_t *pPool, const char *szFile);
-int ap_os_is_filename_valid(const char *file);
-int os_strftime(char *, size_t , const char *, const struct tm *);
-
-/* 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_load(l) LoadLibraryEx(l, NULL, LOAD_WITH_ALTERED_SEARCH_PATH)
-#define ap_os_dso_unload(l) FreeLibrary(l)
-#define ap_os_dso_sym(h,s) GetProcAddress(h,s)
-#define ap_os_dso_error() "" /* for now */
-
-/* Other ap_os_ routines not used by this platform */
-#define ap_os_kill(pid, sig) kill(pid, sig)
-
-/* Moved from multithread.h. Axe this stuff when APR comes online... */
-
-#define MULTI_OK (0)
-#define MULTI_TIMEOUT (1)
-#define MULTI_ERR (2)
-
-typedef void thread;
-typedef void event;
-
-thread *create_thread(void (thread_fn) (void *thread_arg), void *thread_arg);
-int kill_thread(thread *thread_id);
-int await_thread(thread *thread_id, int sec_to_wait);
-void exit_thread(int status);
-void free_thread(thread *thread_id);
-
-#endif /* ! APACHE_OS_H */
diff --git a/os/win32/resource.h b/os/win32/resource.h
deleted file mode 100644
index 820bb6aaaf..0000000000
--- a/os/win32/resource.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//{{NO_DEPENDENCIES}}
-// Microsoft Developer Studio generated include file.
-// Used by Apache.rc
-//
-#define IDI_APACHE 101
-
-// Next default values for new objects
-//
-#ifdef APSTUDIO_INVOKED
-#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NO_MFC 1
-#define _APS_NEXT_RESOURCE_VALUE 102
-#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1000
-#define _APS_NEXT_SYMED_VALUE 101
-#endif
-#endif
diff --git a/os/win32/util_win32.c b/os/win32/util_win32.c
deleted file mode 100644
index 161b6dd306..0000000000
--- a/os/win32/util_win32.c
+++ /dev/null
@@ -1,594 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#include <windows.h>
-#include <sys/stat.h>
-#include <stdarg.h>
-#include <time.h>
-#include <stdlib.h>
-
-#include "httpd.h"
-#include "http_log.h"
-
-/* Returns TRUE if the input string is a string
- * of one or more '.' characters.
- */
-static BOOL OnlyDots(char *pString)
-{
- char *c;
-
- if (*pString == '\0')
- return FALSE;
-
- for (c = pString;*c;c++)
- if (*c != '.')
- return FALSE;
-
- return TRUE;
-}
-
-/* Accepts as input a pathname, and tries to match it to an
- * existing path and return the pathname in the case that
- * is present on the existing path. This routine also
- * converts alias names to long names.
- */
-API_EXPORT(char *) ap_os_systemcase_filename(ap_context_t *pPool,
- const char *szFile)
-{
- char buf[HUGE_STRING_LEN];
- char *pInputName;
- char *p, *q;
- BOOL bDone = FALSE;
- BOOL bFileExists = TRUE;
- HANDLE hFind;
- WIN32_FIND_DATA wfd;
-
- if (!szFile || strlen(szFile) == 0 || strlen(szFile) >= sizeof(buf))
- return ap_pstrdup(pPool, "");
-
- buf[0] = '\0';
- pInputName = ap_pstrdup(pPool, szFile);
-
- /* First convert all slashes to \ so Win32 calls work OK */
- for (p = pInputName; *p; p++) {
- if (*p == '/')
- *p = '\\';
- }
-
- p = pInputName;
- /* If there is drive information, copy it over. */
- if (pInputName[1] == ':') {
- buf[0] = tolower(*p++);
- buf[1] = *p++;
- buf[2] = '\0';
-
- /* If all we have is a drive letter, then we are done */
- if (strlen(pInputName) == 2)
- bDone = TRUE;
- }
-
- q = p;
- if (*p == '\\') {
- p++;
- if (*p == '\\') /* Possible UNC name */
- {
- p++;
- /* Get past the machine name. FindFirstFile */
- /* will not find a machine name only */
- p = strchr(p, '\\');
- if (p)
- {
- p++;
- /* Get past the share name. FindFirstFile */
- /* will not find a \\machine\share name only */
- p = strchr(p, '\\');
- if (p) {
- strncat(buf,q,p-q);
- q = p;
- p++;
- }
- }
-
- if (!p)
- p = q;
- }
- }
-
- p = strchr(p, '\\');
-
- while (!bDone) {
- if (p)
- *p = '\0';
-
- if (strchr(q, '*') || strchr(q, '?'))
- bFileExists = FALSE;
-
- /* If the path exists so far, call FindFirstFile
- * again. However, if this portion of the path contains
- * only '.' charaters, skip the call to FindFirstFile
- * since it will convert '.' and '..' to actual names.
- * Note: in the call to OnlyDots, we may have to skip
- * a leading slash.
- */
- if (bFileExists && !OnlyDots((*q == '.' ? q : q+1))) {
- hFind = FindFirstFile(pInputName, &wfd);
-
- if (hFind == INVALID_HANDLE_VALUE) {
- bFileExists = FALSE;
- }
- else {
- FindClose(hFind);
-
- if (*q == '\\')
- strcat(buf,"\\");
- strcat(buf, wfd.cFileName);
- }
- }
-
- if (!bFileExists || OnlyDots((*q == '.' ? q : q+1))) {
- strcat(buf, q);
- }
-
- if (p) {
- q = p;
- *p++ = '\\';
- p = strchr(p, '\\');
- }
- else {
- bDone = TRUE;
- }
- }
-
- /* First convert all slashes to / so server code handles it ok */
- for (p = buf; *p; p++) {
- if (*p == '\\')
- *p = '/';
- }
-
- return ap_pstrdup(pPool, buf);
-}
-
-
-/* Perform canonicalization with the exception that the
- * input case is preserved.
- */
-API_EXPORT(char *) ap_os_case_canonical_filename(ap_context_t *pPool,
- const char *szFile)
-{
- char *pNewStr;
- char *s;
- char *p;
- char *q;
-
- if (szFile == NULL || strlen(szFile) == 0)
- return ap_pstrdup(pPool, "");
-
- pNewStr = ap_pstrdup(pPool, szFile);
-
- /* Change all '\' characters to '/' characters.
- * While doing this, remove any trailing '.'.
- * Also, blow away any directories with 3 or
- * more '.'
- */
- for (p = pNewStr,s = pNewStr; *s; s++,p++) {
- if (*s == '\\' || *s == '/') {
-
- q = p;
- while (p > pNewStr && *(p-1) == '.')
- p--;
-
- if (p == pNewStr && q-p <= 2 && *p == '.')
- p = q;
- else if (p > pNewStr && p < q && *(p-1) == '/') {
- if (q-p > 2)
- p--;
- else
- p = q;
- }
-
- *p = '/';
- }
- else {
- *p = *s;
- }
- }
- *p = '\0';
-
- /* Blow away any final trailing '.' since on Win32
- * foo.bat == foo.bat. == foo.bat... etc.
- * Also blow away any trailing spaces since
- * "filename" == "filename "
- */
- q = p;
- while (p > pNewStr && (*(p-1) == '.' || *(p-1) == ' '))
- p--;
- if ((p > pNewStr) ||
- (p == pNewStr && q-p > 2))
- *p = '\0';
-
-
- /* One more security issue to deal with. Win32 allows
- * you to create long filenames. However, alias filenames
- * are always created so that the filename will
- * conform to 8.3 rules. According to the Microsoft
- * Developer's network CD (1/98)
- * "Automatically generated aliases are composed of the
- * first six characters of the filename plus ~n
- * (where n is a number) and the first three characters
- * after the last period."
- * Here, we attempt to detect and decode these names.
- */
- p = strchr(pNewStr, '~');
- if (p != NULL) {
- char *pConvertedName, *pQstr, *pPstr;
- char buf[HUGE_STRING_LEN];
- /* We potentially have a short name. Call
- * ap_os_systemcase_filename to examine the filesystem
- * and possibly extract the long name.
- */
- pConvertedName = ap_os_systemcase_filename(pPool, pNewStr);
-
- /* Since we want to preserve the incoming case as much
- * as we can, compare for differences in the string and
- * only substitute in the path names that changed.
- */
- if (stricmp(pNewStr, pConvertedName)) {
- buf[0] = '\0';
-
- q = pQstr = pConvertedName;
- p = pPstr = pNewStr;
- do {
- q = strchr(q,'/');
- p = strchr(p,'/');
-
- if (p != NULL) {
- *q = '\0';
- *p = '\0';
- }
-
- if (stricmp(pQstr, pPstr))
- strcat(buf, pQstr); /* Converted name */
- else
- strcat(buf, pPstr); /* Original name */
-
-
- if (p != NULL) {
- pQstr = q;
- pPstr = p;
- *q++ = '/';
- *p++ = '/';
- }
-
- } while (p != NULL);
-
- pNewStr = ap_pstrdup(pPool, buf);
- }
- }
-
-
- return pNewStr;
-}
-
-/* Perform complete canonicalization.
- */
-API_EXPORT(char *) ap_os_canonical_filename(ap_context_t *pPool, const char *szFile)
-{
- char *pNewName;
- pNewName = ap_os_case_canonical_filename(pPool, szFile);
- strlwr(pNewName);
- return pNewName;
-}
-
-/* Win95 doesn't like trailing /s. NT and Unix don't mind. This works
- * around the problem.
- * Errr... except if it is UNC and we are referring to the root of
- * the UNC, we MUST have a trailing \ and we can't use /s. Jeez.
- * Not sure if this refers to all UNCs or just roots,
- * but I'm going to fix it for all cases for now. (Ben)
- */
-
-#undef stat
-API_EXPORT(int) os_stat(const char *szPath, struct stat *pStat)
-{
- int n;
-
- if (strlen(szPath) == 0) {
- return -1;
- }
-
- if (szPath[0] == '/' && szPath[1] == '/') {
- char buf[_MAX_PATH];
- char *s;
- int nSlashes = 0;
-
- ap_assert(strlen(szPath) < _MAX_PATH);
- strcpy(buf, szPath);
- for (s = buf; *s; ++s) {
- if (*s == '/') {
- *s = '\\';
- ++nSlashes;
- }
- }
- /* then we need to add one more to get \\machine\share\ */
- if (nSlashes == 3) {
- *s++ = '\\';
- }
- *s = '\0';
- return stat(buf, pStat);
- }
-
- /*
- * Below removes the trailing /, however, do not remove
- * it in the case of 'x:/' or stat will fail
- */
- n = strlen(szPath);
- if ((szPath[n - 1] == '\\' || szPath[n - 1] == '/') &&
- !(n == 3 && szPath[1] == ':')) {
- char buf[_MAX_PATH];
-
- ap_assert(n < _MAX_PATH);
- strcpy(buf, szPath);
- buf[n - 1] = '\0';
-
- return stat(buf, pStat);
- }
- return stat(szPath, pStat);
-}
-
-
-#undef strftime
-
-/* Partial replacement for strftime. This adds certain expandos to the
- * Windows version
- */
-
-API_EXPORT(int) os_strftime(char *s, size_t max, const char *format,
- const struct tm *tm) {
- /* If the new format string is bigger than max, the result string probably
- * won't fit anyway. When %-expandos are added, made sure the padding below
- * is enough.
- */
- char *new_format = (char *) _alloca(max + 11);
- size_t i, j, format_length = strlen(format);
- int return_value;
- int length_written;
-
- for (i = 0, j = 0; (i < format_length && j < max);) {
- if (format[i] != '%') {
- new_format[j++] = format[i++];
- continue;
- }
- switch (format[i+1]) {
- case 'D':
- /* Is this locale dependent? Shouldn't be...
- Also note the year 2000 exposure here */
- memcpy(new_format + j, "%m/%d/%y", 8);
- i += 2;
- j += 8;
- break;
- case 'r':
- memcpy(new_format + j, "%I:%M:%S %p", 11);
- i += 2;
- j += 11;
- break;
- case 'T':
- memcpy(new_format + j, "%H:%M:%S", 8);
- i += 2;
- j += 8;
- break;
- case 'e':
- length_written = ap_snprintf(new_format + j, max - j, "%2d",
- tm->tm_mday);
- j = (length_written == -1) ? max : (j + length_written);
- i += 2;
- break;
- default:
- /* We know we can advance two characters forward here. */
- new_format[j++] = format[i++];
- new_format[j++] = format[i++];
- }
- }
- if (j >= max) {
- *s = '\0'; /* Defensive programming, okay since output is undefined */
- return_value = 0;
- } else {
- new_format[j] = '\0';
- return_value = strftime(s, max, new_format, tm);
- }
- return return_value;
-}
-
-/*
- * ap_os_is_filename_valid is given a filename, and returns 0 if the filename
- * is not valid for use on this system. On Windows, this means it fails any
- * of the tests below. Otherwise returns 1.
- *
- * Test for filename validity on Win32. This is of tests come in part from
- * the MSDN article at "Technical Articles, Windows Platform, Base Services,
- * Guidelines, Making Room for Long Filenames" although the information
- * in MSDN about filename testing is incomplete or conflicting. There is a
- * similar set of tests in "Technical Articles, Windows Platform, Base Services,
- * Guidelines, Moving Unix Applications to Windows NT".
- *
- * The tests are:
- *
- * 1) total path length greater than MAX_PATH
- *
- * 2) anything using the octets 0-31 or characters " < > | :
- * (these are reserved for Windows use in filenames. In addition
- * each file system has its own additional characters that are
- * invalid. See KB article Q100108 for more details).
- *
- * 3) anything ending in "." (no matter how many)
- * (filename doc, doc. and doc... all refer to the same file)
- *
- * 4) any segment in which the basename (before first period) matches
- * one of the DOS device names
- * (the list comes from KB article Q100108 although some people
- * reports that additional names such as "COM5" are also special
- * devices).
- *
- * If the path fails ANY of these tests, the result must be to deny access.
- */
-
-API_EXPORT(int) ap_os_is_filename_valid(const char *file)
-{
- const char *segstart;
- unsigned int seglength;
- const char *pos;
- static const char * const invalid_characters = "?\"<>*|:";
- static const char * const invalid_filenames[] = {
- "CON", "AUX", "COM1", "COM2", "COM3",
- "COM4", "LPT1", "LPT2", "LPT3", "PRN", "NUL", NULL
- };
-
- /* Test 1 */
- if (strlen(file) > MAX_PATH) {
- /* Path too long for Windows. Note that this test is not valid
- * if the path starts with //?/ or \\?\. */
- return 0;
- }
-
- pos = file;
-
- /* Skip any leading non-path components. This can be either a
- * drive letter such as C:, or a UNC path such as \\SERVER\SHARE\.
- * We continue and check the rest of the path based on the rules above.
- * This means we could eliminate valid filenames from servers which
- * are not running NT (such as Samba).
- */
-
- if (pos[0] && pos[1] == ':') {
- /* Skip leading drive letter */
- pos += 2;
- }
- else {
- if ((pos[0] == '\\' || pos[0] == '/') &&
- (pos[1] == '\\' || pos[1] == '/')) {
- /* Is a UNC, so skip the server name and share name */
- pos += 2;
- while (*pos && *pos != '/' && *pos != '\\')
- pos++;
- if (!*pos) {
- /* No share name */
- return 0;
- }
- pos++; /* Move to start of share name */
- while (*pos && *pos != '/' && *pos != '\\')
- pos++;
- if (!*pos) {
- /* No path information */
- return 0;
- }
- }
- }
-
- while (*pos) {
- unsigned int idx;
- unsigned int baselength;
-
- while (*pos == '/' || *pos == '\\') {
- pos++;
- }
- if (*pos == '\0') {
- break;
- }
- segstart = pos; /* start of segment */
- while (*pos && *pos != '/' && *pos != '\\') {
- pos++;
- }
- seglength = pos - segstart;
- /*
- * Now we have a segment of the path, starting at position "segstart"
- * and length "seglength"
- */
-
- /* Test 2 */
- for (idx = 0; idx < seglength; idx++) {
- if ((segstart[idx] > 0 && segstart[idx] < 32) ||
- strchr(invalid_characters, segstart[idx])) {
- return 0;
- }
- }
-
- /* Test 3 */
- if (segstart[seglength-1] == '.') {
- return 0;
- }
-
- /* Test 4 */
- for (baselength = 0; baselength < seglength; baselength++) {
- if (segstart[baselength] == '.') {
- break;
- }
- }
-
- /* baselength is the number of characters in the base path of
- * the segment (which could be the same as the whole segment length,
- * if it does not include any dot characters). */
- if (baselength == 3 || baselength == 4) {
- for (idx = 0; invalid_filenames[idx]; idx++) {
- if (strlen(invalid_filenames[idx]) == baselength &&
- !strnicmp(invalid_filenames[idx], segstart, baselength)) {
- return 0;
- }
- }
- }
- }
-
- return 1;
-}
diff --git a/server/.cvsignore b/server/.cvsignore
deleted file mode 100644
index dde5146cac..0000000000
--- a/server/.cvsignore
+++ /dev/null
@@ -1,17 +0,0 @@
-Makefile
-.deps
-.libs
-*.lo
-*.la
-uri_delims.h
-gen_uri_delims
-test_char.h
-gen_test_char
-gen_uri_delims_R
-gen_test_char_R
-gen_uri_delims_D
-gen_uri_delims.ilk
-gen_uri_delims.pdb
-gen_test_char_D
-gen_test_char.ilk
-gen_test_char.pdb
diff --git a/server/.indent.pro b/server/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/server/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/server/Makefile.in b/server/Makefile.in
deleted file mode 100644
index 86facf2fdd..0000000000
--- a/server/Makefile.in
+++ /dev/null
@@ -1,32 +0,0 @@
-
-DEPTH = ..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-LTLIBRARY_NAME = libmain.la
-LTLIBRARY_SOURCES = \
- uri_delims.h test_char.h \
- buff.c http_config.c http_core.c http_log.c http_main.c \
- http_protocol.c http_request.c http_vhost.c util.c util_date.c \
- util_script.c util_uri.c util_md5.c \
- rfc1413.c http_connection.c iol_file.c listen.c
-
-include $(topsrcdir)/build/ltlib.mk
-
-gen_uri_delims_OBJECTS = gen_uri_delims.lo
-gen_uri_delims: $(gen_uri_delims_OBJECTS)
- $(LINK) $(gen_uri_delims_OBJECTS)
-
-gen_test_char_OBJECTS = gen_test_char.lo
-gen_test_char: $(gen_test_char_OBJECTS)
- $(LINK) $(gen_test_char_OBJECTS)
-
-uri_delims.h: gen_uri_delims
- ./gen_uri_delims > uri_delims.h
-
-test_char.h: gen_test_char
- ./gen_test_char > test_char.h
-
-util_uri.c: uri_delims.h
-util.c: test_char.h
diff --git a/server/buildmark.c b/server/buildmark.c
deleted file mode 100644
index 575b9731a0..0000000000
--- a/server/buildmark.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-
-#if defined(__DATE__) && defined(__TIME__)
-static const char server_built[] = __DATE__ " " __TIME__;
-#else
-static const char server_built[] = "unknown";
-#endif
-
-API_EXPORT(const char *) ap_get_server_built()
-{
- return server_built;
-}
diff --git a/server/config.c b/server/config.c
deleted file mode 100644
index fbb7c93a6f..0000000000
--- a/server/config.c
+++ /dev/null
@@ -1,1438 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_config.c: once was auxillary functions for reading httpd's config
- * file and converting filenames into a namespace
- *
- * Rob McCool
- *
- * Wall-to-wall rewrite for Apache... commands which are part of the
- * server core can now be found next door in "http_core.c". Now contains
- * general command loop, and functions which do bookkeeping for the new
- * Apache config stuff (modules and configuration vectors).
- *
- * rst
- *
- */
-
-#define CORE_PRIVATE
-
-#include "ap_config.h"
-#include "apr_portable.h"
-#include "apr_file_io.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h" /* for errors in parse_htaccess */
-#include "http_request.h" /* for default_handler (see invoke_handler) */
-#include "http_main.h"
-#include "http_vhost.h"
-
-HOOK_STRUCT(
- HOOK_LINK(header_parser)
- HOOK_LINK(pre_config)
- HOOK_LINK(post_config)
- HOOK_LINK(open_logs)
- HOOK_LINK(child_init)
-)
-
-IMPLEMENT_HOOK_RUN_ALL(int,header_parser,(request_rec *r),(r),OK,DECLINED)
-IMPLEMENT_HOOK_VOID(pre_config,(ap_context_t *pconf,ap_context_t *plog,ap_context_t *ptemp),
- (pconf,plog,ptemp))
-IMPLEMENT_HOOK_VOID(post_config,
- (ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s),
- (pconf,plog,ptemp,s))
-IMPLEMENT_HOOK_VOID(open_logs,
- (ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s),
- (pconf,plog,ptemp,s))
-IMPLEMENT_HOOK_VOID(child_init,(ap_context_t *pchild, server_rec *s),(pchild,s))
-
-/****************************************************************
- *
- * We begin with the functions which deal with the linked list
- * of modules which control just about all of the server operation.
- */
-
-/* total_modules is the number of modules that have been linked
- * into the server.
- */
-static int total_modules = 0;
-/* dynamic_modules is the number of modules that have been added
- * after the pre-loaded ones have been set up. It shouldn't be larger
- * than DYNAMIC_MODULE_LIMIT.
- */
-static int dynamic_modules = 0;
-API_VAR_EXPORT module *top_module = NULL;
-API_VAR_EXPORT module **ap_loaded_modules=NULL;
-
-typedef int (*handler_func) (request_rec *);
-typedef void *(*dir_maker_func) (ap_context_t *, char *);
-typedef void *(*merger_func) (ap_context_t *, void *, void *);
-
-/* Dealing with config vectors. These are associated with per-directory,
- * per-server, and per-request configuration, and have a void* pointer for
- * each modules. The nature of the structure pointed to is private to the
- * module in question... the core doesn't (and can't) know. However, there
- * are defined interfaces which allow it to create instances of its private
- * per-directory and per-server structures, and to merge the per-directory
- * structures of a directory and its subdirectory (producing a new one in
- * which the defaults applying to the base directory have been properly
- * overridden).
- */
-
-#ifndef ap_get_module_config
-API_EXPORT(void *) ap_get_module_config(void *conf_vector, module *m)
-{
- void **confv = (void **) conf_vector;
- return confv[m->module_index];
-}
-#endif
-
-#ifndef ap_set_module_config
-API_EXPORT(void) ap_set_module_config(void *conf_vector, module *m, void *val)
-{
- void **confv = (void **) conf_vector;
- confv[m->module_index] = val;
-}
-#endif
-
-static void *create_empty_config(ap_context_t *p)
-{
- void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) *
- (total_modules + DYNAMIC_MODULE_LIMIT));
- return (void *) conf_vector;
-}
-
-static void *create_default_per_dir_config(ap_context_t *p)
-{
- void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
- module *modp;
-
- for (modp = top_module; modp; modp = modp->next) {
- dir_maker_func df = modp->create_dir_config;
-
- if (df)
- conf_vector[modp->module_index] = (*df) (p, NULL);
- }
-
- return (void *) conf_vector;
-}
-
-void *
- ap_merge_per_dir_configs(ap_context_t *p, void *base, void *new)
-{
- void **conf_vector = (void **) ap_palloc(p, sizeof(void *) * total_modules);
- void **base_vector = (void **) base;
- void **new_vector = (void **) new;
- module *modp;
-
- for (modp = top_module; modp; modp = modp->next) {
- merger_func df = modp->merge_dir_config;
- int i = modp->module_index;
-
- if (df && new_vector[i])
- conf_vector[i] = (*df) (p, base_vector[i], new_vector[i]);
- else
- conf_vector[i] = new_vector[i] ? new_vector[i] : base_vector[i];
- }
-
- return (void *) conf_vector;
-}
-
-static void *create_server_config(ap_context_t *p, server_rec *s)
-{
- void **conf_vector = (void **) ap_pcalloc(p, sizeof(void *) * (total_modules + DYNAMIC_MODULE_LIMIT));
- module *modp;
-
- for (modp = top_module; modp; modp = modp->next) {
- if (modp->create_server_config)
- conf_vector[modp->module_index] = (*modp->create_server_config) (p, s);
- }
-
- return (void *) conf_vector;
-}
-
-static void merge_server_configs(ap_context_t *p, void *base, void *virt)
-{
- /* Can reuse the 'virt' vector for the spine of it, since we don't
- * have to deal with the moral equivalent of .htaccess files here...
- */
-
- void **base_vector = (void **) base;
- void **virt_vector = (void **) virt;
- module *modp;
-
- for (modp = top_module; modp; modp = modp->next) {
- merger_func df = modp->merge_server_config;
- int i = modp->module_index;
-
- if (!virt_vector[i])
- virt_vector[i] = base_vector[i];
- else if (df)
- virt_vector[i] = (*df) (p, base_vector[i], virt_vector[i]);
- }
-}
-
-void *ap_create_request_config(ap_context_t *p)
-{
- return create_empty_config(p);
-}
-
-void *ap_create_conn_config(ap_context_t *p)
-{
- return create_empty_config(p);
-}
-
-CORE_EXPORT(void *) ap_create_per_dir_config(ap_context_t *p)
-{
- return create_empty_config(p);
-}
-
-/*
- * For speed/efficiency we generate a compact list of all the handlers
- * and wildcard handlers. This means we won't have to scan the entire
- * module list looking for handlers... where we'll find a whole whack
- * of NULLs.
- */
-typedef struct {
- handler_rec hr;
- size_t len;
-} fast_handler_rec;
-
-static fast_handler_rec *handlers;
-static fast_handler_rec *wildhandlers;
-
-static void init_handlers(ap_context_t *p)
-{
- module *modp;
- int nhandlers = 0;
- int nwildhandlers = 0;
- const handler_rec *handp;
- fast_handler_rec *ph, *pw;
- char *starp;
-
- for (modp = top_module; modp; modp = modp->next) {
- if (!modp->handlers)
- continue;
- for (handp = modp->handlers; handp->content_type; ++handp) {
- if (strchr(handp->content_type, '*')) {
- nwildhandlers ++;
- } else {
- nhandlers ++;
- }
- }
- }
- ph = handlers = ap_palloc(p, sizeof(*ph)*(nhandlers + 1));
- pw = wildhandlers = ap_palloc(p, sizeof(*pw)*(nwildhandlers + 1));
- for (modp = top_module; modp; modp = modp->next) {
- if (!modp->handlers)
- continue;
- for (handp = modp->handlers; handp->content_type; ++handp) {
- if ((starp = strchr(handp->content_type, '*'))) {
- pw->hr.content_type = handp->content_type;
- pw->hr.handler = handp->handler;
- pw->len = starp - handp->content_type;
- pw ++;
- } else {
- ph->hr.content_type = handp->content_type;
- ph->hr.handler = handp->handler;
- ph->len = strlen(handp->content_type);
- ph ++;
- }
- }
- }
- pw->hr.content_type = NULL;
- pw->hr.handler = NULL;
- ph->hr.content_type = NULL;
- ph->hr.handler = NULL;
-}
-
-int ap_invoke_handler(request_rec *r)
-{
- fast_handler_rec *handp;
- const char *handler;
- char *p;
- size_t handler_len;
- int result = HTTP_INTERNAL_SERVER_ERROR;
-
- if (r->handler) {
- handler = r->handler;
- handler_len = strlen(handler);
- }
- else {
- handler = r->content_type ? r->content_type : ap_default_type(r);
- if ((p = strchr(handler, ';')) != NULL) { /* MIME type arguments */
- while (p > handler && p[-1] == ' ')
- --p; /* strip trailing spaces */
- handler_len = p - handler;
- }
- else {
- handler_len = strlen(handler);
- }
- }
-
- /* Pass one --- direct matches */
-
- for (handp = handlers; handp->hr.content_type; ++handp) {
- if (handler_len == handp->len
- && !strncmp(handler, handp->hr.content_type, handler_len)) {
- result = (*handp->hr.handler) (r);
-
- if (result != DECLINED)
- return result;
- }
- }
-
- /* Pass two --- wildcard matches */
-
- for (handp = wildhandlers; handp->hr.content_type; ++handp) {
- if (handler_len >= handp->len
- && !strncmp(handler, handp->hr.content_type, handp->len)) {
- result = (*handp->hr.handler) (r);
-
- if (result != DECLINED)
- return result;
- }
- }
-
- if (result == HTTP_INTERNAL_SERVER_ERROR && r->handler && r->filename) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, r,
- "handler \"%s\" not found for: %s", r->handler, r->filename);
- }
- return HTTP_INTERNAL_SERVER_ERROR;
-}
-
-int g_bDebugHooks;
-const char *g_szCurrentHookName;
-
-static void register_hooks(module *m)
- {
- if(m->register_hooks)
- {
- if(getenv("SHOW_HOOKS"))
- {
- printf("Registering hooks for %s\n",m->name);
- g_bDebugHooks=1;
- }
- g_szCurrentHookName=m->name;
- m->register_hooks();
- }
- }
-
-/* One-time setup for precompiled modules --- NOT to be done on restart */
-
-API_EXPORT(void) ap_add_module(module *m)
-{
- /* This could be called from an AddModule httpd.conf command,
- * after the file has been linked and the module structure within it
- * teased out...
- */
-
- if (m->version != MODULE_MAGIC_NUMBER_MAJOR) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: module \"%s\" is not compatible with this "
- "version of Apache.", ap_server_argv0, m->name);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Please contact the vendor for the correct version.");
- exit(1);
- }
-
- if (m->next == NULL) {
- m->next = top_module;
- top_module = m;
- }
- if (m->module_index == -1) {
- m->module_index = total_modules++;
- dynamic_modules++;
-
- if (dynamic_modules > DYNAMIC_MODULE_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: module \"%s\" could not be loaded, because"
- " the dynamic", ap_server_argv0, m->name);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "module limit was reached. Please increase "
- "DYNAMIC_MODULE_LIMIT and recompile.");
- exit(1);
- }
- }
-
- /* Some C compilers put a complete path into __FILE__, but we want
- * only the filename (e.g. mod_includes.c). So check for path
- * components (Unix and DOS), and remove them.
- */
-
- if (strrchr(m->name, '/'))
- m->name = 1 + strrchr(m->name, '/');
- if (strrchr(m->name, '\\'))
- m->name = 1 + strrchr(m->name, '\\');
-
-#ifdef _OSD_POSIX /* __FILE__="*POSIX(/home/martin/apache/src/modules/standard/mod_info.c)" */
- /* We cannot fix the string in-place, because it's const */
- if (m->name[strlen(m->name)-1]==')') {
- char *tmp = strdup(m->name); /* FIXME:memory leak, albeit a small one */
- tmp[strlen(tmp)-1] = '\0';
- m->name = tmp;
- }
-#endif /*_OSD_POSIX*/
-
- /* FIXME: is this the right place to call this? */
- register_hooks(m);
-}
-
-/*
- * remove_module undoes what add_module did. 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.
- */
-
-API_EXPORT(void) ap_remove_module(module *m)
-{
- module *modp;
-
- modp = top_module;
- if (modp == m) {
- /* We are the top module, special case */
- top_module = modp->next;
- m->next = NULL;
- }
- else {
- /* Not the top module, find use. When found modp will
- * point to the module _before_ us in the list
- */
-
- while (modp && modp->next != m) {
- modp = modp->next;
- }
- if (!modp) {
- /* Uh-oh, this module doesn't exist */
- ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, NULL,
- "Cannot remove module %s: not found in module list",
- m->name);
- return;
- }
- /* Eliminate us from the module list */
- modp->next = modp->next->next;
- }
-
- m->module_index = -1; /* simulate being unloaded, should
- * be unnecessary */
- dynamic_modules--;
- total_modules--;
-}
-
-API_EXPORT(void) ap_add_loaded_module(module *mod)
-{
- module **m;
-
- /*
- * Add module pointer to top of chained module list
- */
- ap_add_module(mod);
-
- /*
- * And module pointer to list of loaded modules
- *
- * Notes: 1. ap_add_module() would already complain if no more space
- * exists for adding a dynamically loaded module
- * 2. ap_add_module() accepts double inclusion, so we have
- * to accept this, too.
- */
- for (m = ap_loaded_modules; *m != NULL; m++)
- ;
- *m++ = mod;
- *m = NULL;
-}
-
-API_EXPORT(void) ap_remove_loaded_module(module *mod)
-{
- module **m;
- module **m2;
- int done;
-
- /*
- * Remove module pointer from chained module list
- */
- ap_remove_module(mod);
-
- /*
- * Remove module pointer from list of loaded modules
- *
- * Note: 1. We cannot determine if the module was successfully
- * removed by ap_remove_module().
- * 2. We have not to complain explicity when the module
- * is not found because ap_remove_module() did it
- * for us already.
- */
- for (m = m2 = ap_loaded_modules, done = 0; *m2 != NULL; m2++) {
- if (*m2 == mod && done == 0)
- done = 1;
- else
- *m++ = *m2;
- }
- *m = NULL;
-}
-
-void ap_setup_prelinked_modules(process_rec *process)
-{
- module **m;
- module **m2;
-
- /*
- * Initialise total_modules variable and module indices
- */
- total_modules = 0;
- for (m = ap_preloaded_modules; *m != NULL; m++)
- (*m)->module_index = total_modules++;
-
- /*
- * Initialise list of loaded modules
- */
- ap_loaded_modules = (module **)ap_palloc(process->pool,
- sizeof(module *)*(total_modules+DYNAMIC_MODULE_LIMIT+1));
- if (ap_loaded_modules == NULL) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Ouch! Out of memory in ap_setup_prelinked_modules()!");
- }
- for (m = ap_preloaded_modules, m2 = ap_loaded_modules; *m != NULL; )
- *m2++ = *m++;
- *m2 = NULL;
-
- /*
- * Initialize chain of linked (=activate) modules
- */
- for (m = ap_prelinked_modules; *m != NULL; m++)
- ap_add_module(*m);
-
- ap_sort_hooks();
-}
-
-API_EXPORT(const char *) ap_find_module_name(module *m)
-{
- return m->name;
-}
-
-API_EXPORT(module *) ap_find_linked_module(const char *name)
-{
- module *modp;
-
- for (modp = top_module; modp; modp = modp->next) {
- if (strcmp(modp->name, name) == 0)
- return modp;
- }
- return NULL;
-}
-
-/* Add a named module. Returns 1 if module found, 0 otherwise. */
-API_EXPORT(int) ap_add_named_module(const char *name)
-{
- module *modp;
- int i = 0;
-
- for (modp = ap_loaded_modules[i]; modp; modp = ap_loaded_modules[++i]) {
- if (strcmp(modp->name, name) == 0) {
- /* Only add modules that are not already enabled. */
- if (modp->next == NULL) {
- ap_add_module(modp);
- }
- return 1;
- }
- }
-
- return 0;
-}
-
-/* Clear the internal list of modules, in preparation for starting over. */
-API_EXPORT(void) ap_clear_module_list()
-{
- module **m = &top_module;
- module **next_m;
-
- while (*m) {
- next_m = &((*m)->next);
- *m = NULL;
- m = next_m;
- }
-
- /* This is required; so we add it always. */
- ap_add_named_module("http_core.c");
-}
-
-/*****************************************************************
- *
- * Resource, access, and .htaccess config files now parsed by a common
- * command loop.
- *
- * Let's begin with the basics; parsing the line and
- * invoking the function...
- */
-
-static const char *invoke_cmd(const command_rec *cmd, cmd_parms *parms,
- void *mconfig, const char *args)
-{
- char *w, *w2, *w3;
- const char *errmsg;
-
- if ((parms->override & cmd->req_override) == 0)
- return ap_pstrcat(parms->pool, cmd->name, " not allowed here", NULL);
-
- parms->info = cmd->cmd_data;
- parms->cmd = cmd;
-
- switch (cmd->args_how) {
- case RAW_ARGS:
- return ((const char *(*)(cmd_parms *, void *, const char *))
- (cmd->func)) (parms, mconfig, args);
-
- case NO_ARGS:
- if (*args != 0)
- return ap_pstrcat(parms->pool, cmd->name, " takes no arguments",
- NULL);
-
- return ((const char *(*)(cmd_parms *, void *))
- (cmd->func)) (parms, mconfig);
-
- case TAKE1:
- w = ap_getword_conf(parms->pool, &args);
-
- if (*w == '\0' || *args != 0)
- return ap_pstrcat(parms->pool, cmd->name, " takes one argument",
- cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
-
- return ((const char *(*)(cmd_parms *, void *, const char *))
- (cmd->func)) (parms, mconfig, w);
-
- case TAKE2:
-
- w = ap_getword_conf(parms->pool, &args);
- w2 = ap_getword_conf(parms->pool, &args);
-
- if (*w == '\0' || *w2 == '\0' || *args != 0)
- return ap_pstrcat(parms->pool, cmd->name, " takes two arguments",
- cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
-
- return ((const char *(*)(cmd_parms *, void *, const char *,
- const char *)) (cmd->func)) (parms, mconfig, w, w2);
-
- case TAKE12:
-
- w = ap_getword_conf(parms->pool, &args);
- w2 = ap_getword_conf(parms->pool, &args);
-
- if (*w == '\0' || *args != 0)
- return ap_pstrcat(parms->pool, cmd->name, " takes 1-2 arguments",
- cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
-
- return ((const char *(*)(cmd_parms *, void *, const char *,
- const char *)) (cmd->func)) (parms, mconfig, w,
- *w2 ? w2 : NULL);
-
- case TAKE3:
-
- w = ap_getword_conf(parms->pool, &args);
- w2 = ap_getword_conf(parms->pool, &args);
- w3 = ap_getword_conf(parms->pool, &args);
-
- if (*w == '\0' || *w2 == '\0' || *w3 == '\0' || *args != 0)
- return ap_pstrcat(parms->pool, cmd->name, " takes three arguments",
- cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
-
- return ((const char *(*)(cmd_parms *, void *, const char *,
- const char *, const char *)) (cmd->func)) (parms,
- mconfig, w, w2, w3);
-
- case TAKE23:
-
- w = ap_getword_conf(parms->pool, &args);
- w2 = ap_getword_conf(parms->pool, &args);
- w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
-
- if (*w == '\0' || *w2 == '\0' || *args != 0)
- return ap_pstrcat(parms->pool, cmd->name,
- " takes two or three arguments",
- cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
-
- return ((const char *(*)(cmd_parms *, void *, const char *,
- const char *, const char *)) (cmd->func)) (parms,
- mconfig, w, w2, w3);
-
- case TAKE123:
-
- w = ap_getword_conf(parms->pool, &args);
- w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
- w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
-
- if (*w == '\0' || *args != 0)
- return ap_pstrcat(parms->pool, cmd->name,
- " takes one, two or three arguments",
- cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
-
- return ((const char *(*)(cmd_parms *, void *, const char *,
- const char *, const char *)) (cmd->func)) (parms,
- mconfig, w, w2, w3);
-
- case TAKE13:
-
- w = ap_getword_conf(parms->pool, &args);
- w2 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
- w3 = *args ? ap_getword_conf(parms->pool, &args) : NULL;
-
- if (*w == '\0' || (*w2 && !w3) || *args != 0)
- return ap_pstrcat(parms->pool, cmd->name,
- " takes one or three arguments",
- cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
-
- return ((const char *(*)(cmd_parms *, void *, const char *,
- const char *, const char *)) (cmd->func)) (parms,
- mconfig, w, w2, w3);
-
- case ITERATE:
-
- while (*(w = ap_getword_conf(parms->pool, &args)) != '\0')
- if ((errmsg = ((const char *(*)(cmd_parms *, void *,
- const char *)) (cmd->func)) (parms, mconfig, w)))
- return errmsg;
-
- return NULL;
-
- case ITERATE2:
-
- w = ap_getword_conf(parms->pool, &args);
-
- if (*w == '\0' || *args == 0)
- return ap_pstrcat(parms->pool, cmd->name,
- " requires at least two arguments",
- cmd->errmsg ? ", " : NULL, cmd->errmsg, NULL);
-
-
- while (*(w2 = ap_getword_conf(parms->pool, &args)) != '\0')
- if ((errmsg = ((const char *(*)(cmd_parms *, void *,
- const char *, const char *)) (cmd->func)) (parms,
- mconfig, w, w2)))
- return errmsg;
-
- return NULL;
-
- case FLAG:
-
- w = ap_getword_conf(parms->pool, &args);
-
- if (*w == '\0' || (strcasecmp(w, "on") && strcasecmp(w, "off")))
- return ap_pstrcat(parms->pool, cmd->name, " must be On or Off",
- NULL);
-
- return ((const char *(*)(cmd_parms *, void *, int))
- (cmd->func)) (parms, mconfig, strcasecmp(w, "off") != 0);
-
- default:
-
- return ap_pstrcat(parms->pool, cmd->name,
- " is improperly configured internally (server bug)",
- NULL);
- }
-}
-
-CORE_EXPORT(const command_rec *) ap_find_command(const char *name, const command_rec *cmds)
-{
- while (cmds->name)
- if (!strcasecmp(name, cmds->name))
- return cmds;
- else
- ++cmds;
-
- return NULL;
-}
-
-CORE_EXPORT(const command_rec *) ap_find_command_in_modules(const char *cmd_name, module **mod)
-{
- const command_rec *cmdp;
- module *modp;
-
- for (modp = *mod; modp; modp = modp->next)
- if (modp->cmds && (cmdp = ap_find_command(cmd_name, modp->cmds))) {
- *mod = modp;
- return cmdp;
- }
-
- return NULL;
-}
-
-CORE_EXPORT(void *) ap_set_config_vectors(cmd_parms *parms, void *config, module *mod)
-{
- void *mconfig = ap_get_module_config(config, mod);
- void *sconfig = ap_get_module_config(parms->server->module_config, mod);
-
- if (!mconfig && mod->create_dir_config) {
- mconfig = (*mod->create_dir_config) (parms->pool, parms->path);
- ap_set_module_config(config, mod, mconfig);
- }
-
- if (!sconfig && mod->create_server_config) {
- sconfig = (*mod->create_server_config) (parms->pool, parms->server);
- ap_set_module_config(parms->server->module_config, mod, sconfig);
- }
- return mconfig;
-}
-
-CORE_EXPORT(const char *) ap_handle_command(cmd_parms *parms, void *config, const char *l)
-{
- void *oldconfig;
- const char *args, *cmd_name, *retval;
- const command_rec *cmd;
- module *mod = top_module;
-
- if ((l[0] == '#') || (!l[0]))
- return NULL;
-
- args = l;
- cmd_name = ap_getword_conf(parms->temp_pool, &args);
- if (*cmd_name == '\0')
- return NULL;
-
- oldconfig = parms->context;
- parms->context = config;
- do {
- if (!(cmd = ap_find_command_in_modules(cmd_name, &mod))) {
- errno = EINVAL;
- return ap_pstrcat(parms->pool, "Invalid command '", cmd_name,
- "', perhaps mis-spelled or defined by a module "
- "not included in the server configuration", NULL);
- }
- else {
- void *mconfig = ap_set_config_vectors(parms,config, mod);
-
- retval = invoke_cmd(cmd, parms, mconfig, args);
- mod = mod->next; /* Next time around, skip this one */
- }
- } while (retval && !strcmp(retval, DECLINE_CMD));
- parms->context = oldconfig;
-
- return retval;
-}
-
-API_EXPORT(const char *) ap_srm_command_loop(cmd_parms *parms, void *config)
-{
- char l[MAX_STRING_LEN];
-
- while (!(ap_cfg_getline(l, MAX_STRING_LEN, parms->config_file))) {
- const char *errmsg = ap_handle_command(parms, config, l);
- if (errmsg) {
- return errmsg;
- }
- }
-
- return NULL;
-}
-
-/*
- * Generic command functions...
- */
-
-API_EXPORT_NONSTD(const char *) ap_set_string_slot(cmd_parms *cmd,
- char *struct_ptr, char *arg)
-{
- /* This one's pretty generic... */
-
- int offset = (int) (long) cmd->info;
- *(char **) (struct_ptr + offset) = arg;
- return NULL;
-}
-
-API_EXPORT_NONSTD(const char *) ap_set_string_slot_lower(cmd_parms *cmd,
- char *struct_ptr, char *arg)
-{
- /* This one's pretty generic... */
-
- int offset = (int) (long) cmd->info;
- ap_str_tolower(arg);
- *(char **) (struct_ptr + offset) = arg;
- return NULL;
-}
-
-API_EXPORT_NONSTD(const char *) ap_set_flag_slot(cmd_parms *cmd,
- char *struct_ptr, int arg)
-{
- /* This one's pretty generic too... */
-
- int offset = (int) (long) cmd->info;
- *(int *) (struct_ptr + offset) = arg ? 1 : 0;
- return NULL;
-}
-
-API_EXPORT_NONSTD(const char *) ap_set_file_slot(cmd_parms *cmd, char *struct_ptr, char *arg)
-{
- /* Prepend server_root to relative arg.
- This allows .htaccess to be independent of server_root,
- so the server can be moved or mirrored with less pain. */
- char *p;
- int offset = (int) (long) cmd->info;
- if (ap_os_is_path_absolute(arg))
- p = arg;
- else
- p = ap_make_full_path(cmd->pool, ap_server_root, arg);
- *(char **) (struct_ptr + offset) = p;
- return NULL;
-}
-
-/*****************************************************************
- *
- * Reading whole config files...
- */
-
-static cmd_parms default_parms =
-{NULL, 0, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
-
-API_EXPORT(const char *) ap_server_root_relative(ap_context_t *p, const char *file)
-{
- if(ap_os_is_path_absolute(file))
- return file;
- return ap_make_full_path(p, ap_server_root, file);
-}
-
-
-/* This structure and the following functions are needed for the
- * table-based config file reading. They are passed to the
- * cfg_open_custom() routine.
- */
-
-/* Structure to be passed to cfg_open_custom(): it contains an
- * index which is incremented from 0 to nelts on each call to
- * cfg_getline() (which in turn calls arr_elts_getstr())
- * and an ap_array_header_t pointer for the string array.
- */
-typedef struct {
- ap_array_header_t *array;
- int curr_idx;
-} arr_elts_param_t;
-
-
-/* arr_elts_getstr() returns the next line from the string array. */
-static void *arr_elts_getstr(void *buf, size_t bufsiz, void *param)
-{
- arr_elts_param_t *arr_param = (arr_elts_param_t *) param;
-
- /* End of array reached? */
- if (++arr_param->curr_idx > arr_param->array->nelts)
- return NULL;
-
- /* return the line */
- ap_cpystrn(buf, ((char **) arr_param->array->elts)[arr_param->curr_idx - 1], bufsiz);
-
- return buf;
-}
-
-
-/* arr_elts_close(): dummy close routine (makes sure no more lines can be read) */
-static int arr_elts_close(void *param)
-{
- arr_elts_param_t *arr_param = (arr_elts_param_t *) param;
- arr_param->curr_idx = arr_param->array->nelts;
- return 0;
-}
-
-static void process_command_config(server_rec *s, ap_array_header_t *arr, ap_context_t *p,
- ap_context_t *ptemp)
-{
- const char *errmsg;
- cmd_parms parms;
- arr_elts_param_t arr_parms;
-
- arr_parms.curr_idx = 0;
- arr_parms.array = arr;
-
- parms = default_parms;
- parms.pool = p;
- parms.temp_pool = ptemp;
- parms.server = s;
- parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
- parms.config_file = ap_pcfg_open_custom(p, "-c/-C directives",
- &arr_parms, NULL,
- arr_elts_getstr, arr_elts_close);
-
- errmsg = ap_srm_command_loop(&parms, s->lookup_defaults);
-
- if (errmsg) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Syntax error in -C/-c directive:\n%s", errmsg);
- exit(1);
- }
-
- ap_cfg_closefile(parms.config_file);
-}
-
-void ap_process_resource_config(server_rec *s, const char *fname, ap_context_t *p, ap_context_t *ptemp)
-{
- const char *errmsg;
- cmd_parms parms;
- ap_finfo_t finfo;
-
- fname = ap_server_root_relative(p, fname);
-
- if (!(strcmp(fname, ap_server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
- !(strcmp(fname, ap_server_root_relative(p, ACCESS_CONFIG_FILE)))) {
- if (ap_stat(&finfo, fname, p) != APR_SUCCESS)
- return;
- }
-
- /* don't require conf/httpd.conf if we have a -C or -c switch */
- if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) &&
- !(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
- if (ap_stat(&finfo, fname, p) != APR_SUCCESS)
- return;
- }
-
- /* GCC's initialization extensions are soooo nice here... */
-
- parms = default_parms;
- parms.pool = p;
- parms.temp_pool = ptemp;
- parms.server = s;
- parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
-
- if (ap_pcfg_openfile(&parms.config_file, p, fname) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: could not open document config file %s",
- ap_server_argv0, fname);
- exit(1);
- }
-
- errmsg = ap_srm_command_loop(&parms, s->lookup_defaults);
-
- if (errmsg) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Syntax error on line %d of %s:",
- parms.config_file->line_number, parms.config_file->name);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s", errmsg);
- exit(1);
- }
-
- ap_cfg_closefile(parms.config_file);
-}
-
-
-int ap_parse_htaccess(void **result, request_rec *r, int override,
- const char *d, const char *access_name)
-{
- configfile_t *f = NULL;
- cmd_parms parms;
- const char *errmsg;
- char *filename = NULL;
- const struct htaccess_result *cache;
- struct htaccess_result *new;
- void *dc = NULL;
- ap_status_t status;
-
-/* firstly, search cache */
- for (cache = r->htaccess; cache != NULL; cache = cache->next)
- if (cache->override == override && strcmp(cache->dir, d) == 0) {
- if (cache->htaccess != NULL)
- *result = cache->htaccess;
- return OK;
- }
-
- parms = default_parms;
- parms.override = override;
- parms.pool = r->pool;
- parms.temp_pool = r->pool;
- parms.server = r->server;
- parms.path = ap_pstrdup(r->pool, d);
-
- /* loop through the access names and find the first one */
-
- while (access_name[0]) {
- filename = ap_make_full_path(r->pool, d,
- ap_getword_conf(r->pool, &access_name));
- status = ap_pcfg_openfile(&f, r->pool, filename);
-
- if (status == APR_SUCCESS) {
-
- dc = ap_create_per_dir_config(r->pool);
-
- parms.config_file = f;
-
- errmsg = ap_srm_command_loop(&parms, dc);
-
- ap_cfg_closefile(f);
-
- if (errmsg) {
- ap_log_rerror(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, r,
- "%s: %s", filename, errmsg);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
- *result = dc;
- break;
- }
- else if (status != APR_ENOENT && status != APR_ENOTDIR) {
- ap_log_rerror(APLOG_MARK, APLOG_CRIT, errno, r,
- "%s pcfg_openfile: unable to check htaccess file, "
- "ensure it is readable",
- filename);
- ap_table_setn(r->notes, "error-notes",
- "Server unable to read htaccess file, denying "
- "access to be safe");
- return HTTP_FORBIDDEN;
- }
- }
-
-/* cache it */
- new = ap_palloc(r->pool, sizeof(struct htaccess_result));
- new->dir = parms.path;
- new->override = override;
- new->htaccess = dc;
-/* add to head of list */
- new->next = r->htaccess;
- r->htaccess = new;
-
- return OK;
-}
-
-
-CORE_EXPORT(const char *) ap_init_virtual_host(ap_context_t *p, const char *hostname,
- server_rec *main_server, server_rec **ps)
-{
- server_rec *s = (server_rec *) ap_pcalloc(p, sizeof(server_rec));
-
-#ifdef RLIMIT_NOFILE
- struct rlimit limits;
-
- getrlimit(RLIMIT_NOFILE, &limits);
- if (limits.rlim_cur < limits.rlim_max) {
- limits.rlim_cur += 2;
- if (setrlimit(RLIMIT_NOFILE, &limits) < 0) {
- perror("setrlimit(RLIMIT_NOFILE)");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Cannot exceed hard limit for open files");
- }
- }
-#endif
-
- /* TODO: this crap belongs in http_core */
- s->process = main_server->process;
- s->server_admin = NULL;
- s->server_hostname = NULL;
- s->error_fname = NULL;
- s->srm_confname = NULL;
- s->access_confname = NULL;
- s->timeout = 0;
- s->keep_alive_timeout = 0;
- s->keep_alive = -1;
- s->keep_alive_max = -1;
- s->error_log = main_server->error_log;
- s->loglevel = main_server->loglevel;
- /* useful default, otherwise we get a port of 0 on redirects */
- s->port = main_server->port;
- s->next = NULL;
-
- s->is_virtual = 1;
- s->names = ap_make_array(p, 4, sizeof(char **));
- s->wild_names = ap_make_array(p, 4, sizeof(char **));
-
- s->module_config = create_empty_config(p);
- s->lookup_defaults = ap_create_per_dir_config(p);
-
-#if 0
- s->server_uid = ap_user_id;
- s->server_gid = ap_group_id;
-#endif
-
- s->limit_req_line = main_server->limit_req_line;
- s->limit_req_fieldsize = main_server->limit_req_fieldsize;
- s->limit_req_fields = main_server->limit_req_fields;
-
- *ps = s;
-
- return ap_parse_vhost_addrs(p, hostname, s);
-}
-
-
-static void fixup_virtual_hosts(ap_context_t *p, server_rec *main_server)
-{
- server_rec *virt;
-
- for (virt = main_server->next; virt; virt = virt->next) {
- merge_server_configs(p, main_server->module_config,
- virt->module_config);
-
- virt->lookup_defaults =
- ap_merge_per_dir_configs(p, main_server->lookup_defaults,
- virt->lookup_defaults);
-
- if (virt->server_admin == NULL)
- virt->server_admin = main_server->server_admin;
-
- if (virt->srm_confname == NULL)
- virt->srm_confname = main_server->srm_confname;
-
- if (virt->access_confname == NULL)
- virt->access_confname = main_server->access_confname;
-
- if (virt->timeout == 0)
- virt->timeout = main_server->timeout;
-
- if (virt->keep_alive_timeout == 0)
- virt->keep_alive_timeout = main_server->keep_alive_timeout;
-
- if (virt->keep_alive == -1)
- virt->keep_alive = main_server->keep_alive;
-
- if (virt->keep_alive_max == -1)
- virt->keep_alive_max = main_server->keep_alive_max;
-
- /* XXX: this is really something that should be dealt with by a
- * post-config api phase */
- ap_core_reorder_directories(p, virt);
- }
- ap_core_reorder_directories(p, main_server);
-}
-
-/*****************************************************************
- *
- * Getting *everything* configured...
- */
-
-static void init_config_globals(ap_context_t *p)
-{
- /* Global virtual host hash bucket pointers. Init to null. */
- ap_init_vhost_config(p);
-}
-
-static server_rec *init_server_config(process_rec *process, ap_context_t *p)
-{
- server_rec *s = (server_rec *) ap_pcalloc(p, sizeof(server_rec));
-
- ap_open_stderr(&s->error_log, p);
- s->process = process;
- s->port = 0;
- s->server_admin = DEFAULT_ADMIN;
- s->server_hostname = NULL;
- s->error_fname = DEFAULT_ERRORLOG;
- s->loglevel = DEFAULT_LOGLEVEL;
- s->srm_confname = RESOURCE_CONFIG_FILE;
- s->access_confname = ACCESS_CONFIG_FILE;
- s->limit_req_line = DEFAULT_LIMIT_REQUEST_LINE;
- s->limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE;
- s->limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS;
- s->timeout = DEFAULT_TIMEOUT;
- s->keep_alive_timeout = DEFAULT_KEEPALIVE_TIMEOUT;
- s->keep_alive_max = DEFAULT_KEEPALIVE;
- s->keep_alive = 1;
- s->next = NULL;
- s->addrs = ap_pcalloc(p, sizeof(server_addr_rec));
- /* NOT virtual host; don't match any real network interface */
- s->addrs->host_addr.s_addr = htonl(INADDR_ANY);
- s->addrs->host_port = 0; /* matches any port */
- s->addrs->virthost = ""; /* must be non-NULL */
- s->names = s->wild_names = NULL;
-
- s->module_config = create_server_config(p, s);
- s->lookup_defaults = create_default_per_dir_config(p);
-
- return s;
-}
-
-
-server_rec *ap_read_config(process_rec *process, ap_context_t *ptemp, const char *confname)
-{
- ap_context_t *p = process->pconf;
- server_rec *s = init_server_config(process, p);
-
- init_config_globals(p);
-
- /* All server-wide config files now have the SAME syntax... */
-
- process_command_config(s, ap_server_pre_read_config, p, ptemp);
-
- ap_process_resource_config(s, confname, p, ptemp);
- ap_process_resource_config(s, s->srm_confname, p, ptemp);
- ap_process_resource_config(s, s->access_confname, p, ptemp);
-
- process_command_config(s, ap_server_post_read_config, p, ptemp);
-
- fixup_virtual_hosts(p, s);
- ap_fini_vhost_config(p, s);
-
- return s;
-}
-
-void ap_single_module_configure(ap_context_t *p, server_rec *s, module *m)
-{
- if (m->create_server_config)
- ap_set_module_config(s->module_config, m,
- (*m->create_server_config)(p, s));
- if (m->create_dir_config)
- ap_set_module_config(s->lookup_defaults, m,
- (*m->create_dir_config)(p, NULL));
-}
-
-void ap_post_config_hook(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec *s)
-{
- ap_run_post_config(pconf,plog,ptemp,s);
- init_handlers(pconf);
-}
-
-void ap_child_init_hook(ap_context_t *pchild, server_rec *s)
-{
- /* TODO: uh this seems ugly, is there a better way? */
- /*ap_child_init_alloc(); PUT THIS BACK IN XXXXX */
-
- ap_run_child_init(pchild,s);
-}
-
-/********************************************************************
- * Configuration directives are restricted in terms of where they may
- * appear in the main configuration files and/or .htaccess files according
- * to the bitmask req_override in the command_rec structure.
- * If any of the overrides set in req_override are also allowed in the
- * context in which the command is read, then the command is allowed.
- * The context is determined as follows:
- *
- * inside *.conf --> override = (RSRC_CONF|OR_ALL)&~(OR_AUTHCFG|OR_LIMIT);
- * within <Directory> or <Location> --> override = OR_ALL|ACCESS_CONF;
- * within .htaccess --> override = AllowOverride for current directory;
- *
- * the result is, well, a rather confusing set of possibilities for when
- * a particular directive is allowed to be used. This procedure prints
- * in English where the given (pc) directive can be used.
- */
-static void show_overrides(const command_rec *pc, module *pm)
-{
- int n = 0;
-
- printf("\tAllowed in *.conf ");
- if ((pc->req_override & (OR_OPTIONS | OR_FILEINFO | OR_INDEXES)) ||
- ((pc->req_override & RSRC_CONF) &&
- ((pc->req_override & (ACCESS_CONF | OR_AUTHCFG | OR_LIMIT)))))
- printf("anywhere");
- else if (pc->req_override & RSRC_CONF)
- printf("only outside <Directory>, <Files> or <Location>");
- else
- printf("only inside <Directory>, <Files> or <Location>");
-
- /* Warn if the directive is allowed inside <Directory> or .htaccess
- * but module doesn't support per-dir configuration */
-
- if ((pc->req_override & (OR_ALL | ACCESS_CONF)) && !pm->create_dir_config)
- printf(" [no per-dir config]");
-
- if (pc->req_override & OR_ALL) {
- printf(" and in .htaccess\n\twhen AllowOverride");
-
- if ((pc->req_override & OR_ALL) == OR_ALL)
- printf(" isn't None");
- else {
- printf(" includes ");
-
- if (pc->req_override & OR_AUTHCFG) {
- if (n++)
- printf(" or ");
- printf("AuthConfig");
- }
- if (pc->req_override & OR_LIMIT) {
- if (n++)
- printf(" or ");
- printf("Limit");
- }
- if (pc->req_override & OR_OPTIONS) {
- if (n++)
- printf(" or ");
- printf("Options");
- }
- if (pc->req_override & OR_FILEINFO) {
- if (n++)
- printf(" or ");
- printf("FileInfo");
- }
- if (pc->req_override & OR_INDEXES) {
- if (n++)
- printf(" or ");
- printf("Indexes");
- }
- }
- }
- printf("\n");
-}
-
-/* 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.
- */
-void ap_show_directives()
-{
- const command_rec *pc;
- int n;
-
- for (n = 0; ap_loaded_modules[n]; ++n)
- for (pc = ap_loaded_modules[n]->cmds; pc && pc->name; ++pc) {
- printf("%s (%s)\n", pc->name, ap_loaded_modules[n]->name);
- if (pc->errmsg)
- printf("\t%s\n", pc->errmsg);
- show_overrides(pc, ap_loaded_modules[n]);
- }
-}
-
-/* Show the preloaded module names. Used for httpd -l. */
-void ap_show_modules()
-{
- int n;
-
- printf("Compiled in modules:\n");
- for (n = 0; ap_loaded_modules[n]; ++n)
- printf(" %s\n", ap_loaded_modules[n]->name);
-}
-
diff --git a/server/config.m4 b/server/config.m4
deleted file mode 100644
index 6c146cff7f..0000000000
--- a/server/config.m4
+++ /dev/null
@@ -1,55 +0,0 @@
-dnl ## Check for libraries
-
-AC_DEFUN(APACHE_DEFINE_HAVE_CRYPT, [
-])
-AC_CHECK_LIB(nsl, gethostname, [
- AC_ADD_LIBRARY(nsl) ], [])
-
-AC_CHECK_LIB(socket, socket, [
- AC_ADD_LIBRARY(socket) ], [])
-
-AC_CHECK_LIB(nsl, gethostbyaddr, [
- AC_ADD_LIBRARY(nsl) ], [])
-
-AC_CHECK_LIB(crypt, crypt, [
- AC_ADD_LIBRARY(crypt)
- apache_have_crypt=1
-], [
- AC_CHECK_LIB(c, crypt, [
- apache_have_crypt=1], [])
-])
-if test "$apache_have_crypt" = "1" ; then
- AC_DEFINE(HAVE_CRYPT,,[Define if this platform has crypt()])
-fi
-
-dnl ## Check for header files
-
-AC_HEADER_STDC
-AC_CHECK_HEADERS(
-bstring.h \
-crypt.h \
-unistd.h \
-sys/resource.h \
-sys/select.h \
-sys/processor.h \
-)
-
-dnl ## Check for typedefs, structures, and compiler characteristics.
-
-AC_TYPE_RLIM_T
-AC_CACHE_CHECK([for tm_gmtoff in struct tm], ac_cv_struct_tm_gmtoff,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_gmtoff;],
- ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no)])
-
-if test "$ac_cv_struct_tm_gmtoff" = "yes"; then
- AC_DEFINE(HAVE_GMTOFF,,
- [Define if struct tm has a tm_gmtoff member])
-fi
-
-dnl ## Check for library functions
-
-AC_CHECK_FUNCS(
-difftime \
-syslog \
-)
diff --git a/server/connection.c b/server/connection.c
deleted file mode 100644
index 3a94d14020..0000000000
--- a/server/connection.c
+++ /dev/null
@@ -1,302 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#define CORE_PRIVATE
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_connection.h"
-#include "http_request.h"
-#include "http_protocol.h"
-#include "ap_mpm.h"
-#include "mpm_status.h"
-#include "http_config.h"
-#include "http_vhost.h"
-
-HOOK_STRUCT(
- HOOK_LINK(pre_connection)
- HOOK_LINK(process_connection)
-)
-
-IMPLEMENT_HOOK_VOID(pre_connection,(conn_rec *c),(c))
-IMPLEMENT_HOOK_RUN_FIRST(int,process_connection,(conn_rec *c),(c),DECLINED)
-
-/* TODO: reimplement the lingering close stuff */
-#define NO_LINGCLOSE
-
-/*
- * More machine-dependent networking gooo... on some systems,
- * you've got to be *really* sure that all the packets are acknowledged
- * before closing the connection, since the client will not be able
- * to see the last response if their TCP buffer is flushed by a RST
- * packet from us, which is what the server's TCP stack will send
- * if it receives any request data after closing the connection.
- *
- * In an ideal world, this function would be accomplished by simply
- * setting the socket option SO_LINGER and handling it within the
- * server's TCP stack while the process continues on to the next request.
- * Unfortunately, it seems that most (if not all) operating systems
- * block the server process on close() when SO_LINGER is used.
- * For those that don't, see USE_SO_LINGER below. For the rest,
- * we have created a home-brew lingering_close.
- *
- * Many operating systems tend to block, puke, or otherwise mishandle
- * calls to shutdown only half of the connection. You should define
- * NO_LINGCLOSE in ap_config.h if such is the case for your system.
- */
-#ifndef MAX_SECS_TO_LINGER
-#define MAX_SECS_TO_LINGER 30
-#endif
-
-#ifdef USE_SO_LINGER
-#define NO_LINGCLOSE /* The two lingering options are exclusive */
-
-static void sock_enable_linger(int s)
-{
- struct linger li;
-
- li.l_onoff = 1;
- li.l_linger = MAX_SECS_TO_LINGER;
-
- if (setsockopt(s, SOL_SOCKET, SO_LINGER,
- (char *) &li, sizeof(struct linger)) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf,
- "setsockopt: (SO_LINGER)");
- /* not a fatal error */
- }
-}
-
-#else
-#define sock_enable_linger(s) /* NOOP */
-#endif /* USE_SO_LINGER */
-
-#ifndef NO_LINGCLOSE
-
-/* Since many clients will abort a connection instead of closing it,
- * attempting to log an error message from this routine will only
- * confuse the webmaster. There doesn't seem to be any portable way to
- * distinguish between a dropped connection and something that might be
- * worth logging.
- */
-static void lingering_close(request_rec *r)
-{
- /*TODO remove the hardwired 512. This is an IO Buffer Size */
- char dummybuf[512];
- struct pollfd pd;
- int lsd;
- int max_wait;
-
- /* Prevent a slow-drip client from holding us here indefinitely */
-
- max_wait = 30;
- ap_bsetopt(r->connection->client, BO_TIMEOUT, &max_wait);
-
- /* Send any leftover data to the client, but never try to again */
-
- if (ap_bflush(r->connection->client) != APR_SUCCESS) {
- ap_bclose(r->connection->client);
- return;
- }
- ap_bsetflag(r->connection->client, B_EOUT, 1);
-
- /* Close our half of the connection --- send the client a FIN */
-
- lsd = r->connection->client->fd;
-
- if ((shutdown(lsd, 1) != 0)
- || ap_is_aborted(r->connection)) {
- ap_bclose(r->connection->client);
- return;
- }
-
- /* Set up to wait for readable data on socket... */
- pd.fd = lsd;
- pd.events = POLLIN;
-
- /* Wait for readable data or error condition on socket;
- * slurp up any data that arrives... We exit when we go for an
- * interval of tv length without getting any more data, get an error
- * from poll(), get an error or EOF on a read, or the timer expires.
- */
- /* We use a 2 second timeout because current (Feb 97) browsers
- * fail to close a connection after the server closes it. Thus,
- * to avoid keeping the child busy, we are only lingering long enough
- * for a client that is actively sending data on a connection.
- * This should be sufficient unless the connection is massively
- * losing packets, in which case we might have missed the RST anyway.
- * These parameters are reset on each pass, since they might be
- * changed by poll.
- */
- do {
- pd.revents = 0;
- } while ((poll(&pd, 1, 2) == 1)
- && read(lsd, dummybuf, sizeof(dummybuf)));
- /* && (time() = epoch) < max_wait); */
-
- /* Should now have seen final ack. Safe to finally kill socket */
- ap_bclose(r->connection->client);
-}
-#endif /* ndef NO_LINGCLOSE */
-
-CORE_EXPORT(void) ap_process_connection(conn_rec *c)
-{
- ap_update_vhost_given_ip(c);
-
- ap_run_pre_connection(c);
-
- ap_run_process_connection(c);
-
- /*
- * Close the connection, being careful to send out whatever is still
- * in our buffers. If possible, try to avoid a hard close until the
- * client has ACKed our FIN and/or has stopped sending us data.
- */
-
-#ifdef NO_LINGCLOSE
- ap_bclose(c->client); /* just close it */
-#else
- if (r && r->connection
- && !r->connection->aborted
- && r->connection->client
- && (r->connection->client->fd >= 0)) {
-
- lingering_close(r);
- }
- else {
- ap_bsetflag(c->client, B_EOUT, 1);
- ap_bclose(c->client);
- }
-#endif
-}
-
-int ap_process_http_connection(conn_rec *c)
- {
- request_rec *r;
-
- /*
- * Read and process each request found on our connection
- * until no requests are left or we decide to close.
- */
-
- ap_update_connection_status(c->id, "Status", "Reading");
- while ((r = ap_read_request(c)) != NULL) {
-
- /* process the request if it was read without error */
-
- ap_update_connection_status(c->id, "Status", "Writing");
- if (r->status == HTTP_OK)
- ap_process_request(r);
-
- if (!c->keepalive || c->aborted)
- break;
-
- ap_update_connection_status(c->id, "Status", "Keepalive");
- ap_destroy_pool(r->pool);
-
- if (ap_graceful_stop_signalled()) {
- /* XXX: hey wait, this should do a lingering_close! */
- ap_bclose(c->client);
- return OK;
- }
- }
-
- ap_reset_connection_status(c->id);
- return OK;
-}
-
-/* Clearly some of this stuff doesn't belong in a generalised connection
- structure, but for now...
-*/
-
-conn_rec *ap_new_connection(ap_context_t *p, server_rec *server, BUFF *inout,
- const struct sockaddr_in *remaddr,
- const struct sockaddr_in *saddr, long id)
-{
- conn_rec *conn = (conn_rec *) ap_pcalloc(p, sizeof(conn_rec));
-
- /* Got a connection structure, so initialize what fields we can
- * (the rest are zeroed out by pcalloc).
- */
-
- conn->conn_config=ap_create_conn_config(p);
-
- conn->pool = p;
- conn->local_addr = *saddr;
- conn->local_ip = ap_pstrdup(conn->pool,
- inet_ntoa(conn->local_addr.sin_addr));
- conn->base_server = server;
- conn->client = inout;
-
- conn->remote_addr = *remaddr;
- conn->remote_ip = ap_pstrdup(conn->pool,
- inet_ntoa(conn->remote_addr.sin_addr));
-
- conn->id = id;
-
- return conn;
-}
-
-
-
-conn_rec *ap_new_apr_connection(ap_context_t *p, server_rec *server, BUFF *inout,
- const ap_socket_t *conn_socket, long id)
-{
- struct sockaddr_in *sa_local, *sa_remote;
-
- ap_get_local_name(&sa_local, conn_socket);
- ap_get_remote_name(&sa_remote, conn_socket);
- return ap_new_connection(p, server, inout, sa_remote, sa_local, id);
-}
diff --git a/server/gen_test_char.c b/server/gen_test_char.c
deleted file mode 100644
index b27f38f2dd..0000000000
--- a/server/gen_test_char.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* we need some of the portability definitions... for strchr */
-#include "ap_config.h"
-#include "httpd.h"
-
-/* A bunch of functions in util.c scan strings looking for certain characters.
- * To make that more efficient we encode a lookup table.
- */
-#define T_ESCAPE_SHELL_CMD (0x01)
-#define T_ESCAPE_PATH_SEGMENT (0x02)
-#define T_OS_ESCAPE_PATH (0x04)
-#define T_HTTP_TOKEN_STOP (0x08)
-
-int main(int argc, char *argv[])
-{
- unsigned c;
- unsigned char flags;
-
- printf(
-"/* this file is automatically generated by gen_test_char, do not edit */\n"
-"#define T_ESCAPE_SHELL_CMD (%u)\n"
-"#define T_ESCAPE_PATH_SEGMENT (%u)\n"
-"#define T_OS_ESCAPE_PATH (%u)\n"
-"#define T_HTTP_TOKEN_STOP (%u)\n"
-"\n"
-"static const unsigned char test_char_table[256] = {\n"
-" 0,",
- T_ESCAPE_SHELL_CMD,
- T_ESCAPE_PATH_SEGMENT,
- T_OS_ESCAPE_PATH,
- T_HTTP_TOKEN_STOP);
-
- /* we explicitly dealt with NUL above
- * in case some strchr() do bogosity with it */
-
- for (c = 1; c < 256; ++c) {
- flags = 0;
- if (c % 20 == 0)
- printf("\n ");
-
- /* escape_shell_cmd */
- if (strchr("&;`'\"|*?~<>^()[]{}$\\\n", c)) {
- flags |= T_ESCAPE_SHELL_CMD;
- }
-
- if (!ap_isalnum(c) && !strchr("$-_.+!*'(),:@&=~", c)) {
- flags |= T_ESCAPE_PATH_SEGMENT;
- }
-
- if (!ap_isalnum(c) && !strchr("$-_.+!*'(),:@&=/~", c)) {
- flags |= T_OS_ESCAPE_PATH;
- }
-
- /* these are the "tspecials" from RFC2068 */
- if (ap_iscntrl(c) || strchr(" \t()<>@,;:\\/[]?={}", c)) {
- flags |= T_HTTP_TOKEN_STOP;
- }
- printf("%u%c", flags, (c < 255) ? ',' : ' ');
-
- }
- printf("\n};\n");
-
- return 0;
-}
diff --git a/server/gen_test_char.dsp b/server/gen_test_char.dsp
deleted file mode 100644
index 95db92cce4..0000000000
--- a/server/gen_test_char.dsp
+++ /dev/null
@@ -1,105 +0,0 @@
-# Microsoft Developer Studio Project File - Name="gen_test_char" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=gen_test_char - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "gen_test_char.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "gen_test_char.mak" CFG="gen_test_char - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "gen_test_char - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "gen_test_char - Win32 Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "gen_test_char - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "gen_test"
-# PROP BASE Intermediate_Dir "gen_test"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ""
-# PROP Intermediate_Dir "gen_test_char_R"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /I "..\lib\apr\include" /I "..\os\win32" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:console /machine:I386
-# Begin Special Build Tool
-SOURCE=$(InputPath)
-PostBuild_Desc=Create test_char.h
-PostBuild_Cmds=.\gen_test_char > test_char.h
-# End Special Build Tool
-
-!ELSEIF "$(CFG)" == "gen_test_char - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "gen_tes0"
-# PROP BASE Intermediate_Dir "gen_tes0"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ""
-# PROP Intermediate_Dir "gen_test_char_D"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\include" /I "..\lib\apr\include" /I "..\os\win32" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# Begin Special Build Tool
-SOURCE=$(InputPath)
-PostBuild_Desc=Create test_char.h
-PostBuild_Cmds=.\gen_test_char > test_char.h
-# End Special Build Tool
-
-!ENDIF
-
-# Begin Target
-
-# Name "gen_test_char - Win32 Release"
-# Name "gen_test_char - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\gen_test_char.c
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/server/gen_uri_delims.c b/server/gen_uri_delims.c
deleted file mode 100644
index b71e96ad71..0000000000
--- a/server/gen_uri_delims.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include <stdio.h>
-
-/* generate a ap_table_t of 256 values, where certain characters are
- * marked "interesting"... for the uri parsing process.
- */
-
-int main(int argc, char *argv[])
-{
- int i;
- char *value;
-
- printf("/* this file is automatically generated by "
- "gen_uri_delims, do not edit */\n");
- printf("static const unsigned char uri_delims[256] = {");
- for (i = 0; i < 256; ++i) {
- if (i % 20 == 0)
- printf("\n ");
- switch (i) {
- case ':': value = "T_COLON"; break;
- case '/': value = "T_SLASH"; break;
- case '?': value = "T_QUESTION"; break;
- case '#': value = "T_HASH"; break;
- case '\0': value = "T_NUL"; break;
- default: value = "0"; break;
- }
- printf("%s%c", value, (i < 255) ? ',' : ' ');
- }
- printf("\n};\n");
-
- return 0;
-}
diff --git a/server/gen_uri_delims.dsp b/server/gen_uri_delims.dsp
deleted file mode 100644
index 566dd83e27..0000000000
--- a/server/gen_uri_delims.dsp
+++ /dev/null
@@ -1,105 +0,0 @@
-# Microsoft Developer Studio Project File - Name="gen_uri_delims" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=gen_uri_delims - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "gen_uri_delims.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "gen_uri_delims.mak" CFG="gen_uri_delims - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "gen_uri_delims - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "gen_uri_delims - Win32 Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "gen_uri_delims - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ""
-# PROP Intermediate_Dir "gen_uri_delims_R"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x809 /d "NDEBUG"
-# ADD RSC /l 0x809 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:console /machine:I386
-# Begin Special Build Tool
-SOURCE=$(InputPath)
-PostBuild_Desc=Create uri_delims.h
-PostBuild_Cmds=.\gen_uri_delims > uri_delims.h
-# End Special Build Tool
-
-!ELSEIF "$(CFG)" == "gen_uri_delims - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ""
-# PROP Intermediate_Dir "gen_uri_delims_D"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x809 /d "_DEBUG"
-# ADD RSC /l 0x809 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# Begin Special Build Tool
-SOURCE=$(InputPath)
-PostBuild_Desc=Create uri_delims.h
-PostBuild_Cmds=.\gen_uri_delims > uri_delims.h
-# End Special Build Tool
-
-!ENDIF
-
-# Begin Target
-
-# Name "gen_uri_delims - Win32 Release"
-# Name "gen_uri_delims - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter ""
-# Begin Source File
-
-SOURCE=.\gen_uri_delims.c
-# End Source File
-# End Group
-# End Target
-# End Project
diff --git a/server/listen.c b/server/listen.c
deleted file mode 100644
index 478ddbed40..0000000000
--- a/server/listen.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#include "apr_network_io.h"
-
-#define CORE_PRIVATE
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "ap_listen.h"
-#include "http_log.h"
-#include <string.h>
-
-ap_listen_rec *ap_listeners;
-static ap_listen_rec *old_listeners;
-static int ap_listenbacklog;
-static int send_buffer_size;
-
-/* TODO: make_sock is just begging and screaming for APR abstraction */
-static ap_status_t make_sock(ap_context_t *p, ap_listen_rec *server)
-{
- ap_socket_t *s = server->sd;
- int one = 1;
- char addr[512];
- ap_status_t stat;
-
- ap_cpystrn(addr, "[@main/listen.c:make_sock(): inet_ntoa(server->sin_addr)]", sizeof addr);
-
- stat = ap_setsocketopt(s, APR_SO_REUSEADDR, one);
- if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, stat, NULL,
- "make_sock: for %s, setsockopt: (SO_REUSEADDR)", addr);
- ap_close_socket(s);
- return stat;
- }
-
- stat = ap_setsocketopt(s, APR_SO_KEEPALIVE, one);
- if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, stat, NULL,
- "make_sock: for %s, setsockopt: (SO_KEEPALIVE)", addr);
- ap_close_socket(s);
- return stat;
- }
-
- /*
- * To send data over high bandwidth-delay connections at full
- * speed we must force the TCP window to open wide enough to keep the
- * pipe full. The default window size on many systems
- * is only 4kB. Cross-country WAN connections of 100ms
- * at 1Mb/s are not impossible for well connected sites.
- * If we assume 100ms cross-country latency,
- * a 4kB buffer limits throughput to 40kB/s.
- *
- * To avoid this problem I've added the SendBufferSize directive
- * to allow the web master to configure send buffer size.
- *
- * The trade-off of larger buffers is that more kernel memory
- * is consumed. YMMV, know your customers and your network!
- *
- * -John Heidemann <johnh@isi.edu> 25-Oct-96
- *
- * If no size is specified, use the kernel default.
- */
- if (send_buffer_size) {
- stat = ap_setsocketopt(s, APR_SO_SNDBUF, send_buffer_size);
- if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, stat, NULL,
- "make_sock: failed to set SendBufferSize for %s, "
- "using default", addr);
- /* not a fatal error */
- }
- }
-
- if ((stat = ap_bind(s)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, stat, NULL,
- "make_sock: could not bind to %s", addr);
- ap_close_socket(s);
- return stat;
- }
-
- if ((stat = ap_listen(s, ap_listenbacklog)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, stat, NULL,
- "make_sock: unable to listen for connections on %s", addr);
- ap_close_socket(s);
- return stat;
- }
-
- server->sd = s;
- server->active = 1;
- return APR_SUCCESS;
-}
-
-
-static ap_status_t close_listeners_on_exec(void *v)
-{
- ap_listen_rec *lr;
-
- for (lr = ap_listeners; lr; lr = lr->next) {
- ap_close_socket(lr->sd);
- lr->active = 0;
- }
- return APR_SUCCESS;
-}
-
-
-static void alloc_listener(process_rec *process, char *addr, unsigned int port)
-{
- ap_listen_rec **walk;
- ap_listen_rec *new;
- ap_status_t status;
- char *oldaddr;
- unsigned int oldport;
-
- /* see if we've got an old listener for this address:port */
- for (walk = &old_listeners; *walk; walk = &(*walk)->next) {
- ap_get_local_port(&oldport, (*walk)->sd);
- ap_get_local_ipaddr(&oldaddr,(*walk)->sd);
- if (!strcmp(oldaddr, addr) && port == oldport) {
- /* re-use existing record */
- new = *walk;
- *walk = new->next;
- new->next = ap_listeners;
- ap_listeners = new;
- return;
- }
- }
-
- /* this has to survive restarts */
- new = ap_palloc(process->pool, sizeof(ap_listen_rec));
- new->active = 0;
- if ((status = ap_create_tcp_socket(&new->sd, process->pool)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, status, NULL,
- "make_sock: failed to get a socket for %s", addr);
- return;
- }
- ap_set_local_port(new->sd, port);
- ap_set_local_ipaddr(new->sd, addr);
- new->next = ap_listeners;
- ap_listeners = new;
-}
-
-
-int ap_listen_open(process_rec *process, unsigned port)
-{
- ap_context_t *pconf = process->pconf;
- ap_listen_rec *lr;
- ap_listen_rec *next;
- int num_open;
-
- /* allocate a default listener if necessary */
- if (ap_listeners == NULL) {
- alloc_listener(process, APR_ANYADDR, port ? port : DEFAULT_HTTP_PORT);
- }
-
- num_open = 0;
- for (lr = ap_listeners; lr; lr = lr->next) {
- if (lr->active) {
- ++num_open;
- }
- else {
- if (make_sock(pconf, lr) == APR_SUCCESS) {
- ++num_open;
- lr->active = 1;
- }
- }
- }
-
- /* close the old listeners */
- for (lr = old_listeners; lr; lr = next) {
- ap_close_socket(lr->sd);
- lr->active = 0;
- next = lr->next;
-/* free(lr);*/
- }
- old_listeners = NULL;
-
- ap_register_cleanup(pconf, NULL, ap_null_cleanup, close_listeners_on_exec);
-
- return num_open ? 0 : -1;
-}
-
-
-void ap_listen_pre_config(void)
-{
- old_listeners = ap_listeners;
- ap_listeners = NULL;
- ap_listenbacklog = DEFAULT_LISTENBACKLOG;
-}
-
-
-const char *ap_set_listener(cmd_parms *cmd, void *dummy, char *ips)
-{
- char *ports;
- unsigned short port;
-
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ports = strchr(ips, ':');
- if (ports != NULL) {
- if (ports == ips) {
- return "Missing IP address";
- }
- else if (ports[1] == '\0') {
- return "Address must end in :<port-number>";
- }
- *(ports++) = '\0';
- }
- else {
- ports = ips;
- }
-
- port = atoi(ports);
- if (!port) {
- return "Port must be numeric";
- }
-
- if (ports == ips) { /* no address */
- alloc_listener(cmd->server->process, APR_ANYADDR, port);
- }
- else {
- ips[(ports - ips) - 1] = '\0';
- alloc_listener(cmd->server->process, ips, port);
- }
-
- return NULL;
-}
-
-const char *ap_set_listenbacklog(cmd_parms *cmd, void *dummy, char *arg)
-{
- int b;
-
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- b = atoi(arg);
- if (b < 1) {
- return "ListenBacklog must be > 0";
- }
- ap_listenbacklog = b;
- return NULL;
-}
-
-const char *ap_set_send_buffer_size(cmd_parms *cmd, void *dummy, char *arg)
-{
- int s = atoi(arg);
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (s < 512 && s != 0) {
- return "SendBufferSize must be >= 512 bytes, or 0 for system default.";
- }
- send_buffer_size = s;
- return NULL;
-}
diff --git a/server/log.c b/server/log.c
deleted file mode 100644
index 52c84743a8..0000000000
--- a/server/log.c
+++ /dev/null
@@ -1,742 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_log.c: Dealing with the logs and errors
- *
- * Rob McCool
- *
- */
-
-
-#define CORE_PRIVATE
-#include "ap_config.h"
-#include "apr_lib.h"
-#include "apr_portable.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_core.h"
-#include "http_log.h"
-#include "http_main.h"
-
-#include <stdarg.h>
-
-typedef struct {
- char *t_name;
- int t_val;
-} TRANS;
-
-#ifdef HAVE_SYSLOG
-
-static const TRANS facilities[] = {
- {"auth", LOG_AUTH},
-#ifdef LOG_AUTHPRIV
- {"authpriv",LOG_AUTHPRIV},
-#endif
-#ifdef LOG_CRON
- {"cron", LOG_CRON},
-#endif
-#ifdef LOG_DAEMON
- {"daemon", LOG_DAEMON},
-#endif
-#ifdef LOG_FTP
- {"ftp", LOG_FTP},
-#endif
-#ifdef LOG_KERN
- {"kern", LOG_KERN},
-#endif
-#ifdef LOG_LPR
- {"lpr", LOG_LPR},
-#endif
-#ifdef LOG_MAIL
- {"mail", LOG_MAIL},
-#endif
-#ifdef LOG_NEWS
- {"news", LOG_NEWS},
-#endif
-#ifdef LOG_SYSLOG
- {"syslog", LOG_SYSLOG},
-#endif
-#ifdef LOG_USER
- {"user", LOG_USER},
-#endif
-#ifdef LOG_UUCP
- {"uucp", LOG_UUCP},
-#endif
-#ifdef LOG_LOCAL0
- {"local0", LOG_LOCAL0},
-#endif
-#ifdef LOG_LOCAL1
- {"local1", LOG_LOCAL1},
-#endif
-#ifdef LOG_LOCAL2
- {"local2", LOG_LOCAL2},
-#endif
-#ifdef LOG_LOCAL3
- {"local3", LOG_LOCAL3},
-#endif
-#ifdef LOG_LOCAL4
- {"local4", LOG_LOCAL4},
-#endif
-#ifdef LOG_LOCAL5
- {"local5", LOG_LOCAL5},
-#endif
-#ifdef LOG_LOCAL6
- {"local6", LOG_LOCAL6},
-#endif
-#ifdef LOG_LOCAL7
- {"local7", LOG_LOCAL7},
-#endif
- {NULL, -1},
-};
-#endif
-
-static const TRANS priorities[] = {
- {"emerg", APLOG_EMERG},
- {"alert", APLOG_ALERT},
- {"crit", APLOG_CRIT},
- {"error", APLOG_ERR},
- {"warn", APLOG_WARNING},
- {"notice", APLOG_NOTICE},
- {"info", APLOG_INFO},
- {"debug", APLOG_DEBUG},
- {NULL, -1},
-};
-
-static int log_child(ap_context_t *p, const char *progname,
- ap_file_t **fpin)
-{
- /* Child process code for 'ErrorLog "|..."';
- * may want a common framework for this, since I expect it will
- * be common for other foo-loggers to want this sort of thing...
- */
- int rc = -1;
- ap_procattr_t *procattr;
- ap_proc_t *procnew;
-
- ap_block_alarms();
- ap_cleanup_for_exec();
-
-#ifdef SIGHUP
- /* No concept of a child process on Win32 */
- signal(SIGHUP, SIG_IGN);
-#endif /* ndef SIGHUP */
-
- if ((ap_createprocattr_init(&procattr, p) != APR_SUCCESS) ||
- (ap_setprocattr_io(procattr,
- APR_FULL_BLOCK,
- APR_NO_PIPE,
- APR_NO_PIPE) != APR_SUCCESS)) {
- /* Something bad happened, give up and go away. */
- rc = -1;
- }
- else {
- rc = ap_create_process(&procnew, progname, NULL, NULL, procattr, p);
-
- if (rc == APR_SUCCESS) {
- ap_note_subprocess(p, procnew, kill_after_timeout);
- ap_get_childin(fpin, procnew);
- }
- }
-
- ap_unblock_alarms();
-
- return(rc);
-}
-
-static void open_error_log(server_rec *s, ap_context_t *p)
-{
- const char *fname;
- int rc;
-
- if (*s->error_fname == '|') {
- ap_file_t *dummy = NULL;
-
- /* This starts a new process... */
- rc = log_child (p, s->error_fname+1, &dummy);
- if (rc != APR_SUCCESS) {
- perror("ap_spawn_child");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Couldn't fork child for ErrorLog process");
- exit(1);
- }
-
- s->error_log = dummy;
- }
-
-#ifdef HAVE_SYSLOG
- else if (!strncasecmp(s->error_fname, "syslog", 6)) {
- if ((fname = strchr(s->error_fname, ':'))) {
- const TRANS *fac;
-
- fname++;
- for (fac = facilities; fac->t_name; fac++) {
- if (!strcasecmp(fname, fac->t_name)) {
- openlog(ap_server_argv0, LOG_NDELAY|LOG_CONS|LOG_PID,
- fac->t_val);
- s->error_log = NULL;
- return;
- }
- }
- }
- else
- openlog(ap_server_argv0, LOG_NDELAY|LOG_CONS|LOG_PID, LOG_LOCAL7);
-
- s->error_log = NULL;
- }
-#endif
- else {
- fname = ap_server_root_relative(p, s->error_fname);
- /* Change to AP funcs. */
- if (ap_open(&s->error_log, fname, APR_APPEND |
- APR_READ | APR_WRITE | APR_CREATE, APR_OS_DEFAULT, p) != APR_SUCCESS) {
- perror("fopen");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: could not open error log file %s.",
- ap_server_argv0, fname);
- exit(1);
- }
- }
-}
-
-void ap_open_logs(server_rec *s_main, ap_context_t *p)
-{
- ap_status_t rc = APR_SUCCESS;
- server_rec *virt, *q;
- int replace_stderr;
- ap_file_t *errfile = NULL;
-
- open_error_log(s_main, p);
-
- replace_stderr = 1;
- if (s_main->error_log) {
- /* replace stderr with this new log */
- ap_flush(s_main->error_log);
- ap_open_stderr(&errfile, p);
- if ((rc = ap_dupfile(&errfile, s_main->error_log)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, rc, s_main,
- "unable to replace stderr with error_log");
- } else {
- replace_stderr = 0;
- }
- }
- /* note that stderr may still need to be replaced with something
- * because it points to the old error log, or back to the tty
- * of the submitter.
- */
- if (replace_stderr && freopen("/dev/null", "w", stderr) == NULL) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, errno, s_main,
- "unable to replace stderr with /dev/null");
- }
-
- for (virt = s_main->next; virt; virt = virt->next) {
- if (virt->error_fname) {
- for (q=s_main; q != virt; q = q->next)
- if (q->error_fname != NULL &&
- strcmp(q->error_fname, virt->error_fname) == 0)
- break;
- if (q == virt)
- open_error_log(virt, p);
- else
- virt->error_log = q->error_log;
- }
- else
- virt->error_log = s_main->error_log;
- }
-}
-
-API_EXPORT(void) ap_error_log2stderr(server_rec *s) {
- ap_file_t *errfile = NULL;
-
- ap_open_stderr(&errfile, s->process->pool);
- if (s->error_log != NULL) {
- ap_dupfile(&(s->error_log), errfile);
- }
-}
-
-static void log_error_core(const char *file, int line, int level,
- ap_status_t status, const server_rec *s,
- const request_rec *r, const char *fmt, va_list args)
-{
- char errstr[MAX_STRING_LEN + 1]; /* + 1 to have room for '\n' */
- size_t len;
- ap_file_t *logf = NULL;
-
- if (s == NULL) {
- /*
- * If we are doing stderr logging (startup), don't log messages that are
- * above the default server log level unless it is a startup/shutdown
- * notice
- */
- if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) &&
- ((level & APLOG_LEVELMASK) > DEFAULT_LOGLEVEL))
- return;
- ap_open_stderr(&logf, NULL);
- }
- else if (s->error_log) {
- /*
- * If we are doing normal logging, don't log messages that are
- * above the server log level unless it is a startup/shutdown notice
- */
- if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) &&
- ((level & APLOG_LEVELMASK) > s->loglevel))
- return;
- logf = s->error_log;
- }
-#ifdef TPF
- else if (tpf_child) {
- /*
- * If we are doing normal logging, don't log messages that are
- * above the server log level unless it is a startup/shutdown notice
- */
- if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) &&
- ((level & APLOG_LEVELMASK) > s->loglevel))
- return;
- logf = stderr;
- }
-#endif /* TPF */
- else {
- /*
- * If we are doing syslog logging, don't log messages that are
- * above the server log level (including a startup/shutdown notice)
- */
- if ((level & APLOG_LEVELMASK) > s->loglevel)
- return;
- logf = NULL;
- }
-
- if (logf && ((level & APLOG_STARTUP) != APLOG_STARTUP)) {
- errstr[0] = '[';
- ap_ctime(errstr + 1, ap_now());
- errstr[1 + AP_CTIME_LEN - 1] = ']';
- errstr[1 + AP_CTIME_LEN ] = ' ';
- len = 1 + AP_CTIME_LEN + 1;
- } else {
- len = 0;
- }
-
- if ((level & APLOG_STARTUP) != APLOG_STARTUP) {
- len += ap_snprintf(errstr + len, MAX_STRING_LEN - len,
- "[%s] ", priorities[level & APLOG_LEVELMASK].t_name);
- }
-#ifndef TPF
- if (file && (level & APLOG_LEVELMASK) == APLOG_DEBUG) {
-#ifdef _OSD_POSIX
- char tmp[256];
- char *e = strrchr(file, '/');
-
- /* In OSD/POSIX, the compiler returns for __FILE__
- * a string like: __FILE__="*POSIX(/usr/include/stdio.h)"
- * (it even returns an absolute path for sources in
- * the current directory). Here we try to strip this
- * down to the basename.
- */
- if (e != NULL && e[1] != '\0') {
- ap_snprintf(tmp, sizeof(tmp), "%s", &e[1]);
- e = &tmp[strlen(tmp)-1];
- if (*e == ')')
- *e = '\0';
- file = tmp;
- }
-#endif /*_OSD_POSIX*/
- len += ap_snprintf(errstr + len, MAX_STRING_LEN - len,
- "%s(%d): ", file, line);
- }
-#endif /* TPF */
- if (r && r->connection) {
- /* XXX: TODO: add a method of selecting whether logged client
- * addresses are in dotted quad or resolved form... dotted
- * quad is the most secure, which is why I'm implementing it
- * first. -djg
- */
- len += ap_snprintf(errstr + len, MAX_STRING_LEN - len,
- "[client %s] ", r->connection->remote_ip);
- }
- /* XXX - need an APRized strerror() */
- if (!(level & APLOG_NOERRNO)
- && (status != 0)) {
- len += ap_snprintf(errstr + len, MAX_STRING_LEN - len,
- "(%d)%s: ", status, strerror(status));
- }
-
- len += ap_vsnprintf(errstr + len, MAX_STRING_LEN - len, fmt, args);
-
- /* NULL if we are logging to syslog */
- if (logf) {
- /* We know that we have one more character of space available because
- * the array is sized that way */
- /* ap_assert(len < MAX_STRING_LEN) */
- errstr[len++] = '\n';
- errstr[len] = '\0';
- ap_puts(errstr, logf);
- ap_flush(logf);
- }
-#ifdef HAVE_SYSLOG
- else {
- syslog(level & APLOG_LEVELMASK, "%s", errstr);
- }
-#endif
-}
-
-API_EXPORT(void) ap_log_error(const char *file, int line, int level,
- ap_status_t status, const server_rec *s,
- const char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- log_error_core(file, line, level, status, s, NULL, fmt, args);
- va_end(args);
-}
-
-API_EXPORT(void) ap_log_rerror(const char *file, int line, int level,
- ap_status_t status, const request_rec *r,
- const char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- log_error_core(file, line, level, status, r->server, r, fmt, args);
- /*
- * IF the error level is 'warning' or more severe,
- * AND there isn't already error text associated with this request,
- * THEN make the message text available to ErrorDocument and
- * other error processors. This can be disabled by stuffing
- * something, even an empty string, into the "error-notes" cell
- * before calling this routine.
- */
- va_end(args);
- va_start(args,fmt);
- if (((level & APLOG_LEVELMASK) <= APLOG_WARNING)
- && (ap_table_get(r->notes, "error-notes") == NULL)) {
- ap_table_setn(r->notes, "error-notes",
- ap_pvsprintf(r->pool, fmt, args));
- }
- va_end(args);
-}
-
-void ap_log_pid(ap_context_t *p, const char *fname)
-{
- ap_file_t *pid_file = NULL;
- ap_finfo_t finfo;
- static pid_t saved_pid = -1;
- pid_t mypid;
-#ifndef WIN32
- mode_t u;
-#endif
-
- if (!fname)
- return;
-
- fname = ap_server_root_relative(p, fname);
- mypid = getpid();
- if (mypid != saved_pid && ap_stat(&finfo, fname, p) == APR_SUCCESS) {
- /* WINCH and HUP call this on each restart.
- * Only warn on first time through for this pid.
- *
- * XXX: Could just write first time through too, although
- * that may screw up scripts written to do something
- * based on the last modification time of the pid file.
- */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL,
- ap_psprintf(p,
- "pid file %s overwritten -- Unclean shutdown of previous Apache run?",
- fname)
- );
- }
-
-#ifndef WIN32
- u = umask(022);
- (void) umask(u | 022);
-#endif
- if(ap_open(&pid_file, fname, APR_WRITE | APR_CREATE, APR_OS_DEFAULT, p) != APR_SUCCESS) {
- perror("fopen");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: could not log pid to file %s",
- ap_server_argv0, fname);
- exit(1);
- }
-#ifndef WIN32
- (void) umask(u);
-#endif
- ap_fprintf(pid_file, "%ld\n", (long)mypid);
- ap_close(pid_file);
- saved_pid = mypid;
-}
-
-API_EXPORT(void) ap_log_error_old(const char *err, server_rec *s)
-{
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, "%s", err);
-}
-
-API_EXPORT(void) ap_log_unixerr(const char *routine, const char *file,
- const char *msg, server_rec *s)
-{
- ap_log_error(file, 0, APLOG_ERR, errno, s, "%s", msg);
-}
-
-API_EXPORT(void) ap_log_printf(const server_rec *s, const char *fmt, ...)
-{
- va_list args;
-
- va_start(args, fmt);
- log_error_core(APLOG_MARK, APLOG_ERR, errno, s, NULL, fmt, args);
- va_end(args);
-}
-
-API_EXPORT(void) ap_log_reason(const char *reason, const char *file, request_rec *r)
-{
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, r->server,
- "access to %s failed for %s, reason: %s",
- file,
- ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME),
- reason);
-}
-
-API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
-{
- char time_str[AP_CTIME_LEN];
-
- ap_ctime(time_str, ap_now());
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "[%s] file %s, line %d, assertion \"%s\" failed",
- time_str, szFile, nLine, szExp);
-#ifndef WIN32
- /* unix assert does an abort leading to a core dump */
- abort();
-#else
- exit(1);
-#endif
-}
-
-/* piped log support */
-
-#ifdef HAVE_RELIABLE_PIPED_LOGS
-/* forward declaration */
-static void piped_log_maintenance(int reason, void *data, ap_wait_t status);
-
-static int piped_log_spawn(piped_log *pl)
-{
- int rc;
- ap_procattr_t *procattr;
- ap_os_proc_t pid;
- ap_proc_t *procnew;
-
- /* pjr - calls to block and unblock alarms weren't here before, was this */
- /* an oversight or intentional? */
-/* ap_block_alarms(); */
-
- ap_cleanup_for_exec();
-#ifdef SIGHUP
- signal(SIGHUP, SIG_IGN);
-#endif
- if ((ap_createprocattr_init(&procattr, pl->p) != APR_SUCCESS) ||
- (ap_setprocattr_dir(procattr, pl->program) != APR_SUCCESS) ||
- (ap_set_childin(procattr, ap_piped_log_read_fd(pl), ap_piped_log_write_fd(pl)) != APR_SUCCESS)) {
- /* Something bad happened, give up and go away. */
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "piped_log_spawn: unable to exec '%s': %s",
- pl->program, strerror (errno));
- rc = -1;
- }
- else {
- rc = ap_create_process(&procnew, pl->program, NULL, NULL, procattr, pl->p);
-
- if (rc == APR_SUCCESS) { /* pjr - This no longer happens inside the child, */
- RAISE_SIGSTOP(PIPED_LOG_SPAWN); /* I am assuming that if ap_create_process was */
- /* successful that the child is running. */
- pl->pid = procnew;
- ap_get_os_proc(&pid, procnew);
- ap_register_other_child(pid, piped_log_maintenance, pl, ap_piped_log_write_fd(pl));
- }
- }
-
-/* ap_unblock_alarms(); */
-
- return 0;
-}
-
-
-static void piped_log_maintenance(int reason, void *data, ap_wait_t status)
-{
- piped_log *pl = data;
-
- switch (reason) {
- case OC_REASON_DEATH:
- case OC_REASON_LOST:
- pl->pid = NULL;
- ap_unregister_other_child(pl);
- if (pl->program == NULL) {
- /* during a restart */
- break;
- }
- if (piped_log_spawn(pl) != APR_SUCCESS) {
- /* what can we do? This could be the error log we're having
- * problems opening up... */
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "piped_log_maintenance: unable to respawn '%s': %s",
- pl->program, strerror(errno));
- }
- break;
-
- case OC_REASON_UNWRITABLE:
- if (pl->pid != NULL) {
- ap_kill(pl->pid, SIGTERM);
- }
- break;
-
- case OC_REASON_RESTART:
- pl->program = NULL;
- if (pl->pid != NULL) {
- ap_kill(pl->pid, SIGTERM);
- }
- break;
-
- case OC_REASON_UNREGISTER:
- break;
- }
-}
-
-
-static ap_status_t piped_log_cleanup(void *data)
-{
- piped_log *pl = data;
-
- if (pl->pid != NULL) {
- ap_kill(pl->pid, SIGTERM);
- }
- ap_unregister_other_child(pl);
- ap_close(ap_piped_log_read_fd(pl));
- ap_close(ap_piped_log_write_fd(pl));
- return APR_SUCCESS;
-}
-
-
-static ap_status_t piped_log_cleanup_for_exec(void *data)
-{
- piped_log *pl = data;
-
- ap_close(ap_piped_log_read_fd(pl));
- ap_close(ap_piped_log_write_fd(pl));
- return APR_SUCCESS;
-}
-
-API_EXPORT(piped_log *) ap_open_piped_log(ap_context_t *p, const char *program)
-{
- piped_log *pl;
-
- pl = ap_palloc(p, sizeof (*pl));
- pl->p = p;
- pl->program = ap_pstrdup(p, program);
- pl->pid = NULL;
- if (ap_create_pipe(&ap_piped_log_read_fd(pl), &ap_piped_log_write_fd(pl), p) != APR_SUCCESS) {
- int save_errno = errno;
- errno = save_errno;
- return NULL;
- }
- ap_register_cleanup(p, pl, piped_log_cleanup, piped_log_cleanup_for_exec);
- if (piped_log_spawn(pl) == -1) {
- int save_errno = errno;
- ap_kill_cleanup(p, pl, piped_log_cleanup);
- ap_close(ap_piped_log_read_fd(pl));
- ap_close(ap_piped_log_write_fd(pl));
- errno = save_errno;
- return NULL;
- }
- return pl;
-}
-
-#else
-
-static ap_status_t piped_log_cleanup(void *data)
-{
- piped_log *pl = data;
-
- ap_close(ap_piped_log_write_fd(pl));
- return APR_SUCCESS;
-}
-
-API_EXPORT(piped_log *) ap_open_piped_log(ap_context_t *p, const char *program)
-{
- piped_log *pl;
- ap_file_t *dummy = NULL;
- int rc;
-
- rc = log_child(p, program, &dummy);
- if (rc != APR_SUCCESS) {
- perror("ap_spawn_child");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Couldn't fork child for piped log process");
- exit (1);
- }
-
- pl = ap_palloc(p, sizeof (*pl));
- pl->p = p;
- ap_piped_log_read_fd(pl) = NULL;
- ap_piped_log_write_fd(pl) = dummy;
- ap_register_cleanup(p, pl, piped_log_cleanup, piped_log_cleanup);
-
- return pl;
-}
-
-#endif
-
-API_EXPORT(void) ap_close_piped_log(piped_log *pl)
-{
- ap_run_cleanup(pl->p, pl, piped_log_cleanup);
-}
-
diff --git a/server/main.c b/server/main.c
deleted file mode 100644
index 1fb6e684ad..0000000000
--- a/server/main.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#define CORE_PRIVATE
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "http_config.h"
-#include "util_uri.h"
-#include "apr_getopt.h"
-#include "ap_mpm.h"
-
-const char *ap_server_argv0;
-
-const char *ap_server_root;
-
-ap_array_header_t *ap_server_pre_read_config;
-ap_array_header_t *ap_server_post_read_config;
-ap_array_header_t *ap_server_config_defines;
-
-/* XXX - We should be able to grab the per-MPM settings here too */
-static void show_compile_settings(void)
-{
- printf("Server version: %s\n", ap_get_server_version());
- printf("Server built: %s\n", ap_get_server_built());
- printf("Server's Module Magic Number: %u:%u\n",
- MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
- printf("Server compiled with....\n");
-#ifdef BIG_SECURITY_HOLE
- printf(" -D BIG_SECURITY_HOLE\n");
-#endif
-#ifdef SECURITY_HOLE_PASS_AUTHORIZATION
- printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n");
-#endif
-#ifdef HAVE_MMAP
- printf(" -D HAVE_MMAP\n");
-#endif
-#ifdef HAVE_SHMGET
- printf(" -D HAVE_SHMGET\n");
-#endif
-#ifdef USE_MMAP_SCOREBOARD
- printf(" -D USE_MMAP_SCOREBOARD\n");
-#endif
-#ifdef USE_SHMGET_SCOREBOARD
- printf(" -D USE_SHMGET_SCOREBOARD\n");
-#endif
-#ifdef USE_OS2_SCOREBOARD
- printf(" -D USE_OS2_SCOREBOARD\n");
-#endif
-#ifdef USE_POSIX_SCOREBOARD
- printf(" -D USE_POSIX_SCOREBOARD\n");
-#endif
-#ifdef USE_MMAP_FILES
- printf(" -D USE_MMAP_FILES\n");
-#ifdef MMAP_SEGMENT_SIZE
- printf(" -D MMAP_SEGMENT_SIZE=%ld\n",(long)MMAP_SEGMENT_SIZE);
-#endif
-#endif /*USE_MMAP_FILES*/
-#ifdef NO_WRITEV
- printf(" -D NO_WRITEV\n");
-#endif
-#ifdef NO_LINGCLOSE
- printf(" -D NO_LINGCLOSE\n");
-#endif
-#ifdef USE_FCNTL_SERIALIZED_ACCEPT
- printf(" -D USE_FCNTL_SERIALIZED_ACCEPT\n");
-#endif
-#ifdef USE_FLOCK_SERIALIZED_ACCEPT
- printf(" -D USE_FLOCK_SERIALIZED_ACCEPT\n");
-#endif
-#ifdef USE_USLOCK_SERIALIZED_ACCEPT
- printf(" -D USE_USLOCK_SERIALIZED_ACCEPT\n");
-#endif
-#ifdef USE_SYSVSEM_SERIALIZED_ACCEPT
- printf(" -D USE_SYSVSEM_SERIALIZED_ACCEPT\n");
-#endif
-#ifdef USE_PTHREAD_SERIALIZED_ACCEPT
- printf(" -D USE_PTHREAD_SERIALIZED_ACCEPT\n");
-#endif
-#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
- printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");
-#endif
-#ifdef HAS_OTHER_CHILD
- printf(" -D HAS_OTHER_CHILD\n");
-#endif
-#ifdef HAVE_RELIABLE_PIPED_LOGS
- printf(" -D HAVE_RELIABLE_PIPED_LOGS\n");
-#endif
-#ifdef BUFFERED_LOGS
- printf(" -D BUFFERED_LOGS\n");
-#ifdef PIPE_BUF
- printf(" -D PIPE_BUF=%ld\n",(long)PIPE_BUF);
-#endif
-#endif
-#ifdef MULTITHREAD
- printf(" -D MULTITHREAD\n");
-#endif
-#ifdef CHARSET_EBCDIC
- printf(" -D CHARSET_EBCDIC\n");
-#endif
-#ifdef NEED_HASHBANG_EMUL
- printf(" -D NEED_HASHBANG_EMUL\n");
-#endif
-#ifdef SHARED_CORE
- printf(" -D SHARED_CORE\n");
-#endif
-
-/* This list displays the compiled in default paths: */
-#ifdef HTTPD_ROOT
- printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n");
-#endif
-#ifdef SUEXEC_BIN
- printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n");
-#endif
-#if defined(SHARED_CORE) && defined(SHARED_CORE_DIR)
- printf(" -D SHARED_CORE_DIR=\"" SHARED_CORE_DIR "\"\n");
-#endif
-#ifdef DEFAULT_PIDLOG
- printf(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n");
-#endif
-#ifdef DEFAULT_SCOREBOARD
- printf(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n");
-#endif
-#ifdef DEFAULT_LOCKFILE
- printf(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n");
-#endif
-#ifdef DEFAULT_XFERLOG
- printf(" -D DEFAULT_XFERLOG=\"" DEFAULT_XFERLOG "\"\n");
-#endif
-#ifdef DEFAULT_ERRORLOG
- printf(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n");
-#endif
-#ifdef TYPES_CONFIG_FILE
- printf(" -D TYPES_CONFIG_FILE=\"" TYPES_CONFIG_FILE "\"\n");
-#endif
-#ifdef SERVER_CONFIG_FILE
- printf(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n");
-#endif
-#ifdef ACCESS_CONFIG_FILE
- printf(" -D ACCESS_CONFIG_FILE=\"" ACCESS_CONFIG_FILE "\"\n");
-#endif
-#ifdef RESOURCE_CONFIG_FILE
- printf(" -D RESOURCE_CONFIG_FILE=\"" RESOURCE_CONFIG_FILE "\"\n");
-#endif
-}
-
-static void destroy_and_exit_process(process_rec *process, int process_exit_value)
-{
- ap_destroy_pool(process->pool); /* and destroy all descendent pools */
- exit(process_exit_value);
-}
-
-static process_rec *create_process(int argc, const char **argv)
-{
- process_rec *process;
-
- {
- ap_context_t *cntx;
-
- ap_create_context(&cntx, NULL);
- process = ap_palloc(cntx, sizeof(process_rec));
- process->pool = cntx;
- }
- ap_create_context(&process->pconf, process->pool);
- process->argc = argc;
- process->argv = argv;
- process->short_name = ap_filename_of_pathname(argv[0]);
- return process;
-}
-
-static void usage(process_rec *process)
-{
- const char *bin = process->argv[0];
- char pad[MAX_STRING_LEN];
- unsigned i;
-
- for (i = 0; i < strlen(bin); i++)
- pad[i] = ' ';
- pad[i] = '\0';
-#ifdef SHARED_CORE
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0,NULL , "Usage: %s [-R directory] [-D name] [-d directory] [-f file]", bin);
-#else
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Usage: %s [-D name] [-d directory] [-f file]", bin);
-#endif
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-C \"directive\"] [-c \"directive\"]", pad);
-#ifdef WIN32
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-k restart|shutdown|start]", pad);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-n service_name]", pad);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-i] [-u]", pad);
-#endif
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " %s [-v] [-V] [-h] [-l] [-L] [-S] [-t] [-T]", pad);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Options:");
-#ifdef SHARED_CORE
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -R directory : specify an alternate location for shared object files");
-#endif
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -D name : define a name for use in <IfDefine name> directives");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -d directory : specify an alternate initial ServerRoot");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -f file : specify an alternate ServerConfigFile");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -C \"directive\" : process directive before reading config files");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -c \"directive\" : process directive after reading config files");
-#ifdef WIN32
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -n name : set service name and use its ServerConfigFile");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k shutdown : tell running Apache to shutdown");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k restart : tell running Apache to do a graceful restart");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -k start : tell Apache to start");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -i : install an Apache service");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -u : uninstall an Apache service");
-#endif
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -v : show version number");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -V : show compile settings");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -h : list available command line options (this page)");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -l : list compiled in modules");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -L : list available configuration directives");
- /* TODOC: -S has been replaced by '-t -D DUMP_VHOSTS' */
- /* ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -S : show parsed settings (currently only vhost settings)"); */
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -t : run syntax check for config files (with docroot check)");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, " -T : run syntax check for config files (without docroot check)");
- /* TODOC: -X goes away, expect MPMs to use -D options */
- destroy_and_exit_process(process, 1);
-}
-
-
-
-
-
-ap_context_t *g_pHookPool;
-
-#ifdef WIN32
-API_EXPORT_NONSTD(int) apache_main(int argc, char *argv[])
-#else
-API_EXPORT_NONSTD(int) main(int argc, char *argv[])
-#endif
-{
- int c;
- int configtestonly = 0;
- const char *confname = SERVER_CONFIG_FILE;
- const char *def_server_root = HTTPD_ROOT;
- process_rec *process = create_process(argc, (const char **)argv);
- server_rec *server_conf;
- ap_context_t *pglobal = process->pool;
- ap_context_t *pconf = process->pconf;
- ap_context_t *plog; /* Pool of log streams, reset _after_ each read of conf */
- ap_context_t *ptemp; /* Pool for temporary config stuff, reset often */
- ap_context_t *pcommands; /* Pool for -C and -c switches */
-
- ap_server_argv0 = process->short_name;
-
- ap_util_uri_init();
-
- g_pHookPool=pglobal;
-
- ap_initialize();
-
- ap_setup_prelinked_modules(process);
-
- ap_create_context(&pcommands, pglobal);
- ap_server_pre_read_config = ap_make_array(pcommands, 1, sizeof(char *));
- ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
- ap_server_config_defines = ap_make_array(pcommands, 1, sizeof(char *));
-
- while (ap_getopt(pcommands, argc, argv, "C:c:d:f:k:vVlLth", &c) == APR_SUCCESS) {
- char **new;
- switch (c) {
- case 'c':
- new = (char **)ap_push_array(ap_server_post_read_config);
- *new = ap_pstrdup(pcommands, ap_optarg);
- break;
- case 'C':
- new = (char **)ap_push_array(ap_server_pre_read_config);
- *new = ap_pstrdup(pcommands, ap_optarg);
- break;
- case 'd':
- def_server_root = ap_optarg;
- break;
- case 'f':
- confname = ap_optarg;
- break;
- case 'v':
- printf("Server version: %s\n", ap_get_server_version());
- printf("Server built: %s\n", ap_get_server_built());
- destroy_and_exit_process(process, 0);
- case 'V':
- show_compile_settings();
- destroy_and_exit_process(process, 0);
- case 'l':
- ap_show_modules();
- destroy_and_exit_process(process, 0);
- case 'L':
- ap_show_directives();
- destroy_and_exit_process(process, 0);
- case 't':
- configtestonly = 1;
- break;
- case 'h':
- usage(process);
- case '?':
- usage(process);
- }
- }
-
- ap_create_context(&plog, pglobal);
- ap_create_context(&ptemp, pconf);
-
- /* Note that we preflight the config file once
- before reading it _again_ in the main loop.
- This allows things, log files configuration
- for example, to settle down. */
-
- ap_server_root = def_server_root;
- ap_run_pre_config(pconf, plog, ptemp);
- server_conf = ap_read_config(process, ptemp, confname);
- if (configtestonly) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Syntax OK\n");
- destroy_and_exit_process(process, 0);
- }
- ap_clear_pool(plog);
- ap_run_open_logs(pconf, plog, ptemp, server_conf);
- ap_post_config_hook(pconf, plog, ptemp, server_conf);
- ap_destroy_pool(ptemp);
-
- for (;;) {
- ap_clear_pool(pconf);
- ap_create_context(&ptemp, pconf);
- ap_server_root = def_server_root;
- ap_run_pre_config(pconf, plog, ptemp);
- server_conf = ap_read_config(process, ptemp, confname);
- ap_clear_pool(plog);
- ap_run_open_logs(pconf, plog, ptemp, server_conf);
- ap_post_config_hook(pconf, plog, ptemp, server_conf);
- ap_destroy_pool(ptemp);
-
- if (ap_mpm_run(pconf, plog, server_conf)) break;
- }
- destroy_and_exit_process(process, 0);
- return 0; /* Supress compiler warning. */
-}
-
-/* force Expat to be linked into the server executable */
-#if defined(USE_EXPAT) && !defined(SHARED_CORE_BOOTSTRAP)
-#include "xmlparse.h"
-const XML_LChar *suck_in_expat(void);
-const XML_LChar *suck_in_expat(void)
-{
- return XML_ErrorString(XML_ERROR_NONE);
-}
-#endif /* USE_EXPAT */
-
-#ifndef SHARED_CORE_BOOTSTRAP
-/*
- * Force ap_validate_password() into the image so that modules like
- * mod_auth can use it even if they're dynamically loaded.
- */
-void suck_in_ap_validate_password(void);
-void suck_in_ap_validate_password(void)
-{
- ap_validate_password("a", "b");
-}
-#endif
-
diff --git a/server/mpm/.cvsignore b/server/mpm/.cvsignore
deleted file mode 100644
index f3c7a7c5da..0000000000
--- a/server/mpm/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-Makefile
diff --git a/server/mpm/MPM.NAMING b/server/mpm/MPM.NAMING
deleted file mode 100644
index 452881b3b7..0000000000
--- a/server/mpm/MPM.NAMING
+++ /dev/null
@@ -1,34 +0,0 @@
-For right now, the naming of the MPM methods follows
-the following example for the 'prefork' method.
-
- 1. The directory name under modules/mpm is the actual
- name.
-
- eg: modules/mpm/prefork
-
- 2. The internal module name must be that name, prepended with
- mpm_ and suffixed with _module
-
- eg: mpm_prefork_module
-
- 3. The Makefile.tmpl must create lib<name>.a
-
- eg: libprefork.a
-
-Numbers 1 and 3 follow the normal rules (for example, modules/standard
-creates libstandard.a, etc...).
-
-The MPM_METHOD Rule will use the actual name (eg: prefork) to
-pick the correct method module to build.
-
-The following MPMs currently exist:
-
- prefork ....... Multi Process Model with Preforking (Apache 1.3)
- dexter ........ Multi Process Model with Threading via Pthreads
- Constant number of processes, variable number of threads
- mpmt_pthread .. Multi Process Model with Threading via Pthreads
- Variable number of processes, constant number of
- threads/child (= Apache/pthread)
- spmt_os2 ...... Single Process Model with Threading on OS/2
- winnt ......... Single Process Model with Threading on Windows NT
-
diff --git a/server/mpm/Makefile.in b/server/mpm/Makefile.in
deleted file mode 100644
index 7f678e86bf..0000000000
--- a/server/mpm/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-
-DEPTH = ../..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-SUBDIRS = $(MPM_NAME)
-
-include $(topsrcdir)/build/rules.mk
diff --git a/server/mpm/config.m4 b/server/mpm/config.m4
deleted file mode 100644
index 2d3f877a5d..0000000000
--- a/server/mpm/config.m4
+++ /dev/null
@@ -1,75 +0,0 @@
-AC_MSG_CHECKING(which MPM to use)
-AC_ARG_WITH(mpm,
-[ --with-mpm=MPM Choose the process model for Apache to use.
- MPM={dexter,mpmt_beos,mpmt_pthread,prefork,spmt_os2}],[
- APACHE_MPM=$withval
-],[
- APACHE_MPM=mpmt_pthread
- case "`uname -sr`" in
- "BeOS"*)
- APACHE_MPM=mpmt_beos;;
- esac
-])
-AC_MSG_RESULT($APACHE_MPM)
-
-apache_cv_mpm=$APACHE_MPM
-
-if test "$apache_cv_mpm" = "mpmt_pthread" -o "$apache_cv_mpm" = "dexter"; then
- PTHREADS_CHECK
- AC_MSG_CHECKING([for which threading library to use])
- AC_MSG_RESULT($threads_result)
-
- if test "$apache_threads_working" = "no"; then
- AC_MSG_RESULT(The currently selected MPM requires pthreads which your system seems to lack)
- AC_MSG_CHECKING(checking for replacement)
- AC_MSG_RESULT(prefork selected)
- apache_cv_mpm=prefork
- fi
-fi
-
-APACHE_CHECK_SHM_RW
-
-APACHE_FAST_OUTPUT(modules/mpm/Makefile)
-MPM_NAME=$apache_cv_mpm
-MPM_DIR=modules/mpm/$MPM_NAME
-MPM_LIB=$MPM_DIR/lib${MPM_NAME}.la
-
-APACHE_SUBST(MPM_NAME)
-MODLIST="$MODLIST mpm_${MPM_NAME}"
-
-dnl All the unix MPMs use shared memory; save a little duplication
-AC_DEFUN(APACHE_MPM_CHECK_SHMEM, [
- AC_CHECK_FUNCS(shmget)
- AC_FUNC_MMAP
-
- AC_MSG_CHECKING(which shared memory mechanism to use)
- if test "$ac_cv_func_shmget" = "yes" ; then
- AC_DEFINE(USE_SHMGET_SCOREBOARD,,
- [Define if MPMs should use shmget to implement their shared memory])
- AC_MSG_RESULT(shmget)
- elif test "$ac_cv_func_mmap" = "yes" ; then
- AC_DEFINE(USE_MMAP_SCOREBOARD,,
- [Define if MPMs should use mmap to implement their shared memory])
- AC_MSG_RESULT(mmap)
- else
- AC_MSG_ERROR(No known shared memory system)
- fi
-])
-
-dnl Check for pthreads and attempt to support it
-AC_DEFUN(APACHE_MPM_PTHREAD, [
-
-dnl XXX - We should be checking for the proper flags to use on a particular
-dnl platform. This will cover a couple of them, anyway
-
- AC_CHECK_HEADER(pthread.h, [ ],[
- AC_MSG_ERROR(This MPM requires pthreads. Try --with-mpm=prefork.)
- ])
- AC_CHECK_FUNC(pthread_create, [ ],[
- AC_MSG_ERROR(Can't compile pthread code.)
- ])
-
- dnl User threads libraries need pthread.h included everywhere
- AC_DEFINE(PTHREAD_EVERYWHERE,,
- [Define if all code should have #include <pthread.h>])
-])
diff --git a/server/mpm/dexter/.cvsignore b/server/mpm/dexter/.cvsignore
deleted file mode 100644
index 151f66f3e4..0000000000
--- a/server/mpm/dexter/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.lo
-*.la
-Makefile
diff --git a/server/mpm/dexter/Makefile.in b/server/mpm/dexter/Makefile.in
deleted file mode 100644
index 573c30d9a0..0000000000
--- a/server/mpm/dexter/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-
-DEPTH = ../../..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-LTLIBRARY_NAME = libdexter.la
-LTLIBRARY_SOURCES = dexter.c scoreboard.c
-
-include $(topsrcdir)/build/ltlib.mk
diff --git a/server/mpm/dexter/Makefile.libdir b/server/mpm/dexter/Makefile.libdir
deleted file mode 100644
index 7b5254013a..0000000000
--- a/server/mpm/dexter/Makefile.libdir
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a place-holder which indicates to Configure that it shouldn't
-provide the default targets when building the Makefile in this directory.
-Instead it'll just prepend all the important variable definitions, and
-copy the Makefile.tmpl onto the end.
diff --git a/server/mpm/dexter/config.m4 b/server/mpm/dexter/config.m4
deleted file mode 100644
index 9c50938bb9..0000000000
--- a/server/mpm/dexter/config.m4
+++ /dev/null
@@ -1,10 +0,0 @@
-dnl ## XXX - Need a more thorough check of the proper flags to use
-
-if test "$MPM_NAME" = "dexter" ; then
- ac_cv_enable_threads="yes"
- AC_CACHE_SAVE
-
- APACHE_FAST_OUTPUT(modules/mpm/$MPM_NAME/Makefile)
- APACHE_MPM_PTHREAD
- APACHE_MPM_CHECK_SHMEM
-fi
diff --git a/server/mpm/dexter/dexter.c b/server/mpm/dexter/dexter.c
deleted file mode 100644
index fa4ed627fe..0000000000
--- a/server/mpm/dexter/dexter.c
+++ /dev/null
@@ -1,1719 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#define CORE_PRIVATE
-
-#include "ap_config.h"
-#include "apr_portable.h"
-#include "httpd.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "http_config.h" /* for read_config */
-#include "http_core.h" /* for get_remote_host */
-#include "http_connection.h"
-#include "ap_mpm.h"
-#include "unixd.h"
-#include "iol_socket.h"
-#include "ap_listen.h"
-#include "mpm_default.h"
-#include "dexter.h"
-#include "scoreboard.h"
-
-#include <poll.h>
-#include <netinet/tcp.h>
-#include <pthread.h>
-#include <signal.h>
-
-/*
- * Actual definitions of config globals
- */
-
-static int threads_to_start = 0; /* Worker threads per child */
-static int min_spare_threads = 0;
-static int max_spare_threads = 0;
-static int max_threads = 0;
-static int max_requests_per_child = 0;
-static char *ap_pid_fname=NULL;
-static int num_daemons=0;
-static int workers_may_exit = 0;
-static int requests_this_child;
-static int num_listenfds = 0;
-static struct pollfd *listenfds;
-
-/* Table of child status */
-#define SERVER_DEAD 0
-#define SERVER_DYING 1
-#define SERVER_ALIVE 2
-
-static struct {
- pid_t pid;
- unsigned char status;
-} child_table[HARD_SERVER_LIMIT];
-
-/*
- * The max child slot ever assigned, preserved across restarts. Necessary
- * to deal with NumServers changes across SIGWINCH restarts. We use this
- * value to optimize routines that have to scan the entire child table.
- *
- * XXX - It might not be worth keeping this code in. There aren't very
- * many child processes in this MPM.
- */
-int max_daemons_limit = -1;
-
-static char ap_coredump_dir[MAX_STRING_LEN];
-
-static int pipe_of_death[2];
-static pthread_mutex_t pipe_of_death_mutex;
-
-/* *Non*-shared http_main globals... */
-
-static server_rec *server_conf;
-
-/* one_process --- debugging mode variable; can be set from the command line
- * with the -X flag. If set, this gets you the child_main loop running
- * in the process which originally started up (no detach, no make_child),
- * which is a pretty nice debugging environment. (You'll get a SIGHUP
- * early in standalone_main; just continue through. This is the server
- * trying to kill off any child processes which it might have lying
- * around --- Apache doesn't keep track of their pids, it just sends
- * SIGHUP to the process group, ignoring it in the root process.
- * Continue through and you'll be fine.).
- */
-
-static int one_process = 0;
-
-#ifdef DEBUG_SIGSTOP
-int raise_sigstop_flags;
-#endif
-
-#ifdef HAS_OTHER_CHILD
-/* used to maintain list of children which aren't part of the child table */
-typedef struct other_child_rec other_child_rec;
-struct other_child_rec {
- other_child_rec *next;
- int pid;
- void (*maintenance) (int, void *, ap_wait_t);
- void *data;
- int write_fd;
-};
-static other_child_rec *other_children;
-#endif
-
-static ap_context_t *pconf; /* Pool for config stuff */
-static ap_context_t *pchild; /* Pool for httpd child stuff */
-static ap_context_t *thread_pool_parent; /* Parent of per-thread pools */
-static pthread_mutex_t thread_pool_parent_mutex;
-
-static int child_num;
-static int my_pid; /* Linux getpid() doesn't work except in main thread. Use
- this instead */
-/* Keep track of the number of worker threads currently active */
-static int worker_thread_count;
-static pthread_mutex_t worker_thread_count_mutex;
-static int worker_thread_free_ids[HARD_THREAD_LIMIT];
-static pthread_attr_t worker_thread_attr;
-
-/* Keep track of the number of idle worker threads */
-static int idle_thread_count;
-static pthread_mutex_t idle_thread_count_mutex;
-
-/* Locks for accept serialization */
-#ifdef NO_SERIALIZED_ACCEPT
-#define SAFE_ACCEPT(stmt) APR_SUCCESS
-#else
-#define SAFE_ACCEPT(stmt) (stmt)
-static ap_lock_t *process_accept_mutex;
-#endif /* NO_SERIALIZED_ACCEPT */
-static char *lock_fname;
-static pthread_mutex_t thread_accept_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-/* Global, alas, so http_core can talk to us */
-enum server_token_type ap_server_tokens = SrvTk_FULL;
-
-API_EXPORT(const server_rec *) ap_get_server_conf(void)
-{
- return (server_conf);
-}
-
-/* a clean exit from a child with proper cleanup */
-static void clean_child_exit(int code)
-{
- if (pchild) {
- ap_destroy_pool(pchild);
- }
- exit(code);
-}
-
-/*****************************************************************
- * dealing with other children
- */
-
-#ifdef HAS_OTHER_CHILD
-API_EXPORT(void) ap_register_other_child(int pid,
- void (*maintenance) (int reason, void *, ap_wait_t status),
- void *data, int write_fd)
-{
- other_child_rec *ocr;
-
- ocr = ap_palloc(pconf, sizeof(*ocr));
- ocr->pid = pid;
- ocr->maintenance = maintenance;
- ocr->data = data;
- ocr->write_fd = write_fd;
- ocr->next = other_children;
- other_children = ocr;
-}
-
-/* note that 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.
- */
-API_EXPORT(void) ap_unregister_other_child(void *data)
-{
- other_child_rec **pocr, *nocr;
-
- for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
- if ((*pocr)->data == data) {
- nocr = (*pocr)->next;
- (*(*pocr)->maintenance) (OC_REASON_UNREGISTER, (*pocr)->data, -1);
- *pocr = nocr;
- /* XXX: um, well we've just wasted some space in pconf ? */
- return;
- }
- }
-}
-
-/* test to ensure that the write_fds are all still writable, otherwise
- * invoke the maintenance functions as appropriate */
-static void probe_writable_fds(void)
-{
- return;
-#if 0
- fd_set writable_fds;
- int fd_max;
- other_child_rec *ocr, *nocr;
- struct timeval tv;
- int rc;
-
- if (other_children == NULL)
- return;
-
- fd_max = 0;
- FD_ZERO(&writable_fds);
- do {
- for (ocr = other_children; ocr; ocr = ocr->next) {
- if (ocr->write_fd == -1)
- continue;
- FD_SET(ocr->write_fd, &writable_fds);
- if (ocr->write_fd > fd_max) {
- fd_max = ocr->write_fd;
- }
- }
- if (fd_max == 0)
- return;
-
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
- } while (rc == -1 && errno == EINTR);
-
- if (rc == -1) {
- /* XXX: uhh this could be really bad, we could have a bad file
- * descriptor due to a bug in one of the maintenance routines */
- ap_log_unixerr("probe_writable_fds", "select",
- "could not probe writable fds", server_conf);
- return;
- }
- if (rc == 0)
- return;
-
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->write_fd == -1)
- continue;
- if (FD_ISSET(ocr->write_fd, &writable_fds))
- continue;
- (*ocr->maintenance) (OC_REASON_UNWRITABLE, ocr->data, -1);
- }
-#endif
-}
-
-/* possibly reap an other_child, return 0 if yes, -1 if not */
-static int reap_other_child(int pid, ap_wait_t status)
-{
- other_child_rec *ocr, *nocr;
-
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->pid != pid)
- continue;
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
- return 0;
- }
- return -1;
-}
-#endif
-
-static void reclaim_child_processes(int terminate)
-{
- int i, status;
- long int waittime = 1024 * 16; /* in usecs */
- struct timeval tv;
- int waitret, tries;
- int not_dead_yet;
-#ifdef HAS_OTHER_CHILD
- other_child_rec *ocr, *nocr;
-#endif
-
- for (tries = terminate ? 4 : 1; tries <= 9; ++tries) {
- /* don't want to hold up progress any more than
- * necessary, but we need to allow children a few moments to exit.
- * Set delay with an exponential backoff.
- */
- tv.tv_sec = waittime / 1000000;
- tv.tv_usec = waittime % 1000000;
- waittime = waittime * 4;
- ap_select(0, NULL, NULL, NULL, &tv);
-
- /* now see who is done */
- not_dead_yet = 0;
- for (i = 0; i < max_daemons_limit; ++i) {
- int pid;
-
- if (child_table[i].status == SERVER_DEAD)
- continue;
-
- pid = child_table[i].pid;
-
- waitret = waitpid(pid, &status, WNOHANG);
- if (waitret == pid || waitret == -1) {
- child_table[i].status = SERVER_DEAD;
- continue;
- }
- ++not_dead_yet;
- switch (tries) {
- case 1: /* 16ms */
- case 2: /* 82ms */
- break;
- case 3: /* 344ms */
- case 4: /* 16ms */
- case 5: /* 82ms */
- case 6: /* 344ms */
- case 7: /* 1.4sec */
- /* ok, now it's being annoying */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno,
- server_conf,
- "child process %d still did not exit, sending a SIGTERM",
- pid);
- kill(pid, SIGTERM);
- break;
- case 8: /* 6 sec */
- /* die child scum */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, errno,
- server_conf,
- "child process %d still did not exit, sending a SIGKILL",
- pid);
- kill(pid, SIGKILL);
- break;
- case 9: /* 14 sec */
- /* gave it our best shot, but alas... If this really
- * is a child we are trying to kill and it really hasn't
- * exited, we will likely fail to bind to the port
- * after the restart.
- */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, errno,
- server_conf,
- "could not make child process %d exit, "
- "attempting to continue anyway", pid);
- break;
- }
- }
-#ifdef HAS_OTHER_CHILD
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->pid == -1)
- continue;
-
- waitret = waitpid(ocr->pid, &status, WNOHANG);
- if (waitret == ocr->pid) {
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
- }
- else if (waitret == 0) {
- (*ocr->maintenance) (OC_REASON_RESTART, ocr->data, -1);
- ++not_dead_yet;
- }
- else if (waitret == -1) {
- /* uh what the heck? they didn't call unregister? */
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_LOST, ocr->data, -1);
- }
- }
-#endif
- if (!not_dead_yet) {
- /* nothing left to wait for */
- break;
- }
- }
-}
-
-/* Finally, this routine is used by the caretaker process to wait for
- * a while...
- */
-
-/* number of calls to wait_or_timeout between writable probes */
-#ifndef INTERVAL_OF_WRITABLE_PROBES
-#define INTERVAL_OF_WRITABLE_PROBES 10
-#endif
-static int wait_or_timeout_counter;
-
-static int wait_or_timeout(ap_wait_t *status)
-{
- struct timeval tv;
- int ret;
-
- ++wait_or_timeout_counter;
- if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
- wait_or_timeout_counter = 0;
-#ifdef HAS_OTHER_CHILD
- probe_writable_fds();
-#endif
- }
- ret = waitpid(-1, status, WNOHANG);
- if (ret == -1 && errno == EINTR) {
- return -1;
- }
- if (ret > 0) {
- return ret;
- }
- tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000;
- tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000;
- ap_select(0, NULL, NULL, NULL, &tv);
- return -1;
-}
-
-/* handle all varieties of core dumping signals */
-static void sig_coredump(int sig)
-{
- chdir(ap_coredump_dir);
- signal(sig, SIG_DFL);
- kill(getpid(), sig);
- /* At this point we've got sig blocked, because we're still inside
- * the signal handler. When we leave the signal handler it will
- * be unblocked, and we'll take the signal... and coredump or whatever
- * is appropriate for this particular Unix. In addition the parent
- * will see the real signal we received -- whereas if we called
- * abort() here, the parent would only see SIGABRT.
- */
-}
-
-static void just_die(int sig)
-{
- clean_child_exit(0);
-}
-
-/*****************************************************************
- * Connection structures and accounting...
- */
-
-/* volatile just in case */
-static int volatile shutdown_pending;
-static int volatile restart_pending;
-static int volatile is_graceful;
-
-/*
- * ap_start_shutdown() and ap_start_restart(), below, are a first stab at
- * functions to initiate shutdown or restart without relying on signals.
- * Previously this was initiated in sig_term() and restart() signal handlers,
- * but we want to be able to start a shutdown/restart from other sources --
- * e.g. on Win32, from the service manager. Now the service manager can
- * call ap_start_shutdown() or ap_start_restart() as appropiate. Note that
- * these functions can also be called by the child processes, since global
- * variables are no longer used to pass on the required action to the parent.
- *
- * These should only be called from the parent process itself, since the
- * parent process will use the shutdown_pending and restart_pending variables
- * to determine whether to shutdown or restart. The child process should
- * call signal_parent() directly to tell the parent to die -- this will
- * cause neither of those variable to be set, which the parent will
- * assume means something serious is wrong (which it will be, for the
- * child to force an exit) and so do an exit anyway.
- */
-
-void ap_start_shutdown(void)
-{
- if (shutdown_pending == 1) {
- /* Um, is this _probably_ not an error, if the user has
- * tried to do a shutdown twice quickly, so we won't
- * worry about reporting it.
- */
- return;
- }
- shutdown_pending = 1;
-}
-
-/* do a graceful restart if graceful == 1 */
-void ap_start_restart(int graceful)
-{
-
- if (restart_pending == 1) {
- /* Probably not an error - don't bother reporting it */
- return;
- }
- restart_pending = 1;
- is_graceful = graceful;
-}
-
-static void sig_term(int sig)
-{
- ap_start_shutdown();
-}
-
-static void restart(int sig)
-{
-#ifndef WIN32
- ap_start_restart(sig == SIGWINCH);
-#else
- ap_start_restart(1);
-#endif
-}
-
-static void set_signals(void)
-{
-#ifndef NO_USE_SIGACTION
- struct sigaction sa;
-
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
-
- if (!one_process) {
- sa.sa_handler = sig_coredump;
-#if defined(SA_ONESHOT)
- sa.sa_flags = SA_ONESHOT;
-#elif defined(SA_RESETHAND)
- sa.sa_flags = SA_RESETHAND;
-#endif
- if (sigaction(SIGSEGV, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGSEGV)");
-#ifdef SIGBUS
- if (sigaction(SIGBUS, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGBUS)");
-#endif
-#ifdef SIGABORT
- if (sigaction(SIGABORT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABORT)");
-#endif
-#ifdef SIGABRT
- if (sigaction(SIGABRT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABRT)");
-#endif
-#ifdef SIGILL
- if (sigaction(SIGILL, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGILL)");
-#endif
- sa.sa_flags = 0;
- }
- sa.sa_handler = sig_term;
- if (sigaction(SIGTERM, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGTERM)");
-#ifdef SIGINT
- if (sigaction(SIGINT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGINT)");
-#endif
-#ifdef SIGXCPU
- sa.sa_handler = SIG_DFL;
- if (sigaction(SIGXCPU, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXCPU)");
-#endif
-#ifdef SIGXFSZ
- sa.sa_handler = SIG_DFL;
- if (sigaction(SIGXFSZ, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXFSZ)");
-#endif
-#ifdef SIGPIPE
- sa.sa_handler = SIG_IGN;
- if (sigaction(SIGPIPE, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGPIPE)");
-#endif
-
- /* we want to ignore HUPs and WINCH while we're busy processing one */
- sigaddset(&sa.sa_mask, SIGHUP);
- sigaddset(&sa.sa_mask, SIGWINCH);
- sa.sa_handler = restart;
- if (sigaction(SIGHUP, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGHUP)");
- if (sigaction(SIGWINCH, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGWINCH)");
-#else
- if (!one_process) {
- signal(SIGSEGV, sig_coredump);
-#ifdef SIGBUS
- signal(SIGBUS, sig_coredump);
-#endif /* SIGBUS */
-#ifdef SIGABORT
- signal(SIGABORT, sig_coredump);
-#endif /* SIGABORT */
-#ifdef SIGABRT
- signal(SIGABRT, sig_coredump);
-#endif /* SIGABRT */
-#ifdef SIGILL
- signal(SIGILL, sig_coredump);
-#endif /* SIGILL */
-#ifdef SIGXCPU
- signal(SIGXCPU, SIG_DFL);
-#endif /* SIGXCPU */
-#ifdef SIGXFSZ
- signal(SIGXFSZ, SIG_DFL);
-#endif /* SIGXFSZ */
- }
-
- signal(SIGTERM, sig_term);
-#ifdef SIGHUP
- signal(SIGHUP, restart);
-#endif /* SIGHUP */
-#ifdef SIGWINCH
- signal(SIGWINCH, restart);
-#endif /* SIGWINCH */
-#ifdef SIGPIPE
- signal(SIGPIPE, SIG_IGN);
-#endif /* SIGPIPE */
-
-#endif
-}
-
-static void process_child_status(int pid, ap_wait_t status)
-{
- /* Child died... if it died due to a fatal error,
- * we should simply bail out.
- */
- if ((WIFEXITED(status)) &&
- WEXITSTATUS(status) == APEXIT_CHILDFATAL) {
- ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, errno, server_conf,
- "Child %d returned a Fatal error... \n"
- "Apache is exiting!",
- pid);
- exit(APEXIT_CHILDFATAL);
- }
- if (WIFSIGNALED(status)) {
- switch (WTERMSIG(status)) {
- case SIGTERM:
- case SIGHUP:
- case SIGUSR1:
- case SIGKILL:
- break;
- default:
-#ifdef SYS_SIGLIST
-#ifdef WCOREDUMP
- if (WCOREDUMP(status)) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, errno,
- server_conf,
- "child pid %d exit signal %s (%d), "
- "possible coredump in %s",
- pid, (WTERMSIG(status) >= NumSIG) ? "" :
- SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status),
- ap_coredump_dir);
- }
- else {
-#endif
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, errno,
- server_conf,
- "child pid %d exit signal %s (%d)", pid,
- SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status));
-#ifdef WCOREDUMP
- }
-#endif
-#else
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, errno,
- server_conf,
- "child pid %d exit signal %d",
- pid, WTERMSIG(status));
-#endif
- }
- }
-}
-
-static int setup_listeners(server_rec *s)
-{
- ap_listen_rec *lr;
- int num_listeners = 0;
-
- if (ap_listen_open(s->process, s->port)) {
- return 0;
- }
- for (lr = ap_listeners; lr; lr = lr->next) {
- num_listeners++;
- }
- return num_listeners;
-}
-
-/*****************************************************************
- * Here follows a long bunch of generic server bookkeeping stuff...
- */
-
-#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
-static void sock_disable_nagle(int s)
-{
- /* The Nagle algorithm says that we should delay sending partial
- * packets in hopes of getting more data. We don't want to do
- * this; we are not telnet. There are bad interactions between
- * persistent connections and Nagle's algorithm that have very severe
- * performance penalties. (Failing to disable Nagle is not much of a
- * problem with simple HTTP.)
- *
- * In spite of these problems, failure here is not a shooting offense.
- */
- int just_say_no = 1;
-
- if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &just_say_no,
- sizeof(int)) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf,
- "setsockopt: (TCP_NODELAY)");
- }
-}
-
-#else
-#define sock_disable_nagle(s) /* NOOP */
-#endif
-
-int ap_graceful_stop_signalled(void)
-{
- /* XXX - Does this really work? - Manoj */
- return is_graceful;
-}
-
-/*****************************************************************
- * Child process main loop.
- */
-
-static void process_socket(ap_context_t *p, ap_socket_t *sock, long conn_id)
-{
- BUFF *conn_io;
- conn_rec *current_conn;
- ap_iol *iol;
- int csd;
- ap_status_t rv;
-
- if ((rv = ap_get_os_sock(&csd, sock)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "ap_get_os_sock");
- }
- sock_disable_nagle(csd);
-
- iol = unix_attach_socket(sock);
- if (iol == NULL) {
- if (errno == EBADF) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno, NULL,
- "filedescriptor (%u) larger than FD_SETSIZE (%u) "
- "found, you probably need to rebuild Apache with a "
- "larger FD_SETSIZE", csd, FD_SETSIZE);
- }
- else {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL,
- "error attaching to socket");
- }
- ap_close_socket(sock);
- return;
- }
-
- conn_io = ap_bcreate(p, B_RDWR);
- ap_bpush_iol(conn_io, iol);
-
- current_conn = ap_new_apr_connection(p, server_conf, conn_io, sock,
- conn_id);
-
- ap_process_connection(current_conn);
-}
-
-static void *worker_thread(void *);
-
-/* Starts a thread as long as we're below max_threads */
-static int start_thread(void)
-{
- pthread_t thread;
-
- pthread_mutex_lock(&worker_thread_count_mutex);
- if (worker_thread_count < max_threads) {
- if (pthread_create(&thread, &worker_thread_attr, worker_thread,
- &worker_thread_free_ids[worker_thread_count])) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, server_conf,
- "pthread_create: unable to create worker thread");
- /* In case system resources are maxxed out, we don't want
- Apache running away with the CPU trying to fork over and
- over and over again if we exit. */
- sleep(10);
- workers_may_exit = 1;
- pthread_mutex_unlock(&worker_thread_count_mutex);
- return 0;
- }
- else {
- worker_thread_count++;
- }
- }
- else {
- static int reported = 0;
-
- if (!reported) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, errno, server_conf,
- "server reached MaxThreadsPerChild setting, consider raising the"
- " MaxThreadsPerChild or NumServers settings");
- reported = 1;
- }
- pthread_mutex_unlock(&worker_thread_count_mutex);
- return 0;
- }
- pthread_mutex_unlock(&worker_thread_count_mutex);
- return 1;
-
-}
-/* Sets workers_may_exit if we received a character on the pipe_of_death */
-static void check_pipe_of_death(void)
-{
- pthread_mutex_lock(&pipe_of_death_mutex);
- if (!workers_may_exit) {
- int ret;
- char pipe_read_char;
-
- ret = read(listenfds[0].fd, &pipe_read_char, 1);
- if (ret == -1 && errno == EAGAIN) {
- /* It lost the lottery. It must continue to suffer
- * through a life of servitude. */
- }
- else {
- /* It won the lottery (or something else is very
- * wrong). Embrace death with open arms. */
- workers_may_exit = 1;
- }
- }
- pthread_mutex_unlock(&pipe_of_death_mutex);
-}
-
-/* idle_thread_count should be incremented before starting a worker_thread */
-
-static void *worker_thread(void *arg)
-{
- ap_socket_t *csd = NULL;
- ap_context_t *tpool; /* Pool for this thread */
- ap_context_t *ptrans; /* Pool for per-transaction stuff */
- ap_socket_t *sd = NULL;
- int srv;
- int curr_pollfd, last_pollfd = 0;
- int thread_just_started = 1;
- int thread_num = *((int *) arg);
- long conn_id = child_num * HARD_THREAD_LIMIT + thread_num;
- ap_status_t rv;
-
- pthread_mutex_lock(&thread_pool_parent_mutex);
- ap_create_context(&tpool, thread_pool_parent);
- pthread_mutex_unlock(&thread_pool_parent_mutex);
- ap_create_context(&ptrans, tpool);
-
- while (!workers_may_exit) {
- workers_may_exit |= (max_requests_per_child != 0) && (requests_this_child <= 0);
- if (workers_may_exit) break;
- if (!thread_just_started) {
- pthread_mutex_lock(&idle_thread_count_mutex);
- if (idle_thread_count < max_spare_threads) {
- idle_thread_count++;
- pthread_mutex_unlock(&idle_thread_count_mutex);
- }
- else {
- pthread_mutex_unlock(&idle_thread_count_mutex);
- break;
- }
- }
- else {
- thread_just_started = 0;
- }
- pthread_mutex_lock(&thread_accept_mutex);
- if (workers_may_exit) {
- pthread_mutex_unlock(&thread_accept_mutex);
- break;
- }
- if ((rv = SAFE_ACCEPT(ap_lock(process_accept_mutex)))
- != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, rv, server_conf,
- "ap_lock failed. Attempting to shutdown "
- "process gracefully.");
- workers_may_exit = 1;
- }
-
- while (!workers_may_exit) {
- srv = poll(listenfds, num_listenfds + 1, -1);
-
- if (srv < 0) {
- if (errno == EINTR) {
- continue;
- }
-
- /* poll() will only return errors in catastrophic
- * circumstances. Let's try exiting gracefully, for now. */
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, (const server_rec *)
- ap_get_server_conf(), "poll: (listen)");
- workers_may_exit = 1;
- }
- if (workers_may_exit) break;
-
- if (listenfds[0].revents & POLLIN) {
- /* A process got a signal on the shutdown pipe. Check if we're
- * the lucky process to die. */
- check_pipe_of_death();
- continue;
- }
-
- if (num_listenfds == 1) {
- sd = ap_listeners->sd;
- goto got_fd;
- }
- else {
- /* find a listener */
- curr_pollfd = last_pollfd;
- do {
- curr_pollfd++;
- if (curr_pollfd > num_listenfds) {
- curr_pollfd = 1;
- }
- /* XXX: Should we check for POLLERR? */
- if (listenfds[curr_pollfd].revents & POLLIN) {
- last_pollfd = curr_pollfd;
- sd = NULL;
- ap_put_os_sock(&sd, &listenfds[curr_pollfd].fd, ptrans);
- goto got_fd;
- }
- } while (curr_pollfd != last_pollfd);
- }
- }
- got_fd:
- if (!workers_may_exit) {
- if ((rv = ap_accept(&csd, sd, ptrans)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, "ap_accept");
- }
- if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex)))
- != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, rv, server_conf,
- "ap_unlock failed. Attempting to shutdown "
- "process gracefully.");
- workers_may_exit = 1;
- }
- pthread_mutex_unlock(&thread_accept_mutex);
- pthread_mutex_lock(&idle_thread_count_mutex);
- if (idle_thread_count > min_spare_threads) {
- idle_thread_count--;
- }
- else {
- if (!start_thread()) {
- idle_thread_count--;
- }
- }
- pthread_mutex_unlock(&idle_thread_count_mutex);
- process_socket(ptrans, csd, conn_id);
- requests_this_child--;
- } else {
- if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex)))
- != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, rv, server_conf,
- "ap_unlock failed. Attempting to shutdown "
- "process gracefully.");
- workers_may_exit = 1;
- }
- pthread_mutex_unlock(&thread_accept_mutex);
- pthread_mutex_lock(&idle_thread_count_mutex);
- idle_thread_count--;
- pthread_mutex_unlock(&idle_thread_count_mutex);
- break;
- }
- ap_clear_pool(ptrans);
- }
-
- pthread_mutex_lock(&thread_pool_parent_mutex);
- ap_destroy_context(tpool);
- pthread_mutex_unlock(&thread_pool_parent_mutex);
- pthread_mutex_lock(&worker_thread_count_mutex);
- worker_thread_count--;
- worker_thread_free_ids[worker_thread_count] = thread_num;
- if (worker_thread_count == 0) {
- /* All the threads have exited, now finish the shutdown process
- * by signalling the sigwait thread */
- kill(my_pid, SIGTERM);
- }
- pthread_mutex_unlock(&worker_thread_count_mutex);
-
- return NULL;
-}
-
-static void child_main(int child_num_arg)
-{
- sigset_t sig_mask;
- int signal_received;
- int i;
- ap_listen_rec *lr;
- ap_status_t rv;
-
- my_pid = getpid();
- child_num = child_num_arg;
- ap_create_context(&pchild, pconf);
-
- /*stuff to do before we switch id's, so we have permissions.*/
-
- rv = SAFE_ACCEPT(ap_child_init_lock(&process_accept_mutex, lock_fname,
- pchild));
- if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, rv, server_conf,
- "Couldn't initialize cross-process lock in child");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-
- if (unixd_setup_child()) {
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-
- ap_child_init_hook(pchild, server_conf);
-
- /*done with init critical section */
-
- /* All threads should mask signals out, accoring to sigwait(2) man page */
- sigfillset(&sig_mask);
-
- if (pthread_sigmask(SIG_SETMASK, &sig_mask, NULL) != 0) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, server_conf,
- "pthread_sigmask");
- }
-
- requests_this_child = max_requests_per_child;
-
- /* Set up the pollfd array */
- listenfds = ap_palloc(pchild, sizeof(struct pollfd) * (num_listenfds + 1));
- listenfds[0].fd = pipe_of_death[0];
- listenfds[0].events = POLLIN;
- listenfds[0].revents = 0;
- for (lr = ap_listeners, i = 1; i <= num_listenfds; lr = lr->next, ++i) {
- ap_get_os_sock(&listenfds[i].fd, lr->sd);
- listenfds[i].events = POLLIN; /* should we add POLLPRI ?*/
- listenfds[i].revents = 0;
- }
-
- /* Setup worker threads */
-
- if (threads_to_start > max_threads) {
- threads_to_start = max_threads;
- }
- idle_thread_count = threads_to_start;
- worker_thread_count = 0;
- for (i = 0; i < max_threads; i++) {
- worker_thread_free_ids[i] = i;
- }
- ap_create_context(&thread_pool_parent, pchild);
- pthread_mutex_init(&thread_pool_parent_mutex, NULL);
- pthread_mutex_init(&idle_thread_count_mutex, NULL);
- pthread_mutex_init(&worker_thread_count_mutex, NULL);
- pthread_mutex_init(&pipe_of_death_mutex, NULL);
- pthread_attr_init(&worker_thread_attr);
- pthread_attr_setdetachstate(&worker_thread_attr, PTHREAD_CREATE_DETACHED);
-
- /* We are creating worker threads right now */
- for (i=0; i < threads_to_start; i++) {
- /* start_thread shouldn't fail here */
- if (!start_thread()) {
- break;
- }
- }
-
- /* This thread will be the one responsible for handling signals */
- sigemptyset(&sig_mask);
- sigaddset(&sig_mask, SIGTERM);
- sigaddset(&sig_mask, SIGINT);
- sigwait(&sig_mask, &signal_received);
- switch (signal_received) {
- case SIGTERM:
- case SIGINT:
- just_die(signal_received);
- break;
- default:
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, server_conf,
- "received impossible signal: %d", signal_received);
- just_die(SIGTERM);
- }
-}
-
-static int make_child(server_rec *s, int slot, time_t now)
-{
- int pid;
-
- if (slot + 1 > max_daemons_limit) {
- max_daemons_limit = slot + 1;
- }
-
- if (one_process) {
- set_signals();
- child_table[slot].pid = getpid();
- child_table[slot].status = SERVER_ALIVE;
- child_main(slot);
- }
-
- if ((pid = fork()) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, s,
- "fork: Unable to fork new process");
- /* In case system resources are maxxed out, we don't want
- Apache running away with the CPU trying to fork over and
- over and over again. */
- sleep(10);
-
- return -1;
- }
-
- if (!pid) {
-#ifdef AIX_BIND_PROCESSOR
- /* By default, AIX binds to a single processor. This bit unbinds
- children which will then bind to another CPU.
- */
-#include <sys/processor.h>
- int status = bindprocessor(BINDPROCESS, (int)getpid(),
- PROCESSOR_CLASS_ANY);
- if (status != OK)
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno,
- server_conf, "processor unbind failed %d", status);
-#endif
-
- RAISE_SIGSTOP(MAKE_CHILD);
-
- /* XXX - For an unthreaded server, a signal handler will be necessary
- signal(SIGTERM, just_die);
- */
- child_main(slot);
-
- return 0;
- }
- /* else */
- child_table[slot].pid = pid;
- child_table[slot].status = SERVER_ALIVE;
-
- return 0;
-}
-
-/* start up a bunch of children */
-static int startup_children(int number_to_start)
-{
- int i;
-
- for (i = 0; number_to_start && i < num_daemons; ++i) {
- if (child_table[i].status != SERVER_DEAD) {
- continue;
- }
- if (make_child(server_conf, i, 0) < 0) {
- break;
- }
- --number_to_start;
- }
- return number_to_start;
-}
-
-
-/*
- * spawn_rate is the number of children that will be spawned on the
- * next maintenance cycle if there aren't enough servers. It is
- * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by
- * without the need to spawn.
- */
-static int spawn_rate = 1;
-#ifndef MAX_SPAWN_RATE
-#define MAX_SPAWN_RATE (32)
-#endif
-static int hold_off_on_exponential_spawning;
-
-static void perform_child_maintenance(void)
-{
- int i;
- time_t now = 0;
- int free_length;
- int free_slots[MAX_SPAWN_RATE];
- int last_non_dead = -1;
-
- /* initialize the free_list */
- free_length = 0;
-
- for (i = 0; i < num_daemons; ++i) {
- if (child_table[i].status == SERVER_DEAD) {
- if (free_length < spawn_rate) {
- free_slots[free_length] = i;
- ++free_length;
- }
- }
- else {
- last_non_dead = i;
- }
-
- if (i >= max_daemons_limit && free_length >= spawn_rate) {
- break;
- }
- }
- max_daemons_limit = last_non_dead + 1;
-
- if (free_length > 0) {
- for (i = 0; i < free_length; ++i) {
- make_child(server_conf, free_slots[i], now);
- }
- /* the next time around we want to spawn twice as many if this
- * wasn't good enough, but not if we've just done a graceful
- */
- if (hold_off_on_exponential_spawning) {
- --hold_off_on_exponential_spawning;
- }
- else if (spawn_rate < MAX_SPAWN_RATE) {
- spawn_rate *= 2;
- }
- }
- else {
- spawn_rate = 1;
- }
-}
-
-static void server_main_loop(int remaining_children_to_start)
-{
- int child_slot;
- ap_wait_t status;
- int pid;
- int i;
-
- while (!restart_pending && !shutdown_pending) {
- pid = wait_or_timeout(&status);
-
- if (pid >= 0) {
- process_child_status(pid, status);
- /* non-fatal death... note that it's gone in the child table and
- * clean out the status table. */
- child_slot = -1;
- for (i = 0; i < max_daemons_limit; ++i) {
- if (child_table[i].pid == pid) {
- int j;
-
- child_slot = i;
- for (j = 0; j < HARD_THREAD_LIMIT; j++) {
- ap_dexter_force_reset_connection_status(i * HARD_THREAD_LIMIT + j);
- }
- break;
- }
- }
- if (child_slot >= 0) {
- child_table[child_slot].status = SERVER_DEAD;
-
- if (remaining_children_to_start
- && child_slot < num_daemons) {
- /* we're still doing a 1-for-1 replacement of dead
- * children with new children
- */
- make_child(server_conf, child_slot, time(NULL));
- --remaining_children_to_start;
- }
-#ifdef HAS_OTHER_CHILD
- }
- else if (reap_other_child(pid, status) == 0) {
- /* handled */
-#endif
- }
- else if (is_graceful) {
- /* Great, we've probably just lost a slot in the
- * child table. Somehow we don't know about this
- * child.
- */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno,
- server_conf,
- "long lost child came home! (pid %d)", pid);
- }
- /* Don't perform idle maintenance when a child dies,
- * only do it when there's a timeout. Remember only a
- * finite number of children can die, and it's pretty
- * pathological for a lot to die suddenly.
- */
- continue;
- }
- else if (remaining_children_to_start) {
- /* we hit a 1 second timeout in which none of the previous
- * generation of children needed to be reaped... so assume
- * they're all done, and pick up the slack if any is left.
- */
- remaining_children_to_start = \
- startup_children(remaining_children_to_start);
- /* In any event we really shouldn't do the code below because
- * few of the servers we just started are in the IDLE state
- * yet, so we'd mistakenly create an extra server.
- */
- continue;
- }
-
- perform_child_maintenance();
- }
-}
-
-static ap_status_t cleanup_fd(void *fdptr)
-{
- if (close(*((int *) fdptr)) < 0) {
- return APR_EBADF;
- }
- return APR_SUCCESS;
-}
-
-int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
-{
- int remaining_children_to_start;
- int i;
- ap_status_t rv;
-
- pconf = _pconf;
- server_conf = s;
- if (pipe(pipe_of_death) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno,
- (const server_rec*) server_conf,
- "pipe: (pipe_of_death)");
- exit(1);
- }
- ap_register_cleanup(pconf, &pipe_of_death[0], cleanup_fd, cleanup_fd);
- ap_register_cleanup(pconf, &pipe_of_death[1], cleanup_fd, cleanup_fd);
- if (fcntl(pipe_of_death[0], F_SETFD, O_NONBLOCK) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno,
- (const server_rec*) server_conf,
- "fcntl: O_NONBLOCKing (pipe_of_death)");
- exit(1);
- }
- server_conf = s;
- if ((num_listenfds = setup_listeners(server_conf)) < 1) {
- /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, errno, s,
- "no listening sockets available, shutting down");
- return 1;
- }
- ap_log_pid(pconf, ap_pid_fname);
-
- /* Initialize cross-process accept lock */
- lock_fname = ap_psprintf(_pconf, "%s.%lu",
- ap_server_root_relative(_pconf, lock_fname),
- my_pid);
- rv = SAFE_ACCEPT(ap_create_lock(&process_accept_mutex, APR_MUTEX,
- APR_CROSS_PROCESS, lock_fname, _pconf));
- if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
- "Couldn't create cross-process lock");
- return 1;
- }
-
- if (!is_graceful) {
- reinit_scoreboard(pconf);
- }
- /* Initialize the child table */
- if (!is_graceful) {
- for (i = 0; i < HARD_SERVER_LIMIT; i++) {
- child_table[i].status = SERVER_DEAD;
- }
- }
-
- set_signals();
-
- /* If we're doing a graceful_restart then we're going to see a lot
- * of children exiting immediately when we get into the main loop
- * below (because we just sent them SIGWINCH). This happens pretty
- * rapidly... and for each one that exits we'll start a new one until
- * we reach at least daemons_min_free. But we may be permitted to
- * start more than that, so we'll just keep track of how many we're
- * supposed to start up without the 1 second penalty between each fork.
- */
- remaining_children_to_start = num_daemons;
- if (!is_graceful) {
- remaining_children_to_start = \
- startup_children(remaining_children_to_start);
- }
- else {
- /* give the system some time to recover before kicking into
- * exponential mode */
- hold_off_on_exponential_spawning = 10;
- }
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, errno, server_conf,
- "%s configured -- resuming normal operations",
- ap_get_server_version());
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, errno, server_conf,
- "Server built: %s", ap_get_server_built());
- restart_pending = shutdown_pending = 0;
-
- server_main_loop(remaining_children_to_start);
-
- if (shutdown_pending) {
- /* Time to gracefully shut down:
- * Kill child processes, tell them to call child_exit, etc...
- */
- if (unixd_killpg(getpgrp(), SIGTERM) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf,
- "killpg SIGTERM");
- }
- reclaim_child_processes(1); /* Start with SIGTERM */
-
- /* cleanup pid file on normal shutdown */
- {
- const char *pidfile = NULL;
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, errno,
- server_conf,
- "removed PID file %s (pid=%ld)",
- pidfile, (long)getpid());
- }
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, errno,
- server_conf, "caught SIGTERM, shutting down");
-
- return 1;
- }
-
- /* we've been told to restart */
- signal(SIGHUP, SIG_IGN);
-
- if (one_process) {
- /* not worth thinking about */
- return 1;
- }
-
- if (is_graceful) {
- char char_of_death = '!';
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, errno, server_conf,
- "SIGWINCH received. Doing graceful restart");
-
- /* This is mostly for debugging... so that we know what is still
- * gracefully dealing with existing request.
- */
-
- for (i = 0; i < num_daemons; ++i) {
- if (child_table[i].status != SERVER_DEAD) {
- child_table[i].status = SERVER_DYING;
- }
- }
- /* give the children the signal to die */
- for (i = 0; i < num_daemons;) {
- if (write(pipe_of_death[1], &char_of_death, 1) == -1) {
- if (errno == EINTR) continue;
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf,
- "write pipe_of_death");
- }
- i++;
- }
- }
- else {
- /* Kill 'em all. Since the child acts the same on the parents SIGTERM
- * and a SIGHUP, we may as well use the same signal, because some user
- * pthreads are stealing signals from us left and right.
- */
- if (unixd_killpg(getpgrp(), SIGTERM) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf,
- "killpg SIGTERM");
- }
- reclaim_child_processes(1); /* Start with SIGTERM */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, errno,
- server_conf, "SIGHUP received. Attempting to restart");
- }
- return 0;
-}
-
-static void dexter_pre_config(ap_context_t *p, ap_context_t *plog, ap_context_t *ptemp)
-{
- static int restart_num = 0;
-
- one_process = !!getenv("ONE_PROCESS");
-
- /* sigh, want this only the second time around */
- if (restart_num++ == 1) {
- is_graceful = 0;
-
- if (!one_process) {
- unixd_detach();
- }
-
- my_pid = getpid();
- }
-
- unixd_pre_config();
- ap_listen_pre_config();
- num_daemons = DEFAULT_NUM_DAEMON;
- threads_to_start = DEFAULT_START_THREAD;
- min_spare_threads = DEFAULT_MIN_SPARE_THREAD;
- max_spare_threads = DEFAULT_MAX_SPARE_THREAD;
- max_threads = HARD_THREAD_LIMIT;
- ap_pid_fname = DEFAULT_PIDLOG;
- lock_fname = DEFAULT_LOCKFILE;
- max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
- ap_dexter_set_maintain_connection_status(1);
-
- ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
-}
-
-static void dexter_hooks(void)
-{
- ap_hook_pre_config(dexter_pre_config, NULL, NULL, HOOK_MIDDLE);
- INIT_SIGLIST()
- one_process = 0;
-}
-
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_lockfile(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- lock_fname = arg;
- return NULL;
-}
-static const char *set_num_daemons (cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- num_daemons = atoi(arg);
- if (num_daemons > HARD_SERVER_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: NumServers of %d exceeds compile time limit "
- "of %d servers,", num_daemons, HARD_SERVER_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " lowering NumServers to %d. To increase, please "
- "see the", HARD_SERVER_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " HARD_SERVER_LIMIT define in src/include/httpd.h.");
- num_daemons = HARD_SERVER_LIMIT;
- }
- else if (num_daemons < 1) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: Require NumServers > 0, setting to 1");
- num_daemons = 1;
- }
- return NULL;
-}
-
-static const char *set_threads_to_start (cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- threads_to_start = atoi(arg);
- if (threads_to_start > HARD_THREAD_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: StartThreads of %d exceeds compile time"
- "limit of %d threads,", threads_to_start,
- HARD_THREAD_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "lowering StartThreads to %d. To increase, please"
- "see the", HARD_THREAD_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "HARD_THREAD_LIMIT define in src/include/httpd.h.");
- }
- else if (threads_to_start < 1) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: Require StartThreads > 0, setting to 1");
- threads_to_start = 1;
- }
- return NULL;
-}
-
-static const char *set_min_spare_threads(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- min_spare_threads = atoi(arg);
- if (min_spare_threads <= 0) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: detected MinSpareThreads set to non-positive.");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Resetting to 1 to avoid almost certain Apache failure.");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Please read the documentation.");
- min_spare_threads = 1;
- }
-
- return NULL;
-}
-
-static const char *set_max_spare_threads(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- max_spare_threads = atoi(arg);
- if (max_spare_threads >= HARD_THREAD_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: detected MinSpareThreads set higher than");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "HARD_THREAD_LIMIT. Resetting to %d", HARD_THREAD_LIMIT);
- max_spare_threads = HARD_THREAD_LIMIT;
- }
- return NULL;
-}
-
-static const char *set_max_threads(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- max_threads = atoi(arg);
- if (max_threads > HARD_THREAD_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: detected MaxThreadsPerChild set higher than");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "HARD_THREAD_LIMIT. Resetting to %d", HARD_THREAD_LIMIT);
- max_threads = HARD_THREAD_LIMIT;
- }
- return NULL;
-}
-
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_maintain_connection_status(cmd_parms *cmd,
- core_dir_config *d, int arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_dexter_set_maintain_connection_status(arg != 0);
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
-{
- struct stat finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
- return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
-static const command_rec dexter_cmds[] = {
-UNIX_DAEMON_COMMANDS
-LISTEN_COMMANDS
-{ "PidFile", set_pidfile, NULL, RSRC_CONF, TAKE1,
- "A file for logging the server process ID"},
-{ "LockFile", set_lockfile, NULL, RSRC_CONF, TAKE1,
- "The lockfile used when Apache needs to lock the accept() call"},
-{ "NumServers", set_num_daemons, NULL, RSRC_CONF, TAKE1,
- "Number of children alive at the same time" },
-{ "StartThreads", set_threads_to_start, NULL, RSRC_CONF, TAKE1,
- "Number of threads each child creates" },
-{ "MinSpareThreads", set_min_spare_threads, NULL, RSRC_CONF, TAKE1,
- "Minimum number of idle threads per child, to handle request spikes" },
-{ "MaxSpareThreads", set_max_spare_threads, NULL, RSRC_CONF, TAKE1,
- "Maximum number of idle threads per child" },
-{ "MaxThreadsPerChild", set_max_threads, NULL, RSRC_CONF, TAKE1,
- "Maximum number of threads per child" },
-{ "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF, TAKE1,
- "Maximum number of requests a particular child serves before dying." },
-{ "ConnectionStatus", set_maintain_connection_status, NULL, RSRC_CONF, FLAG,
- "Whether or not to maintain status information on current connections"},
-{ "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1,
- "The location of the directory Apache changes to before dumping core" },
-{ NULL }
-};
-
-module MODULE_VAR_EXPORT mpm_dexter_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- dexter_cmds, /* command ap_table_t */
- NULL, /* handlers */
- dexter_hooks /* register_hooks */
-};
-
diff --git a/server/mpm/dexter/mpm_default.h b/server/mpm/dexter/mpm_default.h
deleted file mode 100644
index ed22c7d2f1..0000000000
--- a/server/mpm/dexter/mpm_default.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_MPM_DEFAULT_H
-#define APACHE_MPM_DEFAULT_H
-
-/* Number of threads to spawn off by default --- also, if fewer than
- * this free when the caretaker checks, it will spawn more.
- */
-#ifndef DEFAULT_START_THREAD
-#define DEFAULT_START_THREAD 5
-#endif
-
-/* Maximum number of *free* server threads --- more than this, and
- * they will die off.
- */
-
-#ifndef DEFAULT_MAX_SPARE_THREAD
-#define DEFAULT_MAX_SPARE_THREAD 10
-#endif
-
-/* Minimum --- fewer than this, and more will be created */
-
-#ifndef DEFAULT_MIN_SPARE_THREAD
-#define DEFAULT_MIN_SPARE_THREAD 5
-#endif
-
-/* Limit on the threads per process. Clients will be locked out if more than
- * this * HARD_SERVER_LIMIT are needed.
- *
- * We keep this for one reason 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_THREAD_LIMIT
-#define HARD_THREAD_LIMIT 64
-#endif
-
-/* Number of servers to spawn off by default
- */
-#ifndef DEFAULT_NUM_DAEMON
-#define DEFAULT_NUM_DAEMON 2
-#endif
-
-/* 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
-#define HARD_SERVER_LIMIT 8
-#endif
-
-/* File used for accept locking, when we use a file */
-#ifndef DEFAULT_LOCKFILE
-#define DEFAULT_LOCKFILE "logs/accept.lock"
-#endif
-
-/* Where the main/parent process's pid is logged */
-#ifndef DEFAULT_PIDLOG
-#define DEFAULT_PIDLOG "logs/httpd.pid"
-#endif
-
-/*
- * Interval, in microseconds, between scoreboard maintenance.
- */
-#ifndef SCOREBOARD_MAINTENANCE_INTERVAL
-#define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
-#endif
-
-/* Number of requests to try to handle in a single process. If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 10000
-#endif
-
-#endif /* AP_MPM_DEFAULT_H */
diff --git a/server/mpm/dexter/scoreboard.c b/server/mpm/dexter/scoreboard.c
deleted file mode 100644
index d80e038ae5..0000000000
--- a/server/mpm/dexter/scoreboard.c
+++ /dev/null
@@ -1,595 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "http_core.h"
-#include "http_config.h"
-#include "unixd.h"
-#include "http_conf_globals.h"
-#include "mpm_status.h"
-#include "scoreboard.h"
-#include "dexter.h" /* for max_daemons_limit */
-#include <sys/types.h>
-#ifdef USE_SHMGET_SCOREBOARD
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#endif
-
-#ifdef USE_OS2_SCOREBOARD
- /* Add MMAP style functionality to OS/2 */
-#define INCL_DOSMEMMGR
-#define INCL_DOSEXCEPTIONS
-#define INCL_DOSSEMAPHORES
-#include <os2.h>
-#include <umalloc.h>
-#include <stdio.h>
-#endif
-
-static scoreboard *ap_scoreboard_image = NULL;
-
-/*****************************************************************
- *
- * Dealing with the scoreboard... a lot of these variables are global
- * only to avoid getting clobbered by the longjmp() that happens when
- * a hard timeout expires...
- *
- * We begin with routines which deal with the file itself...
- */
-
-#if defined(USE_OS2_SCOREBOARD)
-
-/* The next two routines are used to access shared memory under OS/2. */
-/* This requires EMX v09c to be installed. */
-
-caddr_t create_shared_heap(const char *name, size_t size)
-{
- ULONG rc;
- void *mem;
- Heap_t h;
-
- rc = DosAllocSharedMem(&mem, name, size,
- PAG_COMMIT | PAG_READ | PAG_WRITE);
- if (rc != 0)
- return NULL;
- h = _ucreate(mem, size, !_BLOCK_CLEAN, _HEAP_REGULAR | _HEAP_SHARED,
- NULL, NULL);
- if (h == NULL)
- DosFreeMem(mem);
- return (caddr_t) h;
-}
-
-caddr_t get_shared_heap(const char *Name)
-{
-
- PVOID BaseAddress; /* Pointer to the base address of
- the shared memory object */
- ULONG AttributeFlags; /* Flags describing characteristics
- of the shared memory object */
- APIRET rc; /* Return code */
-
- /* Request read and write access to */
- /* the shared memory object */
- AttributeFlags = PAG_WRITE | PAG_READ;
-
- rc = DosGetNamedSharedMem(&BaseAddress, Name, AttributeFlags);
-
- if (rc != 0) {
- printf("DosGetNamedSharedMem error: return code = %ld", rc);
- return 0;
- }
-
- return BaseAddress;
-}
-
-static void setup_shared_mem(ap_context_t *p)
-{
- caddr_t m;
-
- int rc;
-
- m = (caddr_t) create_shared_heap("\\SHAREMEM\\SCOREBOARD", SCOREBOARD_SIZE);
- if (m == 0) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: Could not create OS/2 Shared memory pool.",
- ap_server_argv0);
- exit(APEXIT_INIT);
- }
-
- rc = _uopen((Heap_t) m);
- if (rc != 0) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: Could not uopen() newly created OS/2 Shared memory pool.",
- ap_server_argv0);
- }
- ap_scoreboard_image = (scoreboard *) m;
-}
-
-API_EXPORT(void) reopen_scoreboard(ap_context_t *p)
-{
- caddr_t m;
- int rc;
-
- m = (caddr_t) get_shared_heap("\\SHAREMEM\\SCOREBOARD");
- if (m == 0) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: Could not find existing OS/2 Shared memory pool.",
- ap_server_argv0);
- exit(APEXIT_INIT);
- }
-
- rc = _uopen((Heap_t) m);
- ap_scoreboard_image = (scoreboard *) m;
-}
-
-#elif defined(USE_POSIX_SCOREBOARD)
-#include <sys/mman.h>
-/*
- * POSIX 1003.4 style
- *
- * Note 1:
- * As of version 4.23A, shared memory in QNX must reside under /dev/shmem,
- * where no subdirectories allowed.
- *
- * POSIX shm_open() and shm_unlink() will take care about this issue,
- * but to avoid confusion, I suggest to redefine scoreboard file name
- * in httpd.conf to cut "logs/" from it. With default setup actual name
- * will be "/dev/shmem/logs.apache_status".
- *
- * If something went wrong and Apache did not unlinked this object upon
- * exit, you can remove it manually, using "rm -f" command.
- *
- * Note 2:
- * <sys/mman.h> in QNX defines MAP_ANON, but current implementation
- * does NOT support BSD style anonymous mapping. So, the order of
- * conditional compilation is important:
- * this #ifdef section must be ABOVE the next one (BSD style).
- *
- * I tested this stuff and it works fine for me, but if it provides
- * trouble for you, just comment out USE_MMAP_SCOREBOARD in QNX section
- * of ap_config.h
- *
- * June 5, 1997,
- * Igor N. Kovalenko -- infoh@mail.wplus.net
- */
-
-static void cleanup_shared_mem(void *d)
-{
- shm_unlink(ap_scoreboard_fname);
-}
-
-static void setup_shared_mem(ap_context_t *p)
-{
- char buf[512];
- caddr_t m;
- int fd;
-
- fd = shm_open(ap_scoreboard_fname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
- if (fd == -1) {
- ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
- ap_server_argv0);
- perror(buf);
- exit(APEXIT_INIT);
- }
- if (ltrunc(fd, (off_t) SCOREBOARD_SIZE, SEEK_SET) == -1) {
- ap_snprintf(buf, sizeof(buf), "%s: could not ltrunc scoreboard",
- ap_server_argv0);
- perror(buf);
- shm_unlink(ap_scoreboard_fname);
- exit(APEXIT_INIT);
- }
- if ((m = (caddr_t) mmap((caddr_t) 0,
- (size_t) SCOREBOARD_SIZE, PROT_READ | PROT_WRITE,
- MAP_SHARED, fd, (off_t) 0)) == (caddr_t) - 1) {
- ap_snprintf(buf, sizeof(buf), "%s: cannot mmap scoreboard",
- ap_server_argv0);
- perror(buf);
- shm_unlink(ap_scoreboard_fname);
- exit(APEXIT_INIT);
- }
- close(fd);
- ap_register_cleanup(p, NULL, cleanup_shared_mem, ap_null_cleanup);
- ap_scoreboard_image = (scoreboard *) m;
-}
-
-API_EXPORT(void) reopen_scoreboard(ap_context_t *p)
-{
-}
-
-#elif defined(USE_MMAP_SCOREBOARD)
-
-static void setup_shared_mem(ap_context_t *p)
-{
- caddr_t m;
-
-#if defined(MAP_ANON)
-/* BSD style */
-#ifdef CONVEXOS11
- /*
- * 9-Aug-97 - Jeff Venters (venters@convex.hp.com)
- * ConvexOS maps address space as follows:
- * 0x00000000 - 0x7fffffff : Kernel
- * 0x80000000 - 0xffffffff : User
- * Start mmapped area 1GB above start of text.
- *
- * Also, the length requires a pointer as the actual length is
- * returned (rounded up to a page boundary).
- */
- {
- unsigned len = SCOREBOARD_SIZE;
-
- m = mmap((caddr_t) 0xC0000000, &len,
- PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, NOFD, 0);
- }
-#elif defined(MAP_TMPFILE)
- {
- char mfile[] = "/tmp/apache_shmem_XXXX";
- int fd = mkstemp(mfile);
- if (fd == -1) {
- perror("open");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: Could not open %s", ap_server_argv0, mfile);
- exit(APEXIT_INIT);
- }
- m = mmap((caddr_t) 0, SCOREBOARD_SIZE,
- PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (m == (caddr_t) - 1) {
- perror("mmap");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: Could not mmap %s", ap_server_argv0, mfile);
- exit(APEXIT_INIT);
- }
- close(fd);
- unlink(mfile);
- }
-#else
- m = mmap((caddr_t) 0, SCOREBOARD_SIZE,
- PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0);
-#endif
- if (m == (caddr_t) - 1) {
- perror("mmap");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: Could not mmap memory", ap_server_argv0);
- exit(APEXIT_INIT);
- }
-#else
-/* Sun style */
- int fd;
-
- fd = open("/dev/zero", O_RDWR);
- if (fd == -1) {
- perror("open");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: Could not open /dev/zero", ap_server_argv0);
- exit(APEXIT_INIT);
- }
- m = mmap((caddr_t) 0, SCOREBOARD_SIZE,
- PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (m == (caddr_t) - 1) {
- perror("mmap");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: Could not mmap /dev/zero", ap_server_argv0);
- exit(APEXIT_INIT);
- }
- close(fd);
-#endif
- ap_scoreboard_image = (scoreboard *) m;
-}
-
-API_EXPORT(void) reopen_scoreboard(ap_context_t *p)
-{
-}
-
-#elif defined(USE_SHMGET_SCOREBOARD)
-static key_t shmkey = IPC_PRIVATE;
-static int shmid = -1;
-
-static void setup_shared_mem(ap_context_t *p)
-{
- struct shmid_ds shmbuf;
- const server_rec * server_conf = ap_get_server_conf();
-#ifdef MOVEBREAK
- char *obrk;
-#endif
-
- if ((shmid = shmget(shmkey, SCOREBOARD_SIZE, IPC_CREAT | SHM_R | SHM_W)) == -1) {
-#ifdef LINUX
- if (errno == ENOSYS) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, errno,
- server_conf,
- "Your kernel was built without CONFIG_SYSVIPC\n"
- "%s: Please consult the Apache FAQ for details",
- ap_server_argv0);
- }
-#endif
- ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
- "could not call shmget");
- exit(APEXIT_INIT);
- }
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, errno, server_conf,
- "created shared memory segment #%d", shmid);
-
-#ifdef MOVEBREAK
- /*
- * Some SysV systems place the shared segment WAY too close
- * to the dynamic memory break point (sbrk(0)). This severely
- * limits the use of malloc/sbrk in the program since sbrk will
- * refuse to move past that point.
- *
- * To get around this, we move the break point "way up there",
- * attach the segment and then move break back down. Ugly
- */
- if ((obrk = sbrk(MOVEBREAK)) == (char *) -1) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf,
- "sbrk() could not move break");
- }
-#endif
-
-#define BADSHMAT ((scoreboard *)(-1))
- if ((ap_scoreboard_image = (scoreboard *) shmat(shmid, 0, 0)) == BADSHMAT) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
- "shmat error");
- /*
- * We exit below, after we try to remove the segment
- */
- }
- else { /* only worry about permissions if we attached the segment */
- if (shmctl(shmid, IPC_STAT, &shmbuf) != 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf,
- "shmctl() could not stat segment #%d", shmid);
- }
- else {
- shmbuf.shm_perm.uid = unixd_config.user_id;
- shmbuf.shm_perm.gid = unixd_config.group_id;
- if (shmctl(shmid, IPC_SET, &shmbuf) != 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf,
- "shmctl() could not set segment #%d", shmid);
- }
- }
- }
- /*
- * We must avoid leaving segments in the kernel's
- * (small) tables.
- */
- if (shmctl(shmid, IPC_RMID, NULL) != 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf,
- "shmctl: IPC_RMID: could not remove shared memory segment #%d",
- shmid);
- }
- if (ap_scoreboard_image == BADSHMAT) /* now bailout */
- exit(APEXIT_INIT);
-
-#ifdef MOVEBREAK
- if (obrk == (char *) -1)
- return; /* nothing else to do */
- if (sbrk(-(MOVEBREAK)) == (char *) -1) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf,
- "sbrk() could not move break back");
- }
-#endif
-}
-
-API_EXPORT(void) reopen_scoreboard(ap_context_t *p)
-{
-}
-
-#endif
-
-/* Called by parent process */
-void reinit_scoreboard(ap_context_t *p)
-{
- if (ap_scoreboard_image == NULL) {
- setup_shared_mem(p);
- }
- memset(ap_scoreboard_image, 0, SCOREBOARD_SIZE);
-}
-
-/****
- * Above code is shmem code. Below code is interacting with the shmem
- ****/
-
-static int maintain_connection_status = 1;
-
-void ap_dexter_set_maintain_connection_status(int flag) {
- maintain_connection_status = flag;
- return;
-}
-
-/* Useful to erase the status of children that might be from previous
- * generations */
-void ap_dexter_force_reset_connection_status(long conn_id)
-{
- int i;
-
- for (i = 0; i < STATUSES_PER_CONNECTION; i++) {
- ap_scoreboard_image->table[conn_id][i].key[0] = '\0';
- }
-}
-
-void ap_reset_connection_status(long conn_id)
-{
- if (maintain_connection_status) {
- ap_dexter_force_reset_connection_status(conn_id);
- }
-}
-
-/* Don't mess with the string you get back from this function */
-const char *ap_get_connection_status(long conn_id, const char *key)
-{
- int i = 0;
- status_table_entry *ss;
-
- if (!maintain_connection_status) return "";
- while (i < STATUSES_PER_CONNECTION) {
- ss = &(ap_scoreboard_image->table[conn_id][i]);
- if (ss->key[0] == '\0') {
- break;
- }
- if (0 == strcmp(ss->key, key)) {
- return ss->value;
- }
- }
-
- return NULL;
-}
-
-ap_array_header_t *ap_get_connections(ap_context_t *p)
-{
- int i;
- ap_array_header_t *connection_list;
- long *array_slot;
-
- connection_list = ap_make_array(p, 0, sizeof(long));
- /* We assume that there is a connection iff it has an entry in the status
- * table. Connections without any status sound problematic to me, so this
- * is probably for the best. - manoj */
- for (i = 0; i < max_daemons_limit*HARD_THREAD_LIMIT; i++) {
- if (ap_scoreboard_image->table[i][0].key[0] != '\0') {
- array_slot = ap_push_array(connection_list);
- *array_slot = i;
- }
- }
- return connection_list;
-}
-
-ap_array_header_t *ap_get_connection_keys(ap_context_t *p, long conn_id)
-{
- int i = 0;
- status_table_entry *ss;
- ap_array_header_t *key_list;
- char **array_slot;
-
- key_list = ap_make_array(p, 0, KEY_LENGTH * sizeof(char));
- while (i < STATUSES_PER_CONNECTION) {
- ss = &(ap_scoreboard_image->table[conn_id][i]);
- if (ss->key[0] == '\0') {
- break;
- }
- array_slot = ap_push_array(key_list);
- *array_slot = ap_pstrdup(p, ss->key);
- i++;
- }
- return key_list;
-}
-
-/* Note: no effort is made here to prevent multiple threads from messing with
- * a single connection at the same time. ap_update_connection_status should
- * only be called by the thread that owns the connection */
-
-void ap_update_connection_status(long conn_id, const char *key,
- const char *value)
-{
- int i = 0;
- status_table_entry *ss;
-
- if (!maintain_connection_status) return;
- while (i < STATUSES_PER_CONNECTION) {
- ss = &(ap_scoreboard_image->table[conn_id][i]);
- if (ss->key[0] == '\0') {
- break;
- }
- if (0 == strcmp(ss->key, key)) {
- ap_cpystrn(ss->value, value, VALUE_LENGTH);
- return;
- }
- i++;
- }
- /* Not found. Add an entry for this value */
- if (i >= STATUSES_PER_CONNECTION) {
- /* No room. Oh well, not much anyone can do about it. */
- return;
- }
- ap_cpystrn(ss->key, key, KEY_LENGTH);
- ap_cpystrn(ss->value, value, VALUE_LENGTH);
- return;
-}
-
-ap_array_header_t *ap_get_status_table(ap_context_t *p)
-{
- int i, j;
- ap_array_header_t *server_status;
- ap_status_table_row_t *array_slot;
- status_table_entry *ss;
-
- server_status = ap_make_array(p, 0, sizeof(ap_status_table_row_t));
-
- /* Go ahead and return what's in the connection status table even if we
- * aren't maintaining it. We can at least look at what children from
- * previous generations are up to. */
-
- for (i = 0; i < max_daemons_limit*HARD_THREAD_LIMIT; i++) {
- if (ap_scoreboard_image->table[i][0].key[0] == '\0')
- continue;
- array_slot = ap_push_array(server_status);
- array_slot->data = ap_make_table(p, 0);
- array_slot->conn_id = i;
-
- for (j = 0; j < STATUSES_PER_CONNECTION; j++) {
- ss = &(ap_scoreboard_image->table[i][j]);
- if (ss->key[0] != '\0') {
- ap_table_add(array_slot->data, ss->key, ss->value);
- }
- else {
- break;
- }
- }
- }
- return server_status;
-}
diff --git a/server/mpm/dexter/scoreboard.h b/server/mpm/dexter/scoreboard.h
deleted file mode 100644
index b5dd259026..0000000000
--- a/server/mpm/dexter/scoreboard.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_SCOREBOARD_H
-#define APACHE_SCOREBOARD_H
-#include <pthread.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef TPF
-#include <time.h>
-#else
-#include <sys/times.h>
-#endif /* TPF */
-
-#include "mpm_default.h" /* For HARD_.*_LIMIT */
-
-/* The generic shared memory chunk code */
-void reinit_scoreboard(ap_context_t *p);
-#if defined(USE_OS2_SCOREBOARD)
-caddr_t create_shared_heap(const char *name, size_t size);
-caddr_t get_shared_heap(const char *Name);
-#endif
-
-API_EXPORT(void) reopen_scoreboard(ap_context_t *p);
-
-/* The stuff for Dexter's status table */
-
-#include "mpm_status.h"
-
-void ap_dexter_set_maintain_connection_status(int flag);
-void ap_dexter_force_reset_connection_status(long conn_id);
-#define KEY_LENGTH 16
-#define VALUE_LENGTH 64
-typedef struct {
- char key[KEY_LENGTH];
- char value[VALUE_LENGTH];
-} status_table_entry;
-
-#define STATUSES_PER_CONNECTION 10
-
-typedef struct {
- status_table_entry
- table[HARD_SERVER_LIMIT*HARD_THREAD_LIMIT][STATUSES_PER_CONNECTION];
-} scoreboard;
-
-#define SCOREBOARD_SIZE sizeof(scoreboard)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_SCOREBOARD_H */
diff --git a/server/mpm/mpmt_beos/Makefile.in b/server/mpm/mpmt_beos/Makefile.in
deleted file mode 100644
index 0abb81eb62..0000000000
--- a/server/mpm/mpmt_beos/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-
-DEPTH = ../../..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-LTLIBRARY_NAME = libmpmt_beos.la
-LTLIBRARY_SOURCES = mpmt_beos.c scoreboard.c acceptlock.c mutex.c poll.c
-
-include $(topsrcdir)/build/ltlib.mk
diff --git a/server/mpm/mpmt_beos/Makefile.libdir b/server/mpm/mpmt_beos/Makefile.libdir
deleted file mode 100644
index 7b5254013a..0000000000
--- a/server/mpm/mpmt_beos/Makefile.libdir
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a place-holder which indicates to Configure that it shouldn't
-provide the default targets when building the Makefile in this directory.
-Instead it'll just prepend all the important variable definitions, and
-copy the Makefile.tmpl onto the end.
diff --git a/server/mpm/mpmt_beos/config.m4 b/server/mpm/mpmt_beos/config.m4
deleted file mode 100644
index c71adcb40c..0000000000
--- a/server/mpm/mpmt_beos/config.m4
+++ /dev/null
@@ -1,8 +0,0 @@
-dnl ## XXX - Need a more thorough check of the proper flags to use
-
-if test "$MPM_NAME" = "mpmt_beos" ; then
- ac_cv_enable_threads="yes"
- AC_CACHE_SAVE
-
- APACHE_FAST_OUTPUT(modules/mpm/$MPM_NAME/Makefile)
-fi
diff --git a/server/mpm/mpmt_beos/mpm_default.h b/server/mpm/mpmt_beos/mpm_default.h
deleted file mode 100644
index 02a4b2459f..0000000000
--- a/server/mpm/mpmt_beos/mpm_default.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_MPM_DEFAULT_H
-#define APACHE_MPM_DEFAULT_H
-
-/* Number of servers to spawn off by default --- also, if fewer than
- * this free when the caretaker checks, it will spawn more.
- */
-#ifndef DEFAULT_START_DAEMON
-#define DEFAULT_START_DAEMON 5
-#endif
-
-/* Maximum number of *free* server processes --- more than this, and
- * they will die off.
- */
-
-#ifndef DEFAULT_MAX_FREE_DAEMON
-#define DEFAULT_MAX_FREE_DAEMON 10
-#endif
-
-/* Minimum --- fewer than this, and more will be created */
-
-#ifndef DEFAULT_MIN_FREE_DAEMON
-#define DEFAULT_MIN_FREE_DAEMON 5
-#endif
-
-/* 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.
- */
-#ifdef NO_THREADS
-#define HARD_SERVER_LIMIT 256
-#endif
-#ifndef HARD_SERVER_LIMIT
-#define HARD_SERVER_LIMIT 8
-#endif
-
-/* Limit on the threads per process. Clients will be locked out if more than
- * this * HARD_SERVER_LIMIT are needed.
- *
- * We keep this for one reason it keeps the size of the scoreboard file small
- * enough that we can read the whole thing without worrying too much about
- * the overhead.
- */
-#ifdef NO_THREADS
-#define HARD_THREAD_LIMIT 1
-#endif
-#ifndef HARD_THREAD_LIMIT
-#define HARD_THREAD_LIMIT 64
-#endif
-
-#ifdef NO_THREADS
-#define DEFAULT_THREADS_PER_CHILD 1
-#endif
-#ifndef DEFAULT_THREADS_PER_CHILD
-#define DEFAULT_THREADS_PER_CHILD 10
-#endif
-
-/* Where the main/parent process's pid is logged */
-#ifndef DEFAULT_PIDLOG
-#define DEFAULT_PIDLOG "logs/httpd.pid"
-#endif
-
-/*
- * Interval, in microseconds, between scoreboard maintenance.
- */
-#ifndef SCOREBOARD_MAINTENANCE_INTERVAL
-#define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
-#endif
-
-/* Number of requests to try to handle in a single process. If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 10000
-#endif
-
-#endif /* AP_MPM_DEFAULT_H */
diff --git a/server/mpm/mpmt_beos/mpmt_beos.c b/server/mpm/mpmt_beos/mpmt_beos.c
deleted file mode 100644
index ea1ab5d870..0000000000
--- a/server/mpm/mpmt_beos/mpmt_beos.c
+++ /dev/null
@@ -1,1430 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/* This module is effectivly mpmt_pthread much modified to
- * allow it work on BeOS. It's stable and works OK.
- */
-
-#define CORE_PRIVATE
-
-#include "apr_portable.h"
-#include "httpd.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "http_config.h" /* for read_config */
-#include "http_core.h" /* for get_remote_host */
-#include "http_connection.h"
-#include "ap_mpm.h"
-#include "beosd.h"
-#include "iol_socket.h"
-#include "ap_listen.h"
-#include "scoreboard.h"
-#include "acceptlock.h"
-#include "mutex.h"
-#include "poll.h"
-
-/*
- * Actual definitions of config globals
- */
-
-int ap_threads_per_child=0; /* Worker threads per child */
-int ap_max_requests_per_child=0;
-static char *ap_pid_fname=NULL;
-static char *ap_scoreboard_fname=NULL;
-static int ap_daemons_to_start=0;
-static int min_spare_threads=0;
-static int max_spare_threads=0;
-static int ap_daemons_limit=0;
-static time_t ap_restart_time=0;
-API_VAR_EXPORT int ap_extended_status = 0;
-static int workers_may_exit = 0;
-static int requests_this_child;
-static int num_listenfds = 0;
-static struct pollfd *listenfds;
-
-/* The structure used to pass unique initialization info to each thread */
-typedef struct {
- int pid;
- thread_id tid;
- int sd;
- ap_context_t *tpool; /* "pthread" would be confusing */
-} proc_info;
-
-#define SERVER_DEAD 0
-#define SERVER_DYING 1
-#define SERVER_ALIVE 2
-
-static struct {
- pid_t pid;
- unsigned char status;
-} child_table[HARD_SERVER_LIMIT];
-
-#if 0
-#define SAFE_ACCEPT(stmt) do {if (ap_listeners->next != NULL) {stmt;}} while (0)
-#else
-#define SAFE_ACCEPT(stmt) do {stmt;} while (0)
-#endif
-
-/*
- * The max child slot ever assigned, preserved across restarts. Necessary
- * to deal with MaxClients changes across SIGWINCH restarts. We use this
- * value to optimize routines that have to scan the entire scoreboard.
- */
-int max_daemons_limit = -1;
-static char ap_coredump_dir[MAX_STRING_LEN];
-port_id port_of_death;
-
-/* *Non*-shared http_main globals... */
-
-static server_rec *server_conf;
-
-/* one_process --- debugging mode variable; can be set from the command line
- * with the -X flag. If set, this gets you the child_main loop running
- * in the process which originally started up (no detach, no make_child),
- * which is a pretty nice debugging environment. (You'll get a SIGHUP
- * early in standalone_main; just continue through. This is the server
- * trying to kill off any child processes which it might have lying
- * around --- Apache doesn't keep track of their pids, it just sends
- * SIGHUP to the process group, ignoring it in the root process.
- * Continue through and you'll be fine.).
- */
-
-static int one_process = 0;
-
-#ifdef DEBUG_SIGSTOP
-int raise_sigstop_flags;
-#endif
-
-#ifdef HAS_OTHER_CHILD
-/* used to maintain list of children which aren't part of the scoreboard */
-typedef struct other_child_rec other_child_rec;
-struct other_child_rec {
- other_child_rec *next;
- int pid;
- void (*maintenance) (int, void *, ap_wait_t);
- void *data;
- int write_fd;
-};
-static other_child_rec *other_children;
-#endif
-
-static ap_context_t *pconf; /* Pool for config stuff */
-static ap_context_t *pchild; /* Pool for httpd child stuff */
-
-static int my_pid; /* Linux getpid() doesn't work except in main thread. Use
- this instead */
-/* Keep track of the number of worker threads currently active */
-static int worker_thread_count;
-static be_mutex_t worker_thread_count_mutex;
-
-/* Global, alas, so http_core can talk to us */
-enum server_token_type ap_server_tokens = SrvTk_FULL;
-
-API_EXPORT(const server_rec *) ap_get_server_conf(void)
-{
- return (server_conf);
-}
-
-API_EXPORT(int) ap_get_max_daemons(void)
-{
- return max_daemons_limit;
-}
-
-/* a clean exit from a child with proper cleanup
- static void clean_child_exit(int code) __attribute__ ((noreturn)); */
-void clean_child_exit(int code)
-{
- if (pchild) {
- ap_destroy_pool(pchild);
- }
- exit(code);
-}
-
-/*****************************************************************
- * dealing with other children
- */
-
-#ifdef HAS_OTHER_CHILD
-API_EXPORT(void) ap_register_other_child(int pid,
- void (*maintenance) (int reason, void *, ap_wait_t status),
- void *data, int write_fd)
-{
- other_child_rec *ocr;
-
- ocr = ap_palloc(pconf, sizeof(*ocr));
- ocr->pid = pid;
- ocr->maintenance = maintenance;
- ocr->data = data;
- ocr->write_fd = write_fd;
- ocr->next = other_children;
- other_children = ocr;
-}
-
-/* note that 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.
- */
-API_EXPORT(void) ap_unregister_other_child(void *data)
-{
- other_child_rec **pocr, *nocr;
-
- for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
- if ((*pocr)->data == data) {
- nocr = (*pocr)->next;
- (*(*pocr)->maintenance) (OC_REASON_UNREGISTER, (*pocr)->data, -1);
- *pocr = nocr;
- /* XXX: um, well we've just wasted some space in pconf ? */
- return;
- }
- }
-}
-
-/* test to ensure that the write_fds are all still writable, otherwise
- * invoke the maintenance functions as appropriate */
-static void probe_writable_fds(void)
-{
- return;
-#if 0
- fd_set writable_fds;
- int fd_max;
- other_child_rec *ocr, *nocr;
- struct timeval tv;
- int rc;
-
- if (other_children == NULL)
- return;
-
- fd_max = 0;
- FD_ZERO(&writable_fds);
- do {
- for (ocr = other_children; ocr; ocr = ocr->next) {
- if (ocr->write_fd == -1)
- continue;
- FD_SET(ocr->write_fd, &writable_fds);
- if (ocr->write_fd > fd_max) {
- fd_max = ocr->write_fd;
- }
- }
- if (fd_max == 0)
- return;
-
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
- } while (rc == -1 && errno == EINTR);
-
- if (rc == -1) {
- /* XXX: uhh this could be really bad, we could have a bad file
- * descriptor due to a bug in one of the maintenance routines */
- ap_log_unixerr("probe_writable_fds", "select",
- "could not probe writable fds", server_conf);
- return;
- }
- if (rc == 0)
- return;
-
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->write_fd == -1)
- continue;
- if (FD_ISSET(ocr->write_fd, &writable_fds))
- continue;
- (*ocr->maintenance) (OC_REASON_UNWRITABLE, ocr->data, -1);
- }
-#endif
-}
-
-/* possibly reap an other_child, return 0 if yes, -1 if not */
-static int reap_other_child(int pid, ap_wait_t status)
-{
- other_child_rec *ocr, *nocr;
-
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->pid != pid)
- continue;
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
- return 0;
- }
- return -1;
-}
-#endif
-
-static void reclaim_child_processes(int terminate)
-{
- int i, status;
- long int waittime = 1024 * 16; /* in usecs */
- struct timeval tv;
- int waitret, tries;
- int not_dead_yet;
-#ifdef HAS_OTHER_CHILD
- other_child_rec *ocr, *nocr;
-#endif
-
- for (tries = terminate ? 4 : 1; tries <= 9; ++tries) {
- /* don't want to hold up progress any more than
- * necessary, but we need to allow children a few moments to exit.
- * Set delay with an exponential backoff.
- */
- tv.tv_sec = waittime / 1000000;
- tv.tv_usec = waittime % 1000000;
- waittime = waittime * 4;
- ap_select(0, NULL, NULL, NULL, &tv);
-
- /* now see who is done */
- not_dead_yet = 0;
- for (i = 0; i < max_daemons_limit; ++i) {
- int pid;
- if (child_table[i].status == SERVER_DEAD)
- continue;
-
- pid = child_table[i].pid;
-
- waitret = waitpid(pid, &status, WNOHANG);
- if (waitret == pid || waitret == -1) {
- child_table[i].status = SERVER_DEAD;
- continue;
- }
- ++not_dead_yet;
- switch (tries) {
- case 1: /* 16ms */
- case 2: /* 82ms */
- break;
- case 3: /* 344ms */
- case 4: /* 16ms */
- case 5: /* 82ms */
- case 6: /* 344ms */
- case 7: /* 1.4sec */
- /* ok, now it's being annoying */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
- errno, server_conf,
- "child process %d still did not exit, sending a SIGTERM",
- pid);
- kill(pid, SIGTERM);
- break;
- case 8: /* 6 sec */
- /* die child scum */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, errno, server_conf,
- "child process %d still did not exit, sending a SIGKILL",
- pid);
- kill(pid, SIGKILL);
- break;
- case 9: /* 14 sec */
- /* gave it our best shot, but alas... If this really
- * is a child we are trying to kill and it really hasn't
- * exited, we will likely fail to bind to the port
- * after the restart.
- */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, errno, server_conf,
- "could not make child process %d exit, "
- "attempting to continue anyway", pid);
- break;
- }
- }
-#ifdef HAS_OTHER_CHILD
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->pid == -1)
- continue;
-
- waitret = waitpid(ocr->pid, &status, WNOHANG);
- if (waitret == ocr->pid) {
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
- }
- else if (waitret == 0) {
- (*ocr->maintenance) (OC_REASON_RESTART, ocr->data, -1);
- ++not_dead_yet;
- }
- else if (waitret == -1) {
- /* uh what the heck? they didn't call unregister? */
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_LOST, ocr->data, -1);
- }
- }
-#endif
- if (!not_dead_yet) {
- /* nothing left to wait for */
- break;
- }
- }
-}
-
-/* Finally, this routine is used by the caretaker process to wait for
- * a while...
- */
-
-/* number of calls to wait_or_timeout between writable probes */
-#ifndef INTERVAL_OF_WRITABLE_PROBES
-#define INTERVAL_OF_WRITABLE_PROBES 10
-#endif
-static int wait_or_timeout_counter;
-
-static int wait_or_timeout(ap_wait_t *status)
-{
- struct timeval tv;
- int ret;
-
- ++wait_or_timeout_counter;
- if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
- wait_or_timeout_counter = 0;
-#ifdef HAS_OTHER_CHILD
- probe_writable_fds();
-#endif
- }
- ret = waitpid(-1, status, WNOHANG);
- if (ret == -1 && errno == EINTR) {
- return -1;
- }
- if (ret > 0) {
- return ret;
- }
- tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000;
- tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000;
- ap_select(0, NULL, NULL, NULL, &tv);
- return -1;
-}
-
-/* handle all varieties of core dumping signals */
-static void sig_coredump(int sig)
-{
- chdir(ap_coredump_dir);
- signal(sig, SIG_DFL);
- kill(my_pid, sig);
- /* At this point we've got sig blocked, because we're still inside
- * the signal handler. When we leave the signal handler it will
- * be unblocked, and we'll take the signal... and coredump or whatever
- * is appropriate for this particular Unix. In addition the parent
- * will see the real signal we received -- whereas if we called
- * abort() here, the parent would only see SIGABRT.
- */
-}
-
-static void just_die(int sig)
-{
- clean_child_exit(0);
-}
-
-/*****************************************************************
- * Connection structures and accounting...
- */
-
-/* volatile just in case */
-static int volatile shutdown_pending;
-static int volatile restart_pending;
-static int volatile is_graceful;
-
-/*
- * ap_start_shutdown() and ap_start_restart(), below, are a first stab at
- * functions to initiate shutdown or restart without relying on signals.
- * Previously this was initiated in sig_term() and restart() signal handlers,
- * but we want to be able to start a shutdown/restart from other sources --
- * e.g. on Win32, from the service manager. Now the service manager can
- * call ap_start_shutdown() or ap_start_restart() as appropiate. Note that
- * these functions can also be called by the child processes, since global
- * variables are no longer used to pass on the required action to the parent.
- *
- * These should only be called from the parent process itself, since the
- * parent process will use the shutdown_pending and restart_pending variables
- * to determine whether to shutdown or restart. The child process should
- * call signal_parent() directly to tell the parent to die -- this will
- * cause neither of those variable to be set, which the parent will
- * assume means something serious is wrong (which it will be, for the
- * child to force an exit) and so do an exit anyway.
- */
-
-void ap_start_shutdown(void)
-{
- if (shutdown_pending == 1) {
- /* Um, is this _probably_ not an error, if the user has
- * tried to do a shutdown twice quickly, so we won't
- * worry about reporting it.
- */
- return;
- }
- shutdown_pending = 1;
-}
-
-/* do a graceful restart if graceful == 1 */
-void ap_start_restart(int graceful)
-{
-
- if (restart_pending == 1) {
- /* Probably not an error - don't bother reporting it */
- return;
- }
- restart_pending = 1;
- is_graceful = graceful;
-}
-
-static void sig_term(int sig)
-{
- ap_start_shutdown();
-}
-
-static void restart(int sig)
-{
- ap_start_restart(sig == SIGWINCH);
-}
-
-static void set_signals(void)
-{
- struct sigaction sa;
-
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
-
- if (!one_process) {
- sa.sa_handler = sig_coredump;
-
- if (sigaction(SIGSEGV, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGSEGV)");
- if (sigaction(SIGBUS, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGBUS)");
- if (sigaction(SIGABRT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABRT)");
- if (sigaction(SIGILL, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGILL)");
- sa.sa_flags = 0;
- }
- sa.sa_handler = sig_term;
- if (sigaction(SIGTERM, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGTERM)");
- if (sigaction(SIGINT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGINT)");
-
- sa.sa_handler = SIG_IGN;
- if (sigaction(SIGPIPE, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGPIPE)");
-
- /* we want to ignore HUPs and WINCH while we're busy processing one */
- sigaddset(&sa.sa_mask, SIGHUP);
- sigaddset(&sa.sa_mask, SIGWINCH);
- sa.sa_handler = restart;
- if (sigaction(SIGHUP, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGHUP)");
- if (sigaction(SIGWINCH, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGWINCH)");
-}
-
-static void process_child_status(int pid, ap_wait_t status)
-{
- /* Child died... if it died due to a fatal error,
- * we should simply bail out.
- */
- if ((WIFEXITED(status)) &&
- WEXITSTATUS(status) == APEXIT_CHILDFATAL) {
- ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, errno, server_conf,
- "Child %d returned a Fatal error... \n"
- "Apache is exiting!",
- pid);
- exit(APEXIT_CHILDFATAL);
- }
- if (WIFSIGNALED(status)) {
- switch (WTERMSIG(status)) {
- case SIGTERM:
- case SIGHUP:
- case SIGUSR1:
- case SIGKILL:
- break;
- default:
-#ifdef SYS_SIGLIST
-#ifdef WCOREDUMP
- if (WCOREDUMP(status)) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
- errno, server_conf,
- "child pid %d exit signal %s (%d), "
- "possible coredump in %s",
- pid, (WTERMSIG(status) >= NumSIG) ? "" :
- SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status),
- ap_coredump_dir);
- }
- else {
-#endif
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
- errno, server_conf,
- "child pid %d exit signal %s (%d)", pid,
- SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status));
-#ifdef WCOREDUMP
- }
-#endif
-#else
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
- errno, server_conf,
- "child pid %d exit signal %d",
- pid, WTERMSIG(status));
-#endif
- }
- }
-}
-
-static int setup_listeners(server_rec *s)
-{
- ap_listen_rec *lr;
- int num_listeners = 0;
- if (ap_listen_open(s->process, s->port)) {
- return 0;
- }
- for (lr = ap_listeners; lr; lr = lr->next) {
- num_listeners++;
- }
- return num_listeners;
-}
-
-/*****************************************************************
- * Here follows a long bunch of generic server bookkeeping stuff...
- */
-
-#define sock_disable_nagle(s) /* NOOP */
-
-int ap_graceful_stop_signalled(void)
-{
- /* XXX - Does this really work? - Manoj */
- return is_graceful;
-}
-
-/*****************************************************************
- * Child process main loop.
- */
-
-static void process_socket(ap_context_t *p, ap_socket_t *sock, int my_child_num, int my_thread_num)
-{
- BUFF *conn_io;
- conn_rec *current_conn;
- ap_iol *iol;
- long conn_id = my_child_num * HARD_THREAD_LIMIT + my_thread_num;
- int csd;
-
- iol = beos_attach_socket(sock);
- if (iol == NULL) {
- if (errno == EBADF) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno, NULL,
- "filedescriptor (%u) larger than FD_SETSIZE (%u) "
- "found, you probably need to rebuild Apache with a "
- "larger FD_SETSIZE", csd, FD_SETSIZE);
- }
- else {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL,
- "error attaching to socket");
- }
- ap_close_socket(sock);
- return;
- }
-
- conn_io = ap_bcreate(p, B_RDWR);
- ap_bpush_iol(conn_io, iol);
-
- current_conn = ap_new_apr_connection(p, server_conf, conn_io, sock,
- conn_id);
-
- ap_process_connection(current_conn);
-}
-
-static int32 worker_thread(void * dummy)
-{
- proc_info * ti = dummy;
- int process_slot = ti->pid;
- int thread_slot = ti->tid;
- ap_context_t *tpool = ti->tpool;
- struct sockaddr sa_client;
- ap_socket_t *csd = NULL;
- ap_context_t *ptrans; /* Pool for per-transaction stuff */
- ap_socket_t *sd = NULL;
- int srv;
- int curr_pollfd, last_pollfd = 0;
- int thesock;
- sigset_t sig_mask;
-
- free(ti);
-
- /* block the signals for this thread */
- sigfillset(&sig_mask);
- sigprocmask(SIG_BLOCK, &sig_mask, NULL);
-
- ap_create_context(&ptrans, tpool);
-
- be_mutex_lock(&worker_thread_count_mutex);
- worker_thread_count++;
- be_mutex_unlock(&worker_thread_count_mutex);
-
- /* TODO: Switch to a system where threads reuse the results from earlier
- poll calls - manoj */
- while (!workers_may_exit) {
- workers_may_exit |= (ap_max_requests_per_child != 0) && (requests_this_child <= 0);
- if (workers_may_exit) break;
-
- SAFE_ACCEPT(intra_mutex_on(0));
- if (workers_may_exit) {
- SAFE_ACCEPT(intra_mutex_off(0));
- break;
- }
- SAFE_ACCEPT(accept_mutex_on(0));
- while (!workers_may_exit) {
- srv = poll(listenfds, num_listenfds + 1, -1);
- if (srv < 0) {
- if (errno == EINTR) {
- continue;
- }
-
- /* poll() will only return errors in catastrophic
- * circumstances. Let's try exiting gracefully, for now. */
- ap_log_error(APLOG_MARK, APLOG_ERR,errno, (const server_rec *)
- ap_get_server_conf(), "poll: (listen)");
- workers_may_exit = 1;
- }
-
- if (workers_may_exit) break;
-
- if (num_listenfds == 1) {
- sd = ap_listeners->sd;
- goto got_fd;
- }
- else {
- /* find a listener */
- curr_pollfd = last_pollfd;
- do {
- curr_pollfd++;
- if (curr_pollfd > num_listenfds) {
- curr_pollfd = 1;
- }
- /* XXX: Should we check for POLLERR? */
- if (listenfds[curr_pollfd].revents & POLLIN) {
- last_pollfd = curr_pollfd;
- ap_put_os_sock(&sd, &listenfds[curr_pollfd].fd, tpool);
- goto got_fd;
- }
- } while (curr_pollfd != last_pollfd);
- }
- }
- got_fd:
- if (!workers_may_exit) {
- ap_accept(&csd, sd, ptrans);
- SAFE_ACCEPT(accept_mutex_off(0));
- SAFE_ACCEPT(intra_mutex_off(0));
- process_socket(ptrans, csd, process_slot,
- thread_slot);
- requests_this_child--;
- }
- else {
- SAFE_ACCEPT(accept_mutex_off(0));
- SAFE_ACCEPT(intra_mutex_off(0));
- break;
- }
- ap_clear_pool(ptrans);
- }
-
- ap_destroy_pool(tpool);
- be_mutex_lock(&worker_thread_count_mutex);
- worker_thread_count--;
- if (worker_thread_count == 0) {
- /* All the threads have exited, now finish the shutdown process
- * by signalling the sigwait thread */
- kill(my_pid, SIGTERM);
- }
- be_mutex_unlock(&worker_thread_count_mutex);
-
- return (0);
-}
-
-
-static int32 child_main(void * data)
-{
- int child_num_arg = (int) data;
- sigset_t sig_mask;
- thread_id thread;
- int i;
- int my_child_num = child_num_arg;
- proc_info *my_info = NULL;
- ap_listen_rec *lr;
- struct sigaction sa;
- int32 msg;
- char buf;
-
- my_pid = getpid();
- ap_create_context(&pchild, pconf);
-
- /*stuff to do before we switch id's, so we have permissions.*/
- SAFE_ACCEPT(intra_mutex_init(pchild, 1));
- SAFE_ACCEPT(accept_mutex_child_init(pchild));
-
- if (beosd_setup_child()) {
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-
- ap_child_init_hook(pchild, server_conf);
-
- /*done with init critical section */
-
- /* All threads should mask signals out, accoring to sigwait(2) man page */
- sigfillset(&sig_mask);
- sigprocmask(SIG_BLOCK, &sig_mask, NULL);
-
- requests_this_child = ap_max_requests_per_child;
-
- /* Set up the pollfd array */
- listenfds = ap_palloc(pchild, sizeof(struct pollfd) * (num_listenfds));
- for (lr = ap_listeners, i = 0; i < num_listenfds; lr = lr->next, ++i) {
- ap_get_os_sock(&listenfds[i].fd , lr->sd);
- listenfds[i].events = POLLIN; /* should we add POLLPRI ?*/
- listenfds[i].revents = 0;
- }
-
- /* Setup worker threads */
-
- worker_thread_count = 0;
- be_mutex_init(&worker_thread_count_mutex, NULL);
-
- for (i=0; i < ap_threads_per_child; i++) {
-
- my_info = (proc_info *)malloc(sizeof(proc_info));
- if (my_info == NULL) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, server_conf,
- "malloc: out of memory");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
- my_info->pid = my_child_num;
- my_info->tid = i;
- my_info->sd = 0;
- ap_create_context(&my_info->tpool, pchild);
-
- /* We are creating threads right now */
-
- if ((thread = spawn_thread(worker_thread, "httpd_worker_thread",
- B_NORMAL_PRIORITY, my_info)) < B_NO_ERROR) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, server_conf,
- "spawn_thread: unable to create worker thread");
- /* In case system resources are maxxed out, we don't want
- Apache running away with the CPU trying to fork over and
- over and over again if we exit. */
- sleep(10);
- clean_child_exit(APEXIT_CHILDFATAL);
- }
- resume_thread(thread);
-
- /* We let each thread update it's own scoreboard entry. This is done
- * because it let's us deal with tid better.
- */
- }
-
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = just_die;
- sigaction(SIGTERM, &sa, NULL);
- sigaction(SIGINT, &sa, NULL);
- /* this blocks until it gets a message... */
- read_port(port_of_death, &msg, &buf, 1);
-
- return (0);
-}
-
-static int make_child(server_rec *s, int slot, time_t now)
-{
- thread_id tid;
-
- if (slot + 1 > max_daemons_limit) {
- max_daemons_limit = slot + 1;
- }
-
- if (one_process) {
- set_signals();
- child_table[slot].pid = getpid();
- child_table[slot].status = SERVER_ALIVE;
- //child_main(slot);
- }
-
- tid = spawn_thread(child_main, "httpd_child", B_NORMAL_PRIORITY,
- (void*)slot);
- if (tid < B_NO_ERROR) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, s,
- "spawn_thread: Unable to fork new process");
- /* In case system resources are maxxed out, we don't want
- Apache running away with the CPU trying to fork over and
- over and over again. */
- sleep(10);
-
- return -1;
- }
- resume_thread(tid);
-
- child_table[slot].pid = getpid();
- child_table[slot].status = SERVER_ALIVE;
- return 0;
-}
-
-/* start up a bunch of children */
-static void startup_children(int number_to_start)
-{
- int i;
-
- for (i = 0; number_to_start && i < ap_daemons_limit; ++i) {
- if (child_table[i].status != SERVER_DEAD) {
- continue;
- }
- if (make_child(server_conf, i, 0) < 0) {
- break;
- }
- --number_to_start;
- }
-}
-
-
-/*
- * spawn_rate is the number of children that will be spawned on the
- * next maintenance cycle if there aren't enough idle servers. It is
- * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by
- * without the need to spawn.
- */
-static int spawn_rate = 1;
-#ifndef MAX_SPAWN_RATE
-#define MAX_SPAWN_RATE (32)
-#endif
-static int hold_off_on_exponential_spawning;
-
-static void perform_idle_server_maintenance(void)
-{
- int i, j;
- int idle_thread_count;
- time_t now = 0;
- int free_length;
- int free_slots[MAX_SPAWN_RATE];
- int last_non_dead;
- int total_non_dead;
-
- /* initialize the free_list */
- free_length = 0;
-
- for (i = 0; i < ap_daemons_limit; ++i) {
- if (child_table[i].status == SERVER_DEAD) {
- if (free_length < spawn_rate) {
- free_slots[free_length] = i;
- ++free_length;
- }
- }
- else {
- last_non_dead = i;
- }
-
- if (i >= max_daemons_limit && free_length >= spawn_rate) {
- break;
- }
- }
- max_daemons_limit = last_non_dead + 1;
-
- if (free_length > 0) {
- for (i = 0; i < free_length; ++i) {
- make_child(server_conf, free_slots[i], now);
- }
- /* the next time around we want to spawn twice as many if this
- * wasn't good enough, but not if we've just done a graceful
- */
- if (hold_off_on_exponential_spawning) {
- --hold_off_on_exponential_spawning;
- } else if (spawn_rate < MAX_SPAWN_RATE) {
- spawn_rate *= 2;
- }
- } else {
- spawn_rate = 1;
- }
-}
-
-static void server_main_loop(int remaining_children_to_start)
-{
- int child_slot;
- ap_wait_t status;
- int pid;
- int i;
-
- while (!restart_pending && !shutdown_pending) {
- pid = wait_or_timeout(&status);
-
- if (pid >= 0) {
- process_child_status(pid, status);
- /* non-fatal death... note that it's gone in the scoreboard. */
- child_slot = -1;
- for (i = 0; i < max_daemons_limit; ++i) {
- if (child_table[i].pid == pid) {
- int j;
-
- child_slot = i;
- for (j = 0; j < HARD_THREAD_LIMIT; j++) {
- ap_mpmt_beos_force_reset_connection_status(i * HARD_THREAD_LIMIT + j);
- }
- break;
- }
- }
- if (child_slot >= 0) {
- child_table[child_slot].status = SERVER_DEAD;
-
- if (remaining_children_to_start
- && child_slot < ap_daemons_limit) {
- /* we're still doing a 1-for-1 replacement of dead
- * children with new children
- */
- make_child(server_conf, child_slot, time(NULL));
- --remaining_children_to_start;
- }
-#ifdef HAS_OTHER_CHILD
- }
- else if (reap_other_child(pid, status) == 0) {
- /* handled */
-#endif
- }
- else if (is_graceful) {
- /* Great, we've probably just lost a slot in the
- * scoreboard. Somehow we don't know about this
- * child.
- */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, errno, server_conf,
- "long lost child came home! (pid %d)", pid);
- }
- /* Don't perform idle maintenance when a child dies,
- * only do it when there's a timeout. Remember only a
- * finite number of children can die, and it's pretty
- * pathological for a lot to die suddenly.
- */
- continue;
- }
- else if (remaining_children_to_start) {
- /* we hit a 1 second timeout in which none of the previous
- * generation of children needed to be reaped... so assume
- * they're all done, and pick up the slack if any is left.
- */
- startup_children(remaining_children_to_start);
- remaining_children_to_start = 0;
- /* In any event we really shouldn't do the code below because
- * few of the servers we just started are in the IDLE state
- * yet, so we'd mistakenly create an extra server.
- */
- continue;
- }
-
- perform_idle_server_maintenance();
- }
-}
-
-int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
-{
- int remaining_children_to_start;
-
- pconf = _pconf;
- server_conf = s;
- port_of_death = create_port(1, "httpd_port_of_death");
-
- if ((num_listenfds = setup_listeners(server_conf)) < 1) {
- /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, errno, s,
- "no listening sockets available, shutting down");
- return 1;
- }
- ap_log_pid(pconf, ap_pid_fname);
- SAFE_ACCEPT(accept_mutex_init(pconf, 1));
- if (!is_graceful) {
- reinit_scoreboard(pconf);
- }
-
- set_signals();
- /* Don't thrash... */
- if (max_spare_threads < min_spare_threads + ap_threads_per_child)
- max_spare_threads = min_spare_threads + ap_threads_per_child;
-
- /* If we're doing a graceful_restart then we're going to see a lot
- * of children exiting immediately when we get into the main loop
- * below (because we just sent them SIGWINCH). This happens pretty
- * rapidly... and for each one that exits we'll start a new one until
- * we reach at least daemons_min_free. But we may be permitted to
- * start more than that, so we'll just keep track of how many we're
- * supposed to start up without the 1 second penalty between each fork.
- */
- remaining_children_to_start = ap_daemons_to_start;
- if (remaining_children_to_start > ap_daemons_limit) {
- remaining_children_to_start = ap_daemons_limit;
- }
- if (!is_graceful) {
- startup_children(remaining_children_to_start);
- remaining_children_to_start = 0;
- }
- else {
- /* give the system some time to recover before kicking into
- * exponential mode */
- hold_off_on_exponential_spawning = 10;
- }
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, errno, server_conf,
- "%s configured -- resuming normal operations",
- ap_get_server_version());
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, errno, server_conf,
- "Server built: %s", ap_get_server_built());
- restart_pending = shutdown_pending = 0;
-
- server_main_loop(remaining_children_to_start);
-
- if (shutdown_pending) {
- /* Time to gracefully shut down:
- * Kill child processes, tell them to call child_exit, etc...
- */
- if (beosd_killpg(getpgrp(), SIGTERM) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf,
- "killpg SIGTERM");
- }
- reclaim_child_processes(1); /* Start with SIGTERM */
-
- /* cleanup pid file on normal shutdown */
- {
- const char *pidfile = NULL;
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO,
- errno, server_conf,
- "removed PID file %s (pid=%ld)",
- pidfile, (long)getpid());
- }
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, errno, server_conf,
- "caught SIGTERM, shutting down");
-
- return 1;
- }
-
- /* we've been told to restart */
- signal(SIGHUP, SIG_IGN);
-
- if (one_process) {
- /* not worth thinking about */
- return 1;
- }
-
- if (is_graceful) {
- int i, j;
- char char_of_death = '!';
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, errno, server_conf,
- "SIGWINCH received. Doing graceful restart");
-
- /* give the children the signal to die */
- for (i = 0; i < ap_daemons_limit;) {
- if(child_table[i].status != SERVER_DEAD) {
- if (write_port(port_of_death, 99, &char_of_death, 1) != B_OK) {
- if (errno == EINTR) continue;
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf,
- "write port_of_death");
- }
- }
- i++;
- }
-
- }
- else {
- /* Kill 'em all. Since the child acts the same on the parents SIGTERM
- * and a SIGHUP, we may as well use the same signal, because some user
- * pthreads are stealing signals from us left and right.
- */
- if (beosd_killpg(getpgrp(), SIGTERM) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf,
- "killpg SIGTERM");
- }
- reclaim_child_processes(1); /* Start with SIGTERM */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, errno, server_conf,
- "SIGHUP received. Attempting to restart");
- }
- if (!is_graceful) {
- ap_restart_time = time(NULL);
- }
- delete_port(port_of_death);
- return 0;
-}
-
-static void mpmt_beos_pre_config(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp)
-{
- static int restart_num = 0;
-
- one_process = !!getenv("ONE_PROCESS");
-
- /* sigh, want this only the second time around */
- if (restart_num++ == 1) {
- is_graceful = 0;
-
- if (!one_process) {
- beosd_detach();
- }
-
- my_pid = getpid();
- }
-
- beosd_pre_config();
- ap_listen_pre_config();
- ap_daemons_to_start = DEFAULT_START_DAEMON;
- min_spare_threads = DEFAULT_MIN_FREE_DAEMON * DEFAULT_THREADS_PER_CHILD;
- max_spare_threads = DEFAULT_MAX_FREE_DAEMON * DEFAULT_THREADS_PER_CHILD;
- ap_daemons_limit = HARD_SERVER_LIMIT;
- ap_threads_per_child = DEFAULT_THREADS_PER_CHILD;
- ap_pid_fname = DEFAULT_PIDLOG;
- ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
- ap_mpmt_beos_set_maintain_connection_status(1);
-
- ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
-}
-
-static void mpmt_beos_hooks(void)
-{
- ap_hook_pre_config(mpmt_beos_pre_config,NULL,NULL,HOOK_MIDDLE);
- INIT_SIGLIST()
- one_process = 0;
-}
-
-
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_scoreboard(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_scoreboard_fname = arg;
- return NULL;
-}
-
-static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_to_start = atoi(arg);
- return NULL;
-}
-
-static const char *set_min_spare_threads(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- min_spare_threads = atoi(arg);
- if (min_spare_threads <= 0) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: detected MinSpareThreads set to non-positive.");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Resetting to 1 to avoid almost certain Apache failure.");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Please read the documentation.");
- min_spare_threads = 1;
- }
-
- return NULL;
-}
-
-static const char *set_max_spare_threads(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- max_spare_threads = atoi(arg);
- return NULL;
-}
-
-static const char *set_server_limit (cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_limit = atoi(arg);
- if (ap_daemons_limit > HARD_SERVER_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: MaxClients of %d exceeds compile time limit "
- "of %d servers,", ap_daemons_limit, HARD_SERVER_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " lowering MaxClients to %d. To increase, please "
- "see the", HARD_SERVER_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " HARD_SERVER_LIMIT define in src/include/httpd.h.");
- ap_daemons_limit = HARD_SERVER_LIMIT;
- }
- else if (ap_daemons_limit < 1) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: Require MaxClients > 0, setting to 1");
- ap_daemons_limit = 1;
- }
- return NULL;
-}
-
-static const char *set_threads_per_child (cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_threads_per_child = atoi(arg);
- if (ap_threads_per_child > HARD_THREAD_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: ThreadsPerChild of %d exceeds compile time"
- "limit of %d threads,\n", ap_threads_per_child,
- HARD_THREAD_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " lowering ThreadsPerChild to %d. To increase, please"
- "see the", HARD_THREAD_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " HARD_THREAD_LIMIT define in src/include/httpd.h.");
- }
- else if (ap_threads_per_child < 1) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: Require ThreadsPerChild > 0, setting to 1");
- ap_threads_per_child = 1;
- }
- return NULL;
-}
-
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_maintain_connection_status(cmd_parms *cmd,
- core_dir_config *d, int arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_mpmt_beos_set_maintain_connection_status(arg != 0);
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
-{
- struct stat finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
- return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
-static const command_rec mpmt_beos_cmds[] = {
-UNIX_DAEMON_COMMANDS
-LISTEN_COMMANDS
-{ "PidFile", set_pidfile, NULL, RSRC_CONF, TAKE1,
- "A file for logging the server process ID"},
-{ "ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF, TAKE1,
- "A file for Apache to maintain runtime process management information"},
-{ "StartServers", set_daemons_to_start, NULL, RSRC_CONF, TAKE1,
- "Number of child processes launched at server startup" },
-{ "MinSpareThreads", set_min_spare_threads, NULL, RSRC_CONF, TAKE1,
- "Minimum number of idle children, to handle request spikes" },
-{ "MaxSpareThreads", set_max_spare_threads, NULL, RSRC_CONF, TAKE1,
- "Maximum number of idle children" },
-{ "MaxClients", set_server_limit, NULL, RSRC_CONF, TAKE1,
- "Maximum number of children alive at the same time" },
-{ "ThreadsPerChild", set_threads_per_child, NULL, RSRC_CONF, TAKE1,
- "Number of threads each child creates" },
-{ "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF, TAKE1,
- "Maximum number of requests a particular child serves before dying." },
-{ "ConnectionStatus", set_maintain_connection_status, NULL, RSRC_CONF, FLAG,
- "Whether or not to maintain status information on current connections"},
-{ "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1,
- "The location of the directory Apache changes to before dumping core" },
-{ NULL }
-};
-
-module MODULE_VAR_EXPORT mpm_mpmt_beos_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- mpmt_beos_cmds, /* command ap_table_t */
- NULL, /* handlers */
- mpmt_beos_hooks /* register_hooks */
-};
-
diff --git a/server/mpm/mpmt_beos/mpmt_beos.h b/server/mpm/mpmt_beos/mpmt_beos.h
deleted file mode 100644
index 76260c1fbe..0000000000
--- a/server/mpm/mpmt_beos/mpmt_beos.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_MPM_MPMT_BEOS_H
-#define APACHE_MPM_MPMT_BEOS_H
-
-extern int ap_threads_per_child;
-extern int ap_max_requests_per_child;
-extern int ap_pipe_of_death[2];
-extern int ap_extended_status;
-extern void clean_child_exit(int);
-extern int max_daemons_limit;
-
-#endif /* APACHE_MPM_MPMT_BEOS_H */
diff --git a/server/mpm/mpmt_beos/poll.c b/server/mpm/mpmt_beos/poll.c
deleted file mode 100644
index a8c471e2db..0000000000
--- a/server/mpm/mpmt_beos/poll.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1999 Ralf S. Engelschall. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY
- * EXPRESSED 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 RALF S. ENGELSCHALL OR
- * ITS 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 <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <time.h>
-#include <errno.h>
-#include <unistd.h>
-
-#include "poll.h"
-
-/*
- * Emulate SysV poll(2) with BSD select(2)
- * Written in June 1999 by Ralf S. Engelschall <rse@engelschall.com>
- */
-
-int poll(struct pollfd *pfd, unsigned int nfd, int timeout)
-{
- fd_set rfds, wfds, efds;
- struct timeval tv, *ptv;
- int maxfd, rc, i, ok;
- char data[64];
-
- /* poll(2) semantics */
- if (pfd == NULL) {
- errno = EFAULT;
- return -1;
- }
-
- /* convert timeout number into a timeval structure */
- ptv = &tv;
- if (timeout == 0) {
- /* return immediately */
- ptv->tv_sec = 0;
- ptv->tv_usec = 0;
- }
- else if (timeout == INFTIM) {
- /* wait forever */
- ptv = NULL;
- }
- else {
- /* return after timeout */
- ptv->tv_sec = timeout / 1000;
- ptv->tv_usec = (timeout % 1000) * 1000;
- }
-
- /* clean illegal fd set and (re)enter the repeat loop */
-
- /* create fd sets and determine max fd */
- maxfd = 0;
- FD_ZERO(&rfds);
- FD_ZERO(&wfds);
- FD_ZERO(&efds);
- for(i = 0; i < nfd; i++) {
- if (pfd[i].fd < 0) {
- continue;
- }
- if (pfd[i].events & POLLIN)
- FD_SET(pfd[i].fd, &rfds);
- if (pfd[i].events & POLLOUT)
- FD_SET(pfd[i].fd, &wfds);
- if (pfd[i].events & POLLPRI)
- FD_SET(pfd[i].fd, &efds);
- if (pfd[i].fd >= maxfd && (pfd[i].events & (POLLIN|POLLOUT|POLLPRI)))
- maxfd = pfd[i].fd;
- }
-
- /* examine fd sets */
- rc = select(maxfd+1, &rfds, &wfds, &efds, ptv);
-
- /* establish results */
- if (rc > 0) {
- rc = 0;
- for (i = 0; i < nfd; i++) {
- ok = 0;
- pfd[i].revents = 0;
- if (pfd[i].fd < 0) {
- /* support for POLLNVAL */
- pfd[i].revents |= POLLNVAL;
- continue;
- }
- if (FD_ISSET(pfd[i].fd, &rfds)) {
- pfd[i].revents |= POLLIN;
- ok++;
- /* support for POLLHUP */
- if (recv(pfd[i].fd, data, 0, 0) == -1) {
- if ( errno == ESHUTDOWN || errno == ECONNRESET
- || errno == ECONNABORTED || errno == ENETRESET) {
- pfd[i].revents &= ~(POLLIN);
- pfd[i].revents |= POLLHUP;
- ok--;
- }
- }
- }
- if (FD_ISSET(pfd[i].fd, &wfds)) {
- pfd[i].revents |= POLLOUT;
- ok++;
- }
- if (FD_ISSET(pfd[i].fd, &efds)) {
- pfd[i].revents |= POLLPRI;
- ok++;
- }
- if (ok)
- rc++;
- }
- }
- return rc;
-}
-
diff --git a/server/mpm/mpmt_beos/poll.h b/server/mpm/mpmt_beos/poll.h
deleted file mode 100644
index 07c882e5e2..0000000000
--- a/server/mpm/mpmt_beos/poll.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1999 Ralf S. Engelschall. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY RALF S. ENGELSCHALL ``AS IS'' AND ANY
- * EXPRESSED 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 RALF S. ENGELSCHALL OR
- * ITS 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.
- * ====================================================================
- */
-
-#ifndef _POLL_H_
-#define _POLL_H_
-
-#define LIBPOLL_VERSION 19990812
-
-#ifndef POLLIN
-#define POLLIN 0x0001 /* any readable data available */
-#endif
-#ifndef POLLPRI
-#define POLLPRI 0x0002 /* OOB/Urgent readable data */
-#endif
-#ifndef POLLOUT
-#define POLLOUT 0x0004 /* file descriptor is writeable */
-#endif
-
-#ifndef POLLERR
-#define POLLERR 0x0008 /* some poll error occurred */
-#endif
-#ifndef POLLHUP
-#define POLLHUP 0x0010 /* file descriptor was "hung up" */
-#endif
-#ifndef POLLNVAL
-#define POLLNVAL 0x0020 /* requested events "invalid" */
-#endif
-
-#ifndef POLLRDNORM
-#define POLLRDNORM POLLIN
-#endif
-#ifndef POLLRDBAND
-#define POLLRDBAND POLLIN
-#endif
-#ifndef POLLWRNORM
-#define POLLWRNORM POLLOUT
-#endif
-#ifndef POLLWRBAND
-#define POLLWRBAND POLLOUT
-#endif
-
-#ifndef INFTIM
-#define INFTIM (-1)
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct pollfd {
- int fd; /* which file descriptor to poll */
- short events; /* events we are interested in */
- short revents; /* events found on return */
-};
-
-int poll(struct pollfd *, unsigned int, int);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _POLL_H_ */
diff --git a/server/mpm/mpmt_beos/scoreboard.c b/server/mpm/mpmt_beos/scoreboard.c
deleted file mode 100644
index 24dfcdd869..0000000000
--- a/server/mpm/mpmt_beos/scoreboard.c
+++ /dev/null
@@ -1,169 +0,0 @@
-#include "httpd.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "http_core.h"
-#include "http_config.h"
-#include "mpm_status.h"
-#include "beosd.h"
-#include "http_conf_globals.h"
-#include "mpmt_beos.h"
-#include "scoreboard.h"
-
-scoreboard *ap_scoreboard_image = NULL;
-extern ap_context_t * pconf;
-static int maintain_connection_status = 1;
-
-void reinit_scoreboard(ap_context_t *p)
-{
- ap_assert(!ap_scoreboard_image);
- ap_scoreboard_image = (scoreboard *) malloc(SCOREBOARD_SIZE);
- if (ap_scoreboard_image == NULL) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Ouch! Out of memory reiniting scoreboard!");
- }
- memset(ap_scoreboard_image, 0, SCOREBOARD_SIZE);
-}
-
-void cleanup_scoreboard(void)
-{
- ap_assert(ap_scoreboard_image);
- free(ap_scoreboard_image);
- ap_scoreboard_image = NULL;
-}
-
-API_EXPORT(int) ap_exists_scoreboard_image(void)
-{
- return (ap_scoreboard_image ? 1 : 0);
-}
-
-
-void ap_update_connection_status(long conn_id, const char *key,
- const char *value)
-{
- int i = 0;
- status_table_entry *ss;
-
- if (!maintain_connection_status) return;
- while (i < STATUSES_PER_CONNECTION) {
- ss = &(ap_scoreboard_image->table[conn_id][i]);
- if (ss->key[0] == '\0') {
- break;
- }
- if (0 == strcmp(ss->key, key)) {
- ap_cpystrn(ss->value, value, VALUE_LENGTH);
- return;
- }
- i++;
- }
- if (i >= STATUSES_PER_CONNECTION) {
- return;
- }
- ap_cpystrn(ss->key, key, KEY_LENGTH);
- ap_cpystrn(ss->value, value, VALUE_LENGTH);
- return;
-}
-
-void ap_reset_connection_status(long conn_id)
-{
- if (maintain_connection_status) {
- ap_mpmt_beos_force_reset_connection_status(conn_id);
- }
-}
-
-void ap_mpmt_beos_set_maintain_connection_status(int flag) {
- maintain_connection_status = flag;
- return;
-}
-
-void ap_mpmt_beos_force_reset_connection_status(long conn_id)
-{
- int i;
-
- for (i = 0; i < STATUSES_PER_CONNECTION; i++) {
- ap_scoreboard_image->table[conn_id][i].key[0] = '\0';
- }
-}
-
-const char *ap_get_connection_status(long conn_id, const char *key)
-{
- int i = 0;
- status_table_entry *ss;
-
- if (!maintain_connection_status) return "";
- while (i < STATUSES_PER_CONNECTION) {
- ss = &(ap_scoreboard_image->table[conn_id][i]);
- if (ss->key[0] == '\0') {
- break;
- }
- if (0 == strcmp(ss->key, key)) {
- return ss->value;
- }
- }
-
- return NULL;
-}
-
-ap_array_header_t *ap_get_connections(ap_context_t *p)
-{
- int i;
- ap_array_header_t *connection_list;
- long *array_slot;
-
- connection_list = ap_make_array(p, 0, sizeof(long));
- for (i = 0; i < max_daemons_limit*HARD_THREAD_LIMIT; i++) {
- if (ap_scoreboard_image->table[i][0].key[0] != '\0') {
- array_slot = ap_push_array(connection_list);
- *array_slot = i;
- }
- }
- return connection_list;
-}
-
-ap_array_header_t *ap_get_connection_keys(ap_context_t *p, long conn_id)
-{
- int i = 0;
- status_table_entry *ss;
- ap_array_header_t *key_list;
- char **array_slot;
-
- key_list = ap_make_array(p, 0, KEY_LENGTH * sizeof(char));
- while (i < STATUSES_PER_CONNECTION) {
- ss = &(ap_scoreboard_image->table[conn_id][i]);
- if (ss->key[0] == '\0') {
- break;
- }
- array_slot = ap_push_array(key_list);
- *array_slot = ap_pstrdup(p, ss->key);
- i++;
- }
- return key_list;
-}
-
-ap_array_header_t *ap_get_status_table(ap_context_t *p)
-{
- int i, j;
- ap_array_header_t *server_status;
- ap_status_table_row_t *array_slot;
- status_table_entry *ss;
-
- server_status = ap_make_array(p, 0, sizeof(ap_status_table_row_t));
-
- for (i = 0; i < max_daemons_limit*HARD_THREAD_LIMIT; i++) {
- if (ap_scoreboard_image->table[i][0].key[0] == '\0')
- continue;
- array_slot = ap_push_array(server_status);
- array_slot->data = ap_make_table(p, 0);
- array_slot->conn_id = i;
-
- for (j = 0; j < STATUSES_PER_CONNECTION; j++) {
- ss = &(ap_scoreboard_image->table[i][j]);
- if (ss->key[0] != '\0') {
- ap_table_add(array_slot->data, ss->key, ss->value);
- }
- else {
- break;
- }
- }
- }
- return server_status;
-}
diff --git a/server/mpm/mpmt_beos/scoreboard.h b/server/mpm/mpmt_beos/scoreboard.h
deleted file mode 100644
index a4aab5a7c6..0000000000
--- a/server/mpm/mpmt_beos/scoreboard.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef MPMT_BEOS_SCOREBOARD_H
-#define MPMT_BEOS_SCOREBOARD_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-#include <sys/times.h>
-#include "mpm_default.h" /* For HARD_.*_LIMIT */
-
-API_EXPORT(int) ap_exists_scoreboard_image(void);
-void reinit_scoareboard(ap_context_t *p);
-void cleanup_scoreboard(void);
-void ap_mpmt_beos_set_maintain_connection_status(int flag);
-void ap_mpmt_beos_force_reset_connection_status(long conn_id);
-void reinit_scoreboard(ap_context_t *p);
-void update_scoreboard_global(void);
-API_EXPORT(int) find_child_by_pid(int pid);
-int ap_update_child_status(int child_num, int thread_num, int status, request_rec *r);
-void ap_time_process_request(int child_num, int thread_num, int status);
-
-/* Add support for connection table functions */
-
-#define KEY_LENGTH 16
-#define VALUE_LENGTH 64
-
-typedef struct {
- char key[KEY_LENGTH];
- char value[VALUE_LENGTH];
-} status_table_entry;
-
-#define STATUSES_PER_CONNECTION 10
-
-typedef struct {
- status_table_entry
- table[HARD_SERVER_LIMIT*HARD_THREAD_LIMIT][STATUSES_PER_CONNECTION];
-} scoreboard;
-
-#define SCOREBOARD_SIZE sizeof(scoreboard)
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !MPMT_BEOS_SCOREBOARD_H */
diff --git a/server/mpm/mpmt_pthread/.cvsignore b/server/mpm/mpmt_pthread/.cvsignore
deleted file mode 100644
index 84df257214..0000000000
--- a/server/mpm/mpmt_pthread/.cvsignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.deps
-.libs
-*.lo
-*.la
-Makefile
diff --git a/server/mpm/mpmt_pthread/Makefile.in b/server/mpm/mpmt_pthread/Makefile.in
deleted file mode 100644
index 0be6d53cd6..0000000000
--- a/server/mpm/mpmt_pthread/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-
-DEPTH = ../../..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-LTLIBRARY_NAME = libmpmt_pthread.la
-LTLIBRARY_SOURCES = mpmt_pthread.c scoreboard.c
-
-include $(topsrcdir)/build/ltlib.mk
diff --git a/server/mpm/mpmt_pthread/Makefile.libdir b/server/mpm/mpmt_pthread/Makefile.libdir
deleted file mode 100644
index 7b5254013a..0000000000
--- a/server/mpm/mpmt_pthread/Makefile.libdir
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a place-holder which indicates to Configure that it shouldn't
-provide the default targets when building the Makefile in this directory.
-Instead it'll just prepend all the important variable definitions, and
-copy the Makefile.tmpl onto the end.
diff --git a/server/mpm/mpmt_pthread/config.m4 b/server/mpm/mpmt_pthread/config.m4
deleted file mode 100644
index e85d2570f3..0000000000
--- a/server/mpm/mpmt_pthread/config.m4
+++ /dev/null
@@ -1,15 +0,0 @@
-dnl ## XXX - Need a more thorough check of the proper flags to use
-
-if test "$MPM_NAME" = "mpmt_pthread" ; then
- ac_cv_enable_threads="yes"
- AC_CACHE_SAVE
-
- APACHE_FAST_OUTPUT(modules/mpm/$MPM_NAME/Makefile)
-
- APACHE_MPM_PTHREAD
- APACHE_MPM_CHECK_SHMEM
-
-dnl Obsolete scoreboard code uses this.
- AC_CHECK_HEADERS(sys/times.h)
- AC_CHECK_FUNCS(times)
-fi
diff --git a/server/mpm/mpmt_pthread/mpm_default.h b/server/mpm/mpmt_pthread/mpm_default.h
deleted file mode 100644
index d45efd5929..0000000000
--- a/server/mpm/mpmt_pthread/mpm_default.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_MPM_DEFAULT_H
-#define APACHE_MPM_DEFAULT_H
-
-/* Number of servers to spawn off by default --- also, if fewer than
- * this free when the caretaker checks, it will spawn more.
- */
-#ifndef DEFAULT_START_DAEMON
-#define DEFAULT_START_DAEMON 5
-#endif
-
-/* Maximum number of *free* server processes --- more than this, and
- * they will die off.
- */
-
-#ifndef DEFAULT_MAX_FREE_DAEMON
-#define DEFAULT_MAX_FREE_DAEMON 10
-#endif
-
-/* Minimum --- fewer than this, and more will be created */
-
-#ifndef DEFAULT_MIN_FREE_DAEMON
-#define DEFAULT_MIN_FREE_DAEMON 5
-#endif
-
-/* 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.
- */
-#ifdef NO_THREADS
-#define HARD_SERVER_LIMIT 256
-#endif
-#ifndef HARD_SERVER_LIMIT
-#define HARD_SERVER_LIMIT 8
-#endif
-
-/* Limit on the threads per process. Clients will be locked out if more than
- * this * HARD_SERVER_LIMIT are needed.
- *
- * We keep this for one reason it keeps the size of the scoreboard file small
- * enough that we can read the whole thing without worrying too much about
- * the overhead.
- */
-#ifdef NO_THREADS
-#define HARD_THREAD_LIMIT 1
-#endif
-#ifndef HARD_THREAD_LIMIT
-#define HARD_THREAD_LIMIT 64
-#endif
-
-#ifdef NO_THREADS
-#define DEFAULT_THREADS_PER_CHILD 1
-#endif
-#ifndef DEFAULT_THREADS_PER_CHILD
-#define DEFAULT_THREADS_PER_CHILD 50
-#endif
-
-/* File used for accept locking, when we use a file */
-#ifndef DEFAULT_LOCKFILE
-#define DEFAULT_LOCKFILE "logs/accept.lock"
-#endif
-
-/* Scoreboard file, if there is one */
-#ifndef DEFAULT_SCOREBOARD
-#define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
-#endif
-
-/* Where the main/parent process's pid is logged */
-#ifndef DEFAULT_PIDLOG
-#define DEFAULT_PIDLOG "logs/httpd.pid"
-#endif
-
-/*
- * Interval, in microseconds, between scoreboard maintenance.
- */
-#ifndef SCOREBOARD_MAINTENANCE_INTERVAL
-#define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
-#endif
-
-/* Number of requests to try to handle in a single process. If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 10000
-#endif
-
-#endif /* AP_MPM_DEFAULT_H */
diff --git a/server/mpm/mpmt_pthread/mpmt_pthread.c b/server/mpm/mpmt_pthread/mpmt_pthread.c
deleted file mode 100644
index e7a0ea21b3..0000000000
--- a/server/mpm/mpmt_pthread/mpmt_pthread.c
+++ /dev/null
@@ -1,1733 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#define CORE_PRIVATE
-
-#include "apr_portable.h"
-#include "apr_thread_proc.h"
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "http_config.h" /* for read_config */
-#include "http_core.h" /* for get_remote_host */
-#include "http_connection.h"
-#include "ap_mpm.h"
-#include "unixd.h"
-#include "iol_socket.h"
-#include "ap_listen.h"
-#include "scoreboard.h"
-
-#include <netinet/tcp.h>
-#include <sys/wait.h>
-#include <pthread.h>
-#include <signal.h>
-
-/*
- * Actual definitions of config globals
- */
-
-int ap_threads_per_child=0; /* Worker threads per child */
-int ap_max_requests_per_child=0;
-static char *ap_pid_fname=NULL;
-API_VAR_EXPORT char *ap_scoreboard_fname=NULL;
-static int ap_daemons_to_start=0;
-static int min_spare_threads=0;
-static int max_spare_threads=0;
-static int ap_daemons_limit=0;
-static time_t ap_restart_time=0;
-API_VAR_EXPORT int ap_extended_status = 0;
-static int workers_may_exit = 0;
-static int requests_this_child;
-static int num_listensocks = 0;
-static ap_socket_t **listensocks;
-
-/* The structure used to pass unique initialization info to each thread */
-typedef struct {
- int pid;
- int tid;
- int sd;
- ap_context_t *tpool; /* "pthread" would be confusing */
-} proc_info;
-
-/*
- * The max child slot ever assigned, preserved across restarts. Necessary
- * to deal with MaxClients changes across SIGWINCH restarts. We use this
- * value to optimize routines that have to scan the entire scoreboard.
- */
-static int max_daemons_limit = -1;
-
-static char ap_coredump_dir[MAX_STRING_LEN];
-
-static int pipe_of_death[2];
-static pthread_mutex_t pipe_of_death_mutex;
-
-/* *Non*-shared http_main globals... */
-
-static server_rec *server_conf;
-
-/* one_process --- debugging mode variable; can be set from the command line
- * with the -X flag. If set, this gets you the child_main loop running
- * in the process which originally started up (no detach, no make_child),
- * which is a pretty nice debugging environment. (You'll get a SIGHUP
- * early in standalone_main; just continue through. This is the server
- * trying to kill off any child processes which it might have lying
- * around --- Apache doesn't keep track of their pids, it just sends
- * SIGHUP to the process group, ignoring it in the root process.
- * Continue through and you'll be fine.).
- */
-
-static int one_process = 0;
-
-#ifdef DEBUG_SIGSTOP
-int raise_sigstop_flags;
-#endif
-
-#ifdef HAS_OTHER_CHILD
-/* used to maintain list of children which aren't part of the scoreboard */
-typedef struct other_child_rec other_child_rec;
-struct other_child_rec {
- other_child_rec *next;
- int pid;
- void (*maintenance) (int, void *, ap_wait_t);
- void *data;
- int write_fd;
-};
-static other_child_rec *other_children;
-#endif
-
-static ap_context_t *pconf; /* Pool for config stuff */
-static ap_context_t *pchild; /* Pool for httpd child stuff */
-
-static int my_pid; /* Linux getpid() doesn't work except in main thread. Use
- this instead */
-/* Keep track of the number of worker threads currently active */
-static int worker_thread_count;
-static pthread_mutex_t worker_thread_count_mutex;
-
-/* Locks for accept serialization */
-static pthread_mutex_t thread_accept_mutex = PTHREAD_MUTEX_INITIALIZER;
-static ap_lock_t *process_accept_mutex;
-static char *lock_fname;
-
-#ifdef NO_SERIALIZED_ACCEPT
-#define SAFE_ACCEPT(stmt) APR_SUCCESS
-#else
-#define SAFE_ACCEPT(stmt) (stmt)
-#endif
-
-
-/* Global, alas, so http_core can talk to us */
-enum server_token_type ap_server_tokens = SrvTk_FULL;
-
-API_EXPORT(const server_rec *) ap_get_server_conf(void)
-{
- return (server_conf);
-}
-
-API_EXPORT(int) ap_get_max_daemons(void)
-{
- return max_daemons_limit;
-}
-
-/* a clean exit from a child with proper cleanup */
-static void clean_child_exit(int code) __attribute__ ((noreturn));
-void clean_child_exit(int code)
-{
- if (pchild) {
- ap_destroy_pool(pchild);
- }
- exit(code);
-}
-
-/*****************************************************************
- * dealing with other children
- */
-
-#ifdef HAS_OTHER_CHILD
-API_EXPORT(void) ap_register_other_child(int pid,
- void (*maintenance) (int reason, void *, ap_wait_t status),
- void *data, int write_fd)
-{
- other_child_rec *ocr;
-
- ocr = ap_palloc(pconf, sizeof(*ocr));
- ocr->pid = pid;
- ocr->maintenance = maintenance;
- ocr->data = data;
- ocr->write_fd = write_fd;
- ocr->next = other_children;
- other_children = ocr;
-}
-
-/* note that 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.
- */
-API_EXPORT(void) ap_unregister_other_child(void *data)
-{
- other_child_rec **pocr, *nocr;
-
- for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
- if ((*pocr)->data == data) {
- nocr = (*pocr)->next;
- (*(*pocr)->maintenance) (OC_REASON_UNREGISTER, (*pocr)->data, -1);
- *pocr = nocr;
- /* XXX: um, well we've just wasted some space in pconf ? */
- return;
- }
- }
-}
-
-/* test to ensure that the write_fds are all still writable, otherwise
- * invoke the maintenance functions as appropriate */
-static void probe_writable_fds(void)
-{
- return;
-#if 0
- fd_set writable_fds;
- int fd_max;
- other_child_rec *ocr, *nocr;
- struct timeval tv;
- int rc;
-
- if (other_children == NULL)
- return;
-
- fd_max = 0;
- FD_ZERO(&writable_fds);
- do {
- for (ocr = other_children; ocr; ocr = ocr->next) {
- if (ocr->write_fd == -1)
- continue;
- FD_SET(ocr->write_fd, &writable_fds);
- if (ocr->write_fd > fd_max) {
- fd_max = ocr->write_fd;
- }
- }
- if (fd_max == 0)
- return;
-
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
- } while (rc == -1 && errno == EINTR);
-
- if (rc == -1) {
- /* XXX: uhh this could be really bad, we could have a bad file
- * descriptor due to a bug in one of the maintenance routines */
- ap_log_unixerr("probe_writable_fds", "select",
- "could not probe writable fds", server_conf);
- return;
- }
- if (rc == 0)
- return;
-
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->write_fd == -1)
- continue;
- if (FD_ISSET(ocr->write_fd, &writable_fds))
- continue;
- (*ocr->maintenance) (OC_REASON_UNWRITABLE, ocr->data, -1);
- }
-#endif
-}
-
-/* possibly reap an other_child, return 0 if yes, -1 if not */
-static int reap_other_child(int pid, ap_wait_t status)
-{
- other_child_rec *ocr, *nocr;
-
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->pid != pid)
- continue;
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
- return 0;
- }
- return -1;
-}
-#endif
-
-static void reclaim_child_processes(int terminate)
-{
- int i, status;
- long int waittime = 1024 * 16; /* in usecs */
- struct timeval tv;
- int waitret, tries;
- int not_dead_yet;
-#ifdef HAS_OTHER_CHILD
- other_child_rec *ocr, *nocr;
-#endif
-
- ap_sync_scoreboard_image();
-
- for (tries = terminate ? 4 : 1; tries <= 9; ++tries) {
- /* don't want to hold up progress any more than
- * necessary, but we need to allow children a few moments to exit.
- * Set delay with an exponential backoff.
- */
- tv.tv_sec = waittime / 1000000;
- tv.tv_usec = waittime % 1000000;
- waittime = waittime * 4;
- ap_select(0, NULL, NULL, NULL, &tv);
-
- /* now see who is done */
- not_dead_yet = 0;
- for (i = 0; i < max_daemons_limit; ++i) {
- int pid = ap_scoreboard_image->parent[i].pid;
-
- if (pid == my_pid || pid == 0)
- continue;
-
- waitret = waitpid(pid, &status, WNOHANG);
- if (waitret == pid || waitret == -1) {
- ap_scoreboard_image->parent[i].pid = 0;
- continue;
- }
- ++not_dead_yet;
- switch (tries) {
- case 1: /* 16ms */
- case 2: /* 82ms */
- break;
- case 3: /* 344ms */
- case 4: /* 16ms */
- case 5: /* 82ms */
- case 6: /* 344ms */
- case 7: /* 1.4sec */
- /* ok, now it's being annoying */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
- 0, server_conf,
- "child process %d still did not exit, sending a SIGTERM",
- pid);
- kill(pid, SIGTERM);
- break;
- case 8: /* 6 sec */
- /* die child scum */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
- "child process %d still did not exit, sending a SIGKILL",
- pid);
- kill(pid, SIGKILL);
- break;
- case 9: /* 14 sec */
- /* gave it our best shot, but alas... If this really
- * is a child we are trying to kill and it really hasn't
- * exited, we will likely fail to bind to the port
- * after the restart.
- */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
- "could not make child process %d exit, "
- "attempting to continue anyway", pid);
- break;
- }
- }
-#ifdef HAS_OTHER_CHILD
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->pid == -1)
- continue;
-
- waitret = waitpid(ocr->pid, &status, WNOHANG);
- if (waitret == ocr->pid) {
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
- }
- else if (waitret == 0) {
- (*ocr->maintenance) (OC_REASON_RESTART, ocr->data, -1);
- ++not_dead_yet;
- }
- else if (waitret == -1) {
- /* uh what the heck? they didn't call unregister? */
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_LOST, ocr->data, -1);
- }
- }
-#endif
- if (!not_dead_yet) {
- /* nothing left to wait for */
- break;
- }
- }
-}
-
-/* Finally, this routine is used by the caretaker process to wait for
- * a while...
- */
-
-/* number of calls to wait_or_timeout between writable probes */
-#ifndef INTERVAL_OF_WRITABLE_PROBES
-#define INTERVAL_OF_WRITABLE_PROBES 10
-#endif
-static int wait_or_timeout_counter;
-
-static int wait_or_timeout(ap_wait_t *status)
-{
- struct timeval tv;
- int ret;
-
- ++wait_or_timeout_counter;
- if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
- wait_or_timeout_counter = 0;
-#ifdef HAS_OTHER_CHILD
- probe_writable_fds();
-#endif
- }
- ret = waitpid(-1, status, WNOHANG);
- if (ret == -1 && errno == EINTR) {
- return -1;
- }
- if (ret > 0) {
- return ret;
- }
- tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000;
- tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000;
- ap_select(0, NULL, NULL, NULL, &tv);
- return -1;
-}
-
-/* handle all varieties of core dumping signals */
-static void sig_coredump(int sig)
-{
- chdir(ap_coredump_dir);
- signal(sig, SIG_DFL);
- kill(my_pid, sig);
- /* At this point we've got sig blocked, because we're still inside
- * the signal handler. When we leave the signal handler it will
- * be unblocked, and we'll take the signal... and coredump or whatever
- * is appropriate for this particular Unix. In addition the parent
- * will see the real signal we received -- whereas if we called
- * abort() here, the parent would only see SIGABRT.
- */
-}
-
-static void just_die(int sig)
-{
- clean_child_exit(0);
-}
-
-/*****************************************************************
- * Connection structures and accounting...
- */
-
-/* volatile just in case */
-static int volatile shutdown_pending;
-static int volatile restart_pending;
-static int volatile is_graceful;
-ap_generation_t volatile ap_my_generation;
-
-/*
- * ap_start_shutdown() and ap_start_restart(), below, are a first stab at
- * functions to initiate shutdown or restart without relying on signals.
- * Previously this was initiated in sig_term() and restart() signal handlers,
- * but we want to be able to start a shutdown/restart from other sources --
- * e.g. on Win32, from the service manager. Now the service manager can
- * call ap_start_shutdown() or ap_start_restart() as appropiate. Note that
- * these functions can also be called by the child processes, since global
- * variables are no longer used to pass on the required action to the parent.
- *
- * These should only be called from the parent process itself, since the
- * parent process will use the shutdown_pending and restart_pending variables
- * to determine whether to shutdown or restart. The child process should
- * call signal_parent() directly to tell the parent to die -- this will
- * cause neither of those variable to be set, which the parent will
- * assume means something serious is wrong (which it will be, for the
- * child to force an exit) and so do an exit anyway.
- */
-
-void ap_start_shutdown(void)
-{
- if (shutdown_pending == 1) {
- /* Um, is this _probably_ not an error, if the user has
- * tried to do a shutdown twice quickly, so we won't
- * worry about reporting it.
- */
- return;
- }
- shutdown_pending = 1;
-}
-
-/* do a graceful restart if graceful == 1 */
-void ap_start_restart(int graceful)
-{
-
- if (restart_pending == 1) {
- /* Probably not an error - don't bother reporting it */
- return;
- }
- restart_pending = 1;
- is_graceful = graceful;
-}
-
-static void sig_term(int sig)
-{
- ap_start_shutdown();
-}
-
-static void restart(int sig)
-{
-#ifndef WIN32
- ap_start_restart(sig == SIGWINCH);
-#else
- ap_start_restart(1);
-#endif
-}
-
-static void set_signals(void)
-{
-#ifndef NO_USE_SIGACTION
- struct sigaction sa;
-
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
-
- if (!one_process) {
- sa.sa_handler = sig_coredump;
-#if defined(SA_ONESHOT)
- sa.sa_flags = SA_ONESHOT;
-#elif defined(SA_RESETHAND)
- sa.sa_flags = SA_RESETHAND;
-#endif
- if (sigaction(SIGSEGV, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGSEGV)");
-#ifdef SIGBUS
- if (sigaction(SIGBUS, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGBUS)");
-#endif
-#ifdef SIGABORT
- if (sigaction(SIGABORT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABORT)");
-#endif
-#ifdef SIGABRT
- if (sigaction(SIGABRT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABRT)");
-#endif
-#ifdef SIGILL
- if (sigaction(SIGILL, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGILL)");
-#endif
- sa.sa_flags = 0;
- }
- sa.sa_handler = sig_term;
- if (sigaction(SIGTERM, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGTERM)");
-#ifdef SIGINT
- if (sigaction(SIGINT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGINT)");
-#endif
-#ifdef SIGXCPU
- sa.sa_handler = SIG_DFL;
- if (sigaction(SIGXCPU, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXCPU)");
-#endif
-#ifdef SIGXFSZ
- sa.sa_handler = SIG_DFL;
- if (sigaction(SIGXFSZ, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXFSZ)");
-#endif
-#ifdef SIGPIPE
- sa.sa_handler = SIG_IGN;
- if (sigaction(SIGPIPE, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGPIPE)");
-#endif
-
- /* we want to ignore HUPs and WINCH while we're busy processing one */
- sigaddset(&sa.sa_mask, SIGHUP);
- sigaddset(&sa.sa_mask, SIGWINCH);
- sa.sa_handler = restart;
- if (sigaction(SIGHUP, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGHUP)");
- if (sigaction(SIGWINCH, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGWINCH)");
-#else
- if (!one_process) {
- signal(SIGSEGV, sig_coredump);
-#ifdef SIGBUS
- signal(SIGBUS, sig_coredump);
-#endif /* SIGBUS */
-#ifdef SIGABORT
- signal(SIGABORT, sig_coredump);
-#endif /* SIGABORT */
-#ifdef SIGABRT
- signal(SIGABRT, sig_coredump);
-#endif /* SIGABRT */
-#ifdef SIGILL
- signal(SIGILL, sig_coredump);
-#endif /* SIGILL */
-#ifdef SIGXCPU
- signal(SIGXCPU, SIG_DFL);
-#endif /* SIGXCPU */
-#ifdef SIGXFSZ
- signal(SIGXFSZ, SIG_DFL);
-#endif /* SIGXFSZ */
- }
-
- signal(SIGTERM, sig_term);
-#ifdef SIGHUP
- signal(SIGHUP, restart);
-#endif /* SIGHUP */
-#ifdef SIGWINCH
- signal(SIGWINCH, restart);
-#endif /* SIGWINCH */
-#ifdef SIGPIPE
- signal(SIGPIPE, SIG_IGN);
-#endif /* SIGPIPE */
-
-#endif
-}
-
-static void process_child_status(int pid, ap_wait_t status)
-{
- /* Child died... if it died due to a fatal error,
- * we should simply bail out.
- */
- if ((WIFEXITED(status)) &&
- WEXITSTATUS(status) == APEXIT_CHILDFATAL) {
- ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, server_conf,
- "Child %d returned a Fatal error... \n"
- "Apache is exiting!",
- pid);
- exit(APEXIT_CHILDFATAL);
- }
- if (WIFSIGNALED(status)) {
- switch (WTERMSIG(status)) {
- case SIGTERM:
- case SIGHUP:
- case SIGUSR1:
- case SIGKILL:
- break;
- default:
-#ifdef SYS_SIGLIST
-#ifdef WCOREDUMP
- if (WCOREDUMP(status)) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
- 0, server_conf,
- "child pid %d exit signal %s (%d), "
- "possible coredump in %s",
- pid, (WTERMSIG(status) >= NumSIG) ? "" :
- SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status),
- ap_coredump_dir);
- }
- else {
-#endif
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
- 0, server_conf,
- "child pid %d exit signal %s (%d)", pid,
- SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status));
-#ifdef WCOREDUMP
- }
-#endif
-#else
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
- server_conf,
- "child pid %d exit signal %d",
- pid, WTERMSIG(status));
-#endif
- }
- }
-}
-
-static int setup_listeners(server_rec *s)
-{
- ap_listen_rec *lr;
- int num_listeners = 0;
- if (ap_listen_open(s->process, s->port)) {
- return 0;
- }
- for (lr = ap_listeners; lr; lr = lr->next) {
- num_listeners++;
- }
- return num_listeners;
-}
-
-/*****************************************************************
- * Here follows a long bunch of generic server bookkeeping stuff...
- */
-
-#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
-static void sock_disable_nagle(int s)
-{
- /* The Nagle algorithm says that we should delay sending partial
- * packets in hopes of getting more data. We don't want to do
- * this; we are not telnet. There are bad interactions between
- * persistent connections and Nagle's algorithm that have very severe
- * performance penalties. (Failing to disable Nagle is not much of a
- * problem with simple HTTP.)
- *
- * In spite of these problems, failure here is not a shooting offense.
- */
- int just_say_no = 1;
-
- if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &just_say_no,
- sizeof(int)) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf,
- "setsockopt: (TCP_NODELAY)");
- }
-}
-
-#else
-#define sock_disable_nagle(s) /* NOOP */
-#endif
-
-int ap_graceful_stop_signalled(void)
-{
- /* XXX - Does this really work? - Manoj */
- return is_graceful;
-}
-
-/*****************************************************************
- * Child process main loop.
- */
-
-static void process_socket(ap_context_t *p, ap_socket_t *sock, int my_child_num, int my_thread_num)
-{
- BUFF *conn_io;
- conn_rec *current_conn;
- ap_iol *iol;
- long conn_id = my_child_num * HARD_THREAD_LIMIT + my_thread_num;
- int csd;
-
- (void) ap_get_os_sock(&csd, sock);
-
- sock_disable_nagle(csd);
-
- iol = unix_attach_socket(sock);
- if (iol == NULL) {
- if (errno == EBADF) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL,
- "filedescriptor (%u) larger than FD_SETSIZE (%u) "
- "found, you probably need to rebuild Apache with a "
- "larger FD_SETSIZE", csd, FD_SETSIZE);
- }
- else {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL,
- "error attaching to socket");
- }
- ap_close_socket(sock);
- return;
- }
-
- (void) ap_update_child_status(my_child_num, my_thread_num,
- SERVER_BUSY_READ, (request_rec *) NULL);
- conn_io = ap_bcreate(p, B_RDWR);
- ap_bpush_iol(conn_io, iol);
-
- current_conn = ap_new_apr_connection(p, server_conf, conn_io, sock,
- conn_id);
-
- ap_process_connection(current_conn);
-}
-/* Sets workers_may_exit if we received a character on the pipe_of_death */
-static void check_pipe_of_death(void)
-{
- pthread_mutex_lock(&pipe_of_death_mutex);
- if (!workers_may_exit) {
- ap_status_t ret;
- char pipe_read_char;
- int n=1;
-
- ret = ap_recv(listensocks[0], &pipe_read_char, &n);
- if (ret == APR_EAGAIN) {
- /* It lost the lottery. It must continue to suffer
- * through a life of servitude. */
- }
- else {
- /* It won the lottery (or something else is very
- * wrong). Embrace death with open arms. */
- workers_may_exit = 1;
- }
- }
- pthread_mutex_unlock(&pipe_of_death_mutex);
-}
-
-static void * worker_thread(void * dummy)
-{
- proc_info * ti = dummy;
- int process_slot = ti->pid;
- int thread_slot = ti->tid;
- ap_context_t *tpool = ti->tpool;
- ap_socket_t *csd = NULL;
- ap_context_t *ptrans; /* Pool for per-transaction stuff */
- ap_socket_t *sd = NULL;
- int n;
- int curr_pollfd, last_pollfd = 0;
- ap_pollfd_t *pollset;
- ap_status_t rv;
-
- free(ti);
-
- ap_create_context(&ptrans, tpool);
-
- pthread_mutex_lock(&worker_thread_count_mutex);
- worker_thread_count++;
- pthread_mutex_unlock(&worker_thread_count_mutex);
-
- ap_setup_poll(&pollset, num_listensocks+1, tpool);
- for(n=0 ; n <= num_listensocks ; ++n)
- ap_add_poll_socket(pollset, listensocks[n], APR_POLLIN);
-
- /* TODO: Switch to a system where threads reuse the results from earlier
- poll calls - manoj */
- while (!workers_may_exit) {
- workers_may_exit |= (ap_max_requests_per_child != 0) && (requests_this_child <= 0);
- if (workers_may_exit) break;
-
- (void) ap_update_child_status(process_slot, thread_slot, SERVER_READY,
- (request_rec *) NULL);
- pthread_mutex_lock(&thread_accept_mutex);
- if (workers_may_exit) {
- pthread_mutex_unlock(&thread_accept_mutex);
- break;
- }
- if ((rv = SAFE_ACCEPT(ap_lock(process_accept_mutex)))
- != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, rv, server_conf,
- "ap_lock failed. Attempting to shutdown "
- "process gracefully.");
- workers_may_exit = 1;
- }
-
- while (!workers_may_exit) {
- ap_status_t ret;
- ap_int16_t event;
-
- ret = ap_poll(pollset, &n, -1);
- if (ret != APR_SUCCESS) {
- if (ret == APR_EINTR) {
- continue;
- }
-
- /* poll() will only return errors in catastrophic
- * circumstances. Let's try exiting gracefully, for now. */
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, (const server_rec *)
- ap_get_server_conf(), "poll: (listen)");
- workers_may_exit = 1;
- }
-
- if (workers_may_exit) break;
-
- ap_get_revents(&event, listensocks[0], pollset);
- if (event & APR_POLLIN) {
- /* A process got a signal on the shutdown pipe. Check if we're
- * the lucky process to die. */
- check_pipe_of_death();
- continue;
- }
-
- if (num_listensocks == 1) {
- sd = ap_listeners->sd;
- goto got_fd;
- }
- else {
- /* find a listener */
- curr_pollfd = last_pollfd;
- do {
- curr_pollfd++;
- if (curr_pollfd > num_listensocks) {
- curr_pollfd = 1;
- }
- /* XXX: Should we check for POLLERR? */
- ap_get_revents(&event, listensocks[curr_pollfd], pollset);
- if (event & APR_POLLIN) {
- last_pollfd = curr_pollfd;
- sd=listensocks[curr_pollfd];
- goto got_fd;
- }
- } while (curr_pollfd != last_pollfd);
- }
- }
- got_fd:
- if (!workers_may_exit) {
- ap_accept(&csd, sd, ptrans);
- if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex)))
- != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, rv, server_conf,
- "ap_unlock failed. Attempting to shutdown "
- "process gracefully.");
- workers_may_exit = 1;
- }
- pthread_mutex_unlock(&thread_accept_mutex);
- process_socket(ptrans, csd, process_slot, thread_slot);
- requests_this_child--;
- }
- else {
- if ((rv = SAFE_ACCEPT(ap_unlock(process_accept_mutex)))
- != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, rv, server_conf,
- "ap_unlock failed. Attempting to shutdown "
- "process gracefully.");
- workers_may_exit = 1;
- }
- pthread_mutex_unlock(&thread_accept_mutex);
- break;
- }
- ap_clear_pool(ptrans);
- }
-
- ap_destroy_pool(tpool);
- ap_update_child_status(process_slot, thread_slot, SERVER_DEAD,
- (request_rec *) NULL);
- pthread_mutex_lock(&worker_thread_count_mutex);
- worker_thread_count--;
- if (worker_thread_count == 0) {
- /* All the threads have exited, now finish the shutdown process
- * by signalling the sigwait thread */
- kill(my_pid, SIGTERM);
- }
- pthread_mutex_unlock(&worker_thread_count_mutex);
-
- return NULL;
-}
-
-
-static void child_main(int child_num_arg)
-{
- sigset_t sig_mask;
- int signal_received;
- pthread_t thread;
- pthread_attr_t thread_attr;
- int i;
- int my_child_num = child_num_arg;
- proc_info *my_info = NULL;
- ap_listen_rec *lr;
- ap_status_t rv;
-
-
- my_pid = getpid();
- ap_create_context(&pchild, pconf);
-
- /*stuff to do before we switch id's, so we have permissions.*/
- reopen_scoreboard(pchild);
-
- rv = SAFE_ACCEPT(ap_child_init_lock(&process_accept_mutex, lock_fname,
- pchild));
- if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, rv, server_conf,
- "Couldn't initialize cross-process lock in child");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-
- if (unixd_setup_child()) {
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-
- ap_child_init_hook(pchild, server_conf);
-
- /*done with init critical section */
-
- /* All threads should mask signals out, accoring to sigwait(2) man page */
- sigfillset(&sig_mask);
-
- if (pthread_sigmask(SIG_SETMASK, &sig_mask, NULL) != 0) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, server_conf, "pthread_sigmask");
- }
-
- requests_this_child = ap_max_requests_per_child;
-
- /* Set up the pollfd array */
- listensocks = ap_palloc(pchild,
- sizeof(*listensocks) * (num_listensocks + 1));
- ap_create_tcp_socket(&listensocks[0], pchild);
- ap_put_os_sock(&listensocks[0], &pipe_of_death[0], pchild);
- for (lr = ap_listeners, i = 1; i <= num_listensocks; lr = lr->next, ++i)
- listensocks[i]=lr->sd;
-
- /* Setup worker threads */
-
- worker_thread_count = 0;
- pthread_mutex_init(&worker_thread_count_mutex, NULL);
- pthread_mutex_init(&pipe_of_death_mutex, NULL);
- pthread_attr_init(&thread_attr);
- pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED);
- for (i=0; i < ap_threads_per_child; i++) {
-
- my_info = (proc_info *)malloc(sizeof(proc_info));
- if (my_info == NULL) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, server_conf,
- "malloc: out of memory");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
- my_info->pid = my_child_num;
- my_info->tid = i;
- my_info->sd = 0;
- ap_create_context(&my_info->tpool, pchild);
-
- /* We are creating threads right now */
- (void) ap_update_child_status(my_child_num, i, SERVER_STARTING,
- (request_rec *) NULL);
-#ifndef NO_THREADS
- if (pthread_create(&thread, &thread_attr, worker_thread, my_info)) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, server_conf,
- "pthread_create: unable to create worker thread");
- /* In case system resources are maxxed out, we don't want
- Apache running away with the CPU trying to fork over and
- over and over again if we exit. */
- sleep(10);
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-#else
- worker_thread(my_info);
- /* The SIGTERM shouldn't let us reach this point, but just in case... */
- clean_child_exit(APEXIT_OK);
-#endif
-
- /* We let each thread update it's own scoreboard entry. This is done
- * because it let's us deal with tid better.
- */
- }
-
- pthread_attr_destroy(&thread_attr);
-
- /* This thread will be the one responsible for handling signals */
- sigemptyset(&sig_mask);
- sigaddset(&sig_mask, SIGTERM);
- sigaddset(&sig_mask, SIGINT);
- sigwait(&sig_mask, &signal_received);
- switch (signal_received) {
- case SIGTERM:
- case SIGINT:
- just_die(signal_received);
- break;
- default:
- ap_log_error(APLOG_MARK, APLOG_ALERT, errno, server_conf,
- "received impossible signal: %d", signal_received);
- just_die(SIGTERM);
- }
-}
-
-static int make_child(server_rec *s, int slot, time_t now)
-{
- int pid;
-
- if (slot + 1 > max_daemons_limit) {
- max_daemons_limit = slot + 1;
- }
-
- if (one_process) {
- set_signals();
- ap_scoreboard_image->parent[slot].pid = getpid();
- child_main(slot);
- }
-
- /* Tag this slot as occupied so that perform_idle_server_maintenance
- * doesn't try to steal it */
- (void) ap_update_child_status(slot, 0, SERVER_STARTING, (request_rec *) NULL);
-
- if ((pid = fork()) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, "fork: Unable to fork new process");
-
- /* fork didn't succeed. Fix the scoreboard or else
- * it will say SERVER_STARTING forever and ever
- */
- (void) ap_update_child_status(slot, 0, SERVER_DEAD, (request_rec *) NULL);
-
- /* In case system resources are maxxed out, we don't want
- Apache running away with the CPU trying to fork over and
- over and over again. */
- sleep(10);
-
- return -1;
- }
-
- if (!pid) {
-#ifdef AIX_BIND_PROCESSOR
- /* By default, AIX binds to a single processor. This bit unbinds
- children which will then bind to another CPU.
- */
-#include <sys/processor.h>
- int status = bindprocessor(BINDPROCESS, (int)getpid(),
- PROCESSOR_CLASS_ANY);
- if (status != OK)
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, server_conf,
- "processor unbind failed %d", status);
-#endif
-
- RAISE_SIGSTOP(MAKE_CHILD);
-
- signal(SIGTERM, just_die);
- child_main(slot);
-
- return 0;
- }
- /* else */
- ap_scoreboard_image->parent[slot].pid = pid;
- return 0;
-}
-
-/* start up a bunch of children */
-static void startup_children(int number_to_start)
-{
- int i;
-
- for (i = 0; number_to_start && i < ap_daemons_limit; ++i) {
- if (ap_scoreboard_image->parent[i].pid != 0) {
- continue;
- }
- if (make_child(server_conf, i, 0) < 0) {
- break;
- }
- --number_to_start;
- }
-}
-
-
-/*
- * idle_spawn_rate is the number of children that will be spawned on the
- * next maintenance cycle if there aren't enough idle servers. It is
- * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by
- * without the need to spawn.
- */
-static int idle_spawn_rate = 1;
-#ifndef MAX_SPAWN_RATE
-#define MAX_SPAWN_RATE (32)
-#endif
-static int hold_off_on_exponential_spawning;
-
-static void perform_idle_server_maintenance(void)
-{
- int i, j;
- int idle_thread_count;
- thread_score *ss;
- time_t now = 0;
- int free_length;
- int free_slots[MAX_SPAWN_RATE];
- int last_non_dead;
- int total_non_dead;
-
- /* initialize the free_list */
- free_length = 0;
-
- idle_thread_count = 0;
- last_non_dead = -1;
- total_non_dead = 0;
-
- ap_sync_scoreboard_image();
- for (i = 0; i < ap_daemons_limit; ++i) {
- /* Initialization to satisfy the compiler. It doesn't know
- * that ap_threads_per_child is always > 0 */
- int status = SERVER_DEAD;
- int any_dying_threads = 0;
- int all_dead_threads = 1;
- int idle_thread_addition = 0;
-
- if (i >= max_daemons_limit && free_length == idle_spawn_rate)
- break;
- for (j = 0; j < ap_threads_per_child; j++) {
- ss = &ap_scoreboard_image->servers[i][j];
- status = ss->status;
-
- any_dying_threads = any_dying_threads || (status == SERVER_DEAD)
- || (status == SERVER_GRACEFUL);
- all_dead_threads = all_dead_threads && (status == SERVER_DEAD);
-
- /* We consider a starting server as idle because we started it
- * at least a cycle ago, and if it still hasn't finished starting
- * then we're just going to swamp things worse by forking more.
- * So we hopefully won't need to fork more if we count it.
- * This depends on the ordering of SERVER_READY and SERVER_STARTING.
- */
- if (status <= SERVER_READY) {
- ++idle_thread_addition;
- }
- }
- if (all_dead_threads && free_length < idle_spawn_rate) {
- free_slots[free_length] = i;
- ++free_length;
- }
- if (!all_dead_threads) {
- last_non_dead = i;
- }
- if (!any_dying_threads) {
- ++total_non_dead;
- idle_thread_count += idle_thread_addition;
- }
- }
- max_daemons_limit = last_non_dead + 1;
-
- if (idle_thread_count > max_spare_threads) {
- /* Kill off one child */
- char char_of_death = '!';
- if (write(pipe_of_death[1], &char_of_death, 1) == -1) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "write pipe_of_death");
- }
- idle_spawn_rate = 1;
- }
- else if (idle_thread_count < min_spare_threads) {
- /* terminate the free list */
- if (free_length == 0) {
- /* only report this condition once */
- static int reported = 0;
-
- if (!reported) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
- "server reached MaxClients setting, consider"
- " raising the MaxClients setting");
- reported = 1;
- }
- idle_spawn_rate = 1;
- }
- else {
-
- if (idle_spawn_rate >= 8) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
- "server seems busy, (you may need "
- "to increase StartServers, ThreadsPerChild "
- "or Min/MaxSparetThreads), "
- "spawning %d children, there are around %d idle "
- "threads, and %d total children", idle_spawn_rate,
- idle_thread_count, total_non_dead);
- }
- for (i = 0; i < free_length; ++i) {
- make_child(server_conf, free_slots[i], now);
- }
- /* the next time around we want to spawn twice as many if this
- * wasn't good enough, but not if we've just done a graceful
- */
- if (hold_off_on_exponential_spawning) {
- --hold_off_on_exponential_spawning;
- }
- else if (idle_spawn_rate < MAX_SPAWN_RATE) {
- idle_spawn_rate *= 2;
- }
- }
- }
- else {
- idle_spawn_rate = 1;
- }
-}
-
-static void server_main_loop(int remaining_children_to_start)
-{
- int child_slot;
- ap_wait_t status;
- int pid;
- int i;
-
- while (!restart_pending && !shutdown_pending) {
- pid = wait_or_timeout(&status);
-
- if (pid >= 0) {
- process_child_status(pid, status);
- /* non-fatal death... note that it's gone in the scoreboard. */
- child_slot = find_child_by_pid(pid);
- if (child_slot >= 0) {
- for (i = 0; i < ap_threads_per_child; i++)
- ap_update_child_status(child_slot, i, SERVER_DEAD, (request_rec *) NULL);
-
- if (remaining_children_to_start
- && child_slot < ap_daemons_limit) {
- /* we're still doing a 1-for-1 replacement of dead
- * children with new children
- */
- make_child(server_conf, child_slot, time(NULL));
- --remaining_children_to_start;
- }
-#ifdef HAS_OTHER_CHILD
- }
- else if (reap_other_child(pid, status) == 0) {
- /* handled */
-#endif
- }
- else if (is_graceful) {
- /* Great, we've probably just lost a slot in the
- * scoreboard. Somehow we don't know about this
- * child.
- */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, server_conf,
- "long lost child came home! (pid %d)", pid);
- }
- /* Don't perform idle maintenance when a child dies,
- * only do it when there's a timeout. Remember only a
- * finite number of children can die, and it's pretty
- * pathological for a lot to die suddenly.
- */
- continue;
- }
- else if (remaining_children_to_start) {
- /* we hit a 1 second timeout in which none of the previous
- * generation of children needed to be reaped... so assume
- * they're all done, and pick up the slack if any is left.
- */
- startup_children(remaining_children_to_start);
- remaining_children_to_start = 0;
- /* In any event we really shouldn't do the code below because
- * few of the servers we just started are in the IDLE state
- * yet, so we'd mistakenly create an extra server.
- */
- continue;
- }
-
- perform_idle_server_maintenance();
- }
-}
-
-int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
-{
- int remaining_children_to_start;
- ap_status_t rv;
-
- pconf = _pconf;
- server_conf = s;
- if (pipe(pipe_of_death) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno,
- (const server_rec*) server_conf,
- "pipe: (pipe_of_death)");
- exit(1);
- }
-/* XXXXXX Removed because these functions don't exist anymore. When
- These pipes are changed to apr_types, these functions won't be needed
- anyway.
- ap_note_cleanups_for_fd(pconf, pipe_of_death[0]);
- ap_note_cleanups_for_fd(pconf, pipe_of_death[1]);
-*/
-
- if (fcntl(pipe_of_death[0], F_SETFD, O_NONBLOCK) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno,
- (const server_rec*) server_conf,
- "fcntl: O_NONBLOCKing (pipe_of_death)");
- exit(1);
- }
- server_conf = s;
- if ((num_listensocks = setup_listeners(server_conf)) < 1) {
- /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
- "no listening sockets available, shutting down");
- return 1;
- }
- ap_log_pid(pconf, ap_pid_fname);
-
- /* Initialize cross-process accept lock */
- lock_fname = ap_psprintf(_pconf, "%s.%lu",
- ap_server_root_relative(_pconf, lock_fname),
- my_pid);
- rv = ap_create_lock(&process_accept_mutex, APR_MUTEX, APR_CROSS_PROCESS,
- lock_fname, _pconf);
- if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
- "Couldn't create cross-process lock");
- return 1;
- }
-
-
- if (!is_graceful) {
- reinit_scoreboard(pconf);
- }
-
- set_signals();
- /* Don't thrash... */
- if (max_spare_threads < min_spare_threads + ap_threads_per_child)
- max_spare_threads = min_spare_threads + ap_threads_per_child;
-
- /* If we're doing a graceful_restart then we're going to see a lot
- * of children exiting immediately when we get into the main loop
- * below (because we just sent them SIGWINCH). This happens pretty
- * rapidly... and for each one that exits we'll start a new one until
- * we reach at least daemons_min_free. But we may be permitted to
- * start more than that, so we'll just keep track of how many we're
- * supposed to start up without the 1 second penalty between each fork.
- */
- remaining_children_to_start = ap_daemons_to_start;
- if (remaining_children_to_start > ap_daemons_limit) {
- remaining_children_to_start = ap_daemons_limit;
- }
- if (!is_graceful) {
- startup_children(remaining_children_to_start);
- remaining_children_to_start = 0;
- }
- else {
- /* give the system some time to recover before kicking into
- * exponential mode */
- hold_off_on_exponential_spawning = 10;
- }
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "%s configured -- resuming normal operations",
- ap_get_server_version());
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
- "Server built: %s", ap_get_server_built());
- restart_pending = shutdown_pending = 0;
-
- server_main_loop(remaining_children_to_start);
-
- if (shutdown_pending) {
- /* Time to gracefully shut down:
- * Kill child processes, tell them to call child_exit, etc...
- */
- if (unixd_killpg(getpgrp(), SIGTERM) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "killpg SIGTERM");
- }
- reclaim_child_processes(1); /* Start with SIGTERM */
-
- /* cleanup pid file on normal shutdown */
- {
- const char *pidfile = NULL;
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0,
- server_conf,
- "removed PID file %s (pid=%ld)",
- pidfile, (long)getpid());
- }
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "caught SIGTERM, shutting down");
-
- return 1;
- }
-
- /* we've been told to restart */
- signal(SIGHUP, SIG_IGN);
-
- if (one_process) {
- /* not worth thinking about */
- return 1;
- }
-
- /* advance to the next generation */
- /* XXX: we really need to make sure this new generation number isn't in
- * use by any of the children.
- */
- ++ap_my_generation;
- ap_scoreboard_image->global.running_generation = ap_my_generation;
- update_scoreboard_global();
-
- if (is_graceful) {
- int i, j;
- char char_of_death = '!';
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "SIGWINCH received. Doing graceful restart");
-
- /* give the children the signal to die */
- for (i = 0; i < ap_daemons_limit;) {
- if (write(pipe_of_death[1], &char_of_death, 1) == -1) {
- if (errno == EINTR) continue;
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "write pipe_of_death");
- }
- i++;
- }
-
- /* This is mostly for debugging... so that we know what is still
- * gracefully dealing with existing request.
- */
-
- for (i = 0; i < ap_daemons_limit; ++i) {
- for (j = 0; j < ap_threads_per_child; j++) {
- if (ap_scoreboard_image->servers[i][j].status != SERVER_DEAD) {
- ap_scoreboard_image->servers[i][j].status = SERVER_GRACEFUL;
- }
- }
- }
- }
- else {
- /* Kill 'em all. Since the child acts the same on the parents SIGTERM
- * and a SIGHUP, we may as well use the same signal, because some user
- * pthreads are stealing signals from us left and right.
- */
- if (unixd_killpg(getpgrp(), SIGTERM) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "killpg SIGTERM");
- }
- reclaim_child_processes(1); /* Start with SIGTERM */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "SIGHUP received. Attempting to restart");
- }
- if (!is_graceful) {
- ap_restart_time = time(NULL);
- }
- return 0;
-}
-
-static void mpmt_pthread_pre_config(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp)
-{
- static int restart_num = 0;
-
- one_process = !!getenv("ONE_PROCESS");
-
- /* sigh, want this only the second time around */
- if (restart_num++ == 1) {
- is_graceful = 0;
-
- if (!one_process) {
- unixd_detach();
- }
- my_pid = getpid();
- }
-
- unixd_pre_config();
- ap_listen_pre_config();
- ap_daemons_to_start = DEFAULT_START_DAEMON;
- min_spare_threads = DEFAULT_MIN_FREE_DAEMON * DEFAULT_THREADS_PER_CHILD;
- max_spare_threads = DEFAULT_MAX_FREE_DAEMON * DEFAULT_THREADS_PER_CHILD;
- ap_daemons_limit = HARD_SERVER_LIMIT;
- ap_threads_per_child = DEFAULT_THREADS_PER_CHILD;
- ap_pid_fname = DEFAULT_PIDLOG;
- ap_scoreboard_fname = DEFAULT_SCOREBOARD;
- lock_fname = DEFAULT_LOCKFILE;
- ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
- ap_extended_status = 0;
-
- ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
-}
-
-static void mpmt_pthread_hooks(void)
-{
- ap_hook_pre_config(mpmt_pthread_pre_config,NULL,NULL,HOOK_MIDDLE);
- INIT_SIGLIST()
- one_process = 0;
-}
-
-
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_scoreboard(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_scoreboard_fname = arg;
- return NULL;
-}
-
-static const char *set_lockfile(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- lock_fname = arg;
- return NULL;
-}
-
-static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_to_start = atoi(arg);
- return NULL;
-}
-
-static const char *set_min_spare_threads(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- min_spare_threads = atoi(arg);
- if (min_spare_threads <= 0) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: detected MinSpareThreads set to non-positive.");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Resetting to 1 to avoid almost certain Apache failure.");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Please read the documentation.");
- min_spare_threads = 1;
- }
-
- return NULL;
-}
-
-static const char *set_max_spare_threads(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- max_spare_threads = atoi(arg);
- return NULL;
-}
-
-static const char *set_server_limit (cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_limit = atoi(arg);
- if (ap_daemons_limit > HARD_SERVER_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: MaxClients of %d exceeds compile time limit "
- "of %d servers,", ap_daemons_limit, HARD_SERVER_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " lowering MaxClients to %d. To increase, please "
- "see the", HARD_SERVER_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " HARD_SERVER_LIMIT define in src/include/httpd.h.");
- ap_daemons_limit = HARD_SERVER_LIMIT;
- }
- else if (ap_daemons_limit < 1) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "WARNING: Require MaxClients > 0, setting to 1\n");
- ap_daemons_limit = 1;
- }
- return NULL;
-}
-
-static const char *set_threads_per_child (cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_threads_per_child = atoi(arg);
- if (ap_threads_per_child > HARD_THREAD_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: ThreadsPerChild of %d exceeds compile time"
- "limit of %d threads,", ap_threads_per_child,
- HARD_THREAD_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " lowering ThreadsPerChild to %d. To increase, please"
- "see the", HARD_THREAD_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " HARD_THREAD_LIMIT define in src/include/httpd.h.");
- }
- else if (ap_threads_per_child < 1) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: Require ThreadsPerChild > 0, setting to 1");
- ap_threads_per_child = 1;
- }
- return NULL;
-}
-
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
-{
- struct stat finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
- return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
-static const command_rec mpmt_pthread_cmds[] = {
-UNIX_DAEMON_COMMANDS
-LISTEN_COMMANDS
-{ "PidFile", set_pidfile, NULL, RSRC_CONF, TAKE1,
- "A file for logging the server process ID"},
-{ "ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF, TAKE1,
- "A file for Apache to maintain runtime process management information"},
-{ "LockFile", set_lockfile, NULL, RSRC_CONF, TAKE1,
- "The lockfile used when Apache needs to lock the accept() call"},
-{ "StartServers", set_daemons_to_start, NULL, RSRC_CONF, TAKE1,
- "Number of child processes launched at server startup" },
-{ "MinSpareThreads", set_min_spare_threads, NULL, RSRC_CONF, TAKE1,
- "Minimum number of idle children, to handle request spikes" },
-{ "MaxSpareThreads", set_max_spare_threads, NULL, RSRC_CONF, TAKE1,
- "Maximum number of idle children" },
-{ "MaxClients", set_server_limit, NULL, RSRC_CONF, TAKE1,
- "Maximum number of children alive at the same time" },
-{ "ThreadsPerChild", set_threads_per_child, NULL, RSRC_CONF, TAKE1,
- "Number of threads each child creates" },
-{ "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF, TAKE1,
- "Maximum number of requests a particular child serves before dying." },
-{ "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1,
- "The location of the directory Apache changes to before dumping core" },
-{ NULL }
-};
-
-module MODULE_VAR_EXPORT mpm_mpmt_pthread_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- mpmt_pthread_cmds, /* command ap_table_t */
- NULL, /* handlers */
- mpmt_pthread_hooks /* register_hooks */
-};
-
diff --git a/server/mpm/mpmt_pthread/scoreboard.c b/server/mpm/mpmt_pthread/scoreboard.c
deleted file mode 100644
index baaa34bac5..0000000000
--- a/server/mpm/mpmt_pthread/scoreboard.c
+++ /dev/null
@@ -1,285 +0,0 @@
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "http_core.h"
-#include "http_config.h"
-#include "unixd.h"
-#include "http_conf_globals.h"
-#include "mpm_status.h"
-#include "mpmt_pthread.h"
-#include "scoreboard.h"
-#include <sys/types.h>
-
-scoreboard *ap_scoreboard_image = NULL;
-API_VAR_IMPORT char *ap_scoreboard_fname;
-/*****************************************************************
- *
- * Dealing with the scoreboard... a lot of these variables are global
- * only to avoid getting clobbered by the longjmp() that happens when
- * a hard timeout expires...
- *
- * We begin with routines which deal with the file itself...
- */
-
-#ifdef MULTITHREAD
-/*
- * In the multithreaded mode, have multiple threads - not multiple
- * processes that need to talk to each other. Just use a simple
- * malloc. But let the routines that follow, think that you have
- * shared memory (so they use memcpy etc.)
- */
-
-void reinit_scoreboard(ap_context_t *p)
-{
- ap_assert(!ap_scoreboard_image);
- ap_scoreboard_image = (scoreboard *) malloc(SCOREBOARD_SIZE);
- if (ap_scoreboard_image == NULL) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Ouch! Out of memory reiniting scoreboard!");
- }
- memset(ap_scoreboard_image, 0, SCOREBOARD_SIZE);
-}
-
-void cleanup_scoreboard(void)
-{
- ap_assert(ap_scoreboard_image);
- free(ap_scoreboard_image);
- ap_scoreboard_image = NULL;
-}
-
-API_EXPORT(void) ap_sync_scoreboard_image(void)
-{
-}
-
-
-#else /* MULTITHREAD */
-#if APR_HAS_SHARED_MEMORY
-#include "apr_shmem.h"
-
-static ap_shmem_t *scoreboard_shm = NULL;
-
-ap_status_t cleanup_shared_mem(void *d)
-{
- mm_free(scoreboard_shm, ap_scoreboard_image);
- ap_scoreboard_image = NULL;
- ap_shm_destroy(scoreboard_shm);
-}
-
-void setup_shared_mem(ap_context_t *p)
-{
- char buf[512];
- const char *fname;
-
- fname = ap_server_root_relative(p, ap_scoreboard_fname);
- if (ap_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + 40, fname) != APR_SUCCESS) {
- ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
- ap_server_argv0);
- perror(buf);
- exit(APEXIT_INIT);
- }
- ap_scoreboard_image = ap_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE);
- if (ap_scoreboard_image == NULL) {
- ap_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard",
- ap_server_argv0);
- perror(buf);
- ap_shm_destroy(scoreboard_shm);
- exit(APEXIT_INIT);
- }
- ap_register_cleanup(p, NULL, cleanup_shared_mem, ap_null_cleanup);
- ap_scoreboard_image->global.running_generation = 0;
-}
-
-void reopen_scoreboard(ap_context_t *p)
-{
-}
-#endif /* APR_SHARED_MEM */
-
-/* Called by parent process */
-void reinit_scoreboard(ap_context_t *p)
-{
- int running_gen = 0;
- if (ap_scoreboard_image)
- running_gen = ap_scoreboard_image->global.running_generation;
- if (ap_scoreboard_image == NULL) {
- setup_shared_mem(p);
- }
- memset(ap_scoreboard_image, 0, SCOREBOARD_SIZE);
- ap_scoreboard_image->global.running_generation = running_gen;
-}
-
-/* Routines called to deal with the scoreboard image
- * --- note that we do *not* need write locks, since update_child_status
- * only updates a *single* record in place, and only one process writes to
- * a given scoreboard slot at a time (either the child process owning that
- * slot, or the parent, noting that the child has died).
- *
- * As a final note --- setting the score entry to getpid() is always safe,
- * since when the parent is writing an entry, it's only noting SERVER_DEAD
- * anyway.
- */
-
-ap_inline void ap_sync_scoreboard_image(void)
-{
-}
-
-#endif /* MULTITHREAD */
-
-API_EXPORT(int) ap_exists_scoreboard_image(void)
-{
- return (ap_scoreboard_image ? 1 : 0);
-}
-
-static ap_inline void put_scoreboard_info(int child_num, int thread_num,
- thread_score *new_score_rec)
-{
- /* XXX - needs to be fixed to account for threads */
-#ifdef SCOREBOARD_FILE
- lseek(scoreboard_fd, (long) child_num * sizeof(thread_score), 0);
- force_write(scoreboard_fd, new_score_rec, sizeof(thread_score));
-#endif
-}
-
-void update_scoreboard_global(void)
-{
-#ifdef SCOREBOARD_FILE
- lseek(scoreboard_fd,
- (char *) &ap_scoreboard_image->global -(char *) ap_scoreboard_image, 0);
- force_write(scoreboard_fd, &ap_scoreboard_image->global,
- sizeof ap_scoreboard_image->global);
-#endif
-}
-
-void increment_counts(int child_num, int thread_num, request_rec *r)
-{
- long int bs = 0;
- thread_score *ss;
-
- ss = &ap_scoreboard_image->servers[child_num][thread_num];
-
- if (r->sent_bodyct)
- ap_bgetopt(r->connection->client, BO_BYTECT, &bs);
-
-#ifdef HAVE_TIMES
- times(&ss->times);
-#endif
- ss->access_count++;
- ss->my_access_count++;
- ss->conn_count++;
- ss->bytes_served += (unsigned long) bs;
- ss->my_bytes_served += (unsigned long) bs;
- ss->conn_bytes += (unsigned long) bs;
-
- put_scoreboard_info(child_num, thread_num, ss);
-
-}
-
-API_EXPORT(int) find_child_by_pid(int pid)
-{
- int i;
- int max_daemons_limit = ap_get_max_daemons();
-
- for (i = 0; i < max_daemons_limit; ++i)
- if (ap_scoreboard_image->parent[i].pid == pid)
- return i;
-
- return -1;
-}
-
-int ap_update_child_status(int child_num, int thread_num, int status, request_rec *r)
-{
- int old_status;
- thread_score *ss;
- parent_score *ps;
-
- if (child_num < 0)
- return -1;
-
- ss = &ap_scoreboard_image->servers[child_num][thread_num];
- old_status = ss->status;
- ss->status = status;
-
- ps = &ap_scoreboard_image->parent[child_num];
-
- if ((status == SERVER_READY || status == SERVER_ACCEPTING)
- && old_status == SERVER_STARTING) {
- ss->tid = pthread_self();
- ps->worker_threads = ap_threads_per_child;
- }
-
- if (ap_extended_status) {
- if (status == SERVER_READY || status == SERVER_DEAD) {
- /*
- * Reset individual counters
- */
- if (status == SERVER_DEAD) {
- ss->my_access_count = 0L;
- ss->my_bytes_served = 0L;
- }
- ss->conn_count = (unsigned short) 0;
- ss->conn_bytes = (unsigned long) 0;
- }
- if (r) {
- conn_rec *c = r->connection;
- ap_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config,
- REMOTE_NOLOOKUP), sizeof(ss->client));
- if (r->the_request == NULL) {
- ap_cpystrn(ss->request, "NULL", sizeof(ss->request));
- } else if (r->parsed_uri.password == NULL) {
- ap_cpystrn(ss->request, r->the_request, sizeof(ss->request));
- } else {
- /* Don't reveal the password in the server-status view */
- ap_cpystrn(ss->request, ap_pstrcat(r->pool, r->method, " ",
- ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD),
- r->assbackwards ? NULL : " ", r->protocol, NULL),
- sizeof(ss->request));
- }
- ss->vhostrec = r->server;
- }
- }
-
- put_scoreboard_info(child_num, thread_num, ss);
- return old_status;
-}
-
-void ap_time_process_request(int child_num, int thread_num, int status)
-{
- thread_score *ss;
-
- if (child_num < 0)
- return;
-
- ss = &ap_scoreboard_image->servers[child_num][thread_num];
-
- if (status == START_PREQUEST) {
- /*ss->start_time = GetCurrentTime(); return time in uS since the
- epoch. Some platforms do not support gettimeofday. Create a routine
- to get the current time is some useful units. */
- if (gettimeofday(&ss->start_time, (struct timezone *) 0) < 0) {
- ss->start_time.tv_sec = ss->start_time.tv_usec = 0L;
- }
- }
- else if (status == STOP_PREQUEST) {
- /*ss->stop_time = GetCurrentTime();
- return time in uS since the epoch */
-
- if (gettimeofday(&ss->stop_time, (struct timezone *) 0) < 0) {
- ss->start_time.tv_sec = ss->start_time.tv_usec = 0L;
- }
- }
- put_scoreboard_info(child_num, thread_num, ss);
-}
-
-/* Stub functions until this MPM supports the connection status API */
-
-API_EXPORT(void) ap_update_connection_status(long conn_id, const char *key, \
- const char *value)
-{
- /* NOP */
-}
-
-API_EXPORT(void) ap_reset_connection_status(long conn_id)
-{
- /* NOP */
-}
-
diff --git a/server/mpm/mpmt_pthread/scoreboard.h b/server/mpm/mpmt_pthread/scoreboard.h
deleted file mode 100644
index 4a367f3fdb..0000000000
--- a/server/mpm/mpmt_pthread/scoreboard.h
+++ /dev/null
@@ -1,239 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_SCOREBOARD_H
-#define APACHE_SCOREBOARD_H
-#include <pthread.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef HAVE_SYS_TIMES_H
-#include <sys/time.h>
-#include <sys/times.h>
-#elif defined(TPF)
-#include <time.h>
-#endif
-
-#include "mpm_default.h" /* For HARD_.*_LIMIT */
-
-/* The optimized timeout code only works if we're not using a scoreboard file
- */
-#if (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD))
-#define OPTIMIZE_TIMEOUTS
-#endif
-
-/* Scoreboard info on a process is, for now, kept very brief ---
- * just status value and pid (the latter so that the caretaker process
- * can properly update the scoreboard when a process dies). We may want
- * to eventually add a separate set of long_score structures which would
- * give, for each process, the number of requests serviced, and info on
- * the current, or most recent, request.
- *
- * Status values:
- */
-
-#define SERVER_DEAD 0
-#define SERVER_STARTING 1 /* Server Starting up */
-#define SERVER_READY 2 /* Waiting for connection (or accept() lock) */
-#define SERVER_BUSY_READ 3 /* Reading a client request */
-#define SERVER_BUSY_WRITE 4 /* Processing a client request */
-#define SERVER_BUSY_KEEPALIVE 5 /* Waiting for more requests via keepalive */
-#define SERVER_BUSY_LOG 6 /* Logging the request */
-#define SERVER_BUSY_DNS 7 /* Looking up a hostname */
-#define SERVER_GRACEFUL 8 /* server is gracefully finishing request */
-#define SERVER_ACCEPTING 9 /* thread is accepting connections */
-#define SERVER_QUEUEING 10 /* thread is putting connection on the queue */
-#define SERVER_NUM_STATUS 11 /* number of status settings */
-
-/* A "virtual time" is simply a counter that indicates that a child is
- * making progress. The parent checks up on each child, and when they have
- * made progress it resets the last_rtime element. But when the child hasn't
- * made progress in a time that's roughly timeout_len seconds long, it is
- * sent a SIGALRM.
- *
- * vtime is an optimization that is used only when the scoreboard is in
- * shared memory (it's not easy/feasible to do it in a scoreboard file).
- * The essential observation is that timeouts rarely occur, the vast majority
- * of hits finish before any timeout happens. So it really sucks to have to
- * ask the operating system to set up and destroy alarms many times during
- * a request.
- */
-typedef unsigned vtime_t;
-
-/* Type used for generation indicies. Startup and every restart cause a
- * new generation of children to be spawned. Children within the same
- * generation share the same configuration information -- pointers to stuff
- * created at config time in the parent are valid across children. For
- * example, the vhostrec pointer in the scoreboard below is valid in all
- * children of the same generation.
- *
- * The safe way to access the vhost pointer is like this:
- *
- * short_score *ss = pointer to whichver slot is interesting;
- * parent_score *ps = pointer to whichver slot is interesting;
- * server_rec *vh = ss->vhostrec;
- *
- * if (ps->generation != ap_my_generation) {
- * vh = NULL;
- * }
- *
- * then if vh is not NULL it's valid in this child.
- *
- * This avoids various race conditions around restarts.
- */
-typedef int ap_generation_t;
-
-/* stuff which is thread specific */
-typedef struct {
-#ifdef OPTIMIZE_TIMEOUTS
- vtime_t cur_vtime; /* the child's current vtime */
- unsigned short timeout_len; /* length of the timeout */
-#endif
- pthread_t tid;
- unsigned char status;
- unsigned long access_count;
- unsigned long bytes_served;
- unsigned long my_access_count;
- unsigned long my_bytes_served;
- unsigned long conn_bytes;
- unsigned short conn_count;
-#ifndef HAVE_GETTIMEOFDAY
- clock_t start_time;
- clock_t stop_time;
-#else
- struct timeval start_time;
- struct timeval stop_time;
-#endif
-#ifdef HAVE_TIMES
- struct tms times;
-#endif
-#ifndef OPTIMIZE_TIMEOUTS
- time_t last_used;
-#endif
- char client[32]; /* Keep 'em small... */
- char request[64]; /* We just want an idea... */
- server_rec *vhostrec; /* What virtual host is being accessed? */
- /* SEE ABOVE FOR SAFE USAGE! */
-} thread_score;
-
-typedef struct {
- ap_generation_t running_generation; /* the generation of children which
- * should still be serving requests. */
-} global_score;
-
-/* stuff which the parent generally writes and the children rarely read */
-typedef struct {
- pid_t pid;
- ap_generation_t generation; /* generation of this child */
- int worker_threads;
-#ifdef OPTIMIZE_TIMEOUTS
- time_t last_rtime; /* time(0) of the last change */
- vtime_t last_vtime; /* the last vtime the parent has seen */
-#endif
-} parent_score;
-
-typedef struct {
- thread_score servers[HARD_SERVER_LIMIT][HARD_THREAD_LIMIT];
- parent_score parent[HARD_SERVER_LIMIT];
- global_score global;
-} scoreboard;
-
-#define SCOREBOARD_SIZE sizeof(scoreboard)
-#ifdef TPF
-#define SCOREBOARD_NAME "SCOREBRD"
-#define SCOREBOARD_FRAMES SCOREBOARD_SIZE/4095 + 1
-#endif
-
-API_EXPORT(int) ap_exists_scoreboard_image(void);
-void reinit_scoareboard(ap_context_t *p);
-void cleanup_scoreboard(void);
-API_EXPORT(void) ap_sync_scoreboard_image(void);
-
-#if defined(USE_OS2_SCOREBOARD)
-caddr_t create_shared_heap(const char *name, size_t size);
-caddr_t get_shared_heap(const char *Name);
-#elif defined(USE_POSIX_SCOREBOARD)
-static void cleanup_shared_mem(void *d);
-#else
-void reinit_scoreboard(ap_context_t *p);
-#endif
-
-API_EXPORT(void) reopen_scoreboard(ap_context_t *p);
-
-ap_inline void ap_sync_scoreboard_image(void);
-void increment_counts(int child_num, int thread_num, request_rec *r);
-void update_scoreboard_global(void);
-API_EXPORT(int) find_child_by_pid(int pid);
-int ap_update_child_status(int child_num, int thread_num, int status, request_rec *r);
-void ap_time_process_request(int child_num, int thread_num, int status);
-
-
-
-API_VAR_EXPORT extern scoreboard *ap_scoreboard_image;
-
-API_VAR_EXPORT extern ap_generation_t volatile ap_my_generation;
-
-/* for time_process_request() in http_main.c */
-#define START_PREQUEST 1
-#define STOP_PREQUEST 2
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_SCOREBOARD_H */
diff --git a/server/mpm/prefork/.cvsignore b/server/mpm/prefork/.cvsignore
deleted file mode 100644
index 151f66f3e4..0000000000
--- a/server/mpm/prefork/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.lo
-*.la
-Makefile
diff --git a/server/mpm/prefork/Makefile.in b/server/mpm/prefork/Makefile.in
deleted file mode 100644
index 5d086070f2..0000000000
--- a/server/mpm/prefork/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-
-DEPTH = ../../..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-LTLIBRARY_NAME = libprefork.la
-LTLIBRARY_SOURCES = prefork.c
-
-include $(topsrcdir)/build/ltlib.mk
diff --git a/server/mpm/prefork/Makefile.libdir b/server/mpm/prefork/Makefile.libdir
deleted file mode 100644
index 7b5254013a..0000000000
--- a/server/mpm/prefork/Makefile.libdir
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a place-holder which indicates to Configure that it shouldn't
-provide the default targets when building the Makefile in this directory.
-Instead it'll just prepend all the important variable definitions, and
-copy the Makefile.tmpl onto the end.
diff --git a/server/mpm/prefork/config.m4 b/server/mpm/prefork/config.m4
deleted file mode 100644
index 1fbf4fa8ab..0000000000
--- a/server/mpm/prefork/config.m4
+++ /dev/null
@@ -1,13 +0,0 @@
-if test "$MPM_NAME" = "prefork" ; then
-dnl Turn off all threading functions in APR
- ac_cv_enable_threads="no"
- AC_CACHE_SAVE
-
- APACHE_FAST_OUTPUT(modules/mpm/$MPM_NAME/Makefile)
-
- APACHE_MPM_CHECK_SHMEM
-
-dnl Obsolete scoreboard code uses this.
- AC_CHECK_HEADERS(sys/times.h)
- AC_CHECK_FUNCS(times)
-fi
diff --git a/server/mpm/prefork/mpm_default.h b/server/mpm/prefork/mpm_default.h
deleted file mode 100644
index 131b516cac..0000000000
--- a/server/mpm/prefork/mpm_default.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_MPM_DEFAULT_H
-#define APACHE_MPM_DEFAULT_H
-
-/* Number of servers to spawn off by default --- also, if fewer than
- * this free when the caretaker checks, it will spawn more.
- */
-#ifndef DEFAULT_START_DAEMON
-#define DEFAULT_START_DAEMON 5
-#endif
-
-/* Maximum number of *free* server processes --- more than this, and
- * they will die off.
- */
-
-#ifndef DEFAULT_MAX_FREE_DAEMON
-#define DEFAULT_MAX_FREE_DAEMON 10
-#endif
-
-/* Minimum --- fewer than this, and more will be created */
-
-#ifndef DEFAULT_MIN_FREE_DAEMON
-#define DEFAULT_MIN_FREE_DAEMON 5
-#endif
-
-/* 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
-#define HARD_SERVER_LIMIT 256
-#endif
-
-/* File used for accept locking, when we use a file */
-#ifndef DEFAULT_LOCKFILE
-#define DEFAULT_LOCKFILE "logs/accept.lock"
-#endif
-
-/* Scoreboard file, if there is one */
-#ifndef DEFAULT_SCOREBOARD
-#define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
-#endif
-
-/* Where the main/parent process's pid is logged */
-#ifndef DEFAULT_PIDLOG
-#define DEFAULT_PIDLOG "logs/httpd.pid"
-#endif
-
-/*
- * Interval, in microseconds, between scoreboard maintenance.
- */
-#ifndef SCOREBOARD_MAINTENANCE_INTERVAL
-#define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
-#endif
-
-/* Number of requests to try to handle in a single process. If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 10000
-#endif
-
-#endif /* AP_MPM_DEFAULT_H */
diff --git a/server/mpm/prefork/prefork.c b/server/mpm/prefork/prefork.c
deleted file mode 100644
index cfa45341e0..0000000000
--- a/server/mpm/prefork/prefork.c
+++ /dev/null
@@ -1,2604 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * httpd.c: simple http daemon for answering WWW file requests
- *
- *
- * 03-21-93 Rob McCool wrote original code (up to NCSA HTTPd 1.3)
- *
- * 03-06-95 blong
- * changed server number for child-alone processes to 0 and changed name
- * of processes
- *
- * 03-10-95 blong
- * Added numerous speed hacks proposed by Robert S. Thau (rst@ai.mit.edu)
- * including set group before fork, and call gettime before to fork
- * to set up libraries.
- *
- * 04-14-95 rst / rh
- * Brandon's code snarfed from NCSA 1.4, but tinkered to work with the
- * Apache server, and also to have child processes do accept() directly.
- *
- * April-July '95 rst
- * Extensive rework for Apache.
- */
-
-/* TODO: this is a cobbled together prefork MPM example... it should mostly
- * TODO: behave like apache-1.3... here's a short list of things I think
- * TODO: need cleaning up still:
- * TODO: - use ralf's mm stuff for the shared mem and mutexes
- * TODO: - clean up scoreboard stuff when we figure out how to do it in 2.0
- */
-
-#define CORE_PRIVATE
-
-#include "ap_config.h"
-#include "apr_portable.h"
-#include "httpd.h"
-#include "mpm_default.h"
-#include "mpm_status.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "http_config.h"
-#include "http_core.h" /* for get_remote_host */
-#include "http_connection.h"
-#include "scoreboard.h"
-#include "ap_mpm.h"
-#include "unixd.h"
-#include "iol_socket.h"
-#include "ap_listen.h"
-#include "ap_mmn.h"
-#include <sys/times.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-
-
-#ifdef HAVE_BSTRING_H
-#include <bstring.h> /* for IRIX, FD_SET calls bzero() */
-#endif
-#include <signal.h>
-
-/* config globals */
-
-static int ap_max_requests_per_child=0;
-static char *ap_pid_fname=NULL;
-static char *ap_scoreboard_fname=NULL;
-static char *ap_lock_fname;
-static int ap_daemons_to_start=0;
-static int ap_daemons_min_free=0;
-static int ap_daemons_max_free=0;
-static int ap_daemons_limit=0;
-static time_t ap_restart_time=0;
-static int ap_extended_status = 0;
-
-/*
- * The max child slot ever assigned, preserved across restarts. Necessary
- * to deal with MaxClients changes across SIGUSR1 restarts. We use this
- * value to optimize routines that have to scan the entire scoreboard.
- */
-static int max_daemons_limit = -1;
-
-static char ap_coredump_dir[MAX_STRING_LEN];
-
-/* *Non*-shared http_main globals... */
-
-static server_rec *server_conf;
-static ap_socket_t *sd;
-static fd_set listenfds;
-static int listenmaxfd;
-
-/* one_process --- debugging mode variable; can be set from the command line
- * with the -X flag. If set, this gets you the child_main loop running
- * in the process which originally started up (no detach, no make_child),
- * which is a pretty nice debugging environment. (You'll get a SIGHUP
- * early in standalone_main; just continue through. This is the server
- * trying to kill off any child processes which it might have lying
- * around --- Apache doesn't keep track of their pids, it just sends
- * SIGHUP to the process group, ignoring it in the root process.
- * Continue through and you'll be fine.).
- */
-
-static int one_process = 0;
-
-#ifdef HAS_OTHER_CHILD
-/* used to maintain list of children which aren't part of the scoreboard */
-typedef struct other_child_rec other_child_rec;
-struct other_child_rec {
- other_child_rec *next;
- int pid;
- void (*maintenance) (int, void *, ap_wait_t);
- void *data;
- int write_fd;
-};
-static other_child_rec *other_children;
-#endif
-
-static ap_context_t *pconf; /* Pool for config stuff */
-static ap_context_t *pchild; /* Pool for httpd child stuff */
-
-static int my_pid; /* it seems silly to call getpid all the time */
-#ifndef MULTITHREAD
-static int my_child_num;
-#endif
-
-#ifdef TPF
-int tpf_child = 0;
-char tpf_server_name[INETD_SERVNAME_LENGTH+1];
-#endif /* TPF */
-
-static scoreboard *ap_scoreboard_image = NULL;
-
-#ifdef GPROF
-/*
- * change directory for gprof to plop the gmon.out file
- * configure in httpd.conf:
- * GprofDir logs/ -> $ServerRoot/logs/gmon.out
- * GprofDir logs/% -> $ServerRoot/logs/gprof.$pid/gmon.out
- */
-static void chdir_for_gprof(void)
-{
- core_server_config *sconf =
- ap_get_module_config(server_conf->module_config, &core_module);
- char *dir = sconf->gprof_dir;
-
- if(dir) {
- char buf[512];
- int len = strlen(sconf->gprof_dir) - 1;
- if(*(dir + len) == '%') {
- dir[len] = '\0';
- ap_snprintf(buf, sizeof(buf), "%sgprof.%d", dir, (int)getpid());
- }
- dir = ap_server_root_relative(pconf, buf[0] ? buf : dir);
- if(mkdir(dir, 0755) < 0 && errno != EEXIST) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf,
- "gprof: error creating directory %s", dir);
- }
- }
- else {
- dir = ap_server_root_relative(pconf, "logs");
- }
-
- chdir(dir);
-}
-#else
-#define chdir_for_gprof()
-#endif
-
-/* XXX - I don't know if TPF will ever use this module or not, so leave
- * the ap_check_signals calls in but disable them - manoj */
-#define ap_check_signals()
-
-/* a clean exit from a child with proper cleanup */
-static void clean_child_exit(int code) __attribute__ ((noreturn));
-static void clean_child_exit(int code)
-{
- if (pchild) {
- ap_destroy_pool(pchild);
- }
- chdir_for_gprof();
- exit(code);
-}
-
-#if defined(USE_FCNTL_SERIALIZED_ACCEPT) || defined(USE_FLOCK_SERIALIZED_ACCEPT)
-static void expand_lock_fname(ap_context_t *p)
-{
- /* XXXX possibly bogus cast */
- ap_lock_fname = ap_psprintf(p, "%s.%lu",
- ap_server_root_relative(p, ap_lock_fname), (unsigned long)getpid());
-}
-#endif
-
-#if defined (USE_USLOCK_SERIALIZED_ACCEPT)
-
-#include <ulocks.h>
-
-static ulock_t uslock = NULL;
-
-#define accept_mutex_child_init(x)
-
-static void accept_mutex_init(ap_context_t *p)
-{
- ptrdiff_t old;
- usptr_t *us;
-
-
- /* default is 8, allocate enough for all the children plus the parent */
- if ((old = usconfig(CONF_INITUSERS, HARD_SERVER_LIMIT + 1)) == -1) {
- perror("usconfig(CONF_INITUSERS)");
- exit(-1);
- }
-
- if ((old = usconfig(CONF_LOCKTYPE, US_NODEBUG)) == -1) {
- perror("usconfig(CONF_LOCKTYPE)");
- exit(-1);
- }
- if ((old = usconfig(CONF_ARENATYPE, US_SHAREDONLY)) == -1) {
- perror("usconfig(CONF_ARENATYPE)");
- exit(-1);
- }
- if ((us = usinit("/dev/zero")) == NULL) {
- perror("usinit");
- exit(-1);
- }
-
- if ((uslock = usnewlock(us)) == NULL) {
- perror("usnewlock");
- exit(-1);
- }
-}
-
-static void accept_mutex_on(void)
-{
- switch (ussetlock(uslock)) {
- case 1:
- /* got lock */
- break;
- case 0:
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "didn't get lock");
- clean_child_exit(APEXIT_CHILDFATAL);
- case -1:
- perror("ussetlock");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-}
-
-static void accept_mutex_off(void)
-{
- if (usunsetlock(uslock) == -1) {
- perror("usunsetlock");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-}
-
-#elif defined (USE_PTHREAD_SERIALIZED_ACCEPT)
-
-/* This code probably only works on Solaris ... but it works really fast
- * on Solaris. Note that pthread mutexes are *NOT* released when a task
- * dies ... the task has to free it itself. So we block signals and
- * try to be nice about releasing the mutex.
- */
-
-#include <pthread.h>
-
-static pthread_mutex_t *accept_mutex = (void *)(caddr_t) -1;
-static int have_accept_mutex;
-static sigset_t accept_block_mask;
-static sigset_t accept_previous_mask;
-
-static void accept_mutex_child_cleanup(void *foo)
-{
- if (accept_mutex != (void *)(caddr_t)-1
- && have_accept_mutex) {
- pthread_mutex_unlock(accept_mutex);
- }
-}
-
-static void accept_mutex_child_init(ap_context_t *p)
-{
- ap_register_cleanup(p, NULL, accept_mutex_child_cleanup, ap_null_cleanup);
-}
-
-static void accept_mutex_cleanup(void *foo)
-{
- if (accept_mutex != (void *)(caddr_t)-1
- && munmap((caddr_t) accept_mutex, sizeof(*accept_mutex))) {
- perror("munmap");
- }
- accept_mutex = (void *)(caddr_t)-1;
-}
-
-static void accept_mutex_init(ap_context_t *p)
-{
- pthread_mutexattr_t mattr;
- int fd;
-
- fd = open("/dev/zero", O_RDWR);
- if (fd == -1) {
- perror("open(/dev/zero)");
- exit(APEXIT_INIT);
- }
- accept_mutex = (pthread_mutex_t *) mmap((caddr_t) 0, sizeof(*accept_mutex),
- PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (accept_mutex == (void *) (caddr_t) - 1) {
- perror("mmap");
- exit(APEXIT_INIT);
- }
- close(fd);
- if ((errno = pthread_mutexattr_init(&mattr))) {
- perror("pthread_mutexattr_init");
- exit(APEXIT_INIT);
- }
- if ((errno = pthread_mutexattr_setpshared(&mattr,
- PTHREAD_PROCESS_SHARED))) {
- perror("pthread_mutexattr_setpshared");
- exit(APEXIT_INIT);
- }
- if ((errno = pthread_mutex_init(accept_mutex, &mattr))) {
- perror("pthread_mutex_init");
- exit(APEXIT_INIT);
- }
- sigfillset(&accept_block_mask);
- sigdelset(&accept_block_mask, SIGHUP);
- sigdelset(&accept_block_mask, SIGTERM);
- sigdelset(&accept_block_mask, SIGUSR1);
- ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
-}
-
-static void accept_mutex_on(void)
-{
- int err;
-
- if (sigprocmask(SIG_BLOCK, &accept_block_mask, &accept_previous_mask)) {
- perror("sigprocmask(SIG_BLOCK)");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
- if ((err = pthread_mutex_lock(accept_mutex))) {
- errno = err;
- perror("pthread_mutex_lock");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
- have_accept_mutex = 1;
-}
-
-static void accept_mutex_off(void)
-{
- int err;
-
- if ((err = pthread_mutex_unlock(accept_mutex))) {
- errno = err;
- perror("pthread_mutex_unlock");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
- /* There is a slight race condition right here... if we were to die right
- * now, we'd do another pthread_mutex_unlock. Now, doing that would let
- * another process into the mutex. pthread mutexes are designed to be
- * fast, as such they don't have protection for things like testing if the
- * thread owning a mutex is actually unlocking it (or even any way of
- * testing who owns the mutex).
- *
- * If we were to unset have_accept_mutex prior to releasing the mutex
- * then the race could result in the server unable to serve hits. Doing
- * it this way means that the server can continue, but an additional
- * child might be in the critical section ... at least it's still serving
- * hits.
- */
- have_accept_mutex = 0;
- if (sigprocmask(SIG_SETMASK, &accept_previous_mask, NULL)) {
- perror("sigprocmask(SIG_SETMASK)");
- clean_child_exit(1);
- }
-}
-
-#elif defined (USE_SYSVSEM_SERIALIZED_ACCEPT)
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-
-#ifdef NEED_UNION_SEMUN
-/* it makes no sense, but this isn't defined on solaris */
-union semun {
- long val;
- struct semid_ds *buf;
- ushort *array;
-};
-
-#endif
-
-static int sem_id = -1;
-static struct sembuf op_on;
-static struct sembuf op_off;
-
-/* We get a random semaphore ... the lame sysv semaphore interface
- * means we have to be sure to clean this up or else we'll leak
- * semaphores.
- */
-static void accept_mutex_cleanup(void *foo)
-{
- union semun ick;
-
- if (sem_id < 0)
- return;
- /* this is ignored anyhow */
- ick.val = 0;
- semctl(sem_id, 0, IPC_RMID, ick);
-}
-
-#define accept_mutex_child_init(x)
-
-static void accept_mutex_init(ap_context_t *p)
-{
- union semun ick;
- struct semid_ds buf;
-
- /* acquire the semaphore */
- sem_id = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600);
- if (sem_id < 0) {
- perror("semget");
- exit(APEXIT_INIT);
- }
- ick.val = 1;
- if (semctl(sem_id, 0, SETVAL, ick) < 0) {
- perror("semctl(SETVAL)");
- exit(APEXIT_INIT);
- }
- if (!getuid()) {
- /* restrict it to use only by the appropriate user_id ... not that this
- * stops CGIs from acquiring it and dinking around with it.
- */
- buf.sem_perm.uid = unixd_config.user_id;
- buf.sem_perm.gid = unixd_config.group_id;
- buf.sem_perm.mode = 0600;
- ick.buf = &buf;
- if (semctl(sem_id, 0, IPC_SET, ick) < 0) {
- perror("semctl(IPC_SET)");
- exit(APEXIT_INIT);
- }
- }
- ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
-
- /* preinitialize these */
- op_on.sem_num = 0;
- op_on.sem_op = -1;
- op_on.sem_flg = SEM_UNDO;
- op_off.sem_num = 0;
- op_off.sem_op = 1;
- op_off.sem_flg = SEM_UNDO;
-}
-
-static void accept_mutex_on(void)
-{
- while (semop(sem_id, &op_on, 1) < 0) {
- if (errno != EINTR) {
- perror("accept_mutex_on");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
- }
-}
-
-static void accept_mutex_off(void)
-{
- while (semop(sem_id, &op_off, 1) < 0) {
- if (errno != EINTR) {
- perror("accept_mutex_off");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
- }
-}
-
-#elif defined(USE_FCNTL_SERIALIZED_ACCEPT)
-static struct flock lock_it;
-static struct flock unlock_it;
-
-static int lock_fd = -1;
-
-#define accept_mutex_child_init(x)
-
-/*
- * Initialize mutex lock.
- * Must be safe to call this on a restart.
- */
-static void accept_mutex_init(ap_context_t *p)
-{
- ap_file_t *tempfile = NULL;
- lock_it.l_whence = SEEK_SET; /* from current point */
- lock_it.l_start = 0; /* -"- */
- lock_it.l_len = 0; /* until end of file */
- lock_it.l_type = F_WRLCK; /* set exclusive/write lock */
- lock_it.l_pid = 0; /* pid not actually interesting */
- unlock_it.l_whence = SEEK_SET; /* from current point */
- unlock_it.l_start = 0; /* -"- */
- unlock_it.l_len = 0; /* until end of file */
- unlock_it.l_type = F_UNLCK; /* set exclusive/write lock */
- unlock_it.l_pid = 0; /* pid not actually interesting */
-
- expand_lock_fname(p);
- ap_open(&tempfile, ap_lock_fname, APR_CREATE | APR_WRITE | APR_EXCL,
- APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD, p);
- ap_get_os_file(&lock_fd, tempfile);
- if (lock_fd == -1) {
- perror("open");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Cannot open lock file: %s", ap_lock_fname);
- exit(APEXIT_INIT);
- }
- unlink(ap_lock_fname);
-}
-
-static void accept_mutex_on(void)
-{
- int ret;
-
- while ((ret = fcntl(lock_fd, F_SETLKW, &lock_it)) < 0 && errno == EINTR) {
- /* nop */
- }
-
- if (ret < 0) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
- "fcntl: F_SETLKW: Error getting accept lock, exiting! "
- "Perhaps you need to use the LockFile directive to place "
- "your lock file on a local disk!");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-}
-
-static void accept_mutex_off(void)
-{
- int ret;
-
- while ((ret = fcntl(lock_fd, F_SETLKW, &unlock_it)) < 0 && errno == EINTR) {
- /* nop */
- }
- if (ret < 0) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
- "fcntl: F_SETLKW: Error freeing accept lock, exiting! "
- "Perhaps you need to use the LockFile directive to place "
- "your lock file on a local disk!");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-}
-
-#elif defined(USE_FLOCK_SERIALIZED_ACCEPT)
-
-static int lock_fd = -1;
-
-static ap_status_t accept_mutex_cleanup(void *foo)
-{
- unlink(ap_lock_fname);
-
- return APR_SUCCESS;
-}
-
-/*
- * Initialize mutex lock.
- * Done by each child at it's birth
- */
-static void accept_mutex_child_init(ap_context_t *p)
-{
- ap_file_t *tempfile = NULL;
- ap_status_t ret;
-
- ret=ap_open(&tempfile, ap_lock_fname, APR_WRITE, APR_UREAD|APR_UWRITE, p);
- if (ret != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, ret, server_conf,
- "Child cannot open lock file: %s", ap_lock_fname);
- clean_child_exit(APEXIT_CHILDINIT);
- }
- ap_get_os_file(&lock_fd, tempfile);
-}
-
-/*
- * Initialize mutex lock.
- * Must be safe to call this on a restart.
- */
-static void accept_mutex_init(ap_context_t *p)
-{
- ap_file_t *tempfile = NULL;
- ap_status_t ret;
-
- expand_lock_fname(p);
- unlink(ap_lock_fname);
- ret=ap_open(&tempfile, ap_lock_fname, APR_CREATE|APR_WRITE|APR_EXCL,
- APR_UREAD|APR_UWRITE, p);
- if (ret != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, ret, server_conf,
- "Parent cannot open lock file: %s", ap_lock_fname);
- exit(APEXIT_INIT);
- }
- ap_get_os_file(&lock_fd, tempfile);
- ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
-}
-
-static void accept_mutex_on(void)
-{
- int ret;
-
- while ((ret = flock(lock_fd, LOCK_EX)) < 0 && errno == EINTR)
- continue;
-
- if (ret < 0) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
- "flock: LOCK_EX: Error getting accept lock. Exiting!");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-}
-
-static void accept_mutex_off(void)
-{
- if (flock(lock_fd, LOCK_UN) < 0) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
- "flock: LOCK_UN: Error freeing accept lock. Exiting!");
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-}
-
-#elif defined(USE_OS2SEM_SERIALIZED_ACCEPT)
-
-static HMTX lock_sem = -1;
-
-static void accept_mutex_cleanup(void *foo)
-{
- DosReleaseMutexSem(lock_sem);
- DosCloseMutexSem(lock_sem);
-}
-
-/*
- * Initialize mutex lock.
- * Done by each child at it's birth
- */
-static void accept_mutex_child_init(ap_context_t *p)
-{
- int rc = DosOpenMutexSem(NULL, &lock_sem);
-
- if (rc != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, server_conf,
- "Child cannot open lock semaphore, rc=%d", rc);
- clean_child_exit(APEXIT_CHILDINIT);
- } else {
- ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
- }
-}
-
-/*
- * Initialize mutex lock.
- * Must be safe to call this on a restart.
- */
-static void accept_mutex_init(ap_context_t *p)
-{
- int rc = DosCreateMutexSem(NULL, &lock_sem, DC_SEM_SHARED, FALSE);
-
- if (rc != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, server_conf,
- "Parent cannot create lock semaphore, rc=%d", rc);
- exit(APEXIT_INIT);
- }
-
- ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
-}
-
-static void accept_mutex_on(void)
-{
- int rc = DosRequestMutexSem(lock_sem, SEM_INDEFINITE_WAIT);
-
- if (rc != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, server_conf,
- "OS2SEM: Error %d getting accept lock. Exiting!", rc);
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-}
-
-static void accept_mutex_off(void)
-{
- int rc = DosReleaseMutexSem(lock_sem);
-
- if (rc != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, server_conf,
- "OS2SEM: Error %d freeing accept lock. Exiting!", rc);
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-}
-
-#elif defined(USE_TPF_CORE_SERIALIZED_ACCEPT)
-
-static int tpf_core_held;
-
-static void accept_mutex_cleanup(void *foo)
-{
- if(tpf_core_held)
- coruc(RESOURCE_KEY);
-}
-
-#define accept_mutex_init(x)
-
-static void accept_mutex_child_init(ap_context_t *p)
-{
- ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
- tpf_core_held = 0;
-}
-
-static void accept_mutex_on(void)
-{
- corhc(RESOURCE_KEY);
- tpf_core_held = 1;
- ap_check_signals();
-}
-
-static void accept_mutex_off(void)
-{
- coruc(RESOURCE_KEY);
- tpf_core_held = 0;
- ap_check_signals();
-}
-
-#else
-/* Default --- no serialization. Other methods *could* go here,
- * as #elifs...
- */
-#if !defined(MULTITHREAD)
-/* Multithreaded systems don't complete between processes for
- * the sockets. */
-#define NO_SERIALIZED_ACCEPT
-#define accept_mutex_child_init(x)
-#define accept_mutex_init(x)
-#define accept_mutex_on()
-#define accept_mutex_off()
-#endif
-#endif
-
-/* On some architectures it's safe to do unserialized accept()s in the single
- * Listen case. But it's never safe to do it in the case where there's
- * multiple Listen statements. Define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
- * when it's safe in the single Listen case.
- */
-#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-#define SAFE_ACCEPT(stmt) do {if (ap_listeners->next) {stmt;}} while(0)
-#else
-#define SAFE_ACCEPT(stmt) do {stmt;} while(0)
-#endif
-
-
-/*****************************************************************
- * dealing with other children
- */
-
-#ifdef HAS_OTHER_CHILD
-API_EXPORT(void) ap_register_other_child(int pid,
- void (*maintenance) (int reason, void *, ap_wait_t status),
- void *data, int write_fd)
-{
- other_child_rec *ocr;
-
- ocr = ap_palloc(pconf, sizeof(*ocr));
- ocr->pid = pid;
- ocr->maintenance = maintenance;
- ocr->data = data;
- ocr->write_fd = write_fd;
- ocr->next = other_children;
- other_children = ocr;
-}
-
-/* note that 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.
- */
-API_EXPORT(void) ap_unregister_other_child(void *data)
-{
- other_child_rec **pocr, *nocr;
-
- for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
- if ((*pocr)->data == data) {
- nocr = (*pocr)->next;
- (*(*pocr)->maintenance) (OC_REASON_UNREGISTER, (*pocr)->data, -1);
- *pocr = nocr;
- /* XXX: um, well we've just wasted some space in pconf ? */
- return;
- }
- }
-}
-
-/* test to ensure that the write_fds are all still writable, otherwise
- * invoke the maintenance functions as appropriate */
-static void probe_writable_fds(void)
-{
- fd_set writable_fds;
- int fd_max;
- other_child_rec *ocr, *nocr;
- struct timeval tv;
- int rc;
-
- if (other_children == NULL)
- return;
-
- fd_max = 0;
- FD_ZERO(&writable_fds);
- do {
- for (ocr = other_children; ocr; ocr = ocr->next) {
- if (ocr->write_fd == -1)
- continue;
- FD_SET(ocr->write_fd, &writable_fds);
- if (ocr->write_fd > fd_max) {
- fd_max = ocr->write_fd;
- }
- }
- if (fd_max == 0)
- return;
-
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
- } while (rc == -1 && errno == EINTR);
-
- if (rc == -1) {
- /* XXX: uhh this could be really bad, we could have a bad file
- * descriptor due to a bug in one of the maintenance routines */
- ap_log_unixerr("probe_writable_fds", "select",
- "could not probe writable fds", server_conf);
- return;
- }
- if (rc == 0)
- return;
-
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->write_fd == -1)
- continue;
- if (FD_ISSET(ocr->write_fd, &writable_fds))
- continue;
- (*ocr->maintenance) (OC_REASON_UNWRITABLE, ocr->data, -1);
- }
-}
-
-/* possibly reap an other_child, return 0 if yes, -1 if not */
-static int reap_other_child(int pid, ap_wait_t status)
-{
- other_child_rec *ocr, *nocr;
-
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->pid != pid)
- continue;
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
- return 0;
- }
- return -1;
-}
-#endif
-
-#if APR_HAS_SHARED_MEMORY
-#include "apr_shmem.h"
-
-static ap_shmem_t *scoreboard_shm = NULL;
-
-static ap_status_t cleanup_shared_mem(void *d)
-{
- mm_free(scoreboard_shm, ap_scoreboard_image);
- ap_scoreboard_image = NULL;
- ap_shm_destroy(scoreboard_shm);
-}
-
-static void setup_shared_mem(ap_context_t *p)
-{
- char buf[512];
- const char *fname;
-
- fname = ap_server_root_relative(p, ap_scoreboard_fname);
- if (ap_shm_init(&scoreboard_shm, SCOREBOARD_SIZE + 40, fname) != APR_SUCCESS) {
- ap_snprintf(buf, sizeof(buf), "%s: could not open(create) scoreboard",
- ap_server_argv0);
- perror(buf);
- exit(APEXIT_INIT);
- }
- ap_scoreboard_image = ap_shm_malloc(scoreboard_shm, SCOREBOARD_SIZE);
- if (ap_scoreboard_image == NULL) {
- ap_snprintf(buf, sizeof(buf), "%s: cannot allocate scoreboard",
- ap_server_argv0);
- perror(buf);
- ap_shm_destroy(scoreboard_shm);
- exit(APEXIT_INIT);
- }
- ap_register_cleanup(p, NULL, cleanup_shared_mem, ap_null_cleanup);
- ap_scoreboard_image->global.running_generation = 0;
-}
-
-static void reopen_scoreboard(ap_context_t *p)
-{
-}
-#endif
-
-/* Called by parent process */
-static void reinit_scoreboard(ap_context_t *p)
-{
- int running_gen = 0;
- if (ap_scoreboard_image)
- running_gen = ap_scoreboard_image->global.running_generation;
-
- if (ap_scoreboard_image == NULL) {
- setup_shared_mem(p);
- }
- memset(ap_scoreboard_image, 0, SCOREBOARD_SIZE);
- ap_scoreboard_image->global.running_generation = running_gen;
-}
-
-
-/* Routines called to deal with the scoreboard image
- * --- note that we do *not* need write locks, since update_child_status
- * only updates a *single* record in place, and only one process writes to
- * a given scoreboard slot at a time (either the child process owning that
- * slot, or the parent, noting that the child has died).
- *
- * As a final note --- setting the score entry to getpid() is always safe,
- * since when the parent is writing an entry, it's only noting SERVER_DEAD
- * anyway.
- */
-ap_inline void ap_sync_scoreboard_image(void)
-{
-#ifdef SCOREBOARD_FILE
- lseek(scoreboard_fd, 0L, 0);
- force_read(scoreboard_fd, ap_scoreboard_image, sizeof(*ap_scoreboard_image))
-;
-#endif
-}
-
-API_EXPORT(int) ap_exists_scoreboard_image(void)
-{
- return (ap_scoreboard_image ? 1 : 0);
-}
-
-static ap_inline void put_scoreboard_info(int child_num,
- short_score *new_score_rec)
-{
-#ifdef SCOREBOARD_FILE
- lseek(scoreboard_fd, (long) child_num * sizeof(short_score), 0);
- force_write(scoreboard_fd, new_score_rec, sizeof(short_score));
-#endif
-}
-
-int ap_update_child_status(int child_num, int status, request_rec *r)
-{
- int old_status;
- short_score *ss;
-
- if (child_num < 0)
- return -1;
-
- ap_check_signals();
-
- ss = &ap_scoreboard_image->servers[child_num];
- old_status = ss->status;
- ss->status = status;
-
- if (ap_extended_status) {
- if (status == SERVER_READY || status == SERVER_DEAD) {
- /*
- * Reset individual counters
- */
- if (status == SERVER_DEAD) {
- ss->my_access_count = 0L;
- ss->my_bytes_served = 0L;
- }
- ss->conn_count = (unsigned short) 0;
- ss->conn_bytes = (unsigned long) 0;
- }
- if (r) {
- conn_rec *c = r->connection;
- ap_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config,
- REMOTE_NOLOOKUP), sizeof(ss->client));
- if (r->the_request == NULL) {
- ap_cpystrn(ss->request, "NULL", sizeof(ss->request));
- } else if (r->parsed_uri.password == NULL) {
- ap_cpystrn(ss->request, r->the_request, sizeof(ss->request));
- } else {
- /* Don't reveal the password in the server-status view */
- ap_cpystrn(ss->request, ap_pstrcat(r->pool, r->method, " ",
- ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD),
- r->assbackwards ? NULL : " ", r->protocol, NULL),
- sizeof(ss->request));
- }
- ss->vhostrec = r->server;
- }
- }
- if (status == SERVER_STARTING && r == NULL) {
- /* clean up the slot's vhostrec pointer (maybe re-used)
- * and mark the slot as belonging to a new generation.
- */
- ss->vhostrec = NULL;
- ap_scoreboard_image->parent[child_num].generation = ap_my_generation;
-#ifdef SCOREBOARD_FILE
- lseek(scoreboard_fd, XtOffsetOf(scoreboard, parent[child_num]), 0);
- force_write(scoreboard_fd, &ap_scoreboard_image->parent[child_num],
- sizeof(parent_score));
-#endif
- }
- put_scoreboard_info(child_num, ss);
-
- return old_status;
-}
-
-static void update_scoreboard_global(void)
-{
-#ifdef SCOREBOARD_FILE
- lseek(scoreboard_fd,
- (char *) &ap_scoreboard_image->global -(char *) ap_scoreboard_image, 0);
- force_write(scoreboard_fd, &ap_scoreboard_image->global,
- sizeof ap_scoreboard_image->global);
-#endif
-}
-
-void ap_time_process_request(int child_num, int status)
-{
- short_score *ss;
-#if !defined(HAVE_GETTIMEOFDAY) && defined(HAVE_TIMES)
- struct tms tms_blk;
-#endif
-
- if (child_num < 0)
- return;
-
- ap_sync_scoreboard_image();
- ss = &ap_scoreboard_image->servers[child_num];
-
- if (status == START_PREQUEST) {
-#if !defined(HAVE_GETTIMEOFDAY)
-#ifdef HAVE_TIMES
- if ((ss->start_time = times(&tms_blk)) == -1)
-#endif /* HAVE_TIMES */
- ss->start_time = (clock_t) 0;
-#else
- if (gettimeofday(&ss->start_time, (struct timezone *) 0) < 0)
- ss->start_time.tv_sec =
- ss->start_time.tv_usec = 0L;
-#endif
- }
- else if (status == STOP_PREQUEST) {
-#if !defined(HAVE_GETTIMEOFDAY)
-#ifdef HAVE_TIMES
- if ((ss->stop_time = times(&tms_blk)) == -1)
-#endif
- ss->stop_time = ss->start_time = (clock_t) 0;
-#else
- if (gettimeofday(&ss->stop_time, (struct timezone *) 0) < 0)
- ss->stop_time.tv_sec =
- ss->stop_time.tv_usec =
- ss->start_time.tv_sec =
- ss->start_time.tv_usec = 0L;
-#endif
-
- }
-
- put_scoreboard_info(child_num, ss);
-}
-
-/*
-static void increment_counts(int child_num, request_rec *r)
-{
- long int bs = 0;
- short_score *ss;
-
- ap_sync_scoreboard_image();
- ss = &ap_scoreboard_image->servers[child_num];
-
- if (r->sent_bodyct)
- ap_bgetopt(r->connection->client, BO_BYTECT, &bs);
-
-#ifdef HAVE_TIMES
- times(&ss->times);
-#endif
- ss->access_count++;
- ss->my_access_count++;
- ss->conn_count++;
- ss->bytes_served += (unsigned long) bs;
- ss->my_bytes_served += (unsigned long) bs;
- ss->conn_bytes += (unsigned long) bs;
-
- put_scoreboard_info(child_num, ss);
-}
-*/
-
-static int find_child_by_pid(int pid)
-{
- int i;
-
- for (i = 0; i < max_daemons_limit; ++i)
- if (ap_scoreboard_image->parent[i].pid == pid)
- return i;
-
- return -1;
-}
-
-static void reclaim_child_processes(int terminate)
-{
-#ifndef MULTITHREAD
- int i, status;
- long int waittime = 1024 * 16; /* in usecs */
- struct timeval tv;
- int waitret, tries;
- int not_dead_yet;
-#ifdef HAS_OTHER_CHILD
- other_child_rec *ocr, *nocr;
-#endif
-
- ap_sync_scoreboard_image();
-
- for (tries = terminate ? 4 : 1; tries <= 9; ++tries) {
- /* don't want to hold up progress any more than
- * necessary, but we need to allow children a few moments to exit.
- * Set delay with an exponential backoff.
- */
- tv.tv_sec = waittime / 1000000;
- tv.tv_usec = waittime % 1000000;
- waittime = waittime * 4;
- ap_select(0, NULL, NULL, NULL, &tv);
-
- /* now see who is done */
- not_dead_yet = 0;
- for (i = 0; i < max_daemons_limit; ++i) {
- int pid = ap_scoreboard_image->parent[i].pid;
-
- if (pid == my_pid || pid == 0)
- continue;
-
- waitret = waitpid(pid, &status, WNOHANG);
- if (waitret == pid || waitret == -1) {
- ap_scoreboard_image->parent[i].pid = 0;
- continue;
- }
- ++not_dead_yet;
- switch (tries) {
- case 1: /* 16ms */
- case 2: /* 82ms */
- break;
- case 3: /* 344ms */
- /* perhaps it missed the SIGHUP, lets try again */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
- 0, server_conf,
- "child process %d did not exit, sending another SIGHUP",
- pid);
- kill(pid, SIGHUP);
- waittime = 1024 * 16;
- break;
- case 4: /* 16ms */
- case 5: /* 82ms */
- case 6: /* 344ms */
- break;
- case 7: /* 1.4sec */
- /* ok, now it's being annoying */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
- 0, server_conf,
- "child process %d still did not exit, sending a SIGTERM",
- pid);
- kill(pid, SIGTERM);
- break;
- case 8: /* 6 sec */
- /* die child scum */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
- "child process %d still did not exit, sending a SIGKILL",
- pid);
- kill(pid, SIGKILL);
- break;
- case 9: /* 14 sec */
- /* gave it our best shot, but alas... If this really
- * is a child we are trying to kill and it really hasn't
- * exited, we will likely fail to bind to the port
- * after the restart.
- */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
- "could not make child process %d exit, "
- "attempting to continue anyway", pid);
- break;
- }
- }
-#ifdef HAS_OTHER_CHILD
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->pid == -1)
- continue;
-
- waitret = waitpid(ocr->pid, &status, WNOHANG);
- if (waitret == ocr->pid) {
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
- }
- else if (waitret == 0) {
- (*ocr->maintenance) (OC_REASON_RESTART, ocr->data, -1);
- ++not_dead_yet;
- }
- else if (waitret == -1) {
- /* uh what the heck? they didn't call unregister? */
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_LOST, ocr->data, -1);
- }
- }
-#endif
- if (!not_dead_yet) {
- /* nothing left to wait for */
- break;
- }
- }
-#endif /* ndef MULTITHREAD */
-}
-
-
-#if defined(NEED_WAITPID)
-/*
- Systems without a real waitpid sometimes lose a child's exit while waiting
- for another. Search through the scoreboard for missing children.
- */
-int reap_children(ap_wait_t *status)
-{
- int n, pid;
-
- for (n = 0; n < max_daemons_limit; ++n) {
- ap_sync_scoreboard_image();
- if (ap_scoreboard_image->servers[n].status != SERVER_DEAD &&
- kill((pid = ap_scoreboard_image->parent[n].pid), 0) == -1) {
- ap_update_child_status(n, SERVER_DEAD, NULL);
- /* just mark it as having a successful exit status */
- bzero((char *) status, sizeof(ap_wait_t));
- return(pid);
- }
- }
- return 0;
-}
-#endif
-
-/* Finally, this routine is used by the caretaker process to wait for
- * a while...
- */
-
-/* number of calls to wait_or_timeout between writable probes */
-#ifndef INTERVAL_OF_WRITABLE_PROBES
-#define INTERVAL_OF_WRITABLE_PROBES 10
-#endif
-static int wait_or_timeout_counter;
-
-static int wait_or_timeout(ap_wait_t *status)
-{
- struct timeval tv;
- int ret;
-
- ++wait_or_timeout_counter;
- if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
- wait_or_timeout_counter = 0;
-#ifdef HAS_OTHER_CHILD
- probe_writable_fds();
-#endif
- }
- ret = waitpid(-1, status, WNOHANG);
- if (ret == -1 && errno == EINTR) {
- return -1;
- }
- if (ret > 0) {
- return ret;
- }
-#ifdef NEED_WAITPID
- if ((ret = reap_children(status)) > 0) {
- return ret;
- }
-#endif
- tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000;
- tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000;
- ap_select(0, NULL, NULL, NULL, &tv);
- return -1;
-}
-
-/* handle all varieties of core dumping signals */
-static void sig_coredump(int sig)
-{
- chdir(ap_coredump_dir);
- signal(sig, SIG_DFL);
- kill(getpid(), sig);
- /* At this point we've got sig blocked, because we're still inside
- * the signal handler. When we leave the signal handler it will
- * be unblocked, and we'll take the signal... and coredump or whatever
- * is appropriate for this particular Unix. In addition the parent
- * will see the real signal we received -- whereas if we called
- * abort() here, the parent would only see SIGABRT.
- */
-}
-
-/*****************************************************************
- * Connection structures and accounting...
- */
-
-static void just_die(int sig)
-{
- clean_child_exit(0);
-}
-
-static int volatile deferred_die;
-static int volatile usr1_just_die;
-
-static void usr1_handler(int sig)
-{
- if (usr1_just_die) {
- just_die(sig);
- }
- deferred_die = 1;
-}
-
-/* volatile just in case */
-static int volatile shutdown_pending;
-static int volatile restart_pending;
-static int volatile is_graceful;
-ap_generation_t volatile ap_my_generation=0;
-
-static void sig_term(int sig)
-{
- if (shutdown_pending == 1) {
- /* Um, is this _probably_ not an error, if the user has
- * tried to do a shutdown twice quickly, so we won't
- * worry about reporting it.
- */
- return;
- }
- shutdown_pending = 1;
-}
-
-static void restart(int sig)
-{
- if (restart_pending == 1) {
- /* Probably not an error - don't bother reporting it */
- return;
- }
- restart_pending = 1;
- if (is_graceful = sig == SIGUSR1) {
- ap_kill_cleanup(pconf, NULL, cleanup_shared_mem);
- }
-}
-
-static void set_signals(void)
-{
-#ifndef NO_USE_SIGACTION
- struct sigaction sa;
-
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
-
- if (!one_process) {
- sa.sa_handler = sig_coredump;
-#if defined(SA_ONESHOT)
- sa.sa_flags = SA_ONESHOT;
-#elif defined(SA_RESETHAND)
- sa.sa_flags = SA_RESETHAND;
-#endif
- if (sigaction(SIGSEGV, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGSEGV)");
-#ifdef SIGBUS
- if (sigaction(SIGBUS, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGBUS)");
-#endif
-#ifdef SIGABORT
- if (sigaction(SIGABORT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABORT)");
-#endif
-#ifdef SIGABRT
- if (sigaction(SIGABRT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABRT)");
-#endif
-#ifdef SIGILL
- if (sigaction(SIGILL, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGILL)");
-#endif
- sa.sa_flags = 0;
- }
- sa.sa_handler = sig_term;
- if (sigaction(SIGTERM, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGTERM)");
-#ifdef SIGINT
- if (sigaction(SIGINT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGINT)");
-#endif
-#ifdef SIGXCPU
- sa.sa_handler = SIG_DFL;
- if (sigaction(SIGXCPU, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXCPU)");
-#endif
-#ifdef SIGXFSZ
- sa.sa_handler = SIG_DFL;
- if (sigaction(SIGXFSZ, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXFSZ)");
-#endif
-#ifdef SIGPIPE
- sa.sa_handler = SIG_IGN;
- if (sigaction(SIGPIPE, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGPIPE)");
-#endif
-
- /* we want to ignore HUPs and USR1 while we're busy processing one */
- sigaddset(&sa.sa_mask, SIGHUP);
- sigaddset(&sa.sa_mask, SIGUSR1);
- sa.sa_handler = restart;
- if (sigaction(SIGHUP, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGHUP)");
- if (sigaction(SIGUSR1, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGUSR1)");
-#else
- if (!one_process) {
- signal(SIGSEGV, sig_coredump);
-#ifdef SIGBUS
- signal(SIGBUS, sig_coredump);
-#endif /* SIGBUS */
-#ifdef SIGABORT
- signal(SIGABORT, sig_coredump);
-#endif /* SIGABORT */
-#ifdef SIGABRT
- signal(SIGABRT, sig_coredump);
-#endif /* SIGABRT */
-#ifdef SIGILL
- signal(SIGILL, sig_coredump);
-#endif /* SIGILL */
-#ifdef SIGXCPU
- signal(SIGXCPU, SIG_DFL);
-#endif /* SIGXCPU */
-#ifdef SIGXFSZ
- signal(SIGXFSZ, SIG_DFL);
-#endif /* SIGXFSZ */
- }
-
- signal(SIGTERM, sig_term);
-#ifdef SIGHUP
- signal(SIGHUP, restart);
-#endif /* SIGHUP */
-#ifdef SIGUSR1
- signal(SIGUSR1, restart);
-#endif /* SIGUSR1 */
-#ifdef SIGPIPE
- signal(SIGPIPE, SIG_IGN);
-#endif /* SIGPIPE */
-
-#endif
-}
-
-#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
-static void sock_disable_nagle(int s)
-{
- /* The Nagle algorithm says that we should delay sending partial
- * packets in hopes of getting more data. We don't want to do
- * this; we are not telnet. There are bad interactions between
- * persistent connections and Nagle's algorithm that have very severe
- * performance penalties. (Failing to disable Nagle is not much of a
- * problem with simple HTTP.)
- *
- * In spite of these problems, failure here is not a shooting offense.
- */
- int just_say_no = 1;
-
- if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &just_say_no,
- sizeof(int)) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf,
- "setsockopt: (TCP_NODELAY)");
- }
-}
-
-#else
-#define sock_disable_nagle(s) /* NOOP */
-#endif
-
-
-/*****************************************************************
- * Child process main loop.
- * The following vars are static to avoid getting clobbered by longjmp();
- * they are really private to child_main.
- */
-
-static int srv;
-static ap_socket_t *csd;
-static int requests_this_child;
-static fd_set main_fds;
-
-int ap_graceful_stop_signalled(void)
-{
- ap_sync_scoreboard_image();
- if (deferred_die ||
- ap_scoreboard_image->global.running_generation != ap_my_generation) {
- return 1;
- }
- return 0;
-}
-
-static void child_main(int child_num_arg)
-{
-/* XXX replace int with NET_SIZE_T, this is defined in ap_config.h which
- has macros we can't make visible to this file, but it is the original
- type for clen.
-*/
- int clen;
- struct sockaddr sa_server;
- struct sockaddr sa_client;
- ap_listen_rec *lr;
- ap_listen_rec *last_lr;
- ap_listen_rec *first_lr;
- ap_context_t *ptrans;
- conn_rec *current_conn;
- ap_iol *iol;
- ap_status_t stat;
- int sockdes;
-
- my_pid = getpid();
- csd = NULL;
- my_child_num = child_num_arg;
- requests_this_child = 0;
- last_lr = NULL;
-
- /* Get a sub context for global allocations in this child, so that
- * we can have cleanups occur when the child exits.
- */
- ap_create_context(&pchild, pconf);
-
- ap_create_context(&ptrans, pchild);
-
- /* needs to be done before we switch UIDs so we have permissions */
- reopen_scoreboard(pchild);
- SAFE_ACCEPT(accept_mutex_child_init(pchild));
-
- if (unixd_setup_child()) {
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-
- ap_child_init_hook(pchild, server_conf);
-
- (void) ap_update_child_status(my_child_num, SERVER_READY, (request_rec *) NULL);
-
- signal(SIGHUP, just_die);
- signal(SIGTERM, just_die);
-
-#ifdef OS2
-/* Stop Ctrl-C/Ctrl-Break signals going to child processes */
- {
- unsigned long ulTimes;
- DosSetSignalExceptionFocus(0, &ulTimes);
- }
-#endif
-
- while (!ap_graceful_stop_signalled()) {
- BUFF *conn_io;
-
- /* Prepare to receive a SIGUSR1 due to graceful restart so that
- * we can exit cleanly.
- */
- usr1_just_die = 1;
- signal(SIGUSR1, usr1_handler);
-
- /*
- * (Re)initialize this child to a pre-connection state.
- */
-
- current_conn = NULL;
-
- ap_clear_pool(ptrans);
-
- if ((ap_max_requests_per_child > 0
- && requests_this_child++ >= ap_max_requests_per_child)) {
- clean_child_exit(0);
- }
-
- (void) ap_update_child_status(my_child_num, SERVER_READY, (request_rec *) NULL);
-
- /*
- * Wait for an acceptable connection to arrive.
- */
-
- /* Lock around "accept", if necessary */
- SAFE_ACCEPT(accept_mutex_on());
-
- for (;;) {
- if (ap_listeners->next) {
- /* more than one socket */
- memcpy(&main_fds, &listenfds, sizeof(fd_set));
- srv = ap_select(listenmaxfd + 1, &main_fds, NULL, NULL, NULL);
-
- if (srv < 0 && errno != EINTR) {
- /* Single Unix documents select as returning errnos
- * EBADF, EINTR, and EINVAL... and in none of those
- * cases does it make sense to continue. In fact
- * on Linux 2.0.x we seem to end up with EFAULT
- * occasionally, and we'd loop forever due to it.
- */
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf, "select: (listen)");
- clean_child_exit(1);
- }
-
- if (srv <= 0)
- continue;
-
- /* we remember the last_lr we searched last time around so that
- we don't end up starving any particular listening socket */
- if (last_lr == NULL) {
- lr = ap_listeners;
- }
- else {
- lr = last_lr->next;
- if (!lr)
- lr = ap_listeners;
- }
- first_lr=lr;
- do {
- ap_get_os_sock(&sockdes, lr->sd);
- if (FD_ISSET(sockdes, &main_fds))
- goto got_listener;
- lr = lr->next;
- if (!lr)
- lr = ap_listeners;
- }
- while (lr != first_lr);
- /* FIXME: if we get here, something bad has happened, and we're
- probably gonna spin forever.
- */
- continue;
- got_listener:
- last_lr = lr;
- sd = lr->sd;
- }
- else {
- /* only one socket, just pretend we did the other stuff */
- sd = ap_listeners->sd;
- }
-
- /* if we accept() something we don't want to die, so we have to
- * defer the exit
- */
- usr1_just_die = 0;
- for (;;) {
- if (deferred_die) {
- /* we didn't get a socket, and we were told to die */
- clean_child_exit(0);
- }
- clen = sizeof(sa_client);
- stat = ap_accept(&csd, sd, ptrans);
- if (stat == APR_SUCCESS || stat != APR_EINTR)
- break;
- }
-
- if (stat == APR_SUCCESS)
- break; /* We have a socket ready for reading */
- else {
-
-/* TODO: this accept result handling stuff should be abstracted...
- * it's already out of date between the various unix mpms
- */
- /* Our old behaviour here was to continue after accept()
- * errors. But this leads us into lots of troubles
- * because most of the errors are quite fatal. For
- * example, EMFILE can be caused by slow descriptor
- * leaks (say in a 3rd party module, or libc). It's
- * foolish for us to continue after an EMFILE. We also
- * seem to tickle kernel bugs on some platforms which
- * lead to never-ending loops here. So it seems best
- * to just exit in most cases.
- */
- switch (errno) {
-#ifdef EPROTO
- /* EPROTO on certain older kernels really means
- * ECONNABORTED, so we need to ignore it for them.
- * See discussion in new-httpd archives nh.9701
- * search for EPROTO.
- *
- * Also see nh.9603, search for EPROTO:
- * 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.
- */
- case EPROTO:
-#endif
-#ifdef ECONNABORTED
- case ECONNABORTED:
-#endif
- /* Linux generates the rest of these, other tcp
- * stacks (i.e. bsd) tend to hide them behind
- * getsockopt() interfaces. They occur when
- * the net goes sour or the client disconnects
- * after the three-way handshake has been done
- * in the kernel but before userland has picked
- * up the socket.
- */
-#ifdef ECONNRESET
- case ECONNRESET:
-#endif
-#ifdef ETIMEDOUT
- case ETIMEDOUT:
-#endif
-#ifdef EHOSTUNREACH
- case EHOSTUNREACH:
-#endif
-#ifdef ENETUNREACH
- case ENETUNREACH:
-#endif
- break;
-#ifdef ENETDOWN
- case ENETDOWN:
- /*
- * When the network layer has been shut down, there
- * is not much use in simply exiting: the parent
- * would simply re-create us (and we'd fail again).
- * Use the CHILDFATAL code to tear the server down.
- * @@@ Martin's idea for possible improvement:
- * A different approach would be to define
- * a new APEXIT_NETDOWN exit code, the reception
- * of which would make the parent shutdown all
- * children, then idle-loop until it detected that
- * the network is up again, and restart the children.
- * Ben Hyde noted that temporary ENETDOWN situations
- * occur in mobile IP.
- */
- ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
- "accept: giving up.");
- clean_child_exit(APEXIT_CHILDFATAL);
-#endif /*ENETDOWN*/
-
-#ifdef TPF
- case EINACT:
- ap_log_error(APLOG_MARK, APLOG_EMERG, errno, server_conf,
- "offload device inactive");
- clean_child_exit(APEXIT_CHILDFATAL);
- break;
- default:
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
- "select/accept error (%u)", errno);
- clean_child_exit(APEXIT_CHILDFATAL);
-#else
- default:
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf,
- "accept: (client socket)");
- clean_child_exit(1);
-#endif
- }
- }
-
- if (ap_graceful_stop_signalled()) {
- clean_child_exit(0);
- }
- usr1_just_die = 1;
- }
-
- SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */
-
-#ifdef TPF
- if (csd == 0) /* 0 is invalid socket for TPF */
- continue;
-#endif
-
- /* We've got a socket, let's at least process one request off the
- * socket before we accept a graceful restart request. We set
- * the signal to ignore because we don't want to disturb any
- * third party code.
- */
- signal(SIGUSR1, SIG_IGN);
- /*
- * We now have a connection, so set it up with the appropriate
- * socket options, file descriptors, and read/write buffers.
- */
-
- ap_get_os_sock(&sockdes, csd);
-
- clen = sizeof(sa_server);
- if (getsockname(sockdes, &sa_server, &clen) < 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf, "getsockname");
- ap_close_socket(csd);
- continue;
- }
-
- sock_disable_nagle(sockdes);
-
- iol = unix_attach_socket(csd);
- if (iol == NULL) {
- if (errno == EBADF) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, NULL,
- "filedescriptor (%u) larger than FD_SETSIZE (%u) "
- "found, you probably need to rebuild Apache with a "
- "larger FD_SETSIZE", sockdes, FD_SETSIZE);
- }
- else {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, NULL,
- "error attaching to socket");
- }
- ap_close_socket(csd);
- continue;
- }
-
- (void) ap_update_child_status(my_child_num, SERVER_BUSY_READ,
- (request_rec *) NULL);
-
- conn_io = ap_bcreate(ptrans, B_RDWR);
-
- ap_bpush_iol(conn_io, iol);
-
- current_conn = ap_new_apr_connection(ptrans, server_conf, conn_io, csd,
- my_child_num);
-
- ap_process_connection(current_conn);
- }
-}
-
-
-static int make_child(server_rec *s, int slot, time_t now)
-{
- int pid;
-
- if (slot + 1 > max_daemons_limit) {
- max_daemons_limit = slot + 1;
- }
-
- if (one_process) {
- signal(SIGHUP, just_die);
- signal(SIGINT, just_die);
-#ifdef SIGQUIT
- signal(SIGQUIT, SIG_DFL);
-#endif
- signal(SIGTERM, just_die);
- child_main(slot);
- }
-
- (void) ap_update_child_status(slot, SERVER_STARTING, (request_rec *) NULL);
-
-
-#ifdef _OSD_POSIX
- /* BS2000 requires a "special" version of fork() before a setuid() call */
- if ((pid = os_fork(unixd_config.user_name)) == -1) {
-#elif defined(TPF)
- if ((pid = os_fork(s, slot)) == -1) {
-#else
- if ((pid = fork()) == -1) {
-#endif
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, s, "fork: Unable to fork new process");
-
- /* fork didn't succeed. Fix the scoreboard or else
- * it will say SERVER_STARTING forever and ever
- */
- (void) ap_update_child_status(slot, SERVER_DEAD, (request_rec *) NULL);
-
- /* In case system resources are maxxed out, we don't want
- Apache running away with the CPU trying to fork over and
- over and over again. */
- sleep(10);
-
- return -1;
- }
-
- if (!pid) {
-#ifdef AIX_BIND_PROCESSOR
-/* by default AIX binds to a single processor
- * this bit unbinds children which will then bind to another cpu
- */
-#include <sys/processor.h>
- int status = bindprocessor(BINDPROCESS, (int)getpid(),
- PROCESSOR_CLASS_ANY);
- if (status != OK) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, server_conf,
- "processor unbind failed %d", status);
- }
-#endif
- RAISE_SIGSTOP(MAKE_CHILD);
- /* Disable the restart signal handlers and enable the just_die stuff.
- * Note that since restart() just notes that a restart has been
- * requested there's no race condition here.
- */
- signal(SIGHUP, just_die);
- signal(SIGUSR1, just_die);
- signal(SIGTERM, just_die);
- child_main(slot);
- }
-
- ap_scoreboard_image->parent[slot].pid = pid;
-#ifdef SCOREBOARD_FILE
- lseek(scoreboard_fd, XtOffsetOf(scoreboard, parent[slot]), 0);
- force_write(scoreboard_fd, &ap_scoreboard_image->parent[slot],
- sizeof(parent_score));
-#endif
-
- return 0;
-}
-
-
-/* start up a bunch of children */
-static void startup_children(int number_to_start)
-{
- int i;
- time_t now = time(0);
-
- for (i = 0; number_to_start && i < ap_daemons_limit; ++i) {
- if (ap_scoreboard_image->servers[i].status != SERVER_DEAD) {
- continue;
- }
- if (make_child(server_conf, i, now) < 0) {
- break;
- }
- --number_to_start;
- }
-}
-
-
-/*
- * idle_spawn_rate is the number of children that will be spawned on the
- * next maintenance cycle if there aren't enough idle servers. It is
- * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by
- * without the need to spawn.
- */
-static int idle_spawn_rate = 1;
-#ifndef MAX_SPAWN_RATE
-#define MAX_SPAWN_RATE (32)
-#endif
-static int hold_off_on_exponential_spawning;
-
-static void perform_idle_server_maintenance(void)
-{
- int i;
- int to_kill;
- int idle_count;
- short_score *ss;
- time_t now = time(0);
- int free_length;
- int free_slots[MAX_SPAWN_RATE];
- int last_non_dead;
- int total_non_dead;
-
- /* initialize the free_list */
- free_length = 0;
-
- to_kill = -1;
- idle_count = 0;
- last_non_dead = -1;
- total_non_dead = 0;
-
- ap_sync_scoreboard_image();
- for (i = 0; i < ap_daemons_limit; ++i) {
- int status;
-
- if (i >= max_daemons_limit && free_length == idle_spawn_rate)
- break;
- ss = &ap_scoreboard_image->servers[i];
- status = ss->status;
- if (status == SERVER_DEAD) {
- /* try to keep children numbers as low as possible */
- if (free_length < idle_spawn_rate) {
- free_slots[free_length] = i;
- ++free_length;
- }
- }
- else {
- /* We consider a starting server as idle because we started it
- * at least a cycle ago, and if it still hasn't finished starting
- * then we're just going to swamp things worse by forking more.
- * So we hopefully won't need to fork more if we count it.
- * This depends on the ordering of SERVER_READY and SERVER_STARTING.
- */
- if (status <= SERVER_READY) {
- ++ idle_count;
- /* always kill the highest numbered child if we have to...
- * no really well thought out reason ... other than observing
- * the server behaviour under linux where lower numbered children
- * tend to service more hits (and hence are more likely to have
- * their data in cpu caches).
- */
- to_kill = i;
- }
-
- ++total_non_dead;
- last_non_dead = i;
- }
- }
- max_daemons_limit = last_non_dead + 1;
- if (idle_count > ap_daemons_max_free) {
- /* kill off one child... we use SIGUSR1 because that'll cause it to
- * shut down gracefully, in case it happened to pick up a request
- * while we were counting
- */
- kill(ap_scoreboard_image->parent[to_kill].pid, SIGUSR1);
- idle_spawn_rate = 1;
- }
- else if (idle_count < ap_daemons_min_free) {
- /* terminate the free list */
- if (free_length == 0) {
- /* only report this condition once */
- static int reported = 0;
-
- if (!reported) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
- "server reached MaxClients setting, consider"
- " raising the MaxClients setting");
- reported = 1;
- }
- idle_spawn_rate = 1;
- }
- else {
- if (idle_spawn_rate >= 8) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
- "server seems busy, (you may need "
- "to increase StartServers, or Min/MaxSpareServers), "
- "spawning %d children, there are %d idle, and "
- "%d total children", idle_spawn_rate,
- idle_count, total_non_dead);
- }
- for (i = 0; i < free_length; ++i) {
-#ifdef TPF
- if(make_child(server_conf, free_slots[i], now) == -1) {
- if(free_length == 1) {
- shutdown_pending = 1;
- ap_log_error(APLOG_MARK, APLOG_EMERG, server_conf,
- "No active child processes: shutting down");
- }
- }
-#else
- make_child(server_conf, free_slots[i], now);
-#endif /* TPF */
- }
- /* the next time around we want to spawn twice as many if this
- * wasn't good enough, but not if we've just done a graceful
- */
- if (hold_off_on_exponential_spawning) {
- --hold_off_on_exponential_spawning;
- }
- else if (idle_spawn_rate < MAX_SPAWN_RATE) {
- idle_spawn_rate *= 2;
- }
- }
- }
- else {
- idle_spawn_rate = 1;
- }
-}
-
-
-static void process_child_status(int pid, ap_wait_t status)
-{
- /* Child died... if it died due to a fatal error,
- * we should simply bail out.
- */
- if ((WIFEXITED(status)) &&
- WEXITSTATUS(status) == APEXIT_CHILDFATAL) {
- ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, server_conf,
- "Child %d returned a Fatal error... \n"
- "Apache is exiting!",
- pid);
- exit(APEXIT_CHILDFATAL);
- }
- if (WIFSIGNALED(status)) {
- switch (WTERMSIG(status)) {
- case SIGTERM:
- case SIGHUP:
- case SIGUSR1:
- case SIGKILL:
- break;
- default:
-#ifdef SYS_SIGLIST
-#ifdef WCOREDUMP
- if (WCOREDUMP(status)) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
- 0, server_conf,
- "child pid %d exit signal %s (%d), "
- "possible coredump in %s",
- pid, (WTERMSIG(status) >= NumSIG) ? "" :
- SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status),
- ap_coredump_dir);
- }
- else {
-#endif
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
- 0, server_conf,
- "child pid %d exit signal %s (%d)", pid,
- SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status));
-#ifdef WCOREDUMP
- }
-#endif
-#else
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE,
- server_conf,
- "child pid %d exit signal %d",
- pid, WTERMSIG(status));
-#endif
- }
- }
-}
-
-
-static int setup_listeners(server_rec *s)
-{
- ap_listen_rec *lr;
- int sockdes;
-
- if (ap_listen_open(s->process, s->port)) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, 0, s,
- "no listening sockets available, shutting down");
- return -1;
- }
-
- listenmaxfd = -1;
- FD_ZERO(&listenfds);
- for (lr = ap_listeners; lr; lr = lr->next) {
- ap_get_os_sock(&sockdes, lr->sd);
- FD_SET(sockdes, &listenfds);
- if (sockdes > listenmaxfd) {
- listenmaxfd = sockdes;
- }
- }
- return 0;
-}
-
-
-/*****************************************************************
- * Executive routines.
- */
-
-int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
-{
- int remaining_children_to_start;
-
- pconf = _pconf;
-
- server_conf = s;
-
- ap_log_pid(pconf, ap_pid_fname);
-
- if (setup_listeners(s)) {
- /* XXX: hey, what's the right way for the mpm to indicate a fatal error? */
- return 1;
- }
-
- SAFE_ACCEPT(accept_mutex_init(pconf));
- if (!is_graceful) {
- reinit_scoreboard(pconf);
- }
-#ifdef SCOREBOARD_FILE
- else {
- ap_scoreboard_fname = ap_server_root_relative(pconf, ap_scoreboard_fname);
- ap_note_cleanups_for_fd(pconf, scoreboard_fd);
- }
-#endif
-
- set_signals();
-
- if (ap_daemons_max_free < ap_daemons_min_free + 1) /* Don't thrash... */
- ap_daemons_max_free = ap_daemons_min_free + 1;
-
- /* If we're doing a graceful_restart then we're going to see a lot
- * of children exiting immediately when we get into the main loop
- * below (because we just sent them SIGUSR1). This happens pretty
- * rapidly... and for each one that exits we'll start a new one until
- * we reach at least daemons_min_free. But we may be permitted to
- * start more than that, so we'll just keep track of how many we're
- * supposed to start up without the 1 second penalty between each fork.
- */
- remaining_children_to_start = ap_daemons_to_start;
- if (remaining_children_to_start > ap_daemons_limit) {
- remaining_children_to_start = ap_daemons_limit;
- }
- if (!is_graceful) {
- startup_children(remaining_children_to_start);
- remaining_children_to_start = 0;
- }
- else {
- /* give the system some time to recover before kicking into
- * exponential mode */
- hold_off_on_exponential_spawning = 10;
- }
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "%s configured -- resuming normal operations",
- ap_get_server_version());
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
- "Server built: %s", ap_get_server_built());
- restart_pending = shutdown_pending = 0;
-
- while (!restart_pending && !shutdown_pending) {
- int child_slot;
- ap_wait_t status;
- int pid = wait_or_timeout(&status);
-
- /* XXX: if it takes longer than 1 second for all our children
- * to start up and get into IDLE state then we may spawn an
- * extra child
- */
- if (pid >= 0) {
- process_child_status(pid, status);
- /* non-fatal death... note that it's gone in the scoreboard. */
- ap_sync_scoreboard_image();
- child_slot = find_child_by_pid(pid);
- if (child_slot >= 0) {
- (void) ap_update_child_status(child_slot, SERVER_DEAD,
- (request_rec *) NULL);
- if (remaining_children_to_start
- && child_slot < ap_daemons_limit) {
- /* we're still doing a 1-for-1 replacement of dead
- * children with new children
- */
- make_child(server_conf, child_slot, time(0));
- --remaining_children_to_start;
- }
-#ifdef HAS_OTHER_CHILD
- }
- else if (reap_other_child(pid, status) == 0) {
- /* handled */
-#endif
- }
- else if (is_graceful) {
- /* Great, we've probably just lost a slot in the
- * scoreboard. Somehow we don't know about this
- * child.
- */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
- 0, server_conf,
- "long lost child came home! (pid %d)", pid);
- }
- /* Don't perform idle maintenance when a child dies,
- * only do it when there's a timeout. Remember only a
- * finite number of children can die, and it's pretty
- * pathological for a lot to die suddenly.
- */
- continue;
- }
- else if (remaining_children_to_start) {
- /* we hit a 1 second timeout in which none of the previous
- * generation of children needed to be reaped... so assume
- * they're all done, and pick up the slack if any is left.
- */
- startup_children(remaining_children_to_start);
- remaining_children_to_start = 0;
- /* In any event we really shouldn't do the code below because
- * few of the servers we just started are in the IDLE state
- * yet, so we'd mistakenly create an extra server.
- */
- continue;
- }
-
- perform_idle_server_maintenance();
-#ifdef TPF
- shutdown_pending = os_check_server(tpf_server_name);
- ap_check_signals();
- sleep(1);
-#endif /*TPF */
- }
-
- if (shutdown_pending) {
- /* Time to gracefully shut down:
- * Kill child processes, tell them to call child_exit, etc...
- */
- if (unixd_killpg(getpgrp(), SIGTERM) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "killpg SIGTERM");
- }
- reclaim_child_processes(1); /* Start with SIGTERM */
-
- /* cleanup pid file on normal shutdown */
- {
- const char *pidfile = NULL;
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO,
- 0, server_conf,
- "removed PID file %s (pid=%ld)",
- pidfile, (long)getpid());
- }
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "caught SIGTERM, shutting down");
- return 1;
- }
-
- /* we've been told to restart */
- signal(SIGHUP, SIG_IGN);
- signal(SIGUSR1, SIG_IGN);
- if (one_process) {
- /* not worth thinking about */
- return 1;
- }
-
- /* advance to the next generation */
- /* XXX: we really need to make sure this new generation number isn't in
- * use by any of the children.
- */
- ++ap_my_generation;
- ap_scoreboard_image->global.running_generation = ap_my_generation;
- update_scoreboard_global();
-
- if (is_graceful) {
-#ifndef SCOREBOARD_FILE
- int i;
-#endif
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "SIGUSR1 received. Doing graceful restart");
-
- /* kill off the idle ones */
- if (unixd_killpg(getpgrp(), SIGUSR1) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "killpg SIGUSR1");
- }
-#ifndef SCOREBOARD_FILE
- /* This is mostly for debugging... so that we know what is still
- * gracefully dealing with existing request. But we can't really
- * do it if we're in a SCOREBOARD_FILE because it'll cause
- * corruption too easily.
- */
- ap_sync_scoreboard_image();
- for (i = 0; i < ap_daemons_limit; ++i) {
- if (ap_scoreboard_image->servers[i].status != SERVER_DEAD) {
- ap_scoreboard_image->servers[i].status = SERVER_GRACEFUL;
- }
- }
-#endif
- }
- else {
- /* Kill 'em off */
- if (unixd_killpg(getpgrp(), SIGHUP) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "killpg SIGHUP");
- }
- reclaim_child_processes(0); /* Not when just starting up */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "SIGHUP received. Attempting to restart");
- }
-
- if (!is_graceful) {
- ap_restart_time = time(NULL);
- }
-
- return 0;
-}
-
-static void prefork_pre_config(ap_context_t *p, ap_context_t *plog, ap_context_t *ptemp)
-{
- static int restart_num = 0;
-
- one_process = !!getenv("ONE_PROCESS");
-
- /* sigh, want this only the second time around */
- if (restart_num++ == 1) {
- is_graceful = 0;
-
- if (!one_process) {
- unixd_detach();
- }
-
- my_pid = getpid();
- }
-
- unixd_pre_config();
- ap_listen_pre_config();
- ap_daemons_to_start = DEFAULT_START_DAEMON;
- ap_daemons_min_free = DEFAULT_MIN_FREE_DAEMON;
- ap_daemons_max_free = DEFAULT_MAX_FREE_DAEMON;
- ap_daemons_limit = HARD_SERVER_LIMIT;
- ap_pid_fname = DEFAULT_PIDLOG;
- ap_scoreboard_fname = DEFAULT_SCOREBOARD;
- ap_lock_fname = DEFAULT_LOCKFILE;
- ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
- ap_extended_status = 0;
-
- ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
-}
-
-static void prefork_hooks(void)
-{
- ap_hook_pre_config(prefork_pre_config,NULL,NULL,HOOK_MIDDLE);
- INIT_SIGLIST();
-#ifdef AUX3
- (void) set42sig();
-#endif
- /* TODO: set one_process properly */ one_process = 0;
-}
-
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_scoreboard(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_scoreboard_fname = arg;
- return NULL;
-}
-
-static const char *set_lockfile(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_lock_fname = arg;
- return NULL;
-}
-
-static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_to_start = atoi(arg);
- return NULL;
-}
-
-static const char *set_min_free_servers(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_min_free = atoi(arg);
- if (ap_daemons_min_free <= 0) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: detected MinSpareServers set to non-positive.");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Resetting to 1 to avoid almost certain Apache failure.");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Please read the documentation.");
- ap_daemons_min_free = 1;
- }
-
- return NULL;
-}
-
-static const char *set_max_free_servers(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_max_free = atoi(arg);
- return NULL;
-}
-
-static const char *set_server_limit (cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_limit = atoi(arg);
- if (ap_daemons_limit > HARD_SERVER_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: MaxClients of %d exceeds compile time limit "
- "of %d servers,", ap_daemons_limit, HARD_SERVER_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " lowering MaxClients to %d. To increase, please "
- "see the", HARD_SERVER_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " HARD_SERVER_LIMIT define in src/include/httpd.h.");
- ap_daemons_limit = HARD_SERVER_LIMIT;
- }
- else if (ap_daemons_limit < 1) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: Require MaxClients > 0, setting to 1");
- ap_daemons_limit = 1;
- }
- return NULL;
-}
-
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
-{
- struct stat finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
- return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
-/* Stub functions until this MPM supports the connection status API */
-
-API_EXPORT(void) ap_update_connection_status(long conn_id, const char *key, \
- const char *value)
-{
- /* NOP */
-}
-
-ap_array_header_t *ap_get_status_table(ap_context_t *p)
-{
- /* NOP */
- return NULL;
-}
-
-API_EXPORT(void) ap_reset_connection_status(long conn_id)
-{
- /* NOP */
-}
-
-static const command_rec prefork_cmds[] = {
-UNIX_DAEMON_COMMANDS
-LISTEN_COMMANDS
-{ "PidFile", set_pidfile, NULL, RSRC_CONF, TAKE1,
- "A file for logging the server process ID"},
-{ "ScoreBoardFile", set_scoreboard, NULL, RSRC_CONF, TAKE1,
- "A file for Apache to maintain runtime process management information"},
-{ "LockFile", set_lockfile, NULL, RSRC_CONF, TAKE1,
- "The lockfile used when Apache needs to lock the accept() call"},
-{ "StartServers", set_daemons_to_start, NULL, RSRC_CONF, TAKE1,
- "Number of child processes launched at server startup" },
-{ "MinSpareServers", set_min_free_servers, NULL, RSRC_CONF, TAKE1,
- "Minimum number of idle children, to handle request spikes" },
-{ "MaxSpareServers", set_max_free_servers, NULL, RSRC_CONF, TAKE1,
- "Maximum number of idle children" },
-{ "MaxClients", set_server_limit, NULL, RSRC_CONF, TAKE1,
- "Maximum number of children alive at the same time" },
-{ "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF, TAKE1,
- "Maximum number of requests a particular child serves before dying." },
-{ "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1,
- "The location of the directory Apache changes to before dumping core" },
-{ NULL }
-};
-
-module MODULE_VAR_EXPORT mpm_prefork_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- prefork_cmds, /* command ap_table_t */
- NULL, /* handlers */
- prefork_hooks, /* register hooks */
-};
diff --git a/server/mpm/prefork/scoreboard.h b/server/mpm/prefork/scoreboard.h
deleted file mode 100644
index 8bf2bb695b..0000000000
--- a/server/mpm/prefork/scoreboard.h
+++ /dev/null
@@ -1,217 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_SCOREBOARD_H
-#define APACHE_SCOREBOARD_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef WIN32
-#ifdef TPF
-#include <time.h>
-#else
-#include <sys/times.h>
-#include <sys/time.h>
-#endif /* TPF */
-#endif
-
-
-/* The optimized timeout code only works if we're not using a scoreboard file
- */
-#if (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD))
-#define OPTIMIZE_TIMEOUTS
-#endif
-
-/* Scoreboard info on a process is, for now, kept very brief ---
- * just status value and pid (the latter so that the caretaker process
- * can properly update the scoreboard when a process dies). We may want
- * to eventually add a separate set of long_score structures which would
- * give, for each process, the number of requests serviced, and info on
- * the current, or most recent, request.
- *
- * Status values:
- */
-
-#define SERVER_DEAD 0
-#define SERVER_STARTING 1 /* Server Starting up */
-#define SERVER_READY 2 /* Waiting for connection (or accept() lock) */
-#define SERVER_BUSY_READ 3 /* Reading a client request */
-#define SERVER_BUSY_WRITE 4 /* Processing a client request */
-#define SERVER_BUSY_KEEPALIVE 5 /* Waiting for more requests via keepalive */
-#define SERVER_BUSY_LOG 6 /* Logging the request */
-#define SERVER_BUSY_DNS 7 /* Looking up a hostname */
-#define SERVER_GRACEFUL 8 /* server is gracefully finishing request */
-#define SERVER_NUM_STATUS 9 /* number of status settings */
-
-/* A "virtual time" is simply a counter that indicates that a child is
- * making progress. The parent checks up on each child, and when they have
- * made progress it resets the last_rtime element. But when the child hasn't
- * made progress in a time that's roughly timeout_len seconds long, it is
- * sent a SIGALRM.
- *
- * vtime is an optimization that is used only when the scoreboard is in
- * shared memory (it's not easy/feasible to do it in a scoreboard file).
- * The essential observation is that timeouts rarely occur, the vast majority
- * of hits finish before any timeout happens. So it really sucks to have to
- * ask the operating system to set up and destroy alarms many times during
- * a request.
- */
-typedef unsigned vtime_t;
-
-/* Type used for generation indicies. Startup and every restart cause a
- * new generation of children to be spawned. Children within the same
- * generation share the same configuration information -- pointers to stuff
- * created at config time in the parent are valid across children. For
- * example, the vhostrec pointer in the scoreboard below is valid in all
- * children of the same generation.
- *
- * The safe way to access the vhost pointer is like this:
- *
- * short_score *ss = pointer to whichver slot is interesting;
- * parent_score *ps = pointer to whichver slot is interesting;
- * server_rec *vh = ss->vhostrec;
- *
- * if (ps->generation != ap_my_generation) {
- * vh = NULL;
- * }
- *
- * then if vh is not NULL it's valid in this child.
- *
- * This avoids various race conditions around restarts.
- */
-typedef int ap_generation_t;
-
-/* stuff which the children generally write, and the parent mainly reads */
-typedef struct {
-#ifdef OPTIMIZE_TIMEOUTS
- vtime_t cur_vtime; /* the child's current vtime */
- unsigned short timeout_len; /* length of the timeout */
-#endif
- unsigned char status;
- unsigned long access_count;
- unsigned long bytes_served;
- unsigned long my_access_count;
- unsigned long my_bytes_served;
- unsigned long conn_bytes;
- unsigned short conn_count;
-#if !defined(HAVE_GETTIMEOFDAY)
- clock_t start_time;
- clock_t stop_time;
-#else
- struct timeval start_time;
- struct timeval stop_time;
-#endif
-#ifdef HAVE_TIMES
- struct tms times;
-#endif
-#ifndef OPTIMIZE_TIMEOUTS
- time_t last_used;
-#endif
- char client[32]; /* Keep 'em small... */
- char request[64]; /* We just want an idea... */
- server_rec *vhostrec; /* What virtual host is being accessed? */
- /* SEE ABOVE FOR SAFE USAGE! */
-} short_score;
-
-typedef struct {
- ap_generation_t running_generation; /* the generation of children which
- * should still be serving requests. */
-} global_score;
-
-/* stuff which the parent generally writes and the children rarely read */
-typedef struct {
- pid_t pid;
-#ifdef OPTIMIZE_TIMEOUTS
- time_t last_rtime; /* time(0) of the last change */
- vtime_t last_vtime; /* the last vtime the parent has seen */
-#endif
- ap_generation_t generation; /* generation of this child */
-} parent_score;
-
-typedef struct {
- short_score servers[HARD_SERVER_LIMIT];
- parent_score parent[HARD_SERVER_LIMIT];
- global_score global;
-} scoreboard;
-
-#define SCOREBOARD_SIZE sizeof(scoreboard)
-#ifdef TPF
-#define SCOREBOARD_NAME "SCOREBRD"
-#define SCOREBOARD_FRAMES SCOREBOARD_SIZE/4095 + 1
-#endif
-
-API_EXPORT(void) ap_sync_scoreboard_image(void);
-API_EXPORT(int) ap_exists_scoreboard_image(void);
-
-API_VAR_EXPORT extern scoreboard *ap_scoreboard_image;
-
-API_VAR_EXPORT extern ap_generation_t volatile ap_my_generation;
-
-/* for time_process_request() in http_main.c */
-#define START_PREQUEST 1
-#define STOP_PREQUEST 2
-
-int ap_update_child_status(int child_num, int status, request_rec *r);
-void ap_time_process_request(int child_num, int status);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_SCOREBOARD_H */
diff --git a/server/mpm/spmt_os2/.cvsignore b/server/mpm/spmt_os2/.cvsignore
deleted file mode 100644
index f3c7a7c5da..0000000000
--- a/server/mpm/spmt_os2/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-Makefile
diff --git a/server/mpm/spmt_os2/Makefile.in b/server/mpm/spmt_os2/Makefile.in
deleted file mode 100644
index 081a91bf80..0000000000
--- a/server/mpm/spmt_os2/Makefile.in
+++ /dev/null
@@ -1,10 +0,0 @@
-
-DEPTH = ../../..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-LTLIBRARY_NAME = libspmt_os2.la
-LTLIBRARY_SOURCES = spmt_os2.c
-
-include $(topsrcdir)/build/ltlib.mk
diff --git a/server/mpm/spmt_os2/Makefile.libdir b/server/mpm/spmt_os2/Makefile.libdir
deleted file mode 100644
index 7b5254013a..0000000000
--- a/server/mpm/spmt_os2/Makefile.libdir
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a place-holder which indicates to Configure that it shouldn't
-provide the default targets when building the Makefile in this directory.
-Instead it'll just prepend all the important variable definitions, and
-copy the Makefile.tmpl onto the end.
diff --git a/server/mpm/spmt_os2/config.m4 b/server/mpm/spmt_os2/config.m4
deleted file mode 100644
index 73b1b16aaa..0000000000
--- a/server/mpm/spmt_os2/config.m4
+++ /dev/null
@@ -1,6 +0,0 @@
-if test "$MPM_NAME" = "spmt_os2" ; then
- AC_CACHE_SAVE
- APACHE_FAST_OUTPUT(modules/mpm/$MPM_NAME/Makefile)
- CFLAGS="$CFLAGS -Zmt"
- LDFLAGS="$LDFLAGS -Zmt"
-fi
diff --git a/server/mpm/spmt_os2/mpm_default.h b/server/mpm/spmt_os2/mpm_default.h
deleted file mode 100644
index 78d527efbf..0000000000
--- a/server/mpm/spmt_os2/mpm_default.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_MPM_DEFAULT_H
-#define APACHE_MPM_DEFAULT_H
-
-/* Number of servers to spawn off by default --- also, if fewer than
- * this free when the caretaker checks, it will spawn more.
- */
-#ifndef DEFAULT_START_DAEMON
-#define DEFAULT_START_DAEMON 5
-#endif
-
-/* Maximum number of *free* server processes --- more than this, and
- * they will die off.
- */
-
-#ifndef DEFAULT_MAX_FREE_DAEMON
-#define DEFAULT_MAX_FREE_DAEMON 10
-#endif
-
-/* Minimum --- fewer than this, and more will be created */
-
-#ifndef DEFAULT_MIN_FREE_DAEMON
-#define DEFAULT_MIN_FREE_DAEMON 5
-#endif
-
-/* 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
-#define HARD_SERVER_LIMIT 256
-#endif
-
-/* Where the main/parent process's pid is logged */
-#ifndef DEFAULT_PIDLOG
-#define DEFAULT_PIDLOG "logs/httpd.pid"
-#endif
-
-/*
- * Interval, in microseconds, between scoreboard maintenance.
- */
-#ifndef SCOREBOARD_MAINTENANCE_INTERVAL
-#define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
-#endif
-
-/* Number of requests to try to handle in a single process. If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 10000
-#endif
-
-#endif /* AP_MPM_DEFAULT_H */
diff --git a/server/mpm/spmt_os2/scoreboard.h b/server/mpm/spmt_os2/scoreboard.h
deleted file mode 100644
index 82693e2c37..0000000000
--- a/server/mpm/spmt_os2/scoreboard.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_SCOREBOARD_H
-#define APACHE_SCOREBOARD_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef HAVE_SYS_TIMES_H
-#include <sys/times.h>
-#endif
-
-/* The optimized timeout code only works if we're not using a scoreboard file
- */
-#if (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD))
-#define OPTIMIZE_TIMEOUTS
-#endif
-
-/* Scoreboard info on a thread is, for now, kept very brief ---
- * just status value and pid (the latter so that the caretaker thread
- * can properly update the scoreboard when a thread dies). We may want
- * to eventually add a separate set of long_score structures which would
- * give, for each thread, the number of requests serviced, and info on
- * the current, or most recent, request.
- *
- * Status values:
- */
-
-#define SERVER_DEAD 0
-#define SERVER_STARTING 1 /* Server Starting up */
-#define SERVER_READY 2 /* Waiting for connection (or accept() lock) */
-#define SERVER_BUSY_READ 3 /* Reading a client request */
-#define SERVER_BUSY_WRITE 4 /* Processing a client request */
-#define SERVER_BUSY_KEEPALIVE 5 /* Waiting for more requests via keepalive */
-#define SERVER_BUSY_LOG 6 /* Logging the request */
-#define SERVER_BUSY_DNS 7 /* Looking up a hostname */
-#define SERVER_GRACEFUL 8 /* server is gracefully finishing request */
-#define SERVER_NUM_STATUS 9 /* number of status settings */
-
-/* A "virtual time" is simply a counter that indicates that a child is
- * making progress. The parent checks up on each child, and when they have
- * made progress it resets the last_rtime element. But when the child hasn't
- * made progress in a time that's roughly timeout_len seconds long, it is
- * sent a SIGALRM.
- *
- * vtime is an optimization that is used only when the scoreboard is in
- * shared memory (it's not easy/feasible to do it in a scoreboard file).
- * The essential observation is that timeouts rarely occur, the vast majority
- * of hits finish before any timeout happens. So it really sucks to have to
- * ask the operating system to set up and destroy alarms many times during
- * a request.
- */
-typedef unsigned vtime_t;
-
-/* Type used for generation indicies. Startup and every restart cause a
- * new generation of children to be spawned. Children within the same
- * generation share the same configuration information -- pointers to stuff
- * created at config time in the parent are valid across children. For
- * example, the vhostrec pointer in the scoreboard below is valid in all
- * children of the same generation.
- *
- * The safe way to access the vhost pointer is like this:
- *
- * short_score *ss = pointer to whichver slot is interesting;
- * parent_score *ps = pointer to whichver slot is interesting;
- * server_rec *vh = ss->vhostrec;
- *
- * if (ps->generation != ap_my_generation) {
- * vh = NULL;
- * }
- *
- * then if vh is not NULL it's valid in this child.
- *
- * This avoids various race conditions around restarts.
- */
-typedef int ap_generation_t;
-
-/* stuff which the children generally write, and the parent mainly reads */
-typedef struct {
-#ifdef OPTIMIZE_TIMEOUTS
- vtime_t cur_vtime; /* the child's current vtime */
- unsigned short timeout_len; /* length of the timeout */
-#endif
- unsigned char status;
- unsigned long access_count;
- unsigned long bytes_served;
- unsigned long my_access_count;
- unsigned long my_bytes_served;
- unsigned long conn_bytes;
- unsigned short conn_count;
-#if !defined(HAVE_GETTIMEOFDAY)
- clock_t start_time;
- clock_t stop_time;
-#else
- struct timeval start_time;
- struct timeval stop_time;
-#endif
-#ifdef HAVE_TIMES
- struct tms times;
-#endif
-#ifndef OPTIMIZE_TIMEOUTS
- time_t last_used;
-#endif
- char client[32]; /* Keep 'em small... */
- char request[64]; /* We just want an idea... */
- server_rec *vhostrec; /* What virtual host is being accessed? */
- /* SEE ABOVE FOR SAFE USAGE! */
- int thread_retval;
-} short_score;
-
-typedef struct {
- ap_generation_t running_generation; /* the generation of children which
- * should still be serving requests. */
-} global_score;
-
-/* stuff which the parent generally writes and the children rarely read */
-typedef struct {
- pid_t tid;
-#ifdef OPTIMIZE_TIMEOUTS
- time_t last_rtime; /* time(0) of the last change */
- vtime_t last_vtime; /* the last vtime the parent has seen */
-#endif
- ap_generation_t generation; /* generation of this child */
- int deferred_die;
-} parent_score;
-
-typedef struct {
- short_score servers[HARD_SERVER_LIMIT];
- parent_score parent[HARD_SERVER_LIMIT];
- global_score global;
-} scoreboard;
-
-#define SCOREBOARD_SIZE sizeof(scoreboard)
-#ifdef TPF
-#define SCOREBOARD_NAME "SCOREBRD"
-#define SCOREBOARD_FRAMES SCOREBOARD_SIZE/4095 + 1
-#endif
-
-API_EXPORT(int) ap_exists_scoreboard_image(void);
-
-API_VAR_EXPORT extern scoreboard *ap_scoreboard_image;
-
-
-/* for time_process_request() in http_main.c */
-#define START_PREQUEST 1
-#define STOP_PREQUEST 2
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !APACHE_SCOREBOARD_H */
diff --git a/server/mpm/spmt_os2/spmt_os2.c b/server/mpm/spmt_os2/spmt_os2.c
deleted file mode 100644
index a60b96e097..0000000000
--- a/server/mpm/spmt_os2/spmt_os2.c
+++ /dev/null
@@ -1,1795 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-
-
-#define CORE_PRIVATE
-#define INCL_DOS
-#define INCL_DOSERRORS
-
-#include "httpd.h"
-#include "ap_config.h"
-#include "mpm_default.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "http_config.h"
-#include "http_core.h" /* for get_remote_host */
-#include "http_connection.h"
-#include "scoreboard.h"
-#include "ap_mpm.h"
-#include "ap_listen.h"
-#include "iol_socket.h"
-#include "apr_portable.h"
-
-#include <os2.h>
-#include <stdlib.h>
-#include <sys/signal.h>
-
-/* config globals */
-
-static int ap_max_requests_per_child=0;
-static char *ap_pid_fname=NULL;
-static int ap_daemons_to_start=0;
-static int ap_daemons_min_free=0;
-static int ap_daemons_max_free=0;
-static int ap_daemons_limit=0;
-static time_t ap_restart_time=0;
-static int ap_extended_status = 0;
-
-/*
- * The max child slot ever assigned, preserved across restarts. Necessary
- * to deal with MaxClients changes across SIGUSR1 restarts. We use this
- * value to optimize routines that have to scan the entire scoreboard.
- */
-static int max_daemons_limit = -1;
-
-static char ap_coredump_dir[MAX_STRING_LEN];
-
-/* *Non*-shared http_main globals... */
-
-static server_rec *server_conf;
-
-/* one_process --- debugging mode variable; can be set from the command line
- * with the -X flag. If set, this gets you the child_main loop running
- * in the process which originally started up (no detach, no make_child),
- * which is a pretty nice debugging environment. (You'll get a SIGHUP
- * early in standalone_main; just continue through. This is the server
- * trying to kill off any child processes which it might have lying
- * around --- Apache doesn't keep track of their pids, it just sends
- * SIGHUP to the process group, ignoring it in the root process.
- * Continue through and you'll be fine.).
- */
-
-static int one_process = 0;
-
-#ifdef HAS_OTHER_CHILD
-/* used to maintain list of children which aren't part of the scoreboard */
-typedef struct other_child_rec other_child_rec;
-struct other_child_rec {
- other_child_rec *next;
- int pid;
- void (*maintenance) (int, void *, ap_wait_t);
- void *data;
- int write_fd;
-};
-static other_child_rec *other_children;
-#endif
-
-static ap_context_t *pconf; /* Pool for config stuff */
-static scoreboard *ap_scoreboard_image = NULL;
-
-struct thread_globals {
- int child_num;
- ap_context_t *pchild; /* Pool for httpd child stuff */
- int usr1_just_die;
-};
-
-static struct thread_globals **ppthread_globals = NULL;
-
-#define THREAD_GLOBAL(gvar) ((*ppthread_globals)->gvar)
-
-
-void reinit_scoreboard(ap_context_t *p)
-{
- if (ap_scoreboard_image == NULL) {
- ap_scoreboard_image = (scoreboard *) malloc(SCOREBOARD_SIZE);
-
- if (ap_scoreboard_image == NULL) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Ouch! Out of memory reiniting scoreboard!");
- }
- }
-
- memset(ap_scoreboard_image, 0, SCOREBOARD_SIZE);
-}
-
-void cleanup_scoreboard(void)
-{
- ap_assert(ap_scoreboard_image);
- free(ap_scoreboard_image);
- ap_scoreboard_image = NULL;
-}
-
-
-/* a clean exit from a child with proper cleanup */
-static void clean_child_exit(int code)
-{
- if (THREAD_GLOBAL(pchild)) {
- ap_destroy_pool(THREAD_GLOBAL(pchild));
- }
-
- ap_scoreboard_image->servers[THREAD_GLOBAL(child_num)].thread_retval = code;
- _endthread();
-}
-
-
-
-static HMTX lock_sem = -1;
-
-static ap_status_t accept_mutex_cleanup(void *foo)
-{
- DosReleaseMutexSem(lock_sem);
- DosCloseMutexSem(lock_sem);
- return APR_SUCCESS;
-}
-
-/*
- * Initialize mutex lock.
- * Done by each child at it's birth
- */
-static void accept_mutex_child_init(ap_context_t *p)
-{
- int rc = DosOpenMutexSem(NULL, &lock_sem);
-
- if (rc != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, server_conf,
- "Child cannot open lock semaphore, rc=%d", rc);
- clean_child_exit(APEXIT_CHILDINIT);
- } else {
- ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
- }
-}
-
-/*
- * Initialize mutex lock.
- * Must be safe to call this on a restart.
- */
-static void accept_mutex_init(ap_context_t *p)
-{
- int rc = DosCreateMutexSem(NULL, &lock_sem, DC_SEM_SHARED, FALSE);
-
- if (rc != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, server_conf,
- "Parent cannot create lock semaphore, rc=%d", rc);
- exit(APEXIT_INIT);
- }
-
- ap_register_cleanup(p, NULL, accept_mutex_cleanup, ap_null_cleanup);
-}
-
-static void accept_mutex_on(void)
-{
- int rc = DosRequestMutexSem(lock_sem, SEM_INDEFINITE_WAIT);
-
- if (rc != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, server_conf,
- "OS2SEM: Error %d getting accept lock. Exiting!", rc);
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-}
-
-static void accept_mutex_off(void)
-{
- int rc = DosReleaseMutexSem(lock_sem);
-
- if (rc != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_EMERG, 0, server_conf,
- "OS2SEM: Error %d freeing accept lock. Exiting!", rc);
- clean_child_exit(APEXIT_CHILDFATAL);
- }
-}
-
-
-
-/* On some architectures it's safe to do unserialized accept()s in the single
- * Listen case. But it's never safe to do it in the case where there's
- * multiple Listen statements. Define SINGLE_LISTEN_UNSERIALIZED_ACCEPT
- * when it's safe in the single Listen case.
- */
-#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-#define SAFE_ACCEPT(stmt) do {if (ap_listeners->next) {stmt;}} while(0)
-#else
-#define SAFE_ACCEPT(stmt) do {stmt;} while(0)
-#endif
-
-
-/*****************************************************************
- * dealing with other children
- */
-
-#ifdef HAS_OTHER_CHILD
-API_EXPORT(void) ap_register_other_child(int pid,
- void (*maintenance) (int reason, void *, ap_wait_t status),
- void *data, int write_fd)
-{
- other_child_rec *ocr;
-
- ocr = ap_palloc(pconf, sizeof(*ocr));
- ocr->pid = pid;
- ocr->maintenance = maintenance;
- ocr->data = data;
- ocr->write_fd = write_fd;
- ocr->next = other_children;
- other_children = ocr;
-}
-
-/* note that 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.
- */
-API_EXPORT(void) ap_unregister_other_child(void *data)
-{
- other_child_rec **pocr, *nocr;
-
- for (pocr = &other_children; *pocr; pocr = &(*pocr)->next) {
- if ((*pocr)->data == data) {
- nocr = (*pocr)->next;
- (*(*pocr)->maintenance) (OC_REASON_UNREGISTER, (*pocr)->data, -1);
- *pocr = nocr;
- /* XXX: um, well we've just wasted some space in pconf ? */
- return;
- }
- }
-}
-
-/* test to ensure that the write_fds are all still writable, otherwise
- * invoke the maintenance functions as appropriate */
-static void probe_writable_fds(void)
-{
- fd_set writable_fds;
- int fd_max;
- other_child_rec *ocr, *nocr;
- struct timeval tv;
- int rc;
-
- if (other_children == NULL)
- return;
-
- fd_max = 0;
- FD_ZERO(&writable_fds);
- do {
- for (ocr = other_children; ocr; ocr = ocr->next) {
- if (ocr->write_fd == -1)
- continue;
- FD_SET(ocr->write_fd, &writable_fds);
- if (ocr->write_fd > fd_max) {
- fd_max = ocr->write_fd;
- }
- }
- if (fd_max == 0)
- return;
-
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- rc = ap_select(fd_max + 1, NULL, &writable_fds, NULL, &tv);
- } while (rc == -1 && errno == EINTR);
-
- if (rc == -1) {
- /* XXX: uhh this could be really bad, we could have a bad file
- * descriptor due to a bug in one of the maintenance routines */
- ap_log_unixerr("probe_writable_fds", "select",
- "could not probe writable fds", server_conf);
- return;
- }
- if (rc == 0)
- return;
-
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->write_fd == -1)
- continue;
- if (FD_ISSET(ocr->write_fd, &writable_fds))
- continue;
- (*ocr->maintenance) (OC_REASON_UNWRITABLE, ocr->data, -1);
- }
-}
-
-/* possibly reap an other_child, return 0 if yes, -1 if not */
-static int reap_other_child(int pid, ap_wait_t status)
-{
- other_child_rec *ocr, *nocr;
-
- for (ocr = other_children; ocr; ocr = nocr) {
- nocr = ocr->next;
- if (ocr->pid != pid)
- continue;
- ocr->pid = -1;
- (*ocr->maintenance) (OC_REASON_DEATH, ocr->data, status);
- return 0;
- }
- return -1;
-}
-#endif
-
-API_EXPORT(int) ap_exists_scoreboard_image(void)
-{
- return (ap_scoreboard_image ? 1 : 0);
-}
-
-int ap_update_child_status(int child_num, int status, request_rec *r)
-{
- int old_status;
- short_score *ss;
-
- if (child_num < 0)
- return -1;
-
- ss = &ap_scoreboard_image->servers[child_num];
- old_status = ss->status;
- ss->status = status;
-
- if (ap_extended_status) {
- if (status == SERVER_READY || status == SERVER_DEAD) {
- /*
- * Reset individual counters
- */
- if (status == SERVER_DEAD) {
- ss->my_access_count = 0L;
- ss->my_bytes_served = 0L;
- }
- ss->conn_count = (unsigned short) 0;
- ss->conn_bytes = (unsigned long) 0;
- }
- if (r) {
- conn_rec *c = r->connection;
- ap_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config,
- REMOTE_NOLOOKUP), sizeof(ss->client));
- if (r->the_request == NULL) {
- ap_cpystrn(ss->request, "NULL", sizeof(ss->request));
- } else if (r->parsed_uri.password == NULL) {
- ap_cpystrn(ss->request, r->the_request, sizeof(ss->request));
- } else {
- /* Don't reveal the password in the server-status view */
- ap_cpystrn(ss->request, ap_pstrcat(r->pool, r->method, " ",
- ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD),
- r->assbackwards ? NULL : " ", r->protocol, NULL),
- sizeof(ss->request));
- }
- ss->vhostrec = r->server;
- }
- }
-
- if (status == SERVER_STARTING && r == NULL) {
- /* clean up the slot's vhostrec pointer (maybe re-used)
- * and mark the slot as belonging to a new generation.
- */
- ss->vhostrec = NULL;
- ap_scoreboard_image->parent[child_num].generation = ap_scoreboard_image->global.running_generation;
- }
-
- return old_status;
-}
-
-void ap_time_process_request(int child_num, int status)
-{
- short_score *ss;
-#if !defined(HAVE_GETTIMEOFDAY) && defined(HAVE_TIMES)
- struct tms tms_blk;
-#endif
-
- if (child_num < 0)
- return;
-
- ss = &ap_scoreboard_image->servers[child_num];
-
- if (status == START_PREQUEST) {
-#if !defined(HAVE_GETTIMEOFDAY)
-#ifdef HAVE_TIMES
- if ((ss->start_time = times(&tms_blk)) == -1)
-#endif /* HAVE_TIMES */
- ss->start_time = (clock_t) 0;
-#else
- if (gettimeofday(&ss->start_time, (struct timezone *) 0) < 0)
- ss->start_time.tv_sec =
- ss->start_time.tv_usec = 0L;
-#endif
- }
- else if (status == STOP_PREQUEST) {
-#if !defined(HAVE_GETTIMEOFDAY)
-#ifdef HAVE_TIMES
- if ((ss->stop_time = times(&tms_blk)) == -1)
-#endif
- ss->stop_time = ss->start_time = (clock_t) 0;
-#else
- if (gettimeofday(&ss->stop_time, (struct timezone *) 0) < 0)
- ss->stop_time.tv_sec =
- ss->stop_time.tv_usec =
- ss->start_time.tv_sec =
- ss->start_time.tv_usec = 0L;
-#endif
-
- }
-}
-
-/* TODO: call me some time */
-static void increment_counts(int child_num, request_rec *r)
-{
- long int bs = 0;
- short_score *ss;
-
- ss = &ap_scoreboard_image->servers[child_num];
-
- if (r->sent_bodyct)
- ap_bgetopt(r->connection->client, BO_BYTECT, &bs);
-
-#ifdef HAVE_TIMES
- times(&ss->times);
-#endif
- ss->access_count++;
- ss->my_access_count++;
- ss->conn_count++;
- ss->bytes_served += (unsigned long) bs;
- ss->my_bytes_served += (unsigned long) bs;
- ss->conn_bytes += (unsigned long) bs;
-}
-
-static int find_child_by_tid(int tid)
-{
- int i;
-
- for (i = 0; i < max_daemons_limit; ++i)
- if (ap_scoreboard_image->parent[i].tid == tid)
- return i;
-
- return -1;
-}
-
-/* Finally, this routine is used by the caretaker thread to wait for
- * a while...
- */
-
-/* number of calls to wait_or_timeout between writable probes */
-#ifndef INTERVAL_OF_WRITABLE_PROBES
-#define INTERVAL_OF_WRITABLE_PROBES 10
-#endif
-static int wait_or_timeout_counter;
-
-static int wait_or_timeout(ap_wait_t *status)
-{
- int ret;
- ULONG tid;
-
- ++wait_or_timeout_counter;
- if (wait_or_timeout_counter == INTERVAL_OF_WRITABLE_PROBES) {
- wait_or_timeout_counter = 0;
-#ifdef HAS_OTHER_CHILD
- probe_writable_fds();
-#endif
- }
-
- tid = 0;
- ret = DosWaitThread(&tid, DCWW_NOWAIT);
-
- if (ret == 0) {
- int child_num = find_child_by_tid(tid);
- ap_assert( child_num > 0 );
- *status = ap_scoreboard_image->servers[child_num].thread_retval;
- return tid;
- }
-
- DosSleep(SCOREBOARD_MAINTENANCE_INTERVAL / 1000);
- return -1;
-}
-
-
-#if defined(NSIG)
-#define NumSIG NSIG
-#elif defined(_NSIG)
-#define NumSIG _NSIG
-#elif defined(__NSIG)
-#define NumSIG __NSIG
-#else
-#define NumSIG 32 /* for 1998's unixes, this is still a good assumption */
-#endif
-
-#ifdef SYS_SIGLIST /* platform has sys_siglist[] */
-#define INIT_SIGLIST() /*nothing*/
-#else /* platform has no sys_siglist[], define our own */
-#define SYS_SIGLIST ap_sys_siglist
-#define INIT_SIGLIST() siglist_init();
-
-const char *ap_sys_siglist[NumSIG];
-
-static void siglist_init(void)
-{
- int sig;
-
- ap_sys_siglist[0] = "Signal 0";
-#ifdef SIGHUP
- ap_sys_siglist[SIGHUP] = "Hangup";
-#endif
-#ifdef SIGINT
- ap_sys_siglist[SIGINT] = "Interrupt";
-#endif
-#ifdef SIGQUIT
- ap_sys_siglist[SIGQUIT] = "Quit";
-#endif
-#ifdef SIGILL
- ap_sys_siglist[SIGILL] = "Illegal instruction";
-#endif
-#ifdef SIGTRAP
- ap_sys_siglist[SIGTRAP] = "Trace/BPT trap";
-#endif
-#ifdef SIGIOT
- ap_sys_siglist[SIGIOT] = "IOT instruction";
-#endif
-#ifdef SIGABRT
- ap_sys_siglist[SIGABRT] = "Abort";
-#endif
-#ifdef SIGEMT
- ap_sys_siglist[SIGEMT] = "Emulator trap";
-#endif
-#ifdef SIGFPE
- ap_sys_siglist[SIGFPE] = "Arithmetic exception";
-#endif
-#ifdef SIGKILL
- ap_sys_siglist[SIGKILL] = "Killed";
-#endif
-#ifdef SIGBUS
- ap_sys_siglist[SIGBUS] = "Bus error";
-#endif
-#ifdef SIGSEGV
- ap_sys_siglist[SIGSEGV] = "Segmentation fault";
-#endif
-#ifdef SIGSYS
- ap_sys_siglist[SIGSYS] = "Bad system call";
-#endif
-#ifdef SIGPIPE
- ap_sys_siglist[SIGPIPE] = "Broken pipe";
-#endif
-#ifdef SIGALRM
- ap_sys_siglist[SIGALRM] = "Alarm clock";
-#endif
-#ifdef SIGTERM
- ap_sys_siglist[SIGTERM] = "Terminated";
-#endif
-#ifdef SIGUSR1
- ap_sys_siglist[SIGUSR1] = "User defined signal 1";
-#endif
-#ifdef SIGUSR2
- ap_sys_siglist[SIGUSR2] = "User defined signal 2";
-#endif
-#ifdef SIGCLD
- ap_sys_siglist[SIGCLD] = "Child status change";
-#endif
-#ifdef SIGCHLD
- ap_sys_siglist[SIGCHLD] = "Child status change";
-#endif
-#ifdef SIGPWR
- ap_sys_siglist[SIGPWR] = "Power-fail restart";
-#endif
-#ifdef SIGWINCH
- ap_sys_siglist[SIGWINCH] = "Window changed";
-#endif
-#ifdef SIGURG
- ap_sys_siglist[SIGURG] = "urgent socket condition";
-#endif
-#ifdef SIGPOLL
- ap_sys_siglist[SIGPOLL] = "Pollable event occurred";
-#endif
-#ifdef SIGIO
- ap_sys_siglist[SIGIO] = "socket I/O possible";
-#endif
-#ifdef SIGSTOP
- ap_sys_siglist[SIGSTOP] = "Stopped (signal)";
-#endif
-#ifdef SIGTSTP
- ap_sys_siglist[SIGTSTP] = "Stopped";
-#endif
-#ifdef SIGCONT
- ap_sys_siglist[SIGCONT] = "Continued";
-#endif
-#ifdef SIGTTIN
- ap_sys_siglist[SIGTTIN] = "Stopped (tty input)";
-#endif
-#ifdef SIGTTOU
- ap_sys_siglist[SIGTTOU] = "Stopped (tty output)";
-#endif
-#ifdef SIGVTALRM
- ap_sys_siglist[SIGVTALRM] = "virtual timer expired";
-#endif
-#ifdef SIGPROF
- ap_sys_siglist[SIGPROF] = "profiling timer expired";
-#endif
-#ifdef SIGXCPU
- ap_sys_siglist[SIGXCPU] = "exceeded cpu limit";
-#endif
-#ifdef SIGXFSZ
- ap_sys_siglist[SIGXFSZ] = "exceeded file size limit";
-#endif
- for (sig=0; sig < sizeof(ap_sys_siglist)/sizeof(ap_sys_siglist[0]); ++sig)
- if (ap_sys_siglist[sig] == NULL)
- ap_sys_siglist[sig] = "";
-}
-#endif /* platform has sys_siglist[] */
-
-
-/* handle all varieties of core dumping signals */
-static void sig_coredump(int sig)
-{
- chdir(ap_coredump_dir);
- signal(sig, SIG_DFL);
- kill(getpid(), sig);
- /* At this point we've got sig blocked, because we're still inside
- * the signal handler. When we leave the signal handler it will
- * be unblocked, and we'll take the signal... and coredump or whatever
- * is appropriate for this particular Unix. In addition the parent
- * will see the real signal we received -- whereas if we called
- * abort() here, the parent would only see SIGABRT.
- */
-}
-
-/*****************************************************************
- * Connection structures and accounting...
- */
-
-static void just_die(int sig)
-{
- clean_child_exit(0);
-}
-
-
-static void usr1_handler(int sig)
-{
- if (THREAD_GLOBAL(usr1_just_die)) {
- just_die(sig);
- }
- ap_scoreboard_image->parent[THREAD_GLOBAL(child_num)].deferred_die = 1;
-}
-
-/* volatile just in case */
-static int volatile shutdown_pending;
-static int volatile restart_pending;
-static int volatile is_graceful;
-
-static void sig_term(int sig)
-{
- if (shutdown_pending == 1) {
- /* Um, is this _probably_ not an error, if the user has
- * tried to do a shutdown twice quickly, so we won't
- * worry about reporting it.
- */
- return;
- }
- shutdown_pending = 1;
-}
-
-static void restart(int sig)
-{
- if (restart_pending == 1) {
- /* Probably not an error - don't bother reporting it */
- return;
- }
- restart_pending = 1;
- is_graceful = sig == SIGUSR1;
-}
-
-static void set_signals(void)
-{
-#ifndef NO_USE_SIGACTION
- struct sigaction sa;
-
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
-
- if (!one_process) {
- sa.sa_handler = sig_coredump;
-#if defined(SA_ONESHOT)
- sa.sa_flags = SA_ONESHOT;
-#elif defined(SA_RESETHAND)
- sa.sa_flags = SA_RESETHAND;
-#endif
- if (sigaction(SIGSEGV, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGSEGV)");
-#ifdef SIGBUS
- if (sigaction(SIGBUS, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGBUS)");
-#endif
-#ifdef SIGABORT
- if (sigaction(SIGABORT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABORT)");
-#endif
-#ifdef SIGABRT
- if (sigaction(SIGABRT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGABRT)");
-#endif
-#ifdef SIGILL
- if (sigaction(SIGILL, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGILL)");
-#endif
- sa.sa_flags = 0;
- }
- sa.sa_handler = sig_term;
- if (sigaction(SIGTERM, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGTERM)");
-#ifdef SIGINT
- if (sigaction(SIGINT, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGINT)");
-#endif
-#ifdef SIGXCPU
- sa.sa_handler = SIG_DFL;
- if (sigaction(SIGXCPU, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXCPU)");
-#endif
-#ifdef SIGXFSZ
- sa.sa_handler = SIG_DFL;
- if (sigaction(SIGXFSZ, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGXFSZ)");
-#endif
-#ifdef SIGPIPE
- sa.sa_handler = SIG_IGN;
- if (sigaction(SIGPIPE, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGPIPE)");
-#endif
-
- /* we want to ignore HUPs and USR1 while we're busy processing one */
- sigaddset(&sa.sa_mask, SIGHUP);
- sigaddset(&sa.sa_mask, SIGUSR1);
- sa.sa_handler = restart;
- if (sigaction(SIGHUP, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGHUP)");
- if (sigaction(SIGUSR1, &sa, NULL) < 0)
- ap_log_error(APLOG_MARK, APLOG_WARNING, errno, server_conf, "sigaction(SIGUSR1)");
-#else
- if (!one_process) {
- signal(SIGSEGV, sig_coredump);
-#ifdef SIGBUS
- signal(SIGBUS, sig_coredump);
-#endif /* SIGBUS */
-#ifdef SIGABORT
- signal(SIGABORT, sig_coredump);
-#endif /* SIGABORT */
-#ifdef SIGABRT
- signal(SIGABRT, sig_coredump);
-#endif /* SIGABRT */
-#ifdef SIGILL
- signal(SIGILL, sig_coredump);
-#endif /* SIGILL */
-#ifdef SIGXCPU
- signal(SIGXCPU, SIG_DFL);
-#endif /* SIGXCPU */
-#ifdef SIGXFSZ
- signal(SIGXFSZ, SIG_DFL);
-#endif /* SIGXFSZ */
- }
-
- signal(SIGTERM, sig_term);
-#ifdef SIGHUP
- signal(SIGHUP, restart);
-#endif /* SIGHUP */
-#ifdef SIGUSR1
- signal(SIGUSR1, restart);
-#endif /* SIGUSR1 */
-#ifdef SIGPIPE
- signal(SIGPIPE, SIG_IGN);
-#endif /* SIGPIPE */
-
-#endif
-}
-
-#if defined(TCP_NODELAY) && !defined(MPE) && !defined(TPF)
-static void sock_disable_nagle(ap_socket_t *s)
-{
- /* The Nagle algorithm says that we should delay sending partial
- * packets in hopes of getting more data. We don't want to do
- * this; we are not telnet. There are bad interactions between
- * persistent connections and Nagle's algorithm that have very severe
- * performance penalties. (Failing to disable Nagle is not much of a
- * problem with simple HTTP.)
- *
- * In spite of these problems, failure here is not a shooting offense.
- */
- int just_say_no = 1;
- ap_status_t status;
-
- status = ap_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &just_say_no, sizeof(int));
- if (status != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, status, server_conf,
- "setsockopt: (TCP_NODELAY)");
- }
-}
-
-#else
-#define sock_disable_nagle(s) /* NOOP */
-#endif
-
-
-/*****************************************************************
- * Child process main loop.
- */
-
-API_EXPORT(void) ap_child_terminate(request_rec *r)
-{
- r->connection->keepalive = 0;
- ap_scoreboard_image->parent[THREAD_GLOBAL(child_num)].deferred_die = 1;
-}
-
-int ap_graceful_stop_signalled(void)
-{
- if (ap_scoreboard_image->parent[THREAD_GLOBAL(child_num)].deferred_die ||
- ap_scoreboard_image->global.running_generation != ap_scoreboard_image->parent[THREAD_GLOBAL(child_num)].generation) {
- return 1;
- }
- return 0;
-}
-
-
-
-static int setup_listeners(ap_context_t *pchild, ap_pollfd_t **listen_poll)
-{
- ap_listen_rec *lr;
- int numfds = 0;
-
- for (lr = ap_listeners; lr; lr = lr->next) {
- numfds++;
- }
-
- ap_setup_poll(listen_poll, numfds, pchild);
-
- for (lr = ap_listeners; lr; lr = lr->next) {
- ap_add_poll_socket(*listen_poll, lr->sd, APR_POLLIN);
- }
- return 0;
-}
-
-
-
-static void child_main(void *child_num_arg)
-{
- ap_listen_rec *lr = NULL;
- ap_listen_rec *first_lr = NULL;
- ap_context_t *ptrans;
- conn_rec *current_conn;
- ap_iol *iol;
- ap_context_t *pchild;
- parent_score *sc_parent_rec;
- int requests_this_child = 0;
- ap_pollfd_t *listen_poll;
- ap_socket_t *csd = NULL;
- int nsds, rv;
-
- /* Disable the restart signal handlers and enable the just_die stuff.
- * Note that since restart() just notes that a restart has been
- * requested there's no race condition here.
- */
-
- set_signals(); /* signals aren't inherrited by child threads */
- signal(SIGHUP, just_die);
- signal(SIGUSR1, just_die);
- signal(SIGTERM, just_die);
-
- /* Get a sub pool for global allocations in this child, so that
- * we can have cleanups occur when the child exits.
- */
- ap_create_context(&pchild, pconf);
- *ppthread_globals = (struct thread_globals *)ap_palloc(pchild, sizeof(struct thread_globals));
- THREAD_GLOBAL(child_num) = (int)child_num_arg;
- sc_parent_rec = ap_scoreboard_image->parent + THREAD_GLOBAL(child_num);
- THREAD_GLOBAL(pchild) = pchild;
- ap_create_context(&ptrans, pchild);
-
- if (setup_listeners(pchild, &listen_poll)) {
- clean_child_exit(1);
- }
-
- /* needs to be done before we switch UIDs so we have permissions */
- SAFE_ACCEPT(accept_mutex_child_init(pchild));
-
- ap_child_init_hook(pchild, server_conf);
-
- (void) ap_update_child_status(THREAD_GLOBAL(child_num), SERVER_READY, (request_rec *) NULL);
-
-
- signal(SIGHUP, just_die);
- signal(SIGTERM, just_die);
-
- while (!ap_graceful_stop_signalled()) {
- BUFF *conn_io;
- int srv;
- ap_socket_t *sd;
-
- /* Prepare to receive a SIGUSR1 due to graceful restart so that
- * we can exit cleanly.
- */
- THREAD_GLOBAL(usr1_just_die) = 1;
- signal(SIGUSR1, usr1_handler);
-
- /*
- * (Re)initialize this child to a pre-connection state.
- */
-
- current_conn = NULL;
-
- ap_clear_pool(ptrans);
-
- if ((ap_max_requests_per_child > 0
- && requests_this_child++ >= ap_max_requests_per_child)) {
- clean_child_exit(0);
- }
-
- (void) ap_update_child_status(THREAD_GLOBAL(child_num), SERVER_READY, (request_rec *) NULL);
-
- /*
- * Wait for an acceptable connection to arrive.
- */
-
- /* Lock around "accept", if necessary */
- SAFE_ACCEPT(accept_mutex_on());
-
- for (;;) {
- if (ap_listeners->next) {
- /* more than one socket */
- srv = ap_poll(listen_poll, &nsds, -1);
-
- if (srv < 0 && errno != EINTR) {
- /* Single Unix documents select as returning errnos
- * EBADF, EINTR, and EINVAL... and in none of those
- * cases does it make sense to continue. In fact
- * on Linux 2.0.x we seem to end up with EFAULT
- * occasionally, and we'd loop forever due to it.
- */
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, server_conf, "select: (listen)");
- clean_child_exit(1);
- }
-
- if (srv <= 0)
- continue;
-
- /* we remember the last_lr we searched last time around so that
- we don't end up starving any particular listening socket */
- if (first_lr == NULL) {
- first_lr = ap_listeners;
- }
-
- lr = first_lr;
-
- do {
- ap_int16_t event;
-
- if (!lr) {
- lr = ap_listeners;
- }
-
- ap_get_revents(&event, lr->sd, listen_poll);
-
- if (event == APR_POLLIN) {
- first_lr = lr->next;
- break;
- }
- lr = lr->next;
- } while (lr != first_lr);
-
- if (lr == first_lr) {
- continue;
- }
- sd = lr->sd;
- }
- else {
- /* only one socket, just pretend we did the other stuff */
- sd = ap_listeners->sd;
- }
-
- /* if we accept() something we don't want to die, so we have to
- * defer the exit
- */
- THREAD_GLOBAL(usr1_just_die) = 0;
- for (;;) {
- if (ap_scoreboard_image->parent[THREAD_GLOBAL(child_num)].deferred_die) {
- /* we didn't get a socket, and we were told to die */
- clean_child_exit(0);
- }
- rv = ap_accept(&csd, sd, ptrans);
- if (rv != APR_EINTR)
- break;
- }
-
- if (rv == APR_SUCCESS)
- break; /* We have a socket ready for reading */
- else {
-
- /* Our old behaviour here was to continue after accept()
- * errors. But this leads us into lots of troubles
- * because most of the errors are quite fatal. For
- * example, EMFILE can be caused by slow descriptor
- * leaks (say in a 3rd party module, or libc). It's
- * foolish for us to continue after an EMFILE. We also
- * seem to tickle kernel bugs on some platforms which
- * lead to never-ending loops here. So it seems best
- * to just exit in most cases.
- */
- switch (rv) {
-#ifdef EPROTO
- /* EPROTO on certain older kernels really means
- * ECONNABORTED, so we need to ignore it for them.
- * See discussion in new-httpd archives nh.9701
- * search for EPROTO.
- *
- * Also see nh.9603, search for EPROTO:
- * 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.
- */
- case EPROTO:
-#endif
-#ifdef ECONNABORTED
- case ECONNABORTED:
-#endif
- /* Linux generates the rest of these, other tcp
- * stacks (i.e. bsd) tend to hide them behind
- * getsockopt() interfaces. They occur when
- * the net goes sour or the client disconnects
- * after the three-way handshake has been done
- * in the kernel but before userland has picked
- * up the socket.
- */
-#ifdef ECONNRESET
- case ECONNRESET:
-#endif
-#ifdef ETIMEDOUT
- case ETIMEDOUT:
-#endif
-#ifdef EHOSTUNREACH
- case EHOSTUNREACH:
-#endif
-#ifdef ENETUNREACH
- case ENETUNREACH:
-#endif
- break;
- default:
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, server_conf,
- "accept: (client socket)");
- clean_child_exit(1);
- }
- }
-
- if (ap_graceful_stop_signalled()) {
- clean_child_exit(0);
- }
- THREAD_GLOBAL(usr1_just_die) = 1;
- }
-
- SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */
-
- /* We've got a socket, let's at least process one request off the
- * socket before we accept a graceful restart request. We set
- * the signal to ignore because we don't want to disturb any
- * third party code.
- */
- signal(SIGUSR1, SIG_IGN);
-
- /*
- * We now have a connection, so set it up with the appropriate
- * socket options, file descriptors, and read/write buffers.
- */
-
- sock_disable_nagle(csd);
-
- iol = os2_attach_socket(csd);
-
- if (iol == NULL) {
- ap_log_error(APLOG_MARK, APLOG_WARNING|APLOG_NOERRNO, 0, NULL,
- "error attaching to socket");
- ap_close_socket(csd);
- continue;
- }
-
- (void) ap_update_child_status(THREAD_GLOBAL(child_num), SERVER_BUSY_READ,
- (request_rec *) NULL);
-
- conn_io = ap_bcreate(ptrans, B_RDWR);
- ap_bpush_iol(conn_io, iol);
-
- current_conn = ap_new_apr_connection(ptrans, server_conf, conn_io, csd,
- THREAD_GLOBAL(child_num));
-
- ap_process_connection(current_conn);
- }
-
- clean_child_exit(0);
-}
-
-
-static int make_child(server_rec *s, int slot, time_t now)
-{
- TID tid;
-
- if (slot + 1 > max_daemons_limit) {
- max_daemons_limit = slot + 1;
- }
-
- if (one_process) {
- struct thread_globals *parent_globals = *ppthread_globals;
- signal(SIGHUP, just_die);
- signal(SIGINT, just_die);
-#ifdef SIGQUIT
- signal(SIGQUIT, SIG_DFL);
-#endif
- signal(SIGTERM, just_die);
- child_main((void *)slot);
- *ppthread_globals = parent_globals;
- }
-
- ap_update_child_status(slot, SERVER_STARTING, (request_rec *) NULL);
-
- if ((tid = _beginthread(child_main, NULL, 256*1024, (void *)slot)) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, s, "_beginthread: Unable to create new thread");
-
- /* _beginthread didn't succeed. Fix the scoreboard or else
- * it will say SERVER_STARTING forever and ever
- */
- (void) ap_update_child_status(slot, SERVER_DEAD, (request_rec *) NULL);
-
- /* In case system resources are maxxed out, we don't want
- Apache running away with the CPU trying to _beginthread over and
- over and over again. */
- sleep(10);
-
- return -1;
- }
-
- ap_scoreboard_image->parent[slot].tid = tid;
- return 0;
-}
-
-
-/* start up a bunch of children */
-static void startup_children(int number_to_start)
-{
- int i;
- time_t now = time(0);
-
- for (i = 0; number_to_start && i < ap_daemons_limit; ++i) {
- if (ap_scoreboard_image->servers[i].status != SERVER_DEAD) {
- continue;
- }
- if (make_child(server_conf, i, now) < 0) {
- break;
- }
- --number_to_start;
- }
-}
-
-
-/*
- * idle_spawn_rate is the number of children that will be spawned on the
- * next maintenance cycle if there aren't enough idle servers. It is
- * doubled up to MAX_SPAWN_RATE, and reset only when a cycle goes by
- * without the need to spawn.
- */
-static int idle_spawn_rate = 1;
-#ifndef MAX_SPAWN_RATE
-#define MAX_SPAWN_RATE (32)
-#endif
-static int hold_off_on_exponential_spawning;
-
-static void perform_idle_server_maintenance(void)
-{
- int i;
- int to_kill;
- int idle_count;
- short_score *ss;
- time_t now = time(0);
- int free_length;
- int free_slots[MAX_SPAWN_RATE];
- int last_non_dead;
- int total_non_dead;
-
- /* initialize the free_list */
- free_length = 0;
-
- to_kill = -1;
- idle_count = 0;
- last_non_dead = -1;
- total_non_dead = 0;
-
- for (i = 0; i < ap_daemons_limit; ++i) {
- int status;
-
- if (i >= max_daemons_limit && free_length == idle_spawn_rate)
- break;
- ss = &ap_scoreboard_image->servers[i];
- status = ss->status;
- if (status == SERVER_DEAD) {
- /* try to keep children numbers as low as possible */
- if (free_length < idle_spawn_rate) {
- free_slots[free_length] = i;
- ++free_length;
- }
- }
- else {
- /* We consider a starting server as idle because we started it
- * at least a cycle ago, and if it still hasn't finished starting
- * then we're just going to swamp things worse by forking more.
- * So we hopefully won't need to fork more if we count it.
- * This depends on the ordering of SERVER_READY and SERVER_STARTING.
- */
- if (status <= SERVER_READY) {
- ++ idle_count;
- /* always kill the highest numbered child if we have to...
- * no really well thought out reason ... other than observing
- * the server behaviour under linux where lower numbered children
- * tend to service more hits (and hence are more likely to have
- * their data in cpu caches).
- */
- to_kill = i;
- }
-
- ++total_non_dead;
- last_non_dead = i;
- }
- }
- max_daemons_limit = last_non_dead + 1;
- if (idle_count > ap_daemons_max_free) {
- /* kill off one child... we use SIGUSR1 because that'll cause it to
- * shut down gracefully, in case it happened to pick up a request
- * while we were counting
- */
- ap_scoreboard_image->parent[to_kill].deferred_die = 1;
- idle_spawn_rate = 1;
- }
- else if (idle_count < ap_daemons_min_free) {
- /* terminate the free list */
- if (free_length == 0) {
- /* only report this condition once */
- static int reported = 0;
-
- if (!reported) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, server_conf,
- "server reached MaxClients setting, consider"
- " raising the MaxClients setting");
- reported = 1;
- }
- idle_spawn_rate = 1;
- }
- else {
- if (idle_spawn_rate >= 8) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
- "server seems busy, (you may need "
- "to increase StartServers, or Min/MaxSpareServers), "
- "spawning %d children, there are %d idle, and "
- "%d total children", idle_spawn_rate,
- idle_count, total_non_dead);
- }
- for (i = 0; i < free_length; ++i) {
- make_child(server_conf, free_slots[i], now);
- }
- /* the next time around we want to spawn twice as many if this
- * wasn't good enough, but not if we've just done a graceful
- */
- if (hold_off_on_exponential_spawning) {
- --hold_off_on_exponential_spawning;
- }
- else if (idle_spawn_rate < MAX_SPAWN_RATE) {
- idle_spawn_rate *= 2;
- }
- }
- }
- else {
- idle_spawn_rate = 1;
- }
-}
-
-
-static void process_child_status(int tid, ap_wait_t status)
-{
- /* Child died... if it died due to a fatal error,
- * we should simply bail out.
- */
- if ((WIFEXITED(status)) &&
- WEXITSTATUS(status) == APEXIT_CHILDFATAL) {
- ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, server_conf,
- "Child %d returned a Fatal error... \n"
- "Apache is exiting!",
- tid);
- exit(APEXIT_CHILDFATAL);
- }
- if (WIFSIGNALED(status)) {
- switch (WTERMSIG(status)) {
- case SIGTERM:
- case SIGHUP:
- case SIGUSR1:
- case SIGKILL:
- break;
- default:
-#ifdef SYS_SIGLIST
-#ifdef WCOREDUMP
- if (WCOREDUMP(status)) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0,
- server_conf,
- "child tid %d exit signal %s (%d), "
- "possible coredump in %s",
- tid, (WTERMSIG(status) >= NumSIG) ? "" :
- SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status),
- ap_coredump_dir);
- }
- else {
-#endif
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0,
- server_conf,
- "child tid %d exit signal %s (%d)", tid,
- SYS_SIGLIST[WTERMSIG(status)], WTERMSIG(status));
-#ifdef WCOREDUMP
- }
-#endif
-#else
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0,
- server_conf,
- "child tid %d exit signal %d",
- tid, WTERMSIG(status));
-#endif
- }
- }
-}
-
-
-/*****************************************************************
- * Executive routines.
- */
-
-int ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s)
-{
- int remaining_children_to_start;
- int i;
- ap_status_t status;
-
- pconf = _pconf;
- server_conf = s;
- ap_log_pid(pconf, ap_pid_fname);
-
- if ((status = ap_listen_open(s->process, s->port)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, status, s,
- "no listening sockets available, shutting down");
- return -1;
- }
-
- SAFE_ACCEPT(accept_mutex_init(pconf));
-
- if (!is_graceful) {
- reinit_scoreboard(pconf);
- }
-
- set_signals();
-
- if (ppthread_globals == NULL) {
- if (DosAllocThreadLocalMemory(1, (PULONG *)&ppthread_globals)) {
- ap_log_error(APLOG_MARK, APLOG_ALERT|APLOG_NOERRNO, 0, server_conf,
- "Error allocating thread local storage"
- "Apache is exiting!");
- } else {
- *ppthread_globals = (struct thread_globals *)ap_palloc(pconf, sizeof(struct thread_globals));
- }
- }
-
- if (ap_daemons_max_free < ap_daemons_min_free + 1) /* Don't thrash... */
- ap_daemons_max_free = ap_daemons_min_free + 1;
-
- /* If we're doing a graceful_restart then we're going to see a lot
- * of children exiting immediately when we get into the main loop
- * below (because we just sent them SIGUSR1). This happens pretty
- * rapidly... and for each one that exits we'll start a new one until
- * we reach at least daemons_min_free. But we may be permitted to
- * start more than that, so we'll just keep track of how many we're
- * supposed to start up without the 1 second penalty between each fork.
- */
- remaining_children_to_start = ap_daemons_to_start;
- if (remaining_children_to_start > ap_daemons_limit) {
- remaining_children_to_start = ap_daemons_limit;
- }
- if (!is_graceful) {
- startup_children(remaining_children_to_start);
- remaining_children_to_start = 0;
- }
- else {
- /* give the system some time to recover before kicking into
- * exponential mode */
- hold_off_on_exponential_spawning = 10;
- }
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "%s configured -- resuming normal operations",
- ap_get_server_version());
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0, server_conf,
- "Server built: %s", ap_get_server_built());
- restart_pending = shutdown_pending = 0;
-
- while (!restart_pending && !shutdown_pending) {
- int child_slot;
- ap_wait_t status;
- int tid = wait_or_timeout(&status);
-
- /* XXX: if it takes longer than 1 second for all our children
- * to start up and get into IDLE state then we may spawn an
- * extra child
- */
- if (tid >= 0) {
- process_child_status(tid, status);
- /* non-fatal death... note that it's gone in the scoreboard. */
- child_slot = find_child_by_tid(tid);
- if (child_slot >= 0) {
- (void) ap_update_child_status(child_slot, SERVER_DEAD,
- (request_rec *) NULL);
- if (remaining_children_to_start
- && child_slot < ap_daemons_limit) {
- /* we're still doing a 1-for-1 replacement of dead
- * children with new children
- */
- make_child(server_conf, child_slot, time(0));
- --remaining_children_to_start;
- }
-#ifdef HAS_OTHER_CHILD
-/* TODO: this won't work, we waited on a thread not a process
- }
- else if (reap_other_child(pid, status) == 0) {
-*/
-#endif
- }
- else if (is_graceful) {
- /* Great, we've probably just lost a slot in the
- * scoreboard. Somehow we don't know about this
- * child.
- */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, server_conf,
- "long lost child came home! (tid %d)", tid);
- }
- /* Don't perform idle maintenance when a child dies,
- * only do it when there's a timeout. Remember only a
- * finite number of children can die, and it's pretty
- * pathological for a lot to die suddenly.
- */
- continue;
- }
- else if (remaining_children_to_start) {
- /* we hit a 1 second timeout in which none of the previous
- * generation of children needed to be reaped... so assume
- * they're all done, and pick up the slack if any is left.
- */
- startup_children(remaining_children_to_start);
- remaining_children_to_start = 0;
- /* In any event we really shouldn't do the code below because
- * few of the servers we just started are in the IDLE state
- * yet, so we'd mistakenly create an extra server.
- */
- continue;
- }
-
- perform_idle_server_maintenance();
- }
-
- if (shutdown_pending) {
- /* Time to gracefully shut down */
- const char *pidfile = NULL;
- int slot;
- TID tid;
- ULONG rc;
-
- /* Kill off running threads */
- for (slot=0; slot<max_daemons_limit; slot++) {
- if (ap_scoreboard_image->servers[slot].status != SERVER_DEAD) {
- tid = ap_scoreboard_image->parent[slot].tid;
- rc = DosKillThread(tid);
-
- if (rc == 0) {
- rc = DosWaitThread(&tid, DCWW_WAIT);
-
- if (rc) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, server_conf,
- "error %lu waiting for thread to terminate", rc);
- }
- } else {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, server_conf,
- "error %lu killing thread", rc);
- }
- }
- }
-
- /* cleanup pid file on normal shutdown */
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, 0,
- server_conf,
- "removed PID file %s (pid=%ld)",
- pidfile, (long)getpid());
-
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "caught SIGTERM, shutting down");
- return 1;
- }
-
- /* we've been told to restart */
- signal(SIGHUP, SIG_IGN);
- signal(SIGUSR1, SIG_IGN);
-
- if (one_process) {
- /* not worth thinking about */
- return 1;
- }
-
- /* advance to the next generation */
- /* XXX: we really need to make sure this new generation number isn't in
- * use by any of the children.
- */
- ++ap_scoreboard_image->global.running_generation;
-
- if (is_graceful) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "SIGUSR1 received. Doing graceful restart");
-
- /* kill off the idle ones */
- for (i = 0; i < ap_daemons_limit; ++i) {
- ap_scoreboard_image->parent[i].deferred_die = 1;
- }
-
- /* This is mostly for debugging... so that we know what is still
- * gracefully dealing with existing request. But we can't really
- * do it if we're in a SCOREBOARD_FILE because it'll cause
- * corruption too easily.
- */
- for (i = 0; i < ap_daemons_limit; ++i) {
- if (ap_scoreboard_image->servers[i].status != SERVER_DEAD) {
- ap_scoreboard_image->servers[i].status = SERVER_GRACEFUL;
- }
- }
- }
- else {
- /* Kill 'em off */
- for (i = 0; i < ap_daemons_limit; ++i) {
- DosKillThread(ap_scoreboard_image->parent[i].tid);
- }
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, 0, server_conf,
- "SIGHUP received. Attempting to restart");
- }
-
- if (!is_graceful) {
- ap_restart_time = time(NULL);
- }
-
- return 0;
-}
-
-static void spmt_os2_pre_config(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp)
-{
- one_process = !!getenv("ONE_PROCESS");
-
- is_graceful = 0;
- ap_listen_pre_config();
- ap_daemons_to_start = DEFAULT_START_DAEMON;
- ap_daemons_min_free = DEFAULT_MIN_FREE_DAEMON;
- ap_daemons_max_free = DEFAULT_MAX_FREE_DAEMON;
- ap_daemons_limit = HARD_SERVER_LIMIT;
- ap_pid_fname = DEFAULT_PIDLOG;
- ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
- ap_extended_status = 0;
-
- ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
-}
-
-static void spmt_os2_hooks(void)
-{
- ap_hook_pre_config(spmt_os2_pre_config,NULL,NULL,HOOK_MIDDLE);
- INIT_SIGLIST();
- /* TODO: set one_process properly */ one_process = 0;
-}
-
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_daemons_to_start(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_to_start = atoi(arg);
- return NULL;
-}
-
-static const char *set_min_free_servers(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_min_free = atoi(arg);
- if (ap_daemons_min_free <= 0) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: detected MinSpareServers set to non-positive.");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Resetting to 1 to avoid almost certain Apache failure.");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Please read the documentation.");
- ap_daemons_min_free = 1;
- }
-
- return NULL;
-}
-
-static const char *set_max_free_servers(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_max_free = atoi(arg);
- return NULL;
-}
-
-static const char *set_server_limit (cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_daemons_limit = atoi(arg);
- if (ap_daemons_limit > HARD_SERVER_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: MaxClients of %d exceeds compile time limit "
- "of %d servers,", ap_daemons_limit, HARD_SERVER_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " lowering MaxClients to %d. To increase, please "
- "see the", HARD_SERVER_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " HARD_SERVER_LIMIT define in src/include/httpd.h.");
- ap_daemons_limit = HARD_SERVER_LIMIT;
- }
- else if (ap_daemons_limit < 1) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: Require MaxClients > 0, setting to 1");
- ap_daemons_limit = 1;
- }
- return NULL;
-}
-
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
-{
- struct stat finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
- return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
-/* Stub functions until this MPM supports the connection status API */
-
-API_EXPORT(void) ap_update_connection_status(long conn_id, const char *key, \
- const char *value)
-{
- /* NOP */
-}
-
-API_EXPORT(void) ap_reset_connection_status(long conn_id)
-{
- /* NOP */
-}
-
-static const command_rec spmt_os2_cmds[] = {
-LISTEN_COMMANDS
-{ "PidFile", set_pidfile, NULL, RSRC_CONF, TAKE1,
- "A file for logging the server process ID"},
-{ "StartServers", set_daemons_to_start, NULL, RSRC_CONF, TAKE1,
- "Number of child processes launched at server startup" },
-{ "MinSpareServers", set_min_free_servers, NULL, RSRC_CONF, TAKE1,
- "Minimum number of idle children, to handle request spikes" },
-{ "MaxSpareServers", set_max_free_servers, NULL, RSRC_CONF, TAKE1,
- "Maximum number of idle children" },
-{ "MaxClients", set_server_limit, NULL, RSRC_CONF, TAKE1,
- "Maximum number of children alive at the same time" },
-{ "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF, TAKE1,
- "Maximum number of requests a particular child serves before dying." },
-{ "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1,
- "The location of the directory Apache changes to before dumping core" },
-{ NULL }
-};
-
-module MODULE_VAR_EXPORT mpm_spmt_os2_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- spmt_os2_cmds, /* command ap_table_t */
- NULL, /* handlers */
- spmt_os2_hooks, /* register_hooks */
-};
diff --git a/server/mpm/winnt/mpm_default.h b/server/mpm/winnt/mpm_default.h
deleted file mode 100644
index deb1ceb6ae..0000000000
--- a/server/mpm/winnt/mpm_default.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_MPM_DEFAULT_H
-#define APACHE_MPM_DEFAULT_H
-
-/* Number of threads to spawn off by default --- also, if fewer than
- * this free when the caretaker checks, it will spawn more.
- */
-#ifndef DEFAULT_START_THREAD
-#define DEFAULT_START_THREAD 5
-#endif
-
-/* Maximum number of *free* server threads --- more than this, and
- * they will die off.
-#ifndef DEFAULT_MAX_SPARE_THREAD
-#define DEFAULT_MAX_SPARE_THREAD 10
-#endif
-*/
-
-/* Minimum --- fewer than this, and more will be created */
-/*
-#ifndef DEFAULT_MIN_SPARE_THREAD
-#define DEFAULT_MIN_SPARE_THREAD 5
-#endif
-*/
-
-/* Limit on the threads per process. Clients will be locked out if more than
- * this * HARD_SERVER_LIMIT are needed.
- *
- * We keep this for one reason 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_THREAD_LIMIT
-#define HARD_THREAD_LIMIT 64
-#endif
-
-/* Number of servers to spawn off by default
- */
-#ifndef DEFAULT_NUM_DAEMON
-#define DEFAULT_NUM_DAEMON 1
-#endif
-
-/* 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
-#define HARD_SERVER_LIMIT 8
-#endif
-
-/* Where the main/parent process's pid is logged */
-#ifndef DEFAULT_PIDLOG
-#define DEFAULT_PIDLOG "logs/httpd.pid"
-#endif
-
-/*
- * Interval, in microseconds, between scoreboard maintenance.
- */
-#ifndef SCOREBOARD_MAINTENANCE_INTERVAL
-#define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
-#endif
-
-/* Number of requests to try to handle in a single process. If <= 0,
- * the children don't die off.
- */
-#ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
-#define DEFAULT_MAX_REQUESTS_PER_CHILD 10000
-#endif
-
-#endif /* AP_MPM_DEFAULT_H */
diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c
deleted file mode 100644
index 2e6afe40ac..0000000000
--- a/server/mpm/winnt/mpm_winnt.c
+++ /dev/null
@@ -1,1879 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#define CORE_PRIVATE
-#include "apr_portable.h"
-#include "httpd.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "http_config.h" /* for read_config */
-#include "http_core.h" /* for get_remote_host */
-#include "http_connection.h"
-#include "ap_mpm.h"
-#include "ap_config.h"
-#include "ap_listen.h"
-#include "mpm_default.h"
-#include "service.h"
-#include "iol_socket.h"
-#include "winnt.h"
-
-
-/*
- * Definitions of WINNT MPM specific config globals
- */
-
-static char *ap_pid_fname = NULL;
-static int ap_threads_per_child = 0;
-static int workers_may_exit = 0;
-static int max_requests_per_child = 0;
-
-static struct fd_set listenfds;
-static int num_listenfds = 0;
-static SOCKET listenmaxfd = INVALID_SOCKET;
-
-static ap_context_t *pconf; /* Pool for config stuff */
-
-static char ap_coredump_dir[MAX_STRING_LEN];
-
-static server_rec *server_conf;
-static HANDLE AcceptExCompPort = NULL;
-
-static int one_process = 0;
-
-static OSVERSIONINFO osver; /* VER_PLATFORM_WIN32_NT */
-
-int ap_max_requests_per_child=0;
-int ap_daemons_to_start=0;
-
-static event *exit_event;
-ap_lock_t *start_mutex;
-int my_pid;
-int parent_pid;
-
-static ap_status_t socket_cleanup(void *sock)
-{
- struct socket_t *thesocket = sock;
- SOCKET sd;
- if (ap_get_os_sock(&sd, thesocket) == APR_SUCCESS) {
- closesocket(sd);
- }
- return APR_SUCCESS;
-}
-
-/* A bunch or routines from os/win32/multithread.c that need to be merged into APR
- * or thrown out entirely...
- */
-
-static int
-map_rv(int rv)
-{
- switch(rv)
- {
- case WAIT_OBJECT_0:
- case WAIT_ABANDONED:
- return(MULTI_OK);
- case WAIT_TIMEOUT:
- return(MULTI_TIMEOUT);
- case WAIT_FAILED:
- return(MULTI_ERR);
- default:
- ap_assert(0);
- }
-
- ap_assert(0);
- return(0);
-}
-
-typedef void semaphore;
-typedef void event;
-
-static semaphore *
-create_semaphore(int initial)
-{
- return(CreateSemaphore(NULL, initial, 1000000, NULL));
-}
-
-static int acquire_semaphore(semaphore *semaphore_id)
-{
- int rv;
-
- rv = WaitForSingleObject(semaphore_id, INFINITE);
-
- return(map_rv(rv));
-}
-
-static int release_semaphore(semaphore *semaphore_id)
-{
- return(ReleaseSemaphore(semaphore_id, 1, NULL));
-}
-
-static void destroy_semaphore(semaphore *semaphore_id)
-{
- CloseHandle(semaphore_id);
-}
-
-
-/* To share the semaphores with other processes, we need a NULL ACL
- * Code from MS KB Q106387
- */
-static PSECURITY_ATTRIBUTES GetNullACL()
-{
- PSECURITY_DESCRIPTOR pSD;
- PSECURITY_ATTRIBUTES sa;
-
- sa = (PSECURITY_ATTRIBUTES) LocalAlloc(LPTR, sizeof(SECURITY_ATTRIBUTES));
- pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR,
- SECURITY_DESCRIPTOR_MIN_LENGTH);
- if (pSD == NULL || sa == NULL) {
- return NULL;
- }
- if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)
- || GetLastError()) {
- LocalFree( pSD );
- LocalFree( sa );
- return NULL;
- }
- if (!SetSecurityDescriptorDacl(pSD, TRUE, (PACL) NULL, FALSE)
- || GetLastError()) {
- LocalFree( pSD );
- LocalFree( sa );
- return NULL;
- }
- sa->nLength = sizeof(sa);
- sa->lpSecurityDescriptor = pSD;
- sa->bInheritHandle = TRUE;
- return sa;
-}
-
-static void CleanNullACL( void *sa ) {
- if( sa ) {
- LocalFree( ((PSECURITY_ATTRIBUTES)sa)->lpSecurityDescriptor);
- LocalFree( sa );
- }
-}
-
-/*
- * The Win32 call WaitForMultipleObjects will only allow you to wait for
- * a maximum of MAXIMUM_WAIT_OBJECTS (current 64). Since the threading
- * model in the multithreaded version of apache wants to use this call,
- * we are restricted to a maximum of 64 threads. This is a simplistic
- * routine that will increase this size.
- */
-static DWORD wait_for_many_objects(DWORD nCount, CONST HANDLE *lpHandles,
- DWORD dwSeconds)
-{
- time_t tStopTime;
- DWORD dwRet = WAIT_TIMEOUT;
- DWORD dwIndex=0;
- BOOL bFirst = TRUE;
-
- tStopTime = time(NULL) + dwSeconds;
-
- do {
- if (!bFirst)
- Sleep(1000);
- else
- bFirst = FALSE;
-
- for (dwIndex = 0; dwIndex * MAXIMUM_WAIT_OBJECTS < nCount; dwIndex++) {
- dwRet = WaitForMultipleObjects(
- min(MAXIMUM_WAIT_OBJECTS, nCount - (dwIndex * MAXIMUM_WAIT_OBJECTS)),
- lpHandles + (dwIndex * MAXIMUM_WAIT_OBJECTS),
- 0, 0);
-
- if (dwRet != WAIT_TIMEOUT) {
- break;
- }
- }
- } while((time(NULL) < tStopTime) && (dwRet == WAIT_TIMEOUT));
-
- return dwRet;
-}
-
-/*
- * Signalling Apache on NT.
- *
- * Under Unix, Apache can be told to shutdown or restart by sending various
- * signals (HUP, USR, TERM). On NT we don't have easy access to signals, so
- * we use "events" instead. The parent apache process goes into a loop
- * where it waits forever for a set of events. Two of those events are
- * called
- *
- * apPID_shutdown
- * apPID_restart
- *
- * (where PID is the PID of the apache parent process). When one of these
- * is signalled, the Apache parent performs the appropriate action. The events
- * can become signalled through internal Apache methods (e.g. if the child
- * finds a fatal error and needs to kill its parent), via the service
- * control manager (the control thread will signal the shutdown event when
- * requested to stop the Apache service), from the -k Apache command line,
- * or from any external program which finds the Apache PID from the
- * httpd.pid file.
- *
- * The signal_parent() function, below, is used to signal one of these events.
- * It can be called by any child or parent process, since it does not
- * rely on global variables.
- *
- * On entry, type gives the event to signal. 0 means shutdown, 1 means
- * graceful restart.
- */
-static void signal_parent(int type)
-{
- HANDLE e;
- char *signal_name;
- extern char signal_shutdown_name[];
- extern char signal_restart_name[];
-
- /* after updating the shutdown_pending or restart flags, we need
- * to wake up the parent process so it can see the changes. The
- * parent will normally be waiting for either a child process
- * to die, or for a signal on the "spache-signal" event. So set the
- * "apache-signal" event here.
- */
- if (one_process) {
- return;
- }
-
- switch(type) {
- case 0: signal_name = signal_shutdown_name; break;
- case 1: signal_name = signal_restart_name; break;
- default: return;
- }
- e = OpenEvent(EVENT_ALL_ACCESS, FALSE, signal_name);
- if (!e) {
- /* Um, problem, can't signal the parent, which means we can't
- * signal ourselves to die. Ignore for now...
- */
- ap_log_error(APLOG_MARK, APLOG_EMERG, GetLastError(), server_conf,
- "OpenEvent on %s event", signal_name);
- return;
- }
- if (SetEvent(e) == 0) {
- /* Same problem as above */
- ap_log_error(APLOG_MARK, APLOG_EMERG, GetLastError(), server_conf,
- "SetEvent on %s event", signal_name);
- CloseHandle(e);
- return;
- }
- CloseHandle(e);
-}
-static int volatile is_graceful = 0;
-API_EXPORT(int) ap_graceful_stop_signalled(void)
-{
- return is_graceful;
-}
-void ap_start_shutdown(void)
-{
- signal_parent(0);
-}
-/*
- * Initialise the signal names, in the global variables signal_name_prefix,
- * signal_restart_name and signal_shutdown_name.
- */
-
-#define MAX_SIGNAL_NAME 30 /* Long enough for apPID_shutdown, where PID is an int */
-char signal_name_prefix[MAX_SIGNAL_NAME];
-char signal_restart_name[MAX_SIGNAL_NAME];
-char signal_shutdown_name[MAX_SIGNAL_NAME];
-static void setup_signal_names(char *prefix)
-{
- ap_snprintf(signal_name_prefix, sizeof(signal_name_prefix), prefix);
- ap_snprintf(signal_shutdown_name, sizeof(signal_shutdown_name),
- "%s_shutdown", signal_name_prefix);
- ap_snprintf(signal_restart_name, sizeof(signal_restart_name),
- "%s_restart", signal_name_prefix);
-}
-
-/*
- * Routines that deal with sockets, some are WIN32 specific...
- */
-static int s_iInitCount = 0;
-static int AMCSocketInitialize(void)
-{
- int iVersionRequested;
- WSADATA wsaData;
- int err;
-
- if (s_iInitCount > 0) {
- s_iInitCount++;
- return (0);
- }
- else if (s_iInitCount < 0)
- return (s_iInitCount);
-
- /* s_iInitCount == 0. Do the initailization */
- iVersionRequested = MAKEWORD(2, 0);
- err = WSAStartup((WORD) iVersionRequested, &wsaData);
- if (err) {
- s_iInitCount = -1;
- return (s_iInitCount);
- }
- if (LOBYTE(wsaData.wVersion) != 1 ||
- HIBYTE(wsaData.wVersion) != 1) {
- s_iInitCount = -2;
- WSACleanup();
- return (s_iInitCount);
- }
-
- s_iInitCount++;
- return (s_iInitCount);
-
-}
-static void AMCSocketCleanup(void)
-{
- if (--s_iInitCount == 0)
- WSACleanup();
- return;
-}
-
-static void sock_disable_nagle(int s)
-{
- /* The Nagle algorithm says that we should delay sending partial
- * packets in hopes of getting more data. We don't want to do
- * this; we are not telnet. There are bad interactions between
- * persistent connections and Nagle's algorithm that have very severe
- * performance penalties. (Failing to disable Nagle is not much of a
- * problem with simple HTTP.)
- *
- * In spite of these problems, failure here is not a shooting offense.
- */
- int just_say_no = 1;
-
- if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &just_say_no,
- sizeof(int)) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, APR_SUCCESS, server_conf,
- "setsockopt: (TCP_NODELAY)");
- }
-}
-
-/*
- * Routines to deal with managing the list of listening sockets.
- */
-static ap_listen_rec *head_listener;
-static ap_inline ap_listen_rec *find_ready_listener(fd_set * main_fds)
-{
- ap_listen_rec *lr;
- SOCKET nsd;
-
- for (lr = head_listener; lr ; lr = lr->next) {
- ap_get_os_sock(&nsd, lr->sd);
- if (FD_ISSET(nsd, main_fds)) {
- head_listener = lr->next;
- if (head_listener == NULL)
- head_listener = ap_listeners;
-
- return (lr);
- }
- }
- return NULL;
-}
-static int setup_listeners(server_rec *s)
-{
- ap_listen_rec *lr;
- int num_listeners = 0;
- SOCKET nsd;
-
- /* Setup the listeners */
- FD_ZERO(&listenfds);
-
- if (ap_listen_open(s->process, s->port)) {
- return 0;
- }
- for (lr = ap_listeners; lr; lr = lr->next) {
- num_listeners++;
- if (lr->sd != NULL) {
- ap_get_os_sock(&nsd, lr->sd);
- FD_SET(nsd, &listenfds);
- if (listenmaxfd == INVALID_SOCKET || nsd > listenmaxfd) {
- listenmaxfd = nsd;
- }
- }
- lr->count = 0;
- }
-
- head_listener = ap_listeners;
-
- return num_listeners;
-}
-
-static int setup_inherited_listeners(server_rec *s)
-{
- WSAPROTOCOL_INFO WSAProtocolInfo;
- HANDLE pipe;
- ap_listen_rec *lr;
- DWORD BytesRead;
- int num_listeners = 0;
- SOCKET nsd;
-
- /* Setup the listeners */
- FD_ZERO(&listenfds);
-
- /* Set up a default listener if necessary */
-
- if (ap_listeners == NULL) {
- ap_listen_rec *lr;
- lr = ap_palloc(s->process->pool, sizeof(ap_listen_rec));
- if (!lr)
- return 0;
- lr->sd = NULL;
- lr->next = ap_listeners;
- ap_listeners = lr;
- }
-
- /* Open the pipe to the parent process to receive the inherited socket
- * data. The sockets have been set to listening in the parent process.
- */
- pipe = GetStdHandle(STD_INPUT_HANDLE);
- for (lr = ap_listeners; lr; lr = lr->next) {
- if (!ReadFile(pipe, &WSAProtocolInfo, sizeof(WSAPROTOCOL_INFO),
- &BytesRead, (LPOVERLAPPED) NULL)) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, GetLastError(), server_conf,
- "setup_inherited_listeners: Unable to read socket data from parent");
- signal_parent(0); /* tell parent to die */
- exit(1);
- }
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, APR_SUCCESS, server_conf,
- "Child %d: setup_inherited_listener() read = %d bytes of WSAProtocolInfo.", my_pid);
- nsd = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO,
- &WSAProtocolInfo, 0, 0);
- if (nsd == INVALID_SOCKET) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, WSAGetLastError(), server_conf,
- "Child %d: setup_inherited_listeners(), WSASocket failed to open the inherited socket.", my_pid);
- signal_parent(0); /* tell parent to die */
- exit(1);
- }
- if (nsd >= 0) {
- FD_SET(nsd, &listenfds);
- if (listenmaxfd == INVALID_SOCKET || nsd > listenmaxfd) {
- listenmaxfd = nsd;
- }
- }
-// ap_register_cleanup(p, (void *)lr->sd, socket_cleanup, ap_null_cleanup);
- ap_put_os_sock(&lr->sd, &nsd, pconf);
- lr->count = 0;
- }
- /* Now, read the AcceptExCompPort from the parent */
- ReadFile(pipe, &AcceptExCompPort, sizeof(AcceptExCompPort), &BytesRead, (LPOVERLAPPED) NULL);
- CloseHandle(pipe);
-
- for (lr = ap_listeners; lr; lr = lr->next) {
- num_listeners++;
- }
-
- head_listener = ap_listeners;
- return num_listeners;
-}
-
-
-/**********************************************************************
- * Multithreaded implementation
- *
- * This code is fairly specific to Win32.
- *
- * The model used to handle requests is a set of threads. One "main"
- * thread listens for new requests. When something becomes
- * available, it does a select and places the newly available socket
- * onto a list of "jobs" (add_job()). Then any one of a fixed number
- * of "worker" threads takes the top job off the job list with
- * remove_job() and handles that connection to completion. After
- * the connection has finished the thread is free to take another
- * job from the job list.
- *
- * In the code, the "main" thread is running within the child_main()
- * function. The first thing this function does is create the
- * worker threads, which operate in the child_sub_main() function. The
- * main thread then goes into a loop within child_main() where they
- * do a select() on the listening sockets. The select times out once
- * per second so that the thread can check for an "exit" signal
- * from the parent process (see below). If this signal is set, the
- * thread can exit, but only after it has accepted all incoming
- * connections already in the listen queue (since Win32 appears
- * to through away listened but unaccepted connections when a
- * process dies).
- *
- * Because the main and worker threads exist within a single process
- * they are vulnerable to crashes or memory leaks (crashes can also
- * be caused within modules, of course). There also needs to be a
- * mechanism to perform restarts and shutdowns. This is done by
- * creating the main & worker threads within a subprocess. A
- * main process (the "parent process") creates one (or more)
- * processes to do the work, then the parent sits around waiting
- * for the working process to die, in which case it starts a new
- * one. The parent process also handles restarts (by creating
- * a new working process then signalling the previous working process
- * exit ) and shutdowns (by signalling the working process to exit).
- * The parent process operates within the master_main() function. This
- * process also handles requests from the service manager (NT only).
- *
- * Signalling between the parent and working process uses a Win32
- * event. Each child has a unique name for the event, which is
- * passed to it with the -Z argument when the child is spawned. The
- * parent sets (signals) this event to tell the child to die.
- * At present all children do a graceful die - they finish all
- * current jobs _and_ empty the listen queue before they exit.
- * A non-graceful die would need a second event. The -Z argument in
- * the child is also used to create the shutdown and restart events,
- * since the prefix (apPID) contains the parent process PID.
- *
- * The code below starts with functions at the lowest level -
- * worker threads, and works up to the top level - the main()
- * function of the parent process.
- *
- * The scoreboard (in process memory) contains details of the worker
- * threads (within the active working process). There is no shared
- * "scoreboard" between processes, since only one is ever active
- * at once (or at most, two, when one has been told to shutdown but
- * is processes outstanding requests, and a new one has been started).
- * This is controlled by a "start_mutex" which ensures only one working
- * process is active at once.
- **********************************************************************/
-
-
-/*
- * Definition of jobs, shared by main and worker threads.
- */
-
-typedef struct joblist_s {
- struct joblist_s *next;
- int sock;
-} joblist;
-
-/*
- * Globals common to main and worker threads. This structure is not
- * used by the parent process.
- */
-
-typedef struct globals_s {
- semaphore *jobsemaphore;
- joblist *jobhead;
- joblist *jobtail;
- ap_lock_t *jobmutex;
- int jobcount;
-} globals;
-
-globals allowed_globals =
-{NULL, NULL, NULL, NULL, 0};
-#define MAX_SELECT_ERRORS 100
-#define PADDED_ADDR_SIZE sizeof(SOCKADDR_IN)+16
-
-/* Windows 9x specific code...
- * Accept processing for on Windows 95/98 uses a producer/consumer queue
- * model. A single thread accepts connections and queues the accepted socket
- * to the accept queue for consumption by a pool of worker threads.
- *
- * win9x_get_connection()
- * Calls remove_job() to pull a job from the accept queue. All the worker
- * threads block on remove_job.
- * accept_and_queue_connections()
- * The accept threads runs this function, which accepts connections off
- * the network and calls add_job() to queue jobs to the accept_queue.
- * add_job()/remove_job()
- * Add or remove an accepted socket from the list of sockets
- * connected to clients. allowed_globals.jobmutex protects
- * against multiple concurrent access to the linked list of jobs.
- */
-static void add_job(int sock)
-{
- joblist *new_job;
-
- new_job = (joblist *) malloc(sizeof(joblist));
- if (new_job == NULL) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Ouch! Out of memory in add_job()!");
- return;
- }
- new_job->next = NULL;
- new_job->sock = sock;
-
- ap_lock(allowed_globals.jobmutex);
-
- if (allowed_globals.jobtail != NULL)
- allowed_globals.jobtail->next = new_job;
- allowed_globals.jobtail = new_job;
- if (!allowed_globals.jobhead)
- allowed_globals.jobhead = new_job;
- allowed_globals.jobcount++;
- release_semaphore(allowed_globals.jobsemaphore);
-
- ap_unlock(allowed_globals.jobmutex);
-}
-
-static int remove_job(void)
-{
- joblist *job;
- int sock;
-
- acquire_semaphore(allowed_globals.jobsemaphore);
- ap_lock(allowed_globals.jobmutex);
-
- if (workers_may_exit && !allowed_globals.jobhead) {
- ap_unlock(allowed_globals.jobmutex);
- return (-1);
- }
- job = allowed_globals.jobhead;
- ap_assert(job);
- allowed_globals.jobhead = job->next;
- if (allowed_globals.jobhead == NULL)
- allowed_globals.jobtail = NULL;
- ap_unlock(allowed_globals.jobmutex);
- sock = job->sock;
- free(job);
-
- return (sock);
-}
-
-static void accept_and_queue_connections(void * dummy)
-{
- int requests_this_child = 0;
- struct timeval tv;
- fd_set main_fds;
- int wait_time = 1;
- int csd;
- int nsd = INVALID_SOCKET;
- struct sockaddr_in sa_client;
- int count_select_errors = 0;
- int rc;
- int clen;
-
- while (!workers_may_exit) {
- if (ap_max_requests_per_child && (requests_this_child > ap_max_requests_per_child)) {
- break;
- }
-
- tv.tv_sec = wait_time;
- tv.tv_usec = 0;
- memcpy(&main_fds, &listenfds, sizeof(fd_set));
-
-// rc = ap_select(listenmaxfd + 1, &main_fds, NULL, NULL, &tv);
- rc = select(listenmaxfd + 1, &main_fds, NULL, NULL, &tv);
-
- if (rc == 0 || (rc == SOCKET_ERROR && h_errno == WSAEINTR)) {
- count_select_errors = 0; /* reset count of errors */
- continue;
- }
- else if (rc == SOCKET_ERROR) {
- /* A "real" error occurred, log it and increment the count of
- * select errors. This count is used to ensure we don't go into
- * a busy loop of continuous errors.
- */
- ap_log_error(APLOG_MARK, APLOG_INFO, h_errno, server_conf,
- "select failed with errno %d", h_errno);
- count_select_errors++;
- if (count_select_errors > MAX_SELECT_ERRORS) {
- workers_may_exit = 1;
- ap_log_error(APLOG_MARK, APLOG_ERR, h_errno, server_conf,
- "Too many errors in select loop. Child process exiting.");
- break;
- }
- } else {
- ap_listen_rec *lr;
-
- lr = find_ready_listener(&main_fds);
- if (lr != NULL) {
- /* fetch the native socket descriptor */
- ap_get_os_sock(&nsd, lr->sd);
- }
- }
-
- do {
- clen = sizeof(sa_client);
- csd = accept(nsd, (struct sockaddr *) &sa_client, &clen);
- if (csd == INVALID_SOCKET) {
- csd = -1;
- }
- } while (csd < 0 && h_errno == WSAEINTR);
-
- if (csd < 0) {
- if (h_errno != WSAECONNABORTED) {
- ap_log_error(APLOG_MARK, APLOG_ERR, h_errno, server_conf,
- "accept: (client socket)");
- }
- }
- else {
- add_job(csd);
- requests_this_child++;
- }
- }
- SetEvent(exit_event);
-}
-static PCOMP_CONTEXT win9x_get_connection(PCOMP_CONTEXT context)
-{
- int len;
-
- if (context == NULL) {
- /* allocate the completion context and the transaction pool */
- context = ap_pcalloc(pconf, sizeof(COMP_CONTEXT));
- if (!context) {
- ap_log_error(APLOG_MARK,APLOG_ERR, GetLastError(), server_conf,
- "win9x_get_connection: ap_pcalloc() failed. Process will exit.");
- return NULL;
- }
- ap_create_context(&context->ptrans, pconf);
- }
-
-
- while (1) {
- ap_clear_pool(context->ptrans);
- context->accept_socket = remove_job();
- if (context->accept_socket == -1) {
- return NULL;
- }
- //ap_note_cleanups_for_socket(ptrans, csd);
- len = sizeof(struct sockaddr);
- context->sa_server = ap_palloc(context->ptrans, len);
- if (getsockname(context->accept_socket,
- context->sa_server, &len)== SOCKET_ERROR) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, WSAGetLastError(), server_conf,
- "getsockname failed");
- continue;
- }
- len = sizeof(struct sockaddr);
- context->sa_client = ap_palloc(context->ptrans, len);
- if ((getpeername(context->accept_socket,
- context->sa_client, &len)) == SOCKET_ERROR) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, h_errno, server_conf,
- "getpeername failed with error %d\n", WSAGetLastError());
- memset(&context->sa_client, '\0', sizeof(context->sa_client));
- }
-
- context->conn_io = ap_bcreate(context->ptrans, B_RDWR);
-
- /* do we NEED_DUPPED_CSD ?? */
-
- return context;
- }
-}
-
-/*
- * Windows 2000/NT specific code...
- * create_acceptex_context()
- * reset_acceptex_context()
- * drain_acceptex_complport()
- * winnt_get_connection()
- *
- * TODO: Insert a discussion of 'completion contexts' and what these function do here...
- */
-static void drain_acceptex_complport(HANDLE hComplPort, BOOLEAN bCleanUp)
-{
- LPOVERLAPPED pol;
- PCOMP_CONTEXT context;
- int rc;
- DWORD BytesRead;
- DWORD CompKey;
- int lastError;
-
- while (1) {
- context = NULL;
- rc = GetQueuedCompletionStatus(hComplPort, &BytesRead, &CompKey,
- &pol, 1000);
- if (!rc) {
- lastError = GetLastError();
- if (lastError == ERROR_OPERATION_ABORTED) {
- ap_log_error(APLOG_MARK,APLOG_INFO,lastError, server_conf,
- "Child: %d - Draining a packet off the completion port.", my_pid);
- continue;
- }
- break;
- }
- ap_log_error(APLOG_MARK,APLOG_INFO,APR_SUCCESS, server_conf,
- "Child: %d - Nuking an active connection. context = %x", my_pid, context);
- context = (PCOMP_CONTEXT) pol;
- if (context && bCleanUp) {
- /* It is only valid to clean-up in the process that initiated the I/O */
- closesocket(context->accept_socket);
- CloseHandle(context->Overlapped.hEvent);
- }
- }
-}
-static int create_acceptex_context(ap_context_t *_pconf, ap_listen_rec *lr)
-{
- PCOMP_CONTEXT context;
- DWORD BytesRead;
- SOCKET nsd;
- int lasterror;
-
- /* allocate the completion context */
- context = ap_pcalloc(_pconf, sizeof(COMP_CONTEXT));
- if (!context) {
- ap_log_error(APLOG_MARK,APLOG_ERR, GetLastError(), server_conf,
- "create_acceptex_context: ap_pcalloc() failed. Process will exit.");
- return -1;
- }
-
- /* initialize the completion context */
- context->lr = lr;
- context->Overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- if (context->Overlapped.hEvent == NULL) {
- ap_log_error(APLOG_MARK,APLOG_ERR, GetLastError(), server_conf,
- "create_acceptex_context: CreateEvent() failed. Process will exit.");
- return -1;
- }
- context->accept_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (context->accept_socket == INVALID_SOCKET) {
- ap_log_error(APLOG_MARK,APLOG_ERR, WSAGetLastError(), server_conf,
- "create_acceptex_context: socket() failed. Process will exit.");
- return -1;
- }
- ap_create_context(&context->ptrans, _pconf);
- context->conn_io = ap_bcreate(context->ptrans, B_RDWR);
- context->recv_buf = context->conn_io->inbase;
- context->recv_buf_size = context->conn_io->bufsiz - 2*PADDED_ADDR_SIZE;
- ap_get_os_sock(&nsd, context->lr->sd);
-
- /* AcceptEx on the completion context. The completion context will be signaled
- * when a connection is accepted. */
- if (!AcceptEx(nsd, context->accept_socket,
- context->recv_buf,
- 0, //context->recv_buf_size,
- PADDED_ADDR_SIZE, PADDED_ADDR_SIZE,
- &BytesRead,
- (LPOVERLAPPED) context)) {
- lasterror = WSAGetLastError();
- if (lasterror != ERROR_IO_PENDING) {
- ap_log_error(APLOG_MARK,APLOG_ERR, WSAGetLastError(), server_conf,
- "create_acceptex_context: AcceptEx failed. Process will exit.");
- return -1;
- }
- }
- lr->count++;
-
- return 0;
-}
-static ap_inline int reset_acceptex_context(PCOMP_CONTEXT context)
-{
- DWORD BytesRead;
- SOCKET nsd;
- int lasterror;
-
- context->lr->count++;
-
- if (context->accept_socket == -1)
- context->accept_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
-
- if (context->accept_socket == INVALID_SOCKET) {
- ap_log_error(APLOG_MARK,APLOG_ERR, WSAGetLastError(), server_conf,
- "reset_acceptex_context: socket() failed. Process will exit.");
- return -1;
- }
-
- ap_clear_pool(context->ptrans);
- context->sock = NULL;
- context->conn_io = ap_bcreate(context->ptrans, B_RDWR);
- context->recv_buf = context->conn_io->inbase;
- context->recv_buf_size = context->conn_io->bufsiz - 2*PADDED_ADDR_SIZE;
- ap_get_os_sock(&nsd, context->lr->sd);
-
- if (!AcceptEx(nsd, context->accept_socket,
- context->recv_buf,
- 0, //context->recv_buf_size,
- PADDED_ADDR_SIZE, PADDED_ADDR_SIZE,
- &BytesRead, (LPOVERLAPPED) context)) {
- lasterror = WSAGetLastError();
- if (lasterror != ERROR_IO_PENDING) {
- ap_log_error(APLOG_MARK,APLOG_ERR, WSAGetLastError(), server_conf,
- "reset_acceptex_context: AcceptEx failed. Leaving the process running.");
- return -1;
- }
- }
-
- return 0;
-}
-static PCOMP_CONTEXT winnt_get_connection(PCOMP_CONTEXT context)
-{
- int requests_this_child = 0;
- int rc;
- LPOVERLAPPED pol;
- DWORD CompKey;
- DWORD BytesRead;
-
- if (context != NULL) {
- /* If child shutdown has been signaled, clean-up the completion context */
- if (workers_may_exit) {
- CloseHandle(context->Overlapped.hEvent);
- /* destroy pool */
- }
- else {
- context->accept_socket = -1; /* Don't reuse the accept_socket */
- if (reset_acceptex_context(context) == -1) {
- if (context->accept_socket != -1)
- closesocket(context->accept_socket);
- CloseHandle(context->Overlapped.hEvent);
- return NULL;
- }
- }
- }
-
- while (1) {
- rc = GetQueuedCompletionStatus(AcceptExCompPort,
- &BytesRead,
- &CompKey,
- &pol,
- INFINITE);
- if (!rc) {
- ap_log_error(APLOG_MARK,APLOG_ERR, GetLastError(), server_conf,
- "Child: %d - GetQueuedCompletionStatus() failed", my_pid);
- continue;
- }
- break;
- }
- context = (PCOMP_CONTEXT) pol;
- if (CompKey == 999) {
- return NULL;
- }
-
- /* Each listener needs at least 1 context available to receive connections on.
- * Create additional listener contexts if needed.
- */
- ap_lock(allowed_globals.jobmutex);
- context->lr->count--;
- if ((context->lr->count < 2) && !workers_may_exit) {
- if (create_acceptex_context(pconf, context->lr) == -1) {
- ap_log_error(APLOG_MARK,APLOG_ERR, GetLastError(), server_conf,
- "Unable to create an AcceptEx completion context -- process will exit");
- signal_parent(0);
- return NULL;
- }
- }
- ap_unlock(allowed_globals.jobmutex);
-
- /* Received a connection */
- context->conn_io->incnt = BytesRead;
- GetAcceptExSockaddrs(context->recv_buf,
- 0, //context->recv_buf_size,
- PADDED_ADDR_SIZE,
- PADDED_ADDR_SIZE,
- &context->sa_server,
- &context->sa_server_len,
- &context->sa_client,
- &context->sa_client_len);
-
- return context;
-
-}
-/*
- * worker_main() - this is the main loop for the worker threads
- *
- * Windows 95/98
- * Each thread runs within this function. They wait within remove_job()
- * for a job to become available, then handle all the requests on that
- * connection until it is closed, then return to remove_job().
- *
- * The worker thread will exit when it removes a job which contains
- * socket number -1. This provides a graceful thread exit, since
- * it will never exit during a connection.
- *
- * This code in this function is basically equivalent to the child_main()
- * from the multi-process (Unix) environment, except that we
- *
- * - do not call child_init_modules (child init API phase)
- * - block in remove_job, and when unblocked we have an already
- * accepted socket, instead of blocking on a mutex or select().
- */
-
-static void worker_main(int child_num)
-{
- static BOOLEAN bListenersStarted = FALSE;
- PCOMP_CONTEXT context = NULL;
-
- if (osver.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) {
- /* Windows NT/2000: Create AcceptEx completion contexts for each of the
- * listeners
- */
- ap_lock(allowed_globals.jobmutex);
- if (!bListenersStarted) {
- ap_listen_rec *lr;
- int i;
- bListenersStarted = TRUE;
- for (lr = ap_listeners; lr != NULL; lr = lr->next) {
- for(i=0; i<2; i++) {
- if (lr->count < 2)
- if (create_acceptex_context(pconf, lr) == -1) {
- ap_log_error(APLOG_MARK,APLOG_ERR, GetLastError(), server_conf,
- "Unable to create an AcceptEx completion context -- process will exit");
- signal_parent(0); /* tell parent to die */
- }
- }
- }
- }
- ap_unlock(allowed_globals.jobmutex);
- }
-
- while (1) {
- conn_rec *current_conn;
- ap_iol *iol;
-
- /* Grab a connection off the network */
- if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
- context = win9x_get_connection(context);
- }
- else {
- context = winnt_get_connection(context);
- }
-
- if (!context)
- break;
- sock_disable_nagle(context->accept_socket);
- ap_put_os_sock(&context->sock, &context->accept_socket, context->ptrans);
- ap_register_cleanup(context->ptrans, context->sock, socket_cleanup, ap_null_cleanup);
- iol = win32_attach_socket(context->ptrans, context->sock);
- if (iol == NULL) {
- ap_log_error(APLOG_MARK, APLOG_ERR, APR_ENOMEM, server_conf,
- "worker_main: attach_socket() failed. Continuing...");
- closesocket(context->accept_socket);
- continue;
- }
- ap_bpush_iol(context->conn_io, iol);
- current_conn = ap_new_connection(context->ptrans, server_conf, context->conn_io,
- (struct sockaddr_in *) context->sa_client,
- (struct sockaddr_in *) context->sa_server,
- child_num);
-
- ap_process_connection(current_conn);
- }
-#if 0
- ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, server_conf,
- "child_main: Setting exit_event");
- SetEvent(exit_event);
-#endif
- /* TODO: Add code to clean-up completion contexts here */
-}
-
-static void cleanup_thread(thread **handles, int *thread_cnt, int thread_to_clean)
-{
- int i;
-
- free_thread(handles[thread_to_clean]);
- for (i = thread_to_clean; i < ((*thread_cnt) - 1); i++)
- handles[i] = handles[i + 1];
- (*thread_cnt)--;
-}
-
-
-
-/*
- * child_main() is main loop for the child process. The loop in
- * this function becomes the controlling thread for the actually working
- * threads (which run in a loop in child_sub_main()).
- * Globals Used:
- * exit_event, start_mutex, ap_threads_per_child, server_conf,
- * h_errno defined to WSAGetLastError in winsock2.h,
- */
-static void child_main()
-{
- int nthreads = ap_threads_per_child;
-
- thread **child_handles;
- int rv;
- ap_status_t status;
- time_t end_time;
- int i;
- ap_context_t *pchild;
-
- ap_create_context(&pchild, pconf);
-
-// ap_restart_time = time(NULL);
- /*
- * Wait until we have permission to start accepting connections.
- * start_mutex is used to ensure that only one child ever
- * goes into the listen/accept loop at once.
- */
- status = ap_lock(start_mutex);
- if (status != APR_SUCCESS) {
- ap_log_error(APLOG_MARK,APLOG_ERR, status, server_conf,
- "Child %d: Failed to acquire the start_mutex. Process will exit.", my_pid);
- signal_parent(0); /* tell parent to die */
- ap_destroy_context(pchild);
- exit(0);
- }
- ap_log_error(APLOG_MARK,APLOG_INFO, APR_SUCCESS, server_conf, "Child %d: Acquired the start mutex", my_pid);
-
- /* Setup the listening sockets */
- if (one_process) {
- ap_listen_rec *lr;
- setup_listeners(server_conf);
-
- /* Associate the socket with the IO Completion port */
- for (lr = ap_listeners; lr; lr = lr->next) {
- int nsd;
- ap_get_os_sock(&nsd,lr->sd);
- CreateIoCompletionPort((HANDLE) nsd, AcceptExCompPort, 0, 0);
- }
-
- } else {
- setup_inherited_listeners(server_conf);
- }
- if (listenmaxfd == INVALID_SOCKET) {
- /* No sockets were made, better log something and exit */
- ap_log_error(APLOG_MARK, APLOG_CRIT, h_errno, NULL,
- "No sockets were created for listening");
- signal_parent(0); /* tell parent to die */
- ap_destroy_context(pchild);
- exit(0);
- }
-
- allowed_globals.jobsemaphore = create_semaphore(0);
- ap_create_lock(&allowed_globals.jobmutex, APR_MUTEX, APR_INTRAPROCESS, NULL, pchild);
-
- /* Create the worker thread pool */
- ap_log_error(APLOG_MARK,APLOG_INFO, APR_SUCCESS, server_conf, "Child %d: Creating %d worker threads",my_pid, nthreads);
- child_handles = (thread *) alloca(nthreads * sizeof(int));
- for (i = 0; i < nthreads; i++) {
- child_handles[i] = create_thread((void (*)(void *)) worker_main, (void *) i);
- }
-
- if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
- /* Win95/98: Create the accept thread */
- create_thread((void (*)(void *)) accept_and_queue_connections, (void *) NULL);
- }
-
- /* Wait for the exit event to be signaled by the parent process */
- rv = WaitForSingleObject(exit_event, INFINITE);
-
- ap_log_error(APLOG_MARK,APLOG_INFO, APR_SUCCESS, server_conf,
- "Child %d: Exit event signaled. Child process is ending.", my_pid);
- workers_may_exit = 1;
-
- /* Shutdown the worker threads */
- if (osver.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
- for (i = 0; i < nthreads; i++) {
- add_job(-1);
- }
- }
- else { /* Windows NT/2000 */
- /* Hack alert... Give the server a couple of seconds to receive
- * connections and drain AcceptEx completion contexts. We will
- * probably drop a few connections across a graceful restart, but
- * hopefully not many. This needs work...*/
- Sleep(2000);
-
- /* Tell the worker threads to exit. Any connections accepted on
- * the completion port from now will be dropped */
- for (i=0; i < nthreads; i++) {
- if (!PostQueuedCompletionStatus(AcceptExCompPort, 0, 999, NULL)) {
- ap_log_error(APLOG_MARK,APLOG_INFO, APR_SUCCESS, server_conf,
- "PostQueuedCompletionStatus failed");
- }
- }
- }
-
- /* Wait for the worker threads to die */
- end_time = time(NULL) + 180;
- while (nthreads) {
- rv = wait_for_many_objects(nthreads, child_handles, end_time - time(NULL));
- if (rv != WAIT_TIMEOUT) {
- rv = rv - WAIT_OBJECT_0;
- ap_assert((rv >= 0) && (rv < nthreads));
- cleanup_thread(child_handles, &nthreads, rv);
- continue;
- }
- break;
- }
- for (i = 0; i < nthreads; i++) {
- kill_thread(child_handles[i]);
- free_thread(child_handles[i]);
- }
- ap_log_error(APLOG_MARK,APLOG_INFO, APR_SUCCESS, server_conf,
- "Child %d: All worker threads have ended.", my_pid);
-
- if (osver.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) {
- /* All the worker threads should have exited by now, which will
- * cause any outstanding I/O on the completion port to be aborted.
- * Drain the completion port of this aborted I/O/
- */
- drain_acceptex_complport(AcceptExCompPort, TRUE);
- }
-
- ap_log_error(APLOG_MARK,APLOG_INFO, APR_SUCCESS, server_conf,
- "Child %d: Releasing the start mutex", my_pid);
- ap_unlock(start_mutex);
-
- /* Still need to register cleanups for the sockets */
- CloseHandle(AcceptExCompPort);
- destroy_semaphore(allowed_globals.jobsemaphore);
- ap_destroy_lock(allowed_globals.jobmutex);
-
- ap_destroy_context(pchild);
-}
-
-/*
- * Spawn a child Apache process. The child process has the command line arguments from
- * argc and argv[], plus a -Z argument giving the name of an event. The child should
- * open and poll or wait on this event. When it is signalled, the child should die.
- * prefix is a prefix string for the event name.
- *
- * The child_num argument on entry contains a serial number for this child (used to create
- * a unique event name). On exit, this number will have been incremented by one, ready
- * for the next call.
- *
- * On exit, the value pointed to be *ev will contain the event created
- * to signal the new child process.
- *
- * The return value is the handle to the child process if successful, else -1. If -1 is
- * returned the error will already have been logged by ap_log_error().
- */
-
-/**********************************************************************
- * master_main - this is the parent (main) process. We create a
- * child process to do the work, then sit around waiting for either
- * the child to exit, or a restart or exit signal. If the child dies,
- * we just respawn a new one. If we have a shutdown or graceful restart,
- * tell the child to die when it is ready. If it is a non-graceful
- * restart, force the child to die immediately.
- **********************************************************************/
-
-#define MAX_PROCESSES 50 /* must be < MAX_WAIT_OBJECTS-1 */
-
-static void cleanup_process(HANDLE *handles, HANDLE *events, int position, int *processes)
-{
- int i;
- int handle = 0;
-
- CloseHandle(handles[position]);
- CloseHandle(events[position]);
-
- handle = (int)handles[position];
-
- for (i = position; i < (*processes)-1; i++) {
- handles[i] = handles[i + 1];
- events[i] = events[i + 1];
- }
- (*processes)--;
-}
-
-static int create_process(ap_context_t *p, HANDLE *handles, HANDLE *events, int *processes)
-{
-
- int rv;
- char buf[1024];
- char *pCommand;
- int i;
- STARTUPINFO si; /* Filled in prior to call to CreateProcess */
- PROCESS_INFORMATION pi; /* filled in on call to CreateProces */
-
- ap_listen_rec *lr;
- DWORD BytesWritten;
- HANDLE hPipeRead = NULL;
- HANDLE hPipeWrite = NULL;
- SECURITY_ATTRIBUTES sa = {0};
-
- sa.nLength = sizeof(sa);
- sa.bInheritHandle = TRUE;
- sa.lpSecurityDescriptor = NULL;
-
- /* Create the IOCompletionPort */
- if (AcceptExCompPort == NULL) {
- AcceptExCompPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE,
- NULL,
- 0,
- 0); /* CONCURRENT ACTIVE THREADS */
- if (AcceptExCompPort == NULL) {
- ap_log_error(APLOG_MARK,APLOG_ERR, GetLastError(), server_conf,
- "Unable to create the AcceptExCompletionPort -- process will exit");
- return -1;
- }
- }
-
- /* Build the command line. Should look something like this:
- * C:/apache/bin/apache.exe -f ap_server_confname
- * First, get the path to the executable...
- */
- rv = GetModuleFileName(NULL, buf, sizeof(buf));
- if (rv == sizeof(buf)) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, ERROR_BAD_PATHNAME, server_conf,
- "Parent: Path to Apache process too long");
- return -1;
- } else if (rv == 0) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, GetLastError(), server_conf,
- "Parent: GetModuleFileName() returned NULL for current process.");
- return -1;
- }
-
- /* Build the command line */
- pCommand = ap_psprintf(p, "\"%s\"", buf);
- for (i = 1; i < server_conf->process->argc; i++) {
- pCommand = ap_pstrcat(p, pCommand, " \"", server_conf->process->argv[i], "\"", NULL);
- }
-
- /* Create a pipe to send socket info to the child */
- if (!CreatePipe(&hPipeRead, &hPipeWrite, &sa, 0)) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, GetLastError(), server_conf,
- "Parent: Unable to create pipe to child process.\n");
- return -1;
- }
-
- SetEnvironmentVariable("AP_PARENT_PID",ap_psprintf(p,"%d",parent_pid));
-
- /* Give the read end of the pipe (hPipeRead) to the child as stdin. The
- * parent will write the socket data to the child on this pipe.
- */
- memset(&si, 0, sizeof(si));
- memset(&pi, 0, sizeof(pi));
- si.cb = sizeof(si);
- si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
- si.wShowWindow = SW_HIDE;
- si.hStdInput = hPipeRead;
-
- if (!CreateProcess(NULL, pCommand, NULL, NULL,
- TRUE, /* Inherit handles */
- CREATE_SUSPENDED, /* Creation flags */
- NULL, /* Environment block */
- NULL,
- &si, &pi)) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, GetLastError(), server_conf,
- "Parent: Not able to create the child process.");
- /*
- * We must close the handles to the new process and its main thread
- * to prevent handle and memory leaks.
- */
- CloseHandle(pi.hProcess);
- CloseHandle(pi.hThread);
- return -1;
- }
- else {
- HANDLE kill_event;
- LPWSAPROTOCOL_INFO lpWSAProtocolInfo;
- HANDLE hDupedCompPort;
-
- ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, server_conf,
- "Parent: Created child process %d", pi.dwProcessId);
-
- SetEnvironmentVariable("AP_PARENT_PID",NULL);
-
- /* Create the exit_event, apCchild_pid */
- sa.nLength = sizeof(sa);
- sa.bInheritHandle = TRUE;
- sa.lpSecurityDescriptor = NULL;
- kill_event = CreateEvent(&sa, TRUE, FALSE, ap_psprintf(pconf,"apC%d", pi.dwProcessId));
- if (!kill_event) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, GetLastError(), server_conf,
- "Parent: Could not create exit event for child process");
- CloseHandle(pi.hProcess);
- CloseHandle(pi.hThread);
- return -1;
- }
-
- /* Assume the child process lives. Update the process and event tables */
- handles[*processes] = pi.hProcess;
- events[*processes] = kill_event;
- (*processes)++;
-
- /* We never store the thread's handle, so close it now. */
- ResumeThread(pi.hThread);
- CloseHandle(pi.hThread);
-
- /* Run the chain of open sockets. For each socket, duplicate it
- * for the target process then send the WSAPROTOCOL_INFO
- * (returned by dup socket) to the child */
- for (lr = ap_listeners; lr; lr = lr->next) {
- int nsd;
- lpWSAProtocolInfo = ap_pcalloc(p, sizeof(WSAPROTOCOL_INFO));
- ap_get_os_sock(&nsd,lr->sd);
- /* Associate the socket with the IOcompletion port */
- CreateIoCompletionPort((HANDLE) nsd, AcceptExCompPort, 0, 0);
- ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, APR_SUCCESS, server_conf,
- "Parent: Duplicating socket %d and sending it to child process %d", nsd, pi.dwProcessId);
- if (WSADuplicateSocket(nsd, pi.dwProcessId,
- lpWSAProtocolInfo) == SOCKET_ERROR) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, h_errno, server_conf,
- "Parent: WSADuplicateSocket failed for socket %d.", lr->sd );
- return -1;
- }
-
- if (!WriteFile(hPipeWrite, lpWSAProtocolInfo, (DWORD) sizeof(WSAPROTOCOL_INFO),
- &BytesWritten,
- (LPOVERLAPPED) NULL)) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, GetLastError(), server_conf,
- "Parent: Unable to write duplicated socket %d to the child.", lr->sd );
- return -1;
- }
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, APR_SUCCESS, server_conf,
- "Parent: BytesWritten = %d WSAProtocolInfo = %x20", BytesWritten, *lpWSAProtocolInfo);
- }
- /* Now, send the AcceptEx completion port to the child */
- if (!DuplicateHandle(GetCurrentProcess(), AcceptExCompPort,
- pi.hProcess, &hDupedCompPort, 0,
- TRUE, DUPLICATE_SAME_ACCESS)) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, GetLastError(), server_conf,
- "Parent: Unable to duplicate AcceptEx completion port. Shutting down.");
- return -1;
- }
- WriteFile(hPipeWrite, &hDupedCompPort, (DWORD) sizeof(hDupedCompPort), &BytesWritten, (LPOVERLAPPED) NULL);
- }
-
- CloseHandle(hPipeRead);
- CloseHandle(hPipeWrite);
-
- return 0;
-}
-
-static int master_main(server_rec *s, HANDLE shutdown_event, HANDLE restart_event)
-{
- int remaining_children_to_start = ap_daemons_to_start;
- int i;
- int rv, cld;
- int child_num = 0;
- int restart_pending = 0;
- int shutdown_pending = 0;
- int current_live_processes = 0; /* number of child process we know about */
-
- HANDLE process_handles[MAX_PROCESSES];
- HANDLE process_kill_events[MAX_PROCESSES];
-
- setup_listeners(s);
-
- /* Create child process
- * Should only be one in this version of Apache for WIN32
- */
- service_set_status(SERVICE_START_PENDING);
- while (remaining_children_to_start--) {
- if (create_process(pconf, process_handles, process_kill_events,
- &current_live_processes) < 0) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, GetLastError(), server_conf,
- "master_main: create child process failed. Exiting.");
- shutdown_pending = 1;
- goto die_now;
- }
- }
- service_set_status(SERVICE_RUNNING);
-
- restart_pending = shutdown_pending = 0;
-
- /* Wait for shutdown or restart events or for child death */
- process_handles[current_live_processes] = shutdown_event;
- process_handles[current_live_processes+1] = restart_event;
- printf("process/shutdown/restart %d %d %d\n", process_handles[0], process_handles[1], process_handles[2]);
- rv = WaitForMultipleObjects(current_live_processes+2, (HANDLE *)process_handles,
- FALSE, INFINITE);
- cld = rv - WAIT_OBJECT_0;
- if (rv == WAIT_FAILED) {
- /* Something serious is wrong */
- ap_log_error(APLOG_MARK,APLOG_CRIT, GetLastError(), server_conf,
- "master_main: WaitForMultipeObjects WAIT_FAILED -- doing server shutdown");
- shutdown_pending = 1;
- }
- else if (rv == WAIT_TIMEOUT) {
- /* Hey, this cannot happen */
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), s,
- "master_main: WaitForMultipeObjects with INFINITE wait exited with WAIT_TIMEOUT");
- shutdown_pending = 1;
- }
- else if (cld == current_live_processes) {
- /* shutdown_event signalled */
- shutdown_pending = 1;
- printf("shutdown event signaled\n");
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, APR_SUCCESS, s,
- "master_main: Shutdown event signaled -- doing server shutdown.");
- if (ResetEvent(shutdown_event) == 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), s,
- "ResetEvent(shutdown_event)");
- }
-
- }
- else if (cld == current_live_processes+1) {
- /* restart_event signalled */
- int children_to_kill = current_live_processes;
- restart_pending = 1;
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, APR_SUCCESS, s,
- "master_main: Restart event signaled. Doing a graceful restart.");
- if (ResetEvent(restart_event) == 0) {
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), s,
- "master_main: ResetEvent(restart_event) failed.");
- }
- /* Signal each child process to die
- * We are making a big assumption here that the child process, once signaled,
- * will REALLY go away. Since this is a restart, we do not want to hold the
- * new child process up waiting for the old child to die. Remove the old
- * child out of the process_handles ap_table_t and hope for the best...
- */
- for (i = 0; i < children_to_kill; i++) {
- printf("SetEvent handle = %d\n", process_kill_events[i]);
- if (SetEvent(process_kill_events[i]) == 0)
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), s,
- "master_main: SetEvent for child process in slot #%d failed", i);
- cleanup_process(process_handles, process_kill_events, i, &current_live_processes);
- }
- }
- else {
- /* A child process must have exited because of a fatal error condition (seg fault, etc.).
- * Remove the dead process
- * from the process_handles and process_kill_events ap_table_t and create a new
- * child process.
- * TODO: Consider restarting the child immediately without looping through http_main
- * and without rereading the configuration. Will need this if we ever support multiple
- * children. One option, create a parent thread which waits on child death and restarts it.
- */
- restart_pending = 1;
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, APR_SUCCESS, server_conf,
- "master_main: Child process failed. Restarting the child process.");
- ap_assert(cld < current_live_processes);
- cleanup_process(process_handles, process_kill_events, cld, &current_live_processes);
- /* APD2("main_process: child in slot %d died", rv); */
- /* restart_child(process_hancles, process_kill_events, cld, &current_live_processes); */
-
- /* Drain the AcceptEx completion port of any outstanding I/O pending for the dead
- * process. */
- drain_acceptex_complport(AcceptExCompPort, FALSE);
- }
-
-die_now:
- if (shutdown_pending) {
- int tmstart = time(NULL);
- /* Signal each child processes to die */
- for (i = 0; i < current_live_processes; i++) {
- printf("SetEvent handle = %d\n", process_kill_events[i]);
- if (SetEvent(process_kill_events[i]) == 0)
- ap_log_error(APLOG_MARK,APLOG_ERR, GetLastError(), server_conf,
- "master_main: SetEvent for child process in slot #%d failed", i);
- }
-
- while (current_live_processes && ((tmstart+60) > time(NULL))) {
- rv = WaitForMultipleObjects(current_live_processes, (HANDLE *)process_handles, FALSE, 2000);
- if (rv == WAIT_TIMEOUT)
- continue;
- ap_assert(rv != WAIT_FAILED);
- cld = rv - WAIT_OBJECT_0;
- ap_assert(rv < current_live_processes);
- cleanup_process(process_handles, process_kill_events, cld, &current_live_processes);
- }
- for (i = 0; i < current_live_processes; i++) {
- ap_log_error(APLOG_MARK,APLOG_ERR|APLOG_NOERRNO, APR_SUCCESS, server_conf,
- "forcing termination of child #%d (handle %d)", i, process_handles[i]);
- TerminateProcess((HANDLE) process_handles[i], 1);
- }
- return (0); /* Tell the caller we are shutting down */
- }
-
- return (1); /* Tell the caller we want a restart */
-}
-
-/*
- * winnt_pre_config() hook
- */
-static void winnt_pre_config(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp)
-{
- char *pid;
-
- one_process = !!getenv("ONE_PROCESS");
-
- osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osver);
-
- /* AP_PARENT_PID is only valid in the child */
- pid = getenv("AP_PARENT_PID");
- if (pid) {
- /* This is the child */
- parent_pid = atoi(pid);
- my_pid = getpid();
- }
- else {
- /* This is the parent */
- parent_pid = my_pid = getpid();
-
- }
-
- ap_listen_pre_config();
- ap_daemons_to_start = DEFAULT_NUM_DAEMON;
- ap_threads_per_child = DEFAULT_START_THREAD;
- ap_pid_fname = DEFAULT_PIDLOG;
- max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
-
- ap_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir));
-
-}
-
-static void winnt_post_config(ap_context_t *pconf, ap_context_t *plog, ap_context_t *ptemp, server_rec* server_conf)
-{
- server_conf = server_conf;
-}
-
-API_EXPORT(int) ap_mpm_run(ap_context_t *_pconf, ap_context_t *plog, server_rec *s )
-{
-
- char* exit_event_name;
- static int restart = 0; /* Default is to not restart */
-// time_t tmstart;
- static HANDLE shutdown_event; /* used to signal shutdown to parent */
- static HANDLE restart_event; /* used to signal a restart to parent */
-
- pconf = _pconf;
- server_conf = s;
-
- if ((parent_pid != my_pid) || one_process) {
- /* Child process */
- ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, server_conf,
- "Child %d: Child process is running", my_pid);
- AMCSocketInitialize();
- exit_event_name = ap_psprintf(pconf, "apC%d", my_pid);
- setup_signal_names(ap_psprintf(pconf,"ap%d", parent_pid));
-
- if (one_process) {
- /* Create the IO CompletionPort */
- if (AcceptExCompPort == NULL) {
- AcceptExCompPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE,
- NULL, 0, 0);
- if (AcceptExCompPort == NULL) {
- ap_log_error(APLOG_MARK,APLOG_ERR, GetLastError(), server_conf,
- "Unable to create the AcceptExCompletionPort -- process will exit");
- return -1;
- }
- }
- ap_create_lock(&start_mutex,APR_MUTEX, APR_CROSS_PROCESS,signal_name_prefix,pconf);
- exit_event = CreateEvent(NULL, TRUE, FALSE, exit_event_name);
- }
- else {
- ap_child_init_lock(&start_mutex, signal_name_prefix, pconf);
- exit_event = OpenEvent(EVENT_ALL_ACCESS, FALSE, exit_event_name);
- ap_log_error(APLOG_MARK, APLOG_INFO, APR_SUCCESS, server_conf,
- "Child %d: exit_event_name = %s", my_pid, exit_event_name);
- }
- ap_assert(start_mutex);
- ap_assert(exit_event);
-
- child_main();
-
- CloseHandle(exit_event);
- AMCSocketCleanup();
- restart = 0;
- }
- else {
- /* Parent process */
- PSECURITY_ATTRIBUTES sa = GetNullACL(); /* returns NULL if invalid (Win95?) */
-
- setup_signal_names(ap_psprintf(pconf,"ap%d", parent_pid));
- if (!restart) {
- ap_log_pid(pconf, ap_pid_fname);
-
- service_set_status(SERVICE_START_PENDING);
- AMCSocketInitialize();
-// setup_signal_names(ap_psprintf(pconf,"ap%d", parent_pid));
-
- /* Create shutdown event, apPID_shutdown, where PID is the parent
- * Apache process ID. Shutdown is signaled by 'apache -k shutdown'.
- */
- shutdown_event = CreateEvent(sa, FALSE, FALSE, signal_shutdown_name);
- if (!shutdown_event) {
- ap_log_error(APLOG_MARK, APLOG_EMERG, GetLastError(), s,
- "master_main: Cannot create shutdown event %s", signal_shutdown_name);
- CleanNullACL((void *)sa);
- exit(1);
- }
-
- /* Create restart event, apPID_restart, where PID is the parent
- * Apache process ID. Restart is signaled by 'apache -k restart'.
- */
-// restart_event = CreateEvent(sa, TRUE, FALSE, signal_restart_name);
- restart_event = CreateEvent(sa, FALSE, FALSE, signal_restart_name);
- if (!restart_event) {
- CloseHandle(shutdown_event);
- ap_log_error(APLOG_MARK, APLOG_EMERG, GetLastError(), s,
- "ap_run_mpm: Cannot create restart event %s", signal_restart_name);
- CleanNullACL((void *)sa);
- exit(1);
- }
- CleanNullACL((void *)sa);
-
- /* Create the start mutex, apPID, where PID is the parent Apache process ID.
- * Ths start mutex is used during a restart to prevent more than one
- * child process from entering the accept loop at once.
- */
-// ap_create_lock(&start_mutex,APR_MUTEX, APR_CROSS_PROCESS,signal_name_prefix,pconf);
- ap_create_lock(&start_mutex,APR_MUTEX, APR_CROSS_PROCESS,signal_name_prefix,s->process->pool);
- /* TODO: Add some code to detect failure */
- }
-
- /* Go to work... */
- restart = master_main(server_conf, shutdown_event, restart_event);
-
- if (!restart) {
- const char *pidfile = NULL;
- /* Shutting down. Clean up... */
- pidfile = ap_server_root_relative (pconf, ap_pid_fname);
- if ( pidfile != NULL && unlink(pidfile) == 0)
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO,APR_SUCCESS,
- server_conf, "removed PID file %s (pid=%ld)",
- pidfile, (long)getpid());
- ap_destroy_lock(start_mutex);
-
- CloseHandle(restart_event);
- CloseHandle(shutdown_event);
- AMCSocketCleanup();
-
- service_set_status(SERVICE_STOPPED);
- }
- }
- return !restart;
-}
-
-static void winnt_hooks(void)
-{
-// INIT_SIGLIST()
- one_process = 0;
- /* Configuration hooks implemented by http_config.c ... */
- ap_hook_pre_config(winnt_pre_config, NULL, NULL, HOOK_MIDDLE);
-}
-
-/*
- * Command processors
- */
-static const char *set_pidfile(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- if (cmd->server->is_virtual) {
- return "PidFile directive not allowed in <VirtualHost>";
- }
- ap_pid_fname = arg;
- return NULL;
-}
-
-static const char *set_threads_per_child (cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- ap_threads_per_child = atoi(arg);
- if (ap_threads_per_child > HARD_THREAD_LIMIT) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: ThreadsPerChild of %d exceeds compile time"
- " limit of %d threads,", ap_threads_per_child,
- HARD_THREAD_LIMIT);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- " lowering ThreadsPerChild to %d. To increase, please"
- " see the HARD_THREAD_LIMIT define in src/include/httpd.h.",
- HARD_THREAD_LIMIT);
- }
- else if (ap_threads_per_child < 1) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "WARNING: Require ThreadsPerChild > 0, setting to 1");
- ap_threads_per_child = 1;
- }
- return NULL;
-}
-
-
-static const char *set_max_requests(cmd_parms *cmd, void *dummy, char *arg)
-{
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- max_requests_per_child = atoi(arg);
-
- return NULL;
-}
-
-static const char *set_coredumpdir (cmd_parms *cmd, void *dummy, char *arg)
-{
- struct stat finfo;
- const char *fname;
- const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
- if (err != NULL) {
- return err;
- }
-
- fname = ap_server_root_relative(cmd->pool, arg);
- if ((stat(fname, &finfo) == -1) || !S_ISDIR(finfo.st_mode)) {
- return ap_pstrcat(cmd->pool, "CoreDumpDirectory ", fname,
- " does not exist or is not a directory", NULL);
- }
- ap_cpystrn(ap_coredump_dir, fname, sizeof(ap_coredump_dir));
- return NULL;
-}
-
-/* Stub functions until this MPM supports the connection status API */
-
-API_EXPORT(void) ap_update_connection_status(long conn_id, const char *key, \
- const char *value)
-{
- /* NOP */
-}
-
-API_EXPORT(void) ap_reset_connection_status(long conn_id)
-{
- /* NOP */
-}
-
-static const command_rec winnt_cmds[] = {
-LISTEN_COMMANDS
-{ "PidFile", set_pidfile, NULL, RSRC_CONF, TAKE1,
- "A file for logging the server process ID"},
-{ "ThreadsPerChild", set_threads_per_child, NULL, RSRC_CONF, TAKE1,
- "Number of threads each child creates" },
-{ "MaxRequestsPerChild", set_max_requests, NULL, RSRC_CONF, TAKE1,
- "Maximum number of requests a particular child serves before dying." },
-{ "CoreDumpDirectory", set_coredumpdir, NULL, RSRC_CONF, TAKE1,
- "The location of the directory Apache changes to before dumping core" },
-{ NULL }
-};
-
-module MODULE_VAR_EXPORT mpm_winnt_module = {
- STANDARD20_MODULE_STUFF,
- NULL, /* create per-directory config structure */
- NULL, /* merge per-directory config structures */
- NULL, /* create per-server config structure */
- NULL, /* merge per-server config structures */
- winnt_cmds, /* command ap_table_t */
- NULL, /* handlers */
- winnt_hooks /* register_hooks */
-};
diff --git a/server/mpm/winnt/mpm_winnt.h b/server/mpm/winnt/mpm_winnt.h
deleted file mode 100644
index 32d9d1408b..0000000000
--- a/server/mpm/winnt/mpm_winnt.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifndef APACHE_MPM_WINNT_H
-#define APACHE_MPM_WINNT_H
-
-extern int ap_threads_per_child;
-extern int ap_max_requests_per_child;
-extern int ap_extended_status;
-extern void clean_child_exit(int);
-
-
-typedef struct CompContext {
- OVERLAPPED Overlapped;
- SOCKET accept_socket;
- ap_socket_t *sock;
- ap_listen_rec *lr;
- BUFF *conn_io;
- char *recv_buf;
- int recv_buf_size;
- ap_context_t *ptrans;
- struct sockaddr *sa_server;
- int sa_server_len;
- struct sockaddr *sa_client;
- int sa_client_len;
-} COMP_CONTEXT, *PCOMP_CONTEXT;
-#endif /* APACHE_MPM_WINNT_H */
diff --git a/server/mpm/winnt/registry.c b/server/mpm/winnt/registry.c
deleted file mode 100644
index fd9f96437a..0000000000
--- a/server/mpm/winnt/registry.c
+++ /dev/null
@@ -1,554 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * Functions to handle interacting with the Win32 registry
- */
-
-/*
- * Apache registry key structure
- *
- * Apache's registry information is stored in the HKEY_LOCAL_MACHINE
- * key, under
- *
- * HKLM\SOFTWARE\Apache Group\Apache\version
- *
- * These keys are defined in this file. The definition of the "version" part
- * will need updating each time Apache moves from beta to non-beta or from a
- * release to a development or beta version.
- */
-
-/* To allow for multiple services, store the configuration file's full path
- * under each service entry:
- *
- * HKLM\System\CurrentControlSet\Services\[service name]\Parameters\ConfPath
- *
- * The default configuration path (for console apache) is still stored:
- *
- * HKLM\Software\[Vendor]\[Software]\[Version]\ServerRoot
- */
-#include "os.h"
-//#include <windows.h>
-//#include <stdio.h>
-
-#include "httpd.h"
-#include "http_log.h"
-
-/* Define where the Apache values are stored in the registry. In general
- * VERSION will be the same across all beta releases for a particular
- * major release, but will change when the final release is made.
- */
-
-#define VENDOR "Apache Group"
-#define SOFTWARE "Apache"
-#define VERSION "2.0"
-
-#define REGKEY "SOFTWARE\\" VENDOR "\\" SOFTWARE "\\" VERSION
-
-#define SERVICEKEYPRE "System\\CurrentControlSet\\Services\\"
-#define SERVICEKEYPOST "\\Parameters"
-
-/*
- * The Windows API registry key functions don't set the last error
- * value (the windows equivalent of errno). So we need to set it
- * with SetLastError() before calling the aplog_error() function.
- * Because this is common, let's have a macro.
- */
-#define do_error(rv,fmt,arg) do { \
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, NULL, fmt, arg); \
- } while (0);
-
-/*
- * Get the data for registry key value. This is a generic function that
- * can either get a value into a caller-supplied buffer, or it can
- * allocate space for the value from the pass in pool. It will normally
- * be used by other functions within this file to get specific key values
- * (e.g. registry_get_server_root()). This function returns a number of
- * different error statuses, allowing the caller to differentiate
- * between a key or value not existing and other kinds of errors. Depending
- * on the type of data being obtained the caller can then either ignore
- * the key-not-existing error, or treat it as a real error.
- *
- * If ppValue is NULL, allocate space for the value and return it in
- * *pValue. The return value is the number of bytes in the value.
- * The first argument is the ap_context_t to use to allocate space for the value.
- *
- * If pValue is not NULL, assume it is a buffer of nSizeValue bytes,
- * and write the value into the buffer. The return value is the number
- * of bytes in the value (so if the return value is greater than
- * the supplied nSizeValue, the caller knows that *pValue is truncated).
- * The ap_context_t argument is ignored.
- *
- * The return value is the number of bytes in the successfully retreived
- * key if everything worked, or:
- *
- * -1 the key does not exists
- * -2 if out of memory during the function
- * -3 if the buffer specified by *pValue/nSizeValue was not large enough
- * for the value.
- * -4 if an error occurred
- *
- * If the return value is negative a message will be logged to the error
- * log (aplog_error) function. If the return value is -2, -3 or -4 the message
- * will be logged at priority "error", while if the return value is -1 the
- * message will be logged at priority "warning".
- */
-
-static int ap_registry_get_key_int(ap_context_t *p, char *key, char *name, char *pBuffer, int nSizeBuffer, char **ppValue)
-{
- long rv;
- HKEY hKey;
- char *pValue;
- int nSize;
- int retval;
-
- rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- key,
- 0,
- KEY_READ,
- &hKey);
-
- if (rv == ERROR_FILE_NOT_FOUND) {
- ap_log_error(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,rv,NULL,
- "Registry does not contain key %s",key);
- return -1;
- }
- if (rv != ERROR_SUCCESS) {
- do_error(rv, "RegOpenKeyEx HKLM\\%s",key);
- return -4;
- }
-
- if (pBuffer == NULL) {
- /* Find the size required for the data by passing NULL as the buffer
- * pointer. On return nSize will contain the size required for the
- * buffer if the return value is ERROR_SUCCESS.
- */
- rv = RegQueryValueEx(hKey,
- name, /* key name */
- NULL, /* reserved */
- NULL, /* type */
- NULL, /* for value */
- &nSize); /* for size of "value" */
-
- if (rv != ERROR_SUCCESS) {
- do_error(rv, "RegQueryValueEx(key %s)", key);
- return -1;
- }
-
- pValue = ap_palloc(p, nSize);
- *ppValue = pValue;
- if (!pValue) {
- /* Eek, out of memory, probably not worth trying to carry on,
- * but let's give it a go
- */
- ap_log_error(APLOG_MARK,APLOG_ERR|APLOG_NOERRNO,APR_ENOMEM,NULL,
- "Error getting registry key: out of memory");
- return -2;
- }
- }
- else {
- /* Get the value into the existing buffer of length nSizeBuffer */
- pValue = pBuffer;
- nSize = nSizeBuffer;
- }
-
- rv = RegQueryValueEx(hKey,
- name, /* key name */
- NULL, /* reserved */
- NULL, /* type */
- pValue, /* for value */
- &nSize); /* for size of "value" */
-
- retval = 0; /* Return value */
-
- if (rv == ERROR_FILE_NOT_FOUND) {
- ap_log_error(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,rv,NULL,
- "Registry does not contain value %s\\%s", key, name);
- retval = -1;
- }
- else if (rv == ERROR_MORE_DATA) {
- /* This should only happen if we got passed a pre-existing buffer
- * (pBuffer, nSizeBuffer). But I suppose it could also happen if we
- * allocate a buffer if another process changed the length of the
- * value since we found out its length above. Umm.
- */
- ap_log_error(APLOG_MARK,APLOG_ERR|APLOG_NOERRNO,rv,NULL,
- "Error getting registry value %s: buffer not big enough", key);
- retval = -3;
- }
- else if (rv != ERROR_SUCCESS) {
- do_error(rv, "RegQueryValueEx(key %s)", key);
- retval = -4;
- }
-
- rv = RegCloseKey(hKey);
- if (rv != ERROR_SUCCESS) {
- do_error(rv, "RegCloseKey HKLM\\%s", key);
- if (retval == 0) {
- /* Keep error status from RegQueryValueEx, if any */
- retval = -4;
- }
- }
-
- return retval < 0 ? retval : nSize;
-}
-
-/*
- * Get the server root from the registry into 'dir' which is
- * size bytes long. Returns 0 if the server root was found
- * or if the serverroot key does not exist (in which case
- * dir will contain an empty string), or -1 if there was
- * an error getting the key.
- */
-#if 0
-int ap_registry_get_server_root(ap_context_t *p, char *dir, int size)
-{
- int rv;
-
- rv = ap_registry_get_key_int(p, REGKEY, "ServerRoot", dir, size, NULL);
- if (rv < 0) {
- dir[0] = '\0';
- }
-
- return (rv < -1) ? -1 : 0;
-}
-#else
-int ap_registry_get_server_root(ap_context_t *p, char **buf)
-{
- int rv;
-
- rv = ap_registry_get_key_int(p, REGKEY, "ServerRoot", NULL, 0, buf);
- if (rv < 0) {
- *buf = NULL;
- }
-
- return (rv < -1) ? -1 : 0;
-}
-#endif
-char *ap_get_service_key(char *service_name)
-{
- char *key = malloc(strlen(SERVICEKEYPRE) +
- strlen(service_name) +
- strlen(SERVICEKEYPOST) + 1);
-
- sprintf(key,"%s%s%s", SERVICEKEYPRE, service_name, SERVICEKEYPOST);
-
- return(key);
-}
-#if 0
-int ap_registry_get_service_conf(ap_context_t *p, char *dir, int size, char *service_name)
-{
- int rv;
- char *key = ap_get_service_key(service_name);
-
- rv = ap_registry_get_key_int(p, key, "ConfPath", dir, size, NULL);
- if (rv < 0) {
- dir[0] = '\0';
- }
-
- free(key);
- return (rv < -1) ? -1 : 0;
-}
-#else
-int ap_registry_get_service_conf(ap_context_t *p, char **buf, char *service_name)
-{
- int rv;
- char *key = ap_get_service_key(service_name);
-
- rv = ap_registry_get_key_int(p, key, "ConfPath", NULL, 0, buf);
- if (rv < 0) {
- *buf = NULL;
- }
-
- free(key);
- return (rv < -1) ? -1 : 0;
-}
-#endif
-
-/**********************************************************************
- * The rest of this file deals with storing keys or values in the registry
- */
-
-char *ap_registry_parse_key(int index, char *key)
-{
- char *head = key, *skey;
- int i;
-
- if(!key)
- return(NULL);
-
- for(i = 0; i <= index; i++)
- {
- if(key && key[0] == '\\')
- key++;
- if (!key)
- return(NULL);
- head = key;
- key = strchr(head, '\\');
- }
-
- if(!key)
- return(strdup(head));
- *key = '\0';
- skey = strdup(head);
- *key = '\\';
- return(skey);
-}
-
-/*
- * ap_registry_create_apache_key() creates the Apache registry key
- * (HLKM\SOFTWARE\Apache Group\Apache\version, as defined at the start
- * of this file), if it does not already exist. It will be called by
- * ap_registry_store_key_int() if it cannot open this key. This
- * function is intended to be called by ap_registry_store_key_int() if
- * the Apache key does not exist when it comes to store a data item.
- *
- * Returns 0 on success or -1 on error. If -1 is returned, the error will
- * already have been logged.
- */
-
-static int ap_registry_create_key(char *longkey)
-{
- int index;
- HKEY hKey;
- HKEY hKeyNext;
- int retval;
- int rv;
- char *key;
-
- hKey = HKEY_LOCAL_MACHINE;
- index = 0;
- retval = 0;
-
- /* Walk the tree, creating at each stage if necessary */
- while (key=ap_registry_parse_key(index,longkey)) {
- int result;
-
- rv = RegCreateKeyEx(hKey,
- key, /* subkey */
- 0, /* reserved */
- NULL, /* class */
- REG_OPTION_NON_VOLATILE,
- KEY_WRITE,
- NULL,
- &hKeyNext,
- &result);
- if (rv != ERROR_SUCCESS) {
- do_error(rv, "RegCreateKeyEx(%s)", longkey);
- retval = -4;
- }
-
- /* Close the old key */
- rv = RegCloseKey(hKey);
- if (rv != ERROR_SUCCESS) {
- do_error(rv, "RegCloseKey", NULL);
- if (retval == 0) {
- /* Keep error status from RegCreateKeyEx, if any */
- retval = -4;
- }
- }
-
- if (retval) {
- break;
- }
-
- free(key);
- hKey = hKeyNext;
- index++;
- }
-
- if (!key) {
- /* Close the final key we opened, if we walked the entire
- * tree
- */
- rv = RegCloseKey(hKey);
- if (rv != ERROR_SUCCESS) {
- do_error(rv, "RegCloseKey", NULL);
- if (retval == 0) {
- /* Keep error status from RegCreateKeyEx, if any */
- retval = -4;
- }
- }
- }
- else
- free(key);
-
- return retval;
-}
-
-/*
- * ap_registry_store_key_int() stores a value name and value under the
- * Apache registry key. If the Apache key does not exist it is created
- * first. This function is intended to be called from a wrapper function
- * in this file to set particular data values, such as
- * ap_registry_set_server_root() below.
- *
- * Returns 0 if the value name and data was stored successfully, or
- * returns -1 if the Apache key does not exist (since we try to create
- * this key, this should never happen), or -4 if any other error occurred
- * (these values are consistent with ap_registry_get_key_int()).
- * If the return value is negative then the error will already have been
- * logged via aplog_error().
- */
-
-static int ap_registry_store_key_int(char *key, char *name, DWORD type, void *value, int value_size)
-{
- long rv;
- HKEY hKey;
- int retval;
-
- rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- key,
- 0,
- KEY_WRITE,
- &hKey);
-
- if (rv == ERROR_FILE_NOT_FOUND) {
- /* Key could not be opened -- try to create it
- */
- if (ap_registry_create_key(key) < 0) {
- /* Creation failed (error already reported) */
- return -4;
- }
-
- /* Now it has been created we should be able to open it
- */
- rv = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
- key,
- 0,
- KEY_WRITE,
- &hKey);
-
- if (rv == ERROR_FILE_NOT_FOUND) {
- ap_log_error(APLOG_MARK,APLOG_WARNING|APLOG_NOERRNO,rv,NULL,
- "Registry does not contain key %s after creation",key);
- return -1;
- }
- }
-
- if (rv != ERROR_SUCCESS) {
- do_error(rv, "RegOpenKeyEx HKLM\\%s", key);
- return -4;
- }
-
- /* Now set the value and data */
- rv = RegSetValueEx(hKey,
- name, /* value key name */
- 0, /* reserved */
- type, /* type */
- value, /* value data */
- (DWORD)value_size); /* for size of "value" */
-
- retval = 0; /* Return value */
-
- if (rv != ERROR_SUCCESS) {
- do_error(rv, "RegQueryValueEx(key %s)", key);
- retval = -4;
- }
- else {
- ap_log_error(APLOG_MARK,APLOG_INFO|APLOG_NOERRNO,rv,NULL,
- "Registry stored HKLM\\" REGKEY "\\%s value %s", key,
- type == REG_SZ ? value : "(not displayable)");
- }
-
- /* Make sure we close the key even if there was an error storing
- * the data
- */
- rv = RegCloseKey(hKey);
- if (rv != ERROR_SUCCESS) {
- do_error(rv, "RegCloseKey HKLM\\%s", key);
- if (retval == 0) {
- /* Keep error status from RegQueryValueEx, if any */
- retval = -4;
- }
- }
-
- return retval;
-}
-
-/*
- * Sets the service confpath value within the registry. Returns 0 on success
- * or -1 on error. If -1 is return the error will already have been
- * logged via aplog_error().
- */
-
-int ap_registry_set_service_conf(char *conf, char *service_name)
-{
- int rv;
- char *key = ap_get_service_key(service_name);
-
- rv = ap_registry_store_key_int(key, "ConfPath", REG_SZ, conf, strlen(conf)+1);
- free(key);
-
- return rv < 0 ? -1: 0;
-}
-
-/*
- * Sets the serverroot value within the registry. Returns 0 on success
- * or -1 on error. If -1 is return the error will already have been
- * logged via aplog_error().
- */
-
-int ap_registry_set_server_root(char *dir)
-{
- int rv;
-
- rv = ap_registry_store_key_int(REGKEY, "ServerRoot", REG_SZ, dir, strlen(dir)+1);
-
- return rv < 0 ? -1 : 0;
-}
-
diff --git a/server/mpm/winnt/service.c b/server/mpm/winnt/service.c
deleted file mode 100644
index ebb708a4f0..0000000000
--- a/server/mpm/winnt/service.c
+++ /dev/null
@@ -1,523 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#ifdef WIN32
-
-#include "os.h"
-#include <stdlib.h>
-#include <direct.h>
-
-#define CORE_PRIVATE
-#include "httpd.h"
-#include "http_conf_globals.h"
-#include "http_log.h"
-#include "http_main.h"
-#include "service.h"
-#include "registry.h"
-
-static struct
-{
- int (*main_fn)(int, char **);
- event *stop_event;
- int connected;
- SERVICE_STATUS_HANDLE hServiceStatus;
- char *name;
- int exit_status;
- SERVICE_STATUS ssStatus;
- FILE *logFile;
- char *service_dir;
-} globdat;
-
-static void WINAPI service_main_fn(DWORD, LPTSTR *);
-static void WINAPI service_ctrl(DWORD ctrlCode);
-static int ReportStatusToSCMgr(int currentState, int exitCode, int waitHint);
-static int ap_start_service(SC_HANDLE);
-static int ap_stop_service(SC_HANDLE);
-
-int service_main(int (*main_fn)(int, char **), int argc, char **argv )
-{
- SERVICE_TABLE_ENTRY dispatchTable[] =
- {
- { "", service_main_fn },
- { NULL, NULL }
- };
-
- globdat.main_fn = main_fn;
- globdat.stop_event = CreateEvent(NULL, 0, 0, "apache-signal");
- globdat.connected = 1;
- globdat.service_dir = argv[0];
-
- if(!StartServiceCtrlDispatcher(dispatchTable))
- {
- /* This is a genuine failure of the SCM. */
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "Error starting service control dispatcher");
- return(globdat.exit_status);
- }
- else
- {
- return(globdat.exit_status);
- }
-}
-
-void service_cd()
-{
- /* change to the drive with the executable */
- char buf[300];
- GetModuleFileName(NULL, buf, 300);
- buf[2] = 0;
- chdir(buf);
-}
-
-void __stdcall service_main_fn(DWORD argc, LPTSTR *argv)
-{
- int i, new_argc;
- char **new, *server_root, *tmp;
- char *server_confname = SERVER_CONFIG_FILE;
- ap_array_header_t *cmdtbl;
- ap_context_t *pwincmd;
-
- ap_create_context(&pwincmd, NULL);
- if (pwincmd == NULL) {
- exit(0);
- }
-
- ap_server_argv0 = globdat.name = argv[0];
- cmdtbl = ap_make_array(pwincmd, 1, sizeof(char *));
-
- server_root = ap_pstrdup(pwincmd, globdat.service_dir);
- tmp = strrchr(server_root, '\\');
- *tmp = '\0';
-
- if(!(globdat.hServiceStatus = RegisterServiceCtrlHandler( globdat.name, service_ctrl)))
- {
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "Failure registering service handler");
- return;
- }
-
- ReportStatusToSCMgr(
- SERVICE_START_PENDING, // service state
- NO_ERROR, // exit code
- 3000); // wait hint
-
- service_cd();
-
- /* Fetch server_conf from the registry
- * Rebuild argv and argc adding the -d server_root and -f server_conf then
- * call apache_main
- */
- ap_registry_get_service_conf(pwincmd, &server_confname, argv[0]);
- for (i = 0; i < argc ; i++) {
- new = (char **) ap_push_array(cmdtbl);
- *new = argv[i];
- }
- /* Add server_confname to the argument list */
- new = (char **) ap_push_array(cmdtbl);
- *new = "-f";
- new = (char **) ap_push_array(cmdtbl);
- *new = server_confname;
- new = (char **) ap_push_array(cmdtbl);
- *new = "-d";
- new = (char **) ap_push_array(cmdtbl);
- *new = server_root;
- new_argc = argc + 4;
-
- globdat.exit_status = (*globdat.main_fn)( new_argc, (char**) cmdtbl->elts );
-
- ReportStatusToSCMgr(SERVICE_STOPPED, NO_ERROR, 0);
-
- return;
-}
-
-void service_set_status(int status)
-{
- ReportStatusToSCMgr(status, NO_ERROR, 3000);
-}
-
-
-
-//
-// FUNCTION: service_ctrl
-//
-// PURPOSE: This function is called by the SCM whenever
-// ControlService() is called on this service.
-//
-// PARAMETERS:
-// dwCtrlCode - type of control requested
-//
-// RETURN VALUE:
-// none
-//
-// COMMENTS:
-//
-VOID WINAPI service_ctrl(DWORD dwCtrlCode)
-{
- int state;
-
-
- state = globdat.ssStatus.dwCurrentState;
- switch(dwCtrlCode)
- {
- // Stop the service.
- //
- case SERVICE_CONTROL_STOP:
- state = SERVICE_STOP_PENDING;
- ap_start_shutdown();
- break;
-
- // Update the service status.
- //
- case SERVICE_CONTROL_INTERROGATE:
- break;
-
- // invalid control code
- //
- default:
- break;
-
- }
-
- ReportStatusToSCMgr(state, NO_ERROR, 0);
-}
-
-
-int ReportStatusToSCMgr(int currentState, int exitCode, int waitHint)
-{
- static int firstTime = 1;
- static int checkPoint = 1;
- int rv;
-
- if(firstTime)
- {
- firstTime = 0;
- globdat.ssStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
- globdat.ssStatus.dwServiceSpecificExitCode = 0;
- globdat.ssStatus.dwCheckPoint = 1;
- }
-
- if(globdat.connected)
- {
- if (currentState == SERVICE_START_PENDING)
- globdat.ssStatus.dwControlsAccepted = 0;
- else
- globdat.ssStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
-
- globdat.ssStatus.dwCurrentState = currentState;
- globdat.ssStatus.dwWin32ExitCode = exitCode;
- if(waitHint)
- globdat.ssStatus.dwWaitHint = waitHint;
-
- if ( ( currentState == SERVICE_RUNNING ) ||
- ( currentState == SERVICE_STOPPED ) )
- {
- globdat.ssStatus.dwWaitHint = 0;
- globdat.ssStatus.dwCheckPoint = 0;
- }
- else
- globdat.ssStatus.dwCheckPoint = ++checkPoint;
-
- rv = SetServiceStatus(globdat.hServiceStatus, &globdat.ssStatus);
-
- }
- return(1);
-}
-
-void InstallService(char *service_name, char *conf)
-{
- SC_HANDLE schService;
- SC_HANDLE schSCManager;
-
- TCHAR szPath[512];
- TCHAR szQuotedPath[512];
-
- printf("Installing the %s service to use %s\n", service_name, conf);
-
- if (GetModuleFileName( NULL, szPath, 512 ) == 0)
- {
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "GetModuleFileName failed");
- return;
- }
-
- ap_snprintf(szQuotedPath, 512, "\"%s\"", szPath);
-
- schSCManager = OpenSCManager(
- NULL, // machine (NULL == local)
- NULL, // database (NULL == default)
- SC_MANAGER_ALL_ACCESS // access required
- );
- if (!schSCManager) {
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "OpenSCManager failed");
- }
- else {
- schService = CreateService(
- schSCManager, // SCManager database
- service_name, // name of service
- service_name, // name to display
- SERVICE_ALL_ACCESS, // desired access
- SERVICE_WIN32_OWN_PROCESS, // service type
- SERVICE_AUTO_START, // start type
- SERVICE_ERROR_NORMAL, // error control type
- szQuotedPath, // service's binary
- NULL, // no load ordering group
- NULL, // no tag identifier
- NULL, // dependencies
- NULL, // LocalSystem account
- NULL); // no password
-
- if (schService) {
- CloseServiceHandle(schService);
-
- /* Now store the server_root in the registry */
- if(!ap_registry_set_service_conf(conf, service_name))
- printf("The %s service has been installed successfully.\n", service_name );
- }
- else {
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "CreateService failed");
- }
-
- CloseServiceHandle(schSCManager);
- }
-}
-
-
-void RemoveService(char *service_name)
-{
- SC_HANDLE schService;
- SC_HANDLE schSCManager;
-
- printf("Removing the %s service\n", service_name);
-
- schSCManager = OpenSCManager(
- NULL, // machine (NULL == local)
- NULL, // database (NULL == default)
- SC_MANAGER_ALL_ACCESS // access required
- );
- if (!schSCManager) {
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "OpenSCManager failed");
- }
- else {
- schService = OpenService(schSCManager, service_name, SERVICE_ALL_ACCESS);
-
- if (schService == NULL) {
- /* Could not open the service */
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "OpenService failed");
- }
- else {
- /* try to stop the service */
- ap_stop_service(schService);
-
- // now remove the service
- if (DeleteService(schService) == 0)
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "DeleteService failed");
- else
- printf("The %s service has been removed successfully.\n", service_name );
- CloseServiceHandle(schService);
- }
- /* SCM removes registry parameters */
- CloseServiceHandle(schSCManager);
- }
-
-}
-
-/* A hack to determine if we're running as a service without waiting for
- * the SCM to fail; if AllocConsole succeeds, we're a service.
- */
-
-BOOL isProcessService() {
- if( !AllocConsole() )
- return FALSE;
- FreeConsole();
- return TRUE;
-}
-
-/* Determine is service_name is a valid service
- */
-
-BOOL isValidService(char *service_name) {
- SC_HANDLE schSCM, schSVC;
- int Err;
-
- if (!(schSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS))) {
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "OpenSCManager failed");
- return FALSE;
- }
-
- if ((schSVC = OpenService(schSCM, service_name, SERVICE_ALL_ACCESS))) {
- CloseServiceHandle(schSVC);
- CloseServiceHandle(schSCM);
- return TRUE;
- }
-
- Err = GetLastError();
- if (Err != ERROR_SERVICE_DOES_NOT_EXIST && Err != ERROR_INVALID_NAME)
- ap_log_error(APLOG_MARK, APLOG_ERR, Err, NULL,
- "OpenService failed");
-
- return FALSE;
-}
-
-int send_signal_to_service(char *service_name, char *sig) {
- SC_HANDLE schService;
- SC_HANDLE schSCManager;
- int success = FALSE;
-
- enum { start, restart, stop, unknown } action;
- static char *param[] = { "start", "restart", "shutdown" };
- static char *participle[] = { "starting", "restarting", "stopping" };
- static char *past[] = { "started", "restarted", "stopped" };
-
- for (action = start; action < unknown; action++)
- if (!strcasecmp(sig, param[action]))
- break;
-
- if (action == unknown) {
- printf("signal must be start, restart, or shutdown\n");
- return FALSE;
- }
-
- schSCManager = OpenSCManager(
- NULL, // machine (NULL == local)
- NULL, // database (NULL == default)
- SC_MANAGER_ALL_ACCESS // access required
- );
- if (!schSCManager) {
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "OpenSCManager failed");
- }
- else {
- schService = OpenService(schSCManager, service_name, SERVICE_ALL_ACCESS);
-
- if (schService == NULL) {
- /* Could not open the service */
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "OpenService failed");
- }
- else {
- if (!QueryServiceStatus(schService, &globdat.ssStatus))
- ap_log_error(APLOG_MARK, APLOG_ERR, GetLastError(), NULL,
- "QueryService failed");
- else {
- if (globdat.ssStatus.dwCurrentState == SERVICE_STOPPED && action == stop)
- printf("The %s service is not started.\n", service_name);
- else if (globdat.ssStatus.dwCurrentState == SERVICE_RUNNING && action == start)
- printf("The %s service has already been started.\n", service_name);
- else {
- printf("The %s service is %s.\n", service_name, participle[action]);
-
- if (action == stop || action == restart)
- success = ap_stop_service(schService);
- if (action == start || action == restart)
- success = ap_start_service(schService);
-
- if( success )
- printf("The %s service has %s.\n", service_name, past[action]);
- else
- printf("Failed to %s the %s service.\n", sig, service_name );
- }
-
- CloseServiceHandle(schService);
- }
- }
- /* SCM removes registry parameters */
- CloseServiceHandle(schSCManager);
- }
- return success;
-}
-
-int ap_stop_service(SC_HANDLE schService)
-{
- if (ControlService(schService, SERVICE_CONTROL_STOP, &globdat.ssStatus)) {
- Sleep(1000);
- while (QueryServiceStatus(schService, &globdat.ssStatus)) {
- if (globdat.ssStatus.dwCurrentState == SERVICE_STOP_PENDING)
- Sleep(1000);
- else
- break;
- }
- }
- if (QueryServiceStatus(schService, &globdat.ssStatus))
- if (globdat.ssStatus.dwCurrentState == SERVICE_STOPPED)
- return TRUE;
- return FALSE;
-}
-
-int ap_start_service(SC_HANDLE schService) {
- if (StartService(schService, 0, NULL)) {
- Sleep(1000);
- while(QueryServiceStatus(schService, &globdat.ssStatus)) {
- if(globdat.ssStatus.dwCurrentState == SERVICE_START_PENDING)
- Sleep(1000);
- else
- break;
- }
- }
- if (QueryServiceStatus(schService, &globdat.ssStatus))
- if (globdat.ssStatus.dwCurrentState == SERVICE_RUNNING)
- return TRUE;
- return FALSE;
-}
-
-#endif /* WIN32 */
-
diff --git a/server/rfc1413.c b/server/rfc1413.c
deleted file mode 100644
index 80ceb19eec..0000000000
--- a/server/rfc1413.c
+++ /dev/null
@@ -1,240 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/* TODO - put timeouts back in */
-/*
- * rfc1413() speaks a common subset of the RFC 1413, AUTH, TAP and IDENT
- * protocols. The code queries an RFC 1413 etc. compatible daemon on a remote
- * host to look up the owner of a connection. The information should not be
- * used for authentication purposes. This routine intercepts alarm signals.
- *
- * Diagnostics are reported through syslog(3).
- *
- * Author: Wietse Venema, Eindhoven University of Technology,
- * The Netherlands.
- */
-
-/* Some small additions for Apache --- ditch the "sccsid" var if
- * compiling with gcc (it *has* changed), include ap_config.h for the
- * prototypes it defines on at least one system (SunlOSs) which has
- * them missing from the standard header files, and one minor change
- * below (extra parens around assign "if (foo = bar) ..." to shut up
- * gcc -Wall).
- */
-
-/* Rewritten by David Robinson */
-
-#include "ap_config.h"
-#include "httpd.h" /* for server_rec, conn_rec, etc. */
-#include "http_log.h" /* for aplog_error */
-#include "rfc1413.h"
-#include "http_main.h" /* set_callback_and_alarm */
-#include "apr_network_io.h"
-#include <string.h>
-
-/* Local stuff. */
-/* Semi-well-known port */
-#define RFC1413_PORT 113
-/* maximum allowed length of userid */
-#define RFC1413_USERLEN 512
-/* rough limit on the amount of data we accept. */
-#define RFC1413_MAXDATA 1000
-
-#ifndef RFC1413_TIMEOUT
-#define RFC1413_TIMEOUT 30
-#endif
-#define ANY_PORT 0 /* Any old port will do */
-#define FROM_UNKNOWN "unknown"
-
-int ap_rfc1413_timeout = RFC1413_TIMEOUT; /* Global so it can be changed */
-
-/* bind_connect - bind both ends of a socket */
-/* Ambarish fix this. Very broken */
-static int get_rfc1413(ap_socket_t *sock, const char *local_ip,
- const char *rmt_ip,
- char user[RFC1413_USERLEN+1], server_rec *srv)
-{
- unsigned int rmt_port, our_port;
- unsigned int sav_rmt_port, sav_our_port;
- ap_status_t status;
- int i;
- char *cp;
- char buffer[RFC1413_MAXDATA + 1];
- int buflen;
-
- /*
- * Bind the local and remote ends of the query socket to the same
- * IP addresses as the connection under investigation. We go
- * through all this trouble because the local or remote system
- * might have more than one network address. The RFC1413 etc.
- * client sends only port numbers; the server takes the IP
- * addresses from the query socket.
- */
-
- ap_set_local_port(sock, ANY_PORT);
- ap_set_local_ipaddr(sock, local_ip);
-
- if ((status = ap_bind(sock)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, status, srv,
- "bind: rfc1413: Error binding to local port");
- return -1;
- }
- ap_get_local_port(&sav_our_port, sock);
-
-/*
- * errors from connect usually imply the remote machine doesn't support
- * the service
- */
- ap_set_remote_port(sock, RFC1413_PORT);
- ap_set_remote_ipaddr(sock, rmt_ip);
-
- if (ap_connect(sock, NULL) != APR_SUCCESS)
- return -1;
- ap_get_remote_port(&sav_rmt_port, sock);
-
-/* send the data */
- buflen = ap_snprintf(buffer, sizeof(buffer), "%u,%u\r\n", sav_rmt_port,
- sav_our_port);
-
- /* send query to server. Handle short write. */
-#ifdef CHARSET_EBCDIC
- ebcdic2ascii(&buffer, &buffer, buflen);
-#endif
- i = 0;
- while(i < strlen(buffer)) {
- ap_ssize_t j = strlen(buffer + i);
- ap_status_t status;
- status = ap_send(sock, buffer+i, &j);
- if (status != APR_SUCCESS && status != APR_EINTR) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, status, srv,
- "write: rfc1413: error sending request");
- return -1;
- }
- else if (j > 0) {
- i+=j;
- }
- }
-
- /*
- * Read response from server. - the response should be newline
- * terminated according to rfc - make sure it doesn't stomp it's
- * way out of the buffer.
- */
-
- i = 0;
- memset(buffer, '\0', sizeof(buffer));
- /*
- * Note that the strchr function below checks for 10 instead of '\n'
- * this allows it to work on both ASCII and EBCDIC machines.
- */
- while((cp = strchr(buffer, '\012')) == NULL && i < sizeof(buffer) - 1) {
- ap_ssize_t j = sizeof(buffer) - 1 - i;
- ap_status_t status;
- status = ap_recv(sock, buffer+i, &j);
- if (status != APR_SUCCESS && status != APR_EINTR) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, status, srv,
- "read: rfc1413: error reading response");
- return -1;
- }
- else if (j > 0) {
- i+=j;
- }
- }
-
-/* RFC1413_USERLEN = 512 */
-#ifdef CHARSET_EBCDIC
- ascii2ebcdic(&buffer, &buffer, (size_t)i);
-#endif
- if (sscanf(buffer, "%u , %u : USERID :%*[^:]:%512s", &rmt_port, &our_port,
- user) != 3 || sav_rmt_port != rmt_port
- || sav_our_port != our_port)
- return -1;
-
- /*
- * Strip trailing carriage return. It is part of the
- * protocol, not part of the data.
- */
-
- if ((cp = strchr(user, '\r')))
- *cp = '\0';
-
- return 0;
-}
-
-/* rfc1413 - return remote user name, given socket structures */
-char *ap_rfc1413(conn_rec *conn, server_rec *srv)
-{
- ap_status_t status;
- static char user[RFC1413_USERLEN + 1]; /* XXX */
- static char *result;
- static ap_socket_t *sock;
-
- result = FROM_UNKNOWN;
-
- if ((status = ap_create_tcp_socket(&sock, conn->pool)) != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, status, srv,
- "socket: rfc1413: error creating socket");
- conn->remote_logname = result;
- }
-
- if (get_rfc1413(sock, conn->local_ip, conn->remote_ip, user, srv) >= 0)
- result = user;
- ap_close_socket(sock);
- conn->remote_logname = result;
-
- return conn->remote_logname;
-}
diff --git a/server/util.c b/server/util.c
deleted file mode 100644
index 19cdecf93d..0000000000
--- a/server/util.c
+++ /dev/null
@@ -1,2031 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * util.c: string utility things
- *
- * 3/21/93 Rob McCool
- * 1995-96 Many changes by the Apache Group
- *
- */
-
-/* Debugging aid:
- * #define DEBUG to trace all cfg_open*()/cfg_closefile() calls
- * #define DEBUG_CFG_LINES to trace every line read from the config files
- */
-
-#define CORE_PRIVATE
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "http_protocol.h"
-#if defined(SUNOS4)
-/* stdio.h has been read in ap_config.h already. Add missing prototypes here: */
-extern int fgetc(FILE *);
-extern char *fgets(char *s, int, FILE*);
-extern int fclose(FILE *);
-#endif
-
-/* A bunch of functions in util.c scan strings looking for certain characters.
- * To make that more efficient we encode a lookup table. The test_char_table
- * is generated automatically by gen_test_char.c.
- */
-#include "test_char.h"
-
-/* we assume the folks using this ensure 0 <= c < 256... which means
- * you need a cast to (unsigned char) first, you can't just plug a
- * char in here and get it to work, because if char is signed then it
- * will first be sign extended.
- */
-#define TEST_CHAR(c, f) (test_char_table[(unsigned)(c)] & (f))
-
-/*
- * 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.
- */
-API_EXPORT(char *) ap_field_noparam(ap_context_t *p, const char *intype)
-{
- const char *semi;
-
- semi = strchr(intype, ';');
- if (semi == NULL) {
- return ap_pstrdup(p, intype);
- }
- else {
- while ((semi > intype) && ap_isspace(semi[-1])) {
- semi--;
- }
- return ap_pstrndup(p, intype, semi - intype);
- }
-}
-
-API_EXPORT(char *) ap_ht_time(ap_context_t *p, ap_time_t t, const char *fmt, int gmt)
-{
- ap_size_t retcode;
- char ts[MAX_STRING_LEN];
- char tf[MAX_STRING_LEN];
- ap_exploded_time_t xt;
-
- if (gmt) {
- const char *f;
- char *strp;
-
- ap_explode_gmt(&xt, t);
- /* Convert %Z to "GMT" and %z to "+0000";
- * on hosts that do not have a time zone string in struct tm,
- * strftime must assume its argument is local time.
- */
- for(strp = tf, f = fmt; strp < tf + sizeof(tf) - 6 && (*strp = *f)
- ; f++, strp++) {
- if (*f != '%') continue;
- switch (f[1]) {
- case '%':
- *++strp = *++f;
- break;
- case 'Z':
- *strp++ = 'G';
- *strp++ = 'M';
- *strp = 'T';
- f++;
- break;
- case 'z': /* common extension */
- *strp++ = '+';
- *strp++ = '0';
- *strp++ = '0';
- *strp++ = '0';
- *strp = '0';
- f++;
- break;
- }
- }
- *strp = '\0';
- fmt = tf;
- }
- else {
- ap_explode_localtime(&xt, t);
- }
-
- /* check return code? */
- ap_strftime(ts, &retcode, MAX_STRING_LEN, fmt, &xt);
- ts[MAX_STRING_LEN - 1] = '\0';
- return ap_pstrdup(p, ts);
-}
-
-/* Roy owes Rob beer. */
-/* Rob owes Roy dinner. */
-
-/* These legacy comments would make a lot more sense if Roy hadn't
- * replaced the old later_than() routine with util_date.c.
- *
- * Well, okay, they still wouldn't make any sense.
- */
-
-/* Match = 0, NoMatch = 1, Abort = -1
- * Based loosely on sections of wildmat.c by Rich Salz
- * Hmmm... shouldn't this really go component by component?
- */
-API_EXPORT(int) ap_strcmp_match(const char *str, const char *exp)
-{
- int x, y;
-
- for (x = 0, y = 0; exp[y]; ++y, ++x) {
- if ((!str[x]) && (exp[y] != '*'))
- return -1;
- if (exp[y] == '*') {
- while (exp[++y] == '*');
- if (!exp[y])
- return 0;
- while (str[x]) {
- int ret;
- if ((ret = ap_strcmp_match(&str[x++], &exp[y])) != 1)
- return ret;
- }
- return -1;
- }
- else if ((exp[y] != '?') && (str[x] != exp[y]))
- return 1;
- }
- return (str[x] != '\0');
-}
-
-API_EXPORT(int) ap_strcasecmp_match(const char *str, const char *exp)
-{
- int x, y;
-
- for (x = 0, y = 0; exp[y]; ++y, ++x) {
- if ((!str[x]) && (exp[y] != '*'))
- return -1;
- if (exp[y] == '*') {
- while (exp[++y] == '*');
- if (!exp[y])
- return 0;
- while (str[x]) {
- int ret;
- if ((ret = ap_strcasecmp_match(&str[x++], &exp[y])) != 1)
- return ret;
- }
- return -1;
- }
- else if ((exp[y] != '?') && (ap_tolower(str[x]) != ap_tolower(exp[y])))
- return 1;
- }
- return (str[x] != '\0');
-}
-
-API_EXPORT(int) ap_is_matchexp(const char *str)
-{
- register int x;
-
- for (x = 0; str[x]; x++)
- if ((str[x] == '*') || (str[x] == '?'))
- return 1;
- return 0;
-}
-
-/*
- * Here's a pool-based interface to POSIX regex's regcomp().
- * Note that we return regex_t instead of being passed one.
- * The reason is that if you use an already-used regex_t structure,
- * the memory that you've already allocated gets forgotten, and
- * regfree() doesn't clear it. So we don't allow it.
- */
-
-static ap_status_t regex_cleanup(void *preg)
-{
- regfree((regex_t *) preg);
- return APR_SUCCESS;
-}
-
-API_EXPORT(regex_t *) ap_pregcomp(ap_context_t *p, const char *pattern,
- int cflags)
-{
- regex_t *preg = ap_palloc(p, sizeof(regex_t));
-
- if (regcomp(preg, pattern, cflags)) {
- return NULL;
- }
-
- ap_register_cleanup(p, (void *) preg, regex_cleanup, regex_cleanup);
-
- return preg;
-}
-
-API_EXPORT(void) ap_pregfree(ap_context_t *p, regex_t * reg)
-{
- ap_block_alarms();
- regfree(reg);
- ap_kill_cleanup(p, (void *) reg, regex_cleanup);
- ap_unblock_alarms();
-}
-
-/*
- * Apache stub function for the regex libraries regexec() to make sure the
- * whole regex(3) API is available through the Apache (exported) namespace.
- * This is especially important for the DSO situations of modules.
- * DO NOT MAKE A MACRO OUT OF THIS FUNCTION!
- */
-API_EXPORT(int) ap_regexec(const regex_t *preg, const char *string,
- size_t nmatch, regmatch_t pmatch[], int eflags)
-{
- return regexec(preg, string, nmatch, pmatch, eflags);
-}
-
-API_EXPORT(size_t) ap_regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
-{
- return regerror(errcode, preg, errbuf, errbuf_size);
-}
-
-
-/* This function substitutes for $0-$9, filling in regular expression
- * submatches. Pass it the same nmatch and pmatch arguments that you
- * passed ap_regexec(). pmatch should not be greater than the maximum number
- * of subexpressions - i.e. one more than the re_nsub member of regex_t.
- *
- * input should be the string with the $-expressions, source should be the
- * string that was matched against.
- *
- * It returns the substituted string, or NULL on error.
- *
- * Parts of this code are based on Henry Spencer's regsub(), from his
- * AT&T V8 regexp package.
- */
-
-API_EXPORT(char *) ap_pregsub(ap_context_t *p, const char *input, const char *source,
- size_t nmatch, regmatch_t pmatch[])
-{
- const char *src = input;
- char *dest, *dst;
- char c;
- size_t no;
- int len;
-
- if (!source)
- return NULL;
- if (!nmatch)
- return ap_pstrdup(p, src);
-
- /* First pass, find the size */
-
- len = 0;
-
- while ((c = *src++) != '\0') {
- if (c == '&')
- no = 0;
- else if (c == '$' && ap_isdigit(*src))
- no = *src++ - '0';
- else
- no = 10;
-
- if (no > 9) { /* Ordinary character. */
- if (c == '\\' && (*src == '$' || *src == '&'))
- c = *src++;
- len++;
- }
- else if (no < nmatch && pmatch[no].rm_so < pmatch[no].rm_eo) {
- len += pmatch[no].rm_eo - pmatch[no].rm_so;
- }
-
- }
-
- dest = dst = ap_pcalloc(p, len + 1);
-
- /* Now actually fill in the string */
-
- src = input;
-
- while ((c = *src++) != '\0') {
- if (c == '&')
- no = 0;
- else if (c == '$' && ap_isdigit(*src))
- no = *src++ - '0';
- else
- no = 10;
-
- if (no > 9) { /* Ordinary character. */
- if (c == '\\' && (*src == '$' || *src == '&'))
- c = *src++;
- *dst++ = c;
- }
- else if (no < nmatch && pmatch[no].rm_so < pmatch[no].rm_eo) {
- len = pmatch[no].rm_eo - pmatch[no].rm_so;
- memcpy(dst, source + pmatch[no].rm_so, len);
- dst += len;
- }
-
- }
- *dst = '\0';
-
- return dest;
-}
-
-/*
- * Parse .. so we don't compromise security
- */
-API_EXPORT(void) ap_getparents(char *name)
-{
- int l, w;
-
- /* Four paseses, as per RFC 1808 */
- /* a) remove ./ path segments */
-
- for (l = 0, w = 0; name[l] != '\0';) {
- if (name[l] == '.' && name[l + 1] == '/' && (l == 0 || name[l - 1] == '/'))
- l += 2;
- else
- name[w++] = name[l++];
- }
-
- /* b) remove trailing . path, segment */
- if (w == 1 && name[0] == '.')
- w--;
- else if (w > 1 && name[w - 1] == '.' && name[w - 2] == '/')
- w--;
- name[w] = '\0';
-
- /* c) remove all xx/../ segments. (including leading ../ and /../) */
- l = 0;
-
- while (name[l] != '\0') {
- if (name[l] == '.' && name[l + 1] == '.' && name[l + 2] == '/' &&
- (l == 0 || name[l - 1] == '/')) {
- register int m = l + 3, n;
-
- l = l - 2;
- if (l >= 0) {
- while (l >= 0 && name[l] != '/')
- l--;
- l++;
- }
- else
- l = 0;
- n = l;
- while ((name[n] = name[m]))
- (++n, ++m);
- }
- else
- ++l;
- }
-
- /* d) remove trailing xx/.. segment. */
- if (l == 2 && name[0] == '.' && name[1] == '.')
- name[0] = '\0';
- else if (l > 2 && name[l - 1] == '.' && name[l - 2] == '.' && name[l - 3] == '/') {
- l = l - 4;
- if (l >= 0) {
- while (l >= 0 && name[l] != '/')
- l--;
- l++;
- }
- else
- l = 0;
- name[l] = '\0';
- }
-}
-
-API_EXPORT(void) ap_no2slash(char *name)
-{
- char *d, *s;
-
- s = d = name;
-
-#ifdef WIN32
- /* Check for UNC names. Leave leading two slashes. */
- if (s[0] == '/' && s[1] == '/')
- *d++ = *s++;
-#endif
-
- while (*s) {
- if ((*d++ = *s) == '/') {
- do {
- ++s;
- } while (*s == '/');
- }
- else {
- ++s;
- }
- }
- *d = '\0';
-}
-
-
-/*
- * copy at most n leading directories of s into d
- * d should be at least as large as s plus 1 extra byte
- * assumes n > 0
- * the return value is the ever useful pointer to the trailing \0 of d
- *
- * examples:
- * /a/b, 1 ==> /
- * /a/b, 2 ==> /a/
- * /a/b, 3 ==> /a/b/
- * /a/b, 4 ==> /a/b/
- */
-API_EXPORT(char *) ap_make_dirstr_prefix(char *d, const char *s, int n)
-{
- for (;;) {
- if (*s == '\0' || (*s == '/' && (--n) == 0)) {
- *d = '/';
- break;
- }
- *d++ = *s++;
- }
- *++d = 0;
- return (d);
-}
-
-
-/*
- * return the parent directory name including trailing / of the file s
- */
-API_EXPORT(char *) ap_make_dirstr_parent(ap_context_t *p, const char *s)
-{
- char *last_slash = strrchr(s, '/');
- char *d;
- int l;
-
- if (last_slash == NULL) {
- /* XXX: well this is really broken if this happens */
- return (ap_pstrdup(p, "/"));
- }
- l = (last_slash - s) + 1;
- d = ap_palloc(p, l + 1);
- memcpy(d, s, l);
- d[l] = 0;
- return (d);
-}
-
-
-/*
- * This function is deprecated. Use one of the preceeding two functions
- * which are faster.
- */
-API_EXPORT(char *) ap_make_dirstr(ap_context_t *p, const char *s, int n)
-{
- register int x, f;
- char *res;
-
- for (x = 0, f = 0; s[x]; x++) {
- if (s[x] == '/')
- if ((++f) == n) {
- res = ap_palloc(p, x + 2);
- memcpy(res, s, x);
- res[x] = '/';
- res[x + 1] = '\0';
- return res;
- }
- }
-
- if (s[strlen(s) - 1] == '/')
- return ap_pstrdup(p, s);
- else
- return ap_pstrcat(p, s, "/", NULL);
-}
-
-API_EXPORT(int) ap_count_dirs(const char *path)
-{
- register int x, n;
-
- for (x = 0, n = 0; path[x]; x++)
- if (path[x] == '/')
- n++;
- return n;
-}
-
-
-API_EXPORT(void) ap_chdir_file(const char *file)
-{
- const char *x;
- char buf[HUGE_STRING_LEN];
-
- x = strrchr(file, '/');
- if (x == NULL) {
- chdir(file);
- }
- else if (x - file < sizeof(buf) - 1) {
- memcpy(buf, file, x - file);
- buf[x - file] = '\0';
- chdir(buf);
- }
- /* XXX: well, this is a silly function, no method of reporting an
- * error... ah well. */
-}
-
-API_EXPORT(char *) ap_getword_nc(ap_context_t *atrans, char **line, char stop)
-{
- return ap_getword(atrans, (const char **) line, stop);
-}
-
-API_EXPORT(char *) ap_getword(ap_context_t *atrans, const char **line, char stop)
-{
- char *pos = strchr(*line, stop);
- char *res;
-
- if (!pos) {
- res = ap_pstrdup(atrans, *line);
- *line += strlen(*line);
- return res;
- }
-
- res = ap_pstrndup(atrans, *line, pos - *line);
-
- while (*pos == stop) {
- ++pos;
- }
-
- *line = pos;
-
- return res;
-}
-
-API_EXPORT(char *) ap_getword_white_nc(ap_context_t *atrans, char **line)
-{
- return ap_getword_white(atrans, (const char **) line);
-}
-
-API_EXPORT(char *) ap_getword_white(ap_context_t *atrans, const char **line)
-{
- int pos = -1, x;
- char *res;
-
- for (x = 0; (*line)[x]; x++) {
- if (ap_isspace((*line)[x])) {
- pos = x;
- break;
- }
- }
-
- if (pos == -1) {
- res = ap_pstrdup(atrans, *line);
- *line += strlen(*line);
- return res;
- }
-
- res = ap_palloc(atrans, pos + 1);
- ap_cpystrn(res, *line, pos + 1);
-
- while (ap_isspace((*line)[pos]))
- ++pos;
-
- *line += pos;
-
- return res;
-}
-
-API_EXPORT(char *) ap_getword_nulls_nc(ap_context_t *atrans, char **line, char stop)
-{
- return ap_getword_nulls(atrans, (const char **) line, stop);
-}
-
-API_EXPORT(char *) ap_getword_nulls(ap_context_t *atrans, const char **line, char stop)
-{
- char *pos = strchr(*line, stop);
- char *res;
-
- if (!pos) {
- res = ap_pstrdup(atrans, *line);
- *line += strlen(*line);
- return res;
- }
-
- res = ap_pstrndup(atrans, *line, pos - *line);
-
- ++pos;
-
- *line = pos;
-
- return res;
-}
-
-/* Get a word, (new) config-file style --- quoted strings and backslashes
- * all honored
- */
-
-static char *substring_conf(ap_context_t *p, const char *start, int len, char quote)
-{
- char *result = ap_palloc(p, len + 2);
- char *resp = result;
- int i;
-
- for (i = 0; i < len; ++i) {
- if (start[i] == '\\' && (start[i + 1] == '\\'
- || (quote && start[i + 1] == quote)))
- *resp++ = start[++i];
- else
- *resp++ = start[i];
- }
-
- *resp++ = '\0';
- return result;
-}
-
-API_EXPORT(char *) ap_getword_conf_nc(ap_context_t *p, char **line)
-{
- return ap_getword_conf(p, (const char **) line);
-}
-
-API_EXPORT(char *) ap_getword_conf(ap_context_t *p, const char **line)
-{
- const char *str = *line, *strend;
- char *res;
- char quote;
-
- while (*str && ap_isspace(*str))
- ++str;
-
- if (!*str) {
- *line = str;
- return "";
- }
-
- if ((quote = *str) == '"' || quote == '\'') {
- strend = str + 1;
- while (*strend && *strend != quote) {
- if (*strend == '\\' && strend[1] && strend[1] == quote)
- strend += 2;
- else
- ++strend;
- }
- res = substring_conf(p, str + 1, strend - str - 1, quote);
-
- if (*strend == quote)
- ++strend;
- }
- else {
- strend = str;
- while (*strend && !ap_isspace(*strend))
- ++strend;
-
- res = substring_conf(p, str, strend - str, 0);
- }
-
- while (*strend && ap_isspace(*strend))
- ++strend;
- *line = strend;
- return res;
-}
-
-API_EXPORT(int) ap_cfg_closefile(configfile_t *cfp)
-{
-#ifdef DEBUG
- ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL,
- "Done with config file %s", cfp->name);
-#endif
- return (cfp->close == NULL) ? 0 : cfp->close(cfp->param);
-}
-
-static ap_status_t cfg_close(void *param)
-{
- ap_file_t *cfp = (ap_file_t *) param;
- return (ap_close(cfp));
-}
-
-static int cfg_getch(void *param)
-{
- char ch;
- ap_file_t *cfp = (ap_file_t *) param;
- if (ap_getc(&ch, cfp) == APR_SUCCESS)
- return ch;
- return (int)EOF;
-}
-
-static void *cfg_getstr(void *buf, size_t bufsiz, void *param)
-{
- ap_file_t *cfp = (ap_file_t *) param;
- if (ap_fgets(buf, bufsiz, cfp) == APR_SUCCESS)
- return buf;
- return NULL;
-}
-
-/* Open a configfile_t as FILE, return open configfile_t struct pointer */
-API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **ret_cfg, ap_context_t *p, const char *name)
-{
- configfile_t *new_cfg;
- ap_file_t *file = NULL;
- ap_finfo_t finfo;
- ap_status_t stat;
-
- if (name == NULL) {
- ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, NULL,
- "Internal error: pcfg_openfile() called with NULL filename");
- return APR_EBADF;
- }
-
- if (!ap_os_is_filename_valid(name)) {
- ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, NULL,
- "Access to config file %s denied: not a valid filename",
- name);
- return APR_EACCES;
- }
-
- stat = ap_open(&file, name, APR_READ | APR_BUFFERED, APR_OS_DEFAULT, p);
-#ifdef DEBUG
- ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, NULL,
- "Opening config file %s (%s)",
- name, (stat != APR_SUCCESS) ? strerror(errno) : "successful");
-#endif
- if (stat != APR_SUCCESS)
- return stat;
-
- stat = ap_getfileinfo(&finfo, file);
- if (stat != APR_SUCCESS)
- return stat;
-
- if (finfo.filetype != APR_REG &&
-#if defined(WIN32) || defined(OS2)
- !(strcasecmp(name, "nul") == 0 ||
- (strlen(name) >= 4 &&
- strcasecmp(name + strlen(name) - 4, "/nul") == 0))) {
-#else
- strcmp(name, "/dev/null") != 0) {
-#endif /* WIN32 || OS2 */
- ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, NULL,
- "Access to file %s denied by server: not a regular file",
- name);
- ap_close(file);
- return APR_EBADF;
- }
-
- new_cfg = ap_palloc(p, sizeof(*new_cfg));
- new_cfg->param = file;
- new_cfg->name = ap_pstrdup(p, name);
- new_cfg->getch = (int (*)(void *)) cfg_getch;
- new_cfg->getstr = (void *(*)(void *, size_t, void *)) cfg_getstr;
- new_cfg->close = (int (*)(void *)) cfg_close;
- new_cfg->line_number = 0;
- *ret_cfg = new_cfg;
- return APR_SUCCESS;
-}
-
-
-/* Allocate a configfile_t handle with user defined functions and params */
-API_EXPORT(configfile_t *) ap_pcfg_open_custom(ap_context_t *p, const char *descr,
- void *param,
- int(*getch)(void *param),
- void *(*getstr) (void *buf, size_t bufsiz, void *param),
- int(*close_func)(void *param))
-{
- configfile_t *new_cfg = ap_palloc(p, sizeof(*new_cfg));
-#ifdef DEBUG
- ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, NULL, "Opening config handler %s", descr);
-#endif
- new_cfg->param = param;
- new_cfg->name = descr;
- new_cfg->getch = getch;
- new_cfg->getstr = getstr;
- new_cfg->close = close_func;
- new_cfg->line_number = 0;
- return new_cfg;
-}
-
-
-/* Read one character from a configfile_t */
-API_EXPORT(int) ap_cfg_getc(configfile_t *cfp)
-{
- register int ch = cfp->getch(cfp->param);
- if (ch == LF)
- ++cfp->line_number;
- return ch;
-}
-
-
-/* Read one line from open configfile_t, strip LF, increase line number */
-/* If custom handler does not define a getstr() function, read char by char */
-API_EXPORT(int) ap_cfg_getline(char *buf, size_t bufsize, configfile_t *cfp)
-{
- /* If a "get string" function is defined, use it */
- if (cfp->getstr != NULL) {
- char *src, *dst;
- char *cp;
- char *cbuf = buf;
- size_t cbufsize = bufsize;
-
- while (1) {
- ++cfp->line_number;
- if (cfp->getstr(cbuf, cbufsize, cfp->param) == NULL)
- return 1;
-
- /*
- * check for line continuation,
- * i.e. match [^\\]\\[\r]\n only
- */
- cp = cbuf;
- while (cp < cbuf+cbufsize && *cp != '\0')
- cp++;
- if (cp > cbuf && cp[-1] == LF) {
- cp--;
- if (cp > cbuf && cp[-1] == CR)
- cp--;
- if (cp > cbuf && cp[-1] == '\\') {
- cp--;
- if (!(cp > cbuf && cp[-1] == '\\')) {
- /*
- * line continuation requested -
- * then remove backslash and continue
- */
- cbufsize -= (cp-cbuf);
- cbuf = cp;
- continue;
- }
- else {
- /*
- * no real continuation because escaped -
- * then just remove escape character
- */
- for ( ; cp < cbuf+cbufsize && *cp != '\0'; cp++)
- cp[0] = cp[1];
- }
- }
- }
- break;
- }
-
- /*
- * Leading and trailing white space is eliminated completely
- */
- src = buf;
- while (ap_isspace(*src))
- ++src;
- /* blast trailing whitespace */
- dst = &src[strlen(src)];
- while (--dst >= src && ap_isspace(*dst))
- *dst = '\0';
- /* Zap leading whitespace by shifting */
- if (src != buf)
- for (dst = buf; (*dst++ = *src++) != '\0'; )
- ;
-
-#ifdef DEBUG_CFG_LINES
- ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL, "Read config: %s", buf);
-#endif
- return 0;
- } else {
- /* No "get string" function defined; read character by character */
- register int c;
- register size_t i = 0;
-
- buf[0] = '\0';
- /* skip leading whitespace */
- do {
- c = cfp->getch(cfp->param);
- } while (c == '\t' || c == ' ');
-
- if (c == EOF)
- return 1;
-
- if(bufsize < 2) {
- /* too small, assume caller is crazy */
- return 1;
- }
-
- while (1) {
- if ((c == '\t') || (c == ' ')) {
- buf[i++] = ' ';
- while ((c == '\t') || (c == ' '))
- c = cfp->getch(cfp->param);
- }
- if (c == CR) {
- /* silently ignore CR (_assume_ that a LF follows) */
- c = cfp->getch(cfp->param);
- }
- if (c == LF) {
- /* increase line number and return on LF */
- ++cfp->line_number;
- }
- if (c == EOF || c == 0x4 || c == LF || i >= (bufsize - 2)) {
- /*
- * check for line continuation
- */
- if (i > 0 && buf[i-1] == '\\') {
- i--;
- if (!(i > 0 && buf[i-1] == '\\')) {
- /* line is continued */
- c = cfp->getch(cfp->param);
- continue;
- }
- /* else nothing needs be done because
- * then the backslash is escaped and
- * we just strip to a single one
- */
- }
- /* blast trailing whitespace */
- while (i > 0 && ap_isspace(buf[i - 1]))
- --i;
- buf[i] = '\0';
-#ifdef DEBUG_CFG_LINES
- ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, NULL, "Read config: %s", buf);
-#endif
- return 0;
- }
- buf[i] = c;
- ++i;
- c = cfp->getch(cfp->param);
- }
- }
-}
-
-/* Size an HTTP header field list item, as separated by a comma.
- * 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.
- */
-API_EXPORT(const char *) ap_size_list_item(const char **field, int *len)
-{
- const unsigned char *ptr = (const unsigned char *)*field;
- const unsigned char *token;
- int in_qpair, in_qstr, in_com;
-
- /* Find first non-comma, non-whitespace byte */
-
- while (*ptr == ',' || ap_isspace(*ptr))
- ++ptr;
-
- token = ptr;
-
- /* Find the end of this item, skipping over dead bits */
-
- for (in_qpair = in_qstr = in_com = 0;
- *ptr && (in_qpair || in_qstr || in_com || *ptr != ',');
- ++ptr) {
-
- if (in_qpair) {
- in_qpair = 0;
- }
- else {
- switch (*ptr) {
- case '\\': in_qpair = 1; /* quoted-pair */
- break;
- case '"' : if (!in_com) /* quoted string delim */
- in_qstr = !in_qstr;
- break;
- case '(' : if (!in_qstr) /* comment (may nest) */
- ++in_com;
- break;
- case ')' : if (in_com) /* end comment */
- --in_com;
- break;
- default : break;
- }
- }
- }
-
- if ((*len = (ptr - token)) == 0) {
- *field = (const char *)ptr;
- return NULL;
- }
-
- /* Advance field pointer to the next non-comma, non-white byte */
-
- while (*ptr == ',' || ap_isspace(*ptr))
- ++ptr;
-
- *field = (const char *)ptr;
- return (const char *)token;
-}
-
-/* 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. 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.
- */
-API_EXPORT(char *) ap_get_list_item(ap_context_t *p, const char **field)
-{
- const char *tok_start;
- const unsigned char *ptr;
- unsigned char *pos;
- char *token;
- int addspace = 0, in_qpair = 0, in_qstr = 0, in_com = 0, tok_len = 0;
-
- /* Find the beginning and maximum length of the list item so that
- * we can allocate a buffer for the new string and reset the field.
- */
- if ((tok_start = ap_size_list_item(field, &tok_len)) == NULL) {
- return NULL;
- }
- token = ap_palloc(p, tok_len + 1);
-
- /* Scan the token again, but this time copy only the good bytes.
- * We skip extra whitespace and any whitespace around a '=', '/',
- * or ';' and lowercase normal characters not within a comment,
- * quoted-string or quoted-pair.
- */
- for (ptr = (const unsigned char *)tok_start, pos = (unsigned char *)token;
- *ptr && (in_qpair || in_qstr || in_com || *ptr != ',');
- ++ptr) {
-
- if (in_qpair) {
- in_qpair = 0;
- *pos++ = *ptr;
- }
- else {
- switch (*ptr) {
- case '\\': in_qpair = 1;
- if (addspace == 1)
- *pos++ = ' ';
- *pos++ = *ptr;
- addspace = 0;
- break;
- case '"' : if (!in_com)
- in_qstr = !in_qstr;
- if (addspace == 1)
- *pos++ = ' ';
- *pos++ = *ptr;
- addspace = 0;
- break;
- case '(' : if (!in_qstr)
- ++in_com;
- if (addspace == 1)
- *pos++ = ' ';
- *pos++ = *ptr;
- addspace = 0;
- break;
- case ')' : if (in_com)
- --in_com;
- *pos++ = *ptr;
- addspace = 0;
- break;
- case ' ' :
- case '\t': if (addspace)
- break;
- if (in_com || in_qstr)
- *pos++ = *ptr;
- else
- addspace = 1;
- break;
- case '=' :
- case '/' :
- case ';' : if (!(in_com || in_qstr))
- addspace = -1;
- *pos++ = *ptr;
- break;
- default : if (addspace == 1)
- *pos++ = ' ';
- *pos++ = (in_com || in_qstr) ? *ptr
- : ap_tolower(*ptr);
- addspace = 0;
- break;
- }
- }
- }
- *pos = '\0';
-
- return token;
-}
-
-/* Find an item in canonical form (lowercase, no extra spaces) within
- * an HTTP field value list. Returns 1 if found, 0 if not found.
- * This would be much more efficient if we stored header fields as
- * an array of list items as they are received instead of a plain string.
- */
-API_EXPORT(int) ap_find_list_item(ap_context_t *p, const char *line, const char *tok)
-{
- const unsigned char *pos;
- const unsigned char *ptr = (const unsigned char *)line;
- int good = 0, addspace = 0, in_qpair = 0, in_qstr = 0, in_com = 0;
-
- if (!line || !tok)
- return 0;
-
- do { /* loop for each item in line's list */
-
- /* Find first non-comma, non-whitespace byte */
-
- while (*ptr == ',' || ap_isspace(*ptr))
- ++ptr;
-
- if (*ptr)
- good = 1; /* until proven otherwise for this item */
- else
- break; /* no items left and nothing good found */
-
- /* We skip extra whitespace and any whitespace around a '=', '/',
- * or ';' and lowercase normal characters not within a comment,
- * quoted-string or quoted-pair.
- */
- for (pos = (const unsigned char *)tok;
- *ptr && (in_qpair || in_qstr || in_com || *ptr != ',');
- ++ptr) {
-
- if (in_qpair) {
- in_qpair = 0;
- if (good)
- good = (*pos++ == *ptr);
- }
- else {
- switch (*ptr) {
- case '\\': in_qpair = 1;
- if (addspace == 1)
- good = good && (*pos++ == ' ');
- good = good && (*pos++ == *ptr);
- addspace = 0;
- break;
- case '"' : if (!in_com)
- in_qstr = !in_qstr;
- if (addspace == 1)
- good = good && (*pos++ == ' ');
- good = good && (*pos++ == *ptr);
- addspace = 0;
- break;
- case '(' : if (!in_qstr)
- ++in_com;
- if (addspace == 1)
- good = good && (*pos++ == ' ');
- good = good && (*pos++ == *ptr);
- addspace = 0;
- break;
- case ')' : if (in_com)
- --in_com;
- good = good && (*pos++ == *ptr);
- addspace = 0;
- break;
- case ' ' :
- case '\t': if (addspace || !good)
- break;
- if (in_com || in_qstr)
- good = (*pos++ == *ptr);
- else
- addspace = 1;
- break;
- case '=' :
- case '/' :
- case ';' : if (!(in_com || in_qstr))
- addspace = -1;
- good = good && (*pos++ == *ptr);
- break;
- default : if (!good)
- break;
- if (addspace == 1)
- good = (*pos++ == ' ');
- if (in_com || in_qstr)
- good = good && (*pos++ == *ptr);
- else
- good = good && (*pos++ == ap_tolower(*ptr));
- addspace = 0;
- break;
- }
- }
- }
- if (good && *pos)
- good = 0; /* not good if only a prefix was matched */
-
- } while (*ptr && !good);
-
- return good;
-}
-
-
-/* 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.
- */
-
-API_EXPORT(char *) ap_get_token(ap_context_t *p, const char **accept_line, int accept_white)
-{
- const char *ptr = *accept_line;
- const char *tok_start;
- char *token;
- int tok_len;
-
- /* Find first non-white byte */
-
- while (*ptr && ap_isspace(*ptr))
- ++ptr;
-
- tok_start = ptr;
-
- /* find token end, skipping over quoted strings.
- * (comments are already gone).
- */
-
- while (*ptr && (accept_white || !ap_isspace(*ptr))
- && *ptr != ';' && *ptr != ',') {
- if (*ptr++ == '"')
- while (*ptr)
- if (*ptr++ == '"')
- break;
- }
-
- tok_len = ptr - tok_start;
- token = ap_pstrndup(p, tok_start, tok_len);
-
- /* Advance accept_line pointer to the next non-white byte */
-
- while (*ptr && ap_isspace(*ptr))
- ++ptr;
-
- *accept_line = ptr;
- return token;
-}
-
-
-/* find http tokens, see the definition of token from RFC2068 */
-API_EXPORT(int) ap_find_token(ap_context_t *p, const char *line, const char *tok)
-{
- const unsigned char *start_token;
- const unsigned char *s;
-
- if (!line)
- return 0;
-
- s = (const unsigned char *)line;
- for (;;) {
- /* find start of token, skip all stop characters, note NUL
- * isn't a token stop, so we don't need to test for it
- */
- while (TEST_CHAR(*s, T_HTTP_TOKEN_STOP)) {
- ++s;
- }
- if (!*s) {
- return 0;
- }
- start_token = s;
- /* find end of the token */
- while (*s && !TEST_CHAR(*s, T_HTTP_TOKEN_STOP)) {
- ++s;
- }
- if (!strncasecmp((const char *)start_token, (const char *)tok, s - start_token)) {
- return 1;
- }
- if (!*s) {
- return 0;
- }
- }
-}
-
-
-API_EXPORT(int) ap_find_last_token(ap_context_t *p, const char *line, const char *tok)
-{
- int llen, tlen, lidx;
-
- if (!line)
- return 0;
-
- llen = strlen(line);
- tlen = strlen(tok);
- lidx = llen - tlen;
-
- if ((lidx < 0) ||
- ((lidx > 0) && !(ap_isspace(line[lidx - 1]) || line[lidx - 1] == ',')))
- return 0;
-
- return (strncasecmp(&line[lidx], tok, tlen) == 0);
-}
-
-API_EXPORT(char *) ap_escape_shell_cmd(ap_context_t *p, const char *str)
-{
- char *cmd;
- unsigned char *d;
- const unsigned char *s;
-
- cmd = ap_palloc(p, 2 * strlen(str) + 1); /* Be safe */
- d = (unsigned char *)cmd;
- s = (const unsigned char *)str;
- for (; *s; ++s) {
-
-#if defined(OS2) || defined(WIN32)
- /* Don't allow '&' in parameters under OS/2. */
- /* This can be used to send commands to the shell. */
- if (*s == '&') {
- *d++ = ' ';
- continue;
- }
-#endif
-
- if (TEST_CHAR(*s, T_ESCAPE_SHELL_CMD)) {
- *d++ = '\\';
- }
- *d++ = *s;
- }
- *d = '\0';
-
- return cmd;
-}
-
-static char x2c(const char *what)
-{
- register char digit;
-
-#ifndef CHARSET_EBCDIC
- digit = ((what[0] >= 'A') ? ((what[0] & 0xdf) - 'A') + 10 : (what[0] - '0'));
- digit *= 16;
- digit += (what[1] >= 'A' ? ((what[1] & 0xdf) - 'A') + 10 : (what[1] - '0'));
-#else /*CHARSET_EBCDIC*/
- char xstr[5];
- xstr[0]='0';
- xstr[1]='x';
- xstr[2]=what[0];
- xstr[3]=what[1];
- xstr[4]='\0';
- digit = os_toebcdic[0xFF & strtol(xstr, NULL, 16)];
-#endif /*CHARSET_EBCDIC*/
- return (digit);
-}
-
-/*
- * Unescapes a URL.
- * Returns 0 on success, non-zero on error
- * Failure is due to
- * bad % escape returns BAD_REQUEST
- *
- * decoding %00 -> \0
- * decoding %2f -> / (a special character)
- * returns NOT_FOUND
- */
-API_EXPORT(int) ap_unescape_url(char *url)
-{
- register int badesc, badpath;
- char *x, *y;
-
- badesc = 0;
- badpath = 0;
- /* Initial scan for first '%'. Don't bother writing values before
- * seeing a '%' */
- y = strchr(url, '%');
- if (y == NULL) {
- return OK;
- }
- for (x = y; *y; ++x, ++y) {
- if (*y != '%')
- *x = *y;
- else {
- if (!ap_isxdigit(*(y + 1)) || !ap_isxdigit(*(y + 2))) {
- badesc = 1;
- *x = '%';
- }
- else {
- *x = x2c(y + 1);
- y += 2;
- if (*x == '/' || *x == '\0')
- badpath = 1;
- }
- }
- }
- *x = '\0';
- if (badesc)
- return BAD_REQUEST;
- else if (badpath)
- return NOT_FOUND;
- else
- return OK;
-}
-
-API_EXPORT(char *) ap_construct_server(ap_context_t *p, const char *hostname,
- unsigned port, const request_rec *r)
-{
- if (ap_is_default_port(port, r))
- return ap_pstrdup(p, hostname);
- else {
- return ap_psprintf(p, "%s:%u", hostname, port);
- }
-}
-
-/* c2x takes an unsigned, and expects the caller has guaranteed that
- * 0 <= what < 256... which usually means that you have to cast to
- * unsigned char first, because (unsigned)(char)(x) fist goes through
- * signed extension to an int before the unsigned cast.
- *
- * The reason for this assumption is to assist gcc code generation --
- * the unsigned char -> unsigned extension is already done earlier in
- * both uses of this code, so there's no need to waste time doing it
- * again.
- */
-static const char c2x_table[] = "0123456789abcdef";
-
-static ap_inline unsigned char *c2x(unsigned what, unsigned char *where)
-{
- *where++ = '%';
- *where++ = c2x_table[what >> 4];
- *where++ = c2x_table[what & 0xf];
- return where;
-}
-
-/*
- * escape_path_segment() escapes a path segment, as defined in RFC 1808. This
- * routine is (should be) OS independent.
- *
- * os_escape_path() converts an OS path to a URL, in an OS dependent way. In all
- * cases if a ':' occurs before the first '/' in the URL, the URL should be
- * prefixed with "./" (or the ':' escaped). In the case of Unix, this means
- * leaving '/' alone, but otherwise doing what escape_path_segment() does. For
- * efficiency reasons, we don't use escape_path_segment(), which is provided for
- * reference. Again, RFC 1808 is where this stuff is defined.
- *
- * If partial is set, os_escape_path() assumes that the path will be appended to
- * something with a '/' in it (and thus does not prefix "./").
- */
-
-API_EXPORT(char *) ap_escape_path_segment(ap_context_t *p, const char *segment)
-{
- char *copy = ap_palloc(p, 3 * strlen(segment) + 1);
- const unsigned char *s = (const unsigned char *)segment;
- unsigned char *d = (unsigned char *)copy;
- unsigned c;
-
- while ((c = *s)) {
- if (TEST_CHAR(c, T_ESCAPE_PATH_SEGMENT)) {
- d = c2x(c, d);
- }
- else {
- *d++ = c;
- }
- ++s;
- }
- *d = '\0';
- return copy;
-}
-
-API_EXPORT(char *) ap_os_escape_path(ap_context_t *p, const char *path, int partial)
-{
- char *copy = ap_palloc(p, 3 * strlen(path) + 3);
- const unsigned char *s = (const unsigned char *)path;
- unsigned char *d = (unsigned char *)copy;
- unsigned c;
-
- if (!partial) {
- char *colon = strchr(path, ':');
- char *slash = strchr(path, '/');
-
- if (colon && (!slash || colon < slash)) {
- *d++ = '.';
- *d++ = '/';
- }
- }
- while ((c = *s)) {
- if (TEST_CHAR(c, T_OS_ESCAPE_PATH)) {
- d = c2x(c, d);
- }
- else {
- *d++ = c;
- }
- ++s;
- }
- *d = '\0';
- return copy;
-}
-
-/* ap_escape_uri is now a macro for os_escape_path */
-
-API_EXPORT(char *) ap_escape_html(ap_context_t *p, const char *s)
-{
- int i, j;
- char *x;
-
- /* first, count the number of extra characters */
- for (i = 0, j = 0; s[i] != '\0'; i++)
- if (s[i] == '<' || s[i] == '>')
- j += 3;
- else if (s[i] == '&')
- j += 4;
-
- if (j == 0)
- return ap_pstrndup(p, s, i);
-
- x = ap_palloc(p, i + j + 1);
- for (i = 0, j = 0; s[i] != '\0'; i++, j++)
- if (s[i] == '<') {
- memcpy(&x[j], "&lt;", 4);
- j += 3;
- }
- else if (s[i] == '>') {
- memcpy(&x[j], "&gt;", 4);
- j += 3;
- }
- else if (s[i] == '&') {
- memcpy(&x[j], "&amp;", 5);
- j += 4;
- }
- else
- x[j] = s[i];
-
- x[j] = '\0';
- return x;
-}
-
-API_EXPORT(int) ap_is_directory(const char *path)
-{
- struct stat finfo;
-
- if (stat(path, &finfo) == -1)
- return 0; /* in error condition, just return no */
-
- return (S_ISDIR(finfo.st_mode));
-}
-
-API_EXPORT(char *) ap_make_full_path(ap_context_t *a, const char *src1,
- const char *src2)
-{
- register int x;
-
- x = strlen(src1);
- if (x == 0)
- return ap_pstrcat(a, "/", src2, NULL);
-
- if (src1[x - 1] != '/')
- return ap_pstrcat(a, src1, "/", src2, NULL);
- else
- return ap_pstrcat(a, src1, src2, NULL);
-}
-
-/*
- * Check for an absoluteURI syntax (see section 3.2 in RFC2068).
- */
-API_EXPORT(int) ap_is_url(const char *u)
-{
- register int x;
-
- for (x = 0; u[x] != ':'; x++) {
- if ((!u[x]) ||
- ((!ap_isalpha(u[x])) && (!ap_isdigit(u[x])) &&
- (u[x] != '+') && (u[x] != '-') && (u[x] != '.'))) {
- return 0;
- }
- }
-
- return (x ? 1 : 0); /* If the first character is ':', it's broken, too */
-}
-
-#ifndef HAVE_STRDUP
-char *strdup(const char *str)
-{
- char *sdup;
-
- if (!(sdup = (char *) malloc(strlen(str) + 1))) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Ouch! Out of memory in our strdup()!");
- return NULL;
- }
- sdup = strcpy(sdup, str);
-
- return sdup;
-}
-#endif
-
-/* The following two routines were donated for SVR4 by Andreas Vogel */
-#ifndef HAVE_STRCASECMP
-int strcasecmp(const char *a, const char *b)
-{
- const char *p = a;
- const char *q = b;
- for (p = a, q = b; *p && *q; p++, q++) {
- int diff = ap_tolower(*p) - ap_tolower(*q);
- if (diff)
- return diff;
- }
- if (*p)
- return 1; /* p was longer than q */
- if (*q)
- return -1; /* p was shorter than q */
- return 0; /* Exact match */
-}
-
-#endif
-
-#ifndef HAVE_STRNCASECMP
-int strncasecmp(const char *a, const char *b, int n)
-{
- const char *p = a;
- const char *q = b;
-
- for (p = a, q = b; /*NOTHING */ ; p++, q++) {
- int diff;
- if (p == a + n)
- return 0; /* Match up to n characters */
- if (!(*p && *q))
- return *p - *q;
- diff = ap_tolower(*p) - ap_tolower(*q);
- if (diff)
- return diff;
- }
- /*NOTREACHED */
-}
-#endif
-
-/* The following routine was donated for UTS21 by dwd@bell-labs.com */
-#ifndef HAVE_STRSTR
-char *strstr(char *s1, char *s2)
-{
- char *p1, *p2;
- if (*s2 == '\0') {
- /* an empty s2 */
- return(s1);
- }
- while((s1 = strchr(s1, *s2)) != NULL) {
- /* found first character of s2, see if the rest matches */
- p1 = s1;
- p2 = s2;
- while (*++p1 == *++p2) {
- if (*p1 == '\0') {
- /* both strings ended together */
- return(s1);
- }
- }
- if (*p2 == '\0') {
- /* second string ended, a match */
- break;
- }
- /* didn't find a match here, try starting at next character in s1 */
- s1++;
- }
- return(s1);
-}
-#endif
-
-#ifndef HAVE_INITGROUPS
-int initgroups(const char *name, gid_t basegid)
-{
-#if defined(QNX) || defined(MPE) || defined(BEOS) || defined(_OSD_POSIX) || defined(TPF) || defined(__TANDEM) || defined(OS2)
-/* QNX, MPE and BeOS do not appear to support supplementary groups. */
- return 0;
-#else /* ndef QNX */
- gid_t groups[NGROUPS_MAX];
- struct group *g;
- int index = 0;
-
- setgrent();
-
- groups[index++] = basegid;
-
- while (index < NGROUPS_MAX && ((g = getgrent()) != NULL))
- if (g->gr_gid != basegid) {
- char **names;
-
- for (names = g->gr_mem; *names != NULL; ++names)
- if (!strcmp(*names, name))
- groups[index++] = g->gr_gid;
- }
-
- endgrent();
-
- return setgroups(index, groups);
-#endif /* def QNX */
-}
-#endif /* def NEED_INITGROUPS */
-
-#ifndef HAVE_WAITPID
-/* From ikluft@amdahl.com
- * this is not ideal but it works for SVR3 variants
- * Modified by dwd@bell-labs.com to call wait3 instead of wait because
- * apache started to use the WNOHANG option.
- */
-int waitpid(pid_t pid, int *statusp, int options)
-{
- int tmp_pid;
- if (kill(pid, 0) == -1) {
- errno = ECHILD;
- return -1;
- }
- while (((tmp_pid = wait3(statusp, options, 0)) != pid) &&
- (tmp_pid != -1) && (tmp_pid != 0) && (pid != -1))
- ;
- return tmp_pid;
-}
-#endif
-
-API_EXPORT(int) ap_ind(const char *s, char c)
-{
- register int x;
-
- for (x = 0; s[x]; x++)
- if (s[x] == c)
- return x;
-
- return -1;
-}
-
-API_EXPORT(int) ap_rind(const char *s, char c)
-{
- register int x;
-
- for (x = strlen(s) - 1; x != -1; x--)
- if (s[x] == c)
- return x;
-
- return -1;
-}
-
-API_EXPORT(void) ap_str_tolower(char *str)
-{
- while (*str) {
- *str = ap_tolower(*str);
- ++str;
- }
-}
-
-API_EXPORT(uid_t) ap_uname2id(const char *name)
-{
-#ifdef WIN32
- return (1);
-#else
- struct passwd *ent;
-
- if (name[0] == '#')
- return (atoi(&name[1]));
-
- if (!(ent = getpwnam(name))) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "%s: bad user name %s", ap_server_argv0, name);
- exit(1);
- }
- return (ent->pw_uid);
-#endif
-}
-
-API_EXPORT(gid_t) ap_gname2id(const char *name)
-{
-#ifdef WIN32
- return (1);
-#else
- struct group *ent;
-
- if (name[0] == '#')
- return (atoi(&name[1]));
-
- if (!(ent = getgrnam(name))) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "%s: bad group name %s", ap_server_argv0, name);
- exit(1);
- }
- return (ent->gr_gid);
-#endif
-}
-
-
-/*
- * Parses a host of the form <address>[:port]
- * :port is permitted if 'port' is not NULL
- */
-unsigned long ap_get_virthost_addr(char *w, unsigned short *ports)
-{
- struct hostent *hep;
- unsigned long my_addr;
- char *p;
-
- p = strchr(w, ':');
- if (ports != NULL) {
- *ports = 0;
- if (p != NULL && strcmp(p + 1, "*") != 0)
- *ports = atoi(p + 1);
- }
-
- if (p != NULL)
- *p = '\0';
- if (strcmp(w, "*") == 0) {
- if (p != NULL)
- *p = ':';
- return htonl(INADDR_ANY);
- }
-
- my_addr = ap_inet_addr((char *)w);
- if (my_addr != INADDR_NONE) {
- if (p != NULL)
- *p = ':';
- return my_addr;
- }
-
- hep = gethostbyname(w);
-
- if ((!hep) || (hep->h_addrtype != AF_INET || !hep->h_addr_list[0])) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Cannot resolve host name %s --- exiting!", w);
- exit(1);
- }
-
- if (hep->h_addr_list[1]) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Host %s has multiple addresses ---", w);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "you must choose one explicitly for use as");
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "a virtual host. Exiting!!!");
- exit(1);
- }
-
- if (p != NULL)
- *p = ':';
-
- return ((struct in_addr *) (hep->h_addr))->s_addr;
-}
-
-
-static char *find_fqdn(ap_context_t *a, struct hostent *p)
-{
- int x;
-
- if (!strchr(p->h_name, '.')) {
- for (x = 0; p->h_aliases[x]; ++x) {
- if (strchr(p->h_aliases[x], '.') &&
- (!strncasecmp(p->h_aliases[x], p->h_name, strlen(p->h_name))))
- return ap_pstrdup(a, p->h_aliases[x]);
- }
- return NULL;
- }
- return ap_pstrdup(a, (void *) p->h_name);
-}
-
-char *ap_get_local_host(ap_context_t *a)
-{
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 256
-#endif
- char str[MAXHOSTNAMELEN + 1];
- char *server_hostname;
- struct hostent *p;
-
-#ifdef BEOS
- if (gethostname(str, sizeof(str) - 1) == 0)
-#else
- if (gethostname(str, sizeof(str) - 1) != 0)
-#endif
- {
- perror("Unable to gethostname");
- exit(1);
- }
- str[MAXHOSTNAMELEN] = '\0';
- if ((!(p = gethostbyname(str))) || (!(server_hostname = find_fqdn(a, p)))) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "%s: cannot determine local host name.",
- ap_server_argv0);
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
- "Use the ServerName directive to set it manually.");
- exit(1);
- }
-
- return server_hostname;
-}
-
-/* simple 'pool' alloc()ing glue to ap_base64.c
- */
-API_EXPORT(char *) ap_pbase64decode(ap_context_t *p, const char *bufcoded)
-{
- char *decoded;
- int l;
-
- decoded = (char *) ap_palloc(p, 1 + ap_base64decode_len(bufcoded));
- l = ap_base64decode(decoded, bufcoded);
- decoded[l] = '\0'; /* make binary sequence into string */
-
- return decoded;
-}
-
-API_EXPORT(char *) ap_pbase64encode(ap_context_t *p, char *string)
-{
- char *encoded;
- int l = strlen(string);
-
- encoded = (char *) ap_palloc(p, 1 + ap_base64encode_len(l));
- l = ap_base64encode(encoded, string, l);
- encoded[l] = '\0'; /* make binary sequence into string */
-
- return encoded;
-}
-
-/* deprecated names for the above two functions, here for compatibility
- */
-API_EXPORT(char *) ap_uudecode(ap_context_t *p, const char *bufcoded)
-{
- return ap_pbase64decode(p, bufcoded);
-}
-
-API_EXPORT(char *) ap_uuencode(ap_context_t *p, char *string)
-{
- return ap_pbase64encode(p, string);
-}
-
-#ifndef HAVE_STRERROR
-char *
- strerror(int err)
-{
-
- char *p;
- extern char *const sys_errlist[];
-
- p = sys_errlist[err];
- return (p);
-}
-#endif
-
-/* we want to downcase the type/subtype for comparison purposes
- * but nothing else because ;parameter=foo values are case sensitive.
- * XXX: in truth we want to downcase parameter names... but really,
- * apache has never handled parameters and such correctly. You
- * also need to compress spaces and such to be able to compare
- * properly. -djg
- */
-API_EXPORT(void) ap_content_type_tolower(char *str)
-{
- char *semi;
-
- semi = strchr(str, ';');
- if (semi) {
- *semi = '\0';
- }
- while (*str) {
- *str = ap_tolower(*str);
- ++str;
- }
- if (semi) {
- *semi = ';';
- }
-}
-
-/*
- * Given a string, replace any bare " with \" .
- */
-API_EXPORT(char *) ap_escape_quotes (ap_context_t *p, const char *instring)
-{
- int newlen = 0;
- const char *inchr = instring;
- char *outchr, *outstring;
-
- /*
- * Look through the input string, jogging the length of the output
- * string up by an extra byte each time we find an unescaped ".
- */
- while (*inchr != '\0') {
- newlen++;
- if (*inchr == '"') {
- newlen++;
- }
- /*
- * If we find a slosh, and it's not the last byte in the string,
- * it's escaping something - advance past both bytes.
- */
- if ((*inchr == '\\') && (inchr[1] != '\0')) {
- inchr++;
- newlen++;
- }
- inchr++;
- }
- outstring = ap_palloc(p, newlen + 1);
- inchr = instring;
- outchr = outstring;
- /*
- * Now copy the input string to the output string, inserting a slosh
- * in front of every " that doesn't already have one.
- */
- while (*inchr != '\0') {
- if ((*inchr == '\\') && (inchr[1] != '\0')) {
- *outchr++ = *inchr++;
- *outchr++ = *inchr++;
- }
- if (*inchr == '"') {
- *outchr++ = '\\';
- }
- if (*inchr != '\0') {
- *outchr++ = *inchr++;
- }
- }
- *outchr = '\0';
- return outstring;
-}
diff --git a/server/util_date.c b/server/util_date.c
deleted file mode 100644
index f8809e9def..0000000000
--- a/server/util_date.c
+++ /dev/null
@@ -1,286 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1996-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * util_date.c: date parsing utility routines
- * These routines are (hopefully) platform independent.
- *
- * 27 Oct 1996 Roy Fielding
- * Extracted (with many modifications) from mod_proxy.c and
- * tested with over 50,000 randomly chosen valid date strings
- * and several hundred variations of invalid date strings.
- *
- */
-
-#define CORE_PRIVATE
-
-#include "ap_config.h"
-#include "util_date.h"
-#include <ctype.h>
-#include <string.h>
-
-/*
- * Compare a string to a mask
- * Mask characters (arbitrary maximum is 256 characters, just in case):
- * @ - uppercase letter
- * $ - lowercase letter
- * & - hex digit
- * # - digit
- * ~ - digit or space
- * * - swallow remaining characters
- * <x> - exact match for any other character
- */
-API_EXPORT(int) ap_checkmask(const char *data, const char *mask)
-{
- int i;
- char d;
-
- for (i = 0; i < 256; i++) {
- d = data[i];
- switch (mask[i]) {
- case '\0':
- return (d == '\0');
-
- case '*':
- return 1;
-
- case '@':
- if (!ap_isupper(d))
- return 0;
- break;
- case '$':
- if (!ap_islower(d))
- return 0;
- break;
- case '#':
- if (!ap_isdigit(d))
- return 0;
- break;
- case '&':
- if (!ap_isxdigit(d))
- return 0;
- break;
- case '~':
- if ((d != ' ') && !ap_isdigit(d))
- return 0;
- break;
- default:
- if (mask[i] != d)
- return 0;
- break;
- }
- }
- return 0; /* We only get here if mask is corrupted (exceeds 256) */
-}
-
-
-/*
- * Parses an HTTP date in one of three standard forms:
- *
- * Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
- * Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
- * Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format
- *
- * and returns the time_t number of seconds since 1 Jan 1970 GMT, or
- * 0 if this would be out of range or if the date is invalid.
- *
- * The restricted HTTP syntax is
- *
- * HTTP-date = rfc1123-date | rfc850-date | asctime-date
- *
- * rfc1123-date = wkday "," SP date1 SP time SP "GMT"
- * rfc850-date = weekday "," SP date2 SP time SP "GMT"
- * asctime-date = wkday SP date3 SP time SP 4DIGIT
- *
- * date1 = 2DIGIT SP month SP 4DIGIT
- * ; day month year (e.g., 02 Jun 1982)
- * date2 = 2DIGIT "-" month "-" 2DIGIT
- * ; day-month-year (e.g., 02-Jun-82)
- * date3 = month SP ( 2DIGIT | ( SP 1DIGIT ))
- * ; month day (e.g., Jun 2)
- *
- * time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
- * ; 00:00:00 - 23:59:59
- *
- * wkday = "Mon" | "Tue" | "Wed"
- * | "Thu" | "Fri" | "Sat" | "Sun"
- *
- * weekday = "Monday" | "Tuesday" | "Wednesday"
- * | "Thursday" | "Friday" | "Saturday" | "Sunday"
- *
- * month = "Jan" | "Feb" | "Mar" | "Apr"
- * | "May" | "Jun" | "Jul" | "Aug"
- * | "Sep" | "Oct" | "Nov" | "Dec"
- *
- * However, for the sake of robustness (and Netscapeness), we ignore the
- * weekday and anything after the time field (including the timezone).
- *
- * This routine is intended to be very fast; 10x faster than using sscanf.
- *
- * Originally from Andrew Daviel <andrew@vancouver-webpages.com>, 29 Jul 96
- * but many changes since then.
- *
- */
-API_EXPORT(ap_time_t) ap_parseHTTPdate(const char *date)
-{
- ap_exploded_time_t ds;
- ap_time_t result;
- int mint, mon;
- const char *monstr, *timstr;
- static const int months[12] =
- {
- ('J' << 16) | ('a' << 8) | 'n', ('F' << 16) | ('e' << 8) | 'b',
- ('M' << 16) | ('a' << 8) | 'r', ('A' << 16) | ('p' << 8) | 'r',
- ('M' << 16) | ('a' << 8) | 'y', ('J' << 16) | ('u' << 8) | 'n',
- ('J' << 16) | ('u' << 8) | 'l', ('A' << 16) | ('u' << 8) | 'g',
- ('S' << 16) | ('e' << 8) | 'p', ('O' << 16) | ('c' << 8) | 't',
- ('N' << 16) | ('o' << 8) | 'v', ('D' << 16) | ('e' << 8) | 'c'};
-
- if (!date)
- return BAD_DATE;
-
- while (*date && ap_isspace(*date)) /* Find first non-whitespace char */
- ++date;
-
- if (*date == '\0')
- return BAD_DATE;
-
- if ((date = strchr(date, ' ')) == NULL) /* Find space after weekday */
- return BAD_DATE;
-
- ++date; /* Now pointing to first char after space, which should be */
- /* start of the actual date information for all 3 formats. */
-
- if (ap_checkmask(date, "## @$$ #### ##:##:## *")) { /* RFC 1123 format */
- ds.tm_year = ((date[7] - '0') * 10 + (date[8] - '0') - 19) * 100;
- if (ds.tm_year < 0)
- return BAD_DATE;
-
- ds.tm_year += ((date[9] - '0') * 10) + (date[10] - '0');
-
- ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0');
-
- monstr = date + 3;
- timstr = date + 12;
- }
- else if (ap_checkmask(date, "##-@$$-## ##:##:## *")) { /* RFC 850 format */
- ds.tm_year = ((date[7] - '0') * 10) + (date[8] - '0');
- if (ds.tm_year < 70)
- ds.tm_year += 100;
-
- ds.tm_mday = ((date[0] - '0') * 10) + (date[1] - '0');
-
- monstr = date + 3;
- timstr = date + 10;
- }
- else if (ap_checkmask(date, "@$$ ~# ##:##:## ####*")) { /* asctime format */
- ds.tm_year = ((date[16] - '0') * 10 + (date[17] - '0') - 19) * 100;
- if (ds.tm_year < 0)
- return BAD_DATE;
-
- ds.tm_year += ((date[18] - '0') * 10) + (date[19] - '0');
-
- if (date[4] == ' ')
- ds.tm_mday = 0;
- else
- ds.tm_mday = (date[4] - '0') * 10;
-
- ds.tm_mday += (date[5] - '0');
-
- monstr = date;
- timstr = date + 7;
- }
- else
- return BAD_DATE;
-
- if (ds.tm_mday <= 0 || ds.tm_mday > 31)
- return BAD_DATE;
-
- ds.tm_hour = ((timstr[0] - '0') * 10) + (timstr[1] - '0');
- ds.tm_min = ((timstr[3] - '0') * 10) + (timstr[4] - '0');
- ds.tm_sec = ((timstr[6] - '0') * 10) + (timstr[7] - '0');
-
- if ((ds.tm_hour > 23) || (ds.tm_min > 59) || (ds.tm_sec > 61))
- return BAD_DATE;
-
- mint = (monstr[0] << 16) | (monstr[1] << 8) | monstr[2];
- for (mon = 0; mon < 12; mon++)
- if (mint == months[mon])
- break;
- if (mon == 12)
- return BAD_DATE;
-
- if ((ds.tm_mday == 31) && (mon == 3 || mon == 5 || mon == 8 || mon == 10))
- return BAD_DATE;
-
- /* February gets special check for leapyear */
-
- if ((mon == 1) &&
- ((ds.tm_mday > 29)
- || ((ds.tm_mday == 29)
- && ((ds.tm_year & 3)
- || (((ds.tm_year % 100) == 0)
- && (((ds.tm_year % 400) != 100)))))))
- return BAD_DATE;
-
- ds.tm_mon = mon;
-
- if (ap_implode_time(&result, &ds) != APR_SUCCESS) {
- return BAD_DATE;
- }
- return result;
-}
diff --git a/server/util_md5.c b/server/util_md5.c
deleted file mode 100644
index 3b71c15ee9..0000000000
--- a/server/util_md5.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/************************************************************************
- * NCSA HTTPd Server
- * Software Development Group
- * National Center for Supercomputing Applications
- * University of Illinois at Urbana-Champaign
- * 605 E. Springfield, Champaign, IL 61820
- * httpd@ncsa.uiuc.edu
- *
- * Copyright (C) 1995, Board of Trustees of the University of Illinois
- *
- ************************************************************************
- *
- * md5.c: NCSA HTTPd code which uses the md5c.c RSA Code
- *
- * Original Code Copyright (C) 1994, Jeff Hostetler, Spyglass, Inc.
- * Portions of Content-MD5 code Copyright (C) 1993, 1994 by Carnegie Mellon
- * University (see Copyright below).
- * Portions of Content-MD5 code Copyright (C) 1991 Bell Communications
- * Research, Inc. (Bellcore) (see Copyright below).
- * Portions extracted from mpack, John G. Myers - jgm+@cmu.edu
- * Content-MD5 Code contributed by Martin Hamilton (martin@net.lut.ac.uk)
- *
- */
-
-
-
-/* md5.c --Module Interface to MD5. */
-/* Jeff Hostetler, Spyglass, Inc., 1994. */
-
-#include "ap_config.h"
-#include "apr_portable.h"
-#include "httpd.h"
-#include "util_md5.h"
-
-API_EXPORT(char *) ap_md5_binary(ap_context_t *p, const unsigned char *buf, int length)
-{
- const char *hex = "0123456789abcdef";
- AP_MD5_CTX my_md5;
- unsigned char hash[16];
- char *r, result[33];
- int i;
-
- /*
- * Take the MD5 hash of the string argument.
- */
-
- ap_MD5Init(&my_md5);
- ap_MD5Update(&my_md5, buf, (unsigned int)length);
- ap_MD5Final(hash, &my_md5);
-
- for (i = 0, r = result; i < 16; i++) {
- *r++ = hex[hash[i] >> 4];
- *r++ = hex[hash[i] & 0xF];
- }
- *r = '\0';
-
- return ap_pstrdup(p, result);
-}
-
-API_EXPORT(char *) ap_md5(ap_context_t *p, const unsigned char *string)
-{
- return ap_md5_binary(p, string, (int) strlen((char *)string));
-}
-
-/* these portions extracted from mpack, John G. Myers - jgm+@cmu.edu */
-
-/* (C) Copyright 1993,1994 by Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of Carnegie
- * Mellon University not be used in advertising or publicity
- * pertaining to distribution of the software without specific,
- * written prior permission. Carnegie Mellon University makes no
- * representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied
- * warranty.
- *
- * CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
- * FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
- * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-/*
- * Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
- *
- * Permission to use, copy, modify, and distribute this material
- * for any purpose and without fee is hereby granted, provided
- * that the above copyright notice and this permission notice
- * appear in all copies, and that the name of Bellcore not be
- * used in advertising or publicity pertaining to this
- * material without the specific, prior written permission
- * of an authorized representative of Bellcore. BELLCORE
- * MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
- * OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
- * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
- */
-
-static char basis_64[] =
-"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-API_EXPORT(char *) ap_md5contextTo64(ap_context_t *a, AP_MD5_CTX * context)
-{
- unsigned char digest[18];
- char *encodedDigest;
- int i;
- char *p;
-
- encodedDigest = (char *) ap_pcalloc(a, 25 * sizeof(char));
-
- ap_MD5Final(digest, context);
- digest[sizeof(digest) - 1] = digest[sizeof(digest) - 2] = 0;
-
- p = encodedDigest;
- for (i = 0; i < sizeof(digest); i += 3) {
- *p++ = basis_64[digest[i] >> 2];
- *p++ = basis_64[((digest[i] & 0x3) << 4) | ((int) (digest[i + 1] & 0xF0) >> 4)];
- *p++ = basis_64[((digest[i + 1] & 0xF) << 2) | ((int) (digest[i + 2] & 0xC0) >> 6)];
- *p++ = basis_64[digest[i + 2] & 0x3F];
- }
- *p-- = '\0';
- *p-- = '=';
- *p-- = '=';
- return encodedDigest;
-}
-
-#ifdef CHARSET_EBCDIC
-
-API_EXPORT(char *) ap_md5digest(ap_context_t *p, ap_file_t *infile, int convert)
-{
- AP_MD5_CTX context;
- unsigned char buf[1000];
- long length = 0;
- int nbytes;
-
- ap_MD5Init(&context);
- nbytes = sizeof(buf);
- while (ap_read(infile, buf, &nbytes) == APR_SUCCESS) {
- length += nbytes;
- if (!convert) {
- ascii2ebcdic(buf, buf, nbytes);
- }
- ap_MD5Update(&context, buf, nbytes);
- }
- ap_seek(infile, 0L, APR_SET);
- return ap_md5contextTo64(p, &context);
-}
-
-#else
-
-API_EXPORT(char *) ap_md5digest(ap_context_t *p, ap_file_t *infile)
-{
- AP_MD5_CTX context;
- unsigned char buf[1000];
- long length = 0;
- ap_ssize_t nbytes;
-
- ap_MD5Init(&context);
- nbytes = sizeof(buf);
- while (ap_read(infile, buf, &nbytes) == APR_SUCCESS) {
- length += nbytes;
- ap_MD5Update(&context, buf, nbytes);
- }
- ap_seek(infile, 0L, APR_SET);
- return ap_md5contextTo64(p, &context);
-}
-
-#endif
diff --git a/server/util_script.c b/server/util_script.c
deleted file mode 100644
index f5c1fc1e2c..0000000000
--- a/server/util_script.c
+++ /dev/null
@@ -1,685 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-#define CORE_PRIVATE
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_main.h"
-#include "http_log.h"
-#include "http_core.h"
-#include "http_protocol.h"
-#include "http_request.h" /* for sub_req_lookup_uri() */
-#include "util_script.h"
-#include "util_date.h" /* For parseHTTPdate() */
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef OS2
-#define INCL_DOS
-#include <os2.h>
-#endif
-
-/*
- * Various utility functions which are common to a whole lot of
- * script-type extensions mechanisms, and might as well be gathered
- * in one place (if only to avoid creating inter-module dependancies
- * where there don't have to be).
- */
-
-#define MALFORMED_MESSAGE "malformed header from script. Bad header="
-#define MALFORMED_HEADER_LENGTH_TO_SHOW 30
-
-#if defined(OS2) || defined(WIN32)
-/* If a request includes query info in the URL (stuff after "?"), and
- * the query info does not contain "=" (indicative of a FORM submission),
- * then this routine is called to create the argument list to be passed
- * to the CGI script. When suexec is enabled, the suexec path, user, and
- * group are the first three arguments to be passed; if not, all three
- * must be NULL. The query info is split into separate arguments, where
- * "+" is the separator between keyword arguments.
- *
- * XXXX: note that the WIN32 code uses one of the suexec strings
- * to pass an interpreter name. Remember this if changing the way they
- * are handled in create_argv.
- *
- */
-static char **create_argv(ap_context_t *p, char *path, char *user, char *group,
- char *av0, const char *args)
-{
- int x, numwords;
- char **av;
- char *w;
- int idx = 0;
-
- /* count the number of keywords */
-
- for (x = 0, numwords = 1; args[x]; x++) {
- if (args[x] == '+') {
- ++numwords;
- }
- }
-
- if (numwords > APACHE_ARG_MAX - 5) {
- numwords = APACHE_ARG_MAX - 5; /* Truncate args to prevent overrun */
- }
- av = (char **) ap_palloc(p, (numwords + 5) * sizeof(char *));
-
- if (path) {
- av[idx++] = path;
- }
- if (user) {
- av[idx++] = user;
- }
- if (group) {
- av[idx++] = group;
- }
-
- av[idx++] = av0;
-
- for (x = 1; x <= numwords; x++) {
- w = ap_getword_nulls(p, &args, '+');
- ap_unescape_url(w);
- av[idx++] = ap_escape_shell_cmd(p, w);
- }
- av[idx] = NULL;
- return av;
-}
-#endif /* defined(OS2) || defined(WIN32) */
-
-static char *http2env(ap_context_t *a, char *w)
-{
- char *res = ap_pstrcat(a, "HTTP_", w, NULL);
- char *cp = res;
-
- while (*++cp) {
- if (!ap_isalnum(*cp) && *cp != '_') {
- *cp = '_';
- }
- else {
- *cp = ap_toupper(*cp);
- }
- }
-
- return res;
-}
-
-API_EXPORT(char **) ap_create_environment(ap_context_t *p, ap_table_t *t)
-{
- ap_array_header_t *env_arr = ap_table_elts(t);
- ap_table_entry_t *elts = (ap_table_entry_t *) env_arr->elts;
- char **env = (char **) ap_palloc(p, (env_arr->nelts + 2) * sizeof(char *));
- int i, j;
- char *tz;
- char *whack;
-
- j = 0;
- if (!ap_table_get(t, "TZ")) {
- tz = getenv("TZ");
- if (tz != NULL) {
- env[j++] = ap_pstrcat(p, "TZ=", tz, NULL);
- }
- }
- for (i = 0; i < env_arr->nelts; ++i) {
- if (!elts[i].key) {
- continue;
- }
- env[j] = ap_pstrcat(p, elts[i].key, "=", elts[i].val, NULL);
- whack = env[j];
- if (ap_isdigit(*whack)) {
- *whack++ = '_';
- }
- while (*whack != '=') {
- if (!ap_isalnum(*whack) && *whack != '_') {
- *whack = '_';
- }
- ++whack;
- }
- ++j;
- }
-
- env[j] = NULL;
- return env;
-}
-
-API_EXPORT(void) ap_add_common_vars(request_rec *r)
-{
- ap_table_t *e;
- server_rec *s = r->server;
- conn_rec *c = r->connection;
- const char *rem_logname;
- char *env_path;
-#ifdef WIN32
- char *env_temp;
-#endif
- const char *host;
- ap_array_header_t *hdrs_arr = ap_table_elts(r->headers_in);
- ap_table_entry_t *hdrs = (ap_table_entry_t *) hdrs_arr->elts;
- int i;
-
- /* use a temporary ap_table_t which we'll overlap onto
- * r->subprocess_env later
- */
- e = ap_make_table(r->pool, 25 + hdrs_arr->nelts);
-
- /* First, add environment vars from headers... this is as per
- * CGI specs, though other sorts of scripting interfaces see
- * the same vars...
- */
-
- for (i = 0; i < hdrs_arr->nelts; ++i) {
- if (!hdrs[i].key) {
- continue;
- }
-
- /* A few headers are special cased --- Authorization to prevent
- * rogue scripts from capturing passwords; content-type and -length
- * for no particular reason.
- */
-
- if (!strcasecmp(hdrs[i].key, "Content-type")) {
- ap_table_addn(e, "CONTENT_TYPE", hdrs[i].val);
- }
- else if (!strcasecmp(hdrs[i].key, "Content-length")) {
- ap_table_addn(e, "CONTENT_LENGTH", hdrs[i].val);
- }
- /*
- * You really don't want to disable this check, since it leaves you
- * wide open to CGIs stealing passwords and people viewing them
- * in the environment with "ps -e". But, if you must...
- */
-#ifndef SECURITY_HOLE_PASS_AUTHORIZATION
- else if (!strcasecmp(hdrs[i].key, "Authorization")
- || !strcasecmp(hdrs[i].key, "Proxy-Authorization")) {
- continue;
- }
-#endif
- else {
- ap_table_addn(e, http2env(r->pool, hdrs[i].key), hdrs[i].val);
- }
- }
-
- if (!(env_path = getenv("PATH"))) {
- env_path = DEFAULT_PATH;
- }
-
-#ifdef WIN32
- if (env_temp = getenv("SystemRoot")) {
- ap_table_addn(e, "SystemRoot", env_temp);
- }
- if (env_temp = getenv("COMSPEC")) {
- ap_table_addn(e, "COMSPEC", env_temp);
- }
- if (env_temp = getenv("WINDIR")) {
- ap_table_addn(e, "WINDIR", env_temp);
- }
-#endif
-
- ap_table_addn(e, "PATH", env_path);
- ap_table_addn(e, "SERVER_SIGNATURE", ap_psignature("", r));
- ap_table_addn(e, "SERVER_SOFTWARE", ap_get_server_version());
- ap_table_addn(e, "SERVER_NAME", ap_get_server_name(r));
- ap_table_addn(e, "SERVER_ADDR", r->connection->local_ip); /* Apache */
- ap_table_addn(e, "SERVER_PORT",
- ap_psprintf(r->pool, "%u", ap_get_server_port(r)));
- host = ap_get_remote_host(c, r->per_dir_config, REMOTE_HOST);
- if (host) {
- ap_table_addn(e, "REMOTE_HOST", host);
- }
- ap_table_addn(e, "REMOTE_ADDR", c->remote_ip);
- ap_table_addn(e, "DOCUMENT_ROOT", ap_document_root(r)); /* Apache */
- ap_table_addn(e, "SERVER_ADMIN", s->server_admin); /* Apache */
- ap_table_addn(e, "SCRIPT_FILENAME", r->filename); /* Apache */
-
- ap_table_addn(e, "REMOTE_PORT",
- ap_psprintf(r->pool, "%d", ntohs(c->remote_addr.sin_port)));
-
- if (r->user) {
- ap_table_addn(e, "REMOTE_USER", r->user);
- }
- if (r->ap_auth_type) {
- ap_table_addn(e, "AUTH_TYPE", r->ap_auth_type);
- }
- rem_logname = ap_get_remote_logname(r);
- if (rem_logname) {
- ap_table_addn(e, "REMOTE_IDENT", ap_pstrdup(r->pool, rem_logname));
- }
-
- /* Apache custom error responses. If we have redirected set two new vars */
-
- if (r->prev) {
- if (r->prev->args) {
- ap_table_addn(e, "REDIRECT_QUERY_STRING", r->prev->args);
- }
- if (r->prev->uri) {
- ap_table_addn(e, "REDIRECT_URL", r->prev->uri);
- }
- }
-
- ap_overlap_tables(r->subprocess_env, e, AP_OVERLAP_TABLES_SET);
-}
-
-/* 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.
- */
-
-API_EXPORT(int) ap_find_path_info(const char *uri, const char *path_info)
-{
- int lu = strlen(uri);
- int lp = strlen(path_info);
-
- while (lu-- && lp-- && uri[lu] == path_info[lp]);
-
- if (lu == -1) {
- lu = 0;
- }
-
- while (uri[lu] != '\0' && uri[lu] != '/') {
- lu++;
- }
- return lu;
-}
-
-/* Obtain the Request-URI from the original request-line, returning
- * a new string from the request pool containing the URI or "".
- */
-static char *original_uri(request_rec *r)
-{
- char *first, *last;
-
- if (r->the_request == NULL) {
- return (char *) ap_pcalloc(r->pool, 1);
- }
-
- first = r->the_request; /* use the request-line */
-
- while (*first && !ap_isspace(*first)) {
- ++first; /* skip over the method */
- }
- while (ap_isspace(*first)) {
- ++first; /* and the space(s) */
- }
-
- last = first;
- while (*last && !ap_isspace(*last)) {
- ++last; /* end at next whitespace */
- }
-
- return ap_pstrndup(r->pool, first, last - first);
-}
-
-API_EXPORT(void) ap_add_cgi_vars(request_rec *r)
-{
- ap_table_t *e = r->subprocess_env;
-
- ap_table_setn(e, "GATEWAY_INTERFACE", "CGI/1.1");
- ap_table_setn(e, "SERVER_PROTOCOL", r->protocol);
- ap_table_setn(e, "REQUEST_METHOD", r->method);
- ap_table_setn(e, "QUERY_STRING", r->args ? r->args : "");
- ap_table_setn(e, "REQUEST_URI", original_uri(r));
-
- /* Note that the code below special-cases scripts run from includes,
- * because it "knows" that the sub_request has been hacked to have the
- * args and path_info of the original request, and not any that may have
- * come with the script URI in the include command. Ugh.
- */
-
- if (!strcmp(r->protocol, "INCLUDED")) {
- ap_table_setn(e, "SCRIPT_NAME", r->uri);
- if (r->path_info && *r->path_info) {
- ap_table_setn(e, "PATH_INFO", r->path_info);
- }
- }
- else if (!r->path_info || !*r->path_info) {
- ap_table_setn(e, "SCRIPT_NAME", r->uri);
- }
- else {
- int path_info_start = ap_find_path_info(r->uri, r->path_info);
-
- ap_table_setn(e, "SCRIPT_NAME",
- ap_pstrndup(r->pool, r->uri, path_info_start));
-
- ap_table_setn(e, "PATH_INFO", r->path_info);
- }
-
- if (r->path_info && r->path_info[0]) {
- /*
- * To get PATH_TRANSLATED, treat PATH_INFO as a URI path.
- * Need to re-escape it for this, since the entire URI was
- * un-escaped before we determined where the PATH_INFO began.
- */
- request_rec *pa_req;
-
- pa_req = ap_sub_req_lookup_uri(ap_escape_uri(r->pool, r->path_info), r);
-
- if (pa_req->filename) {
-#ifdef WIN32
- char buffer[HUGE_STRING_LEN];
-#endif
- char *pt = ap_pstrcat(r->pool, pa_req->filename, pa_req->path_info,
- NULL);
-#ifdef WIN32
- /* We need to make this a real Windows path name */
- GetFullPathName(pt, HUGE_STRING_LEN, buffer, NULL);
- ap_table_setn(e, "PATH_TRANSLATED", ap_pstrdup(r->pool, buffer));
-#else
- ap_table_setn(e, "PATH_TRANSLATED", pt);
-#endif
- }
- ap_destroy_sub_req(pa_req);
- }
-}
-
-
-static int set_cookie_doo_doo(void *v, const char *key, const char *val)
-{
- ap_table_addn(v, key, val);
- return 1;
-}
-
-API_EXPORT(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
- int (*getsfunc) (char *, int, void *),
- void *getsfunc_data)
-{
- char x[MAX_STRING_LEN];
- char *w, *l;
- int p;
- int cgi_status = HTTP_OK;
- ap_table_t *merge;
- ap_table_t *cookie_table;
-
- if (buffer) {
- *buffer = '\0';
- }
- w = buffer ? buffer : x;
-
- /* temporary place to hold headers to merge in later */
- merge = ap_make_table(r->pool, 10);
-
- /* The HTTP specification says that it is legal to merge duplicate
- * headers into one. Some browsers that support Cookies don't like
- * merged headers and prefer that each Set-Cookie header is sent
- * separately. Lets humour those browsers by not merging.
- * Oh what a pain it is.
- */
- cookie_table = ap_make_table(r->pool, 2);
- ap_table_do(set_cookie_doo_doo, cookie_table, r->err_headers_out, "Set-Cookie", NULL);
-
- while (1) {
-
- if ((*getsfunc) (w, MAX_STRING_LEN - 1, getsfunc_data) == 0) {
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Premature end of script headers: %s", r->filename);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- /* Delete terminal (CR?)LF */
-
- p = strlen(w);
- if (p > 0 && w[p - 1] == '\n') {
- if (p > 1 && w[p - 2] == '\015') {
- w[p - 2] = '\0';
- }
- else {
- w[p - 1] = '\0';
- }
- }
-
- /*
- * If we've finished reading the headers, check to make sure any
- * HTTP/1.1 conditions are met. If so, we're done; normal processing
- * will handle the script's output. If not, just return the error.
- * The appropriate thing to do would be to send the script process a
- * SIGPIPE to let it know we're ignoring it, close the channel to the
- * script process, and *then* return the failed-to-meet-condition
- * error. Otherwise we'd be waiting for the script to finish
- * blithering before telling the client the output was no good.
- * However, we don't have the information to do that, so we have to
- * leave it to an upper layer.
- */
- if (w[0] == '\0') {
- int cond_status = OK;
-
- if ((cgi_status == HTTP_OK) && (r->method_number == M_GET)) {
- cond_status = ap_meets_conditions(r);
- }
- ap_overlap_tables(r->err_headers_out, merge,
- AP_OVERLAP_TABLES_MERGE);
- if (!ap_is_empty_table(cookie_table)) {
- /* the cookies have already been copied to the cookie_table */
- ap_table_unset(r->err_headers_out, "Set-Cookie");
- r->err_headers_out = ap_overlay_tables(r->pool,
- r->err_headers_out, cookie_table);
- }
- return cond_status;
- }
-
- /* if we see a bogus header don't ignore it. Shout and scream */
-
-#ifdef CHARSET_EBCDIC
- /* Chances are that we received an ASCII header text instead of
- * the expected EBCDIC header lines. Try to auto-detect:
- */
- if (!(l = strchr(w, ':'))) {
- int maybeASCII = 0, maybeEBCDIC = 0;
- char *cp;
-
- for (cp = w; *cp != '\0'; ++cp) {
- if (isprint(*cp) && !isprint(os_toebcdic[*cp]))
- ++maybeEBCDIC;
- if (!isprint(*cp) && isprint(os_toebcdic[*cp]))
- ++maybeASCII;
- }
- if (maybeASCII > maybeEBCDIC) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r->server,
- "CGI Interface Error: Script headers apparently ASCII: (CGI = %s)", r->filename);
- ascii2ebcdic(w, w, cp - w);
- }
- }
-#endif
- if (!(l = strchr(w, ':'))) {
- char malformed[(sizeof MALFORMED_MESSAGE) + 1
- + MALFORMED_HEADER_LENGTH_TO_SHOW];
-
- strcpy(malformed, MALFORMED_MESSAGE);
- strncat(malformed, w, MALFORMED_HEADER_LENGTH_TO_SHOW);
-
- if (!buffer) {
- /* Soak up all the script output - may save an outright kill */
- while ((*getsfunc) (w, MAX_STRING_LEN - 1, getsfunc_data)) {
- continue;
- }
- }
-
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "%s: %s", malformed, r->filename);
- return HTTP_INTERNAL_SERVER_ERROR;
- }
-
- *l++ = '\0';
- while (*l && ap_isspace(*l)) {
- ++l;
- }
-
- if (!strcasecmp(w, "Content-type")) {
- char *tmp;
-
- /* Nuke trailing whitespace */
-
- char *endp = l + strlen(l) - 1;
- while (endp > l && ap_isspace(*endp)) {
- *endp-- = '\0';
- }
-
- tmp = ap_pstrdup(r->pool, l);
- ap_content_type_tolower(tmp);
- r->content_type = tmp;
- }
- /*
- * If the script returned a specific status, that's what
- * we'll use - otherwise we assume 200 OK.
- */
- else if (!strcasecmp(w, "Status")) {
- r->status = cgi_status = atoi(l);
- r->status_line = ap_pstrdup(r->pool, l);
- }
- else if (!strcasecmp(w, "Location")) {
- ap_table_set(r->headers_out, w, l);
- }
- else if (!strcasecmp(w, "Content-Length")) {
- ap_table_set(r->headers_out, w, l);
- }
- else if (!strcasecmp(w, "Transfer-Encoding")) {
- ap_table_set(r->headers_out, w, l);
- }
- /*
- * If the script gave us a Last-Modified header, we can't just
- * pass it on blindly because of restrictions on future values.
- */
- else if (!strcasecmp(w, "Last-Modified")) {
- ap_update_mtime(r, ap_parseHTTPdate(l));
- ap_set_last_modified(r);
- }
- else if (!strcasecmp(w, "Set-Cookie")) {
- ap_table_add(cookie_table, w, l);
- }
- else {
- ap_table_add(merge, w, l);
- }
- }
-}
-
-static int getsfunc_FILE(char *buf, int len, void *f)
-{
- return ap_fgets(buf, len, (ap_file_t *) f) == APR_SUCCESS;
-}
-
-API_EXPORT(int) ap_scan_script_header_err(request_rec *r, ap_file_t *f,
- char *buffer)
-{
- return ap_scan_script_header_err_core(r, buffer, getsfunc_FILE, f);
-}
-
-static int getsfunc_BUFF(char *w, int len, void *fb)
-{
- return ap_bgets(w, len, (BUFF *) fb) > 0;
-}
-
-API_EXPORT(int) ap_scan_script_header_err_buff(request_rec *r, BUFF *fb,
- char *buffer)
-{
- return ap_scan_script_header_err_core(r, buffer, getsfunc_BUFF, fb);
-}
-
-
-API_EXPORT(void) ap_send_size(ap_ssize_t size, request_rec *r)
-{
- /* XXX: this -1 thing is a gross hack */
- if (size == (ap_ssize_t)-1) {
- ap_rputs(" -", r);
- }
- else if (!size) {
- ap_rputs(" 0k", r);
- }
- else if (size < 1024) {
- ap_rputs(" 1k", r);
- }
- else if (size < 1048576) {
- ap_rprintf(r, "%4" APR_SSIZE_T_FMT "k", (size + 512) / 1024);
- }
- else if (size < 103809024) {
- ap_rprintf(r, "%4.1fM", size / 1048576.0);
- }
- else {
- ap_rprintf(r, "%4" APR_SSIZE_T_FMT "M", (size + 524288) / 1048576);
- }
-}
-
-#if defined(OS2) || defined(WIN32)
-static char **create_argv_cmd(ap_context_t *p, char *av0, const char *args, char *path)
-{
- register int x, n;
- char **av;
- char *w;
-
- for (x = 0, n = 2; args[x]; x++) {
- if (args[x] == '+') {
- ++n;
- }
- }
-
- /* Add extra strings to array. */
- n = n + 2;
-
- av = (char **) ap_palloc(p, (n + 1) * sizeof(char *));
- av[0] = av0;
-
- /* Now insert the extra strings we made room for above. */
- av[1] = strdup("/C");
- av[2] = strdup(path);
-
- for (x = (1 + 2); x < n; x++) {
- w = ap_getword(p, &args, '+');
- ap_unescape_url(w);
- av[x] = ap_escape_shell_cmd(p, w);
- }
- av[n] = NULL;
- return av;
-}
-#endif
-
diff --git a/server/util_uri.c b/server/util_uri.c
deleted file mode 100644
index 0e5102955e..0000000000
--- a/server/util_uri.c
+++ /dev/null
@@ -1,600 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * util_uri.c: URI related utility things
- *
- */
-
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_log.h"
-#include "util_uri.h"
-#include <string.h>
-
-/* Some WWW schemes and their default ports; this is basically /etc/services */
-/* This will become global when the protocol abstraction comes */
-/* As the schemes are searched by a linear search, */
-/* they are sorted by their expected frequency */
-static schemes_t schemes[] =
-{
- {"http", DEFAULT_HTTP_PORT},
- {"ftp", DEFAULT_FTP_PORT},
- {"https", DEFAULT_HTTPS_PORT},
- {"gopher", DEFAULT_GOPHER_PORT},
- {"wais", DEFAULT_WAIS_PORT},
- {"nntp", DEFAULT_NNTP_PORT},
- {"snews", DEFAULT_SNEWS_PORT},
- {"prospero", DEFAULT_PROSPERO_PORT},
- { NULL, 0xFFFF } /* unknown port */
-};
-
-
-API_EXPORT(unsigned short) ap_default_port_for_scheme(const char *scheme_str)
-{
- schemes_t *scheme;
-
- for (scheme = schemes; scheme->name != NULL; ++scheme)
- if (strcasecmp(scheme_str, scheme->name) == 0)
- return scheme->default_port;
-
- return 0;
-}
-
-API_EXPORT(unsigned short) ap_default_port_for_request(const request_rec *r)
-{
- return (r->parsed_uri.scheme)
- ? ap_default_port_for_scheme(r->parsed_uri.scheme)
- : 0;
-}
-
-/* Create a copy of a "struct hostent" record; it was presumably returned
- * from a call to gethostbyname() and lives in static storage.
- * By creating a copy we can tuck it away for later use.
- */
-API_EXPORT(struct hostent *) ap_pduphostent(ap_context_t *p, const struct hostent *hp)
-{
- struct hostent *newent;
- char **ptrs;
- char **aliases;
- struct in_addr *addrs;
- int i = 0, j = 0;
-
- if (hp == NULL)
- return NULL;
-
- /* Count number of alias entries */
- if (hp->h_aliases != NULL)
- for (; hp->h_aliases[j] != NULL; ++j)
- continue;
-
- /* Count number of in_addr entries */
- if (hp->h_addr_list != NULL)
- for (; hp->h_addr_list[i] != NULL; ++i)
- continue;
-
- /* Allocate hostent structure, alias ptrs, addr ptrs, addrs */
- newent = (struct hostent *) ap_palloc(p, sizeof(*hp));
- aliases = (char **) ap_palloc(p, (j+1) * sizeof(char*));
- ptrs = (char **) ap_palloc(p, (i+1) * sizeof(char*));
- addrs = (struct in_addr *) ap_palloc(p, (i+1) * sizeof(struct in_addr));
-
- *newent = *hp;
- newent->h_name = ap_pstrdup(p, hp->h_name);
- newent->h_aliases = aliases;
- newent->h_addr_list = (char**) ptrs;
-
- /* Copy Alias Names: */
- for (j = 0; hp->h_aliases[j] != NULL; ++j) {
- aliases[j] = ap_pstrdup(p, hp->h_aliases[j]);
- }
- aliases[j] = NULL;
-
- /* Copy address entries */
- for (i = 0; hp->h_addr_list[i] != NULL; ++i) {
- ptrs[i] = (char*) &addrs[i];
- addrs[i] = *(struct in_addr *) hp->h_addr_list[i];
- }
- ptrs[i] = NULL;
-
- return newent;
-}
-
-
-/* pgethostbyname(): resolve hostname, if successful return an ALLOCATED
- * COPY OF the hostent structure, intended to be stored and used later.
- * (gethostbyname() uses static storage that would be overwritten on each call)
- */
-API_EXPORT(struct hostent *) ap_pgethostbyname(ap_context_t *p, const char *hostname)
-{
- struct hostent *hp = gethostbyname(hostname);
- return (hp == NULL) ? NULL : ap_pduphostent(p, hp);
-}
-
-
-/* Unparse a uri_components structure to an URI string.
- * Optionally suppress the password for security reasons.
- */
-API_EXPORT(char *) ap_unparse_uri_components(ap_context_t *p, const uri_components *uptr, unsigned flags)
-{
- char *ret = "";
-
- /* If suppressing the site part, omit both user name & scheme://hostname */
- if (!(flags & UNP_OMITSITEPART)) {
-
- /* Construct a "user:password@" string, honoring the passed UNP_ flags: */
- if (uptr->user||uptr->password)
- ret = ap_pstrcat (p,
- (uptr->user && !(flags & UNP_OMITUSER)) ? uptr->user : "",
- (uptr->password && !(flags & UNP_OMITPASSWORD)) ? ":" : "",
- (uptr->password && !(flags & UNP_OMITPASSWORD))
- ? ((flags & UNP_REVEALPASSWORD) ? uptr->password : "XXXXXXXX")
- : "",
- "@", NULL);
-
- /* Construct scheme://site string */
- if (uptr->hostname) {
- int is_default_port;
-
- is_default_port =
- (uptr->port_str == NULL ||
- uptr->port == 0 ||
- uptr->port == ap_default_port_for_scheme(uptr->scheme));
-
- ret = ap_pstrcat (p,
- uptr->scheme, "://", ret,
- uptr->hostname ? uptr->hostname : "",
- is_default_port ? "" : ":",
- is_default_port ? "" : uptr->port_str,
- NULL);
- }
- }
-
- /* Should we suppress all path info? */
- if (!(flags & UNP_OMITPATHINFO)) {
- /* Append path, query and fragment strings: */
- ret = ap_pstrcat (p,
- ret,
- uptr->path ? uptr->path : "",
- (uptr->query && !(flags & UNP_OMITQUERY)) ? "?" : "",
- (uptr->query && !(flags & UNP_OMITQUERY)) ? uptr->query : "",
- (uptr->fragment && !(flags & UNP_OMITQUERY)) ? "#" : NULL,
- (uptr->fragment && !(flags & UNP_OMITQUERY)) ? uptr->fragment : NULL,
- NULL);
- }
- return ret;
-}
-
-/* The regex version of parse_uri_components has the advantage that it is
- * relatively easy to understand and extend. But it has the disadvantage
- * that the regexes are complex enough that regex libraries really
- * don't do a great job with them performancewise.
- *
- * The default is a hand coded scanner that is two orders of magnitude
- * faster.
- */
-#ifdef UTIL_URI_REGEX
-
-static regex_t re_uri;
-static regex_t re_hostpart;
-
-void ap_util_uri_init(void)
-{
- int ret;
- const char *re_str;
-
- /* This is a modified version of the regex that appeared in
- * draft-fielding-uri-syntax-01. It doesnt allow the uri to contain a
- * scheme but no hostinfo or vice versa.
- *
- * draft-fielding-uri-syntax-01.txt, section 4.4 tells us:
- *
- * Although the BNF defines what is allowed in each component, it is
- * ambiguous in terms of differentiating between a site component and
- * a path component that begins with two slash characters.
- *
- * RFC2068 disambiguates this for the Request-URI, which may only ever be
- * the "abs_path" portion of the URI. So a request "GET //foo/bar
- * HTTP/1.1" is really referring to the path //foo/bar, not the host foo,
- * path /bar. Nowhere in RFC2068 is it possible to have a scheme but no
- * hostinfo or a hostinfo but no scheme. (Unless you're proxying a
- * protocol other than HTTP, but this parsing engine probably won't work
- * for other protocols.)
- *
- * 12 3 4 5 6 7 8 */
- re_str = "^(([^:/?#]+)://([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$";
- /* ^scheme--^ ^site---^ ^path--^ ^query^ ^frag */
- if ((ret = regcomp(&re_uri, re_str, REG_EXTENDED)) != 0) {
- char line[1024];
-
- /* Make a readable error message */
- ret = regerror(ret, &re_uri, line, sizeof line);
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, NULL,
- "Internal error: regcomp(\"%s\") returned non-zero (%s) - "
- "possibly due to broken regex lib! "
- "Did you define WANTHSREGEX=yes?",
- re_str, line);
-
- exit(1);
- }
-
- /* This is a sub-RE which will break down the hostinfo part,
- * i.e., user, password, hostname and port.
- * $ 12 3 4 5 6 7 */
- re_str = "^(([^:]*)(:(.*))?@)?([^@:]*)(:([0-9]*))?$";
- /* ^^user^ :pw ^host^ ^:[port]^ */
- if ((ret = regcomp(&re_hostpart, re_str, REG_EXTENDED)) != 0) {
- char line[1024];
-
- /* Make a readable error message */
- ret = regerror(ret, &re_hostpart, line, sizeof line);
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, NULL,
- "Internal error: regcomp(\"%s\") returned non-zero (%s) - "
- "possibly due to broken regex lib! "
- "Did you define WANTHSREGEX=yes?",
- re_str, line);
-
- exit(1);
- }
-}
-
-
-/* parse_uri_components():
- * Parse a given URI, fill in all supplied fields of a uri_components
- * structure. This eliminates the necessity of extracting host, port,
- * path, query info repeatedly in the modules.
- * Side effects:
- * - fills in fields of uri_components *uptr
- * - none on any of the r->* fields
- */
-API_EXPORT(int) ap_parse_uri_components(ap_context_t *p, const char *uri, uri_components *uptr)
-{
- int ret;
- regmatch_t match[10]; /* This must have at least as much elements
- * as there are braces in the re_strings */
-
- ap_assert (uptr != NULL);
-
- /* Initialize the structure. parse_uri() and parse_uri_components()
- * can be called more than once per request.
- */
- memset (uptr, '\0', sizeof(*uptr));
- uptr->is_initialized = 1;
-
- ret = ap_regexec(&re_uri, uri, re_uri.re_nsub + 1, match, 0);
-
- if (ret != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, NULL,
- "ap_regexec() could not parse uri (\"%s\")",
- uri);
-
- return HTTP_BAD_REQUEST;
- }
-
- if (match[2].rm_so != match[2].rm_eo)
- uptr->scheme = ap_pstrndup (p, uri+match[2].rm_so, match[2].rm_eo - match[2].rm_so);
-
- /* empty hostinfo is valid, that's why we test $1 but use $3 */
- if (match[1].rm_so != match[1].rm_eo)
- uptr->hostinfo = ap_pstrndup (p, uri+match[3].rm_so, match[3].rm_eo - match[3].rm_so);
-
- if (match[4].rm_so != match[4].rm_eo)
- uptr->path = ap_pstrndup (p, uri+match[4].rm_so, match[4].rm_eo - match[4].rm_so);
-
- /* empty query string is valid, that's why we test $5 but use $6 */
- if (match[5].rm_so != match[5].rm_eo)
- uptr->query = ap_pstrndup (p, uri+match[6].rm_so, match[6].rm_eo - match[6].rm_so);
-
- /* empty fragment is valid, test $7 use $8 */
- if (match[7].rm_so != match[7].rm_eo)
- uptr->fragment = ap_pstrndup (p, uri+match[8].rm_so, match[8].rm_eo - match[8].rm_so);
-
- if (uptr->hostinfo) {
- /* Parse the hostinfo part to extract user, password, host, and port */
- ret = ap_regexec(&re_hostpart, uptr->hostinfo, re_hostpart.re_nsub + 1, match, 0);
- if (ret != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, NULL,
- "ap_regexec() could not parse (\"%s\") as host part",
- uptr->hostinfo);
-
- return HTTP_BAD_REQUEST;
- }
-
- /* $ 12 3 4 5 6 7 */
- /* "^(([^:]*)(:(.*))?@)?([^@:]*)(:([0-9]*))?$" */
- /* ^^user^ :pw ^host^ ^:[port]^ */
-
- /* empty user is valid, that's why we test $1 but use $2 */
- if (match[1].rm_so != match[1].rm_eo)
- uptr->user = ap_pstrndup (p, uptr->hostinfo+match[2].rm_so, match[2].rm_eo - match[2].rm_so);
-
- /* empty password is valid, test $3 but use $4 */
- if (match[3].rm_so != match[3].rm_eo)
- uptr->password = ap_pstrndup (p, uptr->hostinfo+match[4].rm_so, match[4].rm_eo - match[4].rm_so);
-
- /* empty hostname is valid, and implied by the existence of hostinfo */
- uptr->hostname = ap_pstrndup (p, uptr->hostinfo+match[5].rm_so, match[5].rm_eo - match[5].rm_so);
-
- if (match[6].rm_so != match[6].rm_eo) {
- /* Note that the port string can be empty.
- * If it is, we use the default port associated with the scheme
- */
- uptr->port_str = ap_pstrndup (p, uptr->hostinfo+match[7].rm_so, match[7].rm_eo - match[7].rm_so);
- if (uptr->port_str[0] != '\0') {
- char *endstr;
- int port;
-
- port = strtol(uptr->port_str, &endstr, 10);
- uptr->port = port;
- if (*endstr != '\0') {
- /* Invalid characters after ':' found */
- return HTTP_BAD_REQUEST;
- }
- }
- else {
- uptr->port = uptr->scheme ? ap_default_port_for_scheme(uptr->scheme) : DEFAULT_HTTP_PORT;
- }
- }
- }
-
- if (ret == 0)
- ret = HTTP_OK;
- return ret;
-}
-#else
-
-/* Here is the hand-optimized parse_uri_components(). There are some wild
- * tricks we could pull in assembly language that we don't pull here... like we
- * can do word-at-time scans for delimiter characters using the same technique
- * that fast memchr()s use. But that would be way non-portable. -djg
- */
-
-/* We have a ap_table_t that we can index by character and it tells us if the
- * character is one of the interesting delimiters. Note that we even get
- * compares for NUL for free -- it's just another delimiter.
- */
-
-#define T_COLON 0x01 /* ':' */
-#define T_SLASH 0x02 /* '/' */
-#define T_QUESTION 0x04 /* '?' */
-#define T_HASH 0x08 /* '#' */
-#define T_NUL 0x80 /* '\0' */
-
-/* the uri_delims.h file is autogenerated by gen_uri_delims.c */
-#include "uri_delims.h"
-
-/* it works like this:
- if (uri_delims[ch] & NOTEND_foobar) {
- then we're not at a delimiter for foobar
- }
-*/
-
-/* Note that we optimize the scheme scanning here, we cheat and let the
- * compiler know that it doesn't have to do the & masking.
- */
-#define NOTEND_SCHEME (0xff)
-#define NOTEND_HOSTINFO (T_SLASH | T_QUESTION | T_HASH | T_NUL)
-#define NOTEND_PATH (T_QUESTION | T_HASH | T_NUL)
-
-void ap_util_uri_init(void)
-{
- /* nothing to do */
-}
-
-/* parse_uri_components():
- * Parse a given URI, fill in all supplied fields of a uri_components
- * structure. This eliminates the necessity of extracting host, port,
- * path, query info repeatedly in the modules.
- * Side effects:
- * - fills in fields of uri_components *uptr
- * - none on any of the r->* fields
- */
-API_EXPORT(int) ap_parse_uri_components(ap_context_t *p, const char *uri, uri_components *uptr)
-{
- const char *s;
- const char *s1;
- const char *hostinfo;
- char *endstr;
- int port;
-
- /* Initialize the structure. parse_uri() and parse_uri_components()
- * can be called more than once per request.
- */
- memset (uptr, '\0', sizeof(*uptr));
- uptr->is_initialized = 1;
-
- /* We assume the processor has a branch predictor like most --
- * it assumes forward branches are untaken and backwards are taken. That's
- * the reason for the gotos. -djg
- */
- if (uri[0] == '/') {
-deal_with_path:
- /* we expect uri to point to first character of path ... remember
- * that the path could be empty -- http://foobar?query for example
- */
- s = uri;
- while ((uri_delims[*(unsigned char *)s] & NOTEND_PATH) == 0) {
- ++s;
- }
- if (s != uri) {
- uptr->path = ap_pstrndup(p, uri, s - uri);
- }
- if (*s == 0) {
- return HTTP_OK;
- }
- if (*s == '?') {
- ++s;
- s1 = strchr(s, '#');
- if (s1) {
- uptr->fragment = ap_pstrdup(p, s1 + 1);
- uptr->query = ap_pstrndup(p, s, s1 - s);
- }
- else {
- uptr->query = ap_pstrdup(p, s);
- }
- return HTTP_OK;
- }
- /* otherwise it's a fragment */
- uptr->fragment = ap_pstrdup(p, s + 1);
- return HTTP_OK;
- }
-
- /* find the scheme: */
- s = uri;
- while ((uri_delims[*(unsigned char *)s] & NOTEND_SCHEME) == 0) {
- ++s;
- }
- /* scheme must be non-empty and followed by :// */
- if (s == uri || s[0] != ':' || s[1] != '/' || s[2] != '/') {
- goto deal_with_path; /* backwards predicted taken! */
- }
-
- uptr->scheme = ap_pstrndup(p, uri, s - uri);
- s += 3;
- hostinfo = s;
- while ((uri_delims[*(unsigned char *)s] & NOTEND_HOSTINFO) == 0) {
- ++s;
- }
- uri = s; /* whatever follows hostinfo is start of uri */
- uptr->hostinfo = ap_pstrndup(p, hostinfo, uri - hostinfo);
-
- /* If there's a username:password@host:port, the @ we want is the last @...
- * too bad there's no memrchr()... For the C purists, note that hostinfo
- * is definately not the first character of the original uri so therefore
- * &hostinfo[-1] < &hostinfo[0] ... and this loop is valid C.
- */
- do {
- --s;
- } while (s >= hostinfo && *s != '@');
- if (s < hostinfo) {
- /* again we want the common case to be fall through */
-deal_with_host:
- /* We expect hostinfo to point to the first character of
- * the hostname. If there's a port it is the first colon.
- */
- s = memchr(hostinfo, ':', uri - hostinfo);
- if (s == NULL) {
- /* we expect the common case to have no port */
- uptr->hostname = ap_pstrndup(p, hostinfo, uri - hostinfo);
- goto deal_with_path;
- }
- uptr->hostname = ap_pstrndup(p, hostinfo, s - hostinfo);
- ++s;
- uptr->port_str = ap_pstrndup(p, s, uri - s);
- if (uri != s) {
- port = strtol(uptr->port_str, &endstr, 10);
- uptr->port = port;
- if (*endstr == '\0') {
- goto deal_with_path;
- }
- /* Invalid characters after ':' found */
- return HTTP_BAD_REQUEST;
- }
- uptr->port = ap_default_port_for_scheme(uptr->scheme);
- goto deal_with_path;
- }
-
- /* first colon delimits username:password */
- s1 = memchr(hostinfo, ':', s - hostinfo);
- if (s1) {
- uptr->user = ap_pstrndup(p, hostinfo, s1 - hostinfo);
- ++s1;
- uptr->password = ap_pstrndup(p, s1, s - s1);
- }
- else {
- uptr->user = ap_pstrndup(p, hostinfo, s - hostinfo);
- }
- hostinfo = s + 1;
- goto deal_with_host;
-}
-
-/* Special case for CONNECT parsing: it comes with the hostinfo part only */
-/* See the INTERNET-DRAFT document "Tunneling SSL Through a WWW Proxy"
- * currently at http://www.mcom.com/newsref/std/tunneling_ssl.html
- * for the format of the "CONNECT host:port HTTP/1.0" request
- */
-API_EXPORT(int) ap_parse_hostinfo_components(ap_context_t *p, const char *hostinfo, uri_components *uptr)
-{
- const char *s;
- char *endstr;
-
- /* Initialize the structure. parse_uri() and parse_uri_components()
- * can be called more than once per request.
- */
- memset (uptr, '\0', sizeof(*uptr));
- uptr->is_initialized = 1;
- uptr->hostinfo = ap_pstrdup(p, hostinfo);
-
- /* We expect hostinfo to point to the first character of
- * the hostname. There must be a port, separated by a colon
- */
- s = strchr(hostinfo, ':');
- if (s == NULL) {
- return HTTP_BAD_REQUEST;
- }
- uptr->hostname = ap_pstrndup(p, hostinfo, s - hostinfo);
- ++s;
- uptr->port_str = ap_pstrdup(p, s);
- if (*s != '\0') {
- uptr->port = strtol(uptr->port_str, &endstr, 10);
- if (*endstr == '\0') {
- return HTTP_OK;
- }
- /* Invalid characters after ':' found */
- }
- return HTTP_BAD_REQUEST;
-}
-#endif
diff --git a/server/vhost.c b/server/vhost.c
deleted file mode 100644
index 7b8574bd12..0000000000
--- a/server/vhost.c
+++ /dev/null
@@ -1,951 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * http_vhost.c: functions pertaining to virtual host addresses
- * (configuration and run-time)
- */
-
-#define CORE_PRIVATE
-#include "ap_config.h"
-#include "httpd.h"
-#include "http_config.h"
-#include "http_log.h"
-#include "http_vhost.h"
-#include "http_protocol.h"
-#include "http_core.h"
-
-/*
- * After all the definitions there's an explanation of how it's all put
- * together.
- */
-
-/* meta-list of name-vhosts. Each server_rec can be in possibly multiple
- * lists of name-vhosts.
- */
-typedef struct name_chain name_chain;
-struct name_chain {
- name_chain *next;
- server_addr_rec *sar; /* the record causing it to be in
- * this chain (needed for port comparisons) */
- server_rec *server; /* the server to use on a match */
-};
-
-/* meta-list of ip addresses. Each server_rec can be in possibly multiple
- * hash chains since it can have multiple ips.
- */
-typedef struct ipaddr_chain ipaddr_chain;
-struct ipaddr_chain {
- ipaddr_chain *next;
- server_addr_rec *sar; /* the record causing it to be in
- * this chain (need for both ip addr and port
- * comparisons) */
- server_rec *server; /* the server to use if this matches */
- name_chain *names; /* if non-NULL then a list of name-vhosts
- * sharing this address */
-};
-
-/* This defines the size of the hash ap_table_t used for hashing ip addresses
- * of virtual hosts. It must be a power of two.
- */
-#ifndef IPHASH_TABLE_SIZE
-#define IPHASH_TABLE_SIZE 256
-#endif
-
-/* A (n) bucket hash table, each entry has a pointer to a server rec and
- * a pointer to the other entries in that bucket. Each individual address,
- * even for virtualhosts with multiple addresses, has an entry in this hash
- * table. There are extra buckets for _default_, and name-vhost entries.
- *
- * Note that after config time this is constant, so it is thread-safe.
- */
-static ipaddr_chain *iphash_table[IPHASH_TABLE_SIZE];
-
-/* dump out statistics about the hash function */
-/* #define IPHASH_STATISTICS */
-
-/* list of the _default_ servers */
-static ipaddr_chain *default_list;
-
-/* list of the NameVirtualHost addresses */
-static server_addr_rec *name_vhost_list;
-static server_addr_rec **name_vhost_list_tail;
-
-/*
- * How it's used:
- *
- * The ip address determines which chain in iphash_table is interesting, then
- * a comparison is done down that chain to find the first ipaddr_chain whose
- * sar matches the address:port pair.
- *
- * If that ipaddr_chain has names == NULL then you're done, it's an ip-vhost.
- *
- * Otherwise it's a name-vhost list, and the default is the server in the
- * ipaddr_chain record. We tuck away the ipaddr_chain record in the
- * conn_rec field vhost_lookup_data. Later on after the headers we get a
- * second chance, and we use the name_chain to figure out what name-vhost
- * matches the headers.
- *
- * If there was no ip address match in the iphash_table then do a lookup
- * in the default_list.
- *
- * How it's put together ... well you should be able to figure that out
- * from how it's used. Or something like that.
- */
-
-
-/* called at the beginning of the config */
-void ap_init_vhost_config(ap_context_t *p)
-{
- memset(iphash_table, 0, sizeof(iphash_table));
- default_list = NULL;
- name_vhost_list = NULL;
- name_vhost_list_tail = &name_vhost_list;
-}
-
-
-/*
- * Parses a host of the form <address>[:port]
- * paddr is used to create a list in the order of input
- * **paddr is the ->next pointer of the last entry (or s->addrs)
- * *paddr is the variable used to keep track of **paddr between calls
- * port is the default port to assume
- */
-static const char *get_addresses(ap_context_t *p, char *w, server_addr_rec ***paddr,
- unsigned port)
-{
- struct hostent *hep;
- unsigned long my_addr;
- server_addr_rec *sar;
- char *t;
- int i, is_an_ip_addr;
-
- if (*w == 0)
- return NULL;
-
- t = strchr(w, ':');
- if (t) {
- if (strcmp(t + 1, "*") == 0) {
- port = 0;
- }
- else if ((i = atoi(t + 1))) {
- port = i;
- }
- else {
- return ":port must be numeric";
- }
- *t = 0;
- }
-
- is_an_ip_addr = 0;
- if (strcmp(w, "*") == 0) {
- my_addr = htonl(INADDR_ANY);
- is_an_ip_addr = 1;
- }
- else if (strcasecmp(w, "_default_") == 0
- || strcmp(w, "255.255.255.255") == 0) {
- my_addr = DEFAULT_VHOST_ADDR;
- is_an_ip_addr = 1;
- }
- else if ((my_addr = ap_inet_addr(w)) != INADDR_NONE) {
- is_an_ip_addr = 1;
- }
- if (is_an_ip_addr) {
- sar = ap_pcalloc(p, sizeof(server_addr_rec));
- **paddr = sar;
- *paddr = &sar->next;
- sar->host_addr.s_addr = my_addr;
- sar->host_port = port;
- sar->virthost = ap_pstrdup(p, w);
- if (t != NULL)
- *t = ':';
- return NULL;
- }
-
- hep = gethostbyname(w);
-
- if ((!hep) || (hep->h_addrtype != AF_INET || !hep->h_addr_list[0])) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, NULL,
- "Cannot resolve host name %s --- ignoring!", w);
- if (t != NULL)
- *t = ':';
- return NULL;
- }
-
- for (i = 0; hep->h_addr_list[i]; ++i) {
- sar = ap_pcalloc(p, sizeof(server_addr_rec));
- **paddr = sar;
- *paddr = &sar->next;
- sar->host_addr = *(struct in_addr *) hep->h_addr_list[i];
- sar->host_port = port;
- sar->virthost = ap_pstrdup(p, w);
- }
-
- if (t != NULL)
- *t = ':';
- return NULL;
-}
-
-
-/* parse the <VirtualHost> addresses */
-const char *ap_parse_vhost_addrs(ap_context_t *p, const char *hostname, server_rec *s)
-{
- server_addr_rec **addrs;
- const char *err;
-
- /* start the list of addreses */
- addrs = &s->addrs;
- while (hostname[0]) {
- err = get_addresses(p, ap_getword_conf(p, &hostname), &addrs, s->port);
- if (err) {
- *addrs = NULL;
- return err;
- }
- }
- /* terminate the list */
- *addrs = NULL;
- if (s->addrs) {
- if (s->addrs->host_port) {
- /* override the default port which is inherited from main_server */
- s->port = s->addrs->host_port;
- }
- }
- return NULL;
-}
-
-
-const char *ap_set_name_virtual_host (cmd_parms *cmd, void *dummy, char *arg)
-{
- /* use whatever port the main server has at this point */
- return get_addresses(cmd->pool, arg, &name_vhost_list_tail,
- cmd->server->port);
-}
-
-
-/* hash ap_table_t statistics, keep this in here for the beta period so
- * we can find out if the hash function is ok
- */
-#ifdef IPHASH_STATISTICS
-static int iphash_compare(const void *a, const void *b)
-{
- return (*(const int *) b - *(const int *) a);
-}
-
-
-static void dump_iphash_statistics(server_rec *main_s)
-{
- unsigned count[IPHASH_TABLE_SIZE];
- int i;
- ipaddr_chain *src;
- unsigned total;
- char buf[HUGE_STRING_LEN];
- char *p;
-
- total = 0;
- for (i = 0; i < IPHASH_TABLE_SIZE; ++i) {
- count[i] = 0;
- for (src = iphash_table[i]; src; src = src->next) {
- ++count[i];
- if (i < IPHASH_TABLE_SIZE) {
- /* don't count the slop buckets in the total */
- ++total;
- }
- }
- }
- qsort(count, IPHASH_TABLE_SIZE, sizeof(count[0]), iphash_compare);
- p = buf + ap_snprintf(buf, sizeof(buf),
- "iphash: total hashed = %u, avg chain = %u, "
- "chain lengths (count x len):",
- total, total / IPHASH_TABLE_SIZE);
- total = 1;
- for (i = 1; i < IPHASH_TABLE_SIZE; ++i) {
- if (count[i - 1] != count[i]) {
- p += ap_snprintf(p, sizeof(buf) - (p - buf), " %ux%u",
- total, count[i - 1]);
- total = 1;
- }
- else {
- ++total;
- }
- }
- p += ap_snprintf(p, sizeof(buf) - (p - buf), " %ux%u",
- total, count[IPHASH_TABLE_SIZE - 1]);
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, main_s, buf);
-}
-#endif
-
-
-/* This hashing function is designed to get good distribution in the cases
- * where the server is handling entire "networks" of servers. i.e. a
- * whack of /24s. This is probably the most common configuration for
- * ISPs with large virtual servers.
- *
- * NOTE: This function is symmetric (i.e. collapses all 4 octets
- * into one), so machine byte order (big/little endianness) does not matter.
- *
- * Hash function provided by David Hankins.
- */
-static ap_inline unsigned hash_inaddr(unsigned key)
-{
- key ^= (key >> 16);
- return ((key >> 8) ^ key) % IPHASH_TABLE_SIZE;
-}
-
-
-
-static ipaddr_chain *new_ipaddr_chain(ap_context_t *p,
- server_rec *s, server_addr_rec *sar)
-{
- ipaddr_chain *new;
-
- new = ap_palloc(p, sizeof(*new));
- new->names = NULL;
- new->server = s;
- new->sar = sar;
- new->next = NULL;
- return new;
-}
-
-
-static name_chain *new_name_chain(ap_context_t *p, server_rec *s, server_addr_rec *sar)
-{
- name_chain *new;
-
- new = ap_palloc(p, sizeof(*new));
- new->server = s;
- new->sar = sar;
- new->next = NULL;
- return new;
-}
-
-
-static ap_inline ipaddr_chain *find_ipaddr(struct in_addr *server_ip,
- unsigned port)
-{
- unsigned bucket;
- ipaddr_chain *trav;
- unsigned addr;
-
- /* scan the hash ap_table_t for an exact match first */
- addr = server_ip->s_addr;
- bucket = hash_inaddr(addr);
- for (trav = iphash_table[bucket]; trav; trav = trav->next) {
- server_addr_rec *sar = trav->sar;
- if ((sar->host_addr.s_addr == addr)
- && (sar->host_port == 0 || sar->host_port == port
- || port == 0)) {
- return trav;
- }
- }
- return NULL;
-}
-
-
-static ipaddr_chain *find_default_server(unsigned port)
-{
- server_addr_rec *sar;
- ipaddr_chain *trav;
-
- for (trav = default_list; trav; trav = trav->next) {
- sar = trav->sar;
- if (sar->host_port == 0 || sar->host_port == port) {
- /* match! */
- return trav;
- }
- }
- return NULL;
-}
-
-static void dump_vhost_config(ap_file_t *f)
-{
- int i;
- ipaddr_chain *ic;
- name_chain *nc;
- char buf[MAX_STRING_LEN];
-
- ap_fprintf(f, "VirtualHost configuration:\n");
- for (i = 0; i < IPHASH_TABLE_SIZE; ++i) {
- for (ic = iphash_table[i]; ic; ic = ic->next) {
- if (ic->sar->host_port == 0) {
- ap_snprintf(buf, sizeof(buf), "%pA:*", &ic->sar->host_addr);
- }
- else {
- ap_snprintf(buf, sizeof(buf), "%pA:%u", &ic->sar->host_addr,
- ic->sar->host_port);
- }
- if (ic->names == NULL) {
- ap_fprintf(f, "%-22s %s (%s:%u)\n", buf,
- ic->server->server_hostname, ic->server->defn_name,
- ic->server->defn_line_number);
- continue;
- }
- ap_fprintf(f, "%-22s is a NameVirtualHost\n"
- "%22s default server %s (%s:%u)\n",
- buf, "", ic->server->server_hostname,
- ic->server->defn_name, ic->server->defn_line_number);
- for (nc = ic->names; nc; nc = nc->next) {
- if (nc->sar->host_port) {
- ap_fprintf(f, "%22s port %u ", "", nc->sar->host_port);
- }
- else {
- ap_fprintf(f, "%22s port * ", "");
- }
- ap_fprintf(f, "namevhost %s (%s:%u)\n",
- nc->server->server_hostname,
- nc->server->defn_name,
- nc->server->defn_line_number);
- }
- }
- }
- if (default_list) {
- ap_fprintf(f, "_default_ servers:\n");
- for (ic = default_list; ic; ic = ic->next) {
- if (ic->sar->host_port == 0) {
- ap_fprintf(f, "port * ");
- }
- else {
- ap_fprintf(f, "port %u ", ic->sar->host_port);
- }
- ap_fprintf(f, "server %s (%s:%u)\n",
- ic->server->server_hostname, ic->server->defn_name,
- ic->server->defn_line_number);
- }
- }
-}
-
-/* compile the tables and such we need to do the run-time vhost lookups */
-void ap_fini_vhost_config(ap_context_t *p, server_rec *main_s)
-{
- server_addr_rec *sar;
- int has_default_vhost_addr;
- server_rec *s;
- int i;
- ipaddr_chain **iphash_table_tail[IPHASH_TABLE_SIZE];
-
- /* terminate the name_vhost list */
- *name_vhost_list_tail = NULL;
-
- /* Main host first */
- s = main_s;
-
- if (!s->server_hostname) {
- s->server_hostname = ap_get_local_host(p);
- }
-
- /* initialize the tails */
- for (i = 0; i < IPHASH_TABLE_SIZE; ++i) {
- iphash_table_tail[i] = &iphash_table[i];
- }
-
- /* The first things to go into the hash ap_table_t are the NameVirtualHosts
- * Since name_vhost_list is in the same order that the directives
- * occured in the config file, we'll copy it in that order.
- */
- for (sar = name_vhost_list; sar; sar = sar->next) {
- unsigned bucket = hash_inaddr(sar->host_addr.s_addr);
- ipaddr_chain *new = new_ipaddr_chain(p, NULL, sar);
-
- *iphash_table_tail[bucket] = new;
- iphash_table_tail[bucket] = &new->next;
-
- /* Notice that what we've done is insert an ipaddr_chain with
- * both server and names NULL. Remember that.
- */
- }
-
- /* The next things to go into the hash ap_table_t are the virtual hosts
- * themselves. They're listed off of main_s->next in the reverse
- * order they occured in the config file, so we insert them at
- * the iphash_table_tail but don't advance the tail.
- */
-
- for (s = main_s->next; s; s = s->next) {
- has_default_vhost_addr = 0;
- for (sar = s->addrs; sar; sar = sar->next) {
- ipaddr_chain *ic;
-
- if (sar->host_addr.s_addr == DEFAULT_VHOST_ADDR
- || sar->host_addr.s_addr == INADDR_ANY) {
- /* add it to default bucket for each appropriate sar
- * since we need to do a port test
- */
- ipaddr_chain *other;
-
- other = find_default_server(sar->host_port);
- if (other && other->sar->host_port != 0) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, main_s,
- "_default_ VirtualHost overlap on port %u,"
- " the first has precedence", sar->host_port);
- }
- has_default_vhost_addr = 1;
- ic = new_ipaddr_chain(p, s, sar);
- ic->next = default_list;
- default_list = ic;
- }
- else {
- /* see if it matches something we've already got */
- ic = find_ipaddr(&sar->host_addr, sar->host_port);
-
- /* the first time we encounter a NameVirtualHost address
- * ic->server will be NULL, on subsequent encounters
- * ic->names will be non-NULL.
- */
- if (ic && (ic->names || ic->server == NULL)) {
- name_chain *nc = new_name_chain(p, s, sar);
- nc->next = ic->names;
- ic->names = nc;
- ic->server = s;
- if (sar->host_port != ic->sar->host_port) {
- /* one of the two is a * port, the other isn't */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, main_s,
- "VirtualHost %s:%u -- mixing * "
- "ports and non-* ports with "
- "a NameVirtualHost address is not supported,"
- " proceeding with undefined results",
- sar->virthost, sar->host_port);
- }
- }
- else if (ic) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, main_s,
- "VirtualHost %s:%u overlaps with "
- "VirtualHost %s:%u, the first has precedence, "
- "perhaps you need a NameVirtualHost directive",
- sar->virthost, sar->host_port,
- ic->sar->virthost, ic->sar->host_port);
- ic->sar = sar;
- ic->server = s;
- }
- else {
- unsigned bucket = hash_inaddr(sar->host_addr.s_addr);
-
- ic = new_ipaddr_chain(p, s, sar);
- ic->next = *iphash_table_tail[bucket];
- *iphash_table_tail[bucket] = ic;
- }
- }
- }
-
- /* Ok now we want to set up a server_hostname if the user was
- * silly enough to forget one.
- * XXX: This is silly we should just crash and burn.
- */
- if (!s->server_hostname) {
- if (has_default_vhost_addr) {
- s->server_hostname = main_s->server_hostname;
- }
- else if (!s->addrs) {
- /* what else can we do? at this point this vhost has
- no configured name, probably because they used
- DNS in the VirtualHost statement. It's disabled
- anyhow by the host matching code. -djg */
- s->server_hostname =
- ap_pstrdup(p, "bogus_host_without_forward_dns");
- }
- else {
- struct hostent *h;
-
- if ((h = gethostbyaddr((char *) &(s->addrs->host_addr),
- sizeof(struct in_addr), AF_INET))) {
- s->server_hostname = ap_pstrdup(p, (char *) h->h_name);
- }
- else {
- /* again, what can we do? They didn't specify a
- ServerName, and their DNS isn't working. -djg */
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, main_s,
- "Failed to resolve server name "
- "for %s (check DNS) -- or specify an explicit "
- "ServerName",
- inet_ntoa(s->addrs->host_addr));
- s->server_hostname =
- ap_pstrdup(p, "bogus_host_without_reverse_dns");
- }
- }
- }
- }
-
- /* now go through and delete any NameVirtualHosts that didn't have any
- * hosts associated with them. Lamers.
- */
- for (i = 0; i < IPHASH_TABLE_SIZE; ++i) {
- ipaddr_chain **pic = &iphash_table[i];
-
- while (*pic) {
- ipaddr_chain *ic = *pic;
-
- if (ic->server == NULL) {
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, 0, main_s,
- "NameVirtualHost %s:%u has no VirtualHosts",
- ic->sar->virthost, ic->sar->host_port);
- *pic = ic->next;
- }
- else if (ic->names == NULL) {
- /* if server != NULL and names == NULL then we're done
- * looking at NameVirtualHosts
- */
- break;
- }
- else {
- pic = &ic->next;
- }
- }
- }
-
-#ifdef IPHASH_STATISTICS
- dump_iphash_statistics(main_s);
-#endif
- if (getenv("DUMP_VHOSTS")) {
- ap_file_t *thefile = NULL;
- ap_open_stderr(&thefile, p);
- dump_vhost_config(thefile);
- }
-}
-
-
-/*****************************************************************************
- * run-time vhost matching functions
- */
-
-/* Lowercase and remove any trailing dot and/or :port from the hostname,
- * and check that it is sane.
- */
-static void fix_hostname(request_rec *r)
-{
- char *host = ap_palloc(r->pool, strlen(r->hostname) + 1);
- const char *src;
- char *dst;
-
- /* check and copy the host part */
- src = r->hostname;
- dst = host;
- while (*src) {
- if (!ap_isalnum(*src) && *src != '.' && *src != '-') {
- if (*src == ':')
- break;
- else
- goto bad;
- } else {
- *dst++ = *src++;
- }
- }
- /* check the port part */
- if (*src++ == ':') {
- while (*src) {
- if (!ap_isdigit(*src++)) {
- goto bad;
- }
- }
- }
- /* strip trailing gubbins */
- if (dst > host && dst[-1] == '.') {
- dst[-1] = '\0';
- } else {
- dst[0] = '\0';
- }
-
- r->hostname = host;
- return;
-
-bad:
- r->status = HTTP_BAD_REQUEST;
- ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, r,
- "Client sent malformed Host header");
- return;
-}
-
-
-/* return 1 if host matches ServerName or ServerAliases */
-static int matches_aliases(server_rec *s, const char *host)
-{
- int i;
- ap_array_header_t *names;
-
- /* match ServerName */
- if (!strcasecmp(host, s->server_hostname)) {
- return 1;
- }
-
- /* search all the aliases from ServerAlias directive */
- names = s->names;
- if (names) {
- char **name = (char **) names->elts;
- for (i = 0; i < names->nelts; ++i) {
- if(!name[i]) continue;
- if (!strcasecmp(host, name[i]))
- return 1;
- }
- }
- names = s->wild_names;
- if (names) {
- char **name = (char **) names->elts;
- for (i = 0; i < names->nelts; ++i) {
- if(!name[i]) continue;
- if (!ap_strcasecmp_match(host, name[i]))
- return 1;
- }
- }
- return 0;
-}
-
-
-/* Suppose a request came in on the same socket as this r, and included
- * a header "Host: host:port", would it map to r->server? It's more
- * than just that though. When we do the normal matches for each request
- * we don't even bother considering Host: etc on non-namevirtualhosts,
- * we just call it a match. But here we require the host:port to match
- * the ServerName and/or ServerAliases.
- */
-API_EXPORT(int) ap_matches_request_vhost(request_rec *r, const char *host,
- unsigned port)
-{
- server_rec *s;
- server_addr_rec *sar;
-
- s = r->server;
-
- /* search all the <VirtualHost> values */
- /* XXX: If this is a NameVirtualHost then we may not be doing the Right Thing
- * consider:
- *
- * NameVirtualHost 10.1.1.1
- * <VirtualHost 10.1.1.1>
- * ServerName v1
- * </VirtualHost>
- * <VirtualHost 10.1.1.1>
- * ServerName v2
- * </VirtualHost>
- *
- * Suppose r->server is v2, and we're asked to match "10.1.1.1". We'll say
- * "yup it's v2", when really it isn't... if a request came in for 10.1.1.1
- * it would really go to v1.
- */
- for (sar = s->addrs; sar; sar = sar->next) {
- if ((sar->host_port == 0 || port == sar->host_port)
- && !strcasecmp(host, sar->virthost)) {
- return 1;
- }
- }
-
- /* the Port has to match now, because the rest don't have ports associated
- * with them. */
- if (port != s->port) {
- return 0;
- }
-
- return matches_aliases(s, host);
-}
-
-
-static void check_hostalias(request_rec *r)
-{
- /*
- * Even if the request has a Host: header containing a port we ignore
- * that port. We always use the physical port of the socket. There
- * are a few reasons for this:
- *
- * - the default of 80 or 443 for SSL is easier to handle this way
- * - there is less of a possibility of a security problem
- * - it simplifies the data structure
- * - the client may have no idea that a proxy somewhere along the way
- * translated the request to another ip:port
- * - except for the addresses from the VirtualHost line, none of the other
- * names we'll match have ports associated with them
- */
- const char *host = r->hostname;
- unsigned port = ntohs(r->connection->local_addr.sin_port);
- server_rec *s;
- server_rec *last_s;
- name_chain *src;
-
- last_s = NULL;
-
- /* Recall that the name_chain is a list of server_addr_recs, some of
- * whose ports may not match. Also each server may appear more than
- * once in the chain -- specifically, it will appear once for each
- * address from its VirtualHost line which matched. We only want to
- * do the full ServerName/ServerAlias comparisons once for each
- * server, fortunately we know that all the VirtualHost addresses for
- * a single server are adjacent to each other.
- */
-
- for (src = r->connection->vhost_lookup_data; src; src = src->next) {
- server_addr_rec *sar;
-
- /* We only consider addresses on the name_chain which have a matching
- * port
- */
- sar = src->sar;
- if (sar->host_port != 0 && port != sar->host_port) {
- continue;
- }
-
- s = src->server;
-
- /* does it match the virthost from the sar? */
- if (!strcasecmp(host, sar->virthost)) {
- goto found;
- }
-
- if (s == last_s) {
- /* we've already done ServerName and ServerAlias checks for this
- * vhost
- */
- continue;
- }
- last_s = s;
-
- if (matches_aliases(s, host)) {
- goto found;
- }
- }
- return;
-
-found:
- /* s is the first matching server, we're done */
- r->server = s;
-}
-
-
-static void check_serverpath(request_rec *r)
-{
- server_rec *s;
- server_rec *last_s;
- name_chain *src;
- /* use AP func here. */
- unsigned port = ntohs(r->connection->local_addr.sin_port);
-
- /*
- * This is in conjunction with the ServerPath code in http_core, so we
- * get the right host attached to a non- Host-sending request.
- *
- * See the comment in check_hostalias about how each vhost can be
- * listed multiple times.
- */
-
- last_s = NULL;
- for (src = r->connection->vhost_lookup_data; src; src = src->next) {
- /* We only consider addresses on the name_chain which have a matching
- * port
- */
- if (src->sar->host_port != 0 && port != src->sar->host_port) {
- continue;
- }
-
- s = src->server;
- if (s == last_s) {
- continue;
- }
- last_s = s;
-
- if (s->path && !strncmp(r->uri, s->path, s->pathlen) &&
- (s->path[s->pathlen - 1] == '/' ||
- r->uri[s->pathlen] == '/' ||
- r->uri[s->pathlen] == '\0')) {
- r->server = s;
- return;
- }
- }
-}
-
-
-void ap_update_vhost_from_headers(request_rec *r)
-{
- /* must set this for HTTP/1.1 support */
- if (r->hostname || (r->hostname = ap_table_get(r->headers_in, "Host"))) {
- fix_hostname(r);
- if (r->status != HTTP_OK)
- return;
- }
- /* check if we tucked away a name_chain */
- if (r->connection->vhost_lookup_data) {
- if (r->hostname)
- check_hostalias(r);
- else
- check_serverpath(r);
- }
-}
-
-
-/* Called for a new connection which has a known local_addr. Note that the
- * new connection is assumed to have conn->server == main server.
- */
-void ap_update_vhost_given_ip(conn_rec *conn)
-{
- ipaddr_chain *trav;
- unsigned port = ntohs(conn->local_addr.sin_port);
-
- /* scan the hash ap_table_t for an exact match first */
- trav = find_ipaddr(&conn->local_addr.sin_addr, port);
- if (trav) {
- /* save the name_chain for later in case this is a name-vhost */
- conn->vhost_lookup_data = trav->names;
- conn->base_server = trav->server;
- return;
- }
-
- /* There's certainly no name-vhosts with this address, they would have
- * been matched above.
- */
- conn->vhost_lookup_data = NULL;
-
- /* maybe there's a default server matching this port */
- trav = find_default_server(port);
- if (trav) {
- conn->base_server = trav->server;
- }
-
- /* otherwise we're stuck with just the main server */
-}
diff --git a/srclib/.cvsignore b/srclib/.cvsignore
deleted file mode 100644
index 608e723a15..0000000000
--- a/srclib/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-pth
diff --git a/srclib/Makefile.in b/srclib/Makefile.in
deleted file mode 100644
index 5d725f2af1..0000000000
--- a/srclib/Makefile.in
+++ /dev/null
@@ -1,9 +0,0 @@
-
-DEPTH = ..
-topsrcdir = @topsrcdir@
-srcdir = @srcdir@
-VPATH = @srcdir@
-
-SUBDIRS = apr
-
-include $(topsrcdir)/build/rules.mk
diff --git a/srclib/expat-lite/.cvsignore b/srclib/expat-lite/.cvsignore
deleted file mode 100644
index f3c7a7c5da..0000000000
--- a/srclib/expat-lite/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-Makefile
diff --git a/srclib/expat-lite/CHANGES b/srclib/expat-lite/CHANGES
deleted file mode 100644
index e424068ed9..0000000000
--- a/srclib/expat-lite/CHANGES
+++ /dev/null
@@ -1,41 +0,0 @@
-=== PURPOSE ===
-
-This file documents the changes made by the Apache Group to James
-Clark's Expat parser. The original Expat distribution can be found at
-http://www.jclark.com/xml/expat.html.
-
-
-=== SUBSET INFORMATION ===
-
-Apache does not choose (or need) to use the entire Expat parser
-distribution. The subset that Apache will use will be referred to as
-"expat-lite". In particular, this directory contains the files from
-the following Expat distribution subdirectories:
-
- expat/xmltok/*
- expat/xmlparse/*
-
-We also retain expat/expat.html for attribution to James Clark and
-licensing information.
-
-In addition, we remove expat/xmltok/dllmain.c from our version since
-we statically link expat-lite into the executable (rather than
-building a DLL on the Win32 platform). The *.dsp files are also
-removed, since we place those elsewhere in the Apache source
-distribution and they will have a very different structure.
-
-Makefile.tmpl has been created from scratch to provide build
-instructions to the Apache build system.
-
-This file (CHANGES) has been added to document changes from the
-original Expat distribution.
-
-
-=== CHANGES TO ORIGINAL ===
-
-There have been no changes made to any Expat file at this point in
-time (May 31, 1999).
-
-The files, in their original state from the Expat distribution, have
-been tagged within CVS with the "EXPAT_1_1" tag. That tag may be used
-as a reference for changes made by the Apache Group.
diff --git a/srclib/expat-lite/Makefile.in b/srclib/expat-lite/Makefile.in
deleted file mode 100644
index 1cecba2044..0000000000
--- a/srclib/expat-lite/Makefile.in
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# default definition of these two. dunno how to get it prepended when the
-# Makefile is built, so we do it manually
-#
-CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
-INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
-
-# If you know what your system's byte order is, define BYTE_ORDER:
-# use -DBYTE_ORDER=12 for little-endian byte order;
-# use -DBYTE_ORDER=21 for big-endian (network) byte order.
-#CFLAGS=-O2
-
-OBJS=xmltok.o xmlrole.o xmlparse.o hashtable.o
-
-all lib: libexpat.a
-
-libexpat.a: $(OBJS)
- rm -f libexpat.a
- ar cr libexpat.a $(OBJS)
- $(RANLIB) libexpat.a
-
-clean:
- rm -f $(OBJS) libexpat.a
-
-distclean: clean
- -rm -f Makefile
-
-.SUFFIXES: .o
-
-.c.o:
- $(CC) -c $(INCLUDES) $(CFLAGS) $<
-
-depend:
diff --git a/srclib/expat-lite/asciitab.h b/srclib/expat-lite/asciitab.h
deleted file mode 100644
index 8a8a2dd388..0000000000
--- a/srclib/expat-lite/asciitab.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
-/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
-/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
-/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
-/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
-/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
-/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
-/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
-/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
-/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
-/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
diff --git a/srclib/expat-lite/expat.html b/srclib/expat-lite/expat.html
deleted file mode 100644
index 3806ca8d0e..0000000000
--- a/srclib/expat-lite/expat.html
+++ /dev/null
@@ -1,73 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
-"http://www.w3.org/TR/REC-html40/loose.dtd">
-
-<HTML>
-
-<TITLE>expat</TITLE>
-
-<BODY>
-
-<H1>expat - XML Parser Toolkit</H1>
-
-<H3>Version 1.1</H3>
-
-<P>Copyright (c) 1998, 1999 James Clark. Expat is subject to the <A
-HREF="http://www.mozilla.org/NPL/NPL-1_1Final.html">Mozilla Public
-License Version 1.1</A>. Alternatively you may use expat under the <A
-href="http://www.gnu.org/copyleft/gpl.html">GNU General Public
-License</A> instead. Please contact me if you wish to negotiate an
-alternative license.</P>
-
-<P>Expat is an <A
-HREF="http://www.w3.org/TR/1998/REC-xml-19980210">XML 1.0</A> parser
-written in C. It aims to be fully conforming. It is currently not a
-validating XML processor. The current production version of expat can
-be downloaded from <A href = "ftp://ftp.jclark.com/pub/xml/expat.zip"
->ftp://ftp.jclark.com/pub/xml/expat.zip</A>.</P>
-
-<P>The directory <SAMP>xmltok</SAMP> contains a low-level library for
-tokenizing XML. The interface is documented in
-<SAMP>xmltok/xmltok.h</SAMP>.</P>
-
-<P>The directory <SAMP>xmlparse</SAMP> contains an XML parser library
-which is built on top of the <SAMP>xmltok</SAMP> library. The
-interface is documented in <SAMP>xmlparse/xmlparse.h</SAMP>. The
-directory <SAMP>sample</SAMP> contains a simple example program using
-this interface; <SAMP>sample/build.bat</SAMP> is a batch file to build
-the example using Visual C++.</P>
-
-<P>The directory <SAMP>xmlwf</SAMP> contains the <SAMP>xmlwf</SAMP>
-application, which uses the <SAMP>xmlparse</SAMP> library. The
-arguments to <SAMP>xmlwf</SAMP> are one or more files which are each
-to be checked for well-formedness. An option <SAMP>-d
-<VAR>dir</VAR></SAMP> can be specified; for each well-formed input
-file the corresponding <A
-href="http://www.jclark.com/xml/canonxml.html">canonical XML</A> will
-be written to <SAMP>dir/<VAR>f</VAR></SAMP>, where
-<SAMP><VAR>f</VAR></SAMP> is the filename (without any path) of the
-input file. A <CODE>-x</CODE> option will cause references to
-external general entities to be processed. A <CODE>-s</CODE> option
-will make documents that are not standalone cause an error (a document
-is considered standalone if either it is intrinsically standalone
-because it has no external subset and no references to parameter
-entities in the internal subset or it is declared as standalone in the
-XML declaration).</P>
-
-<P>The <SAMP>bin</SAMP> directory contains Win32 executables. The
-<SAMP>lib</SAMP> directory contains Win32 import libraries.</P>
-
-<P>Answers to some frequently asked questions about expat can be found
-in the <A HREF="http://www.jclark.com/xml/expatfaq.html">expat
-FAQ</A>.</P>
-
-<P></P>
-
-<ADDRESS>
-
-<A HREF="mailto:jjc@jclark.com">James Clark</A>
-
-</ADDRESS>
-
-</BODY>
-
-</HTML>
diff --git a/srclib/expat-lite/hashtable.c b/srclib/expat-lite/hashtable.c
deleted file mode 100644
index 780a061041..0000000000
--- a/srclib/expat-lite/hashtable.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (the "License"); you may not use this file except in
-csompliance with the License. You may obtain a copy of the License at
-http://www.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-#include "xmldef.h"
-
-#ifdef XML_UNICODE_WCHAR_T
-#ifndef XML_UNICODE
-#define XML_UNICODE
-#endif
-#endif
-
-#include "hashtable.h"
-
-#define INIT_SIZE 64
-
-static
-int keyeq(KEY s1, KEY s2)
-{
- for (; *s1 == *s2; s1++, s2++)
- if (*s1 == 0)
- return 1;
- return 0;
-}
-
-static
-unsigned long hash(KEY s)
-{
- unsigned long h = 0;
- while (*s)
- h = (h << 5) + h + (unsigned char)*s++;
- return h;
-}
-
-NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize)
-{
- size_t i;
- if (table->size == 0) {
- if (!createSize)
- return 0;
- table->v = calloc(INIT_SIZE, sizeof(NAMED *));
- if (!table->v)
- return 0;
- table->size = INIT_SIZE;
- table->usedLim = INIT_SIZE / 2;
- i = hash(name) & (table->size - 1);
- }
- else {
- unsigned long h = hash(name);
- for (i = h & (table->size - 1);
- table->v[i];
- i == 0 ? i = table->size - 1 : --i) {
- if (keyeq(name, table->v[i]->name))
- return table->v[i];
- }
- if (!createSize)
- return 0;
- if (table->used == table->usedLim) {
- /* check for overflow */
- size_t newSize = table->size * 2;
- NAMED **newV = calloc(newSize, sizeof(NAMED *));
- if (!newV)
- return 0;
- for (i = 0; i < table->size; i++)
- if (table->v[i]) {
- size_t j;
- for (j = hash(table->v[i]->name) & (newSize - 1);
- newV[j];
- j == 0 ? j = newSize - 1 : --j)
- ;
- newV[j] = table->v[i];
- }
- free(table->v);
- table->v = newV;
- table->size = newSize;
- table->usedLim = newSize/2;
- for (i = h & (table->size - 1);
- table->v[i];
- i == 0 ? i = table->size - 1 : --i)
- ;
- }
- }
- table->v[i] = calloc(1, createSize);
- if (!table->v[i])
- return 0;
- table->v[i]->name = name;
- (table->used)++;
- return table->v[i];
-}
-
-void hashTableDestroy(HASH_TABLE *table)
-{
- size_t i;
- for (i = 0; i < table->size; i++) {
- NAMED *p = table->v[i];
- if (p)
- free(p);
- }
- free(table->v);
-}
-
-void hashTableInit(HASH_TABLE *p)
-{
- p->size = 0;
- p->usedLim = 0;
- p->used = 0;
- p->v = 0;
-}
-
-void hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table)
-{
- iter->p = table->v;
- iter->end = iter->p + table->size;
-}
-
-NAMED *hashTableIterNext(HASH_TABLE_ITER *iter)
-{
- while (iter->p != iter->end) {
- NAMED *tem = *(iter->p)++;
- if (tem)
- return tem;
- }
- return 0;
-}
-
diff --git a/srclib/expat-lite/hashtable.h b/srclib/expat-lite/hashtable.h
deleted file mode 100644
index df8ab8a4c8..0000000000
--- a/srclib/expat-lite/hashtable.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-
-#include <stddef.h>
-
-#ifdef XML_UNICODE
-
-#ifdef XML_UNICODE_WCHAR_T
-typedef const wchar_t *KEY;
-#else /* not XML_UNICODE_WCHAR_T */
-typedef const unsigned short *KEY;
-#endif /* not XML_UNICODE_WCHAR_T */
-
-#else /* not XML_UNICODE */
-
-typedef const char *KEY;
-
-#endif /* not XML_UNICODE */
-
-typedef struct {
- KEY name;
-} NAMED;
-
-typedef struct {
- NAMED **v;
- size_t size;
- size_t used;
- size_t usedLim;
-} HASH_TABLE;
-
-NAMED *lookup(HASH_TABLE *table, KEY name, size_t createSize);
-void hashTableInit(HASH_TABLE *);
-void hashTableDestroy(HASH_TABLE *);
-
-typedef struct {
- NAMED **p;
- NAMED **end;
-} HASH_TABLE_ITER;
-
-void hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *);
-NAMED *hashTableIterNext(HASH_TABLE_ITER *);
diff --git a/srclib/expat-lite/iasciitab.h b/srclib/expat-lite/iasciitab.h
deleted file mode 100644
index 333d6bb779..0000000000
--- a/srclib/expat-lite/iasciitab.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
-/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
-/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
-/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
-/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
-/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
-/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
-/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
-/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
-/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
-/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
-/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
-/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
-/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
-/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
diff --git a/srclib/expat-lite/latin1tab.h b/srclib/expat-lite/latin1tab.h
deleted file mode 100644
index 48609aa8f9..0000000000
--- a/srclib/expat-lite/latin1tab.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
-/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
-/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
-/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
-/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
-/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
-/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
diff --git a/srclib/expat-lite/nametab.h b/srclib/expat-lite/nametab.h
deleted file mode 100644
index b05e62c77a..0000000000
--- a/srclib/expat-lite/nametab.h
+++ /dev/null
@@ -1,150 +0,0 @@
-static const unsigned namingBitmap[] = {
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
-0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
-0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
-0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
-0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
-0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
-0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
-0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
-0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
-0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
-0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
-0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
-0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
-0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
-0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
-0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
-0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
-0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
-0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
-0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
-0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
-0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
-0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
-0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
-0x40000000, 0xF580C900, 0x00000007, 0x02010800,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
-0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
-0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
-0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
-0x00000000, 0x00004C40, 0x00000000, 0x00000000,
-0x00000007, 0x00000000, 0x00000000, 0x00000000,
-0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
-0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
-0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
-0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
-0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
-0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
-0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
-0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
-0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
-0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
-0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
-0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
-0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
-0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
-0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
-0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
-0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
-0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
-0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
-0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
-0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
-0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
-0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
-0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
-0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
-0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
-0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
-0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
-0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
-0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x00000000, 0x00000000,
-0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
-0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
-0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF,
-};
-static const unsigned char nmstrtPages[] = {
-0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
-0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
-0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
-0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
-static const unsigned char namePages[] = {
-0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
-0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
-0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
-0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
-0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-};
diff --git a/srclib/expat-lite/utf8tab.h b/srclib/expat-lite/utf8tab.h
deleted file mode 100644
index a38fe624e8..0000000000
--- a/srclib/expat-lite/utf8tab.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-
-/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
-/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
-/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
-/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
-/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
-/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
diff --git a/srclib/expat-lite/xmldef.h b/srclib/expat-lite/xmldef.h
deleted file mode 100644
index 49ce9ed636..0000000000
--- a/srclib/expat-lite/xmldef.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-#include <string.h>
-
-#ifdef XML_WINLIB
-
-#define WIN32_LEAN_AND_MEAN
-#define STRICT
-#include <windows.h>
-
-#define malloc(x) HeapAlloc(GetProcessHeap(), 0, (x))
-#define calloc(x, y) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (x)*(y))
-#define free(x) HeapFree(GetProcessHeap(), 0, (x))
-#define realloc(x, y) HeapReAlloc(GetProcessHeap(), 0, x, y)
-#define abort() /* as nothing */
-
-#else /* not XML_WINLIB */
-
-#include <stdlib.h>
-
-#endif /* not XML_WINLIB */
-
-/* This file can be used for any definitions needed in
-particular environments. */
-
-#ifdef MOZILLA
-
-#include "nspr.h"
-#define malloc(x) PR_Malloc(x)
-#define realloc(x, y) PR_Realloc((x), (y))
-#define calloc(x, y) PR_Calloc((x),(y))
-#define free(x) PR_Free(x)
-#define int int32
-
-#endif /* MOZILLA */
diff --git a/srclib/expat-lite/xmlparse.c b/srclib/expat-lite/xmlparse.c
deleted file mode 100644
index 8f9d09c86e..0000000000
--- a/srclib/expat-lite/xmlparse.c
+++ /dev/null
@@ -1,3256 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-#include "xmldef.h"
-#include "xmlparse.h"
-
-#ifdef XML_UNICODE
-#define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX
-#define XmlConvert XmlUtf16Convert
-#define XmlGetInternalEncoding XmlGetUtf16InternalEncoding
-#define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS
-#define XmlEncode XmlUtf16Encode
-#define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1))
-typedef unsigned short ICHAR;
-#else
-#define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX
-#define XmlConvert XmlUtf8Convert
-#define XmlGetInternalEncoding XmlGetUtf8InternalEncoding
-#define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS
-#define XmlEncode XmlUtf8Encode
-#define MUST_CONVERT(enc, s) (!(enc)->isUtf8)
-typedef char ICHAR;
-#endif
-
-
-#ifndef XML_NS
-
-#define XmlInitEncodingNS XmlInitEncoding
-#define XmlInitUnknownEncodingNS XmlInitUnknownEncoding
-#undef XmlGetInternalEncodingNS
-#define XmlGetInternalEncodingNS XmlGetInternalEncoding
-#define XmlParseXmlDeclNS XmlParseXmlDecl
-
-#endif
-
-
-#ifdef XML_UNICODE_WCHAR_T
-#define XML_T(x) L ## x
-#else
-#define XML_T(x) x
-#endif
-
-/* Round up n to be a multiple of sz, where sz is a power of 2. */
-#define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1))
-
-#include "xmltok.h"
-#include "xmlrole.h"
-#include "hashtable.h"
-
-#define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */
-#define INIT_DATA_BUF_SIZE 1024
-#define INIT_ATTS_SIZE 16
-#define INIT_BLOCK_SIZE 1024
-#define INIT_BUFFER_SIZE 1024
-
-#define EXPAND_SPARE 24
-
-typedef struct binding {
- struct prefix *prefix;
- struct binding *nextTagBinding;
- struct binding *prevPrefixBinding;
- const struct attribute_id *attId;
- XML_Char *uri;
- int uriLen;
- int uriAlloc;
-} BINDING;
-
-typedef struct prefix {
- const XML_Char *name;
- BINDING *binding;
-} PREFIX;
-
-typedef struct {
- const XML_Char *str;
- const XML_Char *localPart;
- int uriLen;
-} TAG_NAME;
-
-typedef struct tag {
- struct tag *parent;
- const char *rawName;
- int rawNameLength;
- TAG_NAME name;
- char *buf;
- char *bufEnd;
- BINDING *bindings;
-} TAG;
-
-typedef struct {
- const XML_Char *name;
- const XML_Char *textPtr;
- int textLen;
- const XML_Char *systemId;
- const XML_Char *base;
- const XML_Char *publicId;
- const XML_Char *notation;
- char open;
-} ENTITY;
-
-typedef struct block {
- struct block *next;
- int size;
- XML_Char s[1];
-} BLOCK;
-
-typedef struct {
- BLOCK *blocks;
- BLOCK *freeBlocks;
- const XML_Char *end;
- XML_Char *ptr;
- XML_Char *start;
-} STRING_POOL;
-
-/* The XML_Char before the name is used to determine whether
-an attribute has been specified. */
-typedef struct attribute_id {
- XML_Char *name;
- PREFIX *prefix;
- char maybeTokenized;
- char xmlns;
-} ATTRIBUTE_ID;
-
-typedef struct {
- const ATTRIBUTE_ID *id;
- char isCdata;
- const XML_Char *value;
-} DEFAULT_ATTRIBUTE;
-
-typedef struct {
- const XML_Char *name;
- PREFIX *prefix;
- int nDefaultAtts;
- int allocDefaultAtts;
- DEFAULT_ATTRIBUTE *defaultAtts;
-} ELEMENT_TYPE;
-
-typedef struct {
- HASH_TABLE generalEntities;
- HASH_TABLE elementTypes;
- HASH_TABLE attributeIds;
- HASH_TABLE prefixes;
- STRING_POOL pool;
- int complete;
- int standalone;
- const XML_Char *base;
- PREFIX defaultPrefix;
-} DTD;
-
-typedef struct open_internal_entity {
- const char *internalEventPtr;
- const char *internalEventEndPtr;
- struct open_internal_entity *next;
- ENTITY *entity;
-} OPEN_INTERNAL_ENTITY;
-
-typedef enum XML_Error Processor(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr);
-
-static Processor prologProcessor;
-static Processor prologInitProcessor;
-static Processor contentProcessor;
-static Processor cdataSectionProcessor;
-static Processor epilogProcessor;
-#if 0
-static Processor errorProcessor;
-#endif
-static Processor externalEntityInitProcessor;
-static Processor externalEntityInitProcessor2;
-static Processor externalEntityInitProcessor3;
-static Processor externalEntityContentProcessor;
-
-static enum XML_Error
-handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName);
-static enum XML_Error
-processXmlDecl(XML_Parser parser, int isGeneralTextEntity, const char *, const char *);
-static enum XML_Error
-initializeEncoding(XML_Parser parser);
-static enum XML_Error
-doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
- const char *start, const char *end, const char **endPtr);
-static enum XML_Error
-doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr, const char *end, const char **nextPtr);
-static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *, const char *s,
- TAG_NAME *tagNamePtr, BINDING **bindingsPtr);
-static
-int addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, const XML_Char *uri, BINDING **bindingsPtr);
-static int
-defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, int isCdata, const XML_Char *dfltValue);
-static enum XML_Error
-storeAttributeValue(XML_Parser parser, const ENCODING *, int isCdata, const char *, const char *,
- STRING_POOL *);
-static enum XML_Error
-appendAttributeValue(XML_Parser parser, const ENCODING *, int isCdata, const char *, const char *,
- STRING_POOL *);
-static ATTRIBUTE_ID *
-getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, const char *end);
-static int setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *);
-static enum XML_Error
-storeEntityValue(XML_Parser parser, const char *start, const char *end);
-static int
-reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, const char *start, const char *end);
-static int
-reportComment(XML_Parser parser, const ENCODING *enc, const char *start, const char *end);
-static void
-reportDefault(XML_Parser parser, const ENCODING *enc, const char *start, const char *end);
-
-static const XML_Char *getContext(XML_Parser parser);
-static int setContext(XML_Parser parser, const XML_Char *context);
-static void normalizePublicId(XML_Char *s);
-static int dtdInit(DTD *);
-static void dtdDestroy(DTD *);
-static int dtdCopy(DTD *newDtd, const DTD *oldDtd);
-static void poolInit(STRING_POOL *);
-static void poolClear(STRING_POOL *);
-static void poolDestroy(STRING_POOL *);
-static XML_Char *poolAppend(STRING_POOL *pool, const ENCODING *enc,
- const char *ptr, const char *end);
-static XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc,
- const char *ptr, const char *end);
-static int poolGrow(STRING_POOL *pool);
-static const XML_Char *poolCopyString(STRING_POOL *pool, const XML_Char *s);
-static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n);
-
-#define poolStart(pool) ((pool)->start)
-#define poolEnd(pool) ((pool)->ptr)
-#define poolLength(pool) ((pool)->ptr - (pool)->start)
-#define poolChop(pool) ((void)--(pool->ptr))
-#define poolLastChar(pool) (((pool)->ptr)[-1])
-#define poolDiscard(pool) ((pool)->ptr = (pool)->start)
-#define poolFinish(pool) ((pool)->start = (pool)->ptr)
-#define poolAppendChar(pool, c) \
- (((pool)->ptr == (pool)->end && !poolGrow(pool)) \
- ? 0 \
- : ((*((pool)->ptr)++ = c), 1))
-
-typedef struct {
- /* The first member must be userData so that the XML_GetUserData macro works. */
- void *m_userData;
- void *m_handlerArg;
- char *m_buffer;
- /* first character to be parsed */
- const char *m_bufferPtr;
- /* past last character to be parsed */
- char *m_bufferEnd;
- /* allocated end of buffer */
- const char *m_bufferLim;
- long m_parseEndByteIndex;
- const char *m_parseEndPtr;
- XML_Char *m_dataBuf;
- XML_Char *m_dataBufEnd;
- XML_StartElementHandler m_startElementHandler;
- XML_EndElementHandler m_endElementHandler;
- XML_CharacterDataHandler m_characterDataHandler;
- XML_ProcessingInstructionHandler m_processingInstructionHandler;
- XML_CommentHandler m_commentHandler;
- XML_StartCdataSectionHandler m_startCdataSectionHandler;
- XML_EndCdataSectionHandler m_endCdataSectionHandler;
- XML_DefaultHandler m_defaultHandler;
- XML_UnparsedEntityDeclHandler m_unparsedEntityDeclHandler;
- XML_NotationDeclHandler m_notationDeclHandler;
- XML_StartNamespaceDeclHandler m_startNamespaceDeclHandler;
- XML_EndNamespaceDeclHandler m_endNamespaceDeclHandler;
- XML_NotStandaloneHandler m_notStandaloneHandler;
- XML_ExternalEntityRefHandler m_externalEntityRefHandler;
- void *m_externalEntityRefHandlerArg;
- XML_UnknownEncodingHandler m_unknownEncodingHandler;
- const ENCODING *m_encoding;
- INIT_ENCODING m_initEncoding;
- const XML_Char *m_protocolEncodingName;
- int m_ns;
- void *m_unknownEncodingMem;
- void *m_unknownEncodingData;
- void *m_unknownEncodingHandlerData;
- void (*m_unknownEncodingRelease)(void *);
- PROLOG_STATE m_prologState;
- Processor *m_processor;
- enum XML_Error m_errorCode;
- const char *m_eventPtr;
- const char *m_eventEndPtr;
- const char *m_positionPtr;
- OPEN_INTERNAL_ENTITY *m_openInternalEntities;
- int m_defaultExpandInternalEntities;
- int m_tagLevel;
- ENTITY *m_declEntity;
- const XML_Char *m_declNotationName;
- const XML_Char *m_declNotationPublicId;
- ELEMENT_TYPE *m_declElementType;
- ATTRIBUTE_ID *m_declAttributeId;
- char m_declAttributeIsCdata;
- DTD m_dtd;
- TAG *m_tagStack;
- TAG *m_freeTagList;
- BINDING *m_inheritedBindings;
- BINDING *m_freeBindingList;
- int m_attsSize;
- int m_nSpecifiedAtts;
- ATTRIBUTE *m_atts;
- POSITION m_position;
- STRING_POOL m_tempPool;
- STRING_POOL m_temp2Pool;
- char *m_groupConnector;
- unsigned m_groupSize;
- int m_hadExternalDoctype;
- XML_Char m_namespaceSeparator;
-} Parser;
-
-#define userData (((Parser *)parser)->m_userData)
-#define handlerArg (((Parser *)parser)->m_handlerArg)
-#define startElementHandler (((Parser *)parser)->m_startElementHandler)
-#define endElementHandler (((Parser *)parser)->m_endElementHandler)
-#define characterDataHandler (((Parser *)parser)->m_characterDataHandler)
-#define processingInstructionHandler (((Parser *)parser)->m_processingInstructionHandler)
-#define commentHandler (((Parser *)parser)->m_commentHandler)
-#define startCdataSectionHandler (((Parser *)parser)->m_startCdataSectionHandler)
-#define endCdataSectionHandler (((Parser *)parser)->m_endCdataSectionHandler)
-#define defaultHandler (((Parser *)parser)->m_defaultHandler)
-#define unparsedEntityDeclHandler (((Parser *)parser)->m_unparsedEntityDeclHandler)
-#define notationDeclHandler (((Parser *)parser)->m_notationDeclHandler)
-#define startNamespaceDeclHandler (((Parser *)parser)->m_startNamespaceDeclHandler)
-#define endNamespaceDeclHandler (((Parser *)parser)->m_endNamespaceDeclHandler)
-#define notStandaloneHandler (((Parser *)parser)->m_notStandaloneHandler)
-#define externalEntityRefHandler (((Parser *)parser)->m_externalEntityRefHandler)
-#define externalEntityRefHandlerArg (((Parser *)parser)->m_externalEntityRefHandlerArg)
-#define unknownEncodingHandler (((Parser *)parser)->m_unknownEncodingHandler)
-#define encoding (((Parser *)parser)->m_encoding)
-#define initEncoding (((Parser *)parser)->m_initEncoding)
-#define unknownEncodingMem (((Parser *)parser)->m_unknownEncodingMem)
-#define unknownEncodingData (((Parser *)parser)->m_unknownEncodingData)
-#define unknownEncodingHandlerData \
- (((Parser *)parser)->m_unknownEncodingHandlerData)
-#define unknownEncodingRelease (((Parser *)parser)->m_unknownEncodingRelease)
-#define protocolEncodingName (((Parser *)parser)->m_protocolEncodingName)
-#define ns (((Parser *)parser)->m_ns)
-#define prologState (((Parser *)parser)->m_prologState)
-#define processor (((Parser *)parser)->m_processor)
-#define errorCode (((Parser *)parser)->m_errorCode)
-#define eventPtr (((Parser *)parser)->m_eventPtr)
-#define eventEndPtr (((Parser *)parser)->m_eventEndPtr)
-#define positionPtr (((Parser *)parser)->m_positionPtr)
-#define position (((Parser *)parser)->m_position)
-#define openInternalEntities (((Parser *)parser)->m_openInternalEntities)
-#define defaultExpandInternalEntities (((Parser *)parser)->m_defaultExpandInternalEntities)
-#define tagLevel (((Parser *)parser)->m_tagLevel)
-#define buffer (((Parser *)parser)->m_buffer)
-#define bufferPtr (((Parser *)parser)->m_bufferPtr)
-#define bufferEnd (((Parser *)parser)->m_bufferEnd)
-#define parseEndByteIndex (((Parser *)parser)->m_parseEndByteIndex)
-#define parseEndPtr (((Parser *)parser)->m_parseEndPtr)
-#define bufferLim (((Parser *)parser)->m_bufferLim)
-#define dataBuf (((Parser *)parser)->m_dataBuf)
-#define dataBufEnd (((Parser *)parser)->m_dataBufEnd)
-#define dtd (((Parser *)parser)->m_dtd)
-#define declEntity (((Parser *)parser)->m_declEntity)
-#define declNotationName (((Parser *)parser)->m_declNotationName)
-#define declNotationPublicId (((Parser *)parser)->m_declNotationPublicId)
-#define declElementType (((Parser *)parser)->m_declElementType)
-#define declAttributeId (((Parser *)parser)->m_declAttributeId)
-#define declAttributeIsCdata (((Parser *)parser)->m_declAttributeIsCdata)
-#define freeTagList (((Parser *)parser)->m_freeTagList)
-#define freeBindingList (((Parser *)parser)->m_freeBindingList)
-#define inheritedBindings (((Parser *)parser)->m_inheritedBindings)
-#define tagStack (((Parser *)parser)->m_tagStack)
-#define atts (((Parser *)parser)->m_atts)
-#define attsSize (((Parser *)parser)->m_attsSize)
-#define nSpecifiedAtts (((Parser *)parser)->m_nSpecifiedAtts)
-#define tempPool (((Parser *)parser)->m_tempPool)
-#define temp2Pool (((Parser *)parser)->m_temp2Pool)
-#define groupConnector (((Parser *)parser)->m_groupConnector)
-#define groupSize (((Parser *)parser)->m_groupSize)
-#define hadExternalDoctype (((Parser *)parser)->m_hadExternalDoctype)
-#define namespaceSeparator (((Parser *)parser)->m_namespaceSeparator)
-
-#ifdef _MSC_VER
-#ifdef _DEBUG
-Parser *asParser(XML_Parser parser)
-{
- return parser;
-}
-#endif
-#endif
-
-XML_Parser XML_ParserCreate(const XML_Char *encodingName)
-{
- XML_Parser parser = malloc(sizeof(Parser));
- if (!parser)
- return parser;
- processor = prologInitProcessor;
- XmlPrologStateInit(&prologState);
- userData = 0;
- handlerArg = 0;
- startElementHandler = 0;
- endElementHandler = 0;
- characterDataHandler = 0;
- processingInstructionHandler = 0;
- commentHandler = 0;
- startCdataSectionHandler = 0;
- endCdataSectionHandler = 0;
- defaultHandler = 0;
- unparsedEntityDeclHandler = 0;
- notationDeclHandler = 0;
- startNamespaceDeclHandler = 0;
- endNamespaceDeclHandler = 0;
- notStandaloneHandler = 0;
- externalEntityRefHandler = 0;
- externalEntityRefHandlerArg = parser;
- unknownEncodingHandler = 0;
- buffer = 0;
- bufferPtr = 0;
- bufferEnd = 0;
- parseEndByteIndex = 0;
- parseEndPtr = 0;
- bufferLim = 0;
- declElementType = 0;
- declAttributeId = 0;
- declEntity = 0;
- declNotationName = 0;
- declNotationPublicId = 0;
- memset(&position, 0, sizeof(POSITION));
- errorCode = XML_ERROR_NONE;
- eventPtr = 0;
- eventEndPtr = 0;
- positionPtr = 0;
- openInternalEntities = 0;
- tagLevel = 0;
- tagStack = 0;
- freeTagList = 0;
- freeBindingList = 0;
- inheritedBindings = 0;
- attsSize = INIT_ATTS_SIZE;
- atts = malloc(attsSize * sizeof(ATTRIBUTE));
- nSpecifiedAtts = 0;
- dataBuf = malloc(INIT_DATA_BUF_SIZE * sizeof(XML_Char));
- groupSize = 0;
- groupConnector = 0;
- hadExternalDoctype = 0;
- unknownEncodingMem = 0;
- unknownEncodingRelease = 0;
- unknownEncodingData = 0;
- unknownEncodingHandlerData = 0;
- namespaceSeparator = '!';
- ns = 0;
- poolInit(&tempPool);
- poolInit(&temp2Pool);
- protocolEncodingName = encodingName ? poolCopyString(&tempPool, encodingName) : 0;
- if (!dtdInit(&dtd) || !atts || !dataBuf
- || (encodingName && !protocolEncodingName)) {
- XML_ParserFree(parser);
- return 0;
- }
- dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE;
- XmlInitEncoding(&initEncoding, &encoding, 0);
- return parser;
-}
-
-XML_Parser XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep)
-{
- static
- const XML_Char implicitContext[] = {
- XML_T('x'), XML_T('m'), XML_T('l'), XML_T('='),
- XML_T('h'), XML_T('t'), XML_T('t'), XML_T('p'), XML_T(':'),
- XML_T('/'), XML_T('/'), XML_T('w'), XML_T('w'), XML_T('w'),
- XML_T('.'), XML_T('w'), XML_T('3'),
- XML_T('.'), XML_T('o'), XML_T('r'), XML_T('g'),
- XML_T('/'), XML_T('X'), XML_T('M'), XML_T('L'),
- XML_T('/'), XML_T('1'), XML_T('9'), XML_T('9'), XML_T('8'),
- XML_T('/'), XML_T('n'), XML_T('a'), XML_T('m'), XML_T('e'),
- XML_T('s'), XML_T('p'), XML_T('a'), XML_T('c'), XML_T('e'),
- XML_T('\0')
- };
-
- XML_Parser parser = XML_ParserCreate(encodingName);
- if (parser) {
- XmlInitEncodingNS(&initEncoding, &encoding, 0);
- ns = 1;
- namespaceSeparator = nsSep;
- }
- if (!setContext(parser, implicitContext)) {
- XML_ParserFree(parser);
- return 0;
- }
- return parser;
-}
-
-int XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName)
-{
- if (!encodingName)
- protocolEncodingName = 0;
- else {
- protocolEncodingName = poolCopyString(&tempPool, encodingName);
- if (!protocolEncodingName)
- return 0;
- }
- return 1;
-}
-
-XML_Parser XML_ExternalEntityParserCreate(XML_Parser oldParser,
- const XML_Char *context,
- const XML_Char *encodingName)
-{
- XML_Parser parser = oldParser;
- DTD *oldDtd = &dtd;
- XML_StartElementHandler oldStartElementHandler = startElementHandler;
- XML_EndElementHandler oldEndElementHandler = endElementHandler;
- XML_CharacterDataHandler oldCharacterDataHandler = characterDataHandler;
- XML_ProcessingInstructionHandler oldProcessingInstructionHandler = processingInstructionHandler;
- XML_CommentHandler oldCommentHandler = commentHandler;
- XML_StartCdataSectionHandler oldStartCdataSectionHandler = startCdataSectionHandler;
- XML_EndCdataSectionHandler oldEndCdataSectionHandler = endCdataSectionHandler;
- XML_DefaultHandler oldDefaultHandler = defaultHandler;
- XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler = startNamespaceDeclHandler;
- XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler = endNamespaceDeclHandler;
- XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler;
- XML_ExternalEntityRefHandler oldExternalEntityRefHandler = externalEntityRefHandler;
- XML_UnknownEncodingHandler oldUnknownEncodingHandler = unknownEncodingHandler;
- void *oldUserData = userData;
- void *oldHandlerArg = handlerArg;
- int oldDefaultExpandInternalEntities = defaultExpandInternalEntities;
- void *oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg;
-
- parser = (ns
- ? XML_ParserCreateNS(encodingName, namespaceSeparator)
- : XML_ParserCreate(encodingName));
- if (!parser)
- return 0;
- startElementHandler = oldStartElementHandler;
- endElementHandler = oldEndElementHandler;
- characterDataHandler = oldCharacterDataHandler;
- processingInstructionHandler = oldProcessingInstructionHandler;
- commentHandler = oldCommentHandler;
- startCdataSectionHandler = oldStartCdataSectionHandler;
- endCdataSectionHandler = oldEndCdataSectionHandler;
- defaultHandler = oldDefaultHandler;
- startNamespaceDeclHandler = oldStartNamespaceDeclHandler;
- endNamespaceDeclHandler = oldEndNamespaceDeclHandler;
- notStandaloneHandler = oldNotStandaloneHandler;
- externalEntityRefHandler = oldExternalEntityRefHandler;
- unknownEncodingHandler = oldUnknownEncodingHandler;
- userData = oldUserData;
- if (oldUserData == oldHandlerArg)
- handlerArg = userData;
- else
- handlerArg = parser;
- if (oldExternalEntityRefHandlerArg != oldParser)
- externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg;
- defaultExpandInternalEntities = oldDefaultExpandInternalEntities;
- if (!dtdCopy(&dtd, oldDtd) || !setContext(parser, context)) {
- XML_ParserFree(parser);
- return 0;
- }
- processor = externalEntityInitProcessor;
- return parser;
-}
-
-static
-void destroyBindings(BINDING *bindings)
-{
- for (;;) {
- BINDING *b = bindings;
- if (!b)
- break;
- bindings = b->nextTagBinding;
- free(b->uri);
- free(b);
- }
-}
-
-void XML_ParserFree(XML_Parser parser)
-{
- for (;;) {
- TAG *p;
- if (tagStack == 0) {
- if (freeTagList == 0)
- break;
- tagStack = freeTagList;
- freeTagList = 0;
- }
- p = tagStack;
- tagStack = tagStack->parent;
- free(p->buf);
- destroyBindings(p->bindings);
- free(p);
- }
- destroyBindings(freeBindingList);
- destroyBindings(inheritedBindings);
- poolDestroy(&tempPool);
- poolDestroy(&temp2Pool);
- dtdDestroy(&dtd);
- free((void *)atts);
- free(groupConnector);
- free(buffer);
- free(dataBuf);
- free(unknownEncodingMem);
- if (unknownEncodingRelease)
- unknownEncodingRelease(unknownEncodingData);
- free(parser);
-}
-
-void XML_UseParserAsHandlerArg(XML_Parser parser)
-{
- handlerArg = parser;
-}
-
-void XML_SetUserData(XML_Parser parser, void *p)
-{
- if (handlerArg == userData)
- handlerArg = userData = p;
- else
- userData = p;
-}
-
-int XML_SetBase(XML_Parser parser, const XML_Char *p)
-{
- if (p) {
- p = poolCopyString(&dtd.pool, p);
- if (!p)
- return 0;
- dtd.base = p;
- }
- else
- dtd.base = 0;
- return 1;
-}
-
-const XML_Char *XML_GetBase(XML_Parser parser)
-{
- return dtd.base;
-}
-
-int XML_GetSpecifiedAttributeCount(XML_Parser parser)
-{
- return nSpecifiedAtts;
-}
-
-void XML_SetElementHandler(XML_Parser parser,
- XML_StartElementHandler start,
- XML_EndElementHandler end)
-{
- startElementHandler = start;
- endElementHandler = end;
-}
-
-void XML_SetCharacterDataHandler(XML_Parser parser,
- XML_CharacterDataHandler handler)
-{
- characterDataHandler = handler;
-}
-
-void XML_SetProcessingInstructionHandler(XML_Parser parser,
- XML_ProcessingInstructionHandler handler)
-{
- processingInstructionHandler = handler;
-}
-
-void XML_SetCommentHandler(XML_Parser parser,
- XML_CommentHandler handler)
-{
- commentHandler = handler;
-}
-
-void XML_SetCdataSectionHandler(XML_Parser parser,
- XML_StartCdataSectionHandler start,
- XML_EndCdataSectionHandler end)
-{
- startCdataSectionHandler = start;
- endCdataSectionHandler = end;
-}
-
-void XML_SetDefaultHandler(XML_Parser parser,
- XML_DefaultHandler handler)
-{
- defaultHandler = handler;
- defaultExpandInternalEntities = 0;
-}
-
-void XML_SetDefaultHandlerExpand(XML_Parser parser,
- XML_DefaultHandler handler)
-{
- defaultHandler = handler;
- defaultExpandInternalEntities = 1;
-}
-
-void XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
- XML_UnparsedEntityDeclHandler handler)
-{
- unparsedEntityDeclHandler = handler;
-}
-
-void XML_SetNotationDeclHandler(XML_Parser parser,
- XML_NotationDeclHandler handler)
-{
- notationDeclHandler = handler;
-}
-
-void XML_SetNamespaceDeclHandler(XML_Parser parser,
- XML_StartNamespaceDeclHandler start,
- XML_EndNamespaceDeclHandler end)
-{
- startNamespaceDeclHandler = start;
- endNamespaceDeclHandler = end;
-}
-
-void XML_SetNotStandaloneHandler(XML_Parser parser,
- XML_NotStandaloneHandler handler)
-{
- notStandaloneHandler = handler;
-}
-
-void XML_SetExternalEntityRefHandler(XML_Parser parser,
- XML_ExternalEntityRefHandler handler)
-{
- externalEntityRefHandler = handler;
-}
-
-void XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg)
-{
- if (arg)
- externalEntityRefHandlerArg = arg;
- else
- externalEntityRefHandlerArg = parser;
-}
-
-void XML_SetUnknownEncodingHandler(XML_Parser parser,
- XML_UnknownEncodingHandler handler,
- void *data)
-{
- unknownEncodingHandler = handler;
- unknownEncodingHandlerData = data;
-}
-
-int XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
-{
- if (len == 0) {
- if (!isFinal)
- return 1;
- positionPtr = bufferPtr;
- errorCode = processor(parser, bufferPtr, parseEndPtr = bufferEnd, 0);
- if (errorCode == XML_ERROR_NONE)
- return 1;
- eventEndPtr = eventPtr;
- return 0;
- }
- else if (bufferPtr == bufferEnd) {
- const char *end;
- int nLeftOver;
- parseEndByteIndex += len;
- positionPtr = s;
- if (isFinal) {
- errorCode = processor(parser, s, parseEndPtr = s + len, 0);
- if (errorCode == XML_ERROR_NONE)
- return 1;
- eventEndPtr = eventPtr;
- return 0;
- }
- errorCode = processor(parser, s, parseEndPtr = s + len, &end);
- if (errorCode != XML_ERROR_NONE) {
- eventEndPtr = eventPtr;
- return 0;
- }
- XmlUpdatePosition(encoding, positionPtr, end, &position);
- nLeftOver = s + len - end;
- if (nLeftOver) {
- if (buffer == 0 || nLeftOver > bufferLim - buffer) {
- /* FIXME avoid integer overflow */
- buffer = buffer == 0 ? malloc(len * 2) : realloc(buffer, len * 2);
- if (!buffer) {
- errorCode = XML_ERROR_NO_MEMORY;
- eventPtr = eventEndPtr = 0;
- return 0;
- }
- bufferLim = buffer + len * 2;
- }
- memcpy(buffer, end, nLeftOver);
- bufferPtr = buffer;
- bufferEnd = buffer + nLeftOver;
- }
- return 1;
- }
- else {
- memcpy(XML_GetBuffer(parser, len), s, len);
- return XML_ParseBuffer(parser, len, isFinal);
- }
-}
-
-int XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
-{
- const char *start = bufferPtr;
- positionPtr = start;
- bufferEnd += len;
- parseEndByteIndex += len;
- errorCode = processor(parser, start, parseEndPtr = bufferEnd,
- isFinal ? (const char **)0 : &bufferPtr);
- if (errorCode == XML_ERROR_NONE) {
- if (!isFinal)
- XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position);
- return 1;
- }
- else {
- eventEndPtr = eventPtr;
- return 0;
- }
-}
-
-void *XML_GetBuffer(XML_Parser parser, int len)
-{
- if (len > bufferLim - bufferEnd) {
- /* FIXME avoid integer overflow */
- int neededSize = len + (bufferEnd - bufferPtr);
- if (neededSize <= bufferLim - buffer) {
- memmove(buffer, bufferPtr, bufferEnd - bufferPtr);
- bufferEnd = buffer + (bufferEnd - bufferPtr);
- bufferPtr = buffer;
- }
- else {
- char *newBuf;
- int bufferSize = bufferLim - bufferPtr;
- if (bufferSize == 0)
- bufferSize = INIT_BUFFER_SIZE;
- do {
- bufferSize *= 2;
- } while (bufferSize < neededSize);
- newBuf = malloc(bufferSize);
- if (newBuf == 0) {
- errorCode = XML_ERROR_NO_MEMORY;
- return 0;
- }
- bufferLim = newBuf + bufferSize;
- if (bufferPtr) {
- memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr);
- free(buffer);
- }
- bufferEnd = newBuf + (bufferEnd - bufferPtr);
- bufferPtr = buffer = newBuf;
- }
- }
- return bufferEnd;
-}
-
-enum XML_Error XML_GetErrorCode(XML_Parser parser)
-{
- return errorCode;
-}
-
-long XML_GetCurrentByteIndex(XML_Parser parser)
-{
- if (eventPtr)
- return parseEndByteIndex - (parseEndPtr - eventPtr);
- return -1;
-}
-
-int XML_GetCurrentByteCount(XML_Parser parser)
-{
- if (eventEndPtr && eventPtr)
- return eventEndPtr - eventPtr;
- return 0;
-}
-
-int XML_GetCurrentLineNumber(XML_Parser parser)
-{
- if (eventPtr) {
- XmlUpdatePosition(encoding, positionPtr, eventPtr, &position);
- positionPtr = eventPtr;
- }
- return position.lineNumber + 1;
-}
-
-int XML_GetCurrentColumnNumber(XML_Parser parser)
-{
- if (eventPtr) {
- XmlUpdatePosition(encoding, positionPtr, eventPtr, &position);
- positionPtr = eventPtr;
- }
- return position.columnNumber;
-}
-
-void XML_DefaultCurrent(XML_Parser parser)
-{
- if (defaultHandler) {
- if (openInternalEntities)
- reportDefault(parser,
- ns ? XmlGetInternalEncodingNS() : XmlGetInternalEncoding(),
- openInternalEntities->internalEventPtr,
- openInternalEntities->internalEventEndPtr);
- else
- reportDefault(parser, encoding, eventPtr, eventEndPtr);
- }
-}
-
-const XML_LChar *XML_ErrorString(int code)
-{
- static const XML_LChar *message[] = {
- 0,
- XML_T("out of memory"),
- XML_T("syntax error"),
- XML_T("no element found"),
- XML_T("not well-formed"),
- XML_T("unclosed token"),
- XML_T("unclosed token"),
- XML_T("mismatched tag"),
- XML_T("duplicate attribute"),
- XML_T("junk after document element"),
- XML_T("illegal parameter entity reference"),
- XML_T("undefined entity"),
- XML_T("recursive entity reference"),
- XML_T("asynchronous entity"),
- XML_T("reference to invalid character number"),
- XML_T("reference to binary entity"),
- XML_T("reference to external entity in attribute"),
- XML_T("xml processing instruction not at start of external entity"),
- XML_T("unknown encoding"),
- XML_T("encoding specified in XML declaration is incorrect"),
- XML_T("unclosed CDATA section"),
- XML_T("error in processing external entity reference"),
- XML_T("document is not standalone")
- };
- if (code > 0 && code < sizeof(message)/sizeof(message[0]))
- return message[code];
- return 0;
-}
-
-static
-enum XML_Error contentProcessor(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
- return doContent(parser, 0, encoding, start, end, endPtr);
-}
-
-static
-enum XML_Error externalEntityInitProcessor(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
- enum XML_Error result = initializeEncoding(parser);
- if (result != XML_ERROR_NONE)
- return result;
- processor = externalEntityInitProcessor2;
- return externalEntityInitProcessor2(parser, start, end, endPtr);
-}
-
-static
-enum XML_Error externalEntityInitProcessor2(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
- const char *next;
- int tok = XmlContentTok(encoding, start, end, &next);
- switch (tok) {
- case XML_TOK_BOM:
- start = next;
- break;
- case XML_TOK_PARTIAL:
- if (endPtr) {
- *endPtr = start;
- return XML_ERROR_NONE;
- }
- eventPtr = start;
- return XML_ERROR_UNCLOSED_TOKEN;
- case XML_TOK_PARTIAL_CHAR:
- if (endPtr) {
- *endPtr = start;
- return XML_ERROR_NONE;
- }
- eventPtr = start;
- return XML_ERROR_PARTIAL_CHAR;
- }
- processor = externalEntityInitProcessor3;
- return externalEntityInitProcessor3(parser, start, end, endPtr);
-}
-
-static
-enum XML_Error externalEntityInitProcessor3(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
- const char *next;
- int tok = XmlContentTok(encoding, start, end, &next);
- switch (tok) {
- case XML_TOK_XML_DECL:
- {
- enum XML_Error result = processXmlDecl(parser, 1, start, next);
- if (result != XML_ERROR_NONE)
- return result;
- start = next;
- }
- break;
- case XML_TOK_PARTIAL:
- if (endPtr) {
- *endPtr = start;
- return XML_ERROR_NONE;
- }
- eventPtr = start;
- return XML_ERROR_UNCLOSED_TOKEN;
- case XML_TOK_PARTIAL_CHAR:
- if (endPtr) {
- *endPtr = start;
- return XML_ERROR_NONE;
- }
- eventPtr = start;
- return XML_ERROR_PARTIAL_CHAR;
- }
- processor = externalEntityContentProcessor;
- tagLevel = 1;
- return doContent(parser, 1, encoding, start, end, endPtr);
-}
-
-static
-enum XML_Error externalEntityContentProcessor(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
- return doContent(parser, 1, encoding, start, end, endPtr);
-}
-
-static enum XML_Error
-doContent(XML_Parser parser,
- int startTagLevel,
- const ENCODING *enc,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
- const ENCODING *internalEnc = ns ? XmlGetInternalEncodingNS() : XmlGetInternalEncoding();
- const char **eventPP;
- const char **eventEndPP;
- if (enc == encoding) {
- eventPP = &eventPtr;
- eventEndPP = &eventEndPtr;
- }
- else {
- eventPP = &(openInternalEntities->internalEventPtr);
- eventEndPP = &(openInternalEntities->internalEventEndPtr);
- }
- *eventPP = s;
- for (;;) {
- const char *next = s; /* XmlContentTok doesn't always set the last arg */
- int tok = XmlContentTok(enc, s, end, &next);
- *eventEndPP = next;
- switch (tok) {
- case XML_TOK_TRAILING_CR:
- if (nextPtr) {
- *nextPtr = s;
- return XML_ERROR_NONE;
- }
- *eventEndPP = end;
- if (characterDataHandler) {
- XML_Char c = 0xA;
- characterDataHandler(handlerArg, &c, 1);
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, end);
- if (startTagLevel == 0)
- return XML_ERROR_NO_ELEMENTS;
- if (tagLevel != startTagLevel)
- return XML_ERROR_ASYNC_ENTITY;
- return XML_ERROR_NONE;
- case XML_TOK_NONE:
- if (nextPtr) {
- *nextPtr = s;
- return XML_ERROR_NONE;
- }
- if (startTagLevel > 0) {
- if (tagLevel != startTagLevel)
- return XML_ERROR_ASYNC_ENTITY;
- return XML_ERROR_NONE;
- }
- return XML_ERROR_NO_ELEMENTS;
- case XML_TOK_INVALID:
- *eventPP = next;
- return XML_ERROR_INVALID_TOKEN;
- case XML_TOK_PARTIAL:
- if (nextPtr) {
- *nextPtr = s;
- return XML_ERROR_NONE;
- }
- return XML_ERROR_UNCLOSED_TOKEN;
- case XML_TOK_PARTIAL_CHAR:
- if (nextPtr) {
- *nextPtr = s;
- return XML_ERROR_NONE;
- }
- return XML_ERROR_PARTIAL_CHAR;
- case XML_TOK_ENTITY_REF:
- {
- const XML_Char *name;
- ENTITY *entity;
- XML_Char ch = XmlPredefinedEntityName(enc,
- s + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (ch) {
- if (characterDataHandler)
- characterDataHandler(handlerArg, &ch, 1);
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- break;
- }
- name = poolStoreString(&dtd.pool, enc,
- s + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (!name)
- return XML_ERROR_NO_MEMORY;
- entity = (ENTITY *)lookup(&dtd.generalEntities, name, 0);
- poolDiscard(&dtd.pool);
- if (!entity) {
- if (dtd.complete || dtd.standalone)
- return XML_ERROR_UNDEFINED_ENTITY;
- if (defaultHandler)
- reportDefault(parser, enc, s, next);
- break;
- }
- if (entity->open)
- return XML_ERROR_RECURSIVE_ENTITY_REF;
- if (entity->notation)
- return XML_ERROR_BINARY_ENTITY_REF;
- if (entity) {
- if (entity->textPtr) {
- enum XML_Error result;
- OPEN_INTERNAL_ENTITY openEntity;
- if (defaultHandler && !defaultExpandInternalEntities) {
- reportDefault(parser, enc, s, next);
- break;
- }
- entity->open = 1;
- openEntity.next = openInternalEntities;
- openInternalEntities = &openEntity;
- openEntity.entity = entity;
- openEntity.internalEventPtr = 0;
- openEntity.internalEventEndPtr = 0;
- result = doContent(parser,
- tagLevel,
- internalEnc,
- (char *)entity->textPtr,
- (char *)(entity->textPtr + entity->textLen),
- 0);
- entity->open = 0;
- openInternalEntities = openEntity.next;
- if (result)
- return result;
- }
- else if (externalEntityRefHandler) {
- const XML_Char *context;
- entity->open = 1;
- context = getContext(parser);
- entity->open = 0;
- if (!context)
- return XML_ERROR_NO_MEMORY;
- if (!externalEntityRefHandler(externalEntityRefHandlerArg,
- context,
- dtd.base,
- entity->systemId,
- entity->publicId))
- return XML_ERROR_EXTERNAL_ENTITY_HANDLING;
- poolDiscard(&tempPool);
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- }
- break;
- }
- case XML_TOK_START_TAG_WITH_ATTS:
- if (!startElementHandler) {
- enum XML_Error result = storeAtts(parser, enc, s, 0, 0);
- if (result)
- return result;
- }
- /* fall through */
- case XML_TOK_START_TAG_NO_ATTS:
- {
- TAG *tag;
- if (freeTagList) {
- tag = freeTagList;
- freeTagList = freeTagList->parent;
- }
- else {
- tag = malloc(sizeof(TAG));
- if (!tag)
- return XML_ERROR_NO_MEMORY;
- tag->buf = malloc(INIT_TAG_BUF_SIZE);
- if (!tag->buf)
- return XML_ERROR_NO_MEMORY;
- tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE;
- }
- tag->bindings = 0;
- tag->parent = tagStack;
- tagStack = tag;
- tag->name.localPart = 0;
- tag->rawName = s + enc->minBytesPerChar;
- tag->rawNameLength = XmlNameLength(enc, tag->rawName);
- if (nextPtr) {
- /* Need to guarantee that:
- tag->buf + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)) <= tag->bufEnd - sizeof(XML_Char) */
- if (tag->rawNameLength + (int)(sizeof(XML_Char) - 1) + (int)sizeof(XML_Char) > tag->bufEnd - tag->buf) {
- int bufSize = tag->rawNameLength * 4;
- bufSize = ROUND_UP(bufSize, sizeof(XML_Char));
- tag->buf = realloc(tag->buf, bufSize);
- if (!tag->buf)
- return XML_ERROR_NO_MEMORY;
- tag->bufEnd = tag->buf + bufSize;
- }
- memcpy(tag->buf, tag->rawName, tag->rawNameLength);
- tag->rawName = tag->buf;
- }
- ++tagLevel;
- if (startElementHandler) {
- enum XML_Error result;
- XML_Char *toPtr;
- for (;;) {
- const char *rawNameEnd = tag->rawName + tag->rawNameLength;
- const char *fromPtr = tag->rawName;
- int bufSize;
- if (nextPtr)
- toPtr = (XML_Char *)(tag->buf + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)));
- else
- toPtr = (XML_Char *)tag->buf;
- tag->name.str = toPtr;
- XmlConvert(enc,
- &fromPtr, rawNameEnd,
- (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1);
- if (fromPtr == rawNameEnd)
- break;
- bufSize = (tag->bufEnd - tag->buf) << 1;
- tag->buf = realloc(tag->buf, bufSize);
- if (!tag->buf)
- return XML_ERROR_NO_MEMORY;
- tag->bufEnd = tag->buf + bufSize;
- if (nextPtr)
- tag->rawName = tag->buf;
- }
- *toPtr = XML_T('\0');
- result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings));
- if (result)
- return result;
- startElementHandler(handlerArg, tag->name.str, (const XML_Char **)atts);
- poolClear(&tempPool);
- }
- else {
- tag->name.str = 0;
- if (defaultHandler)
- reportDefault(parser, enc, s, next);
- }
- break;
- }
- case XML_TOK_EMPTY_ELEMENT_WITH_ATTS:
- if (!startElementHandler) {
- enum XML_Error result = storeAtts(parser, enc, s, 0, 0);
- if (result)
- return result;
- }
- /* fall through */
- case XML_TOK_EMPTY_ELEMENT_NO_ATTS:
- if (startElementHandler || endElementHandler) {
- const char *rawName = s + enc->minBytesPerChar;
- enum XML_Error result;
- BINDING *bindings = 0;
- TAG_NAME name;
- name.str = poolStoreString(&tempPool, enc, rawName,
- rawName + XmlNameLength(enc, rawName));
- if (!name.str)
- return XML_ERROR_NO_MEMORY;
- poolFinish(&tempPool);
- result = storeAtts(parser, enc, s, &name, &bindings);
- if (result)
- return result;
- poolFinish(&tempPool);
- if (startElementHandler)
- startElementHandler(handlerArg, name.str, (const XML_Char **)atts);
- if (endElementHandler) {
- if (startElementHandler)
- *eventPP = *eventEndPP;
- endElementHandler(handlerArg, name.str);
- }
- poolClear(&tempPool);
- while (bindings) {
- BINDING *b = bindings;
- if (endNamespaceDeclHandler)
- endNamespaceDeclHandler(handlerArg, b->prefix->name);
- bindings = bindings->nextTagBinding;
- b->nextTagBinding = freeBindingList;
- freeBindingList = b;
- b->prefix->binding = b->prevPrefixBinding;
- }
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- if (tagLevel == 0)
- return epilogProcessor(parser, next, end, nextPtr);
- break;
- case XML_TOK_END_TAG:
- if (tagLevel == startTagLevel)
- return XML_ERROR_ASYNC_ENTITY;
- else {
- int len;
- const char *rawName;
- TAG *tag = tagStack;
- tagStack = tag->parent;
- tag->parent = freeTagList;
- freeTagList = tag;
- rawName = s + enc->minBytesPerChar*2;
- len = XmlNameLength(enc, rawName);
- if (len != tag->rawNameLength
- || memcmp(tag->rawName, rawName, len) != 0) {
- *eventPP = rawName;
- return XML_ERROR_TAG_MISMATCH;
- }
- --tagLevel;
- if (endElementHandler && tag->name.str) {
- if (tag->name.localPart) {
- XML_Char *to = (XML_Char *)tag->name.str + tag->name.uriLen;
- const XML_Char *from = tag->name.localPart;
- while ((*to++ = *from++) != 0)
- ;
- }
- endElementHandler(handlerArg, tag->name.str);
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- while (tag->bindings) {
- BINDING *b = tag->bindings;
- if (endNamespaceDeclHandler)
- endNamespaceDeclHandler(handlerArg, b->prefix->name);
- tag->bindings = tag->bindings->nextTagBinding;
- b->nextTagBinding = freeBindingList;
- freeBindingList = b;
- b->prefix->binding = b->prevPrefixBinding;
- }
- if (tagLevel == 0)
- return epilogProcessor(parser, next, end, nextPtr);
- }
- break;
- case XML_TOK_CHAR_REF:
- {
- int n = XmlCharRefNumber(enc, s);
- if (n < 0)
- return XML_ERROR_BAD_CHAR_REF;
- if (characterDataHandler) {
- XML_Char buf[XML_ENCODE_MAX];
- characterDataHandler(handlerArg, buf, XmlEncode(n, (ICHAR *)buf));
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- }
- break;
- case XML_TOK_XML_DECL:
- return XML_ERROR_MISPLACED_XML_PI;
- case XML_TOK_DATA_NEWLINE:
- if (characterDataHandler) {
- XML_Char c = 0xA;
- characterDataHandler(handlerArg, &c, 1);
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- break;
- case XML_TOK_CDATA_SECT_OPEN:
- {
- enum XML_Error result;
- if (startCdataSectionHandler)
- startCdataSectionHandler(handlerArg);
-#if 0
- /* Suppose you doing a transformation on a document that involves
- changing only the character data. You set up a defaultHandler
- and a characterDataHandler. The defaultHandler simply copies
- characters through. The characterDataHandler does the transformation
- and writes the characters out escaping them as necessary. This case
- will fail to work if we leave out the following two lines (because &
- and < inside CDATA sections will be incorrectly escaped).
-
- However, now we have a start/endCdataSectionHandler, so it seems
- easier to let the user deal with this. */
-
- else if (characterDataHandler)
- characterDataHandler(handlerArg, dataBuf, 0);
-#endif
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- result = doCdataSection(parser, enc, &next, end, nextPtr);
- if (!next) {
- processor = cdataSectionProcessor;
- return result;
- }
- }
- break;
- case XML_TOK_TRAILING_RSQB:
- if (nextPtr) {
- *nextPtr = s;
- return XML_ERROR_NONE;
- }
- if (characterDataHandler) {
- if (MUST_CONVERT(enc, s)) {
- ICHAR *dataPtr = (ICHAR *)dataBuf;
- XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd);
- characterDataHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf);
- }
- else
- characterDataHandler(handlerArg,
- (XML_Char *)s,
- (XML_Char *)end - (XML_Char *)s);
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, end);
- if (startTagLevel == 0) {
- *eventPP = end;
- return XML_ERROR_NO_ELEMENTS;
- }
- if (tagLevel != startTagLevel) {
- *eventPP = end;
- return XML_ERROR_ASYNC_ENTITY;
- }
- return XML_ERROR_NONE;
- case XML_TOK_DATA_CHARS:
- if (characterDataHandler) {
- if (MUST_CONVERT(enc, s)) {
- for (;;) {
- ICHAR *dataPtr = (ICHAR *)dataBuf;
- XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
- *eventEndPP = s;
- characterDataHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf);
- if (s == next)
- break;
- *eventPP = s;
- }
- }
- else
- characterDataHandler(handlerArg,
- (XML_Char *)s,
- (XML_Char *)next - (XML_Char *)s);
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- break;
- case XML_TOK_PI:
- if (!reportProcessingInstruction(parser, enc, s, next))
- return XML_ERROR_NO_MEMORY;
- break;
- case XML_TOK_COMMENT:
- if (!reportComment(parser, enc, s, next))
- return XML_ERROR_NO_MEMORY;
- break;
- default:
- if (defaultHandler)
- reportDefault(parser, enc, s, next);
- break;
- }
- *eventPP = s = next;
- }
- /* not reached */
-}
-
-/* If tagNamePtr is non-null, build a real list of attributes,
-otherwise just check the attributes for well-formedness. */
-
-static enum XML_Error storeAtts(XML_Parser parser, const ENCODING *enc,
- const char *s, TAG_NAME *tagNamePtr,
- BINDING **bindingsPtr)
-{
- ELEMENT_TYPE *elementType = 0;
- int nDefaultAtts = 0;
- const XML_Char **appAtts;
- int attIndex = 0;
- int i;
- int n;
- int nPrefixes = 0;
- BINDING *binding;
- const XML_Char *localPart;
-
- if (tagNamePtr) {
- elementType = (ELEMENT_TYPE *)lookup(&dtd.elementTypes, tagNamePtr->str, 0);
- if (!elementType) {
- tagNamePtr->str = poolCopyString(&dtd.pool, tagNamePtr->str);
- if (!tagNamePtr->str)
- return XML_ERROR_NO_MEMORY;
- elementType = (ELEMENT_TYPE *)lookup(&dtd.elementTypes, tagNamePtr->str, sizeof(ELEMENT_TYPE));
- if (!elementType)
- return XML_ERROR_NO_MEMORY;
- if (ns && !setElementTypePrefix(parser, elementType))
- return XML_ERROR_NO_MEMORY;
- }
- nDefaultAtts = elementType->nDefaultAtts;
- }
- n = XmlGetAttributes(enc, s, attsSize, atts);
- if (n + nDefaultAtts > attsSize) {
- int oldAttsSize = attsSize;
- attsSize = n + nDefaultAtts + INIT_ATTS_SIZE;
- atts = realloc((void *)atts, attsSize * sizeof(ATTRIBUTE));
- if (!atts)
- return XML_ERROR_NO_MEMORY;
- if (n > oldAttsSize)
- XmlGetAttributes(enc, s, n, atts);
- }
- appAtts = (const XML_Char **)atts;
- for (i = 0; i < n; i++) {
- ATTRIBUTE_ID *attId = getAttributeId(parser, enc, atts[i].name,
- atts[i].name
- + XmlNameLength(enc, atts[i].name));
- if (!attId)
- return XML_ERROR_NO_MEMORY;
- if ((attId->name)[-1]) {
- if (enc == encoding)
- eventPtr = atts[i].name;
- return XML_ERROR_DUPLICATE_ATTRIBUTE;
- }
- (attId->name)[-1] = 1;
- appAtts[attIndex++] = attId->name;
- if (!atts[i].normalized) {
- enum XML_Error result;
- int isCdata = 1;
-
- if (attId->maybeTokenized) {
- int j;
- for (j = 0; j < nDefaultAtts; j++) {
- if (attId == elementType->defaultAtts[j].id) {
- isCdata = elementType->defaultAtts[j].isCdata;
- break;
- }
- }
- }
-
- result = storeAttributeValue(parser, enc, isCdata,
- atts[i].valuePtr, atts[i].valueEnd,
- &tempPool);
- if (result)
- return result;
- if (tagNamePtr) {
- appAtts[attIndex] = poolStart(&tempPool);
- poolFinish(&tempPool);
- }
- else
- poolDiscard(&tempPool);
- }
- else if (tagNamePtr) {
- appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr, atts[i].valueEnd);
- if (appAtts[attIndex] == 0)
- return XML_ERROR_NO_MEMORY;
- poolFinish(&tempPool);
- }
- if (attId->prefix && tagNamePtr) {
- if (attId->xmlns) {
- if (!addBinding(parser, attId->prefix, attId, appAtts[attIndex], bindingsPtr))
- return XML_ERROR_NO_MEMORY;
- --attIndex;
- }
- else {
- attIndex++;
- nPrefixes++;
- (attId->name)[-1] = 2;
- }
- }
- else
- attIndex++;
- }
- nSpecifiedAtts = attIndex;
- if (tagNamePtr) {
- int j;
- for (j = 0; j < nDefaultAtts; j++) {
- const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + j;
- if (!(da->id->name)[-1] && da->value) {
- if (da->id->prefix) {
- if (da->id->xmlns) {
- if (!addBinding(parser, da->id->prefix, da->id, da->value, bindingsPtr))
- return XML_ERROR_NO_MEMORY;
- }
- else {
- (da->id->name)[-1] = 2;
- nPrefixes++;
- appAtts[attIndex++] = da->id->name;
- appAtts[attIndex++] = da->value;
- }
- }
- else {
- (da->id->name)[-1] = 1;
- appAtts[attIndex++] = da->id->name;
- appAtts[attIndex++] = da->value;
- }
- }
- }
- appAtts[attIndex] = 0;
- }
- i = 0;
- if (nPrefixes) {
- for (; i < attIndex; i += 2) {
- if (appAtts[i][-1] == 2) {
- ATTRIBUTE_ID *id;
- ((XML_Char *)(appAtts[i]))[-1] = 0;
- id = (ATTRIBUTE_ID *)lookup(&dtd.attributeIds, appAtts[i], 0);
- if (id->prefix->binding) {
- int j;
- const BINDING *b = id->prefix->binding;
- const XML_Char *ss = appAtts[i];
- for (j = 0; j < b->uriLen; j++) {
- if (!poolAppendChar(&tempPool, b->uri[j]))
- return XML_ERROR_NO_MEMORY;
- }
- while (*ss++ != ':')
- ;
- do {
- if (!poolAppendChar(&tempPool, *ss))
- return XML_ERROR_NO_MEMORY;
- } while (*ss++);
- appAtts[i] = poolStart(&tempPool);
- poolFinish(&tempPool);
- }
- if (!--nPrefixes)
- break;
- }
- else
- ((XML_Char *)(appAtts[i]))[-1] = 0;
- }
- }
- for (; i < attIndex; i += 2)
- ((XML_Char *)(appAtts[i]))[-1] = 0;
- if (!tagNamePtr)
- return XML_ERROR_NONE;
- for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding)
- binding->attId->name[-1] = 0;
- if (elementType->prefix) {
- binding = elementType->prefix->binding;
- if (!binding)
- return XML_ERROR_NONE;
- localPart = tagNamePtr->str;
- while (*localPart++ != XML_T(':'))
- ;
- }
- else if (dtd.defaultPrefix.binding) {
- binding = dtd.defaultPrefix.binding;
- localPart = tagNamePtr->str;
- }
- else
- return XML_ERROR_NONE;
- tagNamePtr->localPart = localPart;
- tagNamePtr->uriLen = binding->uriLen;
- i = binding->uriLen;
- do {
- if (i == binding->uriAlloc) {
- binding->uri = realloc(binding->uri, binding->uriAlloc *= 2);
- if (!binding->uri)
- return XML_ERROR_NO_MEMORY;
- }
- binding->uri[i++] = *localPart;
- } while (*localPart++);
- tagNamePtr->str = binding->uri;
- return XML_ERROR_NONE;
-}
-
-static
-int addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, const XML_Char *uri, BINDING **bindingsPtr)
-{
- BINDING *b;
- int len;
- for (len = 0; uri[len]; len++)
- ;
- if (namespaceSeparator)
- len++;
- if (freeBindingList) {
- b = freeBindingList;
- if (len > b->uriAlloc) {
- b->uri = realloc(b->uri, len + EXPAND_SPARE);
- if (!b->uri)
- return 0;
- b->uriAlloc = len + EXPAND_SPARE;
- }
- freeBindingList = b->nextTagBinding;
- }
- else {
- b = malloc(sizeof(BINDING));
- if (!b)
- return 0;
- b->uri = malloc(sizeof(XML_Char) * len + EXPAND_SPARE);
- if (!b->uri) {
- free(b);
- return 0;
- }
- b->uriAlloc = len;
- }
- b->uriLen = len;
- memcpy(b->uri, uri, len * sizeof(XML_Char));
- if (namespaceSeparator)
- b->uri[len - 1] = namespaceSeparator;
- b->prefix = prefix;
- b->attId = attId;
- b->prevPrefixBinding = prefix->binding;
- if (*uri == XML_T('\0') && prefix == &dtd.defaultPrefix)
- prefix->binding = 0;
- else
- prefix->binding = b;
- b->nextTagBinding = *bindingsPtr;
- *bindingsPtr = b;
- if (startNamespaceDeclHandler)
- startNamespaceDeclHandler(handlerArg, prefix->name,
- prefix->binding ? uri : 0);
- return 1;
-}
-
-/* The idea here is to avoid using stack for each CDATA section when
-the whole file is parsed with one call. */
-
-static
-enum XML_Error cdataSectionProcessor(XML_Parser parser,
- const char *start,
- const char *end,
- const char **endPtr)
-{
- enum XML_Error result = doCdataSection(parser, encoding, &start, end, endPtr);
- if (start) {
- processor = contentProcessor;
- return contentProcessor(parser, start, end, endPtr);
- }
- return result;
-}
-
-/* startPtr gets set to non-null is the section is closed, and to null if
-the section is not yet closed. */
-
-static
-enum XML_Error doCdataSection(XML_Parser parser,
- const ENCODING *enc,
- const char **startPtr,
- const char *end,
- const char **nextPtr)
-{
- const char *s = *startPtr;
- const char **eventPP;
- const char **eventEndPP;
- if (enc == encoding) {
- eventPP = &eventPtr;
- *eventPP = s;
- eventEndPP = &eventEndPtr;
- }
- else {
- eventPP = &(openInternalEntities->internalEventPtr);
- eventEndPP = &(openInternalEntities->internalEventEndPtr);
- }
- *eventPP = s;
- *startPtr = 0;
- for (;;) {
- const char *next;
- int tok = XmlCdataSectionTok(enc, s, end, &next);
- *eventEndPP = next;
- switch (tok) {
- case XML_TOK_CDATA_SECT_CLOSE:
- if (endCdataSectionHandler)
- endCdataSectionHandler(handlerArg);
-#if 0
- /* see comment under XML_TOK_CDATA_SECT_OPEN */
- else if (characterDataHandler)
- characterDataHandler(handlerArg, dataBuf, 0);
-#endif
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- *startPtr = next;
- return XML_ERROR_NONE;
- case XML_TOK_DATA_NEWLINE:
- if (characterDataHandler) {
- XML_Char c = 0xA;
- characterDataHandler(handlerArg, &c, 1);
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- break;
- case XML_TOK_DATA_CHARS:
- if (characterDataHandler) {
- if (MUST_CONVERT(enc, s)) {
- for (;;) {
- ICHAR *dataPtr = (ICHAR *)dataBuf;
- XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd);
- *eventEndPP = next;
- characterDataHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf);
- if (s == next)
- break;
- *eventPP = s;
- }
- }
- else
- characterDataHandler(handlerArg,
- (XML_Char *)s,
- (XML_Char *)next - (XML_Char *)s);
- }
- else if (defaultHandler)
- reportDefault(parser, enc, s, next);
- break;
- case XML_TOK_INVALID:
- *eventPP = next;
- return XML_ERROR_INVALID_TOKEN;
- case XML_TOK_PARTIAL_CHAR:
- if (nextPtr) {
- *nextPtr = s;
- return XML_ERROR_NONE;
- }
- return XML_ERROR_PARTIAL_CHAR;
- case XML_TOK_PARTIAL:
- case XML_TOK_NONE:
- if (nextPtr) {
- *nextPtr = s;
- return XML_ERROR_NONE;
- }
- return XML_ERROR_UNCLOSED_CDATA_SECTION;
- default:
- abort();
- }
- *eventPP = s = next;
- }
- /* not reached */
-}
-
-static enum XML_Error
-initializeEncoding(XML_Parser parser)
-{
- const char *s;
-#ifdef XML_UNICODE
- char encodingBuf[128];
- if (!protocolEncodingName)
- s = 0;
- else {
- int i;
- for (i = 0; protocolEncodingName[i]; i++) {
- if (i == sizeof(encodingBuf) - 1
- || protocolEncodingName[i] >= 0x80
- || protocolEncodingName[i] < 0) {
- encodingBuf[0] = '\0';
- break;
- }
- encodingBuf[i] = (char)protocolEncodingName[i];
- }
- encodingBuf[i] = '\0';
- s = encodingBuf;
- }
-#else
- s = protocolEncodingName;
-#endif
- if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s))
- return XML_ERROR_NONE;
- return handleUnknownEncoding(parser, protocolEncodingName);
-}
-
-static enum XML_Error
-processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
- const char *s, const char *next)
-{
- const char *encodingName = 0;
- const ENCODING *newEncoding = 0;
- const char *version;
- int standalone = -1;
- if (!(ns
- ? XmlParseXmlDeclNS
- : XmlParseXmlDecl)(isGeneralTextEntity,
- encoding,
- s,
- next,
- &eventPtr,
- &version,
- &encodingName,
- &newEncoding,
- &standalone))
- return XML_ERROR_SYNTAX;
- if (!isGeneralTextEntity && standalone == 1)
- dtd.standalone = 1;
- if (defaultHandler)
- reportDefault(parser, encoding, s, next);
- if (!protocolEncodingName) {
- if (newEncoding) {
- if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) {
- eventPtr = encodingName;
- return XML_ERROR_INCORRECT_ENCODING;
- }
- encoding = newEncoding;
- }
- else if (encodingName) {
- enum XML_Error result;
- const XML_Char *ss = poolStoreString(&tempPool,
- encoding,
- encodingName,
- encodingName
- + XmlNameLength(encoding, encodingName));
- if (!ss)
- return XML_ERROR_NO_MEMORY;
- result = handleUnknownEncoding(parser, ss);
- poolDiscard(&tempPool);
- if (result == XML_ERROR_UNKNOWN_ENCODING)
- eventPtr = encodingName;
- return result;
- }
- }
- return XML_ERROR_NONE;
-}
-
-static enum XML_Error
-handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName)
-{
- if (unknownEncodingHandler) {
- XML_Encoding info;
- int i;
- for (i = 0; i < 256; i++)
- info.map[i] = -1;
- info.convert = 0;
- info.data = 0;
- info.release = 0;
- if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName, &info)) {
- ENCODING *enc;
- unknownEncodingMem = malloc(XmlSizeOfUnknownEncoding());
- if (!unknownEncodingMem) {
- if (info.release)
- info.release(info.data);
- return XML_ERROR_NO_MEMORY;
- }
- enc = (ns
- ? XmlInitUnknownEncodingNS
- : XmlInitUnknownEncoding)(unknownEncodingMem,
- info.map,
- info.convert,
- info.data);
- if (enc) {
- unknownEncodingData = info.data;
- unknownEncodingRelease = info.release;
- encoding = enc;
- return XML_ERROR_NONE;
- }
- }
- if (info.release)
- info.release(info.data);
- }
- return XML_ERROR_UNKNOWN_ENCODING;
-}
-
-static enum XML_Error
-prologInitProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
- enum XML_Error result = initializeEncoding(parser);
- if (result != XML_ERROR_NONE)
- return result;
- processor = prologProcessor;
- return prologProcessor(parser, s, end, nextPtr);
-}
-
-static enum XML_Error
-prologProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
- for (;;) {
- const char *next;
- int tok = XmlPrologTok(encoding, s, end, &next);
- if (tok <= 0) {
- if (nextPtr != 0 && tok != XML_TOK_INVALID) {
- *nextPtr = s;
- return XML_ERROR_NONE;
- }
- switch (tok) {
- case XML_TOK_INVALID:
- eventPtr = next;
- return XML_ERROR_INVALID_TOKEN;
- case XML_TOK_NONE:
- return XML_ERROR_NO_ELEMENTS;
- case XML_TOK_PARTIAL:
- return XML_ERROR_UNCLOSED_TOKEN;
- case XML_TOK_PARTIAL_CHAR:
- return XML_ERROR_PARTIAL_CHAR;
- case XML_TOK_TRAILING_CR:
- eventPtr = s + encoding->minBytesPerChar;
- return XML_ERROR_NO_ELEMENTS;
- default:
- abort();
- }
- }
- switch (XmlTokenRole(&prologState, tok, s, next, encoding)) {
- case XML_ROLE_XML_DECL:
- {
- enum XML_Error result = processXmlDecl(parser, 0, s, next);
- if (result != XML_ERROR_NONE)
- return result;
- }
- break;
- case XML_ROLE_DOCTYPE_SYSTEM_ID:
- if (!dtd.standalone
- && notStandaloneHandler
- && !notStandaloneHandler(handlerArg))
- return XML_ERROR_NOT_STANDALONE;
- hadExternalDoctype = 1;
- break;
- case XML_ROLE_DOCTYPE_PUBLIC_ID:
- case XML_ROLE_ENTITY_PUBLIC_ID:
- if (!XmlIsPublicId(encoding, s, next, &eventPtr))
- return XML_ERROR_SYNTAX;
- if (declEntity) {
- XML_Char *tem = poolStoreString(&dtd.pool,
- encoding,
- s + encoding->minBytesPerChar,
- next - encoding->minBytesPerChar);
- if (!tem)
- return XML_ERROR_NO_MEMORY;
- normalizePublicId(tem);
- declEntity->publicId = tem;
- poolFinish(&dtd.pool);
- }
- break;
- case XML_ROLE_INSTANCE_START:
- processor = contentProcessor;
- if (hadExternalDoctype)
- dtd.complete = 0;
- return contentProcessor(parser, s, end, nextPtr);
- case XML_ROLE_ATTLIST_ELEMENT_NAME:
- {
- const XML_Char *name = poolStoreString(&dtd.pool, encoding, s, next);
- if (!name)
- return XML_ERROR_NO_MEMORY;
- declElementType = (ELEMENT_TYPE *)lookup(&dtd.elementTypes, name, sizeof(ELEMENT_TYPE));
- if (!declElementType)
- return XML_ERROR_NO_MEMORY;
- if (declElementType->name != name)
- poolDiscard(&dtd.pool);
- else {
- poolFinish(&dtd.pool);
- if (!setElementTypePrefix(parser, declElementType))
- return XML_ERROR_NO_MEMORY;
- }
- break;
- }
- case XML_ROLE_ATTRIBUTE_NAME:
- declAttributeId = getAttributeId(parser, encoding, s, next);
- if (!declAttributeId)
- return XML_ERROR_NO_MEMORY;
- declAttributeIsCdata = 0;
- break;
- case XML_ROLE_ATTRIBUTE_TYPE_CDATA:
- declAttributeIsCdata = 1;
- break;
- case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE:
- case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE:
- if (dtd.complete
- && !defineAttribute(declElementType, declAttributeId, declAttributeIsCdata, 0))
- return XML_ERROR_NO_MEMORY;
- break;
- case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE:
- case XML_ROLE_FIXED_ATTRIBUTE_VALUE:
- {
- const XML_Char *attVal;
- enum XML_Error result
- = storeAttributeValue(parser, encoding, declAttributeIsCdata,
- s + encoding->minBytesPerChar,
- next - encoding->minBytesPerChar,
- &dtd.pool);
- if (result)
- return result;
- attVal = poolStart(&dtd.pool);
- poolFinish(&dtd.pool);
- if (dtd.complete
- && !defineAttribute(declElementType, declAttributeId, declAttributeIsCdata, attVal))
- return XML_ERROR_NO_MEMORY;
- break;
- }
- case XML_ROLE_ENTITY_VALUE:
- {
- enum XML_Error result = storeEntityValue(parser, s, next);
- if (result != XML_ERROR_NONE)
- return result;
- }
- break;
- case XML_ROLE_ENTITY_SYSTEM_ID:
- if (declEntity) {
- declEntity->systemId = poolStoreString(&dtd.pool, encoding,
- s + encoding->minBytesPerChar,
- next - encoding->minBytesPerChar);
- if (!declEntity->systemId)
- return XML_ERROR_NO_MEMORY;
- declEntity->base = dtd.base;
- poolFinish(&dtd.pool);
- }
- break;
- case XML_ROLE_ENTITY_NOTATION_NAME:
- if (declEntity) {
- declEntity->notation = poolStoreString(&dtd.pool, encoding, s, next);
- if (!declEntity->notation)
- return XML_ERROR_NO_MEMORY;
- poolFinish(&dtd.pool);
- if (unparsedEntityDeclHandler) {
- eventPtr = eventEndPtr = s;
- unparsedEntityDeclHandler(handlerArg,
- declEntity->name,
- declEntity->base,
- declEntity->systemId,
- declEntity->publicId,
- declEntity->notation);
- }
-
- }
- break;
- case XML_ROLE_GENERAL_ENTITY_NAME:
- {
- const XML_Char *name;
- if (XmlPredefinedEntityName(encoding, s, next)) {
- declEntity = 0;
- break;
- }
- name = poolStoreString(&dtd.pool, encoding, s, next);
- if (!name)
- return XML_ERROR_NO_MEMORY;
- if (dtd.complete) {
- declEntity = (ENTITY *)lookup(&dtd.generalEntities, name, sizeof(ENTITY));
- if (!declEntity)
- return XML_ERROR_NO_MEMORY;
- if (declEntity->name != name) {
- poolDiscard(&dtd.pool);
- declEntity = 0;
- }
- else
- poolFinish(&dtd.pool);
- }
- else {
- poolDiscard(&dtd.pool);
- declEntity = 0;
- }
- }
- break;
- case XML_ROLE_PARAM_ENTITY_NAME:
- declEntity = 0;
- break;
- case XML_ROLE_NOTATION_NAME:
- declNotationPublicId = 0;
- declNotationName = 0;
- if (notationDeclHandler) {
- declNotationName = poolStoreString(&tempPool, encoding, s, next);
- if (!declNotationName)
- return XML_ERROR_NO_MEMORY;
- poolFinish(&tempPool);
- }
- break;
- case XML_ROLE_NOTATION_PUBLIC_ID:
- if (!XmlIsPublicId(encoding, s, next, &eventPtr))
- return XML_ERROR_SYNTAX;
- if (declNotationName) {
- XML_Char *tem = poolStoreString(&tempPool,
- encoding,
- s + encoding->minBytesPerChar,
- next - encoding->minBytesPerChar);
- if (!tem)
- return XML_ERROR_NO_MEMORY;
- normalizePublicId(tem);
- declNotationPublicId = tem;
- poolFinish(&tempPool);
- }
- break;
- case XML_ROLE_NOTATION_SYSTEM_ID:
- if (declNotationName && notationDeclHandler) {
- const XML_Char *systemId
- = poolStoreString(&tempPool, encoding,
- s + encoding->minBytesPerChar,
- next - encoding->minBytesPerChar);
- if (!systemId)
- return XML_ERROR_NO_MEMORY;
- eventPtr = eventEndPtr = s;
- notationDeclHandler(handlerArg,
- declNotationName,
- dtd.base,
- systemId,
- declNotationPublicId);
- }
- poolClear(&tempPool);
- break;
- case XML_ROLE_NOTATION_NO_SYSTEM_ID:
- if (declNotationPublicId && notationDeclHandler) {
- eventPtr = eventEndPtr = s;
- notationDeclHandler(handlerArg,
- declNotationName,
- dtd.base,
- 0,
- declNotationPublicId);
- }
- poolClear(&tempPool);
- break;
- case XML_ROLE_ERROR:
- eventPtr = s;
- switch (tok) {
- case XML_TOK_PARAM_ENTITY_REF:
- return XML_ERROR_PARAM_ENTITY_REF;
- case XML_TOK_XML_DECL:
- return XML_ERROR_MISPLACED_XML_PI;
- default:
- return XML_ERROR_SYNTAX;
- }
- case XML_ROLE_GROUP_OPEN:
- if (prologState.level >= groupSize) {
- if (groupSize)
- groupConnector = realloc(groupConnector, groupSize *= 2);
- else
- groupConnector = malloc(groupSize = 32);
- if (!groupConnector)
- return XML_ERROR_NO_MEMORY;
- }
- groupConnector[prologState.level] = 0;
- break;
- case XML_ROLE_GROUP_SEQUENCE:
- if (groupConnector[prologState.level] == '|') {
- eventPtr = s;
- return XML_ERROR_SYNTAX;
- }
- groupConnector[prologState.level] = ',';
- break;
- case XML_ROLE_GROUP_CHOICE:
- if (groupConnector[prologState.level] == ',') {
- eventPtr = s;
- return XML_ERROR_SYNTAX;
- }
- groupConnector[prologState.level] = '|';
- break;
- case XML_ROLE_PARAM_ENTITY_REF:
- if (!dtd.standalone
- && notStandaloneHandler
- && !notStandaloneHandler(handlerArg))
- return XML_ERROR_NOT_STANDALONE;
- dtd.complete = 0;
- break;
- case XML_ROLE_NONE:
- switch (tok) {
- case XML_TOK_PI:
- eventPtr = s;
- eventEndPtr = next;
- if (!reportProcessingInstruction(parser, encoding, s, next))
- return XML_ERROR_NO_MEMORY;
- break;
- case XML_TOK_COMMENT:
- eventPtr = s;
- eventEndPtr = next;
- if (!reportComment(parser, encoding, s, next))
- return XML_ERROR_NO_MEMORY;
- break;
- }
- break;
- }
- if (defaultHandler) {
- switch (tok) {
- case XML_TOK_PI:
- case XML_TOK_COMMENT:
- case XML_TOK_BOM:
- case XML_TOK_XML_DECL:
- break;
- default:
- eventPtr = s;
- eventEndPtr = next;
- reportDefault(parser, encoding, s, next);
- }
- }
- s = next;
- }
- /* not reached */
-}
-
-static
-enum XML_Error epilogProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
- processor = epilogProcessor;
- eventPtr = s;
- for (;;) {
- const char *next;
- int tok = XmlPrologTok(encoding, s, end, &next);
- eventEndPtr = next;
- switch (tok) {
- case XML_TOK_TRAILING_CR:
- if (defaultHandler) {
- eventEndPtr = end;
- reportDefault(parser, encoding, s, end);
- }
- /* fall through */
- case XML_TOK_NONE:
- if (nextPtr)
- *nextPtr = end;
- return XML_ERROR_NONE;
- case XML_TOK_PROLOG_S:
- if (defaultHandler)
- reportDefault(parser, encoding, s, next);
- break;
- case XML_TOK_PI:
- if (!reportProcessingInstruction(parser, encoding, s, next))
- return XML_ERROR_NO_MEMORY;
- break;
- case XML_TOK_COMMENT:
- if (!reportComment(parser, encoding, s, next))
- return XML_ERROR_NO_MEMORY;
- break;
- case XML_TOK_INVALID:
- eventPtr = next;
- return XML_ERROR_INVALID_TOKEN;
- case XML_TOK_PARTIAL:
- if (nextPtr) {
- *nextPtr = s;
- return XML_ERROR_NONE;
- }
- return XML_ERROR_UNCLOSED_TOKEN;
- case XML_TOK_PARTIAL_CHAR:
- if (nextPtr) {
- *nextPtr = s;
- return XML_ERROR_NONE;
- }
- return XML_ERROR_PARTIAL_CHAR;
- default:
- return XML_ERROR_JUNK_AFTER_DOC_ELEMENT;
- }
- eventPtr = s = next;
- }
-}
-
-#if 0
-static
-enum XML_Error errorProcessor(XML_Parser parser,
- const char *s,
- const char *end,
- const char **nextPtr)
-{
- return errorCode;
-}
-#endif
-
-static enum XML_Error
-storeAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata,
- const char *ptr, const char *end,
- STRING_POOL *pool)
-{
- enum XML_Error result = appendAttributeValue(parser, enc, isCdata, ptr, end, pool);
- if (result)
- return result;
- if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20)
- poolChop(pool);
- if (!poolAppendChar(pool, XML_T('\0')))
- return XML_ERROR_NO_MEMORY;
- return XML_ERROR_NONE;
-}
-
-static enum XML_Error
-appendAttributeValue(XML_Parser parser, const ENCODING *enc, int isCdata,
- const char *ptr, const char *end,
- STRING_POOL *pool)
-{
- const ENCODING *internalEnc = ns ? XmlGetInternalEncodingNS() : XmlGetInternalEncoding();
- for (;;) {
- const char *next;
- int tok = XmlAttributeValueTok(enc, ptr, end, &next);
- switch (tok) {
- case XML_TOK_NONE:
- return XML_ERROR_NONE;
- case XML_TOK_INVALID:
- if (enc == encoding)
- eventPtr = next;
- return XML_ERROR_INVALID_TOKEN;
- case XML_TOK_PARTIAL:
- if (enc == encoding)
- eventPtr = ptr;
- return XML_ERROR_INVALID_TOKEN;
- case XML_TOK_CHAR_REF:
- {
- XML_Char buf[XML_ENCODE_MAX];
- int i;
- int n = XmlCharRefNumber(enc, ptr);
- if (n < 0) {
- if (enc == encoding)
- eventPtr = ptr;
- return XML_ERROR_BAD_CHAR_REF;
- }
- if (!isCdata
- && n == 0x20 /* space */
- && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20))
- break;
- n = XmlEncode(n, (ICHAR *)buf);
- if (!n) {
- if (enc == encoding)
- eventPtr = ptr;
- return XML_ERROR_BAD_CHAR_REF;
- }
- for (i = 0; i < n; i++) {
- if (!poolAppendChar(pool, buf[i]))
- return XML_ERROR_NO_MEMORY;
- }
- }
- break;
- case XML_TOK_DATA_CHARS:
- if (!poolAppend(pool, enc, ptr, next))
- return XML_ERROR_NO_MEMORY;
- break;
- break;
- case XML_TOK_TRAILING_CR:
- next = ptr + enc->minBytesPerChar;
- /* fall through */
- case XML_TOK_ATTRIBUTE_VALUE_S:
- case XML_TOK_DATA_NEWLINE:
- if (!isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20))
- break;
- if (!poolAppendChar(pool, 0x20))
- return XML_ERROR_NO_MEMORY;
- break;
- case XML_TOK_ENTITY_REF:
- {
- const XML_Char *name;
- ENTITY *entity;
- XML_Char ch = XmlPredefinedEntityName(enc,
- ptr + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (ch) {
- if (!poolAppendChar(pool, ch))
- return XML_ERROR_NO_MEMORY;
- break;
- }
- name = poolStoreString(&temp2Pool, enc,
- ptr + enc->minBytesPerChar,
- next - enc->minBytesPerChar);
- if (!name)
- return XML_ERROR_NO_MEMORY;
- entity = (ENTITY *)lookup(&dtd.generalEntities, name, 0);
- poolDiscard(&temp2Pool);
- if (!entity) {
- if (dtd.complete) {
- if (enc == encoding)
- eventPtr = ptr;
- return XML_ERROR_UNDEFINED_ENTITY;
- }
- }
- else if (entity->open) {
- if (enc == encoding)
- eventPtr = ptr;
- return XML_ERROR_RECURSIVE_ENTITY_REF;
- }
- else if (entity->notation) {
- if (enc == encoding)
- eventPtr = ptr;
- return XML_ERROR_BINARY_ENTITY_REF;
- }
- else if (!entity->textPtr) {
- if (enc == encoding)
- eventPtr = ptr;
- return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF;
- }
- else {
- enum XML_Error result;
- const XML_Char *textEnd = entity->textPtr + entity->textLen;
- entity->open = 1;
- result = appendAttributeValue(parser, internalEnc, isCdata, (char *)entity->textPtr, (char *)textEnd, pool);
- entity->open = 0;
- if (result)
- return result;
- }
- }
- break;
- default:
- abort();
- }
- ptr = next;
- }
- /* not reached */
-}
-
-static
-enum XML_Error storeEntityValue(XML_Parser parser,
- const char *entityTextPtr,
- const char *entityTextEnd)
-{
-#if 0
- const ENCODING *internalEnc = ns ? XmlGetInternalEncodingNS() : XmlGetInternalEncoding();
-#endif
- STRING_POOL *pool = &(dtd.pool);
- entityTextPtr += encoding->minBytesPerChar;
- entityTextEnd -= encoding->minBytesPerChar;
- for (;;) {
- const char *next;
- int tok = XmlEntityValueTok(encoding, entityTextPtr, entityTextEnd, &next);
- switch (tok) {
- case XML_TOK_PARAM_ENTITY_REF:
- eventPtr = entityTextPtr;
- return XML_ERROR_SYNTAX;
- case XML_TOK_NONE:
- if (declEntity) {
- declEntity->textPtr = pool->start;
- declEntity->textLen = pool->ptr - pool->start;
- poolFinish(pool);
- }
- else
- poolDiscard(pool);
- return XML_ERROR_NONE;
- case XML_TOK_ENTITY_REF:
- case XML_TOK_DATA_CHARS:
- if (!poolAppend(pool, encoding, entityTextPtr, next))
- return XML_ERROR_NO_MEMORY;
- break;
- case XML_TOK_TRAILING_CR:
- next = entityTextPtr + encoding->minBytesPerChar;
- /* fall through */
- case XML_TOK_DATA_NEWLINE:
- if (pool->end == pool->ptr && !poolGrow(pool))
- return XML_ERROR_NO_MEMORY;
- *(pool->ptr)++ = 0xA;
- break;
- case XML_TOK_CHAR_REF:
- {
- XML_Char buf[XML_ENCODE_MAX];
- int i;
- int n = XmlCharRefNumber(encoding, entityTextPtr);
- if (n < 0) {
- eventPtr = entityTextPtr;
- return XML_ERROR_BAD_CHAR_REF;
- }
- n = XmlEncode(n, (ICHAR *)buf);
- if (!n) {
- eventPtr = entityTextPtr;
- return XML_ERROR_BAD_CHAR_REF;
- }
- for (i = 0; i < n; i++) {
- if (pool->end == pool->ptr && !poolGrow(pool))
- return XML_ERROR_NO_MEMORY;
- *(pool->ptr)++ = buf[i];
- }
- }
- break;
- case XML_TOK_PARTIAL:
- eventPtr = entityTextPtr;
- return XML_ERROR_INVALID_TOKEN;
- case XML_TOK_INVALID:
- eventPtr = next;
- return XML_ERROR_INVALID_TOKEN;
- default:
- abort();
- }
- entityTextPtr = next;
- }
- /* not reached */
-}
-
-static void
-normalizeLines(XML_Char *s)
-{
- XML_Char *p;
- for (;; s++) {
- if (*s == XML_T('\0'))
- return;
- if (*s == 0xD)
- break;
- }
- p = s;
- do {
- if (*s == 0xD) {
- *p++ = 0xA;
- if (*++s == 0xA)
- s++;
- }
- else
- *p++ = *s++;
- } while (*s);
- *p = XML_T('\0');
-}
-
-static int
-reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, const char *start, const char *end)
-{
- const XML_Char *target;
- XML_Char *data;
- const char *tem;
- if (!processingInstructionHandler) {
- if (defaultHandler)
- reportDefault(parser, enc, start, end);
- return 1;
- }
- start += enc->minBytesPerChar * 2;
- tem = start + XmlNameLength(enc, start);
- target = poolStoreString(&tempPool, enc, start, tem);
- if (!target)
- return 0;
- poolFinish(&tempPool);
- data = poolStoreString(&tempPool, enc,
- XmlSkipS(enc, tem),
- end - enc->minBytesPerChar*2);
- if (!data)
- return 0;
- normalizeLines(data);
- processingInstructionHandler(handlerArg, target, data);
- poolClear(&tempPool);
- return 1;
-}
-
-static int
-reportComment(XML_Parser parser, const ENCODING *enc, const char *start, const char *end)
-{
- XML_Char *data;
- if (!commentHandler) {
- if (defaultHandler)
- reportDefault(parser, enc, start, end);
- return 1;
- }
- data = poolStoreString(&tempPool,
- enc,
- start + enc->minBytesPerChar * 4,
- end - enc->minBytesPerChar * 3);
- if (!data)
- return 0;
- normalizeLines(data);
- commentHandler(handlerArg, data);
- poolClear(&tempPool);
- return 1;
-}
-
-static void
-reportDefault(XML_Parser parser, const ENCODING *enc, const char *s, const char *end)
-{
- if (MUST_CONVERT(enc, s)) {
- const char **eventPP;
- const char **eventEndPP;
- if (enc == encoding) {
- eventPP = &eventPtr;
- eventEndPP = &eventEndPtr;
- }
- else {
- eventPP = &(openInternalEntities->internalEventPtr);
- eventEndPP = &(openInternalEntities->internalEventEndPtr);
- }
- do {
- ICHAR *dataPtr = (ICHAR *)dataBuf;
- XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd);
- *eventEndPP = s;
- defaultHandler(handlerArg, dataBuf, dataPtr - (ICHAR *)dataBuf);
- *eventPP = s;
- } while (s != end);
- }
- else
- defaultHandler(handlerArg, (XML_Char *)s, (XML_Char *)end - (XML_Char *)s);
-}
-
-
-static int
-defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, int isCdata, const XML_Char *value)
-{
- DEFAULT_ATTRIBUTE *att;
- if (type->nDefaultAtts == type->allocDefaultAtts) {
- if (type->allocDefaultAtts == 0) {
- type->allocDefaultAtts = 8;
- type->defaultAtts = malloc(type->allocDefaultAtts*sizeof(DEFAULT_ATTRIBUTE));
- }
- else {
- type->allocDefaultAtts *= 2;
- type->defaultAtts = realloc(type->defaultAtts,
- type->allocDefaultAtts*sizeof(DEFAULT_ATTRIBUTE));
- }
- if (!type->defaultAtts)
- return 0;
- }
- att = type->defaultAtts + type->nDefaultAtts;
- att->id = attId;
- att->value = value;
- att->isCdata = isCdata;
- if (!isCdata)
- attId->maybeTokenized = 1;
- type->nDefaultAtts += 1;
- return 1;
-}
-
-static int setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType)
-{
- const XML_Char *name;
- for (name = elementType->name; *name; name++) {
- if (*name == XML_T(':')) {
- PREFIX *prefix;
- const XML_Char *s;
- for (s = elementType->name; s != name; s++) {
- if (!poolAppendChar(&dtd.pool, *s))
- return 0;
- }
- if (!poolAppendChar(&dtd.pool, XML_T('\0')))
- return 0;
- prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&dtd.pool), sizeof(PREFIX));
- if (!prefix)
- return 0;
- if (prefix->name == poolStart(&dtd.pool))
- poolFinish(&dtd.pool);
- else
- poolDiscard(&dtd.pool);
- elementType->prefix = prefix;
-
- }
- }
- return 1;
-}
-
-static ATTRIBUTE_ID *
-getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, const char *end)
-{
- ATTRIBUTE_ID *id;
- const XML_Char *name;
- if (!poolAppendChar(&dtd.pool, XML_T('\0')))
- return 0;
- name = poolStoreString(&dtd.pool, enc, start, end);
- if (!name)
- return 0;
- ++name;
- id = (ATTRIBUTE_ID *)lookup(&dtd.attributeIds, name, sizeof(ATTRIBUTE_ID));
- if (!id)
- return 0;
- if (id->name != name)
- poolDiscard(&dtd.pool);
- else {
- poolFinish(&dtd.pool);
- if (!ns)
- ;
- else if (name[0] == 'x'
- && name[1] == 'm'
- && name[2] == 'l'
- && name[3] == 'n'
- && name[4] == 's'
- && (name[5] == XML_T('\0') || name[5] == XML_T(':'))) {
- if (name[5] == '\0')
- id->prefix = &dtd.defaultPrefix;
- else
- id->prefix = (PREFIX *)lookup(&dtd.prefixes, name + 6, sizeof(PREFIX));
- id->xmlns = 1;
- }
- else {
- int i;
- for (i = 0; name[i]; i++) {
- if (name[i] == XML_T(':')) {
- int j;
- for (j = 0; j < i; j++) {
- if (!poolAppendChar(&dtd.pool, name[j]))
- return 0;
- }
- if (!poolAppendChar(&dtd.pool, XML_T('\0')))
- return 0;
- id->prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&dtd.pool), sizeof(PREFIX));
- if (id->prefix->name == poolStart(&dtd.pool))
- poolFinish(&dtd.pool);
- else
- poolDiscard(&dtd.pool);
- break;
- }
- }
- }
- }
- return id;
-}
-
-#define CONTEXT_SEP XML_T('\f')
-
-static
-const XML_Char *getContext(XML_Parser parser)
-{
- HASH_TABLE_ITER iter;
- int needSep = 0;
-
- if (dtd.defaultPrefix.binding) {
- int i;
- int len;
- if (!poolAppendChar(&tempPool, XML_T('=')))
- return 0;
- len = dtd.defaultPrefix.binding->uriLen;
- if (namespaceSeparator != XML_T('\0'))
- len--;
- for (i = 0; i < len; i++)
- if (!poolAppendChar(&tempPool, dtd.defaultPrefix.binding->uri[i]))
- return 0;
- needSep = 1;
- }
-
- hashTableIterInit(&iter, &(dtd.prefixes));
- for (;;) {
- int i;
- int len;
- const XML_Char *s;
- PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter);
- if (!prefix)
- break;
- if (!prefix->binding)
- continue;
- if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP))
- return 0;
- for (s = prefix->name; *s; s++)
- if (!poolAppendChar(&tempPool, *s))
- return 0;
- if (!poolAppendChar(&tempPool, XML_T('=')))
- return 0;
- len = prefix->binding->uriLen;
- if (namespaceSeparator != XML_T('\0'))
- len--;
- for (i = 0; i < len; i++)
- if (!poolAppendChar(&tempPool, prefix->binding->uri[i]))
- return 0;
- needSep = 1;
- }
-
-
- hashTableIterInit(&iter, &(dtd.generalEntities));
- for (;;) {
- const XML_Char *s;
- ENTITY *e = (ENTITY *)hashTableIterNext(&iter);
- if (!e)
- break;
- if (!e->open)
- continue;
- if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP))
- return 0;
- for (s = e->name; *s; s++)
- if (!poolAppendChar(&tempPool, *s))
- return 0;
- needSep = 1;
- }
-
- if (!poolAppendChar(&tempPool, XML_T('\0')))
- return 0;
- return tempPool.start;
-}
-
-static
-int setContext(XML_Parser parser, const XML_Char *context)
-{
- const XML_Char *s = context;
-
- while (*context != XML_T('\0')) {
- if (*s == CONTEXT_SEP || *s == XML_T('\0')) {
- ENTITY *e;
- if (!poolAppendChar(&tempPool, XML_T('\0')))
- return 0;
- e = (ENTITY *)lookup(&dtd.generalEntities, poolStart(&tempPool), 0);
- if (e)
- e->open = 1;
- if (*s != XML_T('\0'))
- s++;
- context = s;
- poolDiscard(&tempPool);
- }
- else if (*s == '=') {
- PREFIX *prefix;
- if (poolLength(&tempPool) == 0)
- prefix = &dtd.defaultPrefix;
- else {
- if (!poolAppendChar(&tempPool, XML_T('\0')))
- return 0;
- prefix = (PREFIX *)lookup(&dtd.prefixes, poolStart(&tempPool), sizeof(PREFIX));
- if (!prefix)
- return 0;
- if (prefix->name == poolStart(&tempPool))
- poolFinish(&tempPool);
- else
- poolDiscard(&tempPool);
- }
- for (context = s + 1; *context != CONTEXT_SEP && *context != XML_T('\0'); context++)
- if (!poolAppendChar(&tempPool, *context))
- return 0;
- if (!poolAppendChar(&tempPool, XML_T('\0')))
- return 0;
- if (!addBinding(parser, prefix, 0, poolStart(&tempPool), &inheritedBindings))
- return 0;
- poolDiscard(&tempPool);
- if (*context != XML_T('\0'))
- ++context;
- s = context;
- }
- else {
- if (!poolAppendChar(&tempPool, *s))
- return 0;
- s++;
- }
- }
- return 1;
-}
-
-
-static
-void normalizePublicId(XML_Char *publicId)
-{
- XML_Char *p = publicId;
- XML_Char *s;
- for (s = publicId; *s; s++) {
- switch (*s) {
- case 0x20:
- case 0xD:
- case 0xA:
- if (p != publicId && p[-1] != 0x20)
- *p++ = 0x20;
- break;
- default:
- *p++ = *s;
- }
- }
- if (p != publicId && p[-1] == 0x20)
- --p;
- *p = XML_T('\0');
-}
-
-static int dtdInit(DTD *p)
-{
- poolInit(&(p->pool));
- hashTableInit(&(p->generalEntities));
- hashTableInit(&(p->elementTypes));
- hashTableInit(&(p->attributeIds));
- hashTableInit(&(p->prefixes));
- p->complete = 1;
- p->standalone = 0;
- p->base = 0;
- p->defaultPrefix.name = 0;
- p->defaultPrefix.binding = 0;
- return 1;
-}
-
-static void dtdDestroy(DTD *p)
-{
- HASH_TABLE_ITER iter;
- hashTableIterInit(&iter, &(p->elementTypes));
- for (;;) {
- ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter);
- if (!e)
- break;
- if (e->allocDefaultAtts != 0)
- free(e->defaultAtts);
- }
- hashTableDestroy(&(p->generalEntities));
- hashTableDestroy(&(p->elementTypes));
- hashTableDestroy(&(p->attributeIds));
- hashTableDestroy(&(p->prefixes));
- poolDestroy(&(p->pool));
-}
-
-/* Do a deep copy of the DTD. Return 0 for out of memory; non-zero otherwise.
-The new DTD has already been initialized. */
-
-static int dtdCopy(DTD *newDtd, const DTD *oldDtd)
-{
- HASH_TABLE_ITER iter;
-
- if (oldDtd->base) {
- const XML_Char *tem = poolCopyString(&(newDtd->pool), oldDtd->base);
- if (!tem)
- return 0;
- newDtd->base = tem;
- }
-
- /* Copy the prefix table. */
-
- hashTableIterInit(&iter, &(oldDtd->prefixes));
- for (;;) {
- const XML_Char *name;
- const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter);
- if (!oldP)
- break;
- name = poolCopyString(&(newDtd->pool), oldP->name);
- if (!name)
- return 0;
- if (!lookup(&(newDtd->prefixes), name, sizeof(PREFIX)))
- return 0;
- }
-
- hashTableIterInit(&iter, &(oldDtd->attributeIds));
-
- /* Copy the attribute id table. */
-
- for (;;) {
- ATTRIBUTE_ID *newA;
- const XML_Char *name;
- const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter);
-
- if (!oldA)
- break;
- /* Remember to allocate the scratch byte before the name. */
- if (!poolAppendChar(&(newDtd->pool), XML_T('\0')))
- return 0;
- name = poolCopyString(&(newDtd->pool), oldA->name);
- if (!name)
- return 0;
- ++name;
- newA = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), name, sizeof(ATTRIBUTE_ID));
- if (!newA)
- return 0;
- newA->maybeTokenized = oldA->maybeTokenized;
- if (oldA->prefix) {
- newA->xmlns = oldA->xmlns;
- if (oldA->prefix == &oldDtd->defaultPrefix)
- newA->prefix = &newDtd->defaultPrefix;
- else
- newA->prefix = (PREFIX *)lookup(&(newDtd->prefixes), oldA->prefix->name, 0);
- }
- }
-
- /* Copy the element type table. */
-
- hashTableIterInit(&iter, &(oldDtd->elementTypes));
-
- for (;;) {
- int i;
- ELEMENT_TYPE *newE;
- const XML_Char *name;
- const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter);
- if (!oldE)
- break;
- name = poolCopyString(&(newDtd->pool), oldE->name);
- if (!name)
- return 0;
- newE = (ELEMENT_TYPE *)lookup(&(newDtd->elementTypes), name, sizeof(ELEMENT_TYPE));
- if (!newE)
- return 0;
- if (oldE->nDefaultAtts) {
- newE->defaultAtts = (DEFAULT_ATTRIBUTE *)malloc(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE));
- if (!newE->defaultAtts)
- return 0;
- }
- newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts;
- if (oldE->prefix)
- newE->prefix = (PREFIX *)lookup(&(newDtd->prefixes), oldE->prefix->name, 0);
- for (i = 0; i < newE->nDefaultAtts; i++) {
- newE->defaultAtts[i].id = (ATTRIBUTE_ID *)lookup(&(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0);
- newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata;
- if (oldE->defaultAtts[i].value) {
- newE->defaultAtts[i].value = poolCopyString(&(newDtd->pool), oldE->defaultAtts[i].value);
- if (!newE->defaultAtts[i].value)
- return 0;
- }
- else
- newE->defaultAtts[i].value = 0;
- }
- }
-
- /* Copy the entity table. */
-
- hashTableIterInit(&iter, &(oldDtd->generalEntities));
-
- for (;;) {
- ENTITY *newE;
- const XML_Char *name;
- const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter);
- if (!oldE)
- break;
- name = poolCopyString(&(newDtd->pool), oldE->name);
- if (!name)
- return 0;
- newE = (ENTITY *)lookup(&(newDtd->generalEntities), name, sizeof(ENTITY));
- if (!newE)
- return 0;
- if (oldE->systemId) {
- const XML_Char *tem = poolCopyString(&(newDtd->pool), oldE->systemId);
- if (!tem)
- return 0;
- newE->systemId = tem;
- if (oldE->base) {
- if (oldE->base == oldDtd->base)
- newE->base = newDtd->base;
- tem = poolCopyString(&(newDtd->pool), oldE->base);
- if (!tem)
- return 0;
- newE->base = tem;
- }
- }
- else {
- const XML_Char *tem = poolCopyStringN(&(newDtd->pool), oldE->textPtr, oldE->textLen);
- if (!tem)
- return 0;
- newE->textPtr = tem;
- newE->textLen = oldE->textLen;
- }
- if (oldE->notation) {
- const XML_Char *tem = poolCopyString(&(newDtd->pool), oldE->notation);
- if (!tem)
- return 0;
- newE->notation = tem;
- }
- }
-
- newDtd->complete = oldDtd->complete;
- newDtd->standalone = oldDtd->standalone;
- return 1;
-}
-
-static
-void poolInit(STRING_POOL *pool)
-{
- pool->blocks = 0;
- pool->freeBlocks = 0;
- pool->start = 0;
- pool->ptr = 0;
- pool->end = 0;
-}
-
-static
-void poolClear(STRING_POOL *pool)
-{
- if (!pool->freeBlocks)
- pool->freeBlocks = pool->blocks;
- else {
- BLOCK *p = pool->blocks;
- while (p) {
- BLOCK *tem = p->next;
- p->next = pool->freeBlocks;
- pool->freeBlocks = p;
- p = tem;
- }
- }
- pool->blocks = 0;
- pool->start = 0;
- pool->ptr = 0;
- pool->end = 0;
-}
-
-static
-void poolDestroy(STRING_POOL *pool)
-{
- BLOCK *p = pool->blocks;
- while (p) {
- BLOCK *tem = p->next;
- free(p);
- p = tem;
- }
- pool->blocks = 0;
- p = pool->freeBlocks;
- while (p) {
- BLOCK *tem = p->next;
- free(p);
- p = tem;
- }
- pool->freeBlocks = 0;
- pool->ptr = 0;
- pool->start = 0;
- pool->end = 0;
-}
-
-static
-XML_Char *poolAppend(STRING_POOL *pool, const ENCODING *enc,
- const char *ptr, const char *end)
-{
- if (!pool->ptr && !poolGrow(pool))
- return 0;
- for (;;) {
- XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end);
- if (ptr == end)
- break;
- if (!poolGrow(pool))
- return 0;
- }
- return pool->start;
-}
-
-static const XML_Char *poolCopyString(STRING_POOL *pool, const XML_Char *s)
-{
- do {
- if (!poolAppendChar(pool, *s))
- return 0;
- } while (*s++);
- s = pool->start;
- poolFinish(pool);
- return s;
-}
-
-static const XML_Char *poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n)
-{
- if (!pool->ptr && !poolGrow(pool))
- return 0;
- for (; n > 0; --n, s++) {
- if (!poolAppendChar(pool, *s))
- return 0;
-
- }
- s = pool->start;
- poolFinish(pool);
- return s;
-}
-
-static
-XML_Char *poolStoreString(STRING_POOL *pool, const ENCODING *enc,
- const char *ptr, const char *end)
-{
- if (!poolAppend(pool, enc, ptr, end))
- return 0;
- if (pool->ptr == pool->end && !poolGrow(pool))
- return 0;
- *(pool->ptr)++ = 0;
- return pool->start;
-}
-
-static
-int poolGrow(STRING_POOL *pool)
-{
- if (pool->freeBlocks) {
- if (pool->start == 0) {
- pool->blocks = pool->freeBlocks;
- pool->freeBlocks = pool->freeBlocks->next;
- pool->blocks->next = 0;
- pool->start = pool->blocks->s;
- pool->end = pool->start + pool->blocks->size;
- pool->ptr = pool->start;
- return 1;
- }
- if (pool->end - pool->start < pool->freeBlocks->size) {
- BLOCK *tem = pool->freeBlocks->next;
- pool->freeBlocks->next = pool->blocks;
- pool->blocks = pool->freeBlocks;
- pool->freeBlocks = tem;
- memcpy(pool->blocks->s, pool->start, (pool->end - pool->start) * sizeof(XML_Char));
- pool->ptr = pool->blocks->s + (pool->ptr - pool->start);
- pool->start = pool->blocks->s;
- pool->end = pool->start + pool->blocks->size;
- return 1;
- }
- }
- if (pool->blocks && pool->start == pool->blocks->s) {
- int blockSize = (pool->end - pool->start)*2;
- pool->blocks = realloc(pool->blocks, offsetof(BLOCK, s) + blockSize * sizeof(XML_Char));
- if (!pool->blocks)
- return 0;
- pool->blocks->size = blockSize;
- pool->ptr = pool->blocks->s + (pool->ptr - pool->start);
- pool->start = pool->blocks->s;
- pool->end = pool->start + blockSize;
- }
- else {
- BLOCK *tem;
- int blockSize = pool->end - pool->start;
- if (blockSize < INIT_BLOCK_SIZE)
- blockSize = INIT_BLOCK_SIZE;
- else
- blockSize *= 2;
- tem = malloc(offsetof(BLOCK, s) + blockSize * sizeof(XML_Char));
- if (!tem)
- return 0;
- tem->size = blockSize;
- tem->next = pool->blocks;
- pool->blocks = tem;
- memcpy(tem->s, pool->start, (pool->ptr - pool->start) * sizeof(XML_Char));
- pool->ptr = tem->s + (pool->ptr - pool->start);
- pool->start = tem->s;
- pool->end = tem->s + blockSize;
- }
- return 1;
-}
diff --git a/srclib/expat-lite/xmlparse.h b/srclib/expat-lite/xmlparse.h
deleted file mode 100644
index 0fdfa75a4e..0000000000
--- a/srclib/expat-lite/xmlparse.h
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-#ifndef XmlParse_INCLUDED
-#define XmlParse_INCLUDED 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef XMLPARSEAPI
-#define XMLPARSEAPI /* as nothing */
-#endif
-
-typedef void *XML_Parser;
-
-#ifdef XML_UNICODE_WCHAR_T
-
-/* XML_UNICODE_WCHAR_T will work only if sizeof(wchar_t) == 2 and wchar_t
-uses Unicode. */
-/* Information is UTF-16 encoded as wchar_ts */
-
-#ifndef XML_UNICODE
-#define XML_UNICODE
-#endif
-
-#include <stddef.h>
-typedef wchar_t XML_Char;
-typedef wchar_t XML_LChar;
-
-#else /* not XML_UNICODE_WCHAR_T */
-
-#ifdef XML_UNICODE
-
-/* Information is UTF-16 encoded as unsigned shorts */
-typedef unsigned short XML_Char;
-typedef char XML_LChar;
-
-#else /* not XML_UNICODE */
-
-/* Information is UTF-8 encoded. */
-typedef char XML_Char;
-typedef char XML_LChar;
-
-#endif /* not XML_UNICODE */
-
-#endif /* not XML_UNICODE_WCHAR_T */
-
-
-/* Constructs a new parser; encoding is the encoding specified by the external
-protocol or null if there is none specified. */
-
-XML_Parser XMLPARSEAPI
-XML_ParserCreate(const XML_Char *encoding);
-
-/* Constructs a new parser and namespace processor. Element type names
-and attribute names that belong to a namespace will be expanded;
-unprefixed attribute names are never expanded; unprefixed element type
-names are expanded only if there is a default namespace. The expanded
-name is the concatenation of the namespace URI, the namespace separator character,
-and the local part of the name. If the namespace separator is '\0' then
-the namespace URI and the local part will be concatenated without any
-separator. When a namespace is not declared, the name and prefix will be
-passed through without expansion. */
-
-XML_Parser XMLPARSEAPI
-XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
-
-
-/* atts is array of name/value pairs, terminated by 0;
- names and values are 0 terminated. */
-
-typedef void (*XML_StartElementHandler)(void *userData,
- const XML_Char *name,
- const XML_Char **atts);
-
-typedef void (*XML_EndElementHandler)(void *userData,
- const XML_Char *name);
-
-/* s is not 0 terminated. */
-typedef void (*XML_CharacterDataHandler)(void *userData,
- const XML_Char *s,
- int len);
-
-/* target and data are 0 terminated */
-typedef void (*XML_ProcessingInstructionHandler)(void *userData,
- const XML_Char *target,
- const XML_Char *data);
-
-/* data is 0 terminated */
-typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data);
-
-typedef void (*XML_StartCdataSectionHandler)(void *userData);
-typedef void (*XML_EndCdataSectionHandler)(void *userData);
-
-/* This is called for any characters in the XML document for
-which there is no applicable handler. This includes both
-characters that are part of markup which is of a kind that is
-not reported (comments, markup declarations), or characters
-that are part of a construct which could be reported but
-for which no handler has been supplied. The characters are passed
-exactly as they were in the XML document except that
-they will be encoded in UTF-8. Line boundaries are not normalized.
-Note that a byte order mark character is not passed to the default handler.
-There are no guarantees about how characters are divided between calls
-to the default handler: for example, a comment might be split between
-multiple calls. */
-
-typedef void (*XML_DefaultHandler)(void *userData,
- const XML_Char *s,
- int len);
-
-/* This is called for a declaration of an unparsed (NDATA)
-entity. The base argument is whatever was set by XML_SetBase.
-The entityName, systemId and notationName arguments will never be null.
-The other arguments may be. */
-
-typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
- const XML_Char *entityName,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId,
- const XML_Char *notationName);
-
-/* This is called for a declaration of notation.
-The base argument is whatever was set by XML_SetBase.
-The notationName will never be null. The other arguments can be. */
-
-typedef void (*XML_NotationDeclHandler)(void *userData,
- const XML_Char *notationName,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId);
-
-/* When namespace processing is enabled, these are called once for
-each namespace declaration. The call to the start and end element
-handlers occur between the calls to the start and end namespace
-declaration handlers. For an xmlns attribute, prefix will be null.
-For an xmlns="" attribute, uri will be null. */
-
-typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
- const XML_Char *prefix,
- const XML_Char *uri);
-
-typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
- const XML_Char *prefix);
-
-/* This is called if the document is not standalone (it has an
-external subset or a reference to a parameter entity, but does not
-have standalone="yes"). If this handler returns 0, then processing
-will not continue, and the parser will return a
-XML_ERROR_NOT_STANDALONE error. */
-
-typedef int (*XML_NotStandaloneHandler)(void *userData);
-
-/* This is called for a reference to an external parsed general entity.
-The referenced entity is not automatically parsed.
-The application can parse it immediately or later using
-XML_ExternalEntityParserCreate.
-The parser argument is the parser parsing the entity containing the reference;
-it can be passed as the parser argument to XML_ExternalEntityParserCreate.
-The systemId argument is the system identifier as specified in the entity declaration;
-it will not be null.
-The base argument is the system identifier that should be used as the base for
-resolving systemId if systemId was relative; this is set by XML_SetBase;
-it may be null.
-The publicId argument is the public identifier as specified in the entity declaration,
-or null if none was specified; the whitespace in the public identifier
-will have been normalized as required by the XML spec.
-The context argument specifies the parsing context in the format
-expected by the context argument to
-XML_ExternalEntityParserCreate; context is valid only until the handler
-returns, so if the referenced entity is to be parsed later, it must be copied.
-The handler should return 0 if processing should not continue because of
-a fatal error in the handling of the external entity.
-In this case the calling parser will return an XML_ERROR_EXTERNAL_ENTITY_HANDLING
-error.
-Note that unlike other handlers the first argument is the parser, not userData. */
-
-typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
- const XML_Char *context,
- const XML_Char *base,
- const XML_Char *systemId,
- const XML_Char *publicId);
-
-/* This structure is filled in by the XML_UnknownEncodingHandler
-to provide information to the parser about encodings that are unknown
-to the parser.
-The map[b] member gives information about byte sequences
-whose first byte is b.
-If map[b] is c where c is >= 0, then b by itself encodes the Unicode scalar value c.
-If map[b] is -1, then the byte sequence is malformed.
-If map[b] is -n, where n >= 2, then b is the first byte of an n-byte
-sequence that encodes a single Unicode scalar value.
-The data member will be passed as the first argument to the convert function.
-The convert function is used to convert multibyte sequences;
-s will point to a n-byte sequence where map[(unsigned char)*s] == -n.
-The convert function must return the Unicode scalar value
-represented by this byte sequence or -1 if the byte sequence is malformed.
-The convert function may be null if the encoding is a single-byte encoding,
-that is if map[b] >= -1 for all bytes b.
-When the parser is finished with the encoding, then if release is not null,
-it will call release passing it the data member;
-once release has been called, the convert function will not be called again.
-
-Expat places certain restrictions on the encodings that are supported
-using this mechanism.
-
-1. Every ASCII character that can appear in a well-formed XML document,
-other than the characters
-
- $@\^`{}~
-
-must be represented by a single byte, and that byte must be the
-same byte that represents that character in ASCII.
-
-2. No character may require more than 4 bytes to encode.
-
-3. All characters encoded must have Unicode scalar values <= 0xFFFF,
-(ie characters that would be encoded by surrogates in UTF-16
-are not allowed). Note that this restriction doesn't apply to
-the built ap_context_t n support for UTF-8 and UTF-16.
-
-4. No Unicode character may be encoded by more than one distinct sequence
-of bytes. */
-
-typedef struct {
- int map[256];
- void *data;
- int (*convert)(void *data, const char *s);
- void (*release)(void *data);
-} XML_Encoding;
-
-/* This is called for an encoding that is unknown to the parser.
-The encodingHandlerData argument is that which was passed as the
-second argument to XML_SetUnknownEncodingHandler.
-The name argument gives the name of the encoding as specified in
-the encoding declaration.
-If the callback can provide information about the encoding,
-it must fill in the XML_Encoding structure, and return 1.
-Otherwise it must return 0.
-If info does not describe a suitable encoding,
-then the parser will return an XML_UNKNOWN_ENCODING error. */
-
-typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
- const XML_Char *name,
- XML_Encoding *info);
-
-void XMLPARSEAPI
-XML_SetElementHandler(XML_Parser parser,
- XML_StartElementHandler start,
- XML_EndElementHandler end);
-
-void XMLPARSEAPI
-XML_SetCharacterDataHandler(XML_Parser parser,
- XML_CharacterDataHandler handler);
-
-void XMLPARSEAPI
-XML_SetProcessingInstructionHandler(XML_Parser parser,
- XML_ProcessingInstructionHandler handler);
-void XMLPARSEAPI
-XML_SetCommentHandler(XML_Parser parser,
- XML_CommentHandler handler);
-
-void XMLPARSEAPI
-XML_SetCdataSectionHandler(XML_Parser parser,
- XML_StartCdataSectionHandler start,
- XML_EndCdataSectionHandler end);
-
-/* This sets the default handler and also inhibits expansion of internal entities.
-The entity reference will be passed to the default handler. */
-
-void XMLPARSEAPI
-XML_SetDefaultHandler(XML_Parser parser,
- XML_DefaultHandler handler);
-
-/* This sets the default handler but does not inhibit expansion of internal entities.
-The entity reference will not be passed to the default handler. */
-
-void XMLPARSEAPI
-XML_SetDefaultHandlerExpand(XML_Parser parser,
- XML_DefaultHandler handler);
-
-void XMLPARSEAPI
-XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
- XML_UnparsedEntityDeclHandler handler);
-
-void XMLPARSEAPI
-XML_SetNotationDeclHandler(XML_Parser parser,
- XML_NotationDeclHandler handler);
-
-void XMLPARSEAPI
-XML_SetNamespaceDeclHandler(XML_Parser parser,
- XML_StartNamespaceDeclHandler start,
- XML_EndNamespaceDeclHandler end);
-
-void XMLPARSEAPI
-XML_SetNotStandaloneHandler(XML_Parser parser,
- XML_NotStandaloneHandler handler);
-
-void XMLPARSEAPI
-XML_SetExternalEntityRefHandler(XML_Parser parser,
- XML_ExternalEntityRefHandler handler);
-
-/* If a non-null value for arg is specified here, then it will be passed
-as the first argument to the external entity ref handler instead
-of the parser object. */
-void XMLPARSEAPI
-XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
-
-void XMLPARSEAPI
-XML_SetUnknownEncodingHandler(XML_Parser parser,
- XML_UnknownEncodingHandler handler,
- void *encodingHandlerData);
-
-/* This can be called within a handler for a start element, end element,
-processing instruction or character data. It causes the corresponding
-markup to be passed to the default handler. */
-void XMLPARSEAPI XML_DefaultCurrent(XML_Parser parser);
-
-/* This value is passed as the userData argument to callbacks. */
-void XMLPARSEAPI
-XML_SetUserData(XML_Parser parser, void *userData);
-
-/* Returns the last value set by XML_SetUserData or null. */
-#define XML_GetUserData(parser) (*(void **)(parser))
-
-/* This is equivalent to supplying an encoding argument
-to XML_CreateParser. It must not be called after XML_Parse
-or XML_ParseBuffer. */
-
-int XMLPARSEAPI
-XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
-
-/* If this function is called, then the parser will be passed
-as the first argument to callbacks instead of userData.
-The userData will still be accessible using XML_GetUserData. */
-
-void XMLPARSEAPI
-XML_UseParserAsHandlerArg(XML_Parser parser);
-
-/* Sets the base to be used for resolving relative URIs in system identifiers in
-declarations. Resolving relative identifiers is left to the application:
-this value will be passed through as the base argument to the
-XML_ExternalEntityRefHandler, XML_NotationDeclHandler
-and XML_UnparsedEntityDeclHandler. The base argument will be copied.
-Returns zero if out of memory, non-zero otherwise. */
-
-int XMLPARSEAPI
-XML_SetBase(XML_Parser parser, const XML_Char *base);
-
-const XML_Char XMLPARSEAPI *
-XML_GetBase(XML_Parser parser);
-
-/* Returns the number of the attributes passed in last call to the
-XML_StartElementHandler that were specified in the start-tag rather
-than defaulted. */
-
-int XMLPARSEAPI XML_GetSpecifiedAttributeCount(XML_Parser parser);
-
-/* Parses some input. Returns 0 if a fatal error is detected.
-The last call to XML_Parse must have isFinal true;
-len may be zero for this call (or any other). */
-int XMLPARSEAPI
-XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
-
-void XMLPARSEAPI *
-XML_GetBuffer(XML_Parser parser, int len);
-
-int XMLPARSEAPI
-XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
-
-/* Creates an XML_Parser object that can parse an external general entity;
-context is a '\0'-terminated string specifying the parse context;
-encoding is a '\0'-terminated string giving the name of the externally specified encoding,
-or null if there is no externally specified encoding.
-The context string consists of a sequence of tokens separated by formfeeds (\f);
-a token consisting of a name specifies that the general entity of the name
-is open; a token of the form prefix=uri specifies the namespace for a particular
-prefix; a token of the form =uri specifies the default namespace.
-This can be called at any point after the first call to an ExternalEntityRefHandler
-so longer as the parser has not yet been freed.
-The new parser is completely independent and may safely be used in a separate thread.
-The handlers and userData are initialized from the parser argument.
-Returns 0 if out of memory. Otherwise returns a new XML_Parser object. */
-XML_Parser XMLPARSEAPI
-XML_ExternalEntityParserCreate(XML_Parser parser,
- const XML_Char *context,
- const XML_Char *encoding);
-
-enum XML_Error {
- XML_ERROR_NONE,
- XML_ERROR_NO_MEMORY,
- XML_ERROR_SYNTAX,
- XML_ERROR_NO_ELEMENTS,
- XML_ERROR_INVALID_TOKEN,
- XML_ERROR_UNCLOSED_TOKEN,
- XML_ERROR_PARTIAL_CHAR,
- XML_ERROR_TAG_MISMATCH,
- XML_ERROR_DUPLICATE_ATTRIBUTE,
- XML_ERROR_JUNK_AFTER_DOC_ELEMENT,
- XML_ERROR_PARAM_ENTITY_REF,
- XML_ERROR_UNDEFINED_ENTITY,
- XML_ERROR_RECURSIVE_ENTITY_REF,
- XML_ERROR_ASYNC_ENTITY,
- XML_ERROR_BAD_CHAR_REF,
- XML_ERROR_BINARY_ENTITY_REF,
- XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF,
- XML_ERROR_MISPLACED_XML_PI,
- XML_ERROR_UNKNOWN_ENCODING,
- XML_ERROR_INCORRECT_ENCODING,
- XML_ERROR_UNCLOSED_CDATA_SECTION,
- XML_ERROR_EXTERNAL_ENTITY_HANDLING,
- XML_ERROR_NOT_STANDALONE
-};
-
-/* If XML_Parse or XML_ParseBuffer have returned 0, then XML_GetErrorCode
-returns information about the error. */
-
-enum XML_Error XMLPARSEAPI XML_GetErrorCode(XML_Parser parser);
-
-/* These functions return information about the current parse location.
-They may be called when XML_Parse or XML_ParseBuffer return 0;
-in this case the location is the location of the character at which
-the error was detected.
-They may also be called from any other callback called to report
-some parse event; in this the location is the location of the first
-of the sequence of characters that generated the event. */
-
-int XMLPARSEAPI XML_GetCurrentLineNumber(XML_Parser parser);
-int XMLPARSEAPI XML_GetCurrentColumnNumber(XML_Parser parser);
-long XMLPARSEAPI XML_GetCurrentByteIndex(XML_Parser parser);
-
-/* Return the number of bytes in the current event.
-Returns 0 if the event is in an internal entity. */
-
-int XMLPARSEAPI XML_GetCurrentByteCount(XML_Parser parser);
-
-/* For backwards compatibility with previous versions. */
-#define XML_GetErrorLineNumber XML_GetCurrentLineNumber
-#define XML_GetErrorColumnNumber XML_GetCurrentColumnNumber
-#define XML_GetErrorByteIndex XML_GetCurrentByteIndex
-
-/* Frees memory used by the parser. */
-void XMLPARSEAPI
-XML_ParserFree(XML_Parser parser);
-
-/* Returns a string describing the error. */
-const XML_LChar XMLPARSEAPI *XML_ErrorString(int code);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* not XmlParse_INCLUDED */
diff --git a/srclib/expat-lite/xmlrole.c b/srclib/expat-lite/xmlrole.c
deleted file mode 100644
index b18e35eb3c..0000000000
--- a/srclib/expat-lite/xmlrole.c
+++ /dev/null
@@ -1,1113 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-#include "xmldef.h"
-#include "xmlrole.h"
-
-/* Doesn't check:
-
- that ,| are not mixed in a model group
- content of literals
-
-*/
-
-#ifndef MIN_BYTES_PER_CHAR
-#define MIN_BYTES_PER_CHAR(enc) ((enc)->minBytesPerChar)
-#endif
-
-typedef int PROLOG_HANDLER(struct prolog_state *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc);
-
-static PROLOG_HANDLER
- prolog0, prolog1, prolog2,
- doctype0, doctype1, doctype2, doctype3, doctype4, doctype5,
- internalSubset,
- entity0, entity1, entity2, entity3, entity4, entity5, entity6,
- entity7, entity8, entity9,
- notation0, notation1, notation2, notation3, notation4,
- attlist0, attlist1, attlist2, attlist3, attlist4, attlist5, attlist6,
- attlist7, attlist8, attlist9,
- element0, element1, element2, element3, element4, element5, element6,
- element7,
- declClose,
- error;
-
-static
-int syntaxError(PROLOG_STATE *);
-
-static
-int prolog0(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- state->handler = prolog1;
- return XML_ROLE_NONE;
- case XML_TOK_XML_DECL:
- state->handler = prolog1;
- return XML_ROLE_XML_DECL;
- case XML_TOK_PI:
- state->handler = prolog1;
- return XML_ROLE_NONE;
- case XML_TOK_COMMENT:
- state->handler = prolog1;
- case XML_TOK_BOM:
- return XML_ROLE_NONE;
- case XML_TOK_DECL_OPEN:
- if (!XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- "DOCTYPE"))
- break;
- state->handler = doctype0;
- return XML_ROLE_NONE;
- case XML_TOK_INSTANCE_START:
- state->handler = error;
- return XML_ROLE_INSTANCE_START;
- }
- return syntaxError(state);
-}
-
-static
-int prolog1(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_PI:
- case XML_TOK_COMMENT:
- case XML_TOK_BOM:
- return XML_ROLE_NONE;
- case XML_TOK_DECL_OPEN:
- if (!XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- "DOCTYPE"))
- break;
- state->handler = doctype0;
- return XML_ROLE_NONE;
- case XML_TOK_INSTANCE_START:
- state->handler = error;
- return XML_ROLE_INSTANCE_START;
- }
- return syntaxError(state);
-}
-
-static
-int prolog2(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_PI:
- case XML_TOK_COMMENT:
- return XML_ROLE_NONE;
- case XML_TOK_INSTANCE_START:
- state->handler = error;
- return XML_ROLE_INSTANCE_START;
- }
- return syntaxError(state);
-}
-
-static
-int doctype0(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- case XML_TOK_PREFIXED_NAME:
- state->handler = doctype1;
- return XML_ROLE_DOCTYPE_NAME;
- }
- return syntaxError(state);
-}
-
-static
-int doctype1(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_OPEN_BRACKET:
- state->handler = internalSubset;
- return XML_ROLE_NONE;
- case XML_TOK_DECL_CLOSE:
- state->handler = prolog2;
- return XML_ROLE_DOCTYPE_CLOSE;
- case XML_TOK_NAME:
- if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
- state->handler = doctype3;
- return XML_ROLE_NONE;
- }
- if (XmlNameMatchesAscii(enc, ptr, "PUBLIC")) {
- state->handler = doctype2;
- return XML_ROLE_NONE;
- }
- break;
- }
- return syntaxError(state);
-}
-
-static
-int doctype2(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_LITERAL:
- state->handler = doctype3;
- return XML_ROLE_DOCTYPE_PUBLIC_ID;
- }
- return syntaxError(state);
-}
-
-static
-int doctype3(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_LITERAL:
- state->handler = doctype4;
- return XML_ROLE_DOCTYPE_SYSTEM_ID;
- }
- return syntaxError(state);
-}
-
-static
-int doctype4(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_OPEN_BRACKET:
- state->handler = internalSubset;
- return XML_ROLE_NONE;
- case XML_TOK_DECL_CLOSE:
- state->handler = prolog2;
- return XML_ROLE_DOCTYPE_CLOSE;
- }
- return syntaxError(state);
-}
-
-static
-int doctype5(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_DECL_CLOSE:
- state->handler = prolog2;
- return XML_ROLE_DOCTYPE_CLOSE;
- }
- return syntaxError(state);
-}
-
-static
-int internalSubset(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_DECL_OPEN:
- if (XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- "ENTITY")) {
- state->handler = entity0;
- return XML_ROLE_NONE;
- }
- if (XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- "ATTLIST")) {
- state->handler = attlist0;
- return XML_ROLE_NONE;
- }
- if (XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- "ELEMENT")) {
- state->handler = element0;
- return XML_ROLE_NONE;
- }
- if (XmlNameMatchesAscii(enc,
- ptr + 2 * MIN_BYTES_PER_CHAR(enc),
- "NOTATION")) {
- state->handler = notation0;
- return XML_ROLE_NONE;
- }
- break;
- case XML_TOK_PI:
- case XML_TOK_COMMENT:
- return XML_ROLE_NONE;
- case XML_TOK_PARAM_ENTITY_REF:
- return XML_ROLE_PARAM_ENTITY_REF;
- case XML_TOK_CLOSE_BRACKET:
- state->handler = doctype5;
- return XML_ROLE_NONE;
- }
- return syntaxError(state);
-}
-
-static
-int entity0(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_PERCENT:
- state->handler = entity1;
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- state->handler = entity2;
- return XML_ROLE_GENERAL_ENTITY_NAME;
- }
- return syntaxError(state);
-}
-
-static
-int entity1(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- state->handler = entity7;
- return XML_ROLE_PARAM_ENTITY_NAME;
- }
- return syntaxError(state);
-}
-
-static
-int entity2(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
- state->handler = entity4;
- return XML_ROLE_NONE;
- }
- if (XmlNameMatchesAscii(enc, ptr, "PUBLIC")) {
- state->handler = entity3;
- return XML_ROLE_NONE;
- }
- break;
- case XML_TOK_LITERAL:
- state->handler = declClose;
- return XML_ROLE_ENTITY_VALUE;
- }
- return syntaxError(state);
-}
-
-static
-int entity3(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_LITERAL:
- state->handler = entity4;
- return XML_ROLE_ENTITY_PUBLIC_ID;
- }
- return syntaxError(state);
-}
-
-
-static
-int entity4(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_LITERAL:
- state->handler = entity5;
- return XML_ROLE_ENTITY_SYSTEM_ID;
- }
- return syntaxError(state);
-}
-
-static
-int entity5(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_DECL_CLOSE:
- state->handler = internalSubset;
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- if (XmlNameMatchesAscii(enc, ptr, "NDATA")) {
- state->handler = entity6;
- return XML_ROLE_NONE;
- }
- break;
- }
- return syntaxError(state);
-}
-
-static
-int entity6(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- state->handler = declClose;
- return XML_ROLE_ENTITY_NOTATION_NAME;
- }
- return syntaxError(state);
-}
-
-static
-int entity7(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
- state->handler = entity9;
- return XML_ROLE_NONE;
- }
- if (XmlNameMatchesAscii(enc, ptr, "PUBLIC")) {
- state->handler = entity8;
- return XML_ROLE_NONE;
- }
- break;
- case XML_TOK_LITERAL:
- state->handler = declClose;
- return XML_ROLE_ENTITY_VALUE;
- }
- return syntaxError(state);
-}
-
-static
-int entity8(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_LITERAL:
- state->handler = entity9;
- return XML_ROLE_ENTITY_PUBLIC_ID;
- }
- return syntaxError(state);
-}
-
-static
-int entity9(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_LITERAL:
- state->handler = declClose;
- return XML_ROLE_ENTITY_SYSTEM_ID;
- }
- return syntaxError(state);
-}
-
-static
-int notation0(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- state->handler = notation1;
- return XML_ROLE_NOTATION_NAME;
- }
- return syntaxError(state);
-}
-
-static
-int notation1(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- if (XmlNameMatchesAscii(enc, ptr, "SYSTEM")) {
- state->handler = notation3;
- return XML_ROLE_NONE;
- }
- if (XmlNameMatchesAscii(enc, ptr, "PUBLIC")) {
- state->handler = notation2;
- return XML_ROLE_NONE;
- }
- break;
- }
- return syntaxError(state);
-}
-
-static
-int notation2(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_LITERAL:
- state->handler = notation4;
- return XML_ROLE_NOTATION_PUBLIC_ID;
- }
- return syntaxError(state);
-}
-
-static
-int notation3(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_LITERAL:
- state->handler = declClose;
- return XML_ROLE_NOTATION_SYSTEM_ID;
- }
- return syntaxError(state);
-}
-
-static
-int notation4(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_LITERAL:
- state->handler = declClose;
- return XML_ROLE_NOTATION_SYSTEM_ID;
- case XML_TOK_DECL_CLOSE:
- state->handler = internalSubset;
- return XML_ROLE_NOTATION_NO_SYSTEM_ID;
- }
- return syntaxError(state);
-}
-
-static
-int attlist0(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- case XML_TOK_PREFIXED_NAME:
- state->handler = attlist1;
- return XML_ROLE_ATTLIST_ELEMENT_NAME;
- }
- return syntaxError(state);
-}
-
-static
-int attlist1(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_DECL_CLOSE:
- state->handler = internalSubset;
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- case XML_TOK_PREFIXED_NAME:
- state->handler = attlist2;
- return XML_ROLE_ATTRIBUTE_NAME;
- }
- return syntaxError(state);
-}
-
-static
-int attlist2(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- {
- static const char *types[] = {
- "CDATA",
- "ID",
- "IDREF",
- "IDREFS",
- "ENTITY",
- "ENTITIES",
- "NMTOKEN",
- "NMTOKENS",
- };
- int i;
- for (i = 0; i < (int)(sizeof(types)/sizeof(types[0])); i++)
- if (XmlNameMatchesAscii(enc, ptr, types[i])) {
- state->handler = attlist8;
- return XML_ROLE_ATTRIBUTE_TYPE_CDATA + i;
- }
- }
- if (XmlNameMatchesAscii(enc, ptr, "NOTATION")) {
- state->handler = attlist5;
- return XML_ROLE_NONE;
- }
- break;
- case XML_TOK_OPEN_PAREN:
- state->handler = attlist3;
- return XML_ROLE_NONE;
- }
- return syntaxError(state);
-}
-
-static
-int attlist3(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NMTOKEN:
- case XML_TOK_NAME:
- case XML_TOK_PREFIXED_NAME:
- state->handler = attlist4;
- return XML_ROLE_ATTRIBUTE_ENUM_VALUE;
- }
- return syntaxError(state);
-}
-
-static
-int attlist4(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_CLOSE_PAREN:
- state->handler = attlist8;
- return XML_ROLE_NONE;
- case XML_TOK_OR:
- state->handler = attlist3;
- return XML_ROLE_NONE;
- }
- return syntaxError(state);
-}
-
-static
-int attlist5(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_OPEN_PAREN:
- state->handler = attlist6;
- return XML_ROLE_NONE;
- }
- return syntaxError(state);
-}
-
-
-static
-int attlist6(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- state->handler = attlist7;
- return XML_ROLE_ATTRIBUTE_NOTATION_VALUE;
- }
- return syntaxError(state);
-}
-
-static
-int attlist7(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_CLOSE_PAREN:
- state->handler = attlist8;
- return XML_ROLE_NONE;
- case XML_TOK_OR:
- state->handler = attlist6;
- return XML_ROLE_NONE;
- }
- return syntaxError(state);
-}
-
-/* default value */
-static
-int attlist8(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_POUND_NAME:
- if (XmlNameMatchesAscii(enc,
- ptr + MIN_BYTES_PER_CHAR(enc),
- "IMPLIED")) {
- state->handler = attlist1;
- return XML_ROLE_IMPLIED_ATTRIBUTE_VALUE;
- }
- if (XmlNameMatchesAscii(enc,
- ptr + MIN_BYTES_PER_CHAR(enc),
- "REQUIRED")) {
- state->handler = attlist1;
- return XML_ROLE_REQUIRED_ATTRIBUTE_VALUE;
- }
- if (XmlNameMatchesAscii(enc,
- ptr + MIN_BYTES_PER_CHAR(enc),
- "FIXED")) {
- state->handler = attlist9;
- return XML_ROLE_NONE;
- }
- break;
- case XML_TOK_LITERAL:
- state->handler = attlist1;
- return XML_ROLE_DEFAULT_ATTRIBUTE_VALUE;
- }
- return syntaxError(state);
-}
-
-static
-int attlist9(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_LITERAL:
- state->handler = attlist1;
- return XML_ROLE_FIXED_ATTRIBUTE_VALUE;
- }
- return syntaxError(state);
-}
-
-static
-int element0(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- case XML_TOK_PREFIXED_NAME:
- state->handler = element1;
- return XML_ROLE_ELEMENT_NAME;
- }
- return syntaxError(state);
-}
-
-static
-int element1(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- if (XmlNameMatchesAscii(enc, ptr, "EMPTY")) {
- state->handler = declClose;
- return XML_ROLE_CONTENT_EMPTY;
- }
- if (XmlNameMatchesAscii(enc, ptr, "ANY")) {
- state->handler = declClose;
- return XML_ROLE_CONTENT_ANY;
- }
- break;
- case XML_TOK_OPEN_PAREN:
- state->handler = element2;
- state->level = 1;
- return XML_ROLE_GROUP_OPEN;
- }
- return syntaxError(state);
-}
-
-static
-int element2(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_POUND_NAME:
- if (XmlNameMatchesAscii(enc,
- ptr + MIN_BYTES_PER_CHAR(enc),
- "PCDATA")) {
- state->handler = element3;
- return XML_ROLE_CONTENT_PCDATA;
- }
- break;
- case XML_TOK_OPEN_PAREN:
- state->level = 2;
- state->handler = element6;
- return XML_ROLE_GROUP_OPEN;
- case XML_TOK_NAME:
- case XML_TOK_PREFIXED_NAME:
- state->handler = element7;
- return XML_ROLE_CONTENT_ELEMENT;
- case XML_TOK_NAME_QUESTION:
- state->handler = element7;
- return XML_ROLE_CONTENT_ELEMENT_OPT;
- case XML_TOK_NAME_ASTERISK:
- state->handler = element7;
- return XML_ROLE_CONTENT_ELEMENT_REP;
- case XML_TOK_NAME_PLUS:
- state->handler = element7;
- return XML_ROLE_CONTENT_ELEMENT_PLUS;
- }
- return syntaxError(state);
-}
-
-static
-int element3(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_CLOSE_PAREN:
- case XML_TOK_CLOSE_PAREN_ASTERISK:
- state->handler = declClose;
- return XML_ROLE_GROUP_CLOSE_REP;
- case XML_TOK_OR:
- state->handler = element4;
- return XML_ROLE_NONE;
- }
- return syntaxError(state);
-}
-
-static
-int element4(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_NAME:
- case XML_TOK_PREFIXED_NAME:
- state->handler = element5;
- return XML_ROLE_CONTENT_ELEMENT;
- }
- return syntaxError(state);
-}
-
-static
-int element5(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_CLOSE_PAREN_ASTERISK:
- state->handler = declClose;
- return XML_ROLE_GROUP_CLOSE_REP;
- case XML_TOK_OR:
- state->handler = element4;
- return XML_ROLE_NONE;
- }
- return syntaxError(state);
-}
-
-static
-int element6(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_OPEN_PAREN:
- state->level += 1;
- return XML_ROLE_GROUP_OPEN;
- case XML_TOK_NAME:
- case XML_TOK_PREFIXED_NAME:
- state->handler = element7;
- return XML_ROLE_CONTENT_ELEMENT;
- case XML_TOK_NAME_QUESTION:
- state->handler = element7;
- return XML_ROLE_CONTENT_ELEMENT_OPT;
- case XML_TOK_NAME_ASTERISK:
- state->handler = element7;
- return XML_ROLE_CONTENT_ELEMENT_REP;
- case XML_TOK_NAME_PLUS:
- state->handler = element7;
- return XML_ROLE_CONTENT_ELEMENT_PLUS;
- }
- return syntaxError(state);
-}
-
-static
-int element7(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_CLOSE_PAREN:
- state->level -= 1;
- if (state->level == 0)
- state->handler = declClose;
- return XML_ROLE_GROUP_CLOSE;
- case XML_TOK_CLOSE_PAREN_ASTERISK:
- state->level -= 1;
- if (state->level == 0)
- state->handler = declClose;
- return XML_ROLE_GROUP_CLOSE_REP;
- case XML_TOK_CLOSE_PAREN_QUESTION:
- state->level -= 1;
- if (state->level == 0)
- state->handler = declClose;
- return XML_ROLE_GROUP_CLOSE_OPT;
- case XML_TOK_CLOSE_PAREN_PLUS:
- state->level -= 1;
- if (state->level == 0)
- state->handler = declClose;
- return XML_ROLE_GROUP_CLOSE_PLUS;
- case XML_TOK_COMMA:
- state->handler = element6;
- return XML_ROLE_GROUP_SEQUENCE;
- case XML_TOK_OR:
- state->handler = element6;
- return XML_ROLE_GROUP_CHOICE;
- }
- return syntaxError(state);
-}
-
-static
-int declClose(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_PROLOG_S:
- return XML_ROLE_NONE;
- case XML_TOK_DECL_CLOSE:
- state->handler = internalSubset;
- return XML_ROLE_NONE;
- }
- return syntaxError(state);
-}
-
-#if 0
-
-static
-int ignore(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- switch (tok) {
- case XML_TOK_DECL_CLOSE:
- state->handler = internalSubset;
- return 0;
- default:
- return XML_ROLE_NONE;
- }
- return syntaxError(state);
-}
-#endif
-
-static
-int error(PROLOG_STATE *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc)
-{
- return XML_ROLE_NONE;
-}
-
-static
-int syntaxError(PROLOG_STATE *state)
-{
- state->handler = error;
- return XML_ROLE_ERROR;
-}
-
-void XmlPrologStateInit(PROLOG_STATE *state)
-{
- state->handler = prolog0;
-}
diff --git a/srclib/expat-lite/xmlrole.h b/srclib/expat-lite/xmlrole.h
deleted file mode 100644
index 877c40ba1f..0000000000
--- a/srclib/expat-lite/xmlrole.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-#ifndef XmlRole_INCLUDED
-#define XmlRole_INCLUDED 1
-
-#include "xmltok.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum {
- XML_ROLE_ERROR = -1,
- XML_ROLE_NONE = 0,
- XML_ROLE_XML_DECL,
- XML_ROLE_INSTANCE_START,
- XML_ROLE_DOCTYPE_NAME,
- XML_ROLE_DOCTYPE_SYSTEM_ID,
- XML_ROLE_DOCTYPE_PUBLIC_ID,
- XML_ROLE_DOCTYPE_CLOSE,
- XML_ROLE_GENERAL_ENTITY_NAME,
- XML_ROLE_PARAM_ENTITY_NAME,
- XML_ROLE_ENTITY_VALUE,
- XML_ROLE_ENTITY_SYSTEM_ID,
- XML_ROLE_ENTITY_PUBLIC_ID,
- XML_ROLE_ENTITY_NOTATION_NAME,
- XML_ROLE_NOTATION_NAME,
- XML_ROLE_NOTATION_SYSTEM_ID,
- XML_ROLE_NOTATION_NO_SYSTEM_ID,
- XML_ROLE_NOTATION_PUBLIC_ID,
- XML_ROLE_ATTRIBUTE_NAME,
- XML_ROLE_ATTRIBUTE_TYPE_CDATA,
- XML_ROLE_ATTRIBUTE_TYPE_ID,
- XML_ROLE_ATTRIBUTE_TYPE_IDREF,
- XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
- XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
- XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
- XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
- XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
- XML_ROLE_ATTRIBUTE_ENUM_VALUE,
- XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
- XML_ROLE_ATTLIST_ELEMENT_NAME,
- XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
- XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
- XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
- XML_ROLE_FIXED_ATTRIBUTE_VALUE,
- XML_ROLE_ELEMENT_NAME,
- XML_ROLE_CONTENT_ANY,
- XML_ROLE_CONTENT_EMPTY,
- XML_ROLE_CONTENT_PCDATA,
- XML_ROLE_GROUP_OPEN,
- XML_ROLE_GROUP_CLOSE,
- XML_ROLE_GROUP_CLOSE_REP,
- XML_ROLE_GROUP_CLOSE_OPT,
- XML_ROLE_GROUP_CLOSE_PLUS,
- XML_ROLE_GROUP_CHOICE,
- XML_ROLE_GROUP_SEQUENCE,
- XML_ROLE_CONTENT_ELEMENT,
- XML_ROLE_CONTENT_ELEMENT_REP,
- XML_ROLE_CONTENT_ELEMENT_OPT,
- XML_ROLE_CONTENT_ELEMENT_PLUS,
- XML_ROLE_PARAM_ENTITY_REF
-};
-
-typedef struct prolog_state {
- int (*handler)(struct prolog_state *state,
- int tok,
- const char *ptr,
- const char *end,
- const ENCODING *enc);
- unsigned level;
-} PROLOG_STATE;
-
-void XMLTOKAPI XmlPrologStateInit(PROLOG_STATE *);
-
-#define XmlTokenRole(state, tok, ptr, end, enc) \
- (((state)->handler)(state, tok, ptr, end, enc))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* not XmlRole_INCLUDED */
diff --git a/srclib/expat-lite/xmltok.c b/srclib/expat-lite/xmltok.c
deleted file mode 100644
index a847d0108c..0000000000
--- a/srclib/expat-lite/xmltok.c
+++ /dev/null
@@ -1,1527 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-#include "xmldef.h"
-#include "xmltok.h"
-#include "nametab.h"
-
-#define VTABLE1 \
- { PREFIX(prologTok), PREFIX(contentTok), PREFIX(cdataSectionTok) }, \
- { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \
- PREFIX(sameName), \
- PREFIX(nameMatchesAscii), \
- PREFIX(nameLength), \
- PREFIX(skipS), \
- PREFIX(getAtts), \
- PREFIX(charRefNumber), \
- PREFIX(predefinedEntityName), \
- PREFIX(updatePosition), \
- PREFIX(isPublicId)
-
-#define VTABLE VTABLE1, PREFIX(toUtf8), PREFIX(toUtf16)
-
-#define UCS2_GET_NAMING(pages, hi, lo) \
- (namingBitmap[(pages[hi] << 3) + ((lo) >> 5)] & (1 << ((lo) & 0x1F)))
-
-/* A 2 byte UTF-8 representation splits the characters 11 bits
-between the bottom 5 and 6 bits of the bytes.
-We need 8 bits to index into pages, 3 bits to add to that index and
-5 bits to generate the mask. */
-#define UTF8_GET_NAMING2(pages, byte) \
- (namingBitmap[((pages)[(((byte)[0]) >> 2) & 7] << 3) \
- + ((((byte)[0]) & 3) << 1) \
- + ((((byte)[1]) >> 5) & 1)] \
- & (1 << (((byte)[1]) & 0x1F)))
-
-/* A 3 byte UTF-8 representation splits the characters 16 bits
-between the bottom 4, 6 and 6 bits of the bytes.
-We need 8 bits to index into pages, 3 bits to add to that index and
-5 bits to generate the mask. */
-#define UTF8_GET_NAMING3(pages, byte) \
- (namingBitmap[((pages)[((((byte)[0]) & 0xF) << 4) \
- + ((((byte)[1]) >> 2) & 0xF)] \
- << 3) \
- + ((((byte)[1]) & 3) << 1) \
- + ((((byte)[2]) >> 5) & 1)] \
- & (1 << (((byte)[2]) & 0x1F)))
-
-#define UTF8_GET_NAMING(pages, p, n) \
- ((n) == 2 \
- ? UTF8_GET_NAMING2(pages, (const unsigned char *)(p)) \
- : ((n) == 3 \
- ? UTF8_GET_NAMING3(pages, (const unsigned char *)(p)) \
- : 0))
-
-#define UTF8_INVALID3(p) \
- ((*p) == 0xED \
- ? (((p)[1] & 0x20) != 0) \
- : ((*p) == 0xEF \
- ? ((p)[1] == 0xBF && ((p)[2] == 0xBF || (p)[2] == 0xBE)) \
- : 0))
-
-#define UTF8_INVALID4(p) ((*p) == 0xF4 && ((p)[1] & 0x30) != 0)
-
-static
-int isNever(const ENCODING *enc, const char *p)
-{
- return 0;
-}
-
-static
-int utf8_isName2(const ENCODING *enc, const char *p)
-{
- return UTF8_GET_NAMING2(namePages, (const unsigned char *)p);
-}
-
-static
-int utf8_isName3(const ENCODING *enc, const char *p)
-{
- return UTF8_GET_NAMING3(namePages, (const unsigned char *)p);
-}
-
-#define utf8_isName4 isNever
-
-static
-int utf8_isNmstrt2(const ENCODING *enc, const char *p)
-{
- return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p);
-}
-
-static
-int utf8_isNmstrt3(const ENCODING *enc, const char *p)
-{
- return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p);
-}
-
-#define utf8_isNmstrt4 isNever
-
-#define utf8_isInvalid2 isNever
-
-static
-int utf8_isInvalid3(const ENCODING *enc, const char *p)
-{
- return UTF8_INVALID3((const unsigned char *)p);
-}
-
-static
-int utf8_isInvalid4(const ENCODING *enc, const char *p)
-{
- return UTF8_INVALID4((const unsigned char *)p);
-}
-
-struct normal_encoding {
- ENCODING enc;
- unsigned char type[256];
-#ifdef XML_MIN_SIZE
- int (*byteType)(const ENCODING *, const char *);
- int (*isNameMin)(const ENCODING *, const char *);
- int (*isNmstrtMin)(const ENCODING *, const char *);
- int (*byteToAscii)(const ENCODING *, const char *);
- int (*charMatches)(const ENCODING *, const char *, int);
-#endif /* XML_MIN_SIZE */
- int (*isName2)(const ENCODING *, const char *);
- int (*isName3)(const ENCODING *, const char *);
- int (*isName4)(const ENCODING *, const char *);
- int (*isNmstrt2)(const ENCODING *, const char *);
- int (*isNmstrt3)(const ENCODING *, const char *);
- int (*isNmstrt4)(const ENCODING *, const char *);
- int (*isInvalid2)(const ENCODING *, const char *);
- int (*isInvalid3)(const ENCODING *, const char *);
- int (*isInvalid4)(const ENCODING *, const char *);
-};
-
-#ifdef XML_MIN_SIZE
-
-#define STANDARD_VTABLE(E) \
- E ## byteType, \
- E ## isNameMin, \
- E ## isNmstrtMin, \
- E ## byteToAscii, \
- E ## charMatches,
-
-#else
-
-#define STANDARD_VTABLE(E) /* as nothing */
-
-#endif
-
-#define NORMAL_VTABLE(E) \
- E ## isName2, \
- E ## isName3, \
- E ## isName4, \
- E ## isNmstrt2, \
- E ## isNmstrt3, \
- E ## isNmstrt4, \
- E ## isInvalid2, \
- E ## isInvalid3, \
- E ## isInvalid4
-
-static int checkCharRefNumber(int);
-
-#include "xmltok_impl.h"
-
-#ifdef XML_MIN_SIZE
-#define sb_isNameMin isNever
-#define sb_isNmstrtMin isNever
-#endif
-
-#ifdef XML_MIN_SIZE
-#define MINBPC(enc) ((enc)->minBytesPerChar)
-#else
-/* minimum bytes per character */
-#define MINBPC(enc) 1
-#endif
-
-#define SB_BYTE_TYPE(enc, p) \
- (((struct normal_encoding *)(enc))->type[(unsigned char)*(p)])
-
-#ifdef XML_MIN_SIZE
-static
-int sb_byteType(const ENCODING *enc, const char *p)
-{
- return SB_BYTE_TYPE(enc, p);
-}
-#define BYTE_TYPE(enc, p) \
- (((const struct normal_encoding *)(enc))->byteType(enc, p))
-#else
-#define BYTE_TYPE(enc, p) SB_BYTE_TYPE(enc, p)
-#endif
-
-#ifdef XML_MIN_SIZE
-#define BYTE_TO_ASCII(enc, p) \
- (((const struct normal_encoding *)(enc))->byteToAscii(enc, p))
-static
-int sb_byteToAscii(const ENCODING *enc, const char *p)
-{
- return *p;
-}
-#else
-#define BYTE_TO_ASCII(enc, p) (*p)
-#endif
-
-#define IS_NAME_CHAR(enc, p, n) \
- (((const struct normal_encoding *)(enc))->isName ## n(enc, p))
-#define IS_NMSTRT_CHAR(enc, p, n) \
- (((const struct normal_encoding *)(enc))->isNmstrt ## n(enc, p))
-#define IS_INVALID_CHAR(enc, p, n) \
- (((const struct normal_encoding *)(enc))->isInvalid ## n(enc, p))
-
-#ifdef XML_MIN_SIZE
-#define IS_NAME_CHAR_MINBPC(enc, p) \
- (((const struct normal_encoding *)(enc))->isNameMin(enc, p))
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) \
- (((const struct normal_encoding *)(enc))->isNmstrtMin(enc, p))
-#else
-#define IS_NAME_CHAR_MINBPC(enc, p) (0)
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) (0)
-#endif
-
-#ifdef XML_MIN_SIZE
-#define CHAR_MATCHES(enc, p, c) \
- (((const struct normal_encoding *)(enc))->charMatches(enc, p, c))
-static
-int sb_charMatches(const ENCODING *enc, const char *p, int c)
-{
- return *p == c;
-}
-#else
-/* c is an ASCII character */
-#define CHAR_MATCHES(enc, p, c) (*(p) == c)
-#endif
-
-#define PREFIX(ident) normal_ ## ident
-#include "xmltok_impl.c"
-
-#undef MINBPC
-#undef BYTE_TYPE
-#undef BYTE_TO_ASCII
-#undef CHAR_MATCHES
-#undef IS_NAME_CHAR
-#undef IS_NAME_CHAR_MINBPC
-#undef IS_NMSTRT_CHAR
-#undef IS_NMSTRT_CHAR_MINBPC
-#undef IS_INVALID_CHAR
-
-enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */
- UTF8_cval1 = 0x00,
- UTF8_cval2 = 0xc0,
- UTF8_cval3 = 0xe0,
- UTF8_cval4 = 0xf0
-};
-
-static
-void utf8_toUtf8(const ENCODING *enc,
- const char **fromP, const char *fromLim,
- char **toP, const char *toLim)
-{
- char *to;
- const char *from;
- if (fromLim - *fromP > toLim - *toP) {
- /* Avoid copying partial characters. */
- for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--)
- if (((unsigned char)fromLim[-1] & 0xc0) != 0x80)
- break;
- }
- for (to = *toP, from = *fromP; from != fromLim; from++, to++)
- *to = *from;
- *fromP = from;
- *toP = to;
-}
-
-static
-void utf8_toUtf16(const ENCODING *enc,
- const char **fromP, const char *fromLim,
- unsigned short **toP, const unsigned short *toLim)
-{
- unsigned short *to = *toP;
- const char *from = *fromP;
- while (from != fromLim && to != toLim) {
- switch (((struct normal_encoding *)enc)->type[(unsigned char)*from]) {
- case BT_LEAD2:
- *to++ = ((from[0] & 0x1f) << 6) | (from[1] & 0x3f);
- from += 2;
- break;
- case BT_LEAD3:
- *to++ = ((from[0] & 0xf) << 12) | ((from[1] & 0x3f) << 6) | (from[2] & 0x3f);
- from += 3;
- break;
- case BT_LEAD4:
- {
- unsigned long n;
- if (to + 1 == toLim)
- break;
- n = ((from[0] & 0x7) << 18) | ((from[1] & 0x3f) << 12) | ((from[2] & 0x3f) << 6) | (from[3] & 0x3f);
- n -= 0x10000;
- to[0] = (unsigned short)((n >> 10) | 0xD800);
- to[1] = (unsigned short)((n & 0x3FF) | 0xDC00);
- to += 2;
- from += 4;
- }
- break;
- default:
- *to++ = *from++;
- break;
- }
- }
- *fromP = from;
- *toP = to;
-}
-
-#ifdef XML_NS
-static const struct normal_encoding utf8_encoding_ns = {
- { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
- {
-#include "asciitab.h"
-#include "utf8tab.h"
- },
- STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
-#endif
-
-static const struct normal_encoding utf8_encoding = {
- { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
- {
-#define BT_COLON BT_NMSTRT
-#include "asciitab.h"
-#undef BT_COLON
-#include "utf8tab.h"
- },
- STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
-
-#ifdef XML_NS
-
-static const struct normal_encoding internal_utf8_encoding_ns = {
- { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
- {
-#include "iasciitab.h"
-#include "utf8tab.h"
- },
- STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
-
-#endif
-
-static const struct normal_encoding internal_utf8_encoding = {
- { VTABLE1, utf8_toUtf8, utf8_toUtf16, 1, 1, 0 },
- {
-#define BT_COLON BT_NMSTRT
-#include "iasciitab.h"
-#undef BT_COLON
-#include "utf8tab.h"
- },
- STANDARD_VTABLE(sb_) NORMAL_VTABLE(utf8_)
-};
-
-static
-void latin1_toUtf8(const ENCODING *enc,
- const char **fromP, const char *fromLim,
- char **toP, const char *toLim)
-{
- for (;;) {
- unsigned char c;
- if (*fromP == fromLim)
- break;
- c = (unsigned char)**fromP;
- if (c & 0x80) {
- if (toLim - *toP < 2)
- break;
- *(*toP)++ = ((c >> 6) | UTF8_cval2);
- *(*toP)++ = ((c & 0x3f) | 0x80);
- (*fromP)++;
- }
- else {
- if (*toP == toLim)
- break;
- *(*toP)++ = *(*fromP)++;
- }
- }
-}
-
-static
-void latin1_toUtf16(const ENCODING *enc,
- const char **fromP, const char *fromLim,
- unsigned short **toP, const unsigned short *toLim)
-{
- while (*fromP != fromLim && *toP != toLim)
- *(*toP)++ = (unsigned char)*(*fromP)++;
-}
-
-#ifdef XML_NS
-
-static const struct normal_encoding latin1_encoding_ns = {
- { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 },
- {
-#include "asciitab.h"
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(sb_)
-};
-
-#endif
-
-static const struct normal_encoding latin1_encoding = {
- { VTABLE1, latin1_toUtf8, latin1_toUtf16, 1, 0, 0 },
- {
-#define BT_COLON BT_NMSTRT
-#include "asciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(sb_)
-};
-
-static
-void ascii_toUtf8(const ENCODING *enc,
- const char **fromP, const char *fromLim,
- char **toP, const char *toLim)
-{
- while (*fromP != fromLim && *toP != toLim)
- *(*toP)++ = *(*fromP)++;
-}
-
-#ifdef XML_NS
-
-static const struct normal_encoding ascii_encoding_ns = {
- { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 },
- {
-#include "asciitab.h"
-/* BT_NONXML == 0 */
- },
- STANDARD_VTABLE(sb_)
-};
-
-#endif
-
-static const struct normal_encoding ascii_encoding = {
- { VTABLE1, ascii_toUtf8, latin1_toUtf16, 1, 1, 0 },
- {
-#define BT_COLON BT_NMSTRT
-#include "asciitab.h"
-#undef BT_COLON
-/* BT_NONXML == 0 */
- },
- STANDARD_VTABLE(sb_)
-};
-
-static int unicode_byte_type(char hi, char lo)
-{
- switch ((unsigned char)hi) {
- case 0xD8: case 0xD9: case 0xDA: case 0xDB:
- return BT_LEAD4;
- case 0xDC: case 0xDD: case 0xDE: case 0xDF:
- return BT_TRAIL;
- case 0xFF:
- switch ((unsigned char)lo) {
- case 0xFF:
- case 0xFE:
- return BT_NONXML;
- }
- break;
- }
- return BT_NONASCII;
-}
-
-#define DEFINE_UTF16_TO_UTF8(E) \
-static \
-void E ## toUtf8(const ENCODING *enc, \
- const char **fromP, const char *fromLim, \
- char **toP, const char *toLim) \
-{ \
- const char *from; \
- for (from = *fromP; from != fromLim; from += 2) { \
- int plane; \
- unsigned char lo2; \
- unsigned char lo = GET_LO(from); \
- unsigned char hi = GET_HI(from); \
- switch (hi) { \
- case 0: \
- if (lo < 0x80) { \
- if (*toP == toLim) { \
- *fromP = from; \
- return; \
- } \
- *(*toP)++ = lo; \
- break; \
- } \
- /* fall through */ \
- case 0x1: case 0x2: case 0x3: \
- case 0x4: case 0x5: case 0x6: case 0x7: \
- if (toLim - *toP < 2) { \
- *fromP = from; \
- return; \
- } \
- *(*toP)++ = ((lo >> 6) | (hi << 2) | UTF8_cval2); \
- *(*toP)++ = ((lo & 0x3f) | 0x80); \
- break; \
- default: \
- if (toLim - *toP < 3) { \
- *fromP = from; \
- return; \
- } \
- /* 16 bits divided 4, 6, 6 amongst 3 bytes */ \
- *(*toP)++ = ((hi >> 4) | UTF8_cval3); \
- *(*toP)++ = (((hi & 0xf) << 2) | (lo >> 6) | 0x80); \
- *(*toP)++ = ((lo & 0x3f) | 0x80); \
- break; \
- case 0xD8: case 0xD9: case 0xDA: case 0xDB: \
- if (toLim - *toP < 4) { \
- *fromP = from; \
- return; \
- } \
- plane = (((hi & 0x3) << 2) | ((lo >> 6) & 0x3)) + 1; \
- *(*toP)++ = ((plane >> 2) | UTF8_cval4); \
- *(*toP)++ = (((lo >> 2) & 0xF) | ((plane & 0x3) << 4) | 0x80); \
- from += 2; \
- lo2 = GET_LO(from); \
- *(*toP)++ = (((lo & 0x3) << 4) \
- | ((GET_HI(from) & 0x3) << 2) \
- | (lo2 >> 6) \
- | 0x80); \
- *(*toP)++ = ((lo2 & 0x3f) | 0x80); \
- break; \
- } \
- } \
- *fromP = from; \
-}
-
-#define DEFINE_UTF16_TO_UTF16(E) \
-static \
-void E ## toUtf16(const ENCODING *enc, \
- const char **fromP, const char *fromLim, \
- unsigned short **toP, const unsigned short *toLim) \
-{ \
- /* Avoid copying first half only of surrogate */ \
- if (fromLim - *fromP > ((toLim - *toP) << 1) \
- && (GET_HI(fromLim - 2) & 0xF8) == 0xD8) \
- fromLim -= 2; \
- for (; *fromP != fromLim && *toP != toLim; *fromP += 2) \
- *(*toP)++ = (GET_HI(*fromP) << 8) | GET_LO(*fromP); \
-}
-
-#define SET2(ptr, ch) \
- (((ptr)[0] = ((ch) & 0xff)), ((ptr)[1] = ((ch) >> 8)))
-#define GET_LO(ptr) ((unsigned char)(ptr)[0])
-#define GET_HI(ptr) ((unsigned char)(ptr)[1])
-
-DEFINE_UTF16_TO_UTF8(little2_)
-DEFINE_UTF16_TO_UTF16(little2_)
-
-#undef SET2
-#undef GET_LO
-#undef GET_HI
-
-#define SET2(ptr, ch) \
- (((ptr)[0] = ((ch) >> 8)), ((ptr)[1] = ((ch) & 0xFF)))
-#define GET_LO(ptr) ((unsigned char)(ptr)[1])
-#define GET_HI(ptr) ((unsigned char)(ptr)[0])
-
-DEFINE_UTF16_TO_UTF8(big2_)
-DEFINE_UTF16_TO_UTF16(big2_)
-
-#undef SET2
-#undef GET_LO
-#undef GET_HI
-
-#define LITTLE2_BYTE_TYPE(enc, p) \
- ((p)[1] == 0 \
- ? ((struct normal_encoding *)(enc))->type[(unsigned char)*(p)] \
- : unicode_byte_type((p)[1], (p)[0]))
-#define LITTLE2_BYTE_TO_ASCII(enc, p) ((p)[1] == 0 ? (p)[0] : -1)
-#define LITTLE2_CHAR_MATCHES(enc, p, c) ((p)[1] == 0 && (p)[0] == c)
-#define LITTLE2_IS_NAME_CHAR_MINBPC(enc, p) \
- UCS2_GET_NAMING(namePages, (unsigned char)p[1], (unsigned char)p[0])
-#define LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
- UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[1], (unsigned char)p[0])
-
-#ifdef XML_MIN_SIZE
-
-static
-int little2_byteType(const ENCODING *enc, const char *p)
-{
- return LITTLE2_BYTE_TYPE(enc, p);
-}
-
-static
-int little2_byteToAscii(const ENCODING *enc, const char *p)
-{
- return LITTLE2_BYTE_TO_ASCII(enc, p);
-}
-
-static
-int little2_charMatches(const ENCODING *enc, const char *p, int c)
-{
- return LITTLE2_CHAR_MATCHES(enc, p, c);
-}
-
-static
-int little2_isNameMin(const ENCODING *enc, const char *p)
-{
- return LITTLE2_IS_NAME_CHAR_MINBPC(enc, p);
-}
-
-static
-int little2_isNmstrtMin(const ENCODING *enc, const char *p)
-{
- return LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p);
-}
-
-#undef VTABLE
-#define VTABLE VTABLE1, little2_toUtf8, little2_toUtf16
-
-#else /* not XML_MIN_SIZE */
-
-#undef PREFIX
-#define PREFIX(ident) little2_ ## ident
-#define MINBPC(enc) 2
-/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
-#define BYTE_TYPE(enc, p) LITTLE2_BYTE_TYPE(enc, p)
-#define BYTE_TO_ASCII(enc, p) LITTLE2_BYTE_TO_ASCII(enc, p)
-#define CHAR_MATCHES(enc, p, c) LITTLE2_CHAR_MATCHES(enc, p, c)
-#define IS_NAME_CHAR(enc, p, n) 0
-#define IS_NAME_CHAR_MINBPC(enc, p) LITTLE2_IS_NAME_CHAR_MINBPC(enc, p)
-#define IS_NMSTRT_CHAR(enc, p, n) (0)
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) LITTLE2_IS_NMSTRT_CHAR_MINBPC(enc, p)
-
-#include "xmltok_impl.c"
-
-#undef MINBPC
-#undef BYTE_TYPE
-#undef BYTE_TO_ASCII
-#undef CHAR_MATCHES
-#undef IS_NAME_CHAR
-#undef IS_NAME_CHAR_MINBPC
-#undef IS_NMSTRT_CHAR
-#undef IS_NMSTRT_CHAR_MINBPC
-#undef IS_INVALID_CHAR
-
-#endif /* not XML_MIN_SIZE */
-
-#ifdef XML_NS
-
-static const struct normal_encoding little2_encoding_ns = {
- { VTABLE, 2, 0,
-#if XML_BYTE_ORDER == 12
- 1
-#else
- 0
-#endif
- },
- {
-#include "asciitab.h"
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(little2_)
-};
-
-#endif
-
-static const struct normal_encoding little2_encoding = {
- { VTABLE, 2, 0,
-#if XML_BYTE_ORDER == 12
- 1
-#else
- 0
-#endif
- },
- {
-#define BT_COLON BT_NMSTRT
-#include "asciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(little2_)
-};
-
-#if XML_BYTE_ORDER != 21
-
-#ifdef XML_NS
-
-static const struct normal_encoding internal_little2_encoding_ns = {
- { VTABLE, 2, 0, 1 },
- {
-#include "iasciitab.h"
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(little2_)
-};
-
-#endif
-
-static const struct normal_encoding internal_little2_encoding = {
- { VTABLE, 2, 0, 1 },
- {
-#define BT_COLON BT_NMSTRT
-#include "iasciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(little2_)
-};
-
-#endif
-
-
-#define BIG2_BYTE_TYPE(enc, p) \
- ((p)[0] == 0 \
- ? ((struct normal_encoding *)(enc))->type[(unsigned char)(p)[1]] \
- : unicode_byte_type((p)[0], (p)[1]))
-#define BIG2_BYTE_TO_ASCII(enc, p) ((p)[0] == 0 ? (p)[1] : -1)
-#define BIG2_CHAR_MATCHES(enc, p, c) ((p)[0] == 0 && (p)[1] == c)
-#define BIG2_IS_NAME_CHAR_MINBPC(enc, p) \
- UCS2_GET_NAMING(namePages, (unsigned char)p[0], (unsigned char)p[1])
-#define BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p) \
- UCS2_GET_NAMING(nmstrtPages, (unsigned char)p[0], (unsigned char)p[1])
-
-#ifdef XML_MIN_SIZE
-
-static
-int big2_byteType(const ENCODING *enc, const char *p)
-{
- return BIG2_BYTE_TYPE(enc, p);
-}
-
-static
-int big2_byteToAscii(const ENCODING *enc, const char *p)
-{
- return BIG2_BYTE_TO_ASCII(enc, p);
-}
-
-static
-int big2_charMatches(const ENCODING *enc, const char *p, int c)
-{
- return BIG2_CHAR_MATCHES(enc, p, c);
-}
-
-static
-int big2_isNameMin(const ENCODING *enc, const char *p)
-{
- return BIG2_IS_NAME_CHAR_MINBPC(enc, p);
-}
-
-static
-int big2_isNmstrtMin(const ENCODING *enc, const char *p)
-{
- return BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p);
-}
-
-#undef VTABLE
-#define VTABLE VTABLE1, big2_toUtf8, big2_toUtf16
-
-#else /* not XML_MIN_SIZE */
-
-#undef PREFIX
-#define PREFIX(ident) big2_ ## ident
-#define MINBPC(enc) 2
-/* CHAR_MATCHES is guaranteed to have MINBPC bytes available. */
-#define BYTE_TYPE(enc, p) BIG2_BYTE_TYPE(enc, p)
-#define BYTE_TO_ASCII(enc, p) BIG2_BYTE_TO_ASCII(enc, p)
-#define CHAR_MATCHES(enc, p, c) BIG2_CHAR_MATCHES(enc, p, c)
-#define IS_NAME_CHAR(enc, p, n) 0
-#define IS_NAME_CHAR_MINBPC(enc, p) BIG2_IS_NAME_CHAR_MINBPC(enc, p)
-#define IS_NMSTRT_CHAR(enc, p, n) (0)
-#define IS_NMSTRT_CHAR_MINBPC(enc, p) BIG2_IS_NMSTRT_CHAR_MINBPC(enc, p)
-
-#include "xmltok_impl.c"
-
-#undef MINBPC
-#undef BYTE_TYPE
-#undef BYTE_TO_ASCII
-#undef CHAR_MATCHES
-#undef IS_NAME_CHAR
-#undef IS_NAME_CHAR_MINBPC
-#undef IS_NMSTRT_CHAR
-#undef IS_NMSTRT_CHAR_MINBPC
-#undef IS_INVALID_CHAR
-
-#endif /* not XML_MIN_SIZE */
-
-#ifdef XML_NS
-
-static const struct normal_encoding big2_encoding_ns = {
- { VTABLE, 2, 0,
-#if XML_BYTE_ORDER == 21
- 1
-#else
- 0
-#endif
- },
- {
-#include "asciitab.h"
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(big2_)
-};
-
-#endif
-
-static const struct normal_encoding big2_encoding = {
- { VTABLE, 2, 0,
-#if XML_BYTE_ORDER == 21
- 1
-#else
- 0
-#endif
- },
- {
-#define BT_COLON BT_NMSTRT
-#include "asciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(big2_)
-};
-
-#if XML_BYTE_ORDER != 12
-
-#ifdef XML_NS
-
-static const struct normal_encoding internal_big2_encoding_ns = {
- { VTABLE, 2, 0, 1 },
- {
-#include "iasciitab.h"
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(big2_)
-};
-
-#endif
-
-static const struct normal_encoding internal_big2_encoding = {
- { VTABLE, 2, 0, 1 },
- {
-#define BT_COLON BT_NMSTRT
-#include "iasciitab.h"
-#undef BT_COLON
-#include "latin1tab.h"
- },
- STANDARD_VTABLE(big2_)
-};
-
-#endif
-
-#undef PREFIX
-
-static
-int streqci(const char *s1, const char *s2)
-{
- for (;;) {
- char c1 = *s1++;
- char c2 = *s2++;
- if ('a' <= c1 && c1 <= 'z')
- c1 += 'A' - 'a';
- if ('a' <= c2 && c2 <= 'z')
- c2 += 'A' - 'a';
- if (c1 != c2)
- return 0;
- if (!c1)
- break;
- }
- return 1;
-}
-
-static
-void initUpdatePosition(const ENCODING *enc, const char *ptr,
- const char *end, POSITION *pos)
-{
- normal_updatePosition(&utf8_encoding.enc, ptr, end, pos);
-}
-
-static
-int toAscii(const ENCODING *enc, const char *ptr, const char *end)
-{
- char buf[1];
- char *p = buf;
- XmlUtf8Convert(enc, &ptr, end, &p, p + 1);
- if (p == buf)
- return -1;
- else
- return buf[0];
-}
-
-static
-int isSpace(int c)
-{
- switch (c) {
- case 0x20:
- case 0xD:
- case 0xA:
- case 0x9:
- return 1;
- }
- return 0;
-}
-
-/* Return 1 if there's just optional white space
-or there's an S followed by name=val. */
-static
-int parsePseudoAttribute(const ENCODING *enc,
- const char *ptr,
- const char *end,
- const char **namePtr,
- const char **valPtr,
- const char **nextTokPtr)
-{
- int c;
- char open;
- if (ptr == end) {
- *namePtr = 0;
- return 1;
- }
- if (!isSpace(toAscii(enc, ptr, end))) {
- *nextTokPtr = ptr;
- return 0;
- }
- do {
- ptr += enc->minBytesPerChar;
- } while (isSpace(toAscii(enc, ptr, end)));
- if (ptr == end) {
- *namePtr = 0;
- return 1;
- }
- *namePtr = ptr;
- for (;;) {
- c = toAscii(enc, ptr, end);
- if (c == -1) {
- *nextTokPtr = ptr;
- return 0;
- }
- if (c == '=')
- break;
- if (isSpace(c)) {
- do {
- ptr += enc->minBytesPerChar;
- } while (isSpace(c = toAscii(enc, ptr, end)));
- if (c != '=') {
- *nextTokPtr = ptr;
- return 0;
- }
- break;
- }
- ptr += enc->minBytesPerChar;
- }
- if (ptr == *namePtr) {
- *nextTokPtr = ptr;
- return 0;
- }
- ptr += enc->minBytesPerChar;
- c = toAscii(enc, ptr, end);
- while (isSpace(c)) {
- ptr += enc->minBytesPerChar;
- c = toAscii(enc, ptr, end);
- }
- if (c != '"' && c != '\'') {
- *nextTokPtr = ptr;
- return 0;
- }
- open = c;
- ptr += enc->minBytesPerChar;
- *valPtr = ptr;
- for (;; ptr += enc->minBytesPerChar) {
- c = toAscii(enc, ptr, end);
- if (c == open)
- break;
- if (!('a' <= c && c <= 'z')
- && !('A' <= c && c <= 'Z')
- && !('0' <= c && c <= '9')
- && c != '.'
- && c != '-'
- && c != '_') {
- *nextTokPtr = ptr;
- return 0;
- }
- }
- *nextTokPtr = ptr + enc->minBytesPerChar;
- return 1;
-}
-
-static
-int doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *,
- const char *,
- const char *),
- int isGeneralTextEntity,
- const ENCODING *enc,
- const char *ptr,
- const char *end,
- const char **badPtr,
- const char **versionPtr,
- const char **encodingName,
- const ENCODING **encoding,
- int *standalone)
-{
- const char *val = 0;
- const char *name = 0;
- ptr += 5 * enc->minBytesPerChar;
- end -= 2 * enc->minBytesPerChar;
- if (!parsePseudoAttribute(enc, ptr, end, &name, &val, &ptr) || !name) {
- *badPtr = ptr;
- return 0;
- }
- if (!XmlNameMatchesAscii(enc, name, "version")) {
- if (!isGeneralTextEntity) {
- *badPtr = name;
- return 0;
- }
- }
- else {
- if (versionPtr)
- *versionPtr = val;
- if (!parsePseudoAttribute(enc, ptr, end, &name, &val, &ptr)) {
- *badPtr = ptr;
- return 0;
- }
- if (!name) {
- if (isGeneralTextEntity) {
- /* a TextDecl must have an EncodingDecl */
- *badPtr = ptr;
- return 0;
- }
- return 1;
- }
- }
- if (XmlNameMatchesAscii(enc, name, "encoding")) {
- int c = toAscii(enc, val, end);
- if (!('a' <= c && c <= 'z') && !('A' <= c && c <= 'Z')) {
- *badPtr = val;
- return 0;
- }
- if (encodingName)
- *encodingName = val;
- if (encoding)
- *encoding = encodingFinder(enc, val, ptr - enc->minBytesPerChar);
- if (!parsePseudoAttribute(enc, ptr, end, &name, &val, &ptr)) {
- *badPtr = ptr;
- return 0;
- }
- if (!name)
- return 1;
- }
- if (!XmlNameMatchesAscii(enc, name, "standalone") || isGeneralTextEntity) {
- *badPtr = name;
- return 0;
- }
- if (XmlNameMatchesAscii(enc, val, "yes")) {
- if (standalone)
- *standalone = 1;
- }
- else if (XmlNameMatchesAscii(enc, val, "no")) {
- if (standalone)
- *standalone = 0;
- }
- else {
- *badPtr = val;
- return 0;
- }
- while (isSpace(toAscii(enc, ptr, end)))
- ptr += enc->minBytesPerChar;
- if (ptr != end) {
- *badPtr = ptr;
- return 0;
- }
- return 1;
-}
-
-static
-int checkCharRefNumber(int result)
-{
- switch (result >> 8) {
- case 0xD8: case 0xD9: case 0xDA: case 0xDB:
- case 0xDC: case 0xDD: case 0xDE: case 0xDF:
- return -1;
- case 0:
- if (latin1_encoding.type[result] == BT_NONXML)
- return -1;
- break;
- case 0xFF:
- if (result == 0xFFFE || result == 0xFFFF)
- return -1;
- break;
- }
- return result;
-}
-
-int XmlUtf8Encode(int c, char *buf)
-{
- enum {
- /* minN is minimum legal resulting value for N byte sequence */
- min2 = 0x80,
- min3 = 0x800,
- min4 = 0x10000
- };
-
- if (c < 0)
- return 0;
- if (c < min2) {
- buf[0] = (c | UTF8_cval1);
- return 1;
- }
- if (c < min3) {
- buf[0] = ((c >> 6) | UTF8_cval2);
- buf[1] = ((c & 0x3f) | 0x80);
- return 2;
- }
- if (c < min4) {
- buf[0] = ((c >> 12) | UTF8_cval3);
- buf[1] = (((c >> 6) & 0x3f) | 0x80);
- buf[2] = ((c & 0x3f) | 0x80);
- return 3;
- }
- if (c < 0x110000) {
- buf[0] = ((c >> 18) | UTF8_cval4);
- buf[1] = (((c >> 12) & 0x3f) | 0x80);
- buf[2] = (((c >> 6) & 0x3f) | 0x80);
- buf[3] = ((c & 0x3f) | 0x80);
- return 4;
- }
- return 0;
-}
-
-int XmlUtf16Encode(int charNum, unsigned short *buf)
-{
- if (charNum < 0)
- return 0;
- if (charNum < 0x10000) {
- buf[0] = charNum;
- return 1;
- }
- if (charNum < 0x110000) {
- charNum -= 0x10000;
- buf[0] = (charNum >> 10) + 0xD800;
- buf[1] = (charNum & 0x3FF) + 0xDC00;
- return 2;
- }
- return 0;
-}
-
-struct unknown_encoding {
- struct normal_encoding normal;
- int (*convert)(void *userData, const char *p);
- void *userData;
- unsigned short utf16[256];
- char utf8[256][4];
-};
-
-int XmlSizeOfUnknownEncoding(void)
-{
- return sizeof(struct unknown_encoding);
-}
-
-static
-int unknown_isName(const ENCODING *enc, const char *p)
-{
- int c = ((const struct unknown_encoding *)enc)
- ->convert(((const struct unknown_encoding *)enc)->userData, p);
- if (c & ~0xFFFF)
- return 0;
- return UCS2_GET_NAMING(namePages, c >> 8, c & 0xFF);
-}
-
-static
-int unknown_isNmstrt(const ENCODING *enc, const char *p)
-{
- int c = ((const struct unknown_encoding *)enc)
- ->convert(((const struct unknown_encoding *)enc)->userData, p);
- if (c & ~0xFFFF)
- return 0;
- return UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xFF);
-}
-
-static
-int unknown_isInvalid(const ENCODING *enc, const char *p)
-{
- int c = ((const struct unknown_encoding *)enc)
- ->convert(((const struct unknown_encoding *)enc)->userData, p);
- return (c & ~0xFFFF) || checkCharRefNumber(c) < 0;
-}
-
-static
-void unknown_toUtf8(const ENCODING *enc,
- const char **fromP, const char *fromLim,
- char **toP, const char *toLim)
-{
- char buf[XML_UTF8_ENCODE_MAX];
- for (;;) {
- const char *utf8;
- int n;
- if (*fromP == fromLim)
- break;
- utf8 = ((const struct unknown_encoding *)enc)->utf8[(unsigned char)**fromP];
- n = *utf8++;
- if (n == 0) {
- int c = ((const struct unknown_encoding *)enc)
- ->convert(((const struct unknown_encoding *)enc)->userData, *fromP);
- n = XmlUtf8Encode(c, buf);
- if (n > toLim - *toP)
- break;
- utf8 = buf;
- *fromP += ((const struct normal_encoding *)enc)->type[(unsigned char)**fromP]
- - (BT_LEAD2 - 2);
- }
- else {
- if (n > toLim - *toP)
- break;
- (*fromP)++;
- }
- do {
- *(*toP)++ = *utf8++;
- } while (--n != 0);
- }
-}
-
-static
-void unknown_toUtf16(const ENCODING *enc,
- const char **fromP, const char *fromLim,
- unsigned short **toP, const unsigned short *toLim)
-{
- while (*fromP != fromLim && *toP != toLim) {
- unsigned short c
- = ((const struct unknown_encoding *)enc)->utf16[(unsigned char)**fromP];
- if (c == 0) {
- c = (unsigned short)((const struct unknown_encoding *)enc)
- ->convert(((const struct unknown_encoding *)enc)->userData, *fromP);
- *fromP += ((const struct normal_encoding *)enc)->type[(unsigned char)**fromP]
- - (BT_LEAD2 - 2);
- }
- else
- (*fromP)++;
- *(*toP)++ = c;
- }
-}
-
-ENCODING *
-XmlInitUnknownEncoding(void *mem,
- int *table,
- int (*convert)(void *userData, const char *p),
- void *userData)
-{
- int i;
- struct unknown_encoding *e = mem;
- for (i = 0; i < sizeof(struct normal_encoding); i++)
- ((char *)mem)[i] = ((char *)&latin1_encoding)[i];
- for (i = 0; i < 128; i++)
- if (latin1_encoding.type[i] != BT_OTHER
- && latin1_encoding.type[i] != BT_NONXML
- && table[i] != i)
- return 0;
- for (i = 0; i < 256; i++) {
- int c = table[i];
- if (c == -1) {
- e->normal.type[i] = BT_MALFORM;
- /* This shouldn't really get used. */
- e->utf16[i] = 0xFFFF;
- e->utf8[i][0] = 1;
- e->utf8[i][1] = 0;
- }
- else if (c < 0) {
- if (c < -4)
- return 0;
- e->normal.type[i] = BT_LEAD2 - (c + 2);
- e->utf8[i][0] = 0;
- e->utf16[i] = 0;
- }
- else if (c < 0x80) {
- if (latin1_encoding.type[c] != BT_OTHER
- && latin1_encoding.type[c] != BT_NONXML
- && c != i)
- return 0;
- e->normal.type[i] = latin1_encoding.type[c];
- e->utf8[i][0] = 1;
- e->utf8[i][1] = (char)c;
- e->utf16[i] = c == 0 ? 0xFFFF : c;
- }
- else if (checkCharRefNumber(c) < 0) {
- e->normal.type[i] = BT_NONXML;
- /* This shouldn't really get used. */
- e->utf16[i] = 0xFFFF;
- e->utf8[i][0] = 1;
- e->utf8[i][1] = 0;
- }
- else {
- if (c > 0xFFFF)
- return 0;
- if (UCS2_GET_NAMING(nmstrtPages, c >> 8, c & 0xff))
- e->normal.type[i] = BT_NMSTRT;
- else if (UCS2_GET_NAMING(namePages, c >> 8, c & 0xff))
- e->normal.type[i] = BT_NAME;
- else
- e->normal.type[i] = BT_OTHER;
- e->utf8[i][0] = (char)XmlUtf8Encode(c, e->utf8[i] + 1);
- e->utf16[i] = c;
- }
- }
- e->userData = userData;
- e->convert = convert;
- if (convert) {
- e->normal.isName2 = unknown_isName;
- e->normal.isName3 = unknown_isName;
- e->normal.isName4 = unknown_isName;
- e->normal.isNmstrt2 = unknown_isNmstrt;
- e->normal.isNmstrt3 = unknown_isNmstrt;
- e->normal.isNmstrt4 = unknown_isNmstrt;
- e->normal.isInvalid2 = unknown_isInvalid;
- e->normal.isInvalid3 = unknown_isInvalid;
- e->normal.isInvalid4 = unknown_isInvalid;
- }
- e->normal.enc.utf8Convert = unknown_toUtf8;
- e->normal.enc.utf16Convert = unknown_toUtf16;
- return &(e->normal.enc);
-}
-
-/* If this enumeration is changed, getEncodingIndex and encodings
-must also be changed. */
-enum {
- UNKNOWN_ENC = -1,
- ISO_8859_1_ENC = 0,
- US_ASCII_ENC,
- UTF_8_ENC,
- UTF_16_ENC,
- UTF_16BE_ENC,
- UTF_16LE_ENC,
- /* must match encodingNames up to here */
- NO_ENC
-};
-
-static
-int getEncodingIndex(const char *name)
-{
- static const char *encodingNames[] = {
- "ISO-8859-1",
- "US-ASCII",
- "UTF-8",
- "UTF-16",
- "UTF-16BE"
- "UTF-16LE",
- };
- int i;
- if (name == 0)
- return NO_ENC;
- for (i = 0; i < sizeof(encodingNames)/sizeof(encodingNames[0]); i++)
- if (streqci(name, encodingNames[i]))
- return i;
- return UNKNOWN_ENC;
-}
-
-/* For binary compatibility, we store the index of the encoding specified
-at initialization in the isUtf16 member. */
-
-#define INIT_ENC_INDEX(enc) ((enc)->initEnc.isUtf16)
-
-/* This is what detects the encoding.
-encodingTable maps from encoding indices to encodings;
-INIT_ENC_INDEX(enc) is the index of the external (protocol) specified encoding;
-state is XML_CONTENT_STATE if we're parsing an external text entity,
-and XML_PROLOG_STATE otherwise.
-*/
-
-
-static
-int initScan(const ENCODING **encodingTable,
- const INIT_ENCODING *enc,
- int state,
- const char *ptr,
- const char *end,
- const char **nextTokPtr)
-{
- const ENCODING **encPtr;
-
- if (ptr == end)
- return XML_TOK_NONE;
- encPtr = enc->encPtr;
- if (ptr + 1 == end) {
- /* only a single byte available for auto-detection */
- /* a well-formed document entity must have more than one byte */
- if (state != XML_CONTENT_STATE)
- return XML_TOK_PARTIAL;
- /* so we're parsing an external text entity... */
- /* if UTF-16 was externally specified, then we need at least 2 bytes */
- switch (INIT_ENC_INDEX(enc)) {
- case UTF_16_ENC:
- case UTF_16LE_ENC:
- case UTF_16BE_ENC:
- return XML_TOK_PARTIAL;
- }
- switch ((unsigned char)*ptr) {
- case 0xFE:
- case 0xFF:
- case 0xEF: /* possibly first byte of UTF-8 BOM */
- if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
- && state == XML_CONTENT_STATE)
- break;
- /* fall through */
- case 0x00:
- case 0x3C:
- return XML_TOK_PARTIAL;
- }
- }
- else {
- switch (((unsigned char)ptr[0] << 8) | (unsigned char)ptr[1]) {
- case 0xFEFF:
- if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
- && state == XML_CONTENT_STATE)
- break;
- *nextTokPtr = ptr + 2;
- *encPtr = encodingTable[UTF_16BE_ENC];
- return XML_TOK_BOM;
- /* 00 3C is handled in the default case */
- case 0x3C00:
- if ((INIT_ENC_INDEX(enc) == UTF_16BE_ENC
- || INIT_ENC_INDEX(enc) == UTF_16_ENC)
- && state == XML_CONTENT_STATE)
- break;
- *encPtr = encodingTable[UTF_16LE_ENC];
- return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
- case 0xFFFE:
- if (INIT_ENC_INDEX(enc) == ISO_8859_1_ENC
- && state == XML_CONTENT_STATE)
- break;
- *nextTokPtr = ptr + 2;
- *encPtr = encodingTable[UTF_16LE_ENC];
- return XML_TOK_BOM;
- case 0xEFBB:
- /* Maybe a UTF-8 BOM (EF BB BF) */
- /* If there's an explicitly specified (external) encoding
- of ISO-8859-1 or some flavour of UTF-16
- and this is an external text entity,
- don't look for the BOM,
- because it might be a legal data. */
- if (state == XML_CONTENT_STATE) {
- int e = INIT_ENC_INDEX(enc);
- if (e == ISO_8859_1_ENC || e == UTF_16BE_ENC || e == UTF_16LE_ENC || e == UTF_16_ENC)
- break;
- }
- if (ptr + 2 == end)
- return XML_TOK_PARTIAL;
- if ((unsigned char)ptr[2] == 0xBF) {
- *encPtr = encodingTable[UTF_8_ENC];
- return XML_TOK_BOM;
- }
- break;
- default:
- if (ptr[0] == '\0') {
- /* 0 isn't a legal data character. Furthermore a document entity can only
- start with ASCII characters. So the only way this can fail to be big-endian
- UTF-16 if it it's an external parsed general entity that's labelled as
- UTF-16LE. */
- if (state == XML_CONTENT_STATE && INIT_ENC_INDEX(enc) == UTF_16LE_ENC)
- break;
- *encPtr = encodingTable[UTF_16BE_ENC];
- return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
- }
- else if (ptr[1] == '\0') {
- /* We could recover here in the case:
- - parsing an external entity
- - second byte is 0
- - no externally specified encoding
- - no encoding declaration
- by assuming UTF-16LE. But we don't, because this would mean when
- presented just with a single byte, we couldn't reliably determine
- whether we needed further bytes. */
- if (state == XML_CONTENT_STATE)
- break;
- *encPtr = encodingTable[UTF_16LE_ENC];
- return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
- }
- break;
- }
- }
- *encPtr = encodingTable[(int)INIT_ENC_INDEX(enc)];
- return XmlTok(*encPtr, state, ptr, end, nextTokPtr);
-}
-
-
-#define NS(x) x
-#define ns(x) x
-#include "xmltok_ns.c"
-#undef NS
-#undef ns
-
-#ifdef XML_NS
-
-#define NS(x) x ## NS
-#define ns(x) x ## _ns
-
-#include "xmltok_ns.c"
-
-#undef NS
-#undef ns
-
-ENCODING *
-XmlInitUnknownEncodingNS(void *mem,
- int *table,
- int (*convert)(void *userData, const char *p),
- void *userData)
-{
- ENCODING *enc = XmlInitUnknownEncoding(mem, table, convert, userData);
- if (enc)
- ((struct normal_encoding *)enc)->type[':'] = BT_COLON;
- return enc;
-}
-
-#endif /* XML_NS */
diff --git a/srclib/expat-lite/xmltok.h b/srclib/expat-lite/xmltok.h
deleted file mode 100644
index fd0ed08e34..0000000000
--- a/srclib/expat-lite/xmltok.h
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-#ifndef XmlTok_INCLUDED
-#define XmlTok_INCLUDED 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef XMLTOKAPI
-#define XMLTOKAPI /* as nothing */
-#endif
-
-/* The following token may be returned by XmlContentTok */
-#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be start of
- illegal ]]> sequence */
-/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
-#define XML_TOK_NONE -4 /* The string to be scanned is empty */
-#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;
- might be part of CRLF sequence */
-#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
-#define XML_TOK_PARTIAL -1 /* only part of a token */
-#define XML_TOK_INVALID 0
-
-/* The following tokens are returned by XmlContentTok; some are also
- returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok */
-
-#define XML_TOK_START_TAG_WITH_ATTS 1
-#define XML_TOK_START_TAG_NO_ATTS 2
-#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
-#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
-#define XML_TOK_END_TAG 5
-#define XML_TOK_DATA_CHARS 6
-#define XML_TOK_DATA_NEWLINE 7
-#define XML_TOK_CDATA_SECT_OPEN 8
-#define XML_TOK_ENTITY_REF 9
-#define XML_TOK_CHAR_REF 10 /* numeric character reference */
-
-/* The following tokens may be returned by both XmlPrologTok and XmlContentTok */
-#define XML_TOK_PI 11 /* processing instruction */
-#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
-#define XML_TOK_COMMENT 13
-#define XML_TOK_BOM 14 /* Byte order mark */
-
-/* The following tokens are returned only by XmlPrologTok */
-#define XML_TOK_PROLOG_S 15
-#define XML_TOK_DECL_OPEN 16 /* <!foo */
-#define XML_TOK_DECL_CLOSE 17 /* > */
-#define XML_TOK_NAME 18
-#define XML_TOK_NMTOKEN 19
-#define XML_TOK_POUND_NAME 20 /* #name */
-#define XML_TOK_OR 21 /* | */
-#define XML_TOK_PERCENT 22
-#define XML_TOK_OPEN_PAREN 23
-#define XML_TOK_CLOSE_PAREN 24
-#define XML_TOK_OPEN_BRACKET 25
-#define XML_TOK_CLOSE_BRACKET 26
-#define XML_TOK_LITERAL 27
-#define XML_TOK_PARAM_ENTITY_REF 28
-#define XML_TOK_INSTANCE_START 29
-
-/* The following occur only in element type declarations */
-#define XML_TOK_NAME_QUESTION 30 /* name? */
-#define XML_TOK_NAME_ASTERISK 31 /* name* */
-#define XML_TOK_NAME_PLUS 32 /* name+ */
-#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
-#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
-#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
-#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
-#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
-#define XML_TOK_COMMA 38
-
-/* The following token is returned only by XmlAttributeValueTok */
-#define XML_TOK_ATTRIBUTE_VALUE_S 39
-
-/* The following token is returned only by XmlCdataSectionTok */
-#define XML_TOK_CDATA_SECT_CLOSE 40
-
-/* With namespace processing this is returned by XmlPrologTok
- for a name with a colon. */
-#define XML_TOK_PREFIXED_NAME 41
-
-#define XML_N_STATES 3
-#define XML_PROLOG_STATE 0
-#define XML_CONTENT_STATE 1
-#define XML_CDATA_SECTION_STATE 2
-
-#define XML_N_LITERAL_TYPES 2
-#define XML_ATTRIBUTE_VALUE_LITERAL 0
-#define XML_ENTITY_VALUE_LITERAL 1
-
-/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
-#define XML_UTF8_ENCODE_MAX 4
-/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
-#define XML_UTF16_ENCODE_MAX 2
-
-typedef struct position {
- /* first line and first column are 0 not 1 */
- unsigned long lineNumber;
- unsigned long columnNumber;
-} POSITION;
-
-typedef struct {
- const char *name;
- const char *valuePtr;
- const char *valueEnd;
- char normalized;
-} ATTRIBUTE;
-
-struct encoding;
-typedef struct encoding ENCODING;
-
-struct encoding {
- int (*scanners[XML_N_STATES])(const ENCODING *,
- const char *,
- const char *,
- const char **);
- int (*literalScanners[XML_N_LITERAL_TYPES])(const ENCODING *,
- const char *,
- const char *,
- const char **);
- int (*sameName)(const ENCODING *,
- const char *, const char *);
- int (*nameMatchesAscii)(const ENCODING *,
- const char *, const char *);
- int (*nameLength)(const ENCODING *, const char *);
- const char *(*skipS)(const ENCODING *, const char *);
- int (*getAtts)(const ENCODING *enc, const char *ptr,
- int attsMax, ATTRIBUTE *atts);
- int (*charRefNumber)(const ENCODING *enc, const char *ptr);
- int (*predefinedEntityName)(const ENCODING *, const char *, const char *);
- void (*updatePosition)(const ENCODING *,
- const char *ptr,
- const char *end,
- POSITION *);
- int (*isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
- const char **badPtr);
- void (*utf8Convert)(const ENCODING *enc,
- const char **fromP,
- const char *fromLim,
- char **toP,
- const char *toLim);
- void (*utf16Convert)(const ENCODING *enc,
- const char **fromP,
- const char *fromLim,
- unsigned short **toP,
- const unsigned short *toLim);
- int minBytesPerChar;
- char isUtf8;
- char isUtf16;
-};
-
-/*
-Scan the string starting at ptr until the end of the next complete token,
-but do not scan past eptr. Return an integer giving the type of token.
-
-Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
-
-Return XML_TOK_PARTIAL when the string does not contain a complete token;
-nextTokPtr will not be set.
-
-Return XML_TOK_INVALID when the string does not start a valid token; nextTokPtr
-will be set to point to the character which made the token invalid.
-
-Otherwise the string starts with a valid token; nextTokPtr will be set to point
-to the character following the end of that token.
-
-Each data character counts as a single token, but adjacent data characters
-may be returned together. Similarly for characters in the prolog outside
-literals, comments and processing instructions.
-*/
-
-
-#define XmlTok(enc, state, ptr, end, nextTokPtr) \
- (((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
-
-#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
- XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
-
-#define XmlContentTok(enc, ptr, end, nextTokPtr) \
- XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
-
-#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
- XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
-
-/* This is used for performing a 2nd-level tokenization on
-the content of a literal that has already been returned by XmlTok. */
-
-#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
- (((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
-
-#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
- XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
-
-#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
- XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
-
-#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
-
-#define XmlNameMatchesAscii(enc, ptr1, ptr2) \
- (((enc)->nameMatchesAscii)(enc, ptr1, ptr2))
-
-#define XmlNameLength(enc, ptr) \
- (((enc)->nameLength)(enc, ptr))
-
-#define XmlSkipS(enc, ptr) \
- (((enc)->skipS)(enc, ptr))
-
-#define XmlGetAttributes(enc, ptr, attsMax, atts) \
- (((enc)->getAtts)(enc, ptr, attsMax, atts))
-
-#define XmlCharRefNumber(enc, ptr) \
- (((enc)->charRefNumber)(enc, ptr))
-
-#define XmlPredefinedEntityName(enc, ptr, end) \
- (((enc)->predefinedEntityName)(enc, ptr, end))
-
-#define XmlUpdatePosition(enc, ptr, end, pos) \
- (((enc)->updatePosition)(enc, ptr, end, pos))
-
-#define XmlIsPublicId(enc, ptr, end, badPtr) \
- (((enc)->isPublicId)(enc, ptr, end, badPtr))
-
-#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
- (((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
-
-#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
- (((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
-
-typedef struct {
- ENCODING initEnc;
- const ENCODING **encPtr;
-} INIT_ENCODING;
-
-int XMLTOKAPI XmlParseXmlDecl(int isGeneralTextEntity,
- const ENCODING *enc,
- const char *ptr,
- const char *end,
- const char **badPtr,
- const char **versionPtr,
- const char **encodingNamePtr,
- const ENCODING **namedEncodingPtr,
- int *standalonePtr);
-
-int XMLTOKAPI XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
-const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncoding(void);
-const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncoding(void);
-int XMLTOKAPI XmlUtf8Encode(int charNumber, char *buf);
-int XMLTOKAPI XmlUtf16Encode(int charNumber, unsigned short *buf);
-
-int XMLTOKAPI XmlSizeOfUnknownEncoding(void);
-ENCODING XMLTOKAPI *
-XmlInitUnknownEncoding(void *mem,
- int *table,
- int (*conv)(void *userData, const char *p),
- void *userData);
-
-int XMLTOKAPI XmlParseXmlDeclNS(int isGeneralTextEntity,
- const ENCODING *enc,
- const char *ptr,
- const char *end,
- const char **badPtr,
- const char **versionPtr,
- const char **encodingNamePtr,
- const ENCODING **namedEncodingPtr,
- int *standalonePtr);
-int XMLTOKAPI XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
-const ENCODING XMLTOKAPI *XmlGetUtf8InternalEncodingNS(void);
-const ENCODING XMLTOKAPI *XmlGetUtf16InternalEncodingNS(void);
-ENCODING XMLTOKAPI *
-XmlInitUnknownEncodingNS(void *mem,
- int *table,
- int (*conv)(void *userData, const char *p),
- void *userData);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* not XmlTok_INCLUDED */
diff --git a/srclib/expat-lite/xmltok_impl.c b/srclib/expat-lite/xmltok_impl.c
deleted file mode 100644
index c52539be8a..0000000000
--- a/srclib/expat-lite/xmltok_impl.c
+++ /dev/null
@@ -1,1746 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-#ifndef IS_INVALID_CHAR
-#define IS_INVALID_CHAR(enc, ptr, n) (0)
-#endif
-
-#define INVALID_LEAD_CASE(n, ptr, nextTokPtr) \
- case BT_LEAD ## n: \
- if (end - ptr < n) \
- return XML_TOK_PARTIAL_CHAR; \
- if (IS_INVALID_CHAR(enc, ptr, n)) { \
- *(nextTokPtr) = (ptr); \
- return XML_TOK_INVALID; \
- } \
- ptr += n; \
- break;
-
-#define INVALID_CASES(ptr, nextTokPtr) \
- INVALID_LEAD_CASE(2, ptr, nextTokPtr) \
- INVALID_LEAD_CASE(3, ptr, nextTokPtr) \
- INVALID_LEAD_CASE(4, ptr, nextTokPtr) \
- case BT_NONXML: \
- case BT_MALFORM: \
- case BT_TRAIL: \
- *(nextTokPtr) = (ptr); \
- return XML_TOK_INVALID;
-
-#define CHECK_NAME_CASE(n, enc, ptr, end, nextTokPtr) \
- case BT_LEAD ## n: \
- if (end - ptr < n) \
- return XML_TOK_PARTIAL_CHAR; \
- if (!IS_NAME_CHAR(enc, ptr, n)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_INVALID; \
- } \
- ptr += n; \
- break;
-
-#define CHECK_NAME_CASES(enc, ptr, end, nextTokPtr) \
- case BT_NONASCII: \
- if (!IS_NAME_CHAR_MINBPC(enc, ptr)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_INVALID; \
- } \
- case BT_NMSTRT: \
- case BT_HEX: \
- case BT_DIGIT: \
- case BT_NAME: \
- case BT_MINUS: \
- ptr += MINBPC(enc); \
- break; \
- CHECK_NAME_CASE(2, enc, ptr, end, nextTokPtr) \
- CHECK_NAME_CASE(3, enc, ptr, end, nextTokPtr) \
- CHECK_NAME_CASE(4, enc, ptr, end, nextTokPtr)
-
-#define CHECK_NMSTRT_CASE(n, enc, ptr, end, nextTokPtr) \
- case BT_LEAD ## n: \
- if (end - ptr < n) \
- return XML_TOK_PARTIAL_CHAR; \
- if (!IS_NMSTRT_CHAR(enc, ptr, n)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_INVALID; \
- } \
- ptr += n; \
- break;
-
-#define CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr) \
- case BT_NONASCII: \
- if (!IS_NMSTRT_CHAR_MINBPC(enc, ptr)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_INVALID; \
- } \
- case BT_NMSTRT: \
- case BT_HEX: \
- ptr += MINBPC(enc); \
- break; \
- CHECK_NMSTRT_CASE(2, enc, ptr, end, nextTokPtr) \
- CHECK_NMSTRT_CASE(3, enc, ptr, end, nextTokPtr) \
- CHECK_NMSTRT_CASE(4, enc, ptr, end, nextTokPtr)
-
-#ifndef PREFIX
-#define PREFIX(ident) ident
-#endif
-
-/* ptr points to character following "<!-" */
-
-static
-int PREFIX(scanComment)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- if (ptr != end) {
- if (!CHAR_MATCHES(enc, ptr, '-')) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- ptr += MINBPC(enc);
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- INVALID_CASES(ptr, nextTokPtr)
- case BT_MINUS:
- if ((ptr += MINBPC(enc)) == end)
- return XML_TOK_PARTIAL;
- if (CHAR_MATCHES(enc, ptr, '-')) {
- if ((ptr += MINBPC(enc)) == end)
- return XML_TOK_PARTIAL;
- if (!CHAR_MATCHES(enc, ptr, '>')) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_COMMENT;
- }
- break;
- default:
- ptr += MINBPC(enc);
- break;
- }
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following "<!" */
-
-static
-int PREFIX(scanDecl)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_MINUS:
- return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_LSQB:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_COND_SECT_OPEN;
- case BT_NMSTRT:
- case BT_HEX:
- ptr += MINBPC(enc);
- break;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_PERCNT:
- if (ptr + MINBPC(enc) == end)
- return XML_TOK_PARTIAL;
- /* don't allow <!ENTITY% foo "whatever"> */
- switch (BYTE_TYPE(enc, ptr + MINBPC(enc))) {
- case BT_S: case BT_CR: case BT_LF: case BT_PERCNT:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- /* fall through */
- case BT_S: case BT_CR: case BT_LF:
- *nextTokPtr = ptr;
- return XML_TOK_DECL_OPEN;
- case BT_NMSTRT:
- case BT_HEX:
- ptr += MINBPC(enc);
- break;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-static
-int PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr, const char *end, int *tokPtr)
-{
- int upper = 0;
- *tokPtr = XML_TOK_PI;
- if (end - ptr != MINBPC(enc)*3)
- return 1;
- switch (BYTE_TO_ASCII(enc, ptr)) {
- case 'x':
- break;
- case 'X':
- upper = 1;
- break;
- default:
- return 1;
- }
- ptr += MINBPC(enc);
- switch (BYTE_TO_ASCII(enc, ptr)) {
- case 'm':
- break;
- case 'M':
- upper = 1;
- break;
- default:
- return 1;
- }
- ptr += MINBPC(enc);
- switch (BYTE_TO_ASCII(enc, ptr)) {
- case 'l':
- break;
- case 'L':
- upper = 1;
- break;
- default:
- return 1;
- }
- if (upper)
- return 0;
- *tokPtr = XML_TOK_XML_DECL;
- return 1;
-}
-
-/* ptr points to character following "<?" */
-
-static
-int PREFIX(scanPi)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- int tok;
- const char *target = ptr;
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
- case BT_S: case BT_CR: case BT_LF:
- if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- ptr += MINBPC(enc);
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- INVALID_CASES(ptr, nextTokPtr)
- case BT_QUEST:
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- if (CHAR_MATCHES(enc, ptr, '>')) {
- *nextTokPtr = ptr + MINBPC(enc);
- return tok;
- }
- break;
- default:
- ptr += MINBPC(enc);
- break;
- }
- }
- return XML_TOK_PARTIAL;
- case BT_QUEST:
- if (!PREFIX(checkPiTarget)(enc, target, ptr, &tok)) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- if (CHAR_MATCHES(enc, ptr, '>')) {
- *nextTokPtr = ptr + MINBPC(enc);
- return tok;
- }
- /* fall through */
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-
-static
-int PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- int i;
- /* CDATA[ */
- if (end - ptr < 6 * MINBPC(enc))
- return XML_TOK_PARTIAL;
- for (i = 0; i < 6; i++, ptr += MINBPC(enc)) {
- if (!CHAR_MATCHES(enc, ptr, "CDATA["[i])) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- *nextTokPtr = ptr;
- return XML_TOK_CDATA_SECT_OPEN;
-}
-
-static
-int PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- if (ptr == end)
- return XML_TOK_NONE;
- if (MINBPC(enc) > 1) {
- size_t n = end - ptr;
- if (n & (MINBPC(enc) - 1)) {
- n &= ~(MINBPC(enc) - 1);
- if (n == 0)
- return XML_TOK_PARTIAL;
- end = ptr + n;
- }
- }
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_RSQB:
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- if (!CHAR_MATCHES(enc, ptr, ']'))
- break;
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- if (!CHAR_MATCHES(enc, ptr, '>')) {
- ptr -= MINBPC(enc);
- break;
- }
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_CDATA_SECT_CLOSE;
- case BT_CR:
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- if (BYTE_TYPE(enc, ptr) == BT_LF)
- ptr += MINBPC(enc);
- *nextTokPtr = ptr;
- return XML_TOK_DATA_NEWLINE;
- case BT_LF:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_DATA_NEWLINE;
- INVALID_CASES(ptr, nextTokPtr)
- default:
- ptr += MINBPC(enc);
- break;
- }
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: \
- if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_DATA_CHARS; \
- } \
- ptr += n; \
- break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
- case BT_NONXML:
- case BT_MALFORM:
- case BT_TRAIL:
- case BT_CR:
- case BT_LF:
- case BT_RSQB:
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
- default:
- ptr += MINBPC(enc);
- break;
- }
- }
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
-}
-
-/* ptr points to character following "</" */
-
-static
-int PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
- case BT_S: case BT_CR: case BT_LF:
- for (ptr += MINBPC(enc); ptr != end; ptr += MINBPC(enc)) {
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_S: case BT_CR: case BT_LF:
- break;
- case BT_GT:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_END_TAG;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- return XML_TOK_PARTIAL;
-#ifdef XML_NS
- case BT_COLON:
- /* no need to check qname syntax here, since end-tag must match exactly */
- ptr += MINBPC(enc);
- break;
-#endif
- case BT_GT:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_END_TAG;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following "&#X" */
-
-static
-int PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- if (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_DIGIT:
- case BT_HEX:
- break;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- for (ptr += MINBPC(enc); ptr != end; ptr += MINBPC(enc)) {
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_DIGIT:
- case BT_HEX:
- break;
- case BT_SEMI:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_CHAR_REF;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following "&#" */
-
-static
-int PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- if (ptr != end) {
- if (CHAR_MATCHES(enc, ptr, 'x'))
- return PREFIX(scanHexCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_DIGIT:
- break;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- for (ptr += MINBPC(enc); ptr != end; ptr += MINBPC(enc)) {
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_DIGIT:
- break;
- case BT_SEMI:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_CHAR_REF;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following "&" */
-
-static
-int PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- case BT_NUM:
- return PREFIX(scanCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
- case BT_SEMI:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_ENTITY_REF;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following first character of attribute name */
-
-static
-int PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
-#ifdef XML_NS
- int hadColon = 0;
-#endif
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-#ifdef XML_NS
- case BT_COLON:
- if (hadColon) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- hadColon = 1;
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- break;
-#endif
- case BT_S: case BT_CR: case BT_LF:
- for (;;) {
- int t;
-
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- t = BYTE_TYPE(enc, ptr);
- if (t == BT_EQUALS)
- break;
- switch (t) {
- case BT_S:
- case BT_LF:
- case BT_CR:
- break;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- /* fall through */
- case BT_EQUALS:
- {
- int open;
-#ifdef XML_NS
- hadColon = 0;
-#endif
- for (;;) {
-
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- open = BYTE_TYPE(enc, ptr);
- if (open == BT_QUOT || open == BT_APOS)
- break;
- switch (open) {
- case BT_S:
- case BT_LF:
- case BT_CR:
- break;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- ptr += MINBPC(enc);
- /* in attribute value */
- for (;;) {
- int t;
- if (ptr == end)
- return XML_TOK_PARTIAL;
- t = BYTE_TYPE(enc, ptr);
- if (t == open)
- break;
- switch (t) {
- INVALID_CASES(ptr, nextTokPtr)
- case BT_AMP:
- {
- int tok = PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, &ptr);
- if (tok <= 0) {
- if (tok == XML_TOK_INVALID)
- *nextTokPtr = ptr;
- return tok;
- }
- break;
- }
- case BT_LT:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- default:
- ptr += MINBPC(enc);
- break;
- }
- }
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_S:
- case BT_CR:
- case BT_LF:
- break;
- case BT_SOL:
- goto sol;
- case BT_GT:
- goto gt;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- /* ptr points to closing quote */
- for (;;) {
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- case BT_S: case BT_CR: case BT_LF:
- continue;
- case BT_GT:
- gt:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_START_TAG_WITH_ATTS;
- case BT_SOL:
- sol:
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- if (!CHAR_MATCHES(enc, ptr, '>')) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_EMPTY_ELEMENT_WITH_ATTS;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- break;
- }
- break;
- }
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-/* ptr points to character following "<" */
-
-static
-int PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
-#ifdef XML_NS
- int hadColon;
-#endif
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- case BT_EXCL:
- if ((ptr += MINBPC(enc)) == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_MINUS:
- return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_LSQB:
- return PREFIX(scanCdataSection)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- }
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- case BT_QUEST:
- return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_SOL:
- return PREFIX(scanEndTag)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
-#ifdef XML_NS
- hadColon = 0;
-#endif
- /* we have a start-tag */
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
-#ifdef XML_NS
- case BT_COLON:
- if (hadColon) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- hadColon = 1;
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- break;
-#endif
- case BT_S: case BT_CR: case BT_LF:
- {
- ptr += MINBPC(enc);
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- case BT_GT:
- goto gt;
- case BT_SOL:
- goto sol;
- case BT_S: case BT_CR: case BT_LF:
- ptr += MINBPC(enc);
- continue;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- return PREFIX(scanAtts)(enc, ptr, end, nextTokPtr);
- }
- return XML_TOK_PARTIAL;
- }
- case BT_GT:
- gt:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_START_TAG_NO_ATTS;
- case BT_SOL:
- sol:
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- if (!CHAR_MATCHES(enc, ptr, '>')) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_EMPTY_ELEMENT_NO_ATTS;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-static
-int PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- if (ptr == end)
- return XML_TOK_NONE;
- if (MINBPC(enc) > 1) {
- size_t n = end - ptr;
- if (n & (MINBPC(enc) - 1)) {
- n &= ~(MINBPC(enc) - 1);
- if (n == 0)
- return XML_TOK_PARTIAL;
- end = ptr + n;
- }
- }
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_LT:
- return PREFIX(scanLt)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_AMP:
- return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_CR:
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_TRAILING_CR;
- if (BYTE_TYPE(enc, ptr) == BT_LF)
- ptr += MINBPC(enc);
- *nextTokPtr = ptr;
- return XML_TOK_DATA_NEWLINE;
- case BT_LF:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_DATA_NEWLINE;
- case BT_RSQB:
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_TRAILING_RSQB;
- if (!CHAR_MATCHES(enc, ptr, ']'))
- break;
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_TRAILING_RSQB;
- if (!CHAR_MATCHES(enc, ptr, '>')) {
- ptr -= MINBPC(enc);
- break;
- }
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- INVALID_CASES(ptr, nextTokPtr)
- default:
- ptr += MINBPC(enc);
- break;
- }
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: \
- if (end - ptr < n || IS_INVALID_CHAR(enc, ptr, n)) { \
- *nextTokPtr = ptr; \
- return XML_TOK_DATA_CHARS; \
- } \
- ptr += n; \
- break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
- case BT_RSQB:
- if (ptr + MINBPC(enc) != end) {
- if (!CHAR_MATCHES(enc, ptr + MINBPC(enc), ']')) {
- ptr += MINBPC(enc);
- break;
- }
- if (ptr + 2*MINBPC(enc) != end) {
- if (!CHAR_MATCHES(enc, ptr + 2*MINBPC(enc), '>')) {
- ptr += MINBPC(enc);
- break;
- }
- *nextTokPtr = ptr + 2*MINBPC(enc);
- return XML_TOK_INVALID;
- }
- }
- /* fall through */
- case BT_AMP:
- case BT_LT:
- case BT_NONXML:
- case BT_MALFORM:
- case BT_TRAIL:
- case BT_CR:
- case BT_LF:
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
- default:
- ptr += MINBPC(enc);
- break;
- }
- }
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
-}
-
-/* ptr points to character following "%" */
-
-static
-int PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- case BT_S: case BT_LF: case BT_CR: case BT_PERCNT:
- *nextTokPtr = ptr;
- return XML_TOK_PERCENT;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
- case BT_SEMI:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_PARAM_ENTITY_REF;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-static
-int PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
- case BT_CR: case BT_LF: case BT_S:
- case BT_RPAR: case BT_GT: case BT_PERCNT: case BT_VERBAR:
- *nextTokPtr = ptr;
- return XML_TOK_POUND_NAME;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-static
-int PREFIX(scanLit)(int open, const ENCODING *enc,
- const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- while (ptr != end) {
- int t = BYTE_TYPE(enc, ptr);
- switch (t) {
- INVALID_CASES(ptr, nextTokPtr)
- case BT_QUOT:
- case BT_APOS:
- ptr += MINBPC(enc);
- if (t != open)
- break;
- if (ptr == end)
- return XML_TOK_PARTIAL;
- *nextTokPtr = ptr;
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_S: case BT_CR: case BT_LF:
- case BT_GT: case BT_PERCNT: case BT_LSQB:
- return XML_TOK_LITERAL;
- default:
- return XML_TOK_INVALID;
- }
- default:
- ptr += MINBPC(enc);
- break;
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-static
-int PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- int tok;
- if (ptr == end)
- return XML_TOK_NONE;
- if (MINBPC(enc) > 1) {
- size_t n = end - ptr;
- if (n & (MINBPC(enc) - 1)) {
- n &= ~(MINBPC(enc) - 1);
- if (n == 0)
- return XML_TOK_PARTIAL;
- end = ptr + n;
- }
- }
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_QUOT:
- return PREFIX(scanLit)(BT_QUOT, enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_APOS:
- return PREFIX(scanLit)(BT_APOS, enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_LT:
- {
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_EXCL:
- return PREFIX(scanDecl)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_QUEST:
- return PREFIX(scanPi)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_NMSTRT:
- case BT_HEX:
- case BT_NONASCII:
- case BT_LEAD2:
- case BT_LEAD3:
- case BT_LEAD4:
- *nextTokPtr = ptr - MINBPC(enc);
- return XML_TOK_INSTANCE_START;
- }
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- case BT_CR:
- if (ptr + MINBPC(enc) == end)
- return XML_TOK_TRAILING_CR;
- /* fall through */
- case BT_S: case BT_LF:
- for (;;) {
- ptr += MINBPC(enc);
- if (ptr == end)
- break;
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_S: case BT_LF:
- break;
- case BT_CR:
- /* don't split CR/LF pair */
- if (ptr + MINBPC(enc) != end)
- break;
- /* fall through */
- default:
- *nextTokPtr = ptr;
- return XML_TOK_PROLOG_S;
- }
- }
- *nextTokPtr = ptr;
- return XML_TOK_PROLOG_S;
- case BT_PERCNT:
- return PREFIX(scanPercent)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- case BT_COMMA:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_COMMA;
- case BT_LSQB:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_OPEN_BRACKET;
- case BT_RSQB:
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- if (CHAR_MATCHES(enc, ptr, ']')) {
- if (ptr + MINBPC(enc) == end)
- return XML_TOK_PARTIAL;
- if (CHAR_MATCHES(enc, ptr + MINBPC(enc), '>')) {
- *nextTokPtr = ptr + 2*MINBPC(enc);
- return XML_TOK_COND_SECT_CLOSE;
- }
- }
- *nextTokPtr = ptr;
- return XML_TOK_CLOSE_BRACKET;
- case BT_LPAR:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_OPEN_PAREN;
- case BT_RPAR:
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_PARTIAL;
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_AST:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_CLOSE_PAREN_ASTERISK;
- case BT_QUEST:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_CLOSE_PAREN_QUESTION;
- case BT_PLUS:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_CLOSE_PAREN_PLUS;
- case BT_CR: case BT_LF: case BT_S:
- case BT_GT: case BT_COMMA: case BT_VERBAR:
- case BT_RPAR:
- *nextTokPtr = ptr;
- return XML_TOK_CLOSE_PAREN;
- }
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- case BT_VERBAR:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_OR;
- case BT_GT:
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_DECL_CLOSE;
- case BT_NUM:
- return PREFIX(scanPoundName)(enc, ptr + MINBPC(enc), end, nextTokPtr);
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: \
- if (end - ptr < n) \
- return XML_TOK_PARTIAL_CHAR; \
- if (IS_NMSTRT_CHAR(enc, ptr, n)) { \
- ptr += n; \
- tok = XML_TOK_NAME; \
- break; \
- } \
- if (IS_NAME_CHAR(enc, ptr, n)) { \
- ptr += n; \
- tok = XML_TOK_NMTOKEN; \
- break; \
- } \
- *nextTokPtr = ptr; \
- return XML_TOK_INVALID;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
- case BT_NMSTRT:
- case BT_HEX:
- tok = XML_TOK_NAME;
- ptr += MINBPC(enc);
- break;
- case BT_DIGIT:
- case BT_NAME:
- case BT_MINUS:
-#ifdef XML_NS
- case BT_COLON:
-#endif
- tok = XML_TOK_NMTOKEN;
- ptr += MINBPC(enc);
- break;
- case BT_NONASCII:
- if (IS_NMSTRT_CHAR_MINBPC(enc, ptr)) {
- ptr += MINBPC(enc);
- tok = XML_TOK_NAME;
- break;
- }
- if (IS_NAME_CHAR_MINBPC(enc, ptr)) {
- ptr += MINBPC(enc);
- tok = XML_TOK_NMTOKEN;
- break;
- }
- /* fall through */
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
- case BT_GT: case BT_RPAR: case BT_COMMA:
- case BT_VERBAR: case BT_LSQB: case BT_PERCNT:
- case BT_S: case BT_CR: case BT_LF:
- *nextTokPtr = ptr;
- return tok;
-#ifdef XML_NS
- case BT_COLON:
- ptr += MINBPC(enc);
- switch (tok) {
- case XML_TOK_NAME:
- if (ptr == end)
- return XML_TOK_PARTIAL;
- tok = XML_TOK_PREFIXED_NAME;
- switch (BYTE_TYPE(enc, ptr)) {
- CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
- default:
- tok = XML_TOK_NMTOKEN;
- break;
- }
- break;
- case XML_TOK_PREFIXED_NAME:
- tok = XML_TOK_NMTOKEN;
- break;
- }
- break;
-#endif
- case BT_PLUS:
- if (tok == XML_TOK_NMTOKEN) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_NAME_PLUS;
- case BT_AST:
- if (tok == XML_TOK_NMTOKEN) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_NAME_ASTERISK;
- case BT_QUEST:
- if (tok == XML_TOK_NMTOKEN) {
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_NAME_QUESTION;
- default:
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- }
- }
- return XML_TOK_PARTIAL;
-}
-
-static
-int PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- const char *start;
- if (ptr == end)
- return XML_TOK_NONE;
- start = ptr;
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: ptr += n; break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
- case BT_AMP:
- if (ptr == start)
- return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
- case BT_LT:
- /* this is for inside entity references */
- *nextTokPtr = ptr;
- return XML_TOK_INVALID;
- case BT_LF:
- if (ptr == start) {
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_DATA_NEWLINE;
- }
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
- case BT_CR:
- if (ptr == start) {
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_TRAILING_CR;
- if (BYTE_TYPE(enc, ptr) == BT_LF)
- ptr += MINBPC(enc);
- *nextTokPtr = ptr;
- return XML_TOK_DATA_NEWLINE;
- }
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
- case BT_S:
- if (ptr == start) {
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_ATTRIBUTE_VALUE_S;
- }
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
- default:
- ptr += MINBPC(enc);
- break;
- }
- }
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
-}
-
-static
-int PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- const char *start;
- if (ptr == end)
- return XML_TOK_NONE;
- start = ptr;
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: ptr += n; break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
- case BT_AMP:
- if (ptr == start)
- return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
- case BT_PERCNT:
- if (ptr == start)
- return PREFIX(scanPercent)(enc, ptr + MINBPC(enc), end, nextTokPtr);
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
- case BT_LF:
- if (ptr == start) {
- *nextTokPtr = ptr + MINBPC(enc);
- return XML_TOK_DATA_NEWLINE;
- }
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
- case BT_CR:
- if (ptr == start) {
- ptr += MINBPC(enc);
- if (ptr == end)
- return XML_TOK_TRAILING_CR;
- if (BYTE_TYPE(enc, ptr) == BT_LF)
- ptr += MINBPC(enc);
- *nextTokPtr = ptr;
- return XML_TOK_DATA_NEWLINE;
- }
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
- default:
- ptr += MINBPC(enc);
- break;
- }
- }
- *nextTokPtr = ptr;
- return XML_TOK_DATA_CHARS;
-}
-
-static
-int PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
- const char **badPtr)
-{
- ptr += MINBPC(enc);
- end -= MINBPC(enc);
- for (; ptr != end; ptr += MINBPC(enc)) {
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_DIGIT:
- case BT_HEX:
- case BT_MINUS:
- case BT_APOS:
- case BT_LPAR:
- case BT_RPAR:
- case BT_PLUS:
- case BT_COMMA:
- case BT_SOL:
- case BT_EQUALS:
- case BT_QUEST:
- case BT_CR:
- case BT_LF:
- case BT_SEMI:
- case BT_EXCL:
- case BT_AST:
- case BT_PERCNT:
- case BT_NUM:
-#ifdef XML_NS
- case BT_COLON:
-#endif
- break;
- case BT_S:
- if (CHAR_MATCHES(enc, ptr, '\t')) {
- *badPtr = ptr;
- return 0;
- }
- break;
- case BT_NAME:
- case BT_NMSTRT:
- if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f))
- break;
- default:
- switch (BYTE_TO_ASCII(enc, ptr)) {
- case 0x24: /* $ */
- case 0x40: /* @ */
- break;
- default:
- *badPtr = ptr;
- return 0;
- }
- break;
- }
- }
- return 1;
-}
-
-/* This must only be called for a well-formed start-tag or empty element tag.
-Returns the number of attributes. Pointers to the first attsMax attributes
-are stored in atts. */
-
-static
-int PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
- int attsMax, ATTRIBUTE *atts)
-{
- enum { other, inName, inValue } state = inName;
- int nAtts = 0;
- int open = 0;
-
- for (ptr += MINBPC(enc);; ptr += MINBPC(enc)) {
- switch (BYTE_TYPE(enc, ptr)) {
-#define START_NAME \
- if (state == other) { \
- if (nAtts < attsMax) { \
- atts[nAtts].name = ptr; \
- atts[nAtts].normalized = 1; \
- } \
- state = inName; \
- }
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: START_NAME ptr += (n - MINBPC(enc)); break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
- case BT_NONASCII:
- case BT_NMSTRT:
- case BT_HEX:
- START_NAME
- break;
-#undef START_NAME
- case BT_QUOT:
- if (state != inValue) {
- if (nAtts < attsMax)
- atts[nAtts].valuePtr = ptr + MINBPC(enc);
- state = inValue;
- open = BT_QUOT;
- }
- else if (open == BT_QUOT) {
- state = other;
- if (nAtts < attsMax)
- atts[nAtts].valueEnd = ptr;
- nAtts++;
- }
- break;
- case BT_APOS:
- if (state != inValue) {
- if (nAtts < attsMax)
- atts[nAtts].valuePtr = ptr + MINBPC(enc);
- state = inValue;
- open = BT_APOS;
- }
- else if (open == BT_APOS) {
- state = other;
- if (nAtts < attsMax)
- atts[nAtts].valueEnd = ptr;
- nAtts++;
- }
- break;
- case BT_AMP:
- if (nAtts < attsMax)
- atts[nAtts].normalized = 0;
- break;
- case BT_S:
- if (state == inName)
- state = other;
- else if (state == inValue
- && nAtts < attsMax
- && atts[nAtts].normalized
- && (ptr == atts[nAtts].valuePtr
- || BYTE_TO_ASCII(enc, ptr) != ' '
- || BYTE_TO_ASCII(enc, ptr + MINBPC(enc)) == ' '
- || BYTE_TYPE(enc, ptr + MINBPC(enc)) == open))
- atts[nAtts].normalized = 0;
- break;
- case BT_CR: case BT_LF:
- /* This case ensures that the first attribute name is counted
- Apart from that we could just change state on the quote. */
- if (state == inName)
- state = other;
- else if (state == inValue && nAtts < attsMax)
- atts[nAtts].normalized = 0;
- break;
- case BT_GT:
- case BT_SOL:
- if (state != inValue)
- return nAtts;
- break;
- default:
- break;
- }
- }
- /* not reached */
-}
-
-static
-int PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr)
-{
- int result = 0;
- /* skip &# */
- ptr += 2*MINBPC(enc);
- if (CHAR_MATCHES(enc, ptr, 'x')) {
- for (ptr += MINBPC(enc); !CHAR_MATCHES(enc, ptr, ';'); ptr += MINBPC(enc)) {
- int c = BYTE_TO_ASCII(enc, ptr);
- switch (c) {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- result <<= 4;
- result |= (c - '0');
- break;
- case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
- result <<= 4;
- result += 10 + (c - 'A');
- break;
- case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
- result <<= 4;
- result += 10 + (c - 'a');
- break;
- }
- if (result >= 0x110000)
- return -1;
- }
- }
- else {
- for (; !CHAR_MATCHES(enc, ptr, ';'); ptr += MINBPC(enc)) {
- int c = BYTE_TO_ASCII(enc, ptr);
- result *= 10;
- result += (c - '0');
- if (result >= 0x110000)
- return -1;
- }
- }
- return checkCharRefNumber(result);
-}
-
-static
-int PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr, const char *end)
-{
- switch ((end - ptr)/MINBPC(enc)) {
- case 2:
- if (CHAR_MATCHES(enc, ptr + MINBPC(enc), 't')) {
- switch (BYTE_TO_ASCII(enc, ptr)) {
- case 'l':
- return '<';
- case 'g':
- return '>';
- }
- }
- break;
- case 3:
- if (CHAR_MATCHES(enc, ptr, 'a')) {
- ptr += MINBPC(enc);
- if (CHAR_MATCHES(enc, ptr, 'm')) {
- ptr += MINBPC(enc);
- if (CHAR_MATCHES(enc, ptr, 'p'))
- return '&';
- }
- }
- break;
- case 4:
- switch (BYTE_TO_ASCII(enc, ptr)) {
- case 'q':
- ptr += MINBPC(enc);
- if (CHAR_MATCHES(enc, ptr, 'u')) {
- ptr += MINBPC(enc);
- if (CHAR_MATCHES(enc, ptr, 'o')) {
- ptr += MINBPC(enc);
- if (CHAR_MATCHES(enc, ptr, 't'))
- return '"';
- }
- }
- break;
- case 'a':
- ptr += MINBPC(enc);
- if (CHAR_MATCHES(enc, ptr, 'p')) {
- ptr += MINBPC(enc);
- if (CHAR_MATCHES(enc, ptr, 'o')) {
- ptr += MINBPC(enc);
- if (CHAR_MATCHES(enc, ptr, 's'))
- return '\'';
- }
- }
- break;
- }
- }
- return 0;
-}
-
-static
-int PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
-{
- for (;;) {
- switch (BYTE_TYPE(enc, ptr1)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: \
- if (*ptr1++ != *ptr2++) \
- return 0;
- LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2)
-#undef LEAD_CASE
- /* fall through */
- if (*ptr1++ != *ptr2++)
- return 0;
- break;
- case BT_NONASCII:
- case BT_NMSTRT:
-#ifdef XML_NS
- case BT_COLON:
-#endif
- case BT_HEX:
- case BT_DIGIT:
- case BT_NAME:
- case BT_MINUS:
- if (*ptr2++ != *ptr1++)
- return 0;
- if (MINBPC(enc) > 1) {
- if (*ptr2++ != *ptr1++)
- return 0;
- if (MINBPC(enc) > 2) {
- if (*ptr2++ != *ptr1++)
- return 0;
- if (MINBPC(enc) > 3) {
- if (*ptr2++ != *ptr1++)
- return 0;
- }
- }
- }
- break;
- default:
- if (MINBPC(enc) == 1 && *ptr1 == *ptr2)
- return 1;
- switch (BYTE_TYPE(enc, ptr2)) {
- case BT_LEAD2:
- case BT_LEAD3:
- case BT_LEAD4:
- case BT_NONASCII:
- case BT_NMSTRT:
-#ifdef XML_NS
- case BT_COLON:
-#endif
- case BT_HEX:
- case BT_DIGIT:
- case BT_NAME:
- case BT_MINUS:
- return 0;
- default:
- return 1;
- }
- }
- }
- /* not reached */
-}
-
-static
-int PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1, const char *ptr2)
-{
- for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) {
- if (!CHAR_MATCHES(enc, ptr1, *ptr2))
- return 0;
- }
- switch (BYTE_TYPE(enc, ptr1)) {
- case BT_LEAD2:
- case BT_LEAD3:
- case BT_LEAD4:
- case BT_NONASCII:
- case BT_NMSTRT:
-#ifdef XML_NS
- case BT_COLON:
-#endif
- case BT_HEX:
- case BT_DIGIT:
- case BT_NAME:
- case BT_MINUS:
- return 0;
- default:
- return 1;
- }
-}
-
-static
-int PREFIX(nameLength)(const ENCODING *enc, const char *ptr)
-{
- const char *start = ptr;
- for (;;) {
- switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: ptr += n; break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
- case BT_NONASCII:
- case BT_NMSTRT:
-#ifdef XML_NS
- case BT_COLON:
-#endif
- case BT_HEX:
- case BT_DIGIT:
- case BT_NAME:
- case BT_MINUS:
- ptr += MINBPC(enc);
- break;
- default:
- return ptr - start;
- }
- }
-}
-
-static
-const char *PREFIX(skipS)(const ENCODING *enc, const char *ptr)
-{
- for (;;) {
- switch (BYTE_TYPE(enc, ptr)) {
- case BT_LF:
- case BT_CR:
- case BT_S:
- ptr += MINBPC(enc);
- break;
- default:
- return ptr;
- }
- }
-}
-
-static
-void PREFIX(updatePosition)(const ENCODING *enc,
- const char *ptr,
- const char *end,
- POSITION *pos)
-{
- while (ptr != end) {
- switch (BYTE_TYPE(enc, ptr)) {
-#define LEAD_CASE(n) \
- case BT_LEAD ## n: \
- ptr += n; \
- break;
- LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
-#undef LEAD_CASE
- case BT_LF:
- pos->columnNumber = (unsigned)-1;
- pos->lineNumber++;
- ptr += MINBPC(enc);
- break;
- case BT_CR:
- pos->lineNumber++;
- ptr += MINBPC(enc);
- if (ptr != end && BYTE_TYPE(enc, ptr) == BT_LF)
- ptr += MINBPC(enc);
- pos->columnNumber = (unsigned)-1;
- break;
- default:
- ptr += MINBPC(enc);
- break;
- }
- pos->columnNumber++;
- }
-}
-
-#undef DO_LEAD_CASE
-#undef MULTIBYTE_CASES
-#undef INVALID_CASES
-#undef CHECK_NAME_CASE
-#undef CHECK_NAME_CASES
-#undef CHECK_NMSTRT_CASE
-#undef CHECK_NMSTRT_CASES
diff --git a/srclib/expat-lite/xmltok_impl.h b/srclib/expat-lite/xmltok_impl.h
deleted file mode 100644
index e72b225c83..0000000000
--- a/srclib/expat-lite/xmltok_impl.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-The contents of this file are subject to the Mozilla Public License
-Version 1.1 (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.mozilla.org/MPL/
-
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is expat.
-
-The Initial Developer of the Original Code is James Clark.
-Portions created by James Clark are Copyright (C) 1998, 1999
-James Clark. All Rights Reserved.
-
-Contributor(s):
-
-Alternatively, the contents of this file may be used under the terms
-of the GNU General Public License (the "GPL"), in which case the
-provisions of the GPL are applicable instead of those above. If you
-wish to allow use of your version of this file only under the terms of
-the GPL and not to allow others to use your version of this file under
-the MPL, indicate your decision by deleting the provisions above and
-replace them with the notice and other provisions required by the
-GPL. If you do not delete the provisions above, a recipient may use
-your version of this file under either the MPL or the GPL.
-*/
-
-enum {
- BT_NONXML,
- BT_MALFORM,
- BT_LT,
- BT_AMP,
- BT_RSQB,
- BT_LEAD2,
- BT_LEAD3,
- BT_LEAD4,
- BT_TRAIL,
- BT_CR,
- BT_LF,
- BT_GT,
- BT_QUOT,
- BT_APOS,
- BT_EQUALS,
- BT_QUEST,
- BT_EXCL,
- BT_SOL,
- BT_SEMI,
- BT_NUM,
- BT_LSQB,
- BT_S,
- BT_NMSTRT,
- BT_COLON,
- BT_HEX,
- BT_DIGIT,
- BT_NAME,
- BT_MINUS,
- BT_OTHER, /* known not to be a name or name start character */
- BT_NONASCII, /* might be a name or name start character */
- BT_PERCNT,
- BT_LPAR,
- BT_RPAR,
- BT_AST,
- BT_PLUS,
- BT_COMMA,
- BT_VERBAR
-};
-
-#include <stddef.h>
diff --git a/srclib/expat-lite/xmltok_ns.c b/srclib/expat-lite/xmltok_ns.c
deleted file mode 100644
index a32c577458..0000000000
--- a/srclib/expat-lite/xmltok_ns.c
+++ /dev/null
@@ -1,96 +0,0 @@
-const ENCODING *NS(XmlGetUtf8InternalEncoding)(void)
-{
- return &ns(internal_utf8_encoding).enc;
-}
-
-const ENCODING *NS(XmlGetUtf16InternalEncoding)(void)
-{
-#if XML_BYTE_ORDER == 12
- return &ns(internal_little2_encoding).enc;
-#elif XML_BYTE_ORDER == 21
- return &ns(internal_big2_encoding).enc;
-#else
- const short n = 1;
- return *(const char *)&n ? &ns(internal_little2_encoding).enc : &ns(internal_big2_encoding).enc;
-#endif
-}
-
-static
-const ENCODING *NS(encodings)[] = {
- &ns(latin1_encoding).enc,
- &ns(ascii_encoding).enc,
- &ns(utf8_encoding).enc,
- &ns(big2_encoding).enc,
- &ns(big2_encoding).enc,
- &ns(little2_encoding).enc,
- &ns(utf8_encoding).enc /* NO_ENC */
-};
-
-static
-int NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_PROLOG_STATE, ptr, end, nextTokPtr);
-}
-
-static
-int NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
- const char **nextTokPtr)
-{
- return initScan(NS(encodings), (const INIT_ENCODING *)enc, XML_CONTENT_STATE, ptr, end, nextTokPtr);
-}
-
-int NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr, const char *name)
-{
- int i = getEncodingIndex(name);
- if (i == UNKNOWN_ENC)
- return 0;
- INIT_ENC_INDEX(p) = (char)i;
- p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
- p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
- p->initEnc.updatePosition = initUpdatePosition;
- p->encPtr = encPtr;
- *encPtr = &(p->initEnc);
- return 1;
-}
-
-static
-const ENCODING *NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
-{
-#define ENCODING_MAX 128
- char buf[ENCODING_MAX];
- char *p = buf;
- int i;
- XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
- if (ptr != end)
- return 0;
- *p = 0;
- if (streqci(buf, "UTF-16") && enc->minBytesPerChar == 2)
- return enc;
- i = getEncodingIndex(buf);
- if (i == UNKNOWN_ENC)
- return 0;
- return NS(encodings)[i];
-}
-
-int NS(XmlParseXmlDecl)(int isGeneralTextEntity,
- const ENCODING *enc,
- const char *ptr,
- const char *end,
- const char **badPtr,
- const char **versionPtr,
- const char **encodingName,
- const ENCODING **encoding,
- int *standalone)
-{
- return doParseXmlDecl(NS(findEncoding),
- isGeneralTextEntity,
- enc,
- ptr,
- end,
- badPtr,
- versionPtr,
- encodingName,
- encoding,
- standalone);
-}
diff --git a/support/.cvsignore b/support/.cvsignore
deleted file mode 100644
index 399f114e93..0000000000
--- a/support/.cvsignore
+++ /dev/null
@@ -1,11 +0,0 @@
-Makefile
-rotatelogs
-htpasswd
-htdigest
-unescape
-inc2shtml
-httpd_monitor
-suexec
-logresolve
-ab
-apxs
diff --git a/support/.indent.pro b/support/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/support/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/support/README b/support/README
deleted file mode 100644
index 80e9cafde0..0000000000
--- a/support/README
+++ /dev/null
@@ -1,62 +0,0 @@
-Support files:
-
-ab
- ABuse your server with this benchmarker. Rudimentary
- command line testing tool.
-
-apachectl
- Apache run-time Control script. To facilitate the
- administrator and/or your rc.d scripts to control the
- functioning of the Apache httpd daemon.
-
-apxs
- APache eXtenSion tool. Eases building and installing
- DSO style modules.
-
-dbmmanage
- Create and update user authentication files in the faster
- DBM format used by mod_auth_db.
-
-htdigest
- Create and update user authentication files used in
- DIGEST authentification. See mod_auth_digest.
-
-htpasswd
- Create and update user authentication files used in
- BASIC authentification. I.e. the htpasswd files.
- See mod_auth.
-
-httpd.8
- General apache man page.
-
-log_server_status
- This script is designed to be run at a frequent interval by something
- like cron. It connects to the server and downloads the status
- information. It reformats the information to a single line and logs
- it to a file.
-
-logresolve
- resolve hostnames for IP-adresses in Apache logfiles
-
-phf_abuse_log.cgi
- This script can be used to detect people trying to abuse an ancient
- and long plugged security hole which existed in a CGI script distributed
- with Apache 1.0.3 and earlier versions.
-
-rotatelogs
- rotate Apache logs without having to kill the server.
-
-split-logfile
- This script will take a combined virtual hosts access
- log file and break its contents into separate files.
-
-suexec
- Switch User For Exec. Used internally by apache,
- see the document `Apache suEXEC Support'
- under http://www.apache.org/docs/suexec.html .
-
-SHA1
- This directory includes some utilities to allow Apache 1.3.6 to
- recognize passwords in SHA1 format, as used by Netscape web
- servers. It is not installed by default.
-
diff --git a/support/SHA1/README.sha1 b/support/SHA1/README.sha1
deleted file mode 100644
index 3998e1fdd9..0000000000
--- a/support/SHA1/README.sha1
+++ /dev/null
@@ -1,34 +0,0 @@
-This directory includes some utilities to allow Apache 1.3.6 to
-recognize passwords in SHA1 format, as used by Netscape web servers.
-
-From Netscape's admin interface, export the password database to an
-ldif file and then use convert.pl in this distribution to generate
-apache style password files.
-
-Note: SHA1 support is useful for migration purposes, but is less
- secure than Apache's password format, since Apache's (MD5)
- password format uses a random eight character salt to generate
- one of many possible hashes for the same password. Netscape
- uses plain SHA1 without a salt, so the same password
- will always generate the same hash, making it easier
- to break since the search space is smaller.
-
-This code was contributed by Clinton Wong <clintdw@netcom.com>.
-
-README.sha1
- this file
-
-convert-sha1.pl
- takes an ldif dump from Netscape's web server on
- standard in, outputs apache htpasswd format on standard out.
-
- Usage: convert.pl < ldif > passwords
-
-htpasswd-sha1.pl
- perl script to generate entries in apache htpasswd format.
-
- Usage: htpasswd-sha1.pl some_user some_password
-
-ldif-sha1.example
- sample ldif dump with one sha1 password and one crypt password.
-
diff --git a/support/SHA1/convert-sha1.pl b/support/SHA1/convert-sha1.pl
deleted file mode 100644
index 35228022a0..0000000000
--- a/support/SHA1/convert-sha1.pl
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/perl -w
-use strict;
-
-# This is public domain code. Do whatever you want with it.
-# It was originally included in Clinton Wong's Apache 1.3.6 SHA1/ldif
-# patch distribution as sample code for converting accounts from
-# ldif format (as used by Netscape web servers) to Apache password format.
-
-my $uid='';
-my $passwd='';
-
-while (my $line = <>) {
- chomp $line;
- if ( $line =~ /uid:\s*(.+)/) { $uid = $1 }
- if ( $line =~ /userpassword:\s*(\{\w+\}.+)/) {
- $passwd = $1;
- $passwd =~ s/^\{crypt\}//i; # Apache stores crypt without a magic string
- }
-
- if (length($line)==0) {
-
- if (length $uid and length $passwd) {
- print $uid, ':', $passwd, "\n";
- } # output if we have something to print
-
- $uid = '';
- $passwd = '';
-
- } # if newline
-} # while something to read
-
-# handle last entry if there isn't a newline before EOF
- if (length $uid and length $passwd) {
- print $uid, ':', $passwd, "\n";
-}
-
diff --git a/support/SHA1/htpasswd-sha1.pl b/support/SHA1/htpasswd-sha1.pl
deleted file mode 100644
index ad624d1101..0000000000
--- a/support/SHA1/htpasswd-sha1.pl
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/perl -w
-use strict;
-#
-# Utility which takes a username and password
-# on the command line and generates a username
-# sha1-encrytped password on the stdout.
-#
-# Typical useage:
-# ./htpasswd-sha1.pl dirkx MySecret >> sha1-passwd
-#
-# This is public domain code. Do whatever you want with it.
-# It was originally included in Clinton Wong's Apache 1.3.6 SHA1/ldif
-# patch distribution as sample code for generating entries for
-# Apache password files using SHA1.
-
-use MIME::Base64; # http://www.cpan.org/modules/by-module/MIME/
-use Digest::SHA1; # http://www.cpan.org/modules/by-module/MD5/
-
-if ($#ARGV!=1) { die "Usage $0: user password\n" }
-
-print $ARGV[0], ':{SHA}', encode_base64( Digest::SHA1::sha1($ARGV[1]) );
-
diff --git a/support/SHA1/ldif-sha1.example b/support/SHA1/ldif-sha1.example
deleted file mode 100644
index b8fe917eaf..0000000000
--- a/support/SHA1/ldif-sha1.example
+++ /dev/null
@@ -1,19 +0,0 @@
-dn: cn=someuser
-cn: someuser
-sn: someuser
-objectclass: top
-objectclass: person
-objectclass: organizationalPerson
-objectclass: inetOrgPerson
-uid: someuser
-userpassword: {SHA}GvF+c3IdvgxAARuC7Uuxp9vjzik=
-
-dn: cn=anotheruser
-cn: anotheruser
-sn: anotheruser
-objectclass: top
-objectclass: person
-objectclass: organizationalPerson
-objectclass: inetOrgPerson
-uid: anotheruser
-userpassword: {crypt}eFnp.4sz5XnH6
diff --git a/support/ab.c b/support/ab.c
deleted file mode 100644
index 15fff6e85d..0000000000
--- a/support/ab.c
+++ /dev/null
@@ -1,1128 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- ** This program is based on ZeusBench V1.0 written by Adam Twiss
- ** which is Copyright (c) 1996 by Zeus Technology Ltd. http://www.zeustech.net/
- **
- ** This software is provided "as is" and any express or implied waranties,
- ** including but not limited to, the implied warranties of merchantability and
- ** fitness for a particular purpose are disclaimed. In no event shall
- ** Zeus Technology Ltd. be liable for any direct, indirect, incidental, special,
- ** exemplary, or consequential damaged (including, but not limited to,
- ** procurement of substitute good or services; loss of use, data, or profits;
- ** or business interruption) however caused and on 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.
- **
- */
-
-/*
- ** HISTORY:
- ** - Originally written by Adam Twiss <adam@zeus.co.uk>, March 1996
- ** with input from Mike Belshe <mbelshe@netscape.com> and
- ** Michael Campanella <campanella@stevms.enet.dec.com>
- ** - Enhanced by Dean Gaudet <dgaudet@apache.org>, November 1997
- ** - Cleaned up by Ralf S. Engelschall <rse@apache.org>, March 1998
- ** - POST and verbosity by Kurt Sussman <kls@merlot.com>, August 1998
- ** - HTML table output added by David N. Welton <davidw@prosa.it>, January 1999
- ** - Added Cookie, Arbitrary header and auth support. <dirkx@webweaving.org>, April 199
- **
- */
-
-/*
- * BUGS:
- *
- * - uses strcpy/etc.
- * - has various other poor buffer attacks related to the lazy parsing of
- * response headers from the server
- * - doesn't implement much of HTTP/1.x, only accepts certain forms of
- * responses
- * - (performance problem) heavy use of strstr shows up top in profile
- * only an issue for loopback usage
- */
-
-#define VERSION "1.3c"
-
-/* -------------------------------------------------------------------- */
-
-/* affects include files on Solaris */
-#define BSD_COMP
-
-/* allow compilation outside an Apache build tree */
-#ifdef NO_APACHE_INCLUDES
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <string.h>
-
-#define ap_select select
-#else /* (!)NO_APACHE_INCLUDES */
-#include "ap_config.h"
-#include "ap.h"
-#ifdef CHARSET_EBCDIC
-#include "ebcdic.h"
-#endif
-#include <fcntl.h>
-#include <sys/time.h>
-
-#ifndef NO_WRITEV
-#include <sys/types.h>
-#include <sys/uio.h>
-#endif
-
-#endif /* NO_APACHE_INCLUDES */
-/* ------------------- DEFINITIONS -------------------------- */
-
-/* maximum number of requests on a time limited test */
-#define MAX_REQUESTS 50000
-
-/* good old state hostname */
-#define STATE_UNCONNECTED 0
-#define STATE_CONNECTING 1
-#define STATE_READ 2
-
-#define CBUFFSIZE 512
-
-struct connection {
- int fd;
- int state;
- int read; /* amount of bytes read */
- int bread; /* amount of body read */
- int length; /* Content-Length value used for keep-alive */
- char cbuff[CBUFFSIZE]; /* a buffer to store server response header */
- int cbx; /* offset in cbuffer */
- int keepalive; /* non-zero if a keep-alive request */
- int gotheader; /* non-zero if we have the entire header in
- * cbuff */
- struct timeval start, connect, done;
-};
-
-struct data {
- int read; /* number of bytes read */
- int ctime; /* time in ms to connect */
- int time; /* time in ms for connection */
-};
-
-#define ap_min(a,b) ((a)<(b))?(a):(b)
-#define ap_max(a,b) ((a)>(b))?(a):(b)
-
-/* --------------------- GLOBALS ---------------------------- */
-
-int verbosity = 0; /* no verbosity by default */
-int posting = 0; /* GET by default */
-int requests = 1; /* Number of requests to make */
-int concurrency = 1; /* Number of multiple requests to make */
-int tlimit = 0; /* time limit in cs */
-int keepalive = 0; /* try and do keepalive connections */
-char servername[1024]; /* name that server reports */
-char hostname[1024]; /* host name */
-char path[1024]; /* path name */
-char postfile[1024]; /* name of file containing post data */
-char *postdata; /* *buffer containing data from postfile */
-int postlen = 0; /* length of data to be POSTed */
-char content_type[1024]; /* content type to put in POST header */
-char cookie[1024], /* optional cookie line */
- auth[1024], /* optional (basic/uuencoded)
- * authentification */
- hdrs[4096]; /* optional arbitrary headers */
-int port = 80; /* port number */
-
-int use_html = 0; /* use html in the report */
-char *tablestring;
-char *trstring;
-char *tdstring;
-
-int doclen = 0; /* the length the document should be */
-int totalread = 0; /* total number of bytes read */
-int totalbread = 0; /* totoal amount of entity body read */
-int totalposted = 0; /* total number of bytes posted, inc. headers */
-int done = 0; /* number of requests we have done */
-int doneka = 0; /* number of keep alive connections done */
-int good = 0, bad = 0; /* number of good and bad requests */
-
-/* store error cases */
-int err_length = 0, err_conn = 0, err_except = 0;
-int err_response = 0;
-
-struct timeval start, endtime;
-
-/* global request (and its length) */
-char request[512];
-int reqlen;
-
-/* one global throw-away buffer to read stuff into */
-char buffer[8192];
-
-struct connection *con; /* connection array */
-struct data *stats; /* date for each request */
-
-fd_set readbits, writebits; /* bits for select */
-struct sockaddr_in server; /* server addr structure */
-
-#ifndef BEOS
-#define ab_close(s) close(s)
-#define ab_read(a,b,c) read(a,b,c)
-#define ab_write(a,b,c) write(a,b,c)
-#else
-#define ab_close(s) closesocket(s)
-#define ab_read(a,b,c) recv(a,b,c,0)
-#define ab_write(a,b,c) send(a,b,c,0)
-#endif
-
-/* --------------------------------------------------------- */
-
-/* simple little function to perror and exit */
-
-static void err(char *s)
-{
- if (errno) {
- perror(s);
- }
- else {
- printf("%s", s);
- }
- exit(errno);
-}
-
-/* --------------------------------------------------------- */
-
-/* write out request to a connection - assumes we can write
- (small) request out in one go into our new socket buffer */
-
-static void write_request(struct connection * c)
-{
-#ifndef NO_WRITEV
- struct iovec out[2]; int outcnt = 1;
-#endif
- gettimeofday(&c->connect, 0);
-#ifndef NO_WRITEV
- out[0].iov_base = request;
- out[0].iov_len = reqlen;
-
- if (posting>0) {
- out[1].iov_base = postdata;
- out[1].iov_len = postlen;
- outcnt = 2;
- totalposted += (reqlen + postlen);
- }
- writev(c->fd,out, outcnt);
-#else
- ab_write(c->fd,request,reqlen);
- if (posting>0) {
- ab_write(c->fd,postdata,postlen);
- totalposted += (reqlen + postlen);
- }
-#endif
-
- c->state = STATE_READ;
- FD_SET(c->fd, &readbits);
- FD_CLR(c->fd, &writebits);
-}
-
-/* --------------------------------------------------------- */
-
-/* make an fd non blocking */
-
-static void nonblock(int fd)
-{
- int i = 1;
-#ifdef BEOS
- setsockopt(fd, SOL_SOCKET, SO_NONBLOCK, &i, sizeof(i));
-#else
- ioctl(fd, FIONBIO, &i);
-#endif
-}
-
-/* --------------------------------------------------------- */
-
-/* returns the time in ms between two timevals */
-
-static int timedif(struct timeval a, struct timeval b)
-{
- register int us, s;
-
- us = a.tv_usec - b.tv_usec;
- us /= 1000;
- s = a.tv_sec - b.tv_sec;
- s *= 1000;
- return s + us;
-}
-
-/* --------------------------------------------------------- */
-
-/* calculate and output results */
-
-static void output_results(void)
-{
- int timetaken;
-
- gettimeofday(&endtime, 0);
- timetaken = timedif(endtime, start);
-
- printf("\r \r");
- printf("Server Software: %s\n", servername);
- printf("Server Hostname: %s\n", hostname);
- printf("Server Port: %d\n", port);
- printf("\n");
- printf("Document Path: %s\n", path);
- printf("Document Length: %d bytes\n", doclen);
- printf("\n");
- printf("Concurrency Level: %d\n", concurrency);
- printf("Time taken for tests: %d.%03d seconds\n",
- timetaken / 1000, timetaken % 1000);
- printf("Complete requests: %d\n", done);
- printf("Failed requests: %d\n", bad);
- if (bad)
- printf(" (Connect: %d, Length: %d, Exceptions: %d)\n",
- err_conn, err_length, err_except);
- if (err_response)
- printf("Non-2xx responses: %d\n", err_response);
- if (keepalive)
- printf("Keep-Alive requests: %d\n", doneka);
- printf("Total transferred: %d bytes\n", totalread);
- if (posting>0)
- printf("Total POSTed: %d\n", totalposted);
- printf("HTML transferred: %d bytes\n", totalbread);
-
- /* avoid divide by zero */
- if (timetaken) {
- printf("Requests per second: %.2f\n", 1000 * (float) (done) / timetaken);
- printf("Transfer rate: %.2f kb/s received\n",
- (float) (totalread) / timetaken);
- if (posting>0) {
- printf(" %.2f kb/s sent\n",
- (float) (totalposted) / timetaken);
- printf(" %.2f kb/s total\n",
- (float) (totalread + totalposted) / timetaken);
- }
- }
-
- {
- /* work out connection times */
- int i;
- int totalcon = 0, total = 0;
- int mincon = 9999999, mintot = 999999;
- int maxcon = 0, maxtot = 0;
-
- for (i = 0; i < requests; i++) {
- struct data s = stats[i];
- mincon = ap_min(mincon, s.ctime);
- mintot = ap_min(mintot, s.time);
- maxcon = ap_max(maxcon, s.ctime);
- maxtot = ap_max(maxtot, s.time);
- totalcon += s.ctime;
- total += s.time;
- }
- if (requests > 0) { /* avoid division by zero (if 0 requests) */
- printf("\nConnnection Times (ms)\n");
- printf(" min avg max\n");
- printf("Connect: %5d %5d %5d\n", mincon, totalcon / requests, maxcon);
- printf("Processing: %5d %5d %5d\n",
- mintot - mincon, (total / requests) - (totalcon / requests),
- maxtot - maxcon);
- printf("Total: %5d %5d %5d\n", mintot, total / requests, maxtot);
- }
- }
-}
-
-/* --------------------------------------------------------- */
-
-/* calculate and output results in HTML */
-
-static void output_html_results(void)
-{
- int timetaken;
-
- gettimeofday(&endtime, 0);
- timetaken = timedif(endtime, start);
-
- printf("\n\n<table %s>\n", tablestring);
- printf("<tr %s><th colspan=2 %s>Server Software:</th>"
- "<td colspan=2 %s>%s</td></tr>\n",
- trstring, tdstring, tdstring, servername);
- printf("<tr %s><th colspan=2 %s>Server Hostname:</th>"
- "<td colspan=2 %s>%s</td></tr>\n",
- trstring, tdstring, tdstring, hostname);
- printf("<tr %s><th colspan=2 %s>Server Port:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
- trstring, tdstring, tdstring, port);
- printf("<tr %s><th colspan=2 %s>Document Path:</th>"
- "<td colspan=2 %s>%s</td></tr>\n",
- trstring, tdstring, tdstring, path);
- printf("<tr %s><th colspan=2 %s>Document Length:</th>"
- "<td colspan=2 %s>%d bytes</td></tr>\n",
- trstring, tdstring, tdstring, doclen);
- printf("<tr %s><th colspan=2 %s>Concurrency Level:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
- trstring, tdstring, tdstring, concurrency);
- printf("<tr %s><th colspan=2 %s>Time taken for tests:</th>"
- "<td colspan=2 %s>%d.%03d seconds</td></tr>\n",
- trstring, tdstring, tdstring, timetaken / 1000, timetaken % 1000);
- printf("<tr %s><th colspan=2 %s>Complete requests:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
- trstring, tdstring, tdstring, done);
- printf("<tr %s><th colspan=2 %s>Failed requests:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
- trstring, tdstring, tdstring, bad);
- if (bad)
- printf("<tr %s><td colspan=4 %s > (Connect: %d, Length: %d, Exceptions: %d)</td></tr>\n",
- trstring, tdstring, err_conn, err_length, err_except);
- if (err_response)
- printf("<tr %s><th colspan=2 %s>Non-2xx responses:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
- trstring, tdstring, tdstring, err_response);
- if (keepalive)
- printf("<tr %s><th colspan=2 %s>Keep-Alive requests:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
- trstring, tdstring, tdstring, doneka);
- printf("<tr %s><th colspan=2 %s>Total transferred:</th>"
- "<td colspan=2 %s>%d bytes</td></tr>\n",
- trstring, tdstring, tdstring, totalread);
- if (posting>0)
- printf("<tr %s><th colspan=2 %s>Total POSTed:</th>"
- "<td colspan=2 %s>%d</td></tr>\n",
- trstring, tdstring, tdstring, totalposted);
- printf("<tr %s><th colspan=2 %s>HTML transferred:</th>"
- "<td colspan=2 %s>%d bytes</td></tr>\n",
- trstring, tdstring, tdstring, totalbread);
-
- /* avoid divide by zero */
- if (timetaken) {
- printf("<tr %s><th colspan=2 %s>Requests per second:</th>"
- "<td colspan=2 %s>%.2f</td></tr>\n",
- trstring, tdstring, tdstring, 1000 * (float) (done) / timetaken);
- printf("<tr %s><th colspan=2 %s>Transfer rate:</th>"
- "<td colspan=2 %s>%.2f kb/s received</td></tr>\n",
- trstring, tdstring, tdstring, (float) (totalread) / timetaken);
- if (posting>0) {
- printf("<tr %s><td colspan=2 %s>&nbsp;</td>"
- "<td colspan=2 %s>%.2f kb/s sent</td></tr>\n",
- trstring, tdstring, tdstring,
- (float) (totalposted) / timetaken);
- printf("<tr %s><td colspan=2 %s>&nbsp;</td>"
- "<td colspan=2 %s>%.2f kb/s total</td></tr>\n",
- trstring, tdstring, tdstring,
- (float) (totalread + totalposted) / timetaken);
- }
- }
-
- {
- /* work out connection times */
- int i;
- int totalcon = 0, total = 0;
- int mincon = 9999999, mintot = 999999;
- int maxcon = 0, maxtot = 0;
-
- for (i = 0; i < requests; i++) {
- struct data s = stats[i];
- mincon = ap_min(mincon, s.ctime);
- mintot = ap_min(mintot, s.time);
- maxcon = ap_max(maxcon, s.ctime);
- maxtot = ap_max(maxtot, s.time);
- totalcon += s.ctime;
- total += s.time;
- }
-
- if (requests > 0) { /* avoid division by zero (if 0 requests) */
- printf("<tr %s><th %s colspan=4>Connnection Times (ms)</th></tr>\n",
- trstring, tdstring);
- printf("<tr %s><th %s>&nbsp;</th> <th %s>min</th> <th %s>avg</th> <th %s>max</th></tr>\n",
- trstring, tdstring, tdstring, tdstring, tdstring);
- printf("<tr %s><th %s>Connect:</th>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td></tr>\n",
- trstring, tdstring, tdstring, mincon, tdstring, totalcon / requests, tdstring, maxcon);
- printf("<tr %s><th %s>Processing:</th>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td></tr>\n",
- trstring, tdstring, tdstring, mintot - mincon, tdstring,
- (total / requests) - (totalcon / requests), tdstring, maxtot - maxcon);
- printf("<tr %s><th %s>Total:</th>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td>"
- "<td %s>%5d</td></tr>\n",
- trstring, tdstring, tdstring, mintot, tdstring, total / requests, tdstring, maxtot);
- }
- printf("</table>\n");
- }
-}
-
-/* --------------------------------------------------------- */
-
-/* start asnchronous non-blocking connection */
-
-static void start_connect(struct connection * c)
-{
- c->read = 0;
- c->bread = 0;
- c->keepalive = 0;
- c->cbx = 0;
- c->gotheader = 0;
-
- c->fd = socket(AF_INET, SOCK_STREAM, 0);
- if (c->fd < 0)
- err("socket");
-
- nonblock(c->fd);
- gettimeofday(&c->start, 0);
-
- if (connect(c->fd, (struct sockaddr *) & server, sizeof(server)) < 0) {
- if (errno == EINPROGRESS) {
- c->state = STATE_CONNECTING;
- FD_SET(c->fd, &writebits);
- return;
- }
- else {
- ab_close(c->fd);
- err_conn++;
- if (bad++ > 10) {
- err("\nTest aborted after 10 failures\n\n");
- }
- start_connect(c);
- }
- }
-
- /* connected first time */
- c->state = STATE_CONNECTING;
- FD_SET(c->fd, &writebits);
-}
-
-/* --------------------------------------------------------- */
-
-/* close down connection and save stats */
-
-static void close_connection(struct connection * c)
-{
- if (c->read == 0 && c->keepalive) {
- /* server has legitimately shut down an idle keep alive request */
- good--; /* connection never happend */
- }
- else {
- if (good == 1) {
- /* first time here */
- doclen = c->bread;
- }
- else if (c->bread != doclen) {
- bad++;
- err_length++;
- }
-
- /* save out time */
- if (done < requests) {
- struct data s;
- gettimeofday(&c->done, 0);
- s.read = c->read;
- s.ctime = timedif(c->connect, c->start);
- s.time = timedif(c->done, c->start);
- stats[done++] = s;
- }
- }
-
- ab_close(c->fd);
- FD_CLR(c->fd, &readbits);
- FD_CLR(c->fd, &writebits);
-
- /* connect again */
- start_connect(c);
- return;
-}
-
-/* --------------------------------------------------------- */
-
-/* read data from connection */
-
-static void read_connection(struct connection * c)
-{
- int r;
- char *part;
- char respcode[4]; /* 3 digits and null */
-
- r = ab_read(c->fd, buffer, sizeof(buffer));
-
- if (r == 0 || (r < 0 && errno != EAGAIN)) {
- good++;
- close_connection(c);
- return;
- }
-
- if (r < 0 && errno == EAGAIN)
- return;
-
- c->read += r;
- totalread += r;
-
- if (!c->gotheader) {
- char *s;
- int l = 4;
- int space = CBUFFSIZE - c->cbx - 1; /* -1 to allow for 0
- * terminator */
- int tocopy = (space < r) ? space : r;
-#ifndef CHARSET_EBCDIC
- memcpy(c->cbuff + c->cbx, buffer, tocopy);
-#else /* CHARSET_EBCDIC */
- ascii2ebcdic(c->cbuff + c->cbx, buffer, tocopy);
-#endif /* CHARSET_EBCDIC */
- c->cbx += tocopy;
- space -= tocopy;
- c->cbuff[c->cbx] = 0; /* terminate for benefit of strstr */
- if (verbosity >= 4) {
- printf("LOG: header received:\n%s\n", c->cbuff);
- }
- s = strstr(c->cbuff, "\r\n\r\n");
- /*
- * this next line is so that we talk to NCSA 1.5 which blatantly
- * breaks the http specification
- */
- if (!s) {
- s = strstr(c->cbuff, "\n\n");
- l = 2;
- }
-
- if (!s) {
- /* read rest next time */
- if (space)
- return;
- else {
- /* header is in invalid or too big - close connection */
- ab_close(c->fd);
- if (bad++ > 10) {
- err("\nTest aborted after 10 failures\n\n");
- }
- FD_CLR(c->fd, &writebits);
- start_connect(c);
- }
- }
- else {
- /* have full header */
- if (!good) {
- /* this is first time, extract some interesting info */
- char *p, *q;
- p = strstr(c->cbuff, "Server:");
- q = servername;
- if (p) {
- p += 8;
- while (*p > 32)
- *q++ = *p++;
- }
- *q = 0;
- }
-
- /*
- * XXX: this parsing isn't even remotely HTTP compliant... but in
- * the interest of speed it doesn't totally have to be, it just
- * needs to be extended to handle whatever servers folks want to
- * test against. -djg
- */
-
- /* check response code */
- part = strstr(c->cbuff, "HTTP"); /* really HTTP/1.x_ */
- strncpy(respcode, (part + strlen("HTTP/1.x_")), 3);
- respcode[3] = '\0';
- if (respcode[0] != '2') {
- err_response++;
- if (verbosity >= 2)
- printf("WARNING: Response code not 2xx (%s)\n", respcode);
- }
- else if (verbosity >= 3) {
- printf("LOG: Response code = %s\n", respcode);
- }
-
- c->gotheader = 1;
- *s = 0; /* terminate at end of header */
- if (keepalive &&
- (strstr(c->cbuff, "Keep-Alive")
- || strstr(c->cbuff, "keep-alive"))) { /* for benefit of MSIIS */
- char *cl;
- cl = strstr(c->cbuff, "Content-Length:");
- /* handle NCSA, which sends Content-length: */
- if (!cl)
- cl = strstr(c->cbuff, "Content-length:");
- if (cl) {
- c->keepalive = 1;
- c->length = atoi(cl + 16);
- }
- }
- c->bread += c->cbx - (s + l - c->cbuff) + r - tocopy;
- totalbread += c->bread;
- }
- }
- else {
- /* outside header, everything we have read is entity body */
- c->bread += r;
- totalbread += r;
- }
-
- /* cater for the case where we're using keepalives and doing HEAD requests */
- if (c->keepalive && ((c->bread >= c->length) || (posting < 0))) {
- /* finished a keep-alive connection */
- good++;
- doneka++;
- /* save out time */
- if (good == 1) {
- /* first time here */
- doclen = c->bread;
- }
- else if (c->bread != doclen) {
- bad++;
- err_length++;
- }
- if (done < requests) {
- struct data s;
- gettimeofday(&c->done, 0);
- s.read = c->read;
- s.ctime = timedif(c->connect, c->start);
- s.time = timedif(c->done, c->start);
- stats[done++] = s;
- }
- c->keepalive = 0;
- c->length = 0;
- c->gotheader = 0;
- c->cbx = 0;
- c->read = c->bread = 0;
- write_request(c);
- c->start = c->connect; /* zero connect time with keep-alive */
- }
-}
-
-/* --------------------------------------------------------- */
-
-/* run the tests */
-
-static void test(void)
-{
- struct timeval timeout, now;
- fd_set sel_read, sel_except, sel_write;
- int i;
-
- if (!use_html) {
- printf("Benchmarking %s (be patient)...", hostname);
- fflush(stdout);
- }
-
- {
- /* get server information */
- struct hostent *he;
- he = gethostbyname(hostname);
- if (!he)
- err("bad hostname");
- server.sin_family = he->h_addrtype;
- server.sin_port = htons(port);
- server.sin_addr.s_addr = ((unsigned long *) (he->h_addr_list[0]))[0];
- }
-
- con = malloc(concurrency * sizeof(struct connection));
- memset(con, 0, concurrency * sizeof(struct connection));
-
- stats = malloc(requests * sizeof(struct data));
-
- FD_ZERO(&readbits);
- FD_ZERO(&writebits);
-
- /* setup request */
- if (posting <= 0) {
- sprintf(request, "%s %s HTTP/1.0\r\n"
- "User-Agent: ApacheBench/%s\r\n"
- "%s" "%s" "%s"
- "Host: %s\r\n"
- "Accept: */*\r\n"
- "%s" "\r\n",
- (posting == 0) ? "GET" : "HEAD",
- path,
- VERSION,
- keepalive ? "Connection: Keep-Alive\r\n" : "",
- cookie, auth, hostname, hdrs);
- }
- else {
- sprintf(request, "POST %s HTTP/1.0\r\n"
- "User-Agent: ApacheBench/%s\r\n"
- "%s" "%s" "%s"
- "Host: %s\r\n"
- "Accept: */*\r\n"
- "Content-length: %d\r\n"
- "Content-type: %s\r\n"
- "%s"
- "\r\n",
- path,
- VERSION,
- keepalive ? "Connection: Keep-Alive\r\n" : "",
- cookie, auth,
- hostname, postlen,
- (content_type[0]) ? content_type : "text/plain", hdrs);
- }
-
- if (verbosity >= 2)
- printf("INFO: POST header == \n---\n%s\n---\n", request);
-
- reqlen = strlen(request);
-
-#ifdef CHARSET_EBCDIC
- ebcdic2ascii(request, request, reqlen);
-#endif /* CHARSET_EBCDIC */
-
- /* ok - lets start */
- gettimeofday(&start, 0);
-
- /* initialise lots of requests */
- for (i = 0; i < concurrency; i++)
- start_connect(&con[i]);
-
- while (done < requests) {
- int n;
- /* setup bit arrays */
- memcpy(&sel_except, &readbits, sizeof(readbits));
- memcpy(&sel_read, &readbits, sizeof(readbits));
- memcpy(&sel_write, &writebits, sizeof(readbits));
-
- /* check for time limit expiry */
- gettimeofday(&now, 0);
- if (tlimit && timedif(now, start) > (tlimit * 1000)) {
- requests = done; /* so stats are correct */
- }
-
- /* Timeout of 30 seconds. */
- timeout.tv_sec = 30;
- timeout.tv_usec = 0;
- n = ap_select(FD_SETSIZE, &sel_read, &sel_write, &sel_except, &timeout);
- if (!n) {
- err("\nServer timed out\n\n");
- }
- if (n < 1)
- err("select");
-
- for (i = 0; i < concurrency; i++) {
- int s = con[i].fd;
- if (FD_ISSET(s, &sel_except)) {
- bad++;
- err_except++;
- start_connect(&con[i]);
- continue;
- }
- if (FD_ISSET(s, &sel_read))
- read_connection(&con[i]);
- if (FD_ISSET(s, &sel_write))
- write_request(&con[i]);
- }
- }
- if (use_html)
- output_html_results();
- else
- output_results();
-}
-
-/* ------------------------------------------------------- */
-
-/* display copyright information */
-static void copyright(void)
-{
- if (!use_html) {
- printf("This is ApacheBench, Version %s\n", VERSION " <$Revision: 1.5 $> apache-2.0");
- printf("Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/\n");
- printf("Copyright (c) 1998-1999 The Apache Group, http://www.apache.org/\n");
- printf("\n");
- }
- else {
- printf("<p>\n");
- printf(" This is ApacheBench, Version %s <i>&lt;%s&gt;</i> apache-2.0<br>\n", VERSION, "$Revision: 1.5 $");
- printf(" Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/<br>\n");
- printf(" Copyright (c) 1998-1999 The Apache Group, http://www.apache.org/<br>\n");
- printf("</p>\n<p>\n");
- }
-}
-
-/* display usage information */
-static void usage(char *progname)
-{
- fprintf(stderr, "Usage: %s [options] [http://]hostname[:port]/path\n", progname);
- fprintf(stderr, "Options are:\n");
- fprintf(stderr, " -n requests Number of requests to perform\n");
- fprintf(stderr, " -c concurrency Number of multiple requests to make\n");
- fprintf(stderr, " -t timelimit Seconds to max. wait for responses\n");
- fprintf(stderr, " -p postfile File containg data to POST\n");
- fprintf(stderr, " -T content-type Content-type header for POSTing\n");
- fprintf(stderr, " -v verbosity How much troubleshooting info to print\n");
- fprintf(stderr, " -w Print out results in HTML tables\n");
- fprintf(stderr, " -i Use HEAD instead of GET\n");
- fprintf(stderr, " -x attributes String to insert as table attributes\n");
- fprintf(stderr, " -y attributes String to insert as tr attributes\n");
- fprintf(stderr, " -z attributes String to insert as td or th attributes\n");
- fprintf(stderr, " -C attribute Add cookie, eg. 'Apache=1234. (repeatable)\n");
- fprintf(stderr, " -H attribute Add Arbitrary header line, eg. 'Accept-Encoding: zop'\n");
- fprintf(stderr, " Inserted after all normal header lines. (repeatable)\n");
- fprintf(stderr, " -A attribute Add Basic WWW Authentication, the attributes\n");
- fprintf(stderr, " are a colon separated username and password.\n");
- fprintf(stderr, " -p attribute Add Basic Proxy Authentication, the attributes\n");
- fprintf(stderr, " are a colon separated username and password.\n");
- fprintf(stderr, " -V Print version number and exit\n");
- fprintf(stderr, " -k Use HTTP KeepAlive feature\n");
- fprintf(stderr, " -h Display usage information (this message)\n");
- exit(EINVAL);
-}
-
-/* ------------------------------------------------------- */
-
-/* split URL into parts */
-
-static int parse_url(char *url)
-{
- char *cp;
- char *h;
- char *p = NULL;
-
- if (strlen(url) > 7 && strncmp(url, "http://", 7) == 0)
- url += 7;
- h = url;
- if ((cp = strchr(url, ':')) != NULL) {
- *cp++ = '\0';
- p = cp;
- url = cp;
- }
- if ((cp = strchr(url, '/')) == NULL)
- return 1;
- strcpy(path, cp);
- *cp = '\0';
- strcpy(hostname, h);
- if (p != NULL)
- port = atoi(p);
- return 0;
-}
-
-/* ------------------------------------------------------- */
-
-/* read data to POST from file, save contents and length */
-
-static int open_postfile(char *pfile)
-{
- int postfd, status;
- struct stat postfilestat;
-
- if ((postfd = open(pfile, O_RDONLY)) == -1) {
- printf("Invalid postfile name (%s)\n", pfile);
- return errno;
- }
- if ((status = fstat(postfd, &postfilestat)) == -1) {
- perror("Can\'t stat postfile\n");
- return status;
- }
- postdata = malloc(postfilestat.st_size);
- if (!postdata) {
- printf("Can\'t alloc postfile buffer\n");
- return ENOMEM;
- }
- if (read(postfd, postdata, postfilestat.st_size) != postfilestat.st_size) {
- printf("error reading postfilen");
- return EIO;
- }
- postlen = postfilestat.st_size;
- return 0;
-}
-
-/* ------------------------------------------------------- */
-
-extern char *optarg;
-extern int optind, opterr, optopt;
-
-/* sort out command-line args and call test */
-int main(int argc, char **argv)
-{
- int c, r,l;
- char tmp[1024];
-
- /* table defaults */
- tablestring = "";
- trstring = "";
- tdstring = "bgcolor=white";
- cookie[0] = '\0';
- auth[0] = '\0';
- hdrs[0] = '\0';
- optind = 1;
- while ((c = getopt(argc, argv, "n:c:t:T:p:v:kVhwix:y:z:C:H:P:A:")) > 0) {
- switch (c) {
- case 'n':
- requests = atoi(optarg);
- if (!requests) {
- err("Invalid number of requests\n");
- }
- break;
- case 'k':
- keepalive = 1;
- break;
- case 'c':
- concurrency = atoi(optarg);
- break;
- case 'i':
- if (posting==1)
- err("Cannot mix POST and HEAD");
-
- posting = -1;
- break;
- case 'p':
- if (posting!=0)
- err("Cannot mix POST and HEAD");
-
- if (0 == (r = open_postfile(optarg))) {
- posting = 1;
- }
- else if (postdata) {
- exit(r);
- }
- break;
- case 'v':
- verbosity = atoi(optarg);
- break;
- case 't':
- tlimit = atoi(optarg);
- requests = MAX_REQUESTS; /* need to size data array on
- * something */
- break;
- case 'T':
- strcpy(content_type, optarg);
- break;
- case 'C':
- strncat(cookie, "Cookie: ", sizeof(cookie));
- strncat(cookie, optarg, sizeof(cookie));
- strncat(cookie, "\r\n", sizeof(cookie));
- break;
- case 'A':
- /* assume username passwd already to be in colon separated form. Ready
- * to be uu-encoded.
- */
- while(isspace(*optarg))
- optarg++;
- l=ap_base64encode(tmp,optarg,strlen(optarg));
- tmp[l]='\0';
-
- strncat(auth, "Authorization: basic ", sizeof(auth));
- strncat(auth, tmp, sizeof(auth));
- strncat(auth, "\r\n", sizeof(auth));
- break;
- case 'P':
- /*
- * assume username passwd already to be in colon separated form.
- */
- while(isspace(*optarg))
- optarg++;
- l=ap_base64encode(tmp,optarg,strlen(optarg));
- tmp[l]='\0';
-
- strncat(auth, "Proxy-Authorization: basic ", sizeof(auth));
- strncat(auth, tmp, sizeof(auth));
- strncat(auth, "\r\n", sizeof(auth));
- break;
- case 'H':
- strncat(hdrs, optarg, sizeof(hdrs));
- strncat(hdrs, "\r\n", sizeof(hdrs));
- break;
- case 'V':
- copyright();
- exit(0);
- break;
- case 'w':
- use_html = 1;
- break;
- /*
- * if any of the following three are used, turn on html output
- * automatically
- */
- case 'x':
- use_html = 1;
- tablestring = optarg;
- break;
- case 'y':
- use_html = 1;
- trstring = optarg;
- break;
- case 'z':
- use_html = 1;
- tdstring = optarg;
- break;
- case 'h':
- usage(argv[0]);
- break;
- default:
- fprintf(stderr, "%s: invalid option `%c'\n", argv[0], c);
- usage(argv[0]);
- break;
- }
- }
- if (optind != argc - 1) {
- fprintf(stderr, "%s: wrong number of arguments\n", argv[0]);
- usage(argv[0]);
- }
-
- if (parse_url(argv[optind++])) {
- fprintf(stderr, "%s: invalid URL\n", argv[0]);
- usage(argv[0]);
- }
-
- copyright();
- test();
-
- exit(0);
-}
diff --git a/support/apxs.in b/support/apxs.in
deleted file mode 100644
index dbb20bf916..0000000000
--- a/support/apxs.in
+++ /dev/null
@@ -1,658 +0,0 @@
-#!/usr/local/bin/perl
-## ====================================================================
-## Copyright (c) 1998-1999 The Apache Group. 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 acknowledgment:
-## "This product includes software developed by the Apache Group
-## for use in the Apache HTTP server project (http://www.apache.org/)."
-##
-## 4. The names "Apache Server" and "Apache Group" must not be used to
-## endorse or promote products derived from this software without
-## prior written permission. For written permission, please contact
-## apache@apache.org.
-##
-## 5. Products derived from this software may not be called "Apache"
-## nor may "Apache" appear in their names without prior written
-## permission of the Apache Group.
-##
-## 6. Redistributions of any form whatsoever must retain the following
-## acknowledgment:
-## "This product includes software developed by the Apache Group
-## for use in the Apache HTTP server project (http://www.apache.org/)."
-##
-## THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-## EXPRESSED 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 APACHE GROUP OR
-## ITS 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.
-## ====================================================================
-##
-## This software consists of voluntary contributions made by many
-## individuals on behalf of the Apache Group and was originally based
-## on public domain software written at the National Center for
-## Supercomputing Applications, University of Illinois, Urbana-Champaign.
-## For more information on the Apache Group and the Apache HTTP server
-## project, please see <http://www.apache.org/>.
-##
-
-##
-## apxs -- APache eXtenSion tool
-## Written by Ralf S. Engelschall <rse@apache.org>
-##
-
-require 5.003;
-use strict;
-package apxs;
-
-##
-## Configuration
-##
-
-my $CFG_TARGET = '@TARGET@'; # substituted via Makefile.tmpl
-my $CFG_CC = '@CC@'; # substituted via Makefile.tmpl
-my $CFG_CFLAGS = '@CFLAGS@'; # substituted via Makefile.tmpl
-my $CFG_CFLAGS_SHLIB = '@CFLAGS_SHLIB@'; # substituted via Makefile.tmpl
-my $CFG_LD_SHLIB = '@LD_SHLIB@'; # substituted via Makefile.tmpl
-my $CFG_LDFLAGS_SHLIB = '@LDFLAGS_MOD_SHLIB@'; # substituted via Makefile.tmpl
-my $CFG_LIBS_SHLIB = '@LIBS_SHLIB@'; # substituted via Makefile.tmpl
-my $CFG_PREFIX = '@prefix@'; # substituted via APACI install
-my $CFG_SBINDIR = '@sbindir@'; # substituted via APACI install
-my $CFG_INCLUDEDIR = '@includedir@'; # substituted via APACI install
-my $CFG_LIBEXECDIR = '@libexecdir@'; # substituted via APACI install
-my $CFG_SYSCONFDIR = '@sysconfdir@'; # substituted via APACI install
-
-##
-## Cleanup the above stuff
-##
-$CFG_CFLAGS =~ s|^\s+||;
-$CFG_CFLAGS =~ s|\s+$||;
-$CFG_CFLAGS =~ s|\s+`.+apaci`||;
-
-##
-## parse argument line
-##
-
-# defaults for parameters
-my $opt_n = '';
-my $opt_g = '';
-my $opt_c = 0;
-my $opt_o = '';
-my @opt_D = ();
-my @opt_I = ();
-my @opt_L = ();
-my @opt_l = ();
-my @opt_W = ();
-my @opt_S = ();
-my $opt_e = 0;
-my $opt_i = 0;
-my $opt_a = 0;
-my $opt_A = 0;
-my $opt_q = 0;
-
-# this subroutine is derived from Perl's getopts.pl with the enhancement of
-# the "+" metacharater at the format string to allow a list to be build by
-# subsequent occurance of the same option.
-sub Getopts {
- my ($argumentative, @ARGV) = @_;
- my (@args, $first, $rest, $pos);
- my ($errs) = 0;
- local ($_);
- local ($[) = 0;
-
- @args = split( / */, $argumentative);
- while(@ARGV && ($_ = $ARGV[0]) =~ /^-(.)(.*)/) {
- ($first, $rest) = ($1,$2);
- if ($_ =~ m|^--$|) {
- shift(@ARGV);
- last;
- }
- $pos = index($argumentative,$first);
- if($pos >= $[) {
- if($args[$pos+1] eq ':') {
- shift(@ARGV);
- if($rest eq '') {
- unless (@ARGV) {
- print STDERR "apxs:Error: Incomplete option: $first (needs an argument)\n";
- ++$errs;
- }
- $rest = shift(@ARGV);
- }
- eval "\$opt_$first = \$rest;";
- }
- elsif ($args[$pos+1] eq '+') {
- shift(@ARGV);
- if($rest eq '') {
- unless (@ARGV) {
- print STDERR "apxs:Error: Incomplete option: $first (needs an argument)\n";
- ++$errs;
- }
- $rest = shift(@ARGV);
- }
- eval "push(\@opt_$first, \$rest);";
- }
- else {
- eval "\$opt_$first = 1";
- if($rest eq '') {
- shift(@ARGV);
- }
- else {
- $ARGV[0] = "-$rest";
- }
- }
- }
- else {
- print STDERR "apxs:Error: Unknown option: $first\n";
- ++$errs;
- if($rest ne '') {
- $ARGV[0] = "-$rest";
- }
- else {
- shift(@ARGV);
- }
- }
- }
- return ($errs == 0, @ARGV);
-}
-
-sub usage {
- print STDERR "Usage: apxs -g [-S <var>=<val>] -n <modname>\n";
- print STDERR " apxs -q [-S <var>=<val>] <query> ...\n";
- print STDERR " apxs -c [-S <var>=<val>] [-o <dsofile>] [-D <name>[=<value>]]\n";
- print STDERR " [-I <incdir>] [-L <libdir>] [-l <libname>] [-Wc,<flags>]\n";
- print STDERR " [-Wl,<flags>] <files> ...\n";
- print STDERR " apxs -i [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...\n";
- print STDERR " apxs -e [-S <var>=<val>] [-a] [-A] [-n <modname>] <dsofile> ...\n";
- exit(1);
-}
-
-# option handling
-my $rc;
-($rc, @ARGV) = &Getopts("qn:gco:I+D+L+l+W+S+eiaA", @ARGV);
-&usage if ($rc == 0);
-&usage if ($#ARGV == -1 and not $opt_g);
-&usage if (not $opt_q and not ($opt_g and $opt_n) and not $opt_i and not $opt_c and not $opt_e);
-
-# argument handling
-my @args = @ARGV;
-my $name = 'unknown';
-$name = $opt_n if ($opt_n ne '');
-
-if (@opt_S) {
- my ($opt_S);
- foreach $opt_S (@opt_S) {
- if ($opt_S =~ m/^([^=]+)=(.*)$/) {
- my ($var) = $1;
- my ($val) = $2;
- my $oldval = eval "\$CFG_$var";
-
- unless ($var and $oldval) {
- print STDERR "apxs:Error: no config variable $var\n";
- &usage;
- }
-
- eval "\$CFG_${var}=\"${val}\"";
- } else {
- print STDERR "apxs:Error: malformatted -S option\n";
- &usage;
- }
- }
-}
-
-##
-## Initial shared object support check
-##
-if (not -x "$CFG_SBINDIR/$CFG_TARGET") {
- print STDERR "apxs:Error: $CFG_SBINDIR/$CFG_TARGET not found or not executable\n";
- exit(1);
-}
-if (not grep(/mod_so/, `$CFG_SBINDIR/$CFG_TARGET -l`)) {
- print STDERR "apxs:Error: Sorry, no shared object support for Apache\n";
- print STDERR "apxs:Error: available under your platform. Make sure\n";
- print STDERR "apxs:Error: the Apache module mod_so is compiled into\n";
- print STDERR "apxs:Error: your server binary `$CFG_SBINDIR/$CFG_TARGET'.\n";
- exit(1);
-}
-
-##
-## Operation
-##
-
-# helper function for executing a list of
-# system command with return code checks
-sub execute_cmds {
- my (@cmds) = @_;
- my ($cmd, $rc);
-
- foreach $cmd (@cmds) {
- print STDERR "$cmd\n";
- $rc = system("$cmd");
- if ($rc != 0) {
- printf(STDERR "apxs:Break: Command failed with rc=%d\n", $rc << 8);
- exit(1);
- }
- }
-}
-
-if ($opt_g) {
- ##
- ## SAMPLE MODULE SOURCE GENERATION
- ##
-
- if (-d $name) {
- print STDERR "apxs:Error: Directory `$name' already exists. Remove first\n";
- exit(1);
- }
-
- my $data = join('', <DATA>);
- $data =~ s|%NAME%|$name|sg;
- $data =~ s|%TARGET%|$CFG_TARGET|sg;
-
- my ($mkf, $src) = ($data =~ m|^(.+)-=#=-\n(.+)|s);
-
- print STDERR "Creating [DIR] $name\n";
- system("mkdir $name");
- print STDERR "Creating [FILE] $name/Makefile\n";
- open(FP, ">${name}/Makefile") || die;
- print FP $mkf;
- close(FP);
- print STDERR "Creating [FILE] $name/mod_$name.c\n";
- open(FP, ">${name}/mod_${name}.c") || die;
- print FP $src;
- close(FP);
-
- exit(0);
-}
-
-
-if ($opt_q) {
- ##
- ## QUERY INFORMATION
- ##
-
- my $result = '';
- my $arg;
- foreach $arg (@args) {
- my $ok = 0;
- my $name;
- foreach $name (qw(
- TARGET CC CFLAGS CFLAGS_SHLIB LD_SHLIB LDFLAGS_SHLIB LIBS_SHLIB
- PREFIX SBINDIR INCLUDEDIR LIBEXECDIR SYSCONFDIR
- )) {
- if ($arg eq $name or $arg eq lc($name)) {
- my $val = eval "\$CFG_$name";
- $result .= "${val}::";
- $ok = 1;
- }
- }
- if (not $ok) {
- printf(STDERR "apxs:Error: Invalid query string `%s'\n", $arg);
- exit(1);
- }
- }
- $result =~ s|::$||;
- $result =~ s|::| |;
- print $result;
-}
-
-if ($opt_c) {
- ##
- ## SHARED OBJECT COMPILATION
- ##
-
- # split files into sources and objects
- my @srcs = ();
- my @objs = ();
- my $f;
- foreach $f (@args) {
- if ($f =~ m|\.c$|) {
- push(@srcs, $f);
- }
- else {
- push(@objs, $f);
- }
- }
-
- # determine output file
- my $dso_file;
- if ($opt_o eq '') {
- if ($#srcs > -1) {
- $dso_file = $srcs[0];
- $dso_file =~ s|\.[^.]+$|.so|;
- }
- elsif ($#objs > -1) {
- $dso_file = $objs[0];
- $dso_file =~ s|\.[^.]+$|.so|;
- }
- else {
- $dso_file = "mod_unknown.so";
- }
- }
- else {
- $dso_file = $opt_o;
- }
-
- # create compilation commands
- my @cmds = ();
- my $opt = '';
- my ($opt_Wc, $opt_I, $opt_D);
- foreach $opt_Wc (@opt_W) {
- $opt .= "$1 " if ($opt_Wc =~ m|^\s*c,(.*)$|);
- }
- foreach $opt_I (@opt_I) {
- $opt .= "-I$opt_I ";
- }
- foreach $opt_D (@opt_D) {
- $opt .= "-D$opt_D ";
- }
- my $cflags = "$CFG_CFLAGS $CFG_CFLAGS_SHLIB";
- my $s;
- foreach $s (@srcs) {
- my $o = $s;
- $o =~ s|\.c$|.o|;
- push(@cmds, "$CFG_CC $cflags -I$CFG_INCLUDEDIR $opt -c $s");
- unshift(@objs, $o);
- }
-
- # create link command
- my $cmd = "$CFG_LD_SHLIB $CFG_LDFLAGS_SHLIB -o $dso_file";
- my $o;
- foreach $o (@objs) {
- $cmd .= " $o";
- }
- $opt = '';
- my ($opt_Wl, $opt_L, $opt_l);
- foreach $opt_Wl (@opt_W) {
- if($CFG_LD_SHLIB ne "gcc") {
- $opt .= " $1" if ($opt_Wl =~ m|^\s*l,(.*)$|);
- } else {
- $opt .= " -W$opt_Wl";
- }
- }
- foreach $opt_L (@opt_L) {
- $opt .= " -L$opt_L";
- }
- foreach $opt_l (@opt_l) {
- $opt .= " -l$opt_l";
- }
- $cmd .= $opt;
- $cmd .= " $CFG_LIBS_SHLIB";
- push(@cmds, $cmd);
-
- # execute the commands
- &execute_cmds(@cmds);
-
- # allow one-step compilation and installation
- if ($opt_i or $opt_e) {
- @args = ( $dso_file );
- }
-}
-
-if ($opt_i or $opt_e) {
- ##
- ## SHARED OBJECT INSTALLATION
- ##
-
- # determine installation commands
- # and corresponding LoadModule/AddModule directives
- my @lmd = ();
- my @amd = ();
- my @cmds = ();
- my $f;
- foreach $f (@args) {
- if ($f !~ m|\.so$|) {
- print STDERR "apxs:Error: file $f is not a shared object\n";
- exit(1);
- }
- my $t = $f;
- $t =~ s|^.+/([^/]+)$|$1|;
- if ($opt_i) {
- push(@cmds, "cp $f $CFG_LIBEXECDIR/$t");
- push(@cmds, "chmod 755 $CFG_LIBEXECDIR/$t");
- }
-
- # determine module symbolname and filename
- my $filename = '';
- if ($name eq 'unknown') {
- $name = '';
- my $base = $f;
- $base =~ s|\.[^.]+$||;
- if (-f "$base.c") {
- open(FP, "<$base.c");
- my $content = join('', <FP>);
- close(FP);
- if ($content =~ m|.*module\s+(?:MODULE_VAR_EXPORT\s+)?([a-zA-Z0-9_]+)_module\s*=\s*.*|s) {
- $name = "$1";
- $filename = "$base.c";
- $filename =~ s|^[^/]+/||;
- }
- }
- if ($name eq '') {
- if ($base =~ m|.*mod_([a-zA-Z0-9_]+)\..+|) {
- $name = "$1";
- $filename = $base;
- $filename =~ s|^[^/]+/||;
- }
- }
- if ($name eq '') {
- print "apxs:Error: Sorry, cannot determine bootstrap symbol name\n";
- print "apxs:Error: Please specify one with option `-n'\n";
- exit(1);
- }
- }
- if ($filename eq '') {
- $filename = "mod_${name}.c";
- }
- my $dir = $CFG_LIBEXECDIR;
- $dir =~ s|^$CFG_PREFIX/?||;
- $dir =~ s|(.)$|$1/|;
- push(@lmd, sprintf("LoadModule %-18s %s", "${name}_module", "$dir$t"));
- push(@amd, sprintf("AddModule %s", $filename));
- }
-
- # execute the commands
- &execute_cmds(@cmds);
-
- # activate module via LoadModule/AddModule directive
- if ($opt_a or $opt_A) {
- if (not -f "$CFG_SYSCONFDIR/$CFG_TARGET.conf") {
- print "apxs:Error: Config file $CFG_SYSCONFDIR/$CFG_TARGET.conf not found\n";
- exit(1);
- }
-
- open(FP, "<$CFG_SYSCONFDIR/$CFG_TARGET.conf") || die;
- my $content = join('', <FP>);
- close(FP);
-
- if ($content !~ m|\n#?\s*LoadModule\s+|) {
- print STDERR "apxs:Error: Activation failed for custom $CFG_SYSCONFDIR/$CFG_TARGET.conf file.\n";
- print STDERR "apxs:Error: At least one `LoadModule' directive already has to exist.\n";
- exit(1);
- }
-
- my $lmd;
- my $c = '';
- $c = '#' if ($opt_A);
- foreach $lmd (@lmd) {
- my $what = $opt_A ? "preparing" : "activating";
- if ($content !~ m|\n#?\s*$lmd|) {
- $content =~ s|^(.*\n#?\s*LoadModule\s+[^\n]+\n)|$1$c$lmd\n|sg;
- } else {
- $content =~ s|^(.*\n)#?\s*$lmd[^\n]*\n|$1$c$lmd\n|sg;
- }
- $lmd =~ m|LoadModule\s+(.+?)_module.*|;
- print STDERR "[$what module `$1' in $CFG_SYSCONFDIR/$CFG_TARGET.conf]\n";
- }
- my $amd;
- foreach $amd (@amd) {
- if ($content !~ m|\n#?\s*$amd|) {
- $content =~ s|^(.*\n#?\s*AddModule\s+[^\n]+\n)|$1$c$amd\n|sg;
- } else {
- $content =~ s|^(.*\n)#?\s*$amd[^\n]*\n|$1$c$amd\n|sg;
- }
- }
- if (@lmd or @amd) {
- if (open(FP, ">$CFG_SYSCONFDIR/$CFG_TARGET.conf.new")) {
- print FP $content;
- close(FP);
- system("cp $CFG_SYSCONFDIR/$CFG_TARGET.conf $CFG_SYSCONFDIR/$CFG_TARGET.conf.bak && " .
- "cp $CFG_SYSCONFDIR/$CFG_TARGET.conf.new $CFG_SYSCONFDIR/$CFG_TARGET.conf && " .
- "rm $CFG_SYSCONFDIR/$CFG_TARGET.conf.new");
- } else {
- print STDERR "unable to open configuration file\n";
- }
- }
- }
-}
-
-##EOF##
-__DATA__
-##
-## Makefile -- Build procedure for sample %NAME% Apache module
-## Autogenerated via ``apxs -n %NAME% -g''.
-##
-
-# the used tools
-APXS=apxs
-APACHECTL=apachectl
-
-# additional defines, includes and libraries
-#DEF=-Dmy_define=my_value
-#INC=-Imy/include/dir
-#LIB=-Lmy/lib/dir -lmylib
-
-# the default target
-all: mod_%NAME%.so
-
-# compile the shared object file
-mod_%NAME%.so: mod_%NAME%.c
- $(APXS) -c $(DEF) $(INC) $(LIB) mod_%NAME%.c
-
-# install the shared object file into Apache
-install: all
- $(APXS) -i -a -n '%NAME%' mod_%NAME%.so
-
-# cleanup
-clean:
- -rm -f mod_%NAME%.o mod_%NAME%.so
-
-# simple test
-test: reload
- lynx -mime_header http://localhost/%NAME%
-
-# install and activate shared object by reloading Apache to
-# force a reload of the shared object file
-reload: install restart
-
-# the general Apache start/restart/stop
-# procedures
-start:
- $(APACHECTL) start
-restart:
- $(APACHECTL) restart
-stop:
- $(APACHECTL) stop
-
--=#=-
-/*
-** mod_%NAME%.c -- Apache sample %NAME% module
-** [Autogenerated via ``apxs -n %NAME% -g'']
-**
-** To play with this sample module first compile it into a
-** DSO file and install it into Apache's libexec directory
-** by running:
-**
-** $ apxs -c -i mod_%NAME%.c
-**
-** Then activate it in Apache's %TARGET%.conf file for instance
-** for the URL /%NAME% in as follows:
-**
-** # %TARGET%.conf
-** LoadModule %NAME%_module libexec/mod_%NAME%.so
-** <Location /%NAME%>
-** SetHandler %NAME%
-** </Location>
-**
-** Then after restarting Apache via
-**
-** $ apachectl restart
-**
-** you immediately can request the URL /%NAME and watch for the
-** output of this module. This can be achieved for instance via:
-**
-** $ lynx -mime_header http://localhost/%NAME%
-**
-** The output should be similar to the following one:
-**
-** HTTP/1.1 200 OK
-** Date: Tue, 31 Mar 1998 14:42:22 GMT
-** Server: Apache/1.3.4 (Unix)
-** Connection: close
-** Content-Type: text/html
-**
-** The sample page from mod_%NAME%.c
-*/
-
-#include "httpd.h"
-#include "http_config.h"
-#include "http_protocol.h"
-#include "ap_config.h"
-
-/* The sample content handler */
-static int %NAME%_handler(request_rec *r)
-{
- r->content_type = "text/html";
- ap_send_http_header(r);
- if (!r->header_only)
- ap_rputs("The sample page from mod_%NAME%.c\n", r);
- return OK;
-}
-
-/* Dispatch list of content handlers */
-static const handler_rec %NAME%_handlers[] = {
- { "%NAME%", %NAME%_handler },
- { NULL, NULL }
-};
-
-/* Dispatch list for API hooks */
-module MODULE_VAR_EXPORT %NAME%_module = {
- STANDARD_MODULE_STUFF,
- NULL, /* module initializer */
- NULL, /* create per-dir config structures */
- NULL, /* merge per-dir config structures */
- NULL, /* create per-server config structures */
- NULL, /* merge per-server config structures */
- NULL, /* table of config file commands */
- %NAME%_handlers, /* [#8] MIME-typed-dispatched handlers */
- NULL, /* [#1] URI to filename translation */
- NULL, /* [#4] validate user id from request */
- NULL, /* [#5] check if the user is ok _here_ */
- NULL, /* [#3] check access by host address */
- NULL, /* [#6] determine MIME type */
- NULL, /* [#7] pre-run fixups */
- NULL, /* [#9] log a transaction */
- NULL, /* [#2] header parser */
- NULL, /* child_init */
- NULL, /* child_exit */
- NULL /* [#0] post read-request */
-};
-
diff --git a/support/dbmmanage b/support/dbmmanage
deleted file mode 100644
index 721bdd1eb3..0000000000
--- a/support/dbmmanage
+++ /dev/null
@@ -1,189 +0,0 @@
-#!/usr/local/bin/perl
-
-# ====================================================================
-# Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
-# "This product includes software developed by the Apache Group
-# for use in the Apache HTTP server project (http://www.apache.org/)."
-#
-# 4. The names "Apache Server" and "Apache Group" must not be used to
-# endorse or promote products derived from this software without
-# prior written permission. For written permission, please contact
-# apache@apache.org.
-#
-# 5. Products derived from this software may not be called "Apache"
-# nor may "Apache" appear in their names without prior written
-# permission of the Apache Group.
-#
-# 6. Redistributions of any form whatsoever must retain the following
-# acknowledgment:
-# "This product includes software developed by the Apache Group
-# for use in the Apache HTTP server project (http://www.apache.org/)."
-#
-# THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-# EXPRESSED 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 APACHE GROUP OR
-# ITS 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.
-# ====================================================================
-#
-# This software consists of voluntary contributions made by many
-# individuals on behalf of the Apache Group and was originally based
-# on public domain software written at the National Center for
-# Supercomputing Applications, University of Illinois, Urbana-Champaign.
-# For more information on the Apache Group and the Apache HTTP server
-# project, please see <http://www.apache.org/>.
-
-#for more functionality see the HTTPD::UserAdmin module:
-# http://www.perl.com/CPAN/modules/by-module/HTTPD/HTTPD-Tools-x.xx.tar.gz
-#
-# usage: dbmmanage <DBMfile> <command> <key> <value>
-
-package dbmmanage;
-# -ldb -lndbm -lgdbm
-BEGIN { @AnyDBM_File::ISA = qw(DB_File NDBM_File GDBM_File) }
-use strict;
-use Fcntl;
-use AnyDBM_File ();
-
-my($file,$command,$key,$crypted_pwd) = @ARGV;
-
-usage() unless $file and $command and defined &{$dbmc::{$command}};
-
-# if your osname is in $newstyle_salt, then use new style salt (starts with '_' and contains
-# four bytes of iteration count and four bytes of salt). Otherwise, just use
-# the traditional two-byte salt.
-# see the man page on your system to decide if you have a newer crypt() lib.
-# I believe that 4.4BSD derived systems do (at least BSD/OS 2.0 does).
-# The new style crypt() allows up to 20 characters of the password to be
-# significant rather than only 8.
-my $newstyle_salt = join '|', qw{bsdos}; #others?
-
-# remove extension if any
-my $chop = join '|', qw{db.? pag dir};
-$file =~ s/\.($chop)$//;
-
-my $is_update = $command eq "update";
-my $Is_Win32 = $^O eq "MSWin32";
-my %DB = ();
-my @range = ();
-my($mode, $flags) = $command =~
- /^(?:view|check)$/ ? (0644, O_RDONLY) : (0644, O_RDWR|O_CREAT);
-
-tie %DB, "AnyDBM_File", $file, $flags, $mode || die "Can't tie $file: $!";
-dbmc->$command();
-untie %DB;
-
-sub usage {
- my $cmds = join "|", sort keys %dbmc::;
- die "usage: $0 filename [$cmds] [username]\n";
-}
-
-my $x;
-sub genseed {
- my $psf;
- for (qw(-xlwwa -le)) {
- `ps $_ 2>/dev/null`;
- $psf = $_, last unless $?;
- }
- srand (time ^ $$ ^ unpack("%L*", `ps $psf | gzip -f`));
- @range = (qw(. /), '0'..'9','a'..'z','A'..'Z');
- $x = int scalar @range;
-}
-
-sub randchar {
- join '', map $range[rand $x], 1..shift||1;
-}
-
-sub salt {
- my $newstyle = $^O =~ /(?:$newstyle_salt)/;
- genseed() unless @range;
- return $newstyle ?
- join '', "_", randchar, "a..", randchar(4) :
- randchar(2);
-}
-
-sub getpass {
- my $prompt = shift || "Enter password:";
-
- unless($Is_Win32) {
- open STDIN, "/dev/tty" or warn "couldn't open /dev/tty $!\n";
- system "stty -echo;";
- }
-
- my($c,$pwd);
- print STDERR $prompt;
- while (($c = getc(STDIN)) ne '' and $c ne "\n" and $c ne "\r") {
- $pwd .= $c;
- }
-
- system "stty echo" unless $Is_Win32;
- print STDERR "\n";
- die "Can't use empty password!\n" unless length $pwd;
- return $pwd;
-}
-
-sub dbmc::update {
- die "Sorry, user `$key' doesn't exist!\n" unless $DB{$key};
- dbmc->adduser;
-}
-
-sub dbmc::add {
- die "Can't use empty password!\n" unless $crypted_pwd;
- unless($is_update) {
- die "Sorry, user `$key' already exists!\n" if $DB{$key};
- }
- $DB{$key} = $crypted_pwd;
- my $action = $is_update ? "updated" : "added";
- print "User $key $action with password encrypted to $DB{$key}\n";
-}
-
-sub dbmc::adduser {
- my $value = getpass "New password:";
- die "They don't match, sorry.\n" unless getpass("Re-type new password:") eq $value;
- $crypted_pwd = crypt $value, caller->salt;
- dbmc->add;
-}
-
-sub dbmc::delete {
- die "Sorry, user `$key' doesn't exist!\n" unless $DB{$key};
- delete $DB{$key}, print "`$key' deleted\n";
-}
-
-sub dbmc::view {
- print $key ? "$key:$DB{$key}\n" : map { "$_:$DB{$_}\n" if $DB{$_} } keys %DB;
-}
-
-sub dbmc::check {
- die "Sorry, user `$key' doesn't exist!\n" unless $DB{$key};
- print crypt(getpass(), $DB{$key}) eq $DB{$key} ? "password ok\n" : "password mismatch\n";
-}
-
-sub dbmc::import {
- while(defined($_ = <STDIN>) and chomp) {
- ($key,$crypted_pwd) = split /:/, $_, 2;
- dbmc->add;
- }
-}
-
diff --git a/support/htdigest.c b/support/htdigest.c
deleted file mode 100644
index 22d0f4435f..0000000000
--- a/support/htdigest.c
+++ /dev/null
@@ -1,275 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-/******************************************************************************
- ******************************************************************************
- * NOTE! This program is not safe as a setuid executable! Do not make it
- * setuid!
- ******************************************************************************
- *****************************************************************************/
-/*
- * htdigest.c: simple program for manipulating digest passwd file for Apache
- *
- * by Alexei Kosut, based on htpasswd.c, by Rob McCool
- */
-
-#include "apr_lib.h"
-#include "ap_config.h"
-#include <sys/types.h>
-#include "ap.h"
-#include "ap_md5.h"
-#if defined(MPE) || defined(QNX) || defined(WIN32) || defined(__TANDEM) || defined(BEOS)
-#include <signal.h>
-#else
-#include <sys/signal.h>
-#endif
-
-#ifdef WIN32
-#include <conio.h>
-#define unlink _unlink
-#endif
-
-#ifdef CHARSET_EBCDIC
-#define LF '\n'
-#define CR '\r'
-#else
-#define LF 10
-#define CR 13
-#endif /* CHARSET_EBCDIC */
-
-#define MAX_STRING_LEN 256
-
-char *tn;
-
-static void getword(char *word, char *line, char stop)
-{
- int x = 0, y;
-
- for (x = 0; ((line[x]) && (line[x] != stop)); x++)
- word[x] = line[x];
-
- word[x] = '\0';
- if (line[x])
- ++x;
- y = 0;
-
- while ((line[y++] = line[x++]));
-}
-
-static int getline(char *s, int n, FILE *f)
-{
- register int i = 0;
-
- while (1) {
- s[i] = (char) fgetc(f);
-
- if (s[i] == CR)
- s[i] = fgetc(f);
-
- if ((s[i] == 0x4) || (s[i] == LF) || (i == (n - 1))) {
- s[i] = '\0';
- return (feof(f) ? 1 : 0);
- }
- ++i;
- }
-}
-
-static void putline(FILE *f, char *l)
-{
- int x;
-
- for (x = 0; l[x]; x++)
- fputc(l[x], f);
- fputc('\n', f);
-}
-
-
-static void add_password(char *user, char *realm, FILE *f)
-{
- char *pw;
- AP_MD5_CTX context;
- unsigned char digest[16];
- char string[MAX_STRING_LEN];
- char pwin[MAX_STRING_LEN];
- char pwv[MAX_STRING_LEN];
- unsigned int i;
- size_t bufsize;
-
- bufsize = sizeof(pwin);
- if (ap_getpass("New password: ", pwin, &bufsize) != 0) {
- fprintf(stderr, "password too long");
- exit(5);
- }
- bufsize = sizeof(pwv);
- ap_getpass("Re-type new password: ", pwv, &bufsize);
- if (strcmp(pwin, pwv) != 0) {
- fprintf(stderr, "They don't match, sorry.\n");
- if (tn) {
- unlink(tn);
- }
- exit(1);
- }
- pw = pwin;
- fprintf(f, "%s:%s:", user, realm);
-
- /* Do MD5 stuff */
- sprintf(string, "%s:%s:%s", user, realm, pw);
-
- ap_MD5Init(&context);
- ap_MD5Update(&context, (unsigned char *) string, strlen(string));
- ap_MD5Final(digest, &context);
-
- for (i = 0; i < 16; i++)
- fprintf(f, "%02x", digest[i]);
-
- fprintf(f, "\n");
-}
-
-static void usage(void)
-{
- fprintf(stderr, "Usage: htdigest [-c] passwordfile realm username\n");
- fprintf(stderr, "The -c flag creates a new file.\n");
- exit(1);
-}
-
-static void interrupted(void)
-{
- fprintf(stderr, "Interrupted.\n");
- if (tn)
- unlink(tn);
- exit(1);
-}
-
-int main(int argc, char *argv[])
-{
- FILE *tfp, *f;
- char user[MAX_STRING_LEN];
- char realm[MAX_STRING_LEN];
- char line[MAX_STRING_LEN];
- char l[MAX_STRING_LEN];
- char w[MAX_STRING_LEN];
- char x[MAX_STRING_LEN];
- char command[MAX_STRING_LEN];
- int found;
-
- tn = NULL;
- signal(SIGINT, (void (*)(int)) interrupted);
- if (argc == 5) {
- if (strcmp(argv[1], "-c"))
- usage();
- if (!(tfp = fopen(argv[2], "w"))) {
- fprintf(stderr, "Could not open passwd file %s for writing.\n",
- argv[2]);
- perror("fopen");
- exit(1);
- }
- printf("Adding password for %s in realm %s.\n", argv[4], argv[3]);
- add_password(argv[4], argv[3], tfp);
- fclose(tfp);
- exit(0);
- }
- else if (argc != 4)
- usage();
-
- tn = tmpnam(NULL);
- if (!(tfp = fopen(tn, "w"))) {
- fprintf(stderr, "Could not open temp file.\n");
- exit(1);
- }
-
- if (!(f = fopen(argv[1], "r"))) {
- fprintf(stderr,
- "Could not open passwd file %s for reading.\n", argv[1]);
- fprintf(stderr, "Use -c option to create new one.\n");
- exit(1);
- }
- strcpy(user, argv[3]);
- strcpy(realm, argv[2]);
-
- found = 0;
- while (!(getline(line, MAX_STRING_LEN, f))) {
- if (found || (line[0] == '#') || (!line[0])) {
- putline(tfp, line);
- continue;
- }
- strcpy(l, line);
- getword(w, l, ':');
- getword(x, l, ':');
- if (strcmp(user, w) || strcmp(realm, x)) {
- putline(tfp, line);
- continue;
- }
- else {
- printf("Changing password for user %s in realm %s\n", user, realm);
- add_password(user, realm, tfp);
- found = 1;
- }
- }
- if (!found) {
- printf("Adding user %s in realm %s\n", user, realm);
- add_password(user, realm, tfp);
- }
- fclose(f);
- fclose(tfp);
-#if defined(OS2) || defined(WIN32)
- sprintf(command, "copy \"%s\" \"%s\"", tn, argv[1]);
-#else
- sprintf(command, "cp %s %s", tn, argv[1]);
-#endif
- system(command);
- unlink(tn);
- return 0;
-}
diff --git a/support/htdigest.dsp b/support/htdigest.dsp
deleted file mode 100644
index f00f87e7e7..0000000000
--- a/support/htdigest.dsp
+++ /dev/null
@@ -1,103 +0,0 @@
-# Microsoft Developer Studio Project File - Name="htdigest" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=htdigest - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "htdigest.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "htdigest.mak" CFG="htdigest - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "htdigest - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "htdigest - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "htdigest - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "htdigest"
-# PROP BASE Intermediate_Dir "htdigest"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir ""
-# PROP Intermediate_Dir ""
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"release/htdigest.exe"
-# SUBTRACT LINK32 /pdb:none
-
-!ELSEIF "$(CFG)" == "htdigest - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "htdiges0"
-# PROP BASE Intermediate_Dir "htdiges0"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ""
-# PROP Intermediate_Dir ""
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"debug/htdigest.exe" /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "htdigest - Win32 Release"
-# Name "htdigest - Win32 Debug"
-# Begin Source File
-
-SOURCE=..\ap\ap_cpystrn.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\ap\ap_getpass.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\ap\ap_md5c.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\htdigest.c
-# End Source File
-# End Target
-# End Project
diff --git a/support/htpasswd.c b/support/htpasswd.c
deleted file mode 100644
index 295520f122..0000000000
--- a/support/htpasswd.c
+++ /dev/null
@@ -1,592 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/******************************************************************************
- ******************************************************************************
- * NOTE! This program is not safe as a setuid executable! Do not make it
- * setuid!
- ******************************************************************************
- *****************************************************************************/
-/*
- * htpasswd.c: simple program for manipulating password file for
- * the Apache HTTP server
- *
- * Originally by Rob McCool
- *
- * Exit values:
- * 0: Success
- * 1: Failure; file access/permission problem
- * 2: Failure; command line syntax problem (usage message issued)
- * 3: Failure; password verification failure
- * 4: Failure; operation interrupted (such as with CTRL/C)
- * 5: Failure; buffer would overflow (username, filename, or computed
- * record too long)
- * 6: Failure; username contains illegal or reserved characters
- */
-
-#include "apr_lib.h"
-#include "ap_config.h"
-#include <sys/types.h>
-#include <signal.h>
-#include <errno.h>
-#include "ap.h"
-#include "ap_md5.h"
-#include "ap_sha1.h"
-
-#ifdef WIN32
-#include <conio.h>
-#include "../os/win32/getopt.h"
-#define unlink _unlink
-#endif
-
-#ifndef CHARSET_EBCDIC
-#define LF 10
-#define CR 13
-#else /*CHARSET_EBCDIC*/
-#define LF '\n'
-#define CR '\r'
-#endif /*CHARSET_EBCDIC*/
-
-#define MAX_STRING_LEN 256
-#define ALG_PLAIN 0
-#define ALG_CRYPT 1
-#define ALG_APMD5 2
-#define ALG_APSHA 3
-
-#define ERR_FILEPERM 1
-#define ERR_SYNTAX 2
-#define ERR_PWMISMATCH 3
-#define ERR_INTERRUPTED 4
-#define ERR_OVERFLOW 5
-#define ERR_BADUSER 6
-
-/*
- * This needs to be declared statically so the signal handler can
- * access it.
- */
-static char *tempfilename;
-
-/*
- * Get a line of input from the user, not including any terminating
- * newline.
- */
-static int getline(char *s, int n, FILE *f)
-{
- register int i = 0;
-
- while (1) {
- s[i] = (char) fgetc(f);
-
- if (s[i] == CR) {
- s[i] = fgetc(f);
- }
-
- if ((s[i] == 0x4) || (s[i] == LF) || (i == (n - 1))) {
- s[i] = '\0';
- return (feof(f) ? 1 : 0);
- }
- ++i;
- }
-}
-
-static void putline(FILE *f, char *l)
-{
- int x;
-
- for (x = 0; l[x]; x++) {
- fputc(l[x], f);
- }
- fputc('\n', f);
-}
-
-static void to64(char *s, unsigned long v, int n)
-{
- static unsigned char itoa64[] = /* 0 ... 63 => ASCII - 64 */
- "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
-
- while (--n >= 0) {
- *s++ = itoa64[v&0x3f];
- v >>= 6;
- }
-}
-
-/*
- * Make a password record from the given information. A zero return
- * indicates success; failure means that the output buffer contains an
- * error message instead.
- */
-static int mkrecord(char *user, char *record, size_t rlen, char *passwd,
- int alg)
-{
- char *pw;
- char cpw[120];
- char pwin[MAX_STRING_LEN];
- char pwv[MAX_STRING_LEN];
- char salt[9];
- size_t bufsize;
-
- if (passwd != NULL) {
- pw = passwd;
- }
- else {
- bufsize = sizeof(pwin);
- if (ap_getpass("New password: ", pwin, &bufsize) != 0) {
- ap_snprintf(record, (rlen - 1), "password too long (>%d)",
- sizeof(pwin) - 1);
- return ERR_OVERFLOW;
- }
- bufsize = sizeof(pwv);
- ap_getpass("Re-type new password: ", pwv, &bufsize);
- if (strcmp(pwin, pwv) != 0) {
- ap_cpystrn(record, "password verification error", (rlen - 1));
- return ERR_PWMISMATCH;
- }
- pw = pwin;
- memset(pwv, '\0', sizeof(pwin));
- }
- switch (alg) {
-
- case ALG_APSHA:
- /* XXX cpw >= 28 + strlen(sha1) chars - fixed len SHA */
- ap_sha1_base64(pw,strlen(pw),cpw);
- break;
-
- case ALG_APMD5:
- (void) srand((int) time((time_t *) NULL));
- to64(&salt[0], rand(), 8);
- salt[8] = '\0';
-
- ap_MD5Encode((const unsigned char *)pw, (const unsigned char *)salt,
- cpw, sizeof(cpw));
- break;
-
- case ALG_PLAIN:
- /* XXX this len limitation is not in sync with any HTTPd len. */
- ap_cpystrn(cpw,pw,sizeof(cpw));
- break;
-
- case ALG_CRYPT:
- default:
- (void) srand((int) time((time_t *) NULL));
- to64(&salt[0], rand(), 8);
- salt[8] = '\0';
-
- ap_cpystrn(cpw, (char *)crypt(pw, salt), sizeof(cpw) - 1);
- break;
- }
- memset(pw, '\0', strlen(pw));
-
- /*
- * Check to see if the buffer is large enough to hold the username,
- * hash, and delimiters.
- */
- if ((strlen(user) + 1 + strlen(cpw)) > (rlen - 1)) {
- ap_cpystrn(record, "resultant record too long", (rlen - 1));
- return ERR_OVERFLOW;
- }
- strcpy(record, user);
- strcat(record, ":");
- strcat(record, cpw);
- return 0;
-}
-
-static int usage(void)
-{
- fprintf(stderr, "Usage:\n");
- fprintf(stderr, "\thtpasswd [-cmdps] passwordfile username\n");
- fprintf(stderr, "\thtpasswd -b[cmdps] passwordfile username password\n\n");
- fprintf(stderr, " -c Create a new file.\n");
- fprintf(stderr, " -m Force MD5 encryption of the password"
-#if defined(WIN32) || defined(TPF)
- " (default)"
-#endif
- ".\n");
- fprintf(stderr, " -d Force CRYPT encryption of the password"
-#if (!(defined(WIN32) || defined(TPF)))
- " (default)"
-#endif
- ".\n");
- fprintf(stderr, " -p Do not encrypt the password (plaintext).\n");
- fprintf(stderr, " -s Force SHA encryption of the password.\n");
- fprintf(stderr, " -b Use the password from the command line rather "
- "than prompting for it.\n");
- fprintf(stderr,
- "On Windows and TPF systems the '-m' flag is used by default.\n");
- fprintf(stderr,
- "On all other systems, the '-p' flag will probably not work.\n");
- return ERR_SYNTAX;
-}
-
-static void interrupted(void)
-{
- fprintf(stderr, "Interrupted.\n");
- if (tempfilename != NULL) {
- unlink(tempfilename);
- }
- exit(ERR_INTERRUPTED);
-}
-
-/*
- * Check to see if the specified file can be opened for the given
- * access.
- */
-static int accessible(char *fname, char *mode)
-{
- FILE *s;
-
- s = fopen(fname, mode);
- if (s == NULL) {
- return 0;
- }
- fclose(s);
- return 1;
-}
-
-/*
- * Return true if a file is readable.
- */
-static int readable(char *fname)
-{
- return accessible(fname, "r");
-}
-
-/*
- * Return true if the specified file can be opened for write access.
- */
-static int writable(char *fname)
-{
- return accessible(fname, "a");
-}
-
-/*
- * Return true if the named file exists, regardless of permissions.
- */
-static int exists(char *fname)
-{
-#ifdef WIN32
- struct _stat sbuf;
-#else
- struct stat sbuf;
-#endif
- int check;
-
-#ifdef WIN32
- check = _stat(fname, &sbuf);
-#else
- check = stat(fname, &sbuf);
-#endif
- return ((check == -1) && (errno == ENOENT)) ? 0 : 1;
-}
-
-/*
- * Copy from the current position of one file to the current position
- * of another.
- */
-static void copy_file(FILE *target, FILE *source)
-{
- static char line[MAX_STRING_LEN];
-
- while (fgets(line, sizeof(line), source) != NULL) {
- fputs(line, target);
- }
-}
-
-/*
- * Let's do it. We end up doing a lot of file opening and closing,
- * but what do we care? This application isn't run constantly.
- */
-int main(int argc, char *argv[])
-{
- FILE *ftemp = NULL;
- FILE *fpw = NULL;
- char user[MAX_STRING_LEN];
- char password[MAX_STRING_LEN];
- char record[MAX_STRING_LEN];
- char line[MAX_STRING_LEN];
- char pwfilename[MAX_STRING_LEN];
- char *arg;
- int found = 0;
- int alg = ALG_CRYPT;
- int newfile = 0;
- int noninteractive = 0;
- int i;
- int args_left = 2;
-
- tempfilename = NULL;
- signal(SIGINT, (void (*)(int)) interrupted);
-
- /*
- * Preliminary check to make sure they provided at least
- * three arguments, we'll do better argument checking as
- * we parse the command line.
- */
- if (argc < 3) {
- return usage();
- }
-
- /*
- * Go through the argument list and pick out any options. They
- * have to precede any other arguments.
- */
- for (i = 1; i < argc; i++) {
- arg = argv[i];
- if (*arg != '-') {
- break;
- }
- while (*++arg != '\0') {
- if (*arg == 'c') {
- newfile++;
- }
- else if (*arg == 'm') {
- alg = ALG_APMD5;
- }
- else if (*arg == 's') {
- alg = ALG_APSHA;
- }
- else if (*arg == 'p') {
- alg = ALG_PLAIN;
- }
- else if (*arg == 'd') {
- alg = ALG_CRYPT;
- }
- else if (*arg == 'b') {
- noninteractive++;
- args_left++;
- }
- else {
- return usage();
- }
- }
- }
-
- /*
- * Make sure we still have exactly the right number of arguments left
- * (the filename, the username, and possibly the password if -b was
- * specified).
- */
- if ((argc - i) != args_left) {
- return usage();
- }
- if (strlen(argv[i]) > (sizeof(pwfilename) - 1)) {
- fprintf(stderr, "%s: filename too long\n", argv[0]);
- return ERR_OVERFLOW;
- }
- strcpy(pwfilename, argv[i]);
- if (strlen(argv[i + 1]) > (sizeof(user) - 1)) {
- fprintf(stderr, "%s: username too long (>%d)\n", argv[0],
- sizeof(user) - 1);
- return ERR_OVERFLOW;
- }
- strcpy(user, argv[i + 1]);
- if ((arg = strchr(user, ':')) != NULL) {
- fprintf(stderr, "%s: username contains illegal character '%c'\n",
- argv[0], *arg);
- return ERR_BADUSER;
- }
- if (noninteractive) {
- if (strlen(argv[i + 2]) > (sizeof(password) - 1)) {
- fprintf(stderr, "%s: password too long (>%d)\n", argv[0],
- sizeof(password) - 1);
- return ERR_OVERFLOW;
- }
- strcpy(password, argv[i + 2]);
- }
-
-#ifdef WIN32
- if (alg == ALG_CRYPT) {
- alg = ALG_APMD5;
- fprintf(stderr, "Automatically using MD5 format on Windows.\n");
- }
-#endif
-
-#if (!(defined(WIN32) || defined(TPF)))
- if (alg == ALG_PLAIN) {
- fprintf(stderr,"Warning: storing passwords as plain text might "
- "just not work on this platform.\n");
- }
-#endif
- /*
- * Verify that the file exists if -c was omitted. We give a special
- * message if it doesn't.
- */
- if ((! newfile) && (! exists(pwfilename))) {
- fprintf(stderr, "%s: cannot modify file %s; use '-c' to create it\n",
- argv[0], pwfilename);
- perror("fopen");
- exit(ERR_FILEPERM);
- }
- /*
- * Verify that we can read the existing file in the case of an update
- * to it (rather than creation of a new one).
- */
- if ((! newfile) && (! readable(pwfilename))) {
- fprintf(stderr, "%s: cannot open file %s for read access\n",
- argv[0], pwfilename);
- perror("fopen");
- exit(ERR_FILEPERM);
- }
- /*
- * Now check to see if we can preserve an existing file in case
- * of password verification errors on a -c operation.
- */
- if (newfile && exists(pwfilename) && (! readable(pwfilename))) {
- fprintf(stderr, "%s: cannot open file %s for read access\n"
- "%s: existing auth data would be lost on password mismatch",
- argv[0], pwfilename, argv[0]);
- perror("fopen");
- exit(ERR_FILEPERM);
- }
- /*
- * Now verify that the file is writable!
- */
- if (! writable(pwfilename)) {
- fprintf(stderr, "%s: cannot open file %s for write access\n",
- argv[0], pwfilename);
- perror("fopen");
- exit(ERR_FILEPERM);
- }
-
- /*
- * All the file access checks have been made. Time to go to work;
- * try to create the record for the username in question. If that
- * fails, there's no need to waste any time on file manipulations.
- * Any error message text is returned in the record buffer, since
- * the mkrecord() routine doesn't have access to argv[].
- */
- i = mkrecord(user, record, sizeof(record) - 1,
- noninteractive ? password : NULL,
- alg);
- if (i != 0) {
- fprintf(stderr, "%s: %s\n", argv[0], record);
- exit(i);
- }
-
- /*
- * We can access the files the right way, and we have a record
- * to add or update. Let's do it..
- */
- tempfilename = tmpnam(NULL);
- ftemp = fopen(tempfilename, "w+");
- if (ftemp == NULL) {
- fprintf(stderr, "%s: unable to create temporary file\n", argv[0]);
- perror("fopen");
- exit(ERR_FILEPERM);
- }
- /*
- * If we're not creating a new file, copy records from the existing
- * one to the temporary file until we find the specified user.
- */
- if (! newfile) {
- char scratch[MAX_STRING_LEN];
-
- fpw = fopen(pwfilename, "r");
- while (! (getline(line, sizeof(line), fpw))) {
- char *colon;
-
- if ((line[0] == '#') || (line[0] == '\0')) {
- putline(ftemp, line);
- continue;
- }
- strcpy(scratch, line);
- /*
- * See if this is our user.
- */
- colon = strchr(scratch, ':');
- if (colon != NULL) {
- *colon = '\0';
- }
- if (strcmp(user, scratch) != 0) {
- putline(ftemp, line);
- continue;
- }
- found++;
- break;
- }
- }
- if (found) {
- fprintf(stderr, "Updating ");
- }
- else {
- fprintf(stderr, "Adding ");
- }
- fprintf(stderr, "password for user %s\n", user);
- /*
- * Now add the user record we created.
- */
- putline(ftemp, record);
- /*
- * If we're updating an existing file, there may be additional
- * records beyond the one we're updating, so copy them.
- */
- if (! newfile) {
- copy_file(ftemp, fpw);
- fclose(fpw);
- }
- /*
- * The temporary file now contains the information that should be
- * in the actual password file. Close the open files, re-open them
- * in the appropriate mode, and copy them file to the real one.
- */
- fclose(ftemp);
- fpw = fopen(pwfilename, "w+");
- ftemp = fopen(tempfilename, "r");
- copy_file(fpw, ftemp);
- fclose(fpw);
- fclose(ftemp);
- unlink(tempfilename);
- return 0;
-}
diff --git a/support/htpasswd.dsp b/support/htpasswd.dsp
deleted file mode 100644
index 7949d7f7e8..0000000000
--- a/support/htpasswd.dsp
+++ /dev/null
@@ -1,119 +0,0 @@
-# Microsoft Developer Studio Project File - Name="htpasswd" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=htpasswd - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "htpasswd.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "htpasswd.mak" CFG="htpasswd - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "htpasswd - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "htpasswd - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "htpasswd - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "..\include" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "WIN32_LEAN_AND_MEAN" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ws2_32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "htpasswd - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\include" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "WIN32_LEAN_AND_MEAN" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# SUBTRACT LINK32 /pdb:none
-
-!ENDIF
-
-# Begin Target
-
-# Name "htpasswd - Win32 Release"
-# Name "htpasswd - Win32 Debug"
-# Begin Source File
-
-SOURCE=..\ap\ap_cpystrn.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\ap\ap_getpass.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\ap\ap_md5c.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\ap\ap_snprintf.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\ap\ap_sha1.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\ap\ap_checkpass.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\ap\ap_base64.c
-# End Source File
-# Begin Source File
-
-SOURCE=.\htpasswd.c
-# End Source File
-# End Target
-# End Project
diff --git a/support/httpd.exp b/support/httpd.exp
deleted file mode 100644
index b6976c210d..0000000000
--- a/support/httpd.exp
+++ /dev/null
@@ -1,411 +0,0 @@
-#! .
-ap_MD5Encode
-ap_MD5Final
-ap_MD5Init
-ap_MD5Update
-ap_SHA1Final
-ap_SHA1Init
-ap_SHA1Update_binary
-ap_SHA1Update
-ap_acquire_mutex
-ap_add_cgi_vars
-ap_add_common_vars
-ap_add_module
-ap_add_named_module
-ap_add_per_dir_conf
-ap_add_per_url_conf
-ap_add_version_component
-ap_allow_options
-ap_allow_overrides
-ap_append_arrays
-ap_array_cat
-ap_array_pstrcat
-ap_auth_name
-ap_auth_type
-ap_base64encode
-ap_base64encode_binary
-ap_base64encode_len
-ap_base64decode
-ap_base64decode_binary
-ap_base64decode_len
-ap_basic_http_header
-ap_bclose
-ap_bcreate
-ap_bfilbuf
-ap_bfileno
-ap_bflsbuf
-ap_bflush
-ap_bgetopt
-ap_bgets
-ap_bhalfduplex
-ap_bind_address
-ap_block_alarms
-ap_blookc
-ap_bnonblock
-ap_bonerror
-ap_bprintf
-ap_bpushfd
-ap_bputs
-ap_bread
-ap_bsetflag
-ap_bsetopt
-ap_bskiplf
-ap_bspawn_child
-ap_bvputs
-ap_bwrite
-ap_bytes_in_free_blocks
-ap_bytes_in_pool
-ap_call_exec
-ap_can_exec
-ap_cfg_closefile
-ap_cfg_getc
-ap_cfg_getline
-ap_chdir_file
-ap_check_access
-ap_check_auth
-ap_check_cmd_context
-ap_check_user_id
-ap_checkmask
-ap_child_exit_modules
-ap_child_init_modules
-ap_child_terminate
-ap_cleanup_for_exec
-ap_clear_module_list
-ap_clear_pool
-ap_clear_table
-ap_close_piped_log
-ap_construct_server
-ap_construct_url
-ap_content_type_tolower
-ap_copy_array
-ap_copy_array_hdr
-ap_copy_table
-ap_core_reorder_directories
-ap_coredump_dir
-ap_count_dirs
-ap_cpystrn
-ap_create_environment
-ap_create_mutex
-ap_create_per_dir_config
-ap_create_request_config
-ap_daemons_limit
-ap_daemons_max_free
-ap_daemons_min_free
-ap_daemons_to_start
-ap_day_snames
-ap_default_port_for_request
-ap_default_port_for_scheme
-ap_default_type
-ap_destroy_pool
-ap_destroy_sub_req
-ap_die
-ap_discard_request_body
-ap_document_root
-ap_each_byterange
-ap_error_log2stderr
-ap_escape_html
-ap_escape_path_segment
-ap_escape_quotes
-ap_escape_shell_cmd
-ap_excess_requests_per_child
-ap_exists_config_define
-ap_exists_scoreboard_image
-ap_extended_status
-ap_field_noparam
-ap_finalize_request_protocol
-ap_finalize_sub_req_protocol
-ap_find_command
-ap_find_command_in_modules
-ap_find_last_token
-ap_find_linked_module
-ap_find_list_item
-ap_find_module_name
-ap_find_path_info
-ap_find_token
-ap_find_types
-ap_fini_vhost_config
-ap_fnmatch
-ap_force_library_loading
-ap_get_basic_auth_pw
-ap_get_client_block
-ap_get_gmtoff
-ap_get_list_item
-ap_get_local_host
-ap_get_remote_host
-ap_get_remote_logname
-ap_get_server_built
-ap_get_server_name
-ap_get_server_port
-ap_get_server_version
-ap_get_time
-ap_get_token
-ap_get_virthost_addr
-ap_getparents
-ap_getword
-ap_getword_conf
-ap_getword_conf_nc
-ap_getword_nc
-ap_getword_nulls
-ap_getword_nulls_nc
-ap_getword_white
-ap_getword_white_nc
-ap_gm_timestr_822
-ap_gname2id
-ap_group_id
-ap_handle_command
-ap_header_parse
-ap_ht_time
-ap_ind
-ap_index_of_response
-ap_init_alloc
-ap_init_modules
-ap_init_vhost_config
-ap_init_virtual_host
-ap_internal_redirect
-ap_internal_redirect_handler
-ap_invoke_handler
-ap_is_directory
-ap_is_fnmatch
-ap_is_initial_req
-ap_is_matchexp
-ap_is_url
-ap_keepalive_timeout
-ap_kill_cleanup
-ap_kill_cleanups_for_fd
-ap_kill_cleanups_for_socket
-ap_limit_section
-ap_listenbacklog
-ap_listeners
-ap_lock_fname
-ap_log_assert
-ap_log_error
-ap_log_error_old
-ap_log_pid
-ap_log_printf
-ap_log_reason
-ap_log_rerror
-ap_log_transaction
-ap_log_unixerr
-ap_make_array
-ap_make_dirstr
-ap_make_dirstr_parent
-ap_make_dirstr_prefix
-ap_make_etag
-ap_make_full_path
-ap_make_sub_pool
-ap_make_table
-ap_matches_request_vhost
-ap_max_requests_per_child
-ap_md5
-ap_md5contextTo64
-ap_md5digest
-ap_meets_conditions
-ap_merge_per_dir_configs
-ap_method_number_of
-ap_month_snames
-ap_my_generation
-ap_no2slash
-ap_note_auth_failure
-ap_note_basic_auth_failure
-ap_note_cleanups_for_fd
-ap_note_cleanups_for_file
-ap_note_cleanups_for_socket
-ap_note_digest_auth_failure
-ap_note_subprocess
-ap_null_cleanup
-ap_open_logs
-ap_open_piped_log
-ap_os_escape_path
-ap_os_is_path_absolute
-ap_overlay_tables
-ap_overlap_tables
-ap_palloc
-ap_parseHTTPdate
-ap_parse_hostinfo_components
-ap_parse_htaccess
-ap_parse_uri
-ap_parse_uri_components
-ap_parse_vhost_addrs
-ap_pbase64decode
-ap_pbase64encode
-ap_pcalloc
-ap_pcfg_open_custom
-ap_pcfg_openfile
-ap_pclosedir
-ap_pclosef
-ap_pclosesocket
-ap_pduphostent
-ap_pfclose
-ap_pfdopen
-ap_pfopen
-ap_pgethostbyname
-ap_pid_fname
-ap_popendir
-ap_popenf
-ap_pregcomp
-ap_pregfree
-ap_pregsub
-ap_prelinked_modules
-ap_preloaded_modules
-ap_process_request
-ap_process_resource_config
-ap_psignature
-ap_psocket
-ap_psprintf
-ap_pstrcat
-ap_pstrdup
-ap_pstrndup
-ap_push_array
-ap_pvsprintf
-ap_rationalize_mtime
-ap_read_config
-ap_read_request
-ap_regerror
-ap_regexec
-ap_register_cleanup
-ap_register_other_child
-ap_release_mutex
-ap_remove_module
-ap_requires
-ap_response_code_string
-ap_restart_time
-ap_rfc1413
-ap_rfc1413_timeout
-ap_rflush
-ap_rind
-ap_rprintf
-ap_rputc
-ap_rputs
-ap_run_cleanup
-ap_run_fixups
-ap_run_post_read_request
-ap_run_sub_req
-ap_rvputs
-ap_rwrite
-ap_satisfies
-ap_scan_script_header_err
-ap_scan_script_header_err_buff
-ap_scoreboard_fname
-ap_scoreboard_image
-ap_send_error_response
-ap_send_fb
-ap_send_fb_length
-ap_send_fd
-ap_send_fd_length
-ap_send_header_field
-ap_send_http_header
-ap_send_http_options
-ap_send_http_trace
-ap_send_mmap
-ap_send_size
-ap_server_argv0
-ap_server_config_defines
-ap_server_confname
-ap_server_post_read_config
-ap_server_pre_read_config
-ap_server_root
-ap_server_root_relative
-ap_set_byterange
-ap_set_callback_and_alarm
-ap_set_content_length
-ap_set_etag
-ap_set_file_slot
-ap_set_flag_slot
-ap_set_keepalive
-ap_set_last_modified
-ap_set_name_virtual_host
-ap_set_string_slot
-ap_set_string_slot_lower
-ap_set_sub_req_protocol
-ap_setup_client_block
-ap_setup_prelinked_modules
-ap_sha1_base64
-ap_should_client_block
-ap_show_directives
-ap_show_modules
-ap_signal
-ap_single_module_configure
-ap_size_list_item
-ap_slack
-ap_snprintf
-ap_soft_timeout
-ap_some_auth_required
-ap_spawn_child
-ap_sync_scoreboard_image
-ap_srm_command_loop
-ap_standalone
-ap_start_restart
-ap_start_shutdown
-ap_str_tolower
-ap_strcasecmp_match
-ap_strcmp_match
-ap_sub_req_lookup_file
-ap_sub_req_lookup_uri
-ap_sub_req_method_uri
-ap_suexec_enabled
-ap_table_add
-ap_table_addn
-ap_table_do
-ap_table_get
-ap_table_merge
-ap_table_mergen
-ap_table_set
-ap_table_setn
-ap_table_unset
-ap_threads_per_child
-ap_tm2sec
-ap_translate_name
-ap_uname2id
-ap_unblock_alarms
-ap_unescape_url
-ap_unparse_uri_components
-ap_unregister_other_child
-ap_update_child_status
-ap_update_mtime
-ap_update_vhost_from_headers
-ap_update_vhost_given_ip
-ap_user_id
-ap_user_name
-ap_util_init
-ap_util_uri_init
-ap_uudecode
-ap_validate_password
-ap_vbprintf
-ap_vformatter
-ap_vsnprintf
-core_module
-top_module
-XML_DefaultCurrent
-XML_ErrorString
-XML_ExternalEntityParserCreate
-XML_GetBase
-XML_GetBuffer
-XML_GetCurrentByteCount
-XML_GetCurrentByteIndex
-XML_GetCurrentColumnNumber
-XML_GetCurrentLineNumber
-XML_GetErrorCode
-XML_GetSpecifiedAttributeCount
-XML_Parse
-XML_ParseBuffer
-XML_ParserCreate
-XML_ParserCreateNS
-XML_ParserFree
-XML_SetBase
-XML_SetCdataSectionHandler
-XML_SetCharacterDataHandler
-XML_SetCommentHandler
-XML_SetDefaultHandler
-XML_SetDefaultHandlerExpand
-XML_SetElementHandler
-XML_SetEncoding
-XML_SetExternalEntityRefHandler
-XML_SetExternalEntityRefHandlerArg
-XML_SetNamespaceDeclHandler
-XML_SetNotStandaloneHandler
-XML_SetNotationDeclHandler
-XML_SetProcessingInstructionHandler
-XML_SetUnknownEncodingHandler
-XML_SetUnparsedEntityDeclHandler
-XML_SetUserData
-XML_UseParserAsHandlerArg
diff --git a/support/log_server_status b/support/log_server_status
deleted file mode 100644
index 1eb2893edc..0000000000
--- a/support/log_server_status
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/local/bin/perl
-
-# ====================================================================
-# Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
-# "This product includes software developed by the Apache Group
-# for use in the Apache HTTP server project (http://www.apache.org/)."
-#
-# 4. The names "Apache Server" and "Apache Group" must not be used to
-# endorse or promote products derived from this software without
-# prior written permission. For written permission, please contact
-# apache@apache.org.
-#
-# 5. Products derived from this software may not be called "Apache"
-# nor may "Apache" appear in their names without prior written
-# permission of the Apache Group.
-#
-# 6. Redistributions of any form whatsoever must retain the following
-# acknowledgment:
-# "This product includes software developed by the Apache Group
-# for use in the Apache HTTP server project (http://www.apache.org/)."
-#
-# THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-# EXPRESSED 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 APACHE GROUP OR
-# ITS 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.
-# ====================================================================
-#
-# This software consists of voluntary contributions made by many
-# individuals on behalf of the Apache Group and was originally based
-# on public domain software written at the National Center for
-# Supercomputing Applications, University of Illinois, Urbana-Champaign.
-# For more information on the Apache Group and the Apache HTTP server
-# project, please see <http://www.apache.org/>.
-
-
-# Log Server Status
-# Mark J Cox, UK Web Ltd 1996, mark@ukweb.com
-#
-# This script is designed to be run at a frequent interval by something
-# like cron. It connects to the server and downloads the status
-# information. It reformats the information to a single line and logs
-# it to a file. Make sure the directory $wherelog is writable by the
-# user who runs this script.
-#
-require 'sys/socket.ph';
-
-$wherelog = "/var/log/graph/"; # Logs will be like "/var/log/graph/19960312"
-$server = "localhost"; # Name of server, could be "www.foo.com"
-$port = "80"; # Port on server
-$request = "/status/?auto"; # Request to send
-
-sub tcp_connect
-{
- local($host,$port) =@_;
- $sockaddr='S n a4 x8';
- chop($hostname=`hostname`);
- $port=(getservbyname($port, 'tcp'))[2] unless $port =~ /^\d+$/;
- $me=pack($sockaddr,&AF_INET,0,(gethostbyname($hostname))[4]);
- $them=pack($sockaddr,&AF_INET,$port,(gethostbyname($host))[4]);
- socket(S,&PF_INET,&SOCK_STREAM,(getprotobyname('tcp'))[2]) ||
- die "socket: $!";
- bind(S,$me) || return "bind: $!";
- connect(S,$them) || return "connect: $!";
- select(S);
- $| = 1;
- select(stdout);
- return "";
-}
-
-### Main
-
-{
- $year=`date +%y`;
- chomp($year);
- $year += ($year < 70) ? 2000 : 1900;
- $date = $year . `date +%m%d:%H%M%S`;
- chomp($date);
- ($day,$time)=split(/:/,$date);
- $res=&tcp_connect($server,$port);
- open(OUT,">>$wherelog$day");
- if ($res) {
- print OUT "$time:-1:-1:-1:-1:$res\n";
- exit 1;
- }
- print S "GET $request\n";
- while (<S>) {
- $requests=$1 if ( m|^BusyServers:\ (\S+)|);
- $idle=$1 if ( m|^IdleServers:\ (\S+)|);
- $number=$1 if ( m|sses:\ (\S+)|);
- $cpu=$1 if (m|^CPULoad:\ (\S+)|);
- }
- print OUT "$time:$requests:$idle:$number:$cpu\n";
-}
-
-
diff --git a/support/logresolve.c b/support/logresolve.c
deleted file mode 100644
index c95fa7d6d2..0000000000
--- a/support/logresolve.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * logresolve 1.1
- *
- * Tom Rathborne - tomr@uunet.ca - http://www.uunet.ca/~tomr/
- * UUNET Canada, April 16, 1995
- *
- * Rewritten by David Robinson. (drtr@ast.cam.ac.uk)
- *
- * Usage: logresolve [-s filename] [-c] < access_log > new_log
- *
- * Arguments:
- * -s filename name of a file to record statistics
- * -c check the DNS for a matching A record for the host.
- *
- * Notes:
- *
- * To generate meaningful statistics from an HTTPD log file, it's good
- * to have the domain name of each machine that accessed your site, but
- * doing this on the fly can slow HTTPD down.
- *
- * Compiling NCSA HTTPD with the -DMINIMAL_DNS flag turns IP#->hostname
- * resolution off. Before running your stats program, just run your log
- * file through this program (logresolve) and all of your IP numbers will
- * be resolved into hostnames (where possible).
- *
- * logresolve takes an HTTPD access log (in the COMMON log file format,
- * or any other format that has the IP number/domain name as the first
- * field for that matter), and outputs the same file with all of the
- * domain names looked up. Where no domain name can be found, the IP
- * number is left in.
- *
- * To minimize impact on your nameserver, logresolve has its very own
- * internal hash-table cache. This means that each IP number will only
- * be looked up the first time it is found in the log file.
- *
- * The -c option causes logresolve to apply the same check as httpd
- * compiled with -DMAXIMUM_DNS; after finding the hostname from the IP
- * address, it looks up the IP addresses for the hostname and checks
- * that one of these matches the original address.
- */
-
-#include "ap_config.h"
-#include <sys/types.h>
-
-#include <ctype.h>
-
-#if !defined(MPE) && !defined(BEOS)
-#include <arpa/inet.h>
-#endif
-
-static void cgethost(struct in_addr ipnum, char *string, int check);
-static int getline(char *s, int n);
-static void stats(FILE *output);
-
-#ifdef BEOS
-#define NO_ADDRESS NO_DATA
-#endif
-
-
-/* maximum line length */
-#define MAXLINE 1024
-
-/* maximum length of a domain name */
-#ifndef MAXDNAME
-#define MAXDNAME 256
-#endif
-
-/* number of buckets in cache hash ap_table_t */
-#define BUCKETS 256
-
-#if defined(NEED_STRDUP)
-char *strdup (const char *str)
-{
- char *dup;
-
- if (!(dup = (char *) malloc(strlen(str) + 1)))
- return NULL;
- dup = strcpy(dup, str);
-
- return dup;
-}
-#endif
-
-/*
- * struct nsrec - record of nameservice for cache linked list
- *
- * ipnum - IP number hostname - hostname noname - nonzero if IP number has no
- * hostname, i.e. hostname=IP number
- */
-
-struct nsrec {
- struct in_addr ipnum;
- char *hostname;
- int noname;
- struct nsrec *next;
-} *nscache[BUCKETS];
-
-/*
- * statistics - obvious
- */
-
-#ifndef h_errno
-extern int h_errno; /* some machines don't have this in their headers */
-#endif
-
-/* largest value for h_errno */
-
-#define MAX_ERR (NO_ADDRESS)
-#define UNKNOWN_ERR (MAX_ERR+1)
-#define NO_REVERSE (MAX_ERR+2)
-
-static int cachehits = 0;
-static int cachesize = 0;
-static int entries = 0;
-static int resolves = 0;
-static int withname = 0;
-static int errors[MAX_ERR + 3];
-
-/*
- * cgethost - gets hostname by IP address, caching, and adding unresolvable
- * IP numbers with their IP number as hostname, setting noname flag
- */
-
-static void cgethost (struct in_addr ipnum, char *string, int check)
-{
- struct nsrec **current, *new;
- struct hostent *hostdata;
- char *name;
-
- current = &nscache[((ipnum.s_addr + (ipnum.s_addr >> 8) +
- (ipnum.s_addr >> 16) + (ipnum.s_addr >> 24)) % BUCKETS)];
-
- while (*current != NULL && ipnum.s_addr != (*current)->ipnum.s_addr)
- current = &(*current)->next;
-
- if (*current == NULL) {
- cachesize++;
- new = (struct nsrec *) malloc(sizeof(struct nsrec));
- if (new == NULL) {
- perror("malloc");
- fprintf(stderr, "Insufficient memory\n");
- exit(1);
- }
- *current = new;
- new->next = NULL;
-
- new->ipnum = ipnum;
-
- hostdata = gethostbyaddr((const char *) &ipnum, sizeof(struct in_addr),
- AF_INET);
- if (hostdata == NULL) {
- if (h_errno > MAX_ERR)
- errors[UNKNOWN_ERR]++;
- else
- errors[h_errno]++;
- new->noname = h_errno;
- name = strdup(inet_ntoa(ipnum));
- }
- else {
- new->noname = 0;
- name = strdup(hostdata->h_name);
- if (check) {
- if (name == NULL) {
- perror("strdup");
- fprintf(stderr, "Insufficient memory\n");
- exit(1);
- }
- hostdata = gethostbyname(name);
- if (hostdata != NULL) {
- char **hptr;
-
- for (hptr = hostdata->h_addr_list; *hptr != NULL; hptr++)
- if (((struct in_addr *) (*hptr))->s_addr == ipnum.s_addr)
- break;
- if (*hptr == NULL)
- hostdata = NULL;
- }
- if (hostdata == NULL) {
- fprintf(stderr, "Bad host: %s != %s\n", name,
- inet_ntoa(ipnum));
- new->noname = NO_REVERSE;
- free(name);
- name = strdup(inet_ntoa(ipnum));
- errors[NO_REVERSE]++;
- }
- }
- }
- new->hostname = name;
- if (new->hostname == NULL) {
- perror("strdup");
- fprintf(stderr, "Insufficient memory\n");
- exit(1);
- }
- }
- else
- cachehits++;
-
- /* size of string == MAXDNAME +1 */
- strncpy(string, (*current)->hostname, MAXDNAME);
- string[MAXDNAME] = '\0';
-}
-
-/*
- * prints various statistics to output
- */
-
-static void stats (FILE *output)
-{
- int i;
- char *ipstring;
- struct nsrec *current;
- char *errstring[MAX_ERR + 3];
-
- for (i = 0; i < MAX_ERR + 3; i++)
- errstring[i] = "Unknown error";
- errstring[HOST_NOT_FOUND] = "Host not found";
- errstring[TRY_AGAIN] = "Try again";
- errstring[NO_RECOVERY] = "Non recoverable error";
- errstring[NO_DATA] = "No data record";
- errstring[NO_ADDRESS] = "No address";
- errstring[NO_REVERSE] = "No reverse entry";
-
- fprintf(output, "logresolve Statistics:\n");
-
- fprintf(output, "Entries: %d\n", entries);
- fprintf(output, " With name : %d\n", withname);
- fprintf(output, " Resolves : %d\n", resolves);
- if (errors[HOST_NOT_FOUND])
- fprintf(output, " - Not found : %d\n", errors[HOST_NOT_FOUND]);
- if (errors[TRY_AGAIN])
- fprintf(output, " - Try again : %d\n", errors[TRY_AGAIN]);
- if (errors[NO_DATA])
- fprintf(output, " - No data : %d\n", errors[NO_DATA]);
- if (errors[NO_ADDRESS])
- fprintf(output, " - No address: %d\n", errors[NO_ADDRESS]);
- if (errors[NO_REVERSE])
- fprintf(output, " - No reverse: %d\n", errors[NO_REVERSE]);
- fprintf(output, "Cache hits : %d\n", cachehits);
- fprintf(output, "Cache size : %d\n", cachesize);
- fprintf(output, "Cache buckets : IP number * hostname\n");
-
- for (i = 0; i < BUCKETS; i++)
- for (current = nscache[i]; current != NULL; current = current->next) {
- ipstring = inet_ntoa(current->ipnum);
- if (current->noname == 0)
- fprintf(output, " %3d %15s - %s\n", i, ipstring,
- current->hostname);
- else {
- if (current->noname > MAX_ERR + 2)
- fprintf(output, " %3d %15s : Unknown error\n", i,
- ipstring);
- else
- fprintf(output, " %3d %15s : %s\n", i, ipstring,
- errstring[current->noname]);
- }
- }
-}
-
-
-/*
- * gets a line from stdin
- */
-
-static int getline (char *s, int n)
-{
- char *cp;
-
- if (!fgets(s, n, stdin))
- return (0);
- cp = strchr(s, '\n');
- if (cp)
- *cp = '\0';
- return (1);
-}
-
-int main (int argc, char *argv[])
-{
- struct in_addr ipnum;
- char *bar, hoststring[MAXDNAME + 1], line[MAXLINE], *statfile;
- int i, check;
-
- check = 0;
- statfile = NULL;
- for (i = 1; i < argc; i++) {
- if (strcmp(argv[i], "-c") == 0)
- check = 1;
- else if (strcmp(argv[i], "-s") == 0) {
- if (i == argc - 1) {
- fprintf(stderr, "logresolve: missing filename to -s\n");
- exit(1);
- }
- i++;
- statfile = argv[i];
- }
- else {
- fprintf(stderr, "Usage: logresolve [-s statfile] [-c] < input > output\n");
- exit(0);
- }
- }
-
-
- for (i = 0; i < BUCKETS; i++)
- nscache[i] = NULL;
- for (i = 0; i < MAX_ERR + 2; i++)
- errors[i] = 0;
-
- while (getline(line, MAXLINE)) {
- if (line[0] == '\0')
- continue;
- entries++;
- if (!isdigit(line[0])) { /* short cut */
- puts(line);
- withname++;
- continue;
- }
- bar = strchr(line, ' ');
- if (bar != NULL)
- *bar = '\0';
- ipnum.s_addr = inet_addr(line);
- if (ipnum.s_addr == 0xffffffffu) {
- if (bar != NULL)
- *bar = ' ';
- puts(line);
- withname++;
- continue;
- }
-
- resolves++;
-
- cgethost(ipnum, hoststring, check);
- if (bar != NULL)
- printf("%s %s\n", hoststring, bar + 1);
- else
- puts(hoststring);
- }
-
- if (statfile != NULL) {
- FILE *fp;
- fp = fopen(statfile, "w");
- if (fp == NULL) {
- fprintf(stderr, "logresolve: could not open statistics file '%s'\n"
- ,statfile);
- exit(1);
- }
- stats(fp);
- fclose(fp);
- }
-
- return (0);
-}
diff --git a/support/logresolve.pl b/support/logresolve.pl
deleted file mode 100644
index 59ab9ebaf2..0000000000
--- a/support/logresolve.pl
+++ /dev/null
@@ -1,264 +0,0 @@
-#!/usr/local/bin/perl
-
-# ====================================================================
-# Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
-# "This product includes software developed by the Apache Group
-# for use in the Apache HTTP server project (http://www.apache.org/)."
-#
-# 4. The names "Apache Server" and "Apache Group" must not be used to
-# endorse or promote products derived from this software without
-# prior written permission. For written permission, please contact
-# apache@apache.org.
-#
-# 5. Products derived from this software may not be called "Apache"
-# nor may "Apache" appear in their names without prior written
-# permission of the Apache Group.
-#
-# 6. Redistributions of any form whatsoever must retain the following
-# acknowledgment:
-# "This product includes software developed by the Apache Group
-# for use in the Apache HTTP server project (http://www.apache.org/)."
-#
-# THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-# EXPRESSED 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 APACHE GROUP OR
-# ITS 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.
-# ====================================================================
-#
-# This software consists of voluntary contributions made by many
-# individuals on behalf of the Apache Group and was originally based
-# on public domain software written at the National Center for
-# Supercomputing Applications, University of Illinois, Urbana-Champaign.
-# For more information on the Apache Group and the Apache HTTP server
-# project, please see <http://www.apache.org/>.
-
-# logresolve.pl
-#
-# v 1.2 by robh @ imdb.com
-#
-# usage: logresolve.pl <infile >outfile
-#
-# input = Apache/NCSA/.. logfile with IP numbers at start of lines
-# output = same logfile with IP addresses resolved to hostnames where
-# name lookups succeeded.
-#
-# this differs from the C based 'logresolve' in that this script
-# spawns a number ($CHILDREN) of subprocesses to resolve addresses
-# concurrently and sets a short timeout ($TIMEOUT) for each lookup in
-# order to keep things moving quickly.
-#
-# the parent process handles caching of IP->hostnames using a Perl hash
-# it also avoids sending the same IP to multiple child processes to be
-# resolved multiple times concurrently.
-#
-# Depending on the settings of $CHILDREN and $TIMEOUT you should see
-# significant reductions in the overall time taken to resolve your
-# logfiles. With $CHILDREN=40 and $TIMEOUT=5 I've seen 200,000 - 300,000
-# logfile lines processed per hour compared to ~45,000 per hour
-# with 'logresolve'.
-#
-# I haven't yet seen any noticable reduction in the percentage of IPs
-# that fail to get resolved. Your mileage will no doubt vary. 5s is long
-# enough to wait IMO.
-#
-# Known to work with FreeBSD 2.2
-# Known to have problems with Solaris
-#
-# 980417 - use 'sockaddr_un' for bind/connect to make the script work
-# with linux. Fix from Luuk de Boer <luuk_de_boer@pi.net>
-
-require 5.004;
-
-$|=1;
-
-use FileHandle;
-use Socket;
-
-use strict;
-no strict 'refs';
-
-use vars qw($PROTOCOL);
-$PROTOCOL = 0;
-
-my $CHILDREN = 40;
-my $TIMEOUT = 5;
-
-my $filename;
-my %hash = ();
-my $parent = $$;
-
-my @children = ();
-for (my $child = 1; $child <=$CHILDREN; $child++) {
- my $f = fork();
- if (!$f) {
- $filename = "./.socket.$parent.$child";
- if (-e $filename) { unlink($filename) || warn "$filename .. $!\n";}
- &child($child);
- exit(0);
- }
- push(@children, $f);
-}
-
-&parent;
-&cleanup;
-
-## remove all temporary files before shutting down
-sub cleanup {
- # die kiddies, die
- kill(15, @children);
- for (my $child = 1; $child <=$CHILDREN; $child++) {
- if (-e "./.socket.$parent.$child") {
- unlink("./.socket.$parent.$child")
- || warn ".socket.$parent.$child $!";
- }
- }
-}
-
-sub parent {
- # Trap some possible signals to trigger temp file cleanup
- $SIG{'KILL'} = $SIG{'INT'} = $SIG{'PIPE'} = \&cleanup;
-
- my %CHILDSOCK;
- my $filename;
-
- ## fork child processes. Each child will create a socket connection
- ## to this parent and use an unique temp filename to do so.
- for (my $child = 1; $child <=$CHILDREN; $child++) {
- $CHILDSOCK{$child}= FileHandle->new;
-
- if (!socket($CHILDSOCK{$child}, AF_UNIX, SOCK_STREAM, $PROTOCOL)) {
- warn "parent socket to child failed $!";
- }
- $filename = "./.socket.$parent.$child";
- my $response;
- do {
- $response = connect($CHILDSOCK{$child}, sockaddr_un($filename));
- if ($response != 1) {
- sleep(1);
- }
- } while ($response != 1);
- $CHILDSOCK{$child}->autoflush;
- }
- ## All child processes should now be ready or at worst warming up
-
- my (@buffer, $child, $ip, $rest, $hostname, $response);
- ## read the logfile lines from STDIN
- while(<STDIN>) {
- @buffer = (); # empty the logfile line buffer array.
- $child = 1; # children are numbered 1..N, start with #1
-
- # while we have a child to talk to and data to give it..
- do {
- push(@buffer, $_); # buffer the line
- ($ip, $rest) = split(/ /, $_, 2); # separate IP form rest
-
- unless ($hash{$ip}) { # resolve if unseen IP
- $CHILDSOCK{$child}->print("$ip\n"); # pass IP to next child
- $hash{$ip} = $ip; # don't look it up again.
- $child++;
- }
- } while (($child < ($CHILDREN-1)) and ($_ = <STDIN>));
-
- ## now poll each child for a response
- while (--$child > 0) {
- $response = $CHILDSOCK{$child}->getline;
- chomp($response);
- # child sends us back both the IP and HOSTNAME, no need for us
- # to remember what child received any given IP, and no worries
- # what order we talk to the children
- ($ip, $hostname) = split(/\|/, $response, 2);
- $hash{$ip} = $hostname;
- }
-
- # resolve all the logfiles lines held in the log buffer array..
- for (my $line = 0; $line <=$#buffer; $line++) {
- # get next buffered line
- ($ip, $rest) = split(/ /, $buffer[$line], 2);
- # separate IP from rest and replace with cached hostname
- printf STDOUT ("%s %s", $hash{$ip}, $rest);
- }
- }
-}
-
-########################################
-
-sub child {
- # arg = numeric ID - how the parent refers to me
- my $me = shift;
-
- # add trap for alarm signals.
- $SIG{'ALRM'} = sub { die "alarmed"; };
-
- # create a socket to communicate with parent
- socket(INBOUND, AF_UNIX, SOCK_STREAM, $PROTOCOL)
- || die "Error with Socket: !$\n";
- $filename = "./.socket.$parent.$me";
- bind(INBOUND, sockaddr_un($filename))
- || die "Error Binding $filename: $!\n";
- listen(INBOUND, 5) || die "Error Listening: $!\n";
-
- my ($ip, $send_back);
- my $talk = FileHandle->new;
-
- # accept a connection from the parent process. We only ever have
- # have one connection where we exchange 1 line of info with the
- # parent.. 1 line in (IP address), 1 line out (IP + hostname).
- accept($talk, INBOUND) || die "Error Accepting: $!\n";
- # disable I/O buffering just in case
- $talk->autoflush;
- # while the parent keeps sending data, we keep responding..
- while(($ip = $talk->getline)) {
- chomp($ip);
- # resolve the IP if time permits and send back what we found..
- $send_back = sprintf("%s|%s", $ip, &nslookup($ip));
- $talk->print($send_back."\n");
- }
-}
-
-# perform a time restricted hostname lookup.
-sub nslookup {
- # get the IP as an arg
- my $ip = shift;
- my $hostname = undef;
-
- # do the hostname lookup inside an eval. The eval will use the
- # already configured SIGnal handler and drop out of the {} block
- # regardless of whether the alarm occured or not.
- eval {
- alarm($TIMEOUT);
- $hostname = gethostbyaddr(gethostbyname($ip), AF_INET);
- alarm(0);
- };
- if ($@ =~ /alarm/) {
- # useful for debugging perhaps..
- # print "alarming, isn't it? ($ip)";
- }
-
- # return the hostname or the IP address itself if there is no hostname
- $hostname ne "" ? $hostname : $ip;
-}
-
-
diff --git a/support/phf_abuse_log.cgi b/support/phf_abuse_log.cgi
deleted file mode 100644
index 9ce2749c57..0000000000
--- a/support/phf_abuse_log.cgi
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/local/bin/perl
-
-# This script can be used to detect people trying to abuse the security hole which
-# existed in A CGI script direstributed with Apache 1.0.3 and earlier versions.
-# You can redirect them to here using the "<Location /cgi-bin/phf*>" suggestion in
-# httpd.conf.
-#
-# The format logged to is "[date] remote_addr remote_host [date] referrer user_agent".
-
-$LOG = "/var/log/phf_log";
-
-require "ctime.pl";
-$when = &ctime(time);
-$when =~ s/\n//go;
-$ENV{HTTP_USER_AGENT} .= " via $ENV{HTTP_VIA}" if($ENV{HTTP_VIA});
-
-open(LOG, ">>$LOG") || die "boo hoo, phf_log $!";
-print LOG "[$when] $ENV{REMOTE_ADDR} $ENV{REMOTE_HOST} $ENV{$HTTP_REFERER} $ENV{HTTP_USER_AGENT}\n";
-close(LOG);
-
-print "Content-type: text/html\r\n\r\n<BLINK>Smile, you're on Candid Camera.</BLINK>\n";
diff --git a/support/rotatelogs.c b/support/rotatelogs.c
deleted file mode 100644
index 1f5b88620e..0000000000
--- a/support/rotatelogs.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Simple program to rotate Apache logs without having to kill the server.
- *
- * Contributed by Ben Laurie <ben@algroup.co.uk>
- *
- * 12 Mar 1996
- */
-
-
-#define BUFSIZE 65536
-#ifdef MAX_PATH
-#undef MAX_PATH
-#endif
-#define MAX_PATH 1024
-
-#include "ap_config.h"
-#include <time.h>
-#include <errno.h>
-#include <fcntl.h>
-
-void main (int argc, char **argv)
-{
- char buf[BUFSIZE], buf2[MAX_PATH];
- time_t tLogEnd = 0;
- time_t tRotation;
- int nLogFD = -1;
- int nRead;
- char *szLogRoot;
-
- if (argc != 3) {
- fprintf(stderr,
- "%s <logfile> <rotation time in seconds>\n\n",
- argv[0]);
-#ifdef OS2
- fprintf(stderr,
- "Add this:\n\nTransferLog \"|%s.exe /some/where 86400\"\n\n",
- argv[0]);
-#else
- fprintf(stderr,
- "Add this:\n\nTransferLog \"|%s /some/where 86400\"\n\n",
- argv[0]);
-#endif
- fprintf(stderr,
- "to httpd.conf. The generated name will be /some/where.nnnn "
- "where nnnn is the\nsystem time at which the log nominally "
- "starts (N.B. this time will always be a\nmultiple of the "
- "rotation time, so you can synchronize cron scripts with it).\n"
- "At the end of each rotation time a new log is started.\n");
- exit(1);
- }
-
- szLogRoot = argv[1];
- tRotation = atoi(argv[2]);
- if (tRotation <= 0) {
- fprintf(stderr, "Rotation time must be > 0\n");
- exit(6);
- }
-
- for (;;) {
- nRead = read(0, buf, sizeof buf);
- if (nRead == 0)
- exit(3);
- if (nRead < 0)
- if (errno != EINTR)
- exit(4);
- if (nLogFD >= 0 && (time(NULL) >= tLogEnd || nRead < 0)) {
- close(nLogFD);
- nLogFD = -1;
- }
- if (nLogFD < 0) {
- time_t tLogStart = (time(NULL) / tRotation) * tRotation;
- sprintf(buf2, "%s.%010d", szLogRoot, (int) tLogStart);
- tLogEnd = tLogStart + tRotation;
- nLogFD = open(buf2, O_WRONLY | O_CREAT | O_APPEND, 0666);
- if (nLogFD < 0) {
- perror(buf2);
- exit(2);
- }
- }
- if (write(nLogFD, buf, nRead) != nRead) {
- perror(buf2);
- exit(5);
- }
- }
-}
diff --git a/support/rotatelogs.dsp b/support/rotatelogs.dsp
deleted file mode 100644
index 3e0209d5cc..0000000000
--- a/support/rotatelogs.dsp
+++ /dev/null
@@ -1,89 +0,0 @@
-# Microsoft Developer Studio Project File - Name="rotatelogs" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 5.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=rotatelogs - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "rotatelogs.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "rotatelogs.mak" CFG="rotatelogs - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "rotatelogs - Win32 Release" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "rotatelogs - Win32 Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "rotatelogs - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "../include" /I "../lib/apr/include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-
-!ELSEIF "$(CFG)" == "rotatelogs - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "../include" /I "../lib/apr/include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-
-!ENDIF
-
-# Begin Target
-
-# Name "rotatelogs - Win32 Release"
-# Name "rotatelogs - Win32 Debug"
-# Begin Source File
-
-SOURCE=.\rotatelogs.c
-# End Source File
-# End Target
-# End Project
diff --git a/support/split-logfile b/support/split-logfile
deleted file mode 100644
index 7cc4652da8..0000000000
--- a/support/split-logfile
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/local/bin/perl
-#
-# ====================================================================
-# Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
-# "This product includes software developed by the Apache Group
-# for use in the Apache HTTP server project (http://www.apache.org/)."
-#
-# 4. The names "Apache Server" and "Apache Group" must not be used to
-# endorse or promote products derived from this software without
-# prior written permission. For permission please contact
-# Apache@Apache.Org.
-#
-# 5. Products derived from this software may not be called "Apache"
-# nor may "Apache" appear in their names without prior written
-# permission of the Apache Group.
-#
-# 6. Redistributions of any form whatsoever must retain the following
-# acknowledgment:
-# "This product includes software developed by the Apache Group
-# for use in the Apache HTTP server project (http://www.apache.org/)."
-#
-# THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
-# EXPRESSED 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 APACHE GROUP OR
-# ITS 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.
-# ====================================================================
-#
-# This software consists of voluntary contributions made by many
-# individuals on behalf of the Apache Group and was originally based
-# on public domain software written at the National Center for
-# Supercomputing Applications, University of Illinois, Urbana-Champaign.
-# For more information on the Apache Group and the Apache HTTP server
-# project, please see <http://www.apache.org/>.
-#
-
-#
-# This script will take a combined Web server access
-# log file and break its contents into separate files.
-# It assumes that the first field of each line is the
-# virtual host identity (put there by "%v"), and that
-# the logfiles should be named that+".log" in the current
-# directory.
-#
-# The combined log file is read from stdin. Records read
-# will be appended to any existing log files.
-#
-%is_open = ();
-
-while ($log_line = <STDIN>) {
- #
- # Get the first token from the log record; it's the
- # identity of the virtual host to which the record
- # applies.
- #
- ($vhost) = split (/\s/, $log_line);
- #
- # Normalize the virtual host name to all lowercase.
- # If it's blank, the request was handled by the default
- # server, so supply a default name. This shouldn't
- # happen, but caution rocks.
- #
- $vhost = lc ($vhost) or "access";
- #
- # If the log file for this virtual host isn't opened
- # yet, do it now.
- #
- if (! $is_open{$vhost}) {
- open $vhost, ">>${vhost}.log"
- or die ("Can't open ${vhost}.log");
- $is_open{$vhost} = 1;
- }
- #
- # Strip off the first token (which may be null in the
- # case of the default server), and write the edited
- # record to the current log file.
- #
- $log_line =~ s/^\S*\s+//;
- printf $vhost "%s", $log_line;
-}
-exit 0;
diff --git a/support/suexec.c b/support/suexec.c
deleted file mode 100644
index 13f3fcc134..0000000000
--- a/support/suexec.c
+++ /dev/null
@@ -1,566 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * suexec.c -- "Wrapper" support program for suEXEC behaviour for Apache
- *
- ***********************************************************************
- *
- * NOTE! : DO NOT edit this code!!! Unless you know what you are doing,
- * editing this code might open up your system in unexpected
- * ways to would-be crackers. Every precaution has been taken
- * to make this code as safe as possible; alter it at your own
- * risk.
- *
- ***********************************************************************
- *
- *
- */
-
-#include "ap_config.h"
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <stdarg.h>
-
-#include "suexec.h"
-
-/*
- ***********************************************************************
- * There is no initgroups() in QNX, so I believe this is safe :-)
- * Use cc -osuexec -3 -O -mf -DQNX suexec.c to compile.
- *
- * May 17, 1997.
- * Igor N. Kovalenko -- infoh@mail.wplus.net
- ***********************************************************************
- */
-
-#if defined(NEED_INITGROUPS)
-int initgroups(const char *name, gid_t basegid)
-{
-/* QNX and MPE do not appear to support supplementary groups. */
- return 0;
-}
-#endif
-
-#if defined(PATH_MAX)
-#define AP_MAXPATH PATH_MAX
-#elif defined(MAXPATHLEN)
-#define AP_MAXPATH MAXPATHLEN
-#else
-#define AP_MAXPATH 8192
-#endif
-
-#define AP_ENVBUF 256
-
-extern char **environ;
-static FILE *log = NULL;
-
-char *safe_env_lst[] =
-{
- "AUTH_TYPE",
- "CONTENT_LENGTH",
- "CONTENT_TYPE",
- "DATE_GMT",
- "DATE_LOCAL",
- "DOCUMENT_NAME",
- "DOCUMENT_PATH_INFO",
- "DOCUMENT_ROOT",
- "DOCUMENT_URI",
- "FILEPATH_INFO",
- "GATEWAY_INTERFACE",
- "LAST_MODIFIED",
- "PATH_INFO",
- "PATH_TRANSLATED",
- "QUERY_STRING",
- "QUERY_STRING_UNESCAPED",
- "REMOTE_ADDR",
- "REMOTE_HOST",
- "REMOTE_IDENT",
- "REMOTE_PORT",
- "REMOTE_USER",
- "REDIRECT_QUERY_STRING",
- "REDIRECT_STATUS",
- "REDIRECT_URL",
- "REQUEST_METHOD",
- "REQUEST_URI",
- "SCRIPT_FILENAME",
- "SCRIPT_NAME",
- "SCRIPT_URI",
- "SCRIPT_URL",
- "SERVER_ADMIN",
- "SERVER_NAME",
- "SERVER_ADDR",
- "SERVER_PORT",
- "SERVER_PROTOCOL",
- "SERVER_SOFTWARE",
- "UNIQUE_ID",
- "USER_NAME",
- "TZ",
- NULL
-};
-
-
-static void err_output(const char *fmt, va_list ap)
-{
-#ifdef LOG_EXEC
- time_t timevar;
- struct tm *lt;
-
- if (!log) {
- if ((log = fopen(LOG_EXEC, "a")) == NULL) {
- fprintf(stderr, "failed to open log file\n");
- perror("fopen");
- exit(1);
- }
- }
-
- time(&timevar);
- lt = localtime(&timevar);
-
- fprintf(log, "[%d-%.2d-%.2d %.2d:%.2d:%.2d]: ",
- lt->tm_year + 1900, lt->tm_mon + 1, lt->tm_mday,
- lt->tm_hour, lt->tm_min, lt->tm_sec);
-
- vfprintf(log, fmt, ap);
-
- fflush(log);
-#endif /* LOG_EXEC */
- return;
-}
-
-static void log_err(const char *fmt,...)
-{
-#ifdef LOG_EXEC
- va_list ap;
-
- va_start(ap, fmt);
- err_output(fmt, ap);
- va_end(ap);
-#endif /* LOG_EXEC */
- return;
-}
-
-static void clean_env(void)
-{
- char pathbuf[512];
- char **cleanenv;
- char **ep;
- int cidx = 0;
- int idx;
-
-
- if ((cleanenv = (char **) calloc(AP_ENVBUF, sizeof(char *))) == NULL) {
- log_err("failed to malloc memory for environment\n");
- exit(120);
- }
-
- sprintf(pathbuf, "PATH=%s", SAFE_PATH);
- cleanenv[cidx] = strdup(pathbuf);
- cidx++;
-
- for (ep = environ; *ep && cidx < AP_ENVBUF-1; ep++) {
- if (!strncmp(*ep, "HTTP_", 5)) {
- cleanenv[cidx] = *ep;
- cidx++;
- }
- else {
- for (idx = 0; safe_env_lst[idx]; idx++) {
- if (!strncmp(*ep, safe_env_lst[idx],
- strlen(safe_env_lst[idx]))) {
- cleanenv[cidx] = *ep;
- cidx++;
- break;
- }
- }
- }
- }
-
- cleanenv[cidx] = NULL;
-
- environ = cleanenv;
-}
-
-int main(int argc, char *argv[])
-{
- int userdir = 0; /* ~userdir flag */
- uid_t uid; /* user information */
- gid_t gid; /* target group placeholder */
- char *target_uname; /* target user name */
- char *target_gname; /* target group name */
- char *target_homedir; /* target home directory */
- char *actual_uname; /* actual user name */
- char *actual_gname; /* actual group name */
- char *prog; /* name of this program */
- char *cmd; /* command to be executed */
- char cwd[AP_MAXPATH]; /* current working directory */
- char dwd[AP_MAXPATH]; /* docroot working directory */
- struct passwd *pw; /* password entry holder */
- struct group *gr; /* group entry holder */
- struct stat dir_info; /* directory info holder */
- struct stat prg_info; /* program info holder */
-
- /*
- * If there are a proper number of arguments, set
- * all of them to variables. Otherwise, error out.
- */
- prog = argv[0];
- if (argc < 4) {
- log_err("too few arguments\n");
- exit(101);
- }
- target_uname = argv[1];
- target_gname = argv[2];
- cmd = argv[3];
-
- /*
- * Check existence/validity of the UID of the user
- * running this program. Error out if invalid.
- */
- uid = getuid();
- if ((pw = getpwuid(uid)) == NULL) {
- log_err("invalid uid: (%ld)\n", uid);
- exit(102);
- }
-
- /*
- * Check to see if the user running this program
- * is the user allowed to do so as defined in
- * suexec.h. If not the allowed user, error out.
- */
-#ifdef _OSD_POSIX
- /* User name comparisons are case insensitive on BS2000/OSD */
- if (strcasecmp(HTTPD_USER, pw->pw_name)) {
- log_err("user mismatch (%s instead of %s)\n", pw->pw_name, HTTPD_USER);
- exit(103);
- }
-#else /*_OSD_POSIX*/
- if (strcmp(HTTPD_USER, pw->pw_name)) {
- log_err("user mismatch (%s instead of %s)\n", pw->pw_name, HTTPD_USER);
- exit(103);
- }
-#endif /*_OSD_POSIX*/
-
- /*
- * Check for a leading '/' (absolute path) in the command to be executed,
- * or attempts to back up out of the current directory,
- * to protect against attacks. If any are
- * found, error out. Naughty naughty crackers.
- */
- if ((cmd[0] == '/') || (!strncmp(cmd, "../", 3))
- || (strstr(cmd, "/../") != NULL)) {
- log_err("invalid command (%s)\n", cmd);
- exit(104);
- }
-
- /*
- * Check to see if this is a ~userdir request. If
- * so, set the flag, and remove the '~' from the
- * target username.
- */
- if (!strncmp("~", target_uname, 1)) {
- target_uname++;
- userdir = 1;
- }
-
- /*
- * Error out if the target username is invalid.
- */
- if ((pw = getpwnam(target_uname)) == NULL) {
- log_err("invalid target user name: (%s)\n", target_uname);
- exit(105);
- }
-
- /*
- * Error out if the target group name is invalid.
- */
- if (strspn(target_gname, "1234567890") != strlen(target_gname)) {
- if ((gr = getgrnam(target_gname)) == NULL) {
- log_err("invalid target group name: (%s)\n", target_gname);
- exit(106);
- }
- gid = gr->gr_gid;
- actual_gname = strdup(gr->gr_name);
- }
- else {
- gid = atoi(target_gname);
- actual_gname = strdup(target_gname);
- }
-
-#ifdef _OSD_POSIX
- /*
- * Initialize BS2000 user environment
- */
- {
- pid_t pid;
- int status;
-
- switch (pid = ufork(target_uname))
- {
- case -1: /* Error */
- log_err("failed to setup bs2000 environment for user %s: %s\n",
- target_uname, strerror(errno));
- exit(150);
- case 0: /* Child */
- break;
- default: /* Father */
- while (pid != waitpid(pid, &status, 0))
- ;
- /* @@@ FIXME: should we deal with STOP signals as well? */
- if (WIFSIGNALED(status))
- kill (getpid(), WTERMSIG(status));
- exit(WEXITSTATUS(status));
- }
- }
-#endif /*_OSD_POSIX*/
-
- /*
- * Save these for later since initgroups will hose the struct
- */
- uid = pw->pw_uid;
- actual_uname = strdup(pw->pw_name);
- target_homedir = strdup(pw->pw_dir);
-
- /*
- * Log the transaction here to be sure we have an open log
- * before we setuid().
- */
- log_err("uid: (%s/%s) gid: (%s/%s) cmd: %s\n",
- target_uname, actual_uname,
- target_gname, actual_gname,
- cmd);
-
- /*
- * Error out if attempt is made to execute as root or as
- * a UID less than UID_MIN. Tsk tsk.
- */
- if ((uid == 0) || (uid < UID_MIN)) {
- log_err("cannot run as forbidden uid (%d/%s)\n", uid, cmd);
- exit(107);
- }
-
- /*
- * Error out if attempt is made to execute as root group
- * or as a GID less than GID_MIN. Tsk tsk.
- */
- if ((gid == 0) || (gid < GID_MIN)) {
- log_err("cannot run as forbidden gid (%d/%s)\n", gid, cmd);
- exit(108);
- }
-
- /*
- * Change UID/GID here so that the following tests work over NFS.
- *
- * Initialize the group access list for the target user,
- * and setgid() to the target group. If unsuccessful, error out.
- */
- if (((setgid(gid)) != 0) || (initgroups(actual_uname, gid) != 0)) {
- log_err("failed to setgid (%ld: %s)\n", gid, cmd);
- exit(109);
- }
-
- /*
- * setuid() to the target user. Error out on fail.
- */
- if ((setuid(uid)) != 0) {
- log_err("failed to setuid (%ld: %s)\n", uid, cmd);
- exit(110);
- }
-
- /*
- * Get the current working directory, as well as the proper
- * document root (dependant upon whether or not it is a
- * ~userdir request). Error out if we cannot get either one,
- * or if the current working directory is not in the docroot.
- * Use chdir()s and getcwd()s to avoid problems with symlinked
- * directories. Yuck.
- */
- if (getcwd(cwd, AP_MAXPATH) == NULL) {
- log_err("cannot get current working directory\n");
- exit(111);
- }
-
- if (userdir) {
- if (((chdir(target_homedir)) != 0) ||
- ((chdir(USERDIR_SUFFIX)) != 0) ||
- ((getcwd(dwd, AP_MAXPATH)) == NULL) ||
- ((chdir(cwd)) != 0)) {
- log_err("cannot get docroot information (%s)\n", target_homedir);
- exit(112);
- }
- }
- else {
- if (((chdir(DOC_ROOT)) != 0) ||
- ((getcwd(dwd, AP_MAXPATH)) == NULL) ||
- ((chdir(cwd)) != 0)) {
- log_err("cannot get docroot information (%s)\n", DOC_ROOT);
- exit(113);
- }
- }
-
- if ((strncmp(cwd, dwd, strlen(dwd))) != 0) {
- log_err("command not in docroot (%s/%s)\n", cwd, cmd);
- exit(114);
- }
-
- /*
- * Stat the cwd and verify it is a directory, or error out.
- */
- if (((lstat(cwd, &dir_info)) != 0) || !(S_ISDIR(dir_info.st_mode))) {
- log_err("cannot stat directory: (%s)\n", cwd);
- exit(115);
- }
-
- /*
- * Error out if cwd is writable by others.
- */
- if ((dir_info.st_mode & S_IWOTH) || (dir_info.st_mode & S_IWGRP)) {
- log_err("directory is writable by others: (%s)\n", cwd);
- exit(116);
- }
-
- /*
- * Error out if we cannot stat the program.
- */
- if (((lstat(cmd, &prg_info)) != 0) || (S_ISLNK(prg_info.st_mode))) {
- log_err("cannot stat program: (%s)\n", cmd);
- exit(117);
- }
-
- /*
- * Error out if the program is writable by others.
- */
- if ((prg_info.st_mode & S_IWOTH) || (prg_info.st_mode & S_IWGRP)) {
- log_err("file is writable by others: (%s/%s)\n", cwd, cmd);
- exit(118);
- }
-
- /*
- * Error out if the file is setuid or setgid.
- */
- if ((prg_info.st_mode & S_ISUID) || (prg_info.st_mode & S_ISGID)) {
- log_err("file is either setuid or setgid: (%s/%s)\n", cwd, cmd);
- exit(119);
- }
-
- /*
- * Error out if the target name/group is different from
- * the name/group of the cwd or the program.
- */
- if ((uid != dir_info.st_uid) ||
- (gid != dir_info.st_gid) ||
- (uid != prg_info.st_uid) ||
- (gid != prg_info.st_gid)) {
- log_err("target uid/gid (%ld/%ld) mismatch "
- "with directory (%ld/%ld) or program (%ld/%ld)\n",
- uid, gid,
- dir_info.st_uid, dir_info.st_gid,
- prg_info.st_uid, prg_info.st_gid);
- exit(120);
- }
- /*
- * Error out if the program is not executable for the user.
- * Otherwise, she won't find any error in the logs except for
- * "[error] Premature end of script headers: ..."
- */
- if (!(prg_info.st_mode & S_IXUSR)) {
- log_err("file has no execute permission: (%s/%s)\n", cwd, cmd);
- exit(121);
- }
-
- clean_env();
-
- /*
- * Be sure to close the log file so the CGI can't
- * mess with it. If the exec fails, it will be reopened
- * automatically when log_err is called. Note that the log
- * might not actually be open if LOG_EXEC isn't defined.
- * However, the "log" cell isn't ifdef'd so let's be defensive
- * and assume someone might have done something with it
- * outside an ifdef'd LOG_EXEC block.
- */
- if (log != NULL) {
- fclose(log);
- log = NULL;
- }
-
- /*
- * Execute the command, replacing our image with its own.
- */
-#ifdef NEED_HASHBANG_EMUL
- /* We need the #! emulation when we want to execute scripts */
- {
- extern char **environ;
-
- ap_execve(cmd, &argv[3], environ);
- }
-#else /*NEED_HASHBANG_EMUL*/
- execv(cmd, &argv[3]);
-#endif /*NEED_HASHBANG_EMUL*/
-
- /*
- * (I can't help myself...sorry.)
- *
- * Uh oh. Still here. Where's the kaboom? There was supposed to be an
- * EARTH-shattering kaboom!
- *
- * Oh well, log the failure and error out.
- */
- log_err("(%d)%s: exec failed (%s)\n", errno, strerror(errno), cmd);
- exit(255);
-}
diff --git a/support/suexec.h b/support/suexec.h
deleted file mode 100644
index 892badd1e0..0000000000
--- a/support/suexec.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/* ====================================================================
- * Copyright (c) 1995-1999 The Apache Group. 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 acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * 4. The names "Apache Server" and "Apache Group" must not be used to
- * endorse or promote products derived from this software without
- * prior written permission. For written permission, please contact
- * apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * 6. Redistributions of any form whatsoever must retain the following
- * acknowledgment:
- * "This product includes software developed by the Apache Group
- * for use in the Apache HTTP server project (http://www.apache.org/)."
- *
- * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
- * EXPRESSED 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 APACHE GROUP OR
- * ITS 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.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Group and was originally based
- * on public domain software written at the National Center for
- * Supercomputing Applications, University of Illinois, Urbana-Champaign.
- * For more information on the Apache Group and the Apache HTTP server
- * project, please see <http://www.apache.org/>.
- *
- */
-
-/*
- * suexec.h -- user-definable variables for the suexec wrapper code.
- * (See README.configure on how to customize these variables.)
- */
-
-
-#ifndef _SUEXEC_H
-#define _SUEXEC_H
-
-/*
- * HTTPD_USER -- Define as the username under which Apache normally
- * runs. This is the only user allowed to execute
- * this program.
- */
-#ifndef HTTPD_USER
-#define HTTPD_USER "www"
-#endif
-
-/*
- * UID_MIN -- Define this as the lowest UID allowed to be a target user
- * for suEXEC. For most systems, 500 or 100 is common.
- */
-#ifndef UID_MIN
-#define UID_MIN 100
-#endif
-
-/*
- * GID_MIN -- Define this as the lowest GID allowed to be a target group
- * for suEXEC. For most systems, 100 is common.
- */
-#ifndef GID_MIN
-#define GID_MIN 100
-#endif
-
-/*
- * USERDIR_SUFFIX -- Define to be the subdirectory under users'
- * home directories where suEXEC access should
- * be allowed. All executables under this directory
- * will be executable by suEXEC as the user so
- * they should be "safe" programs. If you are
- * using a "simple" UserDir directive (ie. one
- * without a "*" in it) this should be set to
- * the same value. suEXEC will not work properly
- * in cases where the UserDir directive points to
- * a location that is not the same as the user's
- * home directory as referenced in the passwd file.
- *
- * If you have VirtualHosts with a different
- * UserDir for each, you will need to define them to
- * all reside in one parent directory; then name that
- * parent directory here. IF THIS IS NOT DEFINED
- * PROPERLY, ~USERDIR CGI REQUESTS WILL NOT WORK!
- * See the suEXEC documentation for more detailed
- * information.
- */
-#ifndef USERDIR_SUFFIX
-#define USERDIR_SUFFIX "public_html"
-#endif
-
-/*
- * LOG_EXEC -- Define this as a filename if you want all suEXEC
- * transactions and errors logged for auditing and
- * debugging purposes.
- */
-#ifndef LOG_EXEC
-#define LOG_EXEC "/usr/local/apache/logs/cgi.log" /* Need me? */
-#endif
-
-/*
- * DOC_ROOT -- Define as the DocumentRoot set for Apache. This
- * will be the only hierarchy (aside from UserDirs)
- * that can be used for suEXEC behavior.
- */
-#ifndef DOC_ROOT
-#define DOC_ROOT "/usr/local/apache/htdocs"
-#endif
-
-/*
- * SAFE_PATH -- Define a safe PATH environment to pass to CGI executables.
- *
- */
-#ifndef SAFE_PATH
-#define SAFE_PATH "/usr/local/bin:/usr/bin:/bin"
-#endif
-
-#endif /* _SUEXEC_H */
diff --git a/test/.cvsignore b/test/.cvsignore
deleted file mode 100644
index e2244a438e..0000000000
--- a/test/.cvsignore
+++ /dev/null
@@ -1,11 +0,0 @@
-a.out
-time-FCNTL
-time-FLOCK
-time-SYSVSEM
-time-SYSVSEM2
-time-PTHREAD
-time-USLOCK
-zb
-test-writev
-test_date
-test_select
diff --git a/test/.indent.pro b/test/.indent.pro
deleted file mode 100644
index a9fbe9f9a1..0000000000
--- a/test/.indent.pro
+++ /dev/null
@@ -1,54 +0,0 @@
--i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -nfc1
--TBUFF
--TFILE
--TTRANS
--TUINT4
--T_trans
--Tallow_options_t
--Tapache_sfio
--Tarray_header
--Tbool_int
--Tbuf_area
--Tbuff_struct
--Tbuffy
--Tcmd_how
--Tcmd_parms
--Tcommand_rec
--Tcommand_struct
--Tconn_rec
--Tcore_dir_config
--Tcore_server_config
--Tdir_maker_func
--Tevent
--Tglobals_s
--Thandler_func
--Thandler_rec
--Tjoblist_s
--Tlisten_rec
--Tmerger_func
--Tmode_t
--Tmodule
--Tmodule_struct
--Tmutex
--Tn_long
--Tother_child_rec
--Toverrides_t
--Tparent_score
--Tpid_t
--Tpiped_log
--Tpool
--Trequest_rec
--Trequire_line
--Trlim_t
--Tscoreboard
--Tsemaphore
--Tserver_addr_rec
--Tserver_rec
--Tserver_rec_chain
--Tshort_score
--Ttable
--Ttable_entry
--Tthread
--Tu_wide_int
--Tvtime_t
--Twide_int
diff --git a/test/README b/test/README
deleted file mode 100644
index 9f8be502b8..0000000000
--- a/test/README
+++ /dev/null
@@ -1,3 +0,0 @@
-This directory contains useful test code for testing various bits
-of Apache functionality. This stuff is for the developers only,
-so we might remove it on public releases.
diff --git a/test/check_chunked b/test/check_chunked
deleted file mode 100644
index 6a12167211..0000000000
--- a/test/check_chunked
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/perl -w
-
-# This is meant to be used on the raw output of an HTTP/1.1 connection
-# to check that the chunks are all correctly laid out. It's easiest
-# to use a tool like netcat to generate the output. This script
-# *insists* that \r exist in the output.
-#
-# You can find netcat at avian.org:/src/hacks/nc110.tgz.
-
-use strict;
-
-my $is_chunked = 0;
-
-# must toss headers
-while(<>) {
- if (/^Transfer-Encoding:\s+chunked/i) {
- $is_chunked = 1;
- }
- last if ($_ eq "\r\n");
-}
-
-$is_chunked || die "wasn't chunked\n";
-
-for(;;) {
- $_ = <> || die "unexpected end of file!\n";
-
- m#^([0-9a-f]+) *\r$#i || die "bogus chunklen: $_";
-
- my $chunklen = hex($1);
-
- exit 0 if ($chunklen == 0);
-
- chop; chop;
- print "$_ ";
-
- my $data = '';
- read(ARGV, $data, $chunklen) == $chunklen || die "short read!\n";
-
- $_ = <> || die "unexpected end of file!\n";
-
- $_ eq "\r\n" || die "missing chunk trailer!\n";
-}
diff --git a/test/cls.c b/test/cls.c
deleted file mode 100644
index 91114a784c..0000000000
--- a/test/cls.c
+++ /dev/null
@@ -1,166 +0,0 @@
-#include <ctype.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-
-/*
- * Compare a string to a mask
- * Mask characters:
- * @ - uppercase letter
- * # - lowercase letter
- * & - hex digit
- * # - digit
- * * - swallow remaining characters
- * <x> - exact match for any other character
- */
-static int checkmask(const char *data, const char *mask)
-{
- int i, ch, d;
-
- for (i = 0; mask[i] != '\0' && mask[i] != '*'; i++) {
- ch = mask[i];
- d = data[i];
- if (ch == '@') {
- if (!isupper(d))
- return 0;
- }
- else if (ch == '$') {
- if (!islower(d))
- return 0;
- }
- else if (ch == '#') {
- if (!isdigit(d))
- return 0;
- }
- else if (ch == '&') {
- if (!isxdigit(d))
- return 0;
- }
- else if (ch != d)
- return 0;
- }
-
- if (mask[i] == '*')
- return 1;
- else
- return (data[i] == '\0');
-}
-
-/*
- * Converts 8 hex digits to a time integer
- */
-static int hex2sec(const char *x)
-{
- int i, ch;
- unsigned int j;
-
- for (i = 0, j = 0; i < 8; i++) {
- ch = x[i];
- j <<= 4;
- if (isdigit(ch))
- j |= ch - '0';
- else if (isupper(ch))
- j |= ch - ('A' - 10);
- else
- j |= ch - ('a' - 10);
- }
- if (j == 0xffffffff)
- return -1; /* so that it works with 8-byte ints */
- else
- return j;
-}
-
-int main(int argc, char **argv)
-{
- int i, ver;
- DIR *d;
- struct dirent *e;
- const char *s;
- FILE *fp;
- char path[FILENAME_MAX + 1];
- char line[1035];
- time_t date, lmod, expire;
- unsigned int len;
- struct tm ts;
- char sdate[30], slmod[30], sexpire[30];
- const char time_format[] = "%e %b %Y %R";
-
- if (argc != 2) {
- printf("Usage: cls directory\n");
- exit(0);
- }
-
- d = opendir(argv[1]);
- if (d == NULL) {
- perror("opendir");
- exit(1);
- }
-
- for (;;) {
- e = readdir(d);
- if (e == NULL)
- break;
- s = e->d_name;
- if (s[0] == '.' || s[0] == '#')
- continue;
- sprintf(path, "%s/%s", argv[1], s);
- fp = fopen(path, "r");
- if (fp == NULL) {
- perror("fopen");
- continue;
- }
- if (fgets(line, 1034, fp) == NULL) {
- perror("fgets");
- fclose(fp);
- continue;
- }
- if (!checkmask(line, "&&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&& &&&&&&&&\n")) {
- fprintf(stderr, "Bad cache file\n");
- fclose(fp);
- continue;
- }
- date = hex2sec(line);
- lmod = hex2sec(line + 9);
- expire = hex2sec(line + 18);
- ver = hex2sec(line + 27);
- len = hex2sec(line + 35);
- if (fgets(line, 1034, fp) == NULL) {
- perror("fgets");
- fclose(fp);
- continue;
- }
- fclose(fp);
- i = strlen(line);
- if (strncmp(line, "X-URL: ", 7) != 0 || line[i - 1] != '\n') {
- fprintf(stderr, "Bad cache file\n");
- continue;
- }
- line[i - 1] = '\0';
- if (date != -1) {
- ts = *gmtime(&date);
- strftime(sdate, 30, time_format, &ts);
- }
- else
- strcpy(sdate, "-");
-
- if (lmod != -1) {
- ts = *gmtime(&lmod);
- strftime(slmod, 30, time_format, &ts);
- }
- else
- strcpy(slmod, "-");
-
- if (expire != -1) {
- ts = *gmtime(&expire);
- strftime(sexpire, 30, time_format, &ts);
- }
- else
- strcpy(sexpire, "-");
-
- printf("%s: %d; %s %s %s\n", line + 7, ver, sdate, slmod, sexpire);
- }
-
- closedir(d);
- return 0;
-}
diff --git a/test/tcpdumpscii.txt b/test/tcpdumpscii.txt
deleted file mode 100644
index 9c1060edab..0000000000
--- a/test/tcpdumpscii.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-
-From marcs@znep.com Fri Apr 17 15:16:16 1998
-Date: Sat, 22 Nov 1997 20:44:10 -0700 (MST)
-From: Marc Slemko <marcs@znep.com>
-To: TLOSAP <new-httpd@apache.org>
-Subject: Re: Getting ethernet packets content under FreeBSD? (fwd)
-Reply-To: new-httpd@apache.org
-
-Anyone too lazy to hack tcpdump (eg. my tcpdump has a -X option to display
-the data in ASCII) can use something like the below to grab HTTP headers
-when debugging broken clients.
-
-Nothing complicated, but handy.
-
----------- Forwarded message ----------
-Date: Sat, 22 Nov 1997 14:35:23 PST
-From: Bill Fenner <fenner@parc.xerox.com>
-To: Nate Williams <nate@mt.sri.com>
-Cc: bmah@ca.sandia.gov, hackers@FreeBSD.ORG
-Subject: Re: Getting ethernet packets content under FreeBSD?
-
-I usually just use this perl script, which I call "tcpdumpscii".
-Then run "tcpdumpscii -s 1500 -x [other tcpdump args]".
-
- Bill
-
-#!/import/misc/bin/perl
-#
-#
-open(TCPDUMP,"tcpdump -l @ARGV|");
-while (<TCPDUMP>) {
- if (/^\s+(\S\S)+/) {
- $sav = $_;
- $asc = "";
- while (s/\s*(\S\S)\s*//) {
- $i = hex($1);
- if ($i < 32 || $i > 126) {
- $asc .= ".";
- } else {
- $asc .= pack(C,hex($1));
- }
- }
- $foo = "." x length($asc);
- $_ = $sav;
- s/\t/ /g;
- s/^$foo/$asc/;
- }
- print;
-}
-
diff --git a/test/test-writev.c b/test/test-writev.c
deleted file mode 100644
index 852c701766..0000000000
--- a/test/test-writev.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- test-writev: use this to figure out if your writev() does intelligent
- things on the network. Some writev()s when given multiple buffers
- will break them up into multiple packets, which is a waste.
-
- Linux prior to 2.0.31 has this problem.
-
- Solaris 2.5, 2.5.1 doesn't appear to, 2.6 hasn't been tested.
-
- IRIX 5.3 doesn't have this problem.
-
- To use this you want to snoop the wire with tcpdump, and then run
- "test-writev a.b.c.d port#" ... against some TCP service on another
- box. For example you can run it against port 80 on another server.
- You want to look to see how many data packets are sent, you're hoping
- only one of size 300 is sent.
-*/
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <arpa/inet.h>
-#include <sys/uio.h>
-#include <errno.h>
-
-#ifndef INADDR_NONE
-#define INADDR_NONE (-1ul)
-#endif
-
-void main( int argc, char **argv )
-{
- struct sockaddr_in server_addr;
- int s;
- struct iovec vector[3];
- char buf[100];
- int i;
- const int just_say_no = 1;
-
- if( argc != 3 ) {
-usage:
- fprintf( stderr, "usage: test-writev a.b.c.d port#\n" );
- exit( 1 );
- }
- server_addr.sin_family = AF_INET;
- server_addr.sin_addr.s_addr = inet_addr( argv[1] );
- if( server_addr.sin_addr.s_addr == INADDR_NONE ) {
- fprintf( stderr, "bogus address\n" );
- goto usage;
- }
- server_addr.sin_port = htons( atoi( argv[2] ) );
-
- s = socket( AF_INET, SOCK_STREAM, 0 );
- if( s < 0 ) {
- perror("socket");
- exit(1);
- }
- if( connect( s, (struct sockaddr *)&server_addr, sizeof( server_addr ) )
- != 0 ) {
- perror("connect");
- exit(1);
- }
-
- if( setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char*)&just_say_no,
- sizeof(just_say_no)) != 0 ) {
- perror( "TCP_NODELAY" );
- exit(1);
- }
- /* now build up a two part writev and write it out */
- for( i = 0; i < sizeof( buf ); ++i ) {
- buf[i] = 'x';
- }
- vector[0].iov_base = buf;
- vector[0].iov_len = sizeof(buf);
- vector[1].iov_base = buf;
- vector[1].iov_len = sizeof(buf);
- vector[2].iov_base = buf;
- vector[2].iov_len = sizeof(buf);
-
- i = writev( s, &vector[0], 3 );
- fprintf( stdout, "i=%d, errno=%d\n", i, errno );
- exit(0);
-}
diff --git a/test/test_date.c b/test/test_date.c
deleted file mode 100644
index 4beaf7943b..0000000000
--- a/test/test_date.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/* This program tests the parseHTTPdate routine in ../main/util_date.c.
- *
- * It is only semiautomated in that I would run it, modify the code to
- * use a different algorithm or seed, recompile and run again, etc.
- * Obviously it should use an argument for that, but I never got around
- * to changing the implementation.
- *
- * gcc -g -O2 -I../main -o test_date ../main/util_date.o test_date.c
- * test_date | egrep '^No '
- *
- * Roy Fielding, 1996
- */
-#define API_EXPORT(x) x
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "util_date.h"
-
-static const long year2secs[] = {
- 0L, /* 1970 */
- 31536000L, /* 1971 */
- 63072000L, /* 1972 */
- 94694400L, /* 1973 */
- 126230400L, /* 1974 */
- 157766400L, /* 1975 */
- 189302400L, /* 1976 */
- 220924800L, /* 1977 */
- 252460800L, /* 1978 */
- 283996800L, /* 1979 */
- 315532800L, /* 1980 */
- 347155200L, /* 1981 */
- 378691200L, /* 1982 */
- 410227200L, /* 1983 */
- 441763200L, /* 1984 */
- 473385600L, /* 1985 */
- 504921600L, /* 1986 */
- 536457600L, /* 1987 */
- 567993600L, /* 1988 */
- 599616000L, /* 1989 */
- 631152000L, /* 1990 */
- 662688000L, /* 1991 */
- 694224000L, /* 1992 */
- 725846400L, /* 1993 */
- 757382400L, /* 1994 */
- 788918400L, /* 1995 */
- 820454400L, /* 1996 */
- 852076800L, /* 1997 */
- 883612800L, /* 1998 */
- 915148800L, /* 1999 */
- 946684800L, /* 2000 */
- 978307200L, /* 2001 */
- 1009843200L, /* 2002 */
- 1041379200L, /* 2003 */
- 1072915200L, /* 2004 */
- 1104537600L, /* 2005 */
- 1136073600L, /* 2006 */
- 1167609600L, /* 2007 */
- 1199145600L, /* 2008 */
- 1230768000L, /* 2009 */
- 1262304000L, /* 2010 */
- 1293840000L, /* 2011 */
- 1325376000L, /* 2012 */
- 1356998400L, /* 2013 */
- 1388534400L, /* 2014 */
- 1420070400L, /* 2015 */
- 1451606400L, /* 2016 */
- 1483228800L, /* 2017 */
- 1514764800L, /* 2018 */
- 1546300800L, /* 2019 */
- 1577836800L, /* 2020 */
- 1609459200L, /* 2021 */
- 1640995200L, /* 2022 */
- 1672531200L, /* 2023 */
- 1704067200L, /* 2024 */
- 1735689600L, /* 2025 */
- 1767225600L, /* 2026 */
- 1798761600L, /* 2027 */
- 1830297600L, /* 2028 */
- 1861920000L, /* 2029 */
- 1893456000L, /* 2030 */
- 1924992000L, /* 2031 */
- 1956528000L, /* 2032 */
- 1988150400L, /* 2033 */
- 2019686400L, /* 2034 */
- 2051222400L, /* 2035 */
- 2082758400L, /* 2036 */
- 2114380800L, /* 2037 */
- 2145916800L /* 2038 */
-};
-
-const char month_snames[12][4] = {
- "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"
-};
-
-void gm_timestr_822(char *ts, time_t sec)
-{
- static const char *const days[7]=
- {"Sun","Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
- struct tm *tms;
-
- tms = gmtime(&sec);
-
- sprintf(ts, "%s, %.2d %s %d %.2d:%.2d:%.2d GMT", days[tms->tm_wday],
- tms->tm_mday, month_snames[tms->tm_mon], tms->tm_year + 1900,
- tms->tm_hour, tms->tm_min, tms->tm_sec);
-}
-
-void gm_timestr_850(char *ts, time_t sec)
-{
- static const char *const days[7]=
- {"Sunday","Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
- struct tm *tms;
- int year;
-
- tms = gmtime(&sec);
-
- year = tms->tm_year;
- if (year >= 100) year -= 100;
-
- sprintf(ts, "%s, %.2d-%s-%.2d %.2d:%.2d:%.2d GMT", days[tms->tm_wday],
- tms->tm_mday, month_snames[tms->tm_mon], year,
- tms->tm_hour, tms->tm_min, tms->tm_sec);
-}
-
-void gm_timestr_ccc(char *ts, time_t sec)
-{
- static const char *const days[7]=
- {"Sun","Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
- struct tm *tms;
-
- tms = gmtime(&sec);
-
- sprintf(ts, "%s %s %2d %.2d:%.2d:%.2d %d", days[tms->tm_wday],
- month_snames[tms->tm_mon], tms->tm_mday,
- tms->tm_hour, tms->tm_min, tms->tm_sec, tms->tm_year + 1900);
-}
-
-int main (void)
-{
- int year, i;
- time_t guess;
- time_t offset = 0;
- /* time_t offset = 0; */
- /* time_t offset = ((31 + 28) * 24 * 3600) - 1; */
- time_t secstodate, newsecs;
- char datestr[50];
-
- for (year = 1970; year < 2038; ++year) {
- secstodate = (time_t)year2secs[year - 1970] + offset;
- gm_timestr_822(datestr, secstodate);
- newsecs = parseHTTPdate(datestr);
- if (secstodate == newsecs)
- printf("Yes %4d %11ld %s\n", year, (long)secstodate, datestr);
- else if (newsecs == BAD_DATE)
- printf("No %4d %11ld %11ld %s\n", year, (long)secstodate,
- (long)newsecs, datestr);
- else
- printf("No* %4d %11ld %11ld %s\n", year, (long)secstodate,
- (long)newsecs, datestr);
- }
-
- srand48(978245L);
-
- for (i = 0; i < 10000; ++i) {
- guess = (time_t)mrand48();
- if (guess < 0) guess *= -1;
- secstodate = guess + offset;
- gm_timestr_822(datestr, secstodate);
- newsecs = parseHTTPdate(datestr);
- if (secstodate == newsecs)
- printf("Yes %11ld %s\n", (long)secstodate, datestr);
- else if (newsecs == BAD_DATE)
- printf("No %11ld %11ld %s\n", (long)secstodate,
- (long)newsecs, datestr);
- else
- printf("No* %11ld %11ld %s\n", (long)secstodate,
- (long)newsecs, datestr);
- }
- exit(0);
-}
diff --git a/test/test_find.c b/test/test_find.c
deleted file mode 100644
index f4141e9e44..0000000000
--- a/test/test_find.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* This program tests the ap_find_list_item routine in ../main/util.c.
- *
- * The defines in this sample compile line are specific to Roy's system.
- * They should match whatever was used to compile Apache first.
- *
- gcc -g -O2 -I../os/unix -I../include -o test_find \
- -DSOLARIS2=250 -Wall -DALLOC_DEBUG -DPOOL_DEBUG \
- ../main/alloc.o ../main/buff.o ../main/util.o \
- ../ap/libap.a -lsocket -lnsl test_find.c
- *
- * Roy Fielding, 1999
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include "httpd.h"
-#include "apr_general.h"
-
-/*
- * Dummy a bunch of stuff just to get a compile
- */
-uid_t ap_user_id;
-gid_t ap_group_id;
-void *ap_dummy_mutex = &ap_dummy_mutex;
-char *ap_server_argv0;
-
-API_EXPORT(void) ap_block_alarms(void)
-{
- ;
-}
-
-API_EXPORT(void) ap_unblock_alarms(void)
-{
- ;
-}
-
-API_EXPORT(void) ap_log_error(const char *file, int line, int level,
- const request_rec *r, const char *fmt, ...)
-{
- ;
-}
-
-int main (void)
-{
- ap_context_t *p;
- char line[512];
- char tok[512];
-
- p = ap_init_alloc();
-
- printf("Enter field value to find items within:\n");
- if (!gets(line))
- exit(0);
-
- printf("Enter search item:\n");
- while (gets(tok)) {
- printf(" [%s] == %s\n", tok, ap_find_list_item(p, line, tok)
- ? "Yes" : "No");
- printf("Enter search item:\n");
- }
-
- exit(0);
-}
diff --git a/test/test_limits.c b/test/test_limits.c
deleted file mode 100644
index 8d76ce2e08..0000000000
--- a/test/test_limits.c
+++ /dev/null
@@ -1,200 +0,0 @@
-/**************************************************************
- * test_limits.c
- *
- * A simple program for sending abusive requests to a server, based
- * on the sioux.c exploit code that this nimrod posted (see below).
- * Roy added options for testing long header fieldsize (-t h), long
- * request-lines (-t r), and a long request body (-t b).
- *
- * FreeBSD 2.2.x, FreeBSD 3.0, IRIX 5.3, IRIX 6.2:
- * gcc -o test_limits test_limits.c
- *
- * Solaris 2.5.1:
- * gcc -o test_limits test_limits.c -lsocket -lnsl
- *
- *
- * Message-ID: <861zqspvtw.fsf@niobe.ewox.org>
- * Date: Fri, 7 Aug 1998 19:04:27 +0200
- * Sender: Bugtraq List <BUGTRAQ@netspace.org>
- * From: Dag-Erling Coidan =?ISO-8859-1?Q?Sm=F8rgrav?= <finrod@EWOX.ORG>
- * Subject: YA Apache DoS attack
- *
- * Copyright (c) 1998 Dag-Erling Codan Smrgrav
- * 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
- * in this position and unchanged.
- * 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. The name of the author may not be used to endorse or promote products
- * derived from this software withough specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- *
- */
-
-/*
- * Kudos to Mark Huizer who originally suggested this on freebsd-current
- */
-
-#include <sys/types.h>
-#include <sys/uio.h>
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <netdb.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#define TEST_LONG_REQUEST_LINE 1
-#define TEST_LONG_REQUEST_FIELDS 2
-#define TEST_LONG_REQUEST_FIELDSIZE 3
-#define TEST_LONG_REQUEST_BODY 4
-
-void
-usage(void)
-{
- fprintf(stderr,
- "usage: test_limits [-t (r|n|h|b)] [-a address] [-p port] [-n num]\n");
- exit(1);
-}
-
-int
-main(int argc, char *argv[])
-{
- struct sockaddr_in sin;
- struct hostent *he;
- FILE *f;
- int o, sd;
-
- /* default parameters */
- char *addr = "localhost";
- int port = 80;
- int num = 1000;
- int testtype = TEST_LONG_REQUEST_FIELDS;
-
- /* get options */
- while ((o = getopt(argc, argv, "t:a:p:n:")) != EOF)
- switch (o) {
- case 't':
- if (*optarg == 'r')
- testtype = TEST_LONG_REQUEST_LINE;
- else if (*optarg == 'n')
- testtype = TEST_LONG_REQUEST_FIELDS;
- else if (*optarg == 'h')
- testtype = TEST_LONG_REQUEST_FIELDSIZE;
- else if (*optarg == 'b')
- testtype = TEST_LONG_REQUEST_BODY;
- break;
- case 'a':
- addr = optarg;
- break;
- case 'p':
- port = atoi(optarg);
- break;
- case 'n':
- num = atoi(optarg);
- break;
- default:
- usage();
- }
-
- if (argc != optind)
- usage();
-
- /* connect */
- if ((he = gethostbyname(addr)) == NULL) {
- perror("gethostbyname");
- exit(1);
- }
- bzero(&sin, sizeof(sin));
- bcopy(he->h_addr, (char *)&sin.sin_addr, he->h_length);
- sin.sin_family = he->h_addrtype;
- sin.sin_port = htons(port);
-
- if ((sd = socket(sin.sin_family, SOCK_STREAM, IPPROTO_TCP)) == -1) {
- perror("socket");
- exit(1);
- }
-
- if (connect(sd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
- perror("connect");
- exit(1);
- }
-
- if ((f = fdopen(sd, "r+")) == NULL) {
- perror("fdopen");
- exit(1);
- }
-
- /* attack! */
- fprintf(stderr, "Testing like a plague of locusts on %s\n", addr);
-
- if (testtype == TEST_LONG_REQUEST_LINE) {
- fprintf(f, "GET ");
- while (num-- && !ferror(f)) {
- fprintf(f, "/123456789");
- fflush(f);
- }
- fprintf(f, " HTTP/1.0\r\n\r\n");
- }
- else {
- fprintf(f, "GET /fred/foo HTTP/1.0\r\n");
-
- if (testtype == TEST_LONG_REQUEST_FIELDSIZE) {
- while (num-- && !ferror(f)) {
- fprintf(f, "User-Agent: sioux");
- fflush(f);
- }
- fprintf(f, "\r\n");
- }
- else if (testtype == TEST_LONG_REQUEST_FIELDS) {
- while (num-- && !ferror(f))
- fprintf(f, "User-Agent: sioux\r\n");
- fprintf(f, "\r\n");
- }
- else if (testtype == TEST_LONG_REQUEST_BODY) {
- fprintf(f, "User-Agent: sioux\r\n");
- fprintf(f, "Content-Length: 33554433\r\n");
- fprintf(f, "\r\n");
- while (num-- && !ferror(f))
- fprintf(f, "User-Agent: sioux\r\n");
- }
- else {
- fprintf(f, "\r\n");
- }
- }
- fflush(f);
-
- {
- ssize_t len;
- char buff[512];
-
- while ((len = read(sd, buff, 512)) > 0)
- len = write(1, buff, len);
- }
- if (ferror(f)) {
- perror("fprintf");
- exit(1);
- }
-
- fclose(f);
- exit(0);
-}
diff --git a/test/test_parser.c b/test/test_parser.c
deleted file mode 100644
index 29d53feef2..0000000000
--- a/test/test_parser.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* This program tests the ap_get_list_item routine in ../main/util.c.
- *
- * The defines in this sample compile line are specific to Roy's system.
- * They should match whatever was used to compile Apache first.
- *
- gcc -g -O2 -I../os/unix -I../include -o test_parser \
- -DSOLARIS2=250 -Wall -DALLOC_DEBUG -DPOOL_DEBUG \
- ../main/alloc.o ../main/buff.o ../main/util.o \
- ../ap/libap.a -lsocket -lnsl test_parser.c
- *
- * Roy Fielding, 1999
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include "httpd.h"
-#include "apr_general.h"
-
-/*
- * Dummy a bunch of stuff just to get a compile
- */
-uid_t ap_user_id;
-gid_t ap_group_id;
-void *ap_dummy_mutex = &ap_dummy_mutex;
-char *ap_server_argv0;
-
-API_EXPORT(void) ap_block_alarms(void)
-{
- ;
-}
-
-API_EXPORT(void) ap_unblock_alarms(void)
-{
- ;
-}
-
-API_EXPORT(void) ap_log_error(const char *file, int line, int level,
- const request_rec *r, const char *fmt, ...)
-{
- ;
-}
-
-int main (void)
-{
- ap_context_t *p;
- const char *field;
- char *newstr;
- char instr[512];
-
- p = ap_init_alloc();
-
- while (gets(instr)) {
- printf(" [%s] ==\n", instr);
- field = instr;
- while ((newstr = ap_get_list_item(p, &field)) != NULL)
- printf(" <%s> ..\n", newstr);
- }
-
- exit(0);
-}
diff --git a/test/test_select.c b/test/test_select.c
deleted file mode 100644
index 8c0a6a4363..0000000000
--- a/test/test_select.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* This is just a quick test program to see how long a wait is
- * produced by a select loop with an exponential backoff.
- *
- * gcc -g -O2 -o test_select test_select.c
- * test_select
- *
- * Roy Fielding, 1996
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-
-int main (void)
-{
- int srv;
- long waittime = 4096;
- struct timeval tv;
-
- printf("Start\n");
- while ((waittime > 0) && (waittime < 3000000)) {
- printf("%d\n", waittime);
- tv.tv_sec = waittime/1000000;
- tv.tv_usec = waittime%1000000;
- waittime <<= 1;
- srv = select(0, NULL, NULL, NULL, &tv);
- }
- printf("End\n");
- exit(0);
-}
diff --git a/test/time-sem.c b/test/time-sem.c
deleted file mode 100644
index 7800844ed2..0000000000
--- a/test/time-sem.c
+++ /dev/null
@@ -1,572 +0,0 @@
-/*
-time-sem.c has the basics of the semaphores we use in http_main.c. It's
-intended for timing differences between various methods on an
-architecture. In practice we've found many things affect which semaphore
-to be used:
-
- - NFS filesystems absolutely suck for fcntl() and flock()
-
- - uslock absolutely sucks on single-processor IRIX boxes, but
- absolutely rocks on multi-processor boxes. The converse
- is true for fcntl. sysvsem seems a moderate balance.
-
- - Under Solaris you can't have too many processes use SEM_UNDO, there
- might be a tuneable somewhere that increases the limit from 29.
- We're not sure what the tunable is, so there's a define
- NO_SEM_UNDO which can be used to simulate us trapping/blocking
- signals to be able to properly release the semaphore on a clean
- child death. You'll also need to define NEED_UNION_SEMUN
- under solaris.
-
-You'll need to define USE_SHMGET_SCOREBOARD if anonymous shared mmap()
-doesn't work on your system (i.e. linux).
-
-argv[1] is the #children, argv[2] is the #iterations per child
-
-You should run each over many different #children inputs, and choose
-#iter such that the program runs for at least a second or so... or even
-longer depending on your patience.
-
-compile with:
-
-gcc -o time-FCNTL -Wall -O time-sem.c -DUSE_FCNTL_SERIALIZED_ACCEPT
-gcc -o time-FLOCK -Wall -O time-sem.c -DUSE_FLOCK_SERIALIZED_ACCEPT
-gcc -o time-SYSVSEM -Wall -O time-sem.c -DUSE_SYSVSEM_SERIALIZED_ACCEPT
-gcc -o time-SYSVSEM2 -Wall -O time-sem.c -DUSE_SYSVSEM_SERIALIZED_ACCEPT -DNO_SEM_UNDO
-gcc -o time-PTHREAD -Wall -O time-sem.c -DUSE_PTHREAD_SERIALIZED_ACCEPT -lpthread
-gcc -o time-USLOCK -Wall -O time-sem.c -DUSE_USLOCK_SERIALIZED_ACCEPT
-
-not all versions work on all systems.
-*/
-
-#include <errno.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <sys/wait.h>
-#include <sys/mman.h>
-#include <signal.h>
-
-#if defined(USE_FCNTL_SERIALIZED_ACCEPT)
-
-static struct flock lock_it;
-static struct flock unlock_it;
-
-static int fcntl_fd=-1;
-
-#define accept_mutex_child_init()
-#define accept_mutex_cleanup()
-
-/*
- * Initialize mutex lock.
- * Must be safe to call this on a restart.
- */
-void
-accept_mutex_init(void)
-{
-
- lock_it.l_whence = SEEK_SET; /* from current point */
- lock_it.l_start = 0; /* -"- */
- lock_it.l_len = 0; /* until end of file */
- lock_it.l_type = F_WRLCK; /* set exclusive/write lock */
- lock_it.l_pid = 0; /* pid not actually interesting */
- unlock_it.l_whence = SEEK_SET; /* from current point */
- unlock_it.l_start = 0; /* -"- */
- unlock_it.l_len = 0; /* until end of file */
- unlock_it.l_type = F_UNLCK; /* set exclusive/write lock */
- unlock_it.l_pid = 0; /* pid not actually interesting */
-
- printf("opening test-lock-thing in current directory\n");
- fcntl_fd = open("test-lock-thing", O_CREAT | O_WRONLY | O_EXCL, 0644);
- if (fcntl_fd == -1)
- {
- perror ("open");
- fprintf (stderr, "Cannot open lock file: %s\n", "test-lock-thing");
- exit (1);
- }
- unlink("test-lock-thing");
-}
-
-void accept_mutex_on(void)
-{
- int ret;
-
- while ((ret = fcntl(fcntl_fd, F_SETLKW, &lock_it)) < 0 && errno == EINTR)
- continue;
-
- if (ret < 0) {
- perror ("fcntl lock_it");
- exit(1);
- }
-}
-
-void accept_mutex_off(void)
-{
- if (fcntl (fcntl_fd, F_SETLKW, &unlock_it) < 0)
- {
- perror ("fcntl unlock_it");
- exit(1);
- }
-}
-
-#elif defined(USE_FLOCK_SERIALIZED_ACCEPT)
-
-#include <sys/file.h>
-
-static int flock_fd=-1;
-
-#define FNAME "test-lock-thing"
-
-/*
- * Initialize mutex lock.
- * Must be safe to call this on a restart.
- */
-void accept_mutex_init(void)
-{
-
- printf("opening " FNAME " in current directory\n");
- flock_fd = open(FNAME, O_CREAT | O_WRONLY | O_EXCL, 0644);
- if (flock_fd == -1)
- {
- perror ("open");
- fprintf (stderr, "Cannot open lock file: %s\n", "test-lock-thing");
- exit (1);
- }
-}
-
-void accept_mutex_child_init(void)
-{
- flock_fd = open(FNAME, O_WRONLY, 0600);
- if (flock_fd == -1) {
- perror("open");
- exit(1);
- }
-}
-
-void accept_mutex_cleanup(void)
-{
- unlink(FNAME);
-}
-
-void accept_mutex_on(void)
-{
- int ret;
-
- while ((ret = flock(flock_fd, LOCK_EX)) < 0 && errno == EINTR)
- continue;
-
- if (ret < 0) {
- perror ("flock(LOCK_EX)");
- exit(1);
- }
-}
-
-void accept_mutex_off(void)
-{
- if (flock (flock_fd, LOCK_UN) < 0)
- {
- perror ("flock(LOCK_UN)");
- exit(1);
- }
-}
-
-#elif defined (USE_SYSVSEM_SERIALIZED_ACCEPT)
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-
-static int sem_id = -1;
-#ifdef NO_SEM_UNDO
-static sigset_t accept_block_mask;
-static sigset_t accept_previous_mask;
-#endif
-
-#define accept_mutex_child_init()
-#define accept_mutex_cleanup()
-
-void accept_mutex_init(void)
-{
-#ifdef NEED_UNION_SEMUN
- /* believe it or not, you need to define this under solaris */
- union semun {
- int val;
- struct semid_ds *buf;
- ushort *array;
- };
-#endif
-
- union semun ick;
-
- sem_id = semget(999, 1, IPC_CREAT | 0666);
- if (sem_id < 0) {
- perror ("semget");
- exit (1);
- }
- ick.val = 1;
- if (semctl(sem_id, 0, SETVAL, ick) < 0) {
- perror ("semctl");
- exit(1);
- }
-#ifdef NO_SEM_UNDO
- sigfillset(&accept_block_mask);
- sigdelset(&accept_block_mask, SIGHUP);
- sigdelset(&accept_block_mask, SIGTERM);
- sigdelset(&accept_block_mask, SIGUSR1);
-#endif
-}
-
-void accept_mutex_on()
-{
- struct sembuf op;
-
-#ifdef NO_SEM_UNDO
- if (sigprocmask(SIG_BLOCK, &accept_block_mask, &accept_previous_mask)) {
- perror("sigprocmask(SIG_BLOCK)");
- exit (1);
- }
- op.sem_flg = 0;
-#else
- op.sem_flg = SEM_UNDO;
-#endif
- op.sem_num = 0;
- op.sem_op = -1;
- if (semop(sem_id, &op, 1) < 0) {
- perror ("accept_mutex_on");
- exit (1);
- }
-}
-
-void accept_mutex_off()
-{
- struct sembuf op;
-
- op.sem_num = 0;
- op.sem_op = 1;
-#ifdef NO_SEM_UNDO
- op.sem_flg = 0;
-#else
- op.sem_flg = SEM_UNDO;
-#endif
- if (semop(sem_id, &op, 1) < 0) {
- perror ("accept_mutex_off");
- exit (1);
- }
-#ifdef NO_SEM_UNDO
- if (sigprocmask(SIG_SETMASK, &accept_previous_mask, NULL)) {
- perror("sigprocmask(SIG_SETMASK)");
- exit (1);
- }
-#endif
-}
-
-#elif defined (USE_PTHREAD_SERIALIZED_ACCEPT)
-
-/* note: pthread mutexes aren't released on child death, hence the
- * signal goop ... in a real implementation we'd do special things
- * during hup, term, usr1.
- */
-
-#include <pthread.h>
-
-static pthread_mutex_t *mutex;
-static sigset_t accept_block_mask;
-static sigset_t accept_previous_mask;
-
-#define accept_mutex_child_init()
-#define accept_mutex_cleanup()
-
-void accept_mutex_init(void)
-{
- pthread_mutexattr_t mattr;
- int fd;
-
- fd = open ("/dev/zero", O_RDWR);
- if (fd == -1) {
- perror ("open(/dev/zero)");
- exit (1);
- }
- mutex = (pthread_mutex_t *)mmap ((caddr_t)0, sizeof (*mutex),
- PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
- if (mutex == (void *)(caddr_t)-1) {
- perror ("mmap");
- exit (1);
- }
- close (fd);
- if (pthread_mutexattr_init(&mattr)) {
- perror ("pthread_mutexattr_init");
- exit (1);
- }
- if (pthread_mutexattr_setpshared(&mattr, PTHREAD_PROCESS_SHARED)) {
- perror ("pthread_mutexattr_setpshared");
- exit (1);
- }
- if (pthread_mutex_init(mutex, &mattr)) {
- perror ("pthread_mutex_init");
- exit (1);
- }
- sigfillset(&accept_block_mask);
- sigdelset(&accept_block_mask, SIGHUP);
- sigdelset(&accept_block_mask, SIGTERM);
- sigdelset(&accept_block_mask, SIGUSR1);
-}
-
-void accept_mutex_on()
-{
- if (sigprocmask(SIG_BLOCK, &accept_block_mask, &accept_previous_mask)) {
- perror("sigprocmask(SIG_BLOCK)");
- exit (1);
- }
- if (pthread_mutex_lock (mutex)) {
- perror ("pthread_mutex_lock");
- exit (1);
- }
-}
-
-void accept_mutex_off()
-{
- if (pthread_mutex_unlock (mutex)) {
- perror ("pthread_mutex_unlock");
- exit (1);
- }
- if (sigprocmask(SIG_SETMASK, &accept_previous_mask, NULL)) {
- perror("sigprocmask(SIG_SETMASK)");
- exit (1);
- }
-}
-
-#elif defined (USE_USLOCK_SERIALIZED_ACCEPT)
-
-#include <ulocks.h>
-
-static usptr_t *us = NULL;
-static ulock_t uslock = NULL;
-
-#define accept_mutex_child_init()
-#define accept_mutex_cleanup()
-
-void accept_mutex_init(void)
-{
- ptrdiff_t old;
- /* default is 8 */
-#define CONF_INITUSERS_MAX 15
- if ((old = usconfig(CONF_INITUSERS, CONF_INITUSERS_MAX)) == -1) {
- perror("usconfig");
- exit(-1);
- }
- if ((old = usconfig(CONF_LOCKTYPE, US_NODEBUG)) == -1) {
- perror("usconfig");
- exit(-1);
- }
- if ((old = usconfig(CONF_ARENATYPE, US_SHAREDONLY)) == -1) {
- perror("usconfig");
- exit(-1);
- }
- if ((us = usinit("/dev/zero")) == NULL) {
- perror("usinit");
- exit(-1);
- }
- if ((uslock = usnewlock(us)) == NULL) {
- perror("usnewlock");
- exit(-1);
- }
-}
-void accept_mutex_on()
-{
- switch(ussetlock(uslock)) {
- case 1:
- /* got lock */
- break;
- case 0:
- fprintf(stderr, "didn't get lock\n");
- exit(-1);
- case -1:
- perror("ussetlock");
- exit(-1);
- }
-}
-void accept_mutex_off()
-{
- if (usunsetlock(uslock) == -1) {
- perror("usunsetlock");
- exit(-1);
- }
-}
-#endif
-
-
-#ifndef USE_SHMGET_SCOREBOARD
-static void *get_shared_mem(size_t size)
-{
- void *result;
-
- /* allocate shared memory for the shared_counter */
- result = (unsigned long *)mmap ((caddr_t)0, size,
- PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
- if (result == (void *)(caddr_t)-1) {
- perror ("mmap");
- exit (1);
- }
- return result;
-}
-#else
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-
-static void *get_shared_mem(size_t size)
-{
- key_t shmkey = IPC_PRIVATE;
- int shmid = -1;
- void *result;
-#ifdef MOVEBREAK
- char *obrk;
-#endif
-
- if ((shmid = shmget(shmkey, size, IPC_CREAT | SHM_R | SHM_W)) == -1) {
- perror("shmget");
- exit(1);
- }
-
-#ifdef MOVEBREAK
- /*
- * Some SysV systems place the shared segment WAY too close
- * to the dynamic memory break point (sbrk(0)). This severely
- * limits the use of malloc/sbrk in the program since sbrk will
- * refuse to move past that point.
- *
- * To get around this, we move the break point "way up there",
- * attach the segment and then move break back down. Ugly
- */
- if ((obrk = sbrk(MOVEBREAK)) == (char *) -1) {
- perror("sbrk");
- }
-#endif
-
-#define BADSHMAT ((void *)(-1))
- if ((result = shmat(shmid, 0, 0)) == BADSHMAT) {
- perror("shmat");
- }
- /*
- * We must avoid leaving segments in the kernel's
- * (small) tables.
- */
- if (shmctl(shmid, IPC_RMID, NULL) != 0) {
- perror("shmctl(IPC_RMID)");
- }
- if (result == BADSHMAT) /* now bailout */
- exit(1);
-
-#ifdef MOVEBREAK
- if (obrk == (char *) -1)
- return; /* nothing else to do */
- if (sbrk(-(MOVEBREAK)) == (char *) -1) {
- perror("sbrk 2");
- }
-#endif
- return result;
-}
-#endif
-
-#ifdef _POSIX_PRIORITY_SCHEDULING
-/* don't ask */
-#define _P __P
-#include <sched.h>
-#define YIELD sched_yield()
-#else
-#define YIELD do { struct timeval zero; zero.tv_sec = zero.tv_usec = 0; select(0,0,0,0,&zero); } while(0)
-#endif
-
-void main (int argc, char **argv)
-{
- int num_iter;
- int num_child;
- int i;
- struct timeval first;
- struct timeval last;
- long ms;
- int pid;
- unsigned long *shared_counter;
-
- if (argc != 3) {
- fprintf (stderr, "Usage: time-sem num-child num iter\n");
- exit (1);
- }
-
- num_child = atoi (argv[1]);
- num_iter = atoi (argv[2]);
-
- /* allocate shared memory for the shared_counter */
- shared_counter = get_shared_mem(sizeof(*shared_counter));
-
- /* initialize counter to 0 */
- *shared_counter = 0;
-
- accept_mutex_init ();
-
- /* parent grabs mutex until done spawning children */
- accept_mutex_on ();
-
- for (i = 0; i < num_child; ++i) {
- pid = fork();
- if (pid == 0) {
- /* child, do our thing */
- accept_mutex_child_init();
- for (i = 0; i < num_iter; ++i) {
- unsigned long tmp;
-
- accept_mutex_on ();
- tmp = *shared_counter;
- YIELD;
- *shared_counter = tmp + 1;
- accept_mutex_off ();
- }
- exit (0);
- } else if (pid == -1) {
- perror ("fork");
- exit (1);
- }
- }
-
- /* a quick test to see that nothing is screwed up */
- if (*shared_counter != 0) {
- puts ("WTF! shared_counter != 0 before the children have been started!");
- exit (1);
- }
-
- gettimeofday (&first, NULL);
- /* launch children into action */
- accept_mutex_off ();
- for (i = 0; i < num_child; ++i) {
- if (wait(NULL) == -1) {
- perror ("wait");
- }
- }
- gettimeofday (&last, NULL);
-
- if (*shared_counter != num_child * num_iter) {
- printf ("WTF! shared_counter != num_child * num_iter!\n"
- "shared_counter = %lu\nnum_child = %d\nnum_iter=%d\n",
- *shared_counter,
- num_child, num_iter);
- }
-
- last.tv_sec -= first.tv_sec;
- ms = last.tv_usec - first.tv_usec;
- if (ms < 0) {
- --last.tv_sec;
- ms += 1000000;
- }
- last.tv_usec = ms;
- printf ("%8lu.%06lu\n", last.tv_sec, last.tv_usec);
-
- accept_mutex_cleanup();
-
- exit(0);
-}
-
diff --git a/test/zb.c b/test/zb.c
deleted file mode 100644
index 0a6666eb25..0000000000
--- a/test/zb.c
+++ /dev/null
@@ -1,567 +0,0 @@
-
-/* ZeusBench V1.01
- ===============
-
-This program is Copyright (C) Zeus Technology Limited 1996.
-
-This program may be used and copied freely providing this copyright notice
-is not removed.
-
-This software is provided "as is" and any express or implied waranties,
-including but not limited to, the implied warranties of merchantability and
-fitness for a particular purpose are disclaimed. In no event shall
-Zeus Technology Ltd. be liable for any direct, indirect, incidental, special,
-exemplary, or consequential damaged (including, but not limited to,
-procurement of substitute good or services; loss of use, data, or profits;
-or business interruption) however caused and on 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.
-
- Written by Adam Twiss (adam@zeus.co.uk). March 1996
-
-Thanks to the following people for their input:
- Mike Belshe (mbelshe@netscape.com)
- Michael Campanella (campanella@stevms.enet.dec.com)
-
-*/
-
-/* -------------------- Notes on compiling ------------------------------
-
-This should compile unmodified using gcc on HP-UX, FreeBSD, Linux,
-IRIX, Solaris, AIX and Digital Unix (OSF). On Solaris 2.x you will
-need to compile with "-lnsl -lsocket" options. If you have any
-difficulties compiling then let me know.
-
-On SunOS 4.x.x you may need to compile with -DSUNOS4 to add the following
-two lines of code which appear not to exist in my SunOS headers */
-
-#ifdef SUNOS4
-extern char *optarg;
-extern int optind, opterr, optopt;
-#endif
-
-/* -------------------------------------------------------------------- */
-
-/* affects include files on Solaris */
-#define BSD_COMP
-
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <string.h>
-
-/* ------------------- DEFINITIONS -------------------------- */
-
-/* maximum number of requests on a time limited test */
-#define MAX_REQUESTS 50000
-
-/* good old state machine */
-#define STATE_UNCONNECTED 0
-#define STATE_CONNECTING 1
-#define STATE_READ 2
-
-#define CBUFFSIZE 512
-
-struct connection
-{
- int fd;
- int state;
- int read; /* amount of bytes read */
- int bread; /* amount of body read */
- int length; /* Content-Length value used for keep-alive */
- char cbuff[CBUFFSIZE]; /* a buffer to store server response header */
- int cbx; /* offset in cbuffer */
- int keepalive; /* non-zero if a keep-alive request */
- int gotheader; /* non-zero if we have the entire header in cbuff */
- struct timeval start, connect, done;
-};
-
-struct data
-{
- int read; /* number of bytes read */
- int ctime; /* time in ms to connect */
- int time; /* time in ms for connection */
-};
-
-#define min(a,b) ((a)<(b))?(a):(b)
-#define max(a,b) ((a)>(b))?(a):(b)
-
-/* --------------------- GLOBALS ---------------------------- */
-
-int requests = 1; /* Number of requests to make */
-int concurrency = 1; /* Number of multiple requests to make */
-int tlimit = 0; /* time limit in cs */
-int keepalive = 0; /* try and do keepalive connections */
-char *machine; /* Machine name */
-char *file; /* file name to use */
-char server_name[80]; /* name that server reports */
-int port = 80; /* port to use */
-
-int doclen = 0; /* the length the document should be */
-int totalread = 0; /* total number of bytes read */
-int totalbread = 0; /* totoal amount of entity body read */
-int done=0; /* number of requests we have done */
-int doneka=0; /* number of keep alive connections done */
-int good=0, bad=0; /* number of good and bad requests */
-
-/* store error cases */
-int err_length = 0, err_conn = 0, err_except = 0;
-
-struct timeval start, endtime;
-
-/* global request (and its length) */
-char request[512];
-int reqlen;
-
-/* one global throw-away buffer to read stuff into */
-char buffer[4096];
-
-struct connection *con; /* connection array */
-struct data *stats; /* date for each request */
-
-fd_set readbits, writebits; /* bits for select */
-struct sockaddr_in server; /* server addr structure */
-
-/* --------------------------------------------------------- */
-
-/* simple little function to perror and exit */
-
-static void err(char *s)
-{
- perror(s);
- exit(errno);
-}
-
-/* --------------------------------------------------------- */
-
-/* write out request to a connection - assumes we can write
- (small) request out in one go into our new socket buffer */
-
-void write_request(struct connection *c)
-{
- gettimeofday(&c->connect,0);
- write(c->fd,request, reqlen);
- c->state = STATE_READ;
- FD_SET(c->fd, &readbits);
- FD_CLR(c->fd, &writebits);
-}
-
-/* --------------------------------------------------------- */
-
-/* make an fd non blocking */
-
-void nonblock(int fd)
-{
- int i=1;
- ioctl(fd, FIONBIO, &i);
-}
-
-/* --------------------------------------------------------- */
-
-/* returns the time in ms between two timevals */
-
-int timedif(struct timeval a, struct timeval b)
-{
- register int us,s;
-
- us = a.tv_usec - b.tv_usec;
- us /= 1000;
- s = a.tv_sec - b.tv_sec;
- s *= 1000;
- return s+us;
-}
-
-/* --------------------------------------------------------- */
-
-/* calculate and output results and exit */
-
-void output_results()
-{
- int timetaken;
-
- gettimeofday(&endtime,0);
- timetaken = timedif(endtime, start);
-
- printf("\n---\n");
- printf("Server: %s\n", server_name);
- printf("Document Length: %d\n", doclen);
- printf("Concurency Level: %d\n", concurrency);
- printf("Time taken for tests: %d.%03d seconds\n",
- timetaken/1000, timetaken%1000);
- printf("Complete requests: %d\n", done);
- printf("Failed requests: %d\n", bad);
- if(bad) printf(" (Connect: %d, Length: %d, Exceptions: %d)\n",
- err_conn, err_length, err_except);
- if(keepalive) printf("Keep-Alive requests: %d\n", doneka);
- printf("Bytes transfered: %d\n", totalread);
- printf("HTML transfered: %d\n", totalbread);
-
- /* avoid divide by zero */
- if(timetaken) {
- printf("Requests per seconds: %.2f\n", 1000*(float)(done)/timetaken);
- printf("Transfer rate: %.2f kb/s\n",
- (float)(totalread)/timetaken);
- }
-
- {
- /* work out connection times */
- int i;
- int totalcon=0, total=0;
- int mincon=9999999, mintot=999999;
- int maxcon=0, maxtot=0;
-
- for(i=0; i<requests; i++) {
- struct data s = stats[i];
- mincon = min(mincon, s.ctime);
- mintot = min(mintot, s.time);
- maxcon = max(maxcon, s.ctime);
- maxtot = max(maxtot, s.time);
- totalcon += s.ctime;
- total += s.time;
- }
- printf("\nConnnection Times (ms)\n");
- printf(" min avg max\n");
- printf("Connect: %5d %5d %5d\n",mincon, totalcon/requests, maxcon );
- printf("Total: %5d %5d %5d\n", mintot, total/requests, maxtot);
- printf("---\n\n");
- }
-
- exit(0);
-}
-
-/* --------------------------------------------------------- */
-
-/* start asnchronous non-blocking connection */
-
-void start_connect(struct connection *c)
-{
- c->read = 0;
- c->bread = 0;
- c->keepalive = 0;
- c->cbx = 0;
- c->gotheader = 0;
-
- c->fd = socket(AF_INET, SOCK_STREAM, 0);
- if(c->fd<0) err("socket");
-
- nonblock(c->fd);
- gettimeofday(&c->start,0);
-
- if(connect(c->fd, (struct sockaddr *) &server, sizeof(server))<0) {
- if(errno==EINPROGRESS) {
- c->state = STATE_CONNECTING;
- FD_SET(c->fd, &writebits);
- return;
- }
- else {
- close(c->fd);
- err_conn++;
- if(bad++>10) {
- printf("\nTest aborted after 10 failures\n\n");
- exit(1);
- }
- start_connect(c);
- }
- }
-
- /* connected first time */
- write_request(c);
-}
-
-/* --------------------------------------------------------- */
-
-/* close down connection and save stats */
-
-void close_connection(struct connection *c)
-{
- if(c->read == 0 && c->keepalive) {
- /* server has legitiamately shut down an idle keep alive request */
- good--; /* connection never happend */
- }
- else {
- if(good==1) {
- /* first time here */
- doclen = c->bread;
- } else if (c->bread!=doclen) {
- bad++;
- err_length++;
- }
-
- /* save out time */
- if(done < requests) {
- struct data s;
- gettimeofday(&c->done,0);
- s.read = c->read;
- s.ctime = timedif(c->connect, c->start);
- s.time = timedif(c->done, c->start);
- stats[done++] = s;
- }
- }
-
- close(c->fd);
- FD_CLR(c->fd, &readbits);
- FD_CLR(c->fd, &writebits);
-
- /* connect again */
- start_connect(c);
- return;
-}
-
-/* --------------------------------------------------------- */
-
-/* read data from connection */
-
-void read_connection(struct connection *c)
-{
- int r;
-
- r=read(c->fd,buffer,sizeof(buffer));
- if(r==0 || (r<0 && errno!=EAGAIN)) {
- good++;
- close_connection(c);
- return;
- }
-
- if(r<0 && errno==EAGAIN) return;
-
- c->read += r;
- totalread += r;
-
- if(!c->gotheader) {
- char *s;
- int l=4;
- int space = CBUFFSIZE - c->cbx - 1; /* -1 to allow for 0 terminator */
- int tocopy = (space<r)?space:r;
- memcpy(c->cbuff+c->cbx, buffer, space);
- c->cbx += tocopy; space -= tocopy;
- c->cbuff[c->cbx] = 0; /* terminate for benefit of strstr */
- s = strstr(c->cbuff, "\r\n\r\n");
- /* this next line is so that we talk to NCSA 1.5 which blatantly breaks
- the http specifaction */
- if(!s) { s = strstr(c->cbuff,"\n\n"); l=2; }
-
- if(!s) {
- /* read rest next time */
- if(space)
- return;
- else {
- /* header is in invalid or too big - close connection */
- close(c->fd);
- if(bad++>10) {
- printf("\nTest aborted after 10 failures\n\n");
- exit(1);
- }
- FD_CLR(c->fd, &writebits);
- start_connect(c);
- }
- }
- else {
- /* have full header */
- if(!good) {
- /* this is first time, extract some interesting info */
- char *p, *q;
- p = strstr(c->cbuff, "Server:");
- q = server_name;
- if(p) { p+=8; while(*p>32) *q++ = *p++; }
- *q = 0;
- }
-
- c->gotheader = 1;
- *s = 0; /* terminate at end of header */
- if(keepalive &&
- (strstr(c->cbuff, "Keep-Alive")
- || strstr(c->cbuff, "keep-alive"))) /* for benefit of MSIIS */
- {
- char *cl;
- cl = strstr(c->cbuff, "Content-Length:");
- /* for cacky servers like NCSA which break the spec and send a
- lower case 'l' */
- if(!cl) cl = strstr(c->cbuff, "Content-length:");
- if(cl) {
- c->keepalive=1;
- c->length = atoi(cl+16);
- }
- }
- c->bread += c->cbx - (s+l-c->cbuff) + r-tocopy;
- totalbread += c->bread;
- }
- }
- else {
- /* outside header, everything we have read is entity body */
- c->bread += r;
- totalbread += r;
- }
-
- if(c->keepalive && (c->bread >= c->length)) {
- /* finished a keep-alive connection */
- good++; doneka++;
- /* save out time */
- if(good==1) {
- /* first time here */
- doclen = c->bread;
- } else if(c->bread!=doclen) { bad++; err_length++; }
- if(done < requests) {
- struct data s;
- gettimeofday(&c->done,0);
- s.read = c->read;
- s.ctime = timedif(c->connect, c->start);
- s.time = timedif(c->done, c->start);
- stats[done++] = s;
- }
- c->keepalive = 0; c->length = 0; c->gotheader=0; c->cbx = 0;
- c->read = c->bread = 0;
- write_request(c);
- c->start = c->connect; /* zero connect time with keep-alive */
- }
-}
-
-/* --------------------------------------------------------- */
-
-/* run the tests */
-
-int test()
-{
- struct timeval timeout, now;
- fd_set sel_read, sel_except, sel_write;
- int i;
-
- {
- /* get server information */
- struct hostent *he;
- he = gethostbyname(machine);
- if (!he) err("gethostbyname");
- server.sin_family = he->h_addrtype;
- server.sin_port = htons(port);
- server.sin_addr.s_addr = ((unsigned long *)(he->h_addr_list[0]))[0];
- }
-
- con = malloc(concurrency*sizeof(struct connection));
- memset(con,0,concurrency*sizeof(struct connection));
-
- stats = malloc(requests * sizeof(struct data));
-
- FD_ZERO(&readbits);
- FD_ZERO(&writebits);
-
- /* setup request */
- sprintf(request,"GET %s HTTP/1.0\r\nUser-Agent: ZeusBench/1.0\r\n"
- "%sHost: %s\r\nAccept: */*\r\n\r\n", file,
- keepalive?"Connection: Keep-Alive\r\n":"", machine );
-
- reqlen = strlen(request);
-
- /* ok - lets start */
- gettimeofday(&start,0);
-
- /* initialise lots of requests */
- for(i=0; i<concurrency; i++) start_connect(&con[i]);
-
- while(done<requests) {
- int n;
- /* setup bit arrays */
- memcpy(&sel_except, &readbits, sizeof(readbits));
- memcpy(&sel_read, &readbits, sizeof(readbits));
- memcpy(&sel_write, &writebits, sizeof(readbits));
-
- /* check for time limit expiry */
- gettimeofday(&now,0);
- if(tlimit && timedif(now,start) > (tlimit*1000)) {
- requests=done; /* so stats are correct */
- output_results();
- }
-
- /* Timeout of 30 seconds. */
- timeout.tv_sec=30; timeout.tv_usec=0;
- n=select(256, &sel_read, &sel_write, &sel_except, &timeout);
- if(!n) {
- printf("\nServer timed out\n\n");
- exit(1);
- }
- if(n<1) err("select");
-
- for(i=0; i<concurrency; i++) {
- int s = con[i].fd;
- if(FD_ISSET(s, &sel_except)) {
- bad++;
- err_except++;
- start_connect(&con[i]);
- continue;
- }
- if(FD_ISSET(s, &sel_read)) read_connection(&con[i]);
- if(FD_ISSET(s, &sel_write)) write_request(&con[i]);
- }
- if(done>=requests) output_results();
- }
- return 0;
-}
-
-/* ------------------------------------------------------- */
-
-/* display usage information */
-
-void usage(char *progname) {
- printf("\nZeusBench v1.0\n\n");
- printf("Usage: %s <machine> <file> [-k] [-n requests | -t timelimit (sec)]"
- "\n\t\t[-c concurrency] [-p port] \n",progname);
- printf("Filename should start with a '/' e.g. /index.html\n\n");
- exit(EINVAL);
-}
-
-/* ------------------------------------------------------- */
-
-/* sort out command-line args and call test */
-
-int main(int argc, char **argv) {
- int c;
- if (argc < 3) usage(argv[0]);
-
- machine = argv[1];
- file = argv[2];
- optind = 3;
- while ((c = getopt(argc,argv,"p:n:c:d:t:d:k"))>0) {
- switch(c) {
- case 'd':
- break;
- case 'n':
- requests = atoi(optarg);
- if(!requests) {
- printf("Invalid number of requests\n");
- exit(1);
- }
- break;
- case 'k':
- keepalive=1;
- break;
- case 'c':
- concurrency = atoi(optarg);
- break;
- case 'p':
- port = atoi(optarg);
- break;
- case 't':
- tlimit = atoi(optarg);
- requests = MAX_REQUESTS; /* need to size data array on something */
- break;
- default:
- usage(argv[0]);
- break;
- }
- }
- test();
- return 0;
-}
-
-
-
-
-
-