Annotation of libwww/Library/src/HTInit.c, revision 2.54
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.54 ! frystyk 6: ** @(#) $Id: HTInit.c,v 2.53 1996/04/12 17:47:27 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.22 frystyk 13: #include "HTUtils.h"
2.24 frystyk 14: #include "HTFormat.h"
15: #include "HTList.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.51 frystyk 55: HTConversion_add(c,"text/x-http", "*/*", HTTPStatus_new, 1.0, 0.0, 0.0);
2.42 frystyk 56: #if 0
57: HTConversion_add(c,"text/x-gopher", "www/present", HTGopherMenu, 1.0, 0.0, 0.0);
58: HTConversion_add(c,"text/x-cso", "www/present", HTGopherCSO, 1.0, 0.0, 0.0);
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.53 frystyk 62: #endif
2.43 frystyk 63:
2.31 frystyk 64: /*
2.45 frystyk 65: ** We also register a special content type guess stream that can figure out
66: ** the content type by reading the first bytes of the stream
67: */
68: HTConversion_add(c,"www/unknown", "*/*", HTGuess_new, 1.0, 0.0, 0.0);
2.46 frystyk 69:
70: /*
71: ** Handling Rule files is handled just like any other stream
72: ** This converter reads a rule file and generates the rules
73: */
2.48 frystyk 74: HTConversion_add(c,"application/x-www-rules","*/*", HTRules, 1.0, 0.0, 0.0);
2.46 frystyk 75:
2.45 frystyk 76: /*
2.34 frystyk 77: ** This dumps all other formats to local disk without any further
2.31 frystyk 78: ** action taken
79: */
2.38 frystyk 80: HTConversion_add(c,"*/*", "www/present", HTSaveLocally, 0.3, 0.0, 0.0);
2.23 frystyk 81: }
82:
83: /* BINDINGS BETWEEN MEDIA TYPES AND EXTERNAL VIEWERS/PRESENTERS
84: ** ------------------------------------------------------------
2.47 frystyk 85: ** Not done automaticly - may be done by application!
2.23 frystyk 86: ** The data objects are stored in temporary files before the external
87: ** program is called
88: */
2.38 frystyk 89: PUBLIC void HTPresenterInit (HTList * c)
2.1 timbl 90: {
91: #ifdef NeXT
2.38 frystyk 92: HTPresentation_add(c,"application/postscript", "open %s", NULL, 1.0, 2.0, 0.0);
2.10 luotonen 93: /* The following needs the GIF previewer -- you might not have it. */
2.19 howcome 94:
2.38 frystyk 95: HTPresentation_add(c,"image/gif", "open %s", NULL, 0.3, 2.0, 0.0);
2.44 frystyk 96: HTPresentation_add(c,"image/tiff", "open %s", NULL, 1.0, 2.0, 0.0);
2.41 frystyk 97: HTPresentation_add(c,"audio/basic", "open %s", NULL, 1.0, 2.0, 0.0);
98: HTPresentation_add(c,"*/*", "open %s", NULL, 0.05, 0.0, 0.0);
2.1 timbl 99: #else
2.10 luotonen 100: if (getenv("DISPLAY")) { /* Must have X11 */
2.38 frystyk 101: HTPresentation_add(c,"application/postscript", "ghostview %s", NULL, 1.0, 3.0, 0.0);
2.41 frystyk 102: HTPresentation_add(c,"image/gif", "xv %s", NULL, 1.0, 3.0, 0.0);
2.44 frystyk 103: HTPresentation_add(c,"image/tiff", "xv %s", NULL, 1.0, 3.0, 0.0);
2.38 frystyk 104: HTPresentation_add(c,"image/jpeg", "xv %s", NULL, 1.0, 3.0, 0.0);
2.44 frystyk 105: HTPresentation_add(c,"image/png", "xv %s", NULL, 1.0, 3.0, 0.0);
2.10 luotonen 106: }
2.1 timbl 107: #endif
2.15 frystyk 108: }
109:
110:
2.23 frystyk 111: /* PRESENTERS AND CONVERTERS AT THE SAME TIME
112: ** ------------------------------------------
2.47 frystyk 113: ** Not done automaticly - may be done by application!
2.23 frystyk 114: ** This function is only defined in order to preserve backward
115: ** compatibility.
116: */
2.38 frystyk 117: PUBLIC void HTFormatInit (HTList * c)
2.15 frystyk 118: {
2.23 frystyk 119: HTConverterInit(c);
120: HTPresenterInit(c);
121:
2.1 timbl 122: }
123:
2.47 frystyk 124:
125: /* REGISTER CALLBACKS FOR THE NET MANAGER
126: ** --------------------------------------
127: ** We register two often used callback functions:
128: ** a BEFORE and a AFTER callback
129: ** Not done automaticly - may be done by application!
130: */
131: PUBLIC void HTNetInit (void)
132: {
2.54 ! frystyk 133: HTNetCall_addBefore(HTLoadStart, NULL, 0);
! 134: HTNetCall_addAfter(HTLoadTerminate, NULL, HT_ALL);
2.47 frystyk 135: }
136:
137:
138: /* REGISTER CALLBACKS FOR THE ALERT MANAGER
139: ** ----------------------------------------
140: ** We register a set of alert messages
141: ** Not done automaticly - may be done by application!
142: */
143: PUBLIC void HTAlertInit (void)
144: {
145: HTAlert_add(HTProgress, HT_A_PROGRESS);
146: HTAlert_add(HTError_print, HT_A_MESSAGE);
147: HTAlert_add(HTConfirm, HT_A_CONFIRM);
148: HTAlert_add(HTPrompt, HT_A_PROMPT);
149: HTAlert_add(HTPromptPassword, HT_A_SECRET);
150: HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
151: }
152:
2.53 frystyk 153: /* REGISTER ALL KNOWN TRANSPORTS IN THE LIBRARY
154: ** --------------------------------------------
155: ** Not done automaticly - may be done by application!
156: */
157: PUBLIC void HTTransportInit (void)
158: {
2.54 ! frystyk 159: HTTransport_add("tcp", HT_CH_SINGLE, HTReader_new, HTWriter_new);
! 160: HTTransport_add("buffered_tcp", HT_CH_SINGLE, HTReader_new, HTBufferWriter_new);
! 161: #ifndef NO_UNIX_IO
! 162: HTTransport_add("local", HT_CH_SINGLE, HTReader_new, HTWriter_new);
! 163: #else
! 164: HTTransport_add("local", HT_CH_SINGLE, HTANSIReader_new, HTANSIWriter_new);
! 165: #endif
2.53 frystyk 166: }
2.47 frystyk 167:
2.24 frystyk 168: /* REGISTER ALL KNOWN PROTOCOLS IN THE LIBRARY
169: ** -------------------------------------------
2.47 frystyk 170: ** Not done automaticly - may be done by application!
2.24 frystyk 171: */
2.33 frystyk 172: PUBLIC void HTAccessInit (void)
2.24 frystyk 173: {
174: #ifndef DECNET
2.53 frystyk 175: HTProtocol_add("ftp", "tcp", NO, HTLoadFTP, NULL);
176: HTProtocol_add("nntp", "tcp", NO, HTLoadNews, NULL);
177: HTProtocol_add("news", "tcp", NO, HTLoadNews, NULL);
178: HTProtocol_add("gopher", "tcp", NO, HTLoadGopher, NULL);
2.24 frystyk 179: #ifdef HT_DIRECT_WAIS
2.53 frystyk 180: HTProtocol_add("wais", "", YES, HTLoadWAIS, NULL);
2.24 frystyk 181: #endif
182: #endif /* DECNET */
183:
2.54 ! frystyk 184: HTProtocol_add("http", "buffered_tcp", NO, HTLoadHTTP, NULL);
2.53 frystyk 185: HTProtocol_add("file", "local", NO, HTLoadFile, NULL);
186: HTProtocol_add("telnet", "", YES, HTLoadTelnet, NULL);
187: HTProtocol_add("tn3270", "", YES, HTLoadTelnet, NULL);
188: HTProtocol_add("rlogin", "", YES, HTLoadTelnet, NULL);
2.24 frystyk 189: }
2.1 timbl 190:
2.48 frystyk 191: #if 0
192: /* BINDINGS BETWEEN ICONS AND MEDIA TYPES
193: ** --------------------------------------
194: ** Not done automaticly - may be done by application!
195: ** For directory listings etc. you can bind a set of icons to a set of
196: ** media types and special icons for directories and other objects that
197: ** do not have a media type.
198: */
2.52 frystyk 199: /* PUBLIC void HTStdIconInit (const char * url_prefix) */
2.48 frystyk 200: {
2.52 frystyk 201: const char * p = url_prefix ? url_prefix : "/internal-icon/";
2.48 frystyk 202:
203: HTAddBlankIcon (prefixed(p,"blank.xbm"), NULL );
204: HTAddDirIcon (prefixed(p,"directory.xbm"),"DIR" );
205: HTAddParentIcon (prefixed(p,"back.xbm"), "UP" );
206: HTAddUnknownIcon(prefixed(p,"unknown.xbm"), NULL );
207: HTAddIcon(prefixed(p,"unknown.xbm"), NULL, "*/*");
208: HTAddIcon(prefixed(p,"binary.xbm"), "BIN", "binary");
209: HTAddIcon(prefixed(p,"unknown.xbm"), NULL, "www/unknown");
210: HTAddIcon(prefixed(p,"text.xbm"), "TXT", "text/*");
211: HTAddIcon(prefixed(p,"image.xbm"), "IMG", "image/*");
212: HTAddIcon(prefixed(p,"movie.xbm"), "MOV", "video/*");
213: HTAddIcon(prefixed(p,"sound.xbm"), "AU", "audio/*");
214: HTAddIcon(prefixed(p,"tar.xbm"), "TAR", "multipart/x-tar");
215: HTAddIcon(prefixed(p,"tar.xbm"), "TAR", "multipart/x-gtar");
216: HTAddIcon(prefixed(p,"compressed.xbm"), "CMP", "x-compress");
217: HTAddIcon(prefixed(p,"compressed.xbm"), "GZP", "x-gzip");
218: HTAddIcon(prefixed(p,"index.xbm"), "IDX", "application/x-gopher-index");
219: HTAddIcon(prefixed(p,"index2.xbm"), "CSO", "application/x-gopher-cso");
220: HTAddIcon(prefixed(p,"telnet.xbm"), "TEL", "application/x-gopher-telnet");
221: HTAddIcon(prefixed(p,"unknown.xbm"), "DUP", "application/x-gopher-duplicate");
222: HTAddIcon(prefixed(p,"unknown.xbm"), "TN", "application/x-gopher-tn3270");
223: }
224: #endif
Webmaster