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

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

Webmaster