Commit Graph

116 Commits

Author SHA1 Message Date
Emil Mikulic 4fed6d0665 Implement --pidfile and move clean shutdown into main() 2013-04-28 19:44:12 +10:00
Emil Mikulic 42833fb312 Fix build on FreeBSD by spelling "sockin" correctly.
This has been outstanding for a long time.
2013-04-28 19:44:12 +10:00
Emil Mikulic 6c1922391f Answer requests that end in \n\n as well as the more pedantic \r\n\r\n 2013-04-28 19:44:12 +10:00
Emil Mikulic bea398d629 Add support for sendfile() on Solaris. 2013-04-28 19:44:12 +10:00
Emil Mikulic 49fb5f3fbf Fix fallback on platforms that don't have sendfile()
It was quite badly broken.
2013-04-28 19:44:12 +10:00
Emil Mikulic 2ca3cef4a3 [ darkhttpd-1.2 release ] 2013-04-28 19:44:12 +10:00
Emil Mikulic 3829ceade8 Fix (unsigned < 0) comparison. 2013-04-28 19:44:12 +10:00
Emil Mikulic 74fcaf5859 safefree -> free 2013-04-28 19:44:12 +10:00
Emil Mikulic dfe896357a Fix debugf mess. 2013-04-28 19:44:12 +10:00
Emil Mikulic b50b4f1c5a Fix signed-unsigned comparison. 2013-04-28 19:44:12 +10:00
Emil Mikulic 5cf2862f08 Manually inline acceptfilter code to remove unused arg warning on
non-FreeBSD platforms.
2013-04-28 19:44:12 +10:00
Emil Mikulic e624dbbe02 Fix err and debugf warnings. 2013-04-28 19:44:12 +10:00
Emil Mikulic 91fcb80e4a Adjust copyright and license. 2013-04-28 19:44:12 +10:00
Emil Mikulic d545127600 Track requests and bytes transferred statistics. 2013-04-28 19:44:12 +10:00
Emil Mikulic 27a35821a1 wwwroot = strdup(argv[1]) so we don't end up stripping the only existing
slash out of the commandline shown by ps(1).  And free it on shutdown.
2013-04-28 19:44:12 +10:00
Emil Mikulic 108eb4cce3 . Split usage() into many printfs() to keep GCC3 happy about ISO limits.
. Knock out the REPLY_GENERATED length assertion since ap_buf doesn't
  null-terminate strings and it's never been tripped by xasprintf()
  consumers.
. Cast rusage times when printing, and don't print too many zeroes.
2013-04-28 19:44:12 +10:00
Emil Mikulic ecb3d8adb3 Optimize generate_dir_listing():
. Split appendf() calls into a number of append() calls.
. To insert spaces, instead of sitting in a loop, use a spaces[] buffer
  and insert a chunk of it with appendl().
2013-04-28 19:44:12 +10:00
Emil Mikulic 4ce4eabdbd . Version upped to 1.1 for append buffer optimizations.
. Don't keep the apbuf strings null-terminated.
. Compile-time optimise append() if we have GCC.
2013-04-28 19:44:12 +10:00
Emil Mikulic fd4e271d57 Before exiting, getrusage() and print time spent on CPU. 2013-04-28 19:44:12 +10:00
Emil Mikulic 0f798c0d71 Merge two lines. 2013-04-28 19:44:12 +10:00
Emil Mikulic 020b4d20e2 Fix whitespace and disclaimer comment. 2013-04-28 19:44:12 +10:00
Emil Mikulic 84e59c72ac Use FALLTHROUGH instead of goto. 2013-04-28 19:44:12 +10:00
Emil Mikulic 6ab21a586e . Don't expect user to define NDEBUG. 2013-04-28 19:44:12 +10:00
Emil Mikulic 761462e4e5 . __sun__ -> __sun since Sun's CC doesn't use the former. 2013-04-28 19:44:12 +10:00
Emil Mikulic 7df4b55839 . Fix chomp()'s checking of empty strings. 2013-04-28 19:44:12 +10:00
Emil Mikulic c58880c10a . Added third BSD clause.
. Got rid of Solaris hint - it belongs in the README.
. Got rid of a tab.
2013-04-28 19:44:12 +10:00
Emil Mikulic b175db347d . Added --accf instead of compile-time NO_ACCEPTFILTER.
. Fixed const issues in dlent_cmp().
. Fixed uninitialized from/to warning.
2013-04-28 19:44:12 +10:00
Emil Mikulic 36f027c8c8 Fix two memory leaks. 2013-04-28 19:44:12 +10:00
Emil Mikulic a4be99dc3f . USE_ACCEPTFILTER -> NO_ACCEPTFILTER and document it. 2013-04-28 19:44:11 +10:00
Emil Mikulic a0dddaf19a . Add USE_ACCEPTFILTER knob.
. debugf() sweep - turn non-verbose ones into printf()s
2013-04-28 19:44:11 +10:00
Emil Mikulic a4347fa196 . Added BSD license.
. Version is now 1.0.
. Display [!]NDEBUG in --version output.
2013-04-28 19:44:11 +10:00
Emil Mikulic 3e378caaf0 . Implemented apbuf API.
. Reworked generate_dir_listing() to use apbuf - much nicer now.
2013-04-28 19:44:11 +10:00
Emil Mikulic 2776f8c35e . Cosmetics in mime_mapping_cmp().
. Added make_sorted_dirlist(), cleanup_sorted_dirlist().
. generate_dir_listing() works better and produces sorted output, but
  still looks awful.
