int main(int argc, char **argv) { struct sigaction sig_stop; struct sigaction sig_time; _main = main_init(argc, argv); _log = log_init(); _main->conf = conf_init(argc, argv); _main->work = work_init(); _main->tcp = tcp_init(); _main->node = node_init(); _main->mime = mime_init(); /* Check configuration */ conf_print(); /* Catch SIG INT */ unix_signal(&sig_stop, &sig_time); /* Fork daemon */ unix_fork(log_console(_log)); /* Increase limits */ unix_limits(_main->conf->cores, CONF_EPOLL_MAX_EVENTS); /* Load mime types */ mime_load(); mime_hash(); /* Prepare TCP daemon */ tcp_start(); /* Drop privileges */ unix_dropuid0(); /* Start worker threads */ work_start(); /* Stop worker threads */ work_stop(); /* Stop TCP daemon */ tcp_stop(); mime_free(); node_free(); tcp_free(); work_free(); conf_free(); log_free(_log); main_free(); return 0; }
static struct mimetype * mime_lookup (register const char *str, register unsigned int len) { static struct mimetype wordlist[] = { {"",""}, {"h","text/plain"}, {"hh","text/plain"}, {"hxx","text/plain"}, {"",""}, {"xhtml","application/xhtml+xml"}, {"",""}, {"tr","application/x-troff"}, {"xht","application/xhtml+xml"}, {"html","text/html"}, {"lzh","application/octet-stream"}, {"t","application/x-troff"}, {"el","text/plain"}, {"txt","text/plain"}, {"vrml","model/vrml"}, {"",""}, {"",""}, {"qt","video/quicktime"}, {"xsl","text/xml"}, {"",""}, {"",""}, {"",""}, {"",""}, {"exe","application/octet-stream"}, {"text","text/plain"}, {"",""}, {"",""}, {"",""}, {"xml","text/xml"}, {"texi","application/x-texinfo"}, {"",""}, {"",""}, {"",""}, {"htm","text/html"}, {"",""}, {"",""}, {"",""}, {"",""}, {"eml","message/rfc822"}, {"mesh","model/mesh"}, {"",""}, {"",""}, {"",""}, {"msh","model/mesh"}, {"smil","application/smil"}, {"bin","application/octet-stream"}, {"",""}, {"",""}, {"eps","application/postscript"}, {"midi","audio/midi"}, {"tgz","application/x-gzip"}, {"gz","application/x-gzip"}, {"ps","application/postscript"}, {"smi","application/smil"}, {"sgml","text/sgml"}, {"mp3","audio/mpeg"}, {"",""}, {"",""}, {"mpe","video/mpeg"}, {"",""}, {"mp2","audio/mpeg"}, {"",""}, {"",""}, {"igs","model/iges"}, {"iges","model/iges"}, {"",""}, {"",""}, {"",""}, {"cxx","text/plain"}, {"",""}, {"",""}, {"",""}, {"pm","text/plain"}, {"img","application/octet-stream"}, {"",""}, {"",""}, {"",""}, {"",""}, {"sgm","text/sgml"}, {"",""}, {"",""}, {"",""}, {"",""}, {"mpg","video/mpeg"}, {"mpeg","video/mpeg"}, {"class","application/octet-stream"}, {"",""}, {"au","audio/basic"}, {"lha","application/octet-stream"}, {"",""}, {"",""}, {"",""}, {"texinfo","application/x-texinfo"}, {"tif","image/tiff"}, {"tiff","image/tiff"}, {"",""}, {"",""}, {"",""}, {"iso","application/octet-stream"}, {"silo","model/mesh"}, {"",""}, {"",""}, {"",""}, {"asx","video/x-ms-asf"}, {"",""}, {"",""}, {"",""}, {"ai","application/postscript"}, {"mov","video/quicktime"}, {"",""}, {"",""}, {"",""}, {"",""}, {"jpe","image/jpeg"}, {"mail","message/rfc822"}, {"",""}, {"",""}, {"",""}, {"dll","application/octet-stream"}, {"",""}, {"",""}, {"",""}, {"",""}, {"gif","image/gif"}, {"",""}, {"",""}, {"",""}, {"",""}, {"wrl","model/vrml"}, {"",""}, {"",""}, {"c","text/plain"}, {"",""}, {"xsd","text/xml"}, {"mpga","audio/mpeg"}, {"",""}, {"",""}, {"",""}, {"jpg","image/jpg"}, {"jpeg","image/jpeg"}, {"",""}, {"",""}, {"",""}, {"man","application/x-troff-man"}, {"wsdl","text/xml"}, {"",""}, {"",""}, {"",""}, {"ico","image/ico"}, {"roff","application/x-troff"}, {"",""}, {"",""}, {"",""}, {"mid","audio/midi"}, {"",""}, {"",""}, {"",""}, {"so","application/octet-stream"}, {"dms","application/octet-stream"}, {"",""}, {"",""}, {"",""}, {"nc","application/x-netcdf"}, {"snd","audio/basic"}, {"aifc","audio/x-aiff"}, {"",""}, {"",""}, {"",""}, {"asc","text/plain"}, {"",""}, {"",""}, {"",""}, {"",""}, {"aif","audio/x-aiff"}, {"aiff","audio/x-aiff"}, {"",""}, {"",""}, {"",""}, {"asf","video/x-ms-asf"}, {"",""}, {"",""}, {"",""}, {"",""}, {"kar","audio/midi"}, {"",""}, {"",""}, {"",""}, {"",""}, {"f90","text/plain"}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"cc","text/plain"}, {"",""}, {"djvu","image/vnd.djvu"}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"djv","image/vnd.djvu"}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"jfif","image/jpeg"}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"",""}, {"cdf","application/x-netcdf"} }; if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { int key = mime_hash (str, len); if (key <= MAX_HASH_VALUE && key >= 0) { const char *s = wordlist[key].ext; if ((((unsigned char)*str ^ (unsigned char)*s) & ~32) == 0 && !gperf_case_strcmp (str, s)) return &wordlist[key]; } } return 0; }