version 1.11, 2014/12/13 19:30:04 |
version 1.12, 2015/05/02 11:35:48 |
|
|
/* $eterna: content-bozo.c,v 1.17 2011/11/18 09:21:15 mrg Exp $ */ |
/* $eterna: content-bozo.c,v 1.17 2011/11/18 09:21:15 mrg Exp $ */ |
|
|
/* |
/* |
* Copyright (c) 1997-2014 Matthew R. Green |
* Copyright (c) 1997-2015 Matthew R. Green |
* All rights reserved. |
* All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
|
|
*/ |
*/ |
|
|
static bozo_content_map_t static_content_map[] = { |
static bozo_content_map_t static_content_map[] = { |
{ ".html", 5, "text/html", "", "", NULL }, |
{ ".html", "text/html", "", "", NULL }, |
{ ".htm", 4, "text/html", "", "", NULL }, |
{ ".htm", "text/html", "", "", NULL }, |
{ ".gif", 4, "image/gif", "", "", NULL }, |
{ ".gif", "image/gif", "", "", NULL }, |
{ ".jpeg", 5, "image/jpeg", "", "", NULL }, |
{ ".jpeg", "image/jpeg", "", "", NULL }, |
{ ".jpg", 4, "image/jpeg", "", "", NULL }, |
{ ".jpg", "image/jpeg", "", "", NULL }, |
{ ".jpe", 4, "image/jpeg", "", "", NULL }, |
{ ".jpe", "image/jpeg", "", "", NULL }, |
{ ".png", 4, "image/png", "", "", NULL }, |
{ ".png", "image/png", "", "", NULL }, |
{ ".mp3", 4, "audio/mpeg", "", "", NULL }, |
{ ".mp3", "audio/mpeg", "", "", NULL }, |
{ ".css", 4, "text/css", "", "", NULL }, |
{ ".css", "text/css", "", "", NULL }, |
{ ".txt", 4, "text/plain", "", "", NULL }, |
{ ".txt", "text/plain", "", "", NULL }, |
{ ".swf", 4, "application/x-shockwave-flash","", "", NULL }, |
{ ".swf", "application/x-shockwave-flash","", "", NULL }, |
{ ".dcr", 4, "application/x-director", "", "", NULL }, |
{ ".dcr", "application/x-director", "", "", NULL }, |
{ ".pac", 4, "application/x-ns-proxy-autoconfig", "", "", NULL }, |
{ ".pac", "application/x-ns-proxy-autoconfig", "", "", NULL }, |
{ ".pa", 3, "application/x-ns-proxy-autoconfig", "", "", NULL }, |
{ ".pa", "application/x-ns-proxy-autoconfig", "", "", NULL }, |
{ ".tar", 4, "multipart/x-tar", "", "", NULL }, |
{ ".tar", "multipart/x-tar", "", "", NULL }, |
{ ".gtar", 5, "multipart/x-gtar", "", "", NULL }, |
{ ".gtar", "multipart/x-gtar", "", "", NULL }, |
{ ".tar.Z", 6, "multipart/x-tar", "x-compress", "compress", NULL }, |
{ ".tar.Z", "multipart/x-tar", "x-compress", "compress", NULL }, |
{ ".tar.gz", 7, "multipart/x-tar", "x-gzip", "gzip", NULL }, |
{ ".tar.gz", "multipart/x-tar", "x-gzip", "gzip", NULL }, |
{ ".taz", 4, "multipart/x-tar", "x-gzip", "gzip", NULL }, |
{ ".taz", "multipart/x-tar", "x-gzip", "gzip", NULL }, |
{ ".tgz", 4, "multipart/x-tar", "x-gzip", "gzip", NULL }, |
{ ".tgz", "multipart/x-tar", "x-gzip", "gzip", NULL }, |
{ ".tar.z", 6, "multipart/x-tar", "x-pack", "x-pack", NULL }, |
{ ".tar.z", "multipart/x-tar", "x-pack", "x-pack", NULL }, |
{ ".Z", 2, "application/x-compress", "x-compress", "compress", NULL }, |
{ ".Z", "application/x-compress", "x-compress", "compress", NULL }, |
{ ".gz", 3, "application/x-gzip", "x-gzip", "gzip", NULL }, |
{ ".gz", "application/x-gzip", "x-gzip", "gzip", NULL }, |
{ ".z", 2, "unknown", "x-pack", "x-pack", NULL }, |
{ ".z", "unknown", "x-pack", "x-pack", NULL }, |
{ ".bz2", 4, "application/x-bzip2", "x-bzip2", "x-bzip2", NULL }, |
{ ".bz2", "application/x-bzip2", "x-bzip2", "x-bzip2", NULL }, |
{ ".ogg", 4, "application/x-ogg", "", "", NULL }, |
{ ".ogg", "application/x-ogg", "", "", NULL }, |
{ ".mkv", 4, "video/x-matroska", "", "", NULL }, |
{ ".mkv", "video/x-matroska", "", "", NULL }, |
{ ".xbel", 5, "text/xml", "", "", NULL }, |
{ ".xbel", "text/xml", "", "", NULL }, |
{ ".xml", 4, "text/xml", "", "", NULL }, |
{ ".xml", "text/xml", "", "", NULL }, |
{ ".xsl", 4, "text/xml", "", "", NULL }, |
{ ".xsl", "text/xml", "", "", NULL }, |
{ ".hqx", 4, "application/mac-binhex40", "", "", NULL }, |
{ ".hqx", "application/mac-binhex40", "", "", NULL }, |
{ ".cpt", 4, "application/mac-compactpro","", "", NULL }, |
{ ".cpt", "application/mac-compactpro", "", "", NULL }, |
{ ".doc", 4, "application/msword", "", "", NULL }, |
{ ".doc", "application/msword", "", "", NULL }, |
{ ".bin", 4, "application/octet-stream", "", "", NULL }, |
{ ".bin", "application/octet-stream", "", "", NULL }, |
{ ".dms", 4, "application/octet-stream", "", "", NULL }, |
{ ".dms", "application/octet-stream", "", "", NULL }, |
{ ".lha", 4, "application/octet-stream", "", "", NULL }, |
{ ".lha", "application/octet-stream", "", "", NULL }, |
{ ".lzh", 4, "application/octet-stream", "", "", NULL }, |
{ ".lzh", "application/octet-stream", "", "", NULL }, |
{ ".exe", 4, "application/octet-stream", "", "", NULL }, |
{ ".exe", "application/octet-stream", "", "", NULL }, |
{ ".class", 6, "application/octet-stream", "", "", NULL }, |
{ ".class", "application/octet-stream", "", "", NULL }, |
{ ".oda", 4, "application/oda", "", "", NULL }, |
{ ".oda", "application/oda", "", "", NULL }, |
{ ".pdf", 4, "application/pdf", "", "", NULL }, |
{ ".pdf", "application/pdf", "", "", NULL }, |
{ ".ai", 3, "application/postscript", "", "", NULL }, |
{ ".ai", "application/postscript", "", "", NULL }, |
{ ".eps", 4, "application/postscript", "", "", NULL }, |
{ ".eps", "application/postscript", "", "", NULL }, |
{ ".ps", 3, "application/postscript", "", "", NULL }, |
{ ".ps", "application/postscript", "", "", NULL }, |
{ ".ppt", 4, "application/powerpoint", "", "", NULL }, |
{ ".ppt", "application/powerpoint", "", "", NULL }, |
{ ".rtf", 4, "application/rtf", "", "", NULL }, |
{ ".rtf", "application/rtf", "", "", NULL }, |
{ ".bcpio", 6, "application/x-bcpio", "", "", NULL }, |
{ ".bcpio", "application/x-bcpio", "", "", NULL }, |
{ ".torrent", 8, "application/x-bittorrent", "", "", NULL }, |
{ ".torrent", "application/x-bittorrent", "", "", NULL }, |
{ ".vcd", 4, "application/x-cdlink", "", "", NULL }, |
{ ".vcd", "application/x-cdlink", "", "", NULL }, |
{ ".cpio", 5, "application/x-cpio", "", "", NULL }, |
{ ".cpio", "application/x-cpio", "", "", NULL }, |
{ ".csh", 4, "application/x-csh", "", "", NULL }, |
{ ".csh", "application/x-csh", "", "", NULL }, |
{ ".dir", 4, "application/x-director", "", "", NULL }, |
{ ".dir", "application/x-director", "", "", NULL }, |
{ ".dxr", 4, "application/x-director", "", "", NULL }, |
{ ".dxr", "application/x-director", "", "", NULL }, |
{ ".dvi", 4, "application/x-dvi", "", "", NULL }, |
{ ".dvi", "application/x-dvi", "", "", NULL }, |
{ ".hdf", 4, "application/x-hdf", "", "", NULL }, |
{ ".hdf", "application/x-hdf", "", "", NULL }, |
{ ".cgi", 4, "application/x-httpd-cgi", "", "", NULL }, |
{ ".cgi", "application/x-httpd-cgi", "", "", NULL }, |
{ ".skp", 4, "application/x-koan", "", "", NULL }, |
{ ".skp", "application/x-koan", "", "", NULL }, |
{ ".skd", 4, "application/x-koan", "", "", NULL }, |
{ ".skd", "application/x-koan", "", "", NULL }, |
{ ".skt", 4, "application/x-koan", "", "", NULL }, |
{ ".skt", "application/x-koan", "", "", NULL }, |
{ ".skm", 4, "application/x-koan", "", "", NULL }, |
{ ".skm", "application/x-koan", "", "", NULL }, |
{ ".latex", 6, "application/x-latex", "", "", NULL }, |
{ ".latex", "application/x-latex", "", "", NULL }, |
{ ".mif", 4, "application/x-mif", "", "", NULL }, |
{ ".mif", "application/x-mif", "", "", NULL }, |
{ ".nc", 3, "application/x-netcdf", "", "", NULL }, |
{ ".nc", "application/x-netcdf", "", "", NULL }, |
{ ".cdf", 4, "application/x-netcdf", "", "", NULL }, |
{ ".cdf", "application/x-netcdf", "", "", NULL }, |
{ ".patch", 6, "application/x-patch", "", "", NULL }, |
{ ".patch", "application/x-patch", "", "", NULL }, |
{ ".sh", 3, "application/x-sh", "", "", NULL }, |
{ ".sh", "application/x-sh", "", "", NULL }, |
{ ".shar", 5, "application/x-shar", "", "", NULL }, |
{ ".shar", "application/x-shar", "", "", NULL }, |
{ ".sit", 4, "application/x-stuffit", "", "", NULL }, |
{ ".sit", "application/x-stuffit", "", "", NULL }, |
{ ".sv4cpio", 8, "application/x-sv4cpio", "", "", NULL }, |
{ ".sv4cpio", "application/x-sv4cpio", "", "", NULL }, |
{ ".sv4crc", 7, "application/x-sv4crc", "", "", NULL }, |
{ ".sv4crc", "application/x-sv4crc", "", "", NULL }, |
{ ".tar", 4, "application/x-tar", "", "", NULL }, |
{ ".tar", "application/x-tar", "", "", NULL }, |
{ ".tcl", 4, "application/x-tcl", "", "", NULL }, |
{ ".tcl", "application/x-tcl", "", "", NULL }, |
{ ".tex", 4, "application/x-tex", "", "", NULL }, |
{ ".tex", "application/x-tex", "", "", NULL }, |
{ ".texinfo", 8, "application/x-texinfo", "", "", NULL }, |
{ ".texinfo", "application/x-texinfo", "", "", NULL }, |
{ ".texi", 5, "application/x-texinfo", "", "", NULL }, |
{ ".texi", "application/x-texinfo", "", "", NULL }, |
{ ".t", 2, "application/x-troff", "", "", NULL }, |
{ ".t", "application/x-troff", "", "", NULL }, |
{ ".tr", 3, "application/x-troff", "", "", NULL }, |
{ ".tr", "application/x-troff", "", "", NULL }, |
{ ".roff", 5, "application/x-troff", "", "", NULL }, |
{ ".roff", "application/x-troff", "", "", NULL }, |
{ ".man", 4, "application/x-troff-man", "", "", NULL }, |
{ ".man", "application/x-troff-man", "", "", NULL }, |
{ ".me", 3, "application/x-troff-me", "", "", NULL }, |
{ ".me", "application/x-troff-me", "", "", NULL }, |
{ ".ms", 3, "application/x-troff-ms", "", "", NULL }, |
{ ".ms", "application/x-troff-ms", "", "", NULL }, |
{ ".ustar", 6, "application/x-ustar", "", "", NULL }, |
{ ".ustar", "application/x-ustar", "", "", NULL }, |
{ ".src", 4, "application/x-wais-source", "", "", NULL }, |
{ ".src", "application/x-wais-source", "", "", NULL }, |
{ ".zip", 4, "application/zip", "", "", NULL }, |
{ ".zip", "application/zip", "", "", NULL }, |
{ ".au", 3, "audio/basic", "", "", NULL }, |
{ ".au", "audio/basic", "", "", NULL }, |
{ ".snd", 4, "audio/basic", "", "", NULL }, |
{ ".snd", "audio/basic", "", "", NULL }, |
{ ".mpga", 5, "audio/mpeg", "", "", NULL }, |
{ ".mpga", "audio/mpeg", "", "", NULL }, |
{ ".mp2", 4, "audio/mpeg", "", "", NULL }, |
{ ".mp2", "audio/mpeg", "", "", NULL }, |
{ ".aif", 4, "audio/x-aiff", "", "", NULL }, |
{ ".aif", "audio/x-aiff", "", "", NULL }, |
{ ".aiff", 5, "audio/x-aiff", "", "", NULL }, |
{ ".aiff", "audio/x-aiff", "", "", NULL }, |
{ ".aifc", 5, "audio/x-aiff", "", "", NULL }, |
{ ".aifc", "audio/x-aiff", "", "", NULL }, |
{ ".ram", 4, "audio/x-pn-realaudio", "", "", NULL }, |
{ ".ram", "audio/x-pn-realaudio", "", "", NULL }, |
{ ".rpm", 4, "audio/x-pn-realaudio-plugin","", "", NULL }, |
{ ".rpm", "audio/x-pn-realaudio-plugin", "", "", NULL }, |
{ ".ra", 3, "audio/x-realaudio", "", "", NULL }, |
{ ".ra", "audio/x-realaudio", "", "", NULL }, |
{ ".wav", 4, "audio/x-wav", "", "", NULL }, |
{ ".wav", "audio/x-wav", "", "", NULL }, |
{ ".pdb", 4, "chemical/x-pdb", "", "", NULL }, |
{ ".pdb", "chemical/x-pdb", "", "", NULL }, |
{ ".xyz", 4, "chemical/x-pdb", "", "", NULL }, |
{ ".xyz", "chemical/x-pdb", "", "", NULL }, |
{ ".ief", 4, "image/ief", "", "", NULL }, |
{ ".ief", "image/ief", "", "", NULL }, |
{ ".tiff", 5, "image/tiff", "", "", NULL }, |
{ ".tiff", "image/tiff", "", "", NULL }, |
{ ".tif", 4, "image/tiff", "", "", NULL }, |
{ ".tif", "image/tiff", "", "", NULL }, |
{ ".ras", 4, "image/x-cmu-raster", "", "", NULL }, |
{ ".ras", "image/x-cmu-raster", "", "", NULL }, |
{ ".pnm", 4, "image/x-portable-anymap", "", "", NULL }, |
{ ".pnm", "image/x-portable-anymap", "", "", NULL }, |
{ ".pbm", 4, "image/x-portable-bitmap", "", "", NULL }, |
{ ".pbm", "image/x-portable-bitmap", "", "", NULL }, |
{ ".pgm", 4, "image/x-portable-graymap", "", "", NULL }, |
{ ".pgm", "image/x-portable-graymap", "", "", NULL }, |
{ ".ppm", 4, "image/x-portable-pixmap", "", "", NULL }, |
{ ".ppm", "image/x-portable-pixmap", "", "", NULL }, |
{ ".rgb", 4, "image/x-rgb", "", "", NULL }, |
{ ".rgb", "image/x-rgb", "", "", NULL }, |
{ ".xbm", 4, "image/x-xbitmap", "", "", NULL }, |
{ ".xbm", "image/x-xbitmap", "", "", NULL }, |
{ ".xpm", 4, "image/x-xpixmap", "", "", NULL }, |
{ ".xpm", "image/x-xpixmap", "", "", NULL }, |
{ ".xwd", 4, "image/x-xwindowdump", "", "", NULL }, |
{ ".xwd", "image/x-xwindowdump", "", "", NULL }, |
{ ".rtx", 4, "text/richtext", "", "", NULL }, |
{ ".rtx", "text/richtext", "", "", NULL }, |
{ ".tsv", 4, "text/tab-separated-values", "", "", NULL }, |
{ ".tsv", "text/tab-separated-values", "", "", NULL }, |
{ ".etx", 4, "text/x-setext", "", "", NULL }, |
{ ".etx", "text/x-setext", "", "", NULL }, |
{ ".sgml", 5, "text/x-sgml", "", "", NULL }, |
{ ".sgml", "text/x-sgml", "", "", NULL }, |
{ ".sgm", 4, "text/x-sgml", "", "", NULL }, |
{ ".sgm", "text/x-sgml", "", "", NULL }, |
{ ".mpeg", 5, "video/mpeg", "", "", NULL }, |
{ ".mpeg", "video/mpeg", "", "", NULL }, |
{ ".mpg", 4, "video/mpeg", "", "", NULL }, |
{ ".mpg", "video/mpeg", "", "", NULL }, |
{ ".mpe", 4, "video/mpeg", "", "", NULL }, |
{ ".mpe", "video/mpeg", "", "", NULL }, |
{ ".ts", 4, "video/mpeg", "", "", NULL }, |
{ ".ts", "video/mpeg", "", "", NULL }, |
{ ".vob", 4, "video/mpeg", "", "", NULL }, |
{ ".vob", "video/mpeg", "", "", NULL }, |
{ ".mp4", 4, "video/mp4", "", "", NULL }, |
{ ".mp4", "video/mp4", "", "", NULL }, |
{ ".qt", 3, "video/quicktime", "", "", NULL }, |
{ ".qt", "video/quicktime", "", "", NULL }, |
{ ".mov", 4, "video/quicktime", "", "", NULL }, |
{ ".mov", "video/quicktime", "", "", NULL }, |
{ ".avi", 4, "video/x-msvideo", "", "", NULL }, |
{ ".avi", "video/x-msvideo", "", "", NULL }, |
{ ".movie", 6, "video/x-sgi-movie", "", "", NULL }, |
{ ".movie", "video/x-sgi-movie", "", "", NULL }, |
{ ".ice", 4, "x-conference/x-cooltalk", "", "", NULL }, |
{ ".ice", "x-conference/x-cooltalk", "", "", NULL }, |
{ ".wrl", 4, "x-world/x-vrml", "", "", NULL }, |
{ ".wrl", "x-world/x-vrml", "", "", NULL }, |
{ ".vrml", 5, "x-world/x-vrml", "", "", NULL }, |
{ ".vrml", "x-world/x-vrml", "", "", NULL }, |
{ ".svg", 5, "image/svg+xml", "", "", NULL }, |
{ ".svg", "image/svg+xml", "", "", NULL }, |
{ NULL, 0, NULL, NULL, NULL, NULL } |
{ NULL, NULL, NULL, NULL, NULL } |
}; |
}; |
|
|
static bozo_content_map_t * |
static bozo_content_map_t * |
search_map(bozo_content_map_t *map, const char *name, size_t len) |
search_map(bozo_content_map_t *map, const char *name, size_t len) |
{ |
{ |
for ( ; map && map->name; map++) { |
for ( ; map && map->name; map++) { |
if (map->namelen < len && |
const size_t namelen = strlen(map->name); |
strcasecmp(map->name, name + (len - map->namelen)) == 0) |
|
|
if (namelen < len && |
|
strcasecmp(map->name, name + (len - namelen)) == 0) |
return map; |
return map; |
} |
} |
return NULL; |
return NULL; |
Line 260 bozo_get_content_map(bozohttpd_t *httpd, |
|
Line 262 bozo_get_content_map(bozohttpd_t *httpd, |
|
map = &httpd->dynamic_content_map[httpd->dynamic_content_map_size]; |
map = &httpd->dynamic_content_map[httpd->dynamic_content_map_size]; |
map->name = map->type = map->encoding = map->encoding11 = |
map->name = map->type = map->encoding = map->encoding11 = |
map->cgihandler = NULL; |
map->cgihandler = NULL; |
map->namelen = 0; |
|
map--; |
map--; |
|
|
return map; |
return map; |
Line 291 bozo_add_content_map_mime(bozohttpd_t *h |
|
Line 292 bozo_add_content_map_mime(bozohttpd_t *h |
|
map = bozo_get_content_map(httpd, cmap0); |
map = bozo_get_content_map(httpd, cmap0); |
#define CHECKMAP(s) (!s || ((s)[0] == '-' && (s)[1] == '\0') ? "" : (s)) |
#define CHECKMAP(s) (!s || ((s)[0] == '-' && (s)[1] == '\0') ? "" : (s)) |
map->name = CHECKMAP(cmap0); |
map->name = CHECKMAP(cmap0); |
map->namelen = strlen(map->name); |
|
map->type = CHECKMAP(cmap1); |
map->type = CHECKMAP(cmap1); |
map->encoding = CHECKMAP(cmap2); |
map->encoding = CHECKMAP(cmap2); |
map->encoding11 = CHECKMAP(cmap3); |
map->encoding11 = CHECKMAP(cmap3); |