2013-04-28 19:44:11 +10:00
Emil Mikulic 3dbf2f15b4 . Got rid of pretty top-of-file.
. Moved $Id$ into static rcsid[].
. Preened TODO list.
. Removed LIST_EMPTY() - it wasn't being used.
. Got rid of "mapping x -> y" debugf.
. Move exit() out of usage() and into caller to make program flow more
  obvious.
. Added --version handling that prints rcsid.
2013-04-28 19:44:11 +10:00
Emil Mikulic fb2e40cae5 . Added file_exists().
. Added skeleton for generate_dir_listing().
. Tied it into process_get().
2013-04-28 19:44:11 +10:00
Emil Mikulic 917e7a2cc4 . De-constify offset for Linux. 2013-04-28 19:44:11 +10:00
Emil Mikulic 132757b8fe . Do a non-blocking open and only stat once. 2013-04-28 19:44:11 +10:00
Emil Mikulic 7abf59ea32 . Removed test_make_safe_uri(). 2013-04-28 19:44:11 +10:00
Emil Mikulic 19f70a46a9 . Added xclose().
. Changed reply_file from FILE to a file descriptor - using regular
  syscalls instead of stdio f* calls.
2013-04-28 19:44:11 +10:00
Emil Mikulic 6312e230fb . Implement chroot. 2013-04-28 19:44:11 +10:00
Emil Mikulic 45ac8883e0 . Correct order of checking name and id for --uid and --gid. 2013-04-28 19:44:11 +10:00
Emil Mikulic 7ef872fd6a Added handling of --uid. 2013-04-28 19:44:11 +10:00
Emil Mikulic b5f0992e7e . Added str_to_num().
. Added handling of --uid.
2013-04-28 19:44:11 +10:00
Emil Mikulic b2b6d75a05 . In NDEBUG, safefree() is just free().
. Originally there were three places where a pointer was NULL'd after
  being freed.  One of these is actually important, so annotate it.
2013-04-28 19:44:11 +10:00
Emil Mikulic 7014380256 Cosmetics. 2013-04-28 19:44:11 +10:00
Emil Mikulic 850543f7d6 . Patch up a leak by freeing target when needed. 2013-04-28 19:44:11 +10:00
Emil Mikulic 832851b83d . Add safefree(x) macro to set x to NULL after freeing. 2013-04-28 19:44:11 +10:00
Emil Mikulic e74bb5a077 . Added redirect().
. Moved 404 reply up to stat() section.
. Redirect /dir to /dir/
. Separate permissions (403 Forbidden) from other fopen() failures
  (500 Internal Server Error)
2013-04-28 19:44:11 +10:00
Emil Mikulic eee798c571 . stat() the file before opening it to avoid opening FIFOs, sockets, etc. 2013-04-28 19:44:11 +10:00
Emil Mikulic db6517c62d . Use goto instead of code duplication. 2013-04-28 19:44:11 +10:00