Nokotan -- not very complicated Spartan daemon.

Supported command line parameters:
-d <absolute-path>
	A directory to serve. Default is /var/spartan/
-p <port>
	A port to listen on. Default is 300
-u <user name>
-g <group name>
	The user and group to which privilleges are dropped.
	Default - do not switch user and group.
-f
	Do not daemonize, work in foreground.
-t <path>
	Load additional media types database. Can be used
	multiple times. (See below)
-c
	Try to chroot to the served directory.
-F
	Enable a footer after directory listings.
	Footer is a single short line ``Generated and served
	by Nokotan''.
-V
	Enable basic virtual hosts support (see below).
-v
	Be more verbose. Use twice to enable debug messages.
-e
	Also send log messages to stderr.
-E
	Send log messages to stderr only.
-h
	This list of options and the program version.

Nokotan remains single-process, but uses select(2) (which is my favourite
Unix system call) to serve multiple clients at a single time.

## Directory listings

When requested file is a directory, then it sends a directory listing. If
a requested directory contains a file named .message, this file is written
before the listing, much like in many FTP daemons.

Directory listing items are sorted in this manner: all directories are put
before other files, and everything is sorted alphabetically, ignoring case.

## MIME types

Nokotan tries to read a database file from /etc/nokotan-types. Additional
databases can be supplied with -t parameter. They have precedence over the
system-wide one. When /etc/nokotan-types does not exist, and no additional
files were supplied, it uses small hard-coded set of types from older
versions.

### Types database file format
Empty and commented (starting with #) lines are ignored.

[type1]
patt1
patt2

[type2]
patt3
...

'patt's are common Unix glob(7) patterns (except that . and / don't have
special behavior). Slash at the beginning of a pattern is optional, but
useful if a pattern starts with [.

Nokotan finds the first pattern to which a requested path matches, and uses
a MIME type from its section. If no such pattern found, it uses hard-coded
types, so, for simple ASCII-only sites creating such database is
unnecessary.

### Example file
[text/gemini; charset=KOI8-R]
/ru/*.gmi
/ru/*.message

[text/gemini; charset=US-ASCII]
*.gmi
*.message

[text/plain]
/*.txt

[audio/ogg]
music/*

### Fallback MIME-types
"text/gemini" is for .gmi, .gem, .gemini and .message files;
"text/plain" is used by .txt, .sh, .c and files with no suffix
"video/mp4" for .mp4
"audio/mpeg" for .mp3
"application/octet-stream" for other suffixes;

Fallback charset parameter is US-ASCII.

## Virtual hosts

With -V flag, the daemon uses each directory in a Spartan root as a
separate virtual host. Directories are named as a virtual host they are
used by.

V-hosts support is basic and I didn't test it yet, so it might be buggy.


If you experience troubles with Nokotan daemon (and the real Nokotan too!),
write me to <arbo@sh.pp.ru>
