?? htinit.c
字號:
HTAA_newModule ("basic", HTBasic_generate, HTBasic_parse, NULL, HTBasic_delete);#ifdef HT_MD5 HTAA_newModule ("digest", HTDigest_generate, HTDigest_parse, HTDigest_updateInfo, HTDigest_delete);#endif /* HT_MD5 */}/* REGISTER BEFORE AND AFTER FILTERS** ---------------------------------** We register a commonly used set of BEFORE and AFTER filters.** Not done automaticly - may be done by application!*/PUBLIC void HTNetInit (void){ HTBeforeInit(); HTAfterInit();}/* REGISTER CALLBACKS FOR THE ALERT MANAGER** ----------------------------------------** We register a set of alert messages** Not done automaticly - may be done by application!*/PUBLIC void HTAlertInit (void){ HTAlert_add(HTProgress, HT_A_PROGRESS); HTAlert_add(HTError_print, HT_A_MESSAGE); HTAlert_add(HTConfirm, HT_A_CONFIRM); HTAlert_add(HTPrompt, HT_A_PROMPT); HTAlert_add(HTPromptPassword, HT_A_SECRET); HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);}/* REGISTER ALL KNOWN TRANSPORTS IN THE LIBRARY** --------------------------------------------** Not done automaticly - may be done by application!*/PUBLIC void HTTransportInit (void){ HTTransport_add("tcp", HT_TP_SINGLE, HTReader_new, HTWriter_new); HTTransport_add("buffered_tcp", HT_TP_SINGLE, HTReader_new, HTBufferWriter_new);#ifdef HT_MUX HTTransport_add("mux", HT_TP_INTERLEAVE, HTReader_new, HTBufferWriter_new);#endif /* HT_MUX */#ifndef NO_UNIX_IO HTTransport_add("local", HT_TP_SINGLE, HTReader_new, HTWriter_new);#else HTTransport_add("local", HT_TP_SINGLE, HTANSIReader_new, HTANSIWriter_new);#endif}/* REGISTER ALL KNOWN PROTOCOLS IN THE LIBRARY** -------------------------------------------** Not done automaticly - may be done by application!*/PUBLIC void HTProtocolInit (void){#ifndef DECNET HTProtocol_add("ftp", "tcp", FTP_PORT, NO, HTLoadFTP, NULL); HTProtocol_add("nntp", "tcp", NEWS_PORT, NO, HTLoadNews, NULL); HTProtocol_add("news", "tcp", NEWS_PORT, NO, HTLoadNews, NULL); HTProtocol_add("gopher", "tcp", GOPHER_PORT, NO, HTLoadGopher, NULL);#ifdef HT_DIRECT_WAIS HTProtocol_add("wais", "tcp", WAIS_PORT, YES, HTLoadWAIS, NULL);#endif#endif /* DECNET */#ifdef HT_MUX HTProtocol_add("http", "mux", HTTP_PORT, NO, HTLoadHTTP, NULL);#else HTProtocol_add("http", "buffered_tcp", HTTP_PORT, NO, HTLoadHTTP, NULL);#endif /* !HT_MUX */#ifndef NO_UNIX_IO HTProtocol_add("file", "local", 0, NO, HTLoadFile, NULL); HTProtocol_add("cache", "local", 0, NO, HTLoadCache, NULL);#else HTProtocol_add("file", "local", 0, YES, HTLoadFile, NULL); HTProtocol_add("cache", "local", 0, YES, HTLoadCache, NULL);#endif HTProtocol_add("telnet", "", 0, YES, HTLoadTelnet, NULL); HTProtocol_add("tn3270", "", 0, YES, HTLoadTelnet, NULL); HTProtocol_add("rlogin", "", 0, YES, HTLoadTelnet, NULL);}/* REGISTER ALL KNOWN PROTOCOLS IN THE LIBRARY PREEMPTIVELY** --------------------------------------------------------** Not done automaticly - may be done by application!*/PUBLIC void HTProtocolPreemptiveInit (void){#ifndef DECNET HTProtocol_add("ftp", "tcp", FTP_PORT, YES, HTLoadFTP, NULL); HTProtocol_add("nntp", "tcp", NEWS_PORT, YES, HTLoadNews, NULL); HTProtocol_add("news", "tcp", NEWS_PORT, YES, HTLoadNews, NULL); HTProtocol_add("gopher", "tcp", GOPHER_PORT, YES, HTLoadGopher, NULL);#ifdef HT_DIRECT_WAIS HTProtocol_add("wais", "", WAIS_PORT, YES, HTLoadWAIS, NULL);#endif#endif /* DECNET */ HTProtocol_add("http", "buffered_tcp", HTTP_PORT, YES, HTLoadHTTP, NULL); HTProtocol_add("file", "local", 0, YES, HTLoadFile, NULL); HTProtocol_add("telnet", "", 0, YES, HTLoadTelnet, NULL); HTProtocol_add("tn3270", "", 0, YES, HTLoadTelnet, NULL); HTProtocol_add("rlogin", "", 0, YES, HTLoadTelnet, NULL); HTProtocol_add("cache","local",0,YES,HTLoadCache, NULL);}/* BINDINGS BETWEEN ICONS AND MEDIA TYPES** --------------------------------------** Not done automaticly - may be done by application!** For directory listings etc. you can bind a set of icons to a set of** media types and special icons for directories and other objects that** do not have a media type.*/PUBLIC void HTIconInit (const char * url_prefix){ const char * prefix = url_prefix ? url_prefix : ICON_LOCATION; HTIcon_addBlank("blank.xbm", prefix, NULL); HTIcon_addDir("directory.xbm", prefix, "DIR"); HTIcon_addParent("back.xbm", prefix, "UP"); HTIcon_addUnknown("unknown.xbm", prefix, NULL); HTIcon_add("unknown.xbm", prefix, NULL, "*/*"); HTIcon_add("binary.xbm", prefix, "BIN", "binary"); HTIcon_add("unknown.xbm", prefix, NULL, "www/unknown"); HTIcon_add("text.xbm", prefix, "TXT", "text/*"); HTIcon_add("image.xbm", prefix, "IMG", "image/*"); HTIcon_add("movie.xbm", prefix, "MOV", "video/*"); HTIcon_add("sound.xbm", prefix, "AU", "audio/*"); HTIcon_add("tar.xbm", prefix, "TAR", "multipart/x-tar"); HTIcon_add("tar.xbm", prefix, "TAR", "multipart/x-gtar"); HTIcon_add("compressed.xbm",prefix, "CMP", "x-compress"); HTIcon_add("compressed.xbm",prefix, "GZP", "x-gzip"); HTIcon_add("index.xbm", prefix, "IDX", "application/x-gopher-index"); HTIcon_add("index2.xbm", prefix, "CSO", "application/x-gopher-cso"); HTIcon_add("telnet.xbm", prefix, "TEL", "application/x-gopher-telnet"); HTIcon_add("unknown.xbm", prefix, "DUP", "application/x-gopher-duplicate"); HTIcon_add("unknown.xbm", prefix, "TN", "application/x-gopher-tn3270"); /* Add global mapping to where to find the internal icons */ { char * curdir = HTGetCurrentDirectoryURL(); char * virtual = HTParse(ICON_LOCATION, curdir, PARSE_ACCESS|PARSE_HOST|PARSE_PATH|PARSE_PUNCTUATION); char * physical = NULL; StrAllocCat(virtual, "*"); { char * str = NULL; if ((str = (char *) HT_MALLOC(strlen(W3C_ICONS) + 4)) == NULL) HT_OUTOFMEM("HTIconInit"); strcpy(str, W3C_ICONS); if (*(str + strlen(str) - 1) != '/') strcat(str, "/"); strcat(str, "*"); physical = HTParse(str, curdir, PARSE_ACCESS|PARSE_HOST|PARSE_PATH|PARSE_PUNCTUATION); HT_FREE(str); } HTRule_addGlobal(HT_Pass, virtual, physical); HT_FREE(virtual); HT_FREE(physical); HT_FREE(curdir); }}/* REGISTER ALL HTTP/1.1 MIME HEADERS** --------------------------------------------** Not done automaticly - may be done by application!*/PUBLIC void HTMIMEInit (void){ struct { char * string; HTParserCallback * pHandler; } fixedHandlers[] = { {"accept", &HTMIME_accept}, {"accept-charset", &HTMIME_acceptCharset}, {"accept-encoding", &HTMIME_acceptEncoding}, {"accept-language", &HTMIME_acceptLanguage}, {"accept-ranges", &HTMIME_acceptRanges}, {"authorization", NULL}, {"cache-control", &HTMIME_cacheControl}, {"connection", &HTMIME_connection}, {"content-encoding", &HTMIME_contentEncoding}, {"content-length", &HTMIME_contentLength}, {"content-range", &HTMIME_contentRange}, {"content-transfer-encoding", &HTMIME_contentTransferEncoding}, {"content-type", &HTMIME_contentType}, {"digest-MessageDigest", &HTMIME_messageDigest}, {"keep-alive", &HTMIME_keepAlive}, {"link", &HTMIME_link}, {"location", &HTMIME_location}, {"max-forwards", &HTMIME_maxForwards}, {"mime-version", NULL}, {"pragma", &HTMIME_pragma}, {"protocol", &HTMIME_protocol}, {"protocol-info", &HTMIME_protocolInfo}, {"protocol-request", &HTMIME_protocolRequest}, {"proxy-authenticate", &HTMIME_authenticate}, {"proxy-authorization", &HTMIME_proxyAuthorization}, {"public", &HTMIME_public}, {"range", &HTMIME_range}, {"referer", &HTMIME_referer}, {"retry-after", &HTMIME_retryAfter}, {"server", &HTMIME_server}, {"trailer", &HTMIME_trailer}, {"transfer-encoding", &HTMIME_transferEncoding}, {"upgrade", &HTMIME_upgrade}, {"user-agent", &HTMIME_userAgent}, {"vary", &HTMIME_vary}, {"via", &HTMIME_via}, {"warning", &HTMIME_warning}, {"www-authenticate", &HTMIME_authenticate}, {"authentication-info", &HTMIME_authenticationInfo}, {"proxy-authentication-info", &HTMIME_proxyAuthenticationInfo} }; int i; for (i = 0; i < sizeof(fixedHandlers)/sizeof(fixedHandlers[0]); i++) HTHeader_addParser(fixedHandlers[i].string, NO, fixedHandlers[i].pHandler);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -