Annotation of libwww/Library/src/HTInit.c, revision 2.53

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.53    ! frystyk     6: **     @(#) $Id: Date Author State $
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: {
                    133:     HTNetCall_addBefore(HTLoadStart, 0);
                    134:     HTNetCall_addAfter(HTLoadTerminate, HT_ALL);
                    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: #if 0
        !           154: /*     REGISTER ALL KNOWN TRANSPORTS IN THE LIBRARY
        !           155: **     --------------------------------------------
        !           156: **     Not done automaticly - may be done by application!
        !           157: */
        !           158: PUBLIC void HTTransportInit (void)
        !           159: {
        !           160:     HTTransport_add("tcp_buffered", NO, HTLoadFTP, NULL);
        !           161: }
        !           162: #endif
2.47      frystyk   163: 
2.24      frystyk   164: /*     REGISTER ALL KNOWN PROTOCOLS IN THE LIBRARY
                    165: **     -------------------------------------------
2.47      frystyk   166: **     Not done automaticly - may be done by application!
2.24      frystyk   167: */
2.33      frystyk   168: PUBLIC void HTAccessInit (void)
2.24      frystyk   169: {
                    170: #ifndef DECNET
2.53    ! frystyk   171:     HTProtocol_add("ftp", "tcp", NO, HTLoadFTP, NULL);
        !           172:     HTProtocol_add("nntp", "tcp", NO, HTLoadNews, NULL);
        !           173:     HTProtocol_add("news", "tcp", NO, HTLoadNews, NULL);
        !           174:     HTProtocol_add("gopher", "tcp", NO, HTLoadGopher, NULL);
2.24      frystyk   175: #ifdef HT_DIRECT_WAIS
2.53    ! frystyk   176:     HTProtocol_add("wais", "", YES, HTLoadWAIS, NULL);
2.24      frystyk   177: #endif
                    178: #endif /* DECNET */
                    179: 
2.53    ! frystyk   180:     HTProtocol_add("http", "tcp", NO, HTLoadHTTP, NULL);
        !           181:     HTProtocol_add("file", "local", NO, HTLoadFile, NULL);
        !           182:     HTProtocol_add("telnet", "", YES, HTLoadTelnet, NULL);
        !           183:     HTProtocol_add("tn3270", "", YES, HTLoadTelnet, NULL);
        !           184:     HTProtocol_add("rlogin", "", YES, HTLoadTelnet, NULL);
2.24      frystyk   185: }
2.1       timbl     186: 
2.48      frystyk   187: #if 0
                    188: /*     BINDINGS BETWEEN ICONS AND MEDIA TYPES
                    189: **     --------------------------------------
                    190: **     Not done automaticly - may be done by application!
                    191: **     For directory listings etc. you can bind a set of icons to a set of
                    192: **     media types and special icons for directories and other objects that
                    193: **     do not have a media type.
                    194: */
2.52      frystyk   195: /* PUBLIC void HTStdIconInit (const char * url_prefix) */
2.48      frystyk   196: {
2.52      frystyk   197:     const char * p = url_prefix ? url_prefix : "/internal-icon/";
2.48      frystyk   198: 
                    199:     HTAddBlankIcon  (prefixed(p,"blank.xbm"),  NULL    );
                    200:     HTAddDirIcon    (prefixed(p,"directory.xbm"),"DIR" );
                    201:     HTAddParentIcon (prefixed(p,"back.xbm"),   "UP"    );
                    202:     HTAddUnknownIcon(prefixed(p,"unknown.xbm"),        NULL    );
                    203:     HTAddIcon(prefixed(p,"unknown.xbm"),       NULL,   "*/*");
                    204:     HTAddIcon(prefixed(p,"binary.xbm"),                "BIN",  "binary");
                    205:     HTAddIcon(prefixed(p,"unknown.xbm"),       NULL,   "www/unknown");
                    206:     HTAddIcon(prefixed(p,"text.xbm"),          "TXT",  "text/*");
                    207:     HTAddIcon(prefixed(p,"image.xbm"),         "IMG",  "image/*");
                    208:     HTAddIcon(prefixed(p,"movie.xbm"),         "MOV",  "video/*");
                    209:     HTAddIcon(prefixed(p,"sound.xbm"),         "AU",   "audio/*");
                    210:     HTAddIcon(prefixed(p,"tar.xbm"),           "TAR",  "multipart/x-tar");
                    211:     HTAddIcon(prefixed(p,"tar.xbm"),           "TAR",  "multipart/x-gtar");
                    212:     HTAddIcon(prefixed(p,"compressed.xbm"),    "CMP",  "x-compress");
                    213:     HTAddIcon(prefixed(p,"compressed.xbm"),    "GZP",  "x-gzip");
                    214:     HTAddIcon(prefixed(p,"index.xbm"),         "IDX",  "application/x-gopher-index");
                    215:     HTAddIcon(prefixed(p,"index2.xbm"),                "CSO",  "application/x-gopher-cso");
                    216:     HTAddIcon(prefixed(p,"telnet.xbm"),                "TEL",  "application/x-gopher-telnet");
                    217:     HTAddIcon(prefixed(p,"unknown.xbm"),               "DUP",  "application/x-gopher-duplicate");
                    218:     HTAddIcon(prefixed(p,"unknown.xbm"),       "TN",   "application/x-gopher-tn3270");
                    219: }
                    220: #endif

Webmaster