Annotation of libwww/Library/src/HTInit.c, revision 2.49
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.9 duns 6: **
2.20 frystyk 7: ** Define a basic set of suffixes and presentations
2.1 timbl 8: */
9:
2.22 frystyk 10: /* Library include files */
11: #include "tcp.h"
12: #include "HTUtils.h"
2.24 frystyk 13: #include "HTFormat.h"
14: #include "HTList.h"
15: #include "HTBind.h"
2.28 frystyk 16: #include "HTProt.h"
2.22 frystyk 17: #include "HTInit.h" /* Implemented here */
2.1 timbl 18:
2.29 frystyk 19: /* ------------------------------------------------------------------------- */
20:
2.23 frystyk 21: /* BINDINGS BETWEEN A SOURCE MEDIA TYPE AND A DEST MEDIA TYPE (CONVERSION)
22: ** ----------------------------------------------------------------------
2.47 frystyk 23: ** Not done automaticly - may be done by application!
2.23 frystyk 24: */
2.38 frystyk 25: PUBLIC void HTConverterInit (HTList * c)
2.23 frystyk 26: {
2.31 frystyk 27: /*
28: ** This set of converters uses the HTML/HText interface.
2.34 frystyk 29: ** If you do not want this interface then replace them!
2.31 frystyk 30: */
2.38 frystyk 31: HTConversion_add(c,"text/html", "www/present", HTMLPresent, 1.0, 0.0, 0.0);
32: HTConversion_add(c,"text/plain", "www/present", HTPlainPresent, 1.0, 0.0, 0.0);
33: HTConversion_add(c,"text/html", "text/x-c", HTMLToC, 0.5, 0.0, 0.0);
34: HTConversion_add(c,"text/html", "text/plain", HTMLToPlain, 0.5, 0.0, 0.0);
35: HTConversion_add(c,"text/html", "text/latex", HTMLToTeX, 1.0, 0.0, 0.0);
2.31 frystyk 36:
37: /*
2.49 ! frystyk 38: ** You can get debug information out through the debug stream if you set
! 39: ** the debug format appropriately
! 40: */
! 41: HTConversion_add(c,"*/*", "www/debug", HTBlackHoleConverter, 1.0, 0.0, 0.0);
! 42:
! 43: /*
2.31 frystyk 44: ** These are converters that converts to something other than www/present,
45: ** that is not directly outputting someting to the user on the screen
46: */
2.43 frystyk 47: HTConversion_add(c,"message/rfc822", "*/*", HTMIMEConvert, 1.0, 0.0, 0.0);
48: HTConversion_add(c,"multipart/*", "*/*", HTBoundary, 1.0, 0.0, 0.0);
2.38 frystyk 49: HTConversion_add(c,"text/plain", "text/html", HTPlainToHTML, 1.0, 0.0, 0.0);
2.39 frystyk 50:
51: /*
52: ** The following conversions are converting ASCII output from various
53: ** protocols to HTML objects.
54: */
2.42 frystyk 55: #if 0
56: HTConversion_add(c,"text/x-gopher", "www/present", HTGopherMenu, 1.0, 0.0, 0.0);
57: HTConversion_add(c,"text/x-cso", "www/present", HTGopherCSO, 1.0, 0.0, 0.0);
58: #endif
2.48 frystyk 59: HTConversion_add(c,"text/x-nntp-list", "*/*", HTNewsList, 1.0, 0.0, 0.0);
60: HTConversion_add(c,"text/x-nntp-over", "*/*", HTNewsGroup, 1.0, 0.0, 0.0);
61: HTConversion_add(c,"text/x-wais-source", "*/*", HTWSRCConvert, 1.0, 0.0, 0.0);
2.43 frystyk 62:
2.31 frystyk 63: /*
2.45 frystyk 64: ** We also register a special content type guess stream that can figure out
65: ** the content type by reading the first bytes of the stream
66: */
67: HTConversion_add(c,"www/unknown", "*/*", HTGuess_new, 1.0, 0.0, 0.0);
2.46 frystyk 68:
69: /*
70: ** Handling Rule files is handled just like any other stream
71: ** This converter reads a rule file and generates the rules
72: */
2.48 frystyk 73: HTConversion_add(c,"application/x-www-rules","*/*", HTRules, 1.0, 0.0, 0.0);
2.46 frystyk 74:
2.45 frystyk 75: /*
2.34 frystyk 76: ** This dumps all other formats to local disk without any further
2.31 frystyk 77: ** action taken
78: */
2.38 frystyk 79: HTConversion_add(c,"*/*", "www/present", HTSaveLocally, 0.3, 0.0, 0.0);
2.23 frystyk 80: }
81:
82: /* BINDINGS BETWEEN MEDIA TYPES AND EXTERNAL VIEWERS/PRESENTERS
83: ** ------------------------------------------------------------
2.47 frystyk 84: ** Not done automaticly - may be done by application!
2.23 frystyk 85: ** The data objects are stored in temporary files before the external
86: ** program is called
87: */
2.38 frystyk 88: PUBLIC void HTPresenterInit (HTList * c)
2.1 timbl 89: {
90: #ifdef NeXT
2.38 frystyk 91: HTPresentation_add(c,"application/postscript", "open %s", NULL, 1.0, 2.0, 0.0);
2.10 luotonen 92: /* The following needs the GIF previewer -- you might not have it. */
2.19 howcome 93:
2.38 frystyk 94: HTPresentation_add(c,"image/gif", "open %s", NULL, 0.3, 2.0, 0.0);
2.44 frystyk 95: HTPresentation_add(c,"image/tiff", "open %s", NULL, 1.0, 2.0, 0.0);
2.41 frystyk 96: HTPresentation_add(c,"audio/basic", "open %s", NULL, 1.0, 2.0, 0.0);
97: HTPresentation_add(c,"*/*", "open %s", NULL, 0.05, 0.0, 0.0);
2.1 timbl 98: #else
2.10 luotonen 99: if (getenv("DISPLAY")) { /* Must have X11 */
2.38 frystyk 100: HTPresentation_add(c,"application/postscript", "ghostview %s", NULL, 1.0, 3.0, 0.0);
2.41 frystyk 101: HTPresentation_add(c,"image/gif", "xv %s", NULL, 1.0, 3.0, 0.0);
2.44 frystyk 102: HTPresentation_add(c,"image/tiff", "xv %s", NULL, 1.0, 3.0, 0.0);
2.38 frystyk 103: HTPresentation_add(c,"image/jpeg", "xv %s", NULL, 1.0, 3.0, 0.0);
2.44 frystyk 104: HTPresentation_add(c,"image/png", "xv %s", NULL, 1.0, 3.0, 0.0);
2.10 luotonen 105: }
2.1 timbl 106: #endif
2.15 frystyk 107: }
108:
109:
2.23 frystyk 110: /* PRESENTERS AND CONVERTERS AT THE SAME TIME
111: ** ------------------------------------------
2.47 frystyk 112: ** Not done automaticly - may be done by application!
2.23 frystyk 113: ** This function is only defined in order to preserve backward
114: ** compatibility.
115: */
2.38 frystyk 116: PUBLIC void HTFormatInit (HTList * c)
2.15 frystyk 117: {
2.23 frystyk 118: HTConverterInit(c);
119: HTPresenterInit(c);
120:
2.1 timbl 121: }
122:
2.47 frystyk 123:
124: /* REGISTER CALLBACKS FOR THE NET MANAGER
125: ** --------------------------------------
126: ** We register two often used callback functions:
127: ** a BEFORE and a AFTER callback
128: ** Not done automaticly - may be done by application!
129: */
130: PUBLIC void HTNetInit (void)
131: {
132: HTNetCall_addBefore(HTLoadStart, 0);
133: HTNetCall_addAfter(HTLoadTerminate, HT_ALL);
134: }
135:
136:
137: /* REGISTER CALLBACKS FOR THE ALERT MANAGER
138: ** ----------------------------------------
139: ** We register a set of alert messages
140: ** Not done automaticly - may be done by application!
141: */
142: PUBLIC void HTAlertInit (void)
143: {
144: HTAlert_add(HTProgress, HT_A_PROGRESS);
145: HTAlert_add(HTError_print, HT_A_MESSAGE);
146: HTAlert_add(HTConfirm, HT_A_CONFIRM);
147: HTAlert_add(HTPrompt, HT_A_PROMPT);
148: HTAlert_add(HTPromptPassword, HT_A_SECRET);
149: HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
150: }
151:
152:
2.24 frystyk 153: /* REGISTER ALL KNOWN PROTOCOLS IN THE LIBRARY
154: ** -------------------------------------------
2.47 frystyk 155: ** Not done automaticly - may be done by application!
2.24 frystyk 156: */
2.33 frystyk 157: PUBLIC void HTAccessInit (void)
2.24 frystyk 158: {
159: #ifndef DECNET
2.48 frystyk 160: HTProtocol_add("ftp", NO, HTLoadFTP, NULL);
161: HTProtocol_add("nntp", NO, HTLoadNews, NULL);
162: HTProtocol_add("news", NO, HTLoadNews, NULL);
163: HTProtocol_add("gopher", NO, HTLoadGopher, NULL);
2.24 frystyk 164: #ifdef HT_DIRECT_WAIS
2.48 frystyk 165: HTProtocol_add("wais", YES, HTLoadWAIS, NULL);
2.24 frystyk 166: #endif
167: #endif /* DECNET */
168:
2.48 frystyk 169: HTProtocol_add("http", NO, HTLoadHTTP, NULL);
170: HTProtocol_add("file", NO, HTLoadFile, NULL);
171: HTProtocol_add("telnet", YES, HTLoadTelnet, NULL);
172: HTProtocol_add("tn3270", YES, HTLoadTelnet, NULL);
173: HTProtocol_add("rlogin", YES, HTLoadTelnet, NULL);
2.24 frystyk 174: }
2.1 timbl 175:
2.48 frystyk 176: #if 0
177: /* BINDINGS BETWEEN ICONS AND MEDIA TYPES
178: ** --------------------------------------
179: ** Not done automaticly - may be done by application!
180: ** For directory listings etc. you can bind a set of icons to a set of
181: ** media types and special icons for directories and other objects that
182: ** do not have a media type.
183: */
184: PUBLIC void HTStdIconInit (CONST char * url_prefix)
185: {
186: CONST char * p = url_prefix ? url_prefix : "/internal-icon/";
187:
188: HTAddBlankIcon (prefixed(p,"blank.xbm"), NULL );
189: HTAddDirIcon (prefixed(p,"directory.xbm"),"DIR" );
190: HTAddParentIcon (prefixed(p,"back.xbm"), "UP" );
191: HTAddUnknownIcon(prefixed(p,"unknown.xbm"), NULL );
192: HTAddIcon(prefixed(p,"unknown.xbm"), NULL, "*/*");
193: HTAddIcon(prefixed(p,"binary.xbm"), "BIN", "binary");
194: HTAddIcon(prefixed(p,"unknown.xbm"), NULL, "www/unknown");
195: HTAddIcon(prefixed(p,"text.xbm"), "TXT", "text/*");
196: HTAddIcon(prefixed(p,"image.xbm"), "IMG", "image/*");
197: HTAddIcon(prefixed(p,"movie.xbm"), "MOV", "video/*");
198: HTAddIcon(prefixed(p,"sound.xbm"), "AU", "audio/*");
199: HTAddIcon(prefixed(p,"tar.xbm"), "TAR", "multipart/x-tar");
200: HTAddIcon(prefixed(p,"tar.xbm"), "TAR", "multipart/x-gtar");
201: HTAddIcon(prefixed(p,"compressed.xbm"), "CMP", "x-compress");
202: HTAddIcon(prefixed(p,"compressed.xbm"), "GZP", "x-gzip");
203: HTAddIcon(prefixed(p,"index.xbm"), "IDX", "application/x-gopher-index");
204: HTAddIcon(prefixed(p,"index2.xbm"), "CSO", "application/x-gopher-cso");
205: HTAddIcon(prefixed(p,"telnet.xbm"), "TEL", "application/x-gopher-telnet");
206: HTAddIcon(prefixed(p,"unknown.xbm"), "DUP", "application/x-gopher-duplicate");
207: HTAddIcon(prefixed(p,"unknown.xbm"), "TN", "application/x-gopher-tn3270");
208: }
209: #endif
210:
2.23 frystyk 211: /* BINDINGS BETWEEN FILE EXTENSIONS AND MEDIA TYPES
212: ** ------------------------------------------------
2.47 frystyk 213: ** Not done automaticly - may be done by application!
2.23 frystyk 214: ** The LAST suffix for a type is that used for temporary files of that
215: ** type. The quality is an apriori bias as to whether the file should be
2.1 timbl 216: ** used. Not that different suffixes can be used to represent files
217: ** which are of the same format but are originals or regenerated,
2.48 frystyk 218: ** with different values.
2.1 timbl 219: */
2.38 frystyk 220: PUBLIC void HTFileInit (void)
2.10 luotonen 221: {
2.24 frystyk 222: /* Suffix Content-Type Encoding Lang Quality */
2.12 luotonen 223:
2.41 frystyk 224: HTBind_add("mime", "message/rfc822", "8bit", NULL, 1.0); /* Internal -- MIME is */
2.24 frystyk 225: /* not recursive */
2.40 frystyk 226: HTBind_add("bin", "application/octet-stream", "binary", NULL, 1.0); /* Uninterpreted binary */
227: HTBind_add("oda", "application/oda", "binary", NULL, 1.0);
228: HTBind_add("pdf", "application/pdf", "binary", NULL, 1.0);
229: HTBind_add("ai", "application/postscript", "8bit", NULL, 0.5); /* Adobe Illustrator */
230: HTBind_add("PS", "application/postscript", "8bit", NULL, 0.8); /* PostScript */
231: HTBind_add("eps", "application/postscript", "8bit", NULL, 0.8);
232: HTBind_add("ps", "application/postscript", "8bit", NULL, 0.8);
233: HTBind_add("gtar", "application/x-gtar", "binary", NULL, 1.0); /* Gnu tar */
234: HTBind_add("rtf", "application/x-rtf", "7bit", NULL, 1.0); /* RTF */
235: HTBind_add("csh", "application/x-csh", "7bit", NULL, 0.5); /* C-shell script */
236: HTBind_add("dvi", "application/x-dvi", "binary", NULL, 1.0); /* TeX DVI */
237: HTBind_add("hdf", "application/x-hdf", "binary", NULL, 1.0); /* NCSA HDF data file */
238: HTBind_add("latex", "application/x-latex", "8bit", NULL, 1.0); /* LaTeX source */
239: HTBind_add("nc", "application/x-netcdf", "binary", NULL, 1.0); /* Unidata netCDF data */
240: HTBind_add("cdf", "application/x-netcdf", "binary", NULL, 1.0);
241: HTBind_add("sh", "application/x-sh", "7bit", NULL, 0.5); /* Shell-script */
242: HTBind_add("tar", "application/x-tar", "binary", NULL, 1.0); /* 4.3BSD tar */
243: HTBind_add("tcl", "application/x-tcl", "7bit", NULL, 0.5); /* TCL-script */
244: HTBind_add("tex", "application/x-tex", "8bit", NULL, 1.0); /* TeX source */
245: HTBind_add("texi", "application/x-texinfo", "7bit", NULL, 1.0); /* Texinfo */
246: HTBind_add("texinfo","application/x-texinfo", "7bit", NULL, 1.0);
247: HTBind_add("t", "application/x-troff", "7bit", NULL, 0.5); /* Troff */
248: HTBind_add("roff", "application/x-troff", "7bit", NULL, 0.5);
249: HTBind_add("tr", "application/x-troff", "7bit", NULL, 0.5);
250: HTBind_add("man", "application/x-troff-man", "7bit", NULL, 0.5); /* Troff with man macros*/
251: HTBind_add("me", "application/x-troff-me", "7bit", NULL, 0.5); /* Troff with me macros */
252: HTBind_add("ms", "application/x-troff-ms", "7bit", NULL, 0.5); /* Troff with ms macros */
253: HTBind_add("src", "application/x-wais-source", "7bit", NULL, 1.0); /* WAIS source */
254: HTBind_add("bcpio", "application/x-bcpio", "binary", NULL, 1.0); /* Old binary CPIO */
255: HTBind_add("cpio", "application/x-cpio", "binary", NULL, 1.0); /* POSIX CPIO */
256: HTBind_add("shar", "application/x-shar", "8bit", NULL, 1.0); /* Shell archive */
257: HTBind_add("sv4cpio","application/x-sv4cpio", "binary", NULL, 1.0); /* SVR4 CPIO */
258: HTBind_add("sv4crc", "application/x-sv4crc", "binary", NULL, 1.0); /* SVR4 CPIO with CRC */
259: HTBind_add("ustar", "application/x-ustar", "binary", NULL, 1.0); /* POSIX tar */
260: HTBind_add("snd", "audio/basic", "binary", NULL, 1.0); /* Audio */
261: HTBind_add("au", "audio/basic", "binary", NULL, 1.0);
262: HTBind_add("aiff", "audio/x-aiff", "binary", NULL, 1.0);
263: HTBind_add("aifc", "audio/x-aiff", "binary", NULL, 1.0);
264: HTBind_add("aif", "audio/x-aiff", "binary", NULL, 1.0);
265: HTBind_add("wav", "audio/x-wav", "binary", NULL, 1.0); /* Windows+ WAVE format */
266: HTBind_add("gif", "image/gif", "binary", NULL, 1.0); /* GIF */
2.44 frystyk 267: HTBind_add("png", "image/png", "binary", NULL, 1.0); /* PNG */
2.40 frystyk 268: HTBind_add("ief", "image/ief", "binary", NULL, 1.0); /* Image Exchange fmt */
269: HTBind_add("jpg", "image/jpeg", "binary", NULL, 1.0); /* JPEG */
270: HTBind_add("JPG", "image/jpeg", "binary", NULL, 1.0);
271: HTBind_add("JPE", "image/jpeg", "binary", NULL, 1.0);
272: HTBind_add("jpe", "image/jpeg", "binary", NULL, 1.0);
273: HTBind_add("JPEG", "image/jpeg", "binary", NULL, 1.0);
274: HTBind_add("jpeg", "image/jpeg", "binary", NULL, 1.0);
275: HTBind_add("tif", "image/tiff", "binary", NULL, 1.0); /* TIFF */
276: HTBind_add("tiff", "image/tiff", "binary", NULL, 1.0);
277: HTBind_add("ras", "image/cmu-raster", "binary", NULL, 1.0);
278: HTBind_add("pnm", "image/x-portable-anymap", "binary", NULL, 1.0); /* PBM Anymap format */
279: HTBind_add("pbm", "image/x-portable-bitmap", "binary", NULL, 1.0); /* PBM Bitmap format */
280: HTBind_add("pgm", "image/x-portable-graymap", "binary", NULL, 1.0); /* PBM Graymap format */
281: HTBind_add("ppm", "image/x-portable-pixmap", "binary", NULL, 1.0); /* PBM Pixmap format */
282: HTBind_add("rgb", "image/x-rgb", "binary", NULL, 1.0);
283: HTBind_add("xbm", "image/x-xbitmap", "binary", NULL, 1.0); /* X bitmap */
284: HTBind_add("xpm", "image/x-xpixmap", "binary", NULL, 1.0); /* X pixmap format */
285: HTBind_add("xwd", "image/x-xwindowdump", "binary", NULL, 1.0); /* X window dump (xwd) */
286: HTBind_add("html", "text/html", "8bit", NULL, 1.0); /* HTML */
287: HTBind_add("c", "text/plain", "7bit", NULL, 0.5); /* C source */
288: HTBind_add("h", "text/plain", "7bit", NULL, 0.5); /* C headers */
289: HTBind_add("C", "text/plain", "7bit", NULL, 0.5); /* C++ source */
290: HTBind_add("cc", "text/plain", "7bit", NULL, 0.5); /* C++ source */
291: HTBind_add("hh", "text/plain", "7bit", NULL, 0.5); /* C++ headers */
292: HTBind_add("m", "text/plain", "7bit", NULL, 0.5); /* Objective-C source */
293: HTBind_add("f90", "text/plain", "7bit", NULL, 0.5); /* Fortran 90 source */
294: HTBind_add("txt", "text/plain", "7bit", NULL, 0.5); /* Plain text */
295: HTBind_add("rtx", "text/richtext", "7bit", NULL, 1.0); /* MIME Richtext format */
296: HTBind_add("tsv", "text/tab-separated-values", "7bit", NULL, 1.0); /* Tab-separated values */
297: HTBind_add("etx", "text/x-setext", "7bit", NULL, 0.9); /* Struct Enchanced Txt */
298: HTBind_add("MPG", "video/mpeg", "binary", NULL, 1.0); /* MPEG */
299: HTBind_add("mpg", "video/mpeg", "binary", NULL, 1.0);
300: HTBind_add("MPE", "video/mpeg", "binary", NULL, 1.0);
301: HTBind_add("mpe", "video/mpeg", "binary", NULL, 1.0);
302: HTBind_add("MPEG", "video/mpeg", "binary", NULL, 1.0);
303: HTBind_add("mpeg", "video/mpeg", "binary", NULL, 1.0);
304: HTBind_add("qt", "video/quicktime", "binary", NULL, 1.0); /* QuickTime */
305: HTBind_add("mov", "video/quicktime", "binary", NULL, 1.0);
306: HTBind_add("avi", "video/x-msvideo", "binary", NULL, 1.0); /* MS Video for Windows */
307: HTBind_add("movie", "video/x-sgi-movie", "binary", NULL, 1.0); /* SGI "moviepalyer" */
2.24 frystyk 308:
2.40 frystyk 309: HTBind_add("zip", NULL, "zip", NULL, 1.0); /* PKZIP */
310: HTBind_add("Z", NULL, "compress", NULL, 1.0); /* Compressed data */
311: HTBind_add("gz", NULL, "gzip", NULL, 1.0); /* Gnu Compressed data */
2.46 frystyk 312:
313: HTBind_add("conf", "text/x-www-rules", "8bit", NULL, 1.0); /* CONFIGURATION FILE */
2.1 timbl 314:
2.40 frystyk 315: HTBind_add("*.*", "www/unknown", "binary", NULL, 0.1); /* Unknown suffix */
316: HTBind_add("*", "www/unknown", "7bit", NULL, 0.5); /* No suffix */
2.1 timbl 317: }
318:
Webmaster