Annotation of libwww/Library/src/HTInit.c, revision 2.50
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"
2.28 frystyk 15: #include "HTProt.h"
2.22 frystyk 16: #include "HTInit.h" /* Implemented here */
2.1 timbl 17:
2.29 frystyk 18: /* ------------------------------------------------------------------------- */
19:
2.23 frystyk 20: /* BINDINGS BETWEEN A SOURCE MEDIA TYPE AND A DEST MEDIA TYPE (CONVERSION)
21: ** ----------------------------------------------------------------------
2.47 frystyk 22: ** Not done automaticly - may be done by application!
2.23 frystyk 23: */
2.38 frystyk 24: PUBLIC void HTConverterInit (HTList * c)
2.23 frystyk 25: {
2.31 frystyk 26: /*
27: ** This set of converters uses the HTML/HText interface.
2.34 frystyk 28: ** If you do not want this interface then replace them!
2.31 frystyk 29: */
2.38 frystyk 30: HTConversion_add(c,"text/html", "www/present", HTMLPresent, 1.0, 0.0, 0.0);
31: HTConversion_add(c,"text/plain", "www/present", HTPlainPresent, 1.0, 0.0, 0.0);
32: HTConversion_add(c,"text/html", "text/x-c", HTMLToC, 0.5, 0.0, 0.0);
33: HTConversion_add(c,"text/html", "text/plain", HTMLToPlain, 0.5, 0.0, 0.0);
34: HTConversion_add(c,"text/html", "text/latex", HTMLToTeX, 1.0, 0.0, 0.0);
2.31 frystyk 35:
36: /*
2.49 frystyk 37: ** You can get debug information out through the debug stream if you set
38: ** the debug format appropriately
39: */
40: HTConversion_add(c,"*/*", "www/debug", HTBlackHoleConverter, 1.0, 0.0, 0.0);
41:
42: /*
2.31 frystyk 43: ** These are converters that converts to something other than www/present,
44: ** that is not directly outputting someting to the user on the screen
45: */
2.43 frystyk 46: HTConversion_add(c,"message/rfc822", "*/*", HTMIMEConvert, 1.0, 0.0, 0.0);
47: HTConversion_add(c,"multipart/*", "*/*", HTBoundary, 1.0, 0.0, 0.0);
2.38 frystyk 48: HTConversion_add(c,"text/plain", "text/html", HTPlainToHTML, 1.0, 0.0, 0.0);
2.39 frystyk 49:
50: /*
51: ** The following conversions are converting ASCII output from various
52: ** protocols to HTML objects.
53: */
2.42 frystyk 54: #if 0
55: HTConversion_add(c,"text/x-gopher", "www/present", HTGopherMenu, 1.0, 0.0, 0.0);
56: HTConversion_add(c,"text/x-cso", "www/present", HTGopherCSO, 1.0, 0.0, 0.0);
57: #endif
2.48 frystyk 58: HTConversion_add(c,"text/x-nntp-list", "*/*", HTNewsList, 1.0, 0.0, 0.0);
59: HTConversion_add(c,"text/x-nntp-over", "*/*", HTNewsGroup, 1.0, 0.0, 0.0);
60: HTConversion_add(c,"text/x-wais-source", "*/*", HTWSRCConvert, 1.0, 0.0, 0.0);
2.43 frystyk 61:
2.31 frystyk 62: /*
2.45 frystyk 63: ** We also register a special content type guess stream that can figure out
64: ** the content type by reading the first bytes of the stream
65: */
66: HTConversion_add(c,"www/unknown", "*/*", HTGuess_new, 1.0, 0.0, 0.0);
2.46 frystyk 67:
68: /*
69: ** Handling Rule files is handled just like any other stream
70: ** This converter reads a rule file and generates the rules
71: */
2.48 frystyk 72: HTConversion_add(c,"application/x-www-rules","*/*", HTRules, 1.0, 0.0, 0.0);
2.46 frystyk 73:
2.45 frystyk 74: /*
2.34 frystyk 75: ** This dumps all other formats to local disk without any further
2.31 frystyk 76: ** action taken
77: */
2.38 frystyk 78: HTConversion_add(c,"*/*", "www/present", HTSaveLocally, 0.3, 0.0, 0.0);
2.23 frystyk 79: }
80:
81: /* BINDINGS BETWEEN MEDIA TYPES AND EXTERNAL VIEWERS/PRESENTERS
82: ** ------------------------------------------------------------
2.47 frystyk 83: ** Not done automaticly - may be done by application!
2.23 frystyk 84: ** The data objects are stored in temporary files before the external
85: ** program is called
86: */
2.38 frystyk 87: PUBLIC void HTPresenterInit (HTList * c)
2.1 timbl 88: {
89: #ifdef NeXT
2.38 frystyk 90: HTPresentation_add(c,"application/postscript", "open %s", NULL, 1.0, 2.0, 0.0);
2.10 luotonen 91: /* The following needs the GIF previewer -- you might not have it. */
2.19 howcome 92:
2.38 frystyk 93: HTPresentation_add(c,"image/gif", "open %s", NULL, 0.3, 2.0, 0.0);
2.44 frystyk 94: HTPresentation_add(c,"image/tiff", "open %s", NULL, 1.0, 2.0, 0.0);
2.41 frystyk 95: HTPresentation_add(c,"audio/basic", "open %s", NULL, 1.0, 2.0, 0.0);
96: HTPresentation_add(c,"*/*", "open %s", NULL, 0.05, 0.0, 0.0);
2.1 timbl 97: #else
2.10 luotonen 98: if (getenv("DISPLAY")) { /* Must have X11 */
2.38 frystyk 99: HTPresentation_add(c,"application/postscript", "ghostview %s", NULL, 1.0, 3.0, 0.0);
2.41 frystyk 100: HTPresentation_add(c,"image/gif", "xv %s", NULL, 1.0, 3.0, 0.0);
2.44 frystyk 101: HTPresentation_add(c,"image/tiff", "xv %s", NULL, 1.0, 3.0, 0.0);
2.38 frystyk 102: HTPresentation_add(c,"image/jpeg", "xv %s", NULL, 1.0, 3.0, 0.0);
2.44 frystyk 103: HTPresentation_add(c,"image/png", "xv %s", NULL, 1.0, 3.0, 0.0);
2.10 luotonen 104: }
2.1 timbl 105: #endif
2.15 frystyk 106: }
107:
108:
2.23 frystyk 109: /* PRESENTERS AND CONVERTERS AT THE SAME TIME
110: ** ------------------------------------------
2.47 frystyk 111: ** Not done automaticly - may be done by application!
2.23 frystyk 112: ** This function is only defined in order to preserve backward
113: ** compatibility.
114: */
2.38 frystyk 115: PUBLIC void HTFormatInit (HTList * c)
2.15 frystyk 116: {
2.23 frystyk 117: HTConverterInit(c);
118: HTPresenterInit(c);
119:
2.1 timbl 120: }
121:
2.47 frystyk 122:
123: /* REGISTER CALLBACKS FOR THE NET MANAGER
124: ** --------------------------------------
125: ** We register two often used callback functions:
126: ** a BEFORE and a AFTER callback
127: ** Not done automaticly - may be done by application!
128: */
129: PUBLIC void HTNetInit (void)
130: {
131: HTNetCall_addBefore(HTLoadStart, 0);
132: HTNetCall_addAfter(HTLoadTerminate, HT_ALL);
133: }
134:
135:
136: /* REGISTER CALLBACKS FOR THE ALERT MANAGER
137: ** ----------------------------------------
138: ** We register a set of alert messages
139: ** Not done automaticly - may be done by application!
140: */
141: PUBLIC void HTAlertInit (void)
142: {
143: HTAlert_add(HTProgress, HT_A_PROGRESS);
144: HTAlert_add(HTError_print, HT_A_MESSAGE);
145: HTAlert_add(HTConfirm, HT_A_CONFIRM);
146: HTAlert_add(HTPrompt, HT_A_PROMPT);
147: HTAlert_add(HTPromptPassword, HT_A_SECRET);
148: HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
149: }
150:
151:
2.24 frystyk 152: /* REGISTER ALL KNOWN PROTOCOLS IN THE LIBRARY
153: ** -------------------------------------------
2.47 frystyk 154: ** Not done automaticly - may be done by application!
2.24 frystyk 155: */
2.33 frystyk 156: PUBLIC void HTAccessInit (void)
2.24 frystyk 157: {
158: #ifndef DECNET
2.48 frystyk 159: HTProtocol_add("ftp", NO, HTLoadFTP, NULL);
160: HTProtocol_add("nntp", NO, HTLoadNews, NULL);
161: HTProtocol_add("news", NO, HTLoadNews, NULL);
162: HTProtocol_add("gopher", NO, HTLoadGopher, NULL);
2.24 frystyk 163: #ifdef HT_DIRECT_WAIS
2.48 frystyk 164: HTProtocol_add("wais", YES, HTLoadWAIS, NULL);
2.24 frystyk 165: #endif
166: #endif /* DECNET */
167:
2.48 frystyk 168: HTProtocol_add("http", NO, HTLoadHTTP, NULL);
169: HTProtocol_add("file", NO, HTLoadFile, NULL);
170: HTProtocol_add("telnet", YES, HTLoadTelnet, NULL);
171: HTProtocol_add("tn3270", YES, HTLoadTelnet, NULL);
172: HTProtocol_add("rlogin", YES, HTLoadTelnet, NULL);
2.24 frystyk 173: }
2.1 timbl 174:
2.48 frystyk 175: #if 0
176: /* BINDINGS BETWEEN ICONS AND MEDIA TYPES
177: ** --------------------------------------
178: ** Not done automaticly - may be done by application!
179: ** For directory listings etc. you can bind a set of icons to a set of
180: ** media types and special icons for directories and other objects that
181: ** do not have a media type.
182: */
183: PUBLIC void HTStdIconInit (CONST char * url_prefix)
184: {
185: CONST char * p = url_prefix ? url_prefix : "/internal-icon/";
186:
187: HTAddBlankIcon (prefixed(p,"blank.xbm"), NULL );
188: HTAddDirIcon (prefixed(p,"directory.xbm"),"DIR" );
189: HTAddParentIcon (prefixed(p,"back.xbm"), "UP" );
190: HTAddUnknownIcon(prefixed(p,"unknown.xbm"), NULL );
191: HTAddIcon(prefixed(p,"unknown.xbm"), NULL, "*/*");
192: HTAddIcon(prefixed(p,"binary.xbm"), "BIN", "binary");
193: HTAddIcon(prefixed(p,"unknown.xbm"), NULL, "www/unknown");
194: HTAddIcon(prefixed(p,"text.xbm"), "TXT", "text/*");
195: HTAddIcon(prefixed(p,"image.xbm"), "IMG", "image/*");
196: HTAddIcon(prefixed(p,"movie.xbm"), "MOV", "video/*");
197: HTAddIcon(prefixed(p,"sound.xbm"), "AU", "audio/*");
198: HTAddIcon(prefixed(p,"tar.xbm"), "TAR", "multipart/x-tar");
199: HTAddIcon(prefixed(p,"tar.xbm"), "TAR", "multipart/x-gtar");
200: HTAddIcon(prefixed(p,"compressed.xbm"), "CMP", "x-compress");
201: HTAddIcon(prefixed(p,"compressed.xbm"), "GZP", "x-gzip");
202: HTAddIcon(prefixed(p,"index.xbm"), "IDX", "application/x-gopher-index");
203: HTAddIcon(prefixed(p,"index2.xbm"), "CSO", "application/x-gopher-cso");
204: HTAddIcon(prefixed(p,"telnet.xbm"), "TEL", "application/x-gopher-telnet");
205: HTAddIcon(prefixed(p,"unknown.xbm"), "DUP", "application/x-gopher-duplicate");
206: HTAddIcon(prefixed(p,"unknown.xbm"), "TN", "application/x-gopher-tn3270");
207: }
208: #endif
Webmaster