Annotation of libwww/Library/src/HTInit.c, revision 2.64
2.20 frystyk 1: /* HTInit.c
2: ** CONFIGURATION-SPECIFIC INITIALIALIZATION
3: **
2.25 frystyk 4: ** (c) COPYRIGHT MIT 1995.
2.20 frystyk 5: ** Please first read the full copyright statement in the file COPYRIGH.
2.64 ! frystyk 6: ** @(#) $Id: HTInit.c,v 2.63 1996/07/04 18:40:19 frystyk Exp $
2.9 duns 7: **
2.20 frystyk 8: ** Define a basic set of suffixes and presentations
2.1 timbl 9: */
10:
2.22 frystyk 11: /* Library include files */
2.52 frystyk 12: #include "sysdep.h"
2.59 frystyk 13: #include "WWWUtil.h"
14: #include "WWWCore.h"
2.22 frystyk 15: #include "HTInit.h" /* Implemented here */
2.1 timbl 16:
2.29 frystyk 17: /* ------------------------------------------------------------------------- */
18:
2.23 frystyk 19: /* BINDINGS BETWEEN A SOURCE MEDIA TYPE AND A DEST MEDIA TYPE (CONVERSION)
20: ** ----------------------------------------------------------------------
2.47 frystyk 21: ** Not done automaticly - may be done by application!
2.23 frystyk 22: */
2.38 frystyk 23: PUBLIC void HTConverterInit (HTList * c)
2.23 frystyk 24: {
2.31 frystyk 25: /*
2.49 frystyk 26: ** You can get debug information out through the debug stream if you set
27: ** the debug format appropriately
28: */
29: HTConversion_add(c,"*/*", "www/debug", HTBlackHoleConverter, 1.0, 0.0, 0.0);
30:
31: /*
2.31 frystyk 32: ** These are converters that converts to something other than www/present,
33: ** that is not directly outputting someting to the user on the screen
34: */
2.43 frystyk 35: HTConversion_add(c,"message/rfc822", "*/*", HTMIMEConvert, 1.0, 0.0, 0.0);
2.55 frystyk 36: HTConversion_add(c,"message/x-rfc822-foot", "*/*", HTMIMEFooter, 1.0, 0.0, 0.0);
2.43 frystyk 37: HTConversion_add(c,"multipart/*", "*/*", HTBoundary, 1.0, 0.0, 0.0);
2.38 frystyk 38: HTConversion_add(c,"text/plain", "text/html", HTPlainToHTML, 1.0, 0.0, 0.0);
2.39 frystyk 39:
40: /*
41: ** The following conversions are converting ASCII output from various
42: ** protocols to HTML objects.
43: */
2.51 frystyk 44: HTConversion_add(c,"text/x-http", "*/*", HTTPStatus_new, 1.0, 0.0, 0.0);
2.42 frystyk 45: #if 0
46: HTConversion_add(c,"text/x-gopher", "www/present", HTGopherMenu, 1.0, 0.0, 0.0);
47: HTConversion_add(c,"text/x-cso", "www/present", HTGopherCSO, 1.0, 0.0, 0.0);
2.48 frystyk 48: HTConversion_add(c,"text/x-nntp-list", "*/*", HTNewsList, 1.0, 0.0, 0.0);
49: HTConversion_add(c,"text/x-nntp-over", "*/*", HTNewsGroup, 1.0, 0.0, 0.0);
50: HTConversion_add(c,"text/x-wais-source", "*/*", HTWSRCConvert, 1.0, 0.0, 0.0);
2.53 frystyk 51: #endif
2.43 frystyk 52:
2.31 frystyk 53: /*
2.45 frystyk 54: ** We also register a special content type guess stream that can figure out
55: ** the content type by reading the first bytes of the stream
56: */
57: HTConversion_add(c,"www/unknown", "*/*", HTGuess_new, 1.0, 0.0, 0.0);
2.46 frystyk 58:
59: /*
60: ** Handling Rule files is handled just like any other stream
61: ** This converter reads a rule file and generates the rules
62: */
2.48 frystyk 63: HTConversion_add(c,"application/x-www-rules","*/*", HTRules, 1.0, 0.0, 0.0);
2.46 frystyk 64:
2.45 frystyk 65: /*
2.34 frystyk 66: ** This dumps all other formats to local disk without any further
2.31 frystyk 67: ** action taken
68: */
2.38 frystyk 69: HTConversion_add(c,"*/*", "www/present", HTSaveLocally, 0.3, 0.0, 0.0);
2.23 frystyk 70: }
71:
72: /* BINDINGS BETWEEN MEDIA TYPES AND EXTERNAL VIEWERS/PRESENTERS
73: ** ------------------------------------------------------------
2.47 frystyk 74: ** Not done automaticly - may be done by application!
2.23 frystyk 75: ** The data objects are stored in temporary files before the external
76: ** program is called
77: */
2.38 frystyk 78: PUBLIC void HTPresenterInit (HTList * c)
2.1 timbl 79: {
80: #ifdef NeXT
2.38 frystyk 81: HTPresentation_add(c,"application/postscript", "open %s", NULL, 1.0, 2.0, 0.0);
2.10 luotonen 82: /* The following needs the GIF previewer -- you might not have it. */
2.19 howcome 83:
2.38 frystyk 84: HTPresentation_add(c,"image/gif", "open %s", NULL, 0.3, 2.0, 0.0);
2.44 frystyk 85: HTPresentation_add(c,"image/tiff", "open %s", NULL, 1.0, 2.0, 0.0);
2.41 frystyk 86: HTPresentation_add(c,"audio/basic", "open %s", NULL, 1.0, 2.0, 0.0);
87: HTPresentation_add(c,"*/*", "open %s", NULL, 0.05, 0.0, 0.0);
2.1 timbl 88: #else
2.10 luotonen 89: if (getenv("DISPLAY")) { /* Must have X11 */
2.38 frystyk 90: HTPresentation_add(c,"application/postscript", "ghostview %s", NULL, 1.0, 3.0, 0.0);
2.41 frystyk 91: HTPresentation_add(c,"image/gif", "xv %s", NULL, 1.0, 3.0, 0.0);
2.44 frystyk 92: HTPresentation_add(c,"image/tiff", "xv %s", NULL, 1.0, 3.0, 0.0);
2.38 frystyk 93: HTPresentation_add(c,"image/jpeg", "xv %s", NULL, 1.0, 3.0, 0.0);
2.44 frystyk 94: HTPresentation_add(c,"image/png", "xv %s", NULL, 1.0, 3.0, 0.0);
2.10 luotonen 95: }
2.1 timbl 96: #endif
2.15 frystyk 97: }
98:
99:
2.23 frystyk 100: /* PRESENTERS AND CONVERTERS AT THE SAME TIME
101: ** ------------------------------------------
2.47 frystyk 102: ** Not done automaticly - may be done by application!
2.23 frystyk 103: ** This function is only defined in order to preserve backward
104: ** compatibility.
105: */
2.38 frystyk 106: PUBLIC void HTFormatInit (HTList * c)
2.15 frystyk 107: {
2.23 frystyk 108: HTConverterInit(c);
109: HTPresenterInit(c);
110:
2.1 timbl 111: }
112:
2.55 frystyk 113: /* BINDINGS BETWEEN A ENCODING AND CODERS / DECODERS
114: ** --------------------------- ---------------------
115: ** Not done automaticly - may be done by application!
116: */
117: PUBLIC void HTEncoderInit (HTList * c)
118: {
2.63 frystyk 119: HTCoding_add(c, "chunked", HTChunkedEncoder, HTChunkedDecoder, 1.0);
2.55 frystyk 120: }
2.47 frystyk 121:
2.64 ! frystyk 122: /* REGISTER BEFORE FILTERS
! 123: ** -----------------------
! 124: ** The BEFORE filters handle proxies, caches, rule files etc.
! 125: ** The filters are called in the order by which the are registered
! 126: ** Not done automaticly - may be done by application!
! 127: */
! 128: PUBLIC void HTBeforeInit (void)
! 129: {
! 130: HTNetCall_addBefore(HTProxyFilter, NULL, 0);
! 131: HTNetCall_addBefore(HTRuleFilter, NULL, 0);
! 132: HTNetCall_addBefore(HTCacheFilter, NULL, 0);
! 133: HTNetCall_addBefore(HTCredentialsFilter, NULL, 0);
! 134: }
! 135:
! 136: /* REGISTER AFTER FILTERS
! 137: ** ----------------------
! 138: ** The AFTER filters handle error messages, logging, redirection,
! 139: ** authentication etc.
! 140: ** The filters are called in the order by which the are registered
! 141: ** Not done automaticly - may be done by application!
! 142: */
! 143: PUBLIC void HTAfterInit (void)
! 144: {
! 145: HTNetCall_addAfter(HTAuthFilter, NULL, HT_NO_ACCESS);
! 146: HTNetCall_addAfter(HTRedirectFilter, NULL, HT_TEMP_REDIRECT);
! 147: HTNetCall_addAfter(HTRedirectFilter, NULL, HT_PERM_REDIRECT);
! 148: HTNetCall_addAfter(HTLogFilter, NULL, HT_ALL);
! 149: HTNetCall_addAfter(HTInfoFilter, NULL, HT_ALL);
! 150: }
! 151:
! 152: /* REGISTER DEFAULT AUTHENTICATION SCHEMES
! 153: ** ---------------------------------------
! 154: ** This function registers the BASIC access authentication
! 155: */
! 156: PUBLIC void HTAAInit (void)
! 157: {
! 158: HTAA_newModule ("basic", HTBasic_generate, HTBasic_parse, HTBasic_delete);
! 159: }
! 160:
! 161: /* REGISTER BEFORE AND AFTER FILTERS
! 162: ** ---------------------------------
! 163: ** We register a commonly used set of BEFORE and AFTER filters.
2.47 frystyk 164: ** Not done automaticly - may be done by application!
165: */
166: PUBLIC void HTNetInit (void)
167: {
2.64 ! frystyk 168: HTBeforeInit();
! 169: HTAfterInit();
2.47 frystyk 170: }
171:
172:
173: /* REGISTER CALLBACKS FOR THE ALERT MANAGER
174: ** ----------------------------------------
175: ** We register a set of alert messages
176: ** Not done automaticly - may be done by application!
177: */
178: PUBLIC void HTAlertInit (void)
179: {
180: HTAlert_add(HTProgress, HT_A_PROGRESS);
181: HTAlert_add(HTError_print, HT_A_MESSAGE);
182: HTAlert_add(HTConfirm, HT_A_CONFIRM);
183: HTAlert_add(HTPrompt, HT_A_PROMPT);
184: HTAlert_add(HTPromptPassword, HT_A_SECRET);
185: HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
186: }
187:
2.53 frystyk 188: /* REGISTER ALL KNOWN TRANSPORTS IN THE LIBRARY
189: ** --------------------------------------------
190: ** Not done automaticly - may be done by application!
191: */
192: PUBLIC void HTTransportInit (void)
193: {
2.54 frystyk 194: HTTransport_add("tcp", HT_CH_SINGLE, HTReader_new, HTWriter_new);
195: HTTransport_add("buffered_tcp", HT_CH_SINGLE, HTReader_new, HTBufferWriter_new);
196: #ifndef NO_UNIX_IO
197: HTTransport_add("local", HT_CH_SINGLE, HTReader_new, HTWriter_new);
198: #else
199: HTTransport_add("local", HT_CH_SINGLE, HTANSIReader_new, HTANSIWriter_new);
200: #endif
2.53 frystyk 201: }
2.47 frystyk 202:
2.24 frystyk 203: /* REGISTER ALL KNOWN PROTOCOLS IN THE LIBRARY
204: ** -------------------------------------------
2.47 frystyk 205: ** Not done automaticly - may be done by application!
2.24 frystyk 206: */
2.63 frystyk 207: PUBLIC void HTProtocolInit (void)
2.24 frystyk 208: {
209: #ifndef DECNET
2.53 frystyk 210: HTProtocol_add("ftp", "tcp", NO, HTLoadFTP, NULL);
211: HTProtocol_add("nntp", "tcp", NO, HTLoadNews, NULL);
212: HTProtocol_add("news", "tcp", NO, HTLoadNews, NULL);
213: HTProtocol_add("gopher", "tcp", NO, HTLoadGopher, NULL);
2.24 frystyk 214: #ifdef HT_DIRECT_WAIS
2.53 frystyk 215: HTProtocol_add("wais", "", YES, HTLoadWAIS, NULL);
2.24 frystyk 216: #endif
217: #endif /* DECNET */
218:
2.54 frystyk 219: HTProtocol_add("http", "buffered_tcp", NO, HTLoadHTTP, NULL);
2.53 frystyk 220: HTProtocol_add("file", "local", NO, HTLoadFile, NULL);
221: HTProtocol_add("telnet", "", YES, HTLoadTelnet, NULL);
222: HTProtocol_add("tn3270", "", YES, HTLoadTelnet, NULL);
223: HTProtocol_add("rlogin", "", YES, HTLoadTelnet, NULL);
2.24 frystyk 224: }
2.1 timbl 225:
2.61 frystyk 226: /* REGISTER DEFULT EVENT MANAGER
227: ** -----------------------------
228: ** Not done automaticly - may be done by application!
229: */
230: PUBLIC void HTEventInit (void)
231: {
232: HTEvent_setRegisterCallback(HTEventrg_register);
233: HTEvent_setUnregisterCallback(HTEventrg_unregister);
234: }
235:
2.48 frystyk 236: /* BINDINGS BETWEEN ICONS AND MEDIA TYPES
237: ** --------------------------------------
238: ** Not done automaticly - may be done by application!
239: ** For directory listings etc. you can bind a set of icons to a set of
240: ** media types and special icons for directories and other objects that
241: ** do not have a media type.
242: */
2.61 frystyk 243: PUBLIC void HTIconInit (const char * url_prefix)
2.58 eric 244: {
2.61 frystyk 245: const char * prefix = url_prefix ? url_prefix : "/internal-icon/";
2.58 eric 246:
2.61 frystyk 247: HTIcon_addBlank("blank.xbm", prefix, NULL);
248: HTIcon_addDir("directory.xbm", prefix, "DIR");
249: HTIcon_addParent("back.xbm", prefix, "UP");
250: HTIcon_addUnknown("unknown.xbm", prefix, NULL);
251:
252: HTIcon_add("unknown.xbm", prefix, NULL, "*/*");
253: HTIcon_add("binary.xbm", prefix, "BIN", "binary");
254: HTIcon_add("unknown.xbm", prefix, NULL, "www/unknown");
255: HTIcon_add("text.xbm", prefix, "TXT", "text/*");
256: HTIcon_add("image.xbm", prefix, "IMG", "image/*");
257: HTIcon_add("movie.xbm", prefix, "MOV", "video/*");
258: HTIcon_add("sound.xbm", prefix, "AU", "audio/*");
259: HTIcon_add("tar.xbm", prefix, "TAR", "multipart/x-tar");
260: HTIcon_add("tar.xbm", prefix, "TAR", "multipart/x-gtar");
261: HTIcon_add("compressed.xbm",prefix, "CMP", "x-compress");
262: HTIcon_add("compressed.xbm",prefix, "GZP", "x-gzip");
263: HTIcon_add("index.xbm", prefix, "IDX", "application/x-gopher-index");
264: HTIcon_add("index2.xbm", prefix, "CSO", "application/x-gopher-cso");
265: HTIcon_add("telnet.xbm", prefix, "TEL", "application/x-gopher-telnet");
266: HTIcon_add("unknown.xbm", prefix, "DUP", "application/x-gopher-duplicate");
267: HTIcon_add("unknown.xbm", prefix, "TN", "application/x-gopher-tn3270");
2.58 eric 268: }
269:
2.57 eric 270: /* REGISTER ALL HTTP/1.1 MIME HEADERS
271: ** --------------------------------------------
272: ** Not done automaticly - may be done by application!
273: */
2.64 ! frystyk 274: PUBLIC void HTMIMEInit (void)
2.57 eric 275: {
276: struct {
277: char * string;
278: HTParserCallback * pHandler;
279: } fixedHandlers[] = {
2.61 frystyk 280: {"accept", &HTMIME_accept},
281: {"accept-charset", &HTMIME_acceptCharset},
282: {"accept-encoding", &HTMIME_acceptEncoding},
283: {"accept-language", &HTMIME_acceptLanguage},
284: {"accept-ranges", &HTMIME_acceptRanges},
285: {"age", &HTMIME_age},
286: {"allow", &HTMIME_allow},
287: {"authorization", NULL},
288: {"cache-control", NULL},
289: {"connection", &HTMIME_connection},
290: {"content-base", &HTMIME_contentBase},
291: {"content-encoding", &HTMIME_contentEncoding},
292: {"content-language", &HTMIME_contentLanguage},
293: {"content-length", &HTMIME_contentLength},
294: {"content-location", &HTMIME_contentLocation},
295: {"content-md5", &HTMIME_contentMD5},
296: {"content-range", &HTMIME_contentRange},
297: {"content-transfer-encoding", &HTMIME_contentTransferEncoding},
298: {"content-type", &HTMIME_contentType},
299: {"date", &HTMIME_date},
300: {"derived-from", &HTMIME_derivedFrom},
301: {"digest-MessageDigest", &HTMIME_messageDigest},
302: {"etag", &HTMIME_etag},
303: {"expires", &HTMIME_expires},
304: {"from", &HTMIME_from},
305: {"host", &HTMIME_host},
306: {"if-modified-since", &HTMIME_ifModifiedSince},
307: {"if-match", &HTMIME_ifMatch},
308: {"if-none-match", &HTMIME_ifNoneMatch},
309: {"if-range", &HTMIME_ifRange},
310: {"if-unmodified-since", &HTMIME_ifUnmodifiedSince},
2.57 eric 311: {"keep-alive", NULL},
2.61 frystyk 312: {"last-modified", &HTMIME_lastModified},
313: {"link", &HTMIME_link},
314: {"location", &HTMIME_location},
315: {"max-forwards", &HTMIME_maxForwards},
2.57 eric 316: {"mime-version", NULL},
2.61 frystyk 317: {"pragma", &HTMIME_pragma},
318: {"proxy-authenticate", &HTMIME_proxyAuthenticate},
319: {"proxy-authorization", &HTMIME_proxyAuthorization},
320: {"public", &HTMIME_public},
321: {"range", &HTMIME_range},
322: {"referer", &HTMIME_referer},
323: {"retry-after", &HTMIME_retryAfter},
2.62 frystyk 324: {"server", &HTMIME_server},
2.61 frystyk 325: {"title", &HTMIME_title},
326: {"transfer-encoding", &HTMIME_contentTransferEncoding},
327: {"upgrade", &HTMIME_upgrade},
328: {"uri", &HTMIME_uri},
329: {"user-agent", &HTMIME_userAgent},
330: {"vary", &HTMIME_vary},
331: {"version", &HTMIME_version},
332: {"via", &HTMIME_via},
333: {"warning", &HTMIME_warning},
334: {"www-authenticate", &HTMIME_authenticate},
2.57 eric 335: };
336: int i;
337:
338: for (i = 0; i < sizeof(fixedHandlers)/sizeof(fixedHandlers[0]); i++)
339: HTHeader_addParser(fixedHandlers[i].string, NO,
340: fixedHandlers[i].pHandler);
341: }
342:
Webmaster