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

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.61    ! frystyk     6: **     @(#) $Id: HTInit.c,v 2.60 1996/06/24 16:56:59 eric 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.59      frystyk    13: #include "WWWUtil.h"
                     14: #include "WWWCore.h"
2.22      frystyk    15: #include "HTInit.h"                                     /* Implemented here */
2.1       timbl      16: 
2.29      frystyk    17: /* ------------------------------------------------------------------------- */
                     18: 
2.23      frystyk    19: /*     BINDINGS BETWEEN A SOURCE MEDIA TYPE AND A DEST MEDIA TYPE (CONVERSION)
                     20: **     ----------------------------------------------------------------------
2.47      frystyk    21: **     Not done automaticly - may be done by application!
2.23      frystyk    22: */
2.38      frystyk    23: PUBLIC void HTConverterInit (HTList * c)
2.23      frystyk    24: {
2.31      frystyk    25:     /*
2.49      frystyk    26:     ** You can get debug information out through the debug stream if you set
                     27:     ** the debug format appropriately
                     28:     */
                     29:     HTConversion_add(c,"*/*",                  "www/debug",    HTBlackHoleConverter,   1.0, 0.0, 0.0);
                     30: 
                     31:     /*
2.31      frystyk    32:     ** These are converters that converts to something other than www/present,
                     33:     ** that is not directly outputting someting to the user on the screen
                     34:     */
2.43      frystyk    35:     HTConversion_add(c,"message/rfc822",       "*/*",          HTMIMEConvert,  1.0, 0.0, 0.0);
2.55      frystyk    36:     HTConversion_add(c,"message/x-rfc822-foot",        "*/*",          HTMIMEFooter,   1.0, 0.0, 0.0);
2.43      frystyk    37:     HTConversion_add(c,"multipart/*",          "*/*",          HTBoundary,     1.0, 0.0, 0.0);
2.38      frystyk    38:     HTConversion_add(c,"text/plain",           "text/html",    HTPlainToHTML,  1.0, 0.0, 0.0);
2.39      frystyk    39: 
                     40:     /*
                     41:     ** The following conversions are converting ASCII output from various
                     42:     ** protocols to HTML objects.
                     43:     */
2.51      frystyk    44:     HTConversion_add(c,"text/x-http",          "*/*",          HTTPStatus_new, 1.0, 0.0, 0.0);
2.42      frystyk    45: #if 0
                     46:     HTConversion_add(c,"text/x-gopher",                "www/present",  HTGopherMenu,   1.0, 0.0, 0.0);
                     47:     HTConversion_add(c,"text/x-cso",           "www/present",  HTGopherCSO,    1.0, 0.0, 0.0);
2.48      frystyk    48:     HTConversion_add(c,"text/x-nntp-list",     "*/*",          HTNewsList,     1.0, 0.0, 0.0);
                     49:     HTConversion_add(c,"text/x-nntp-over",     "*/*",          HTNewsGroup,    1.0, 0.0, 0.0);
                     50:     HTConversion_add(c,"text/x-wais-source",   "*/*",          HTWSRCConvert,  1.0, 0.0, 0.0);
2.53      frystyk    51: #endif
2.43      frystyk    52: 
2.31      frystyk    53:     /*
2.45      frystyk    54:     ** We also register a special content type guess stream that can figure out
                     55:     ** the content type by reading the first bytes of the stream
                     56:     */
                     57:     HTConversion_add(c,"www/unknown",          "*/*",          HTGuess_new,    1.0, 0.0, 0.0);
2.46      frystyk    58: 
                     59:     /*
                     60:     ** Handling Rule files is handled just like any other stream
                     61:     ** This converter reads a rule file and generates the rules
                     62:     */
2.48      frystyk    63:     HTConversion_add(c,"application/x-www-rules","*/*",                HTRules,        1.0, 0.0, 0.0);
2.46      frystyk    64: 
2.45      frystyk    65:     /*
2.34      frystyk    66:     ** This dumps all other formats to local disk without any further
2.31      frystyk    67:     ** action taken
                     68:     */
2.38      frystyk    69:     HTConversion_add(c,"*/*",                  "www/present",  HTSaveLocally,  0.3, 0.0, 0.0);
2.23      frystyk    70: }
                     71: 
                     72: /*     BINDINGS BETWEEN MEDIA TYPES AND EXTERNAL VIEWERS/PRESENTERS
                     73: **     ------------------------------------------------------------
2.47      frystyk    74: **     Not done automaticly - may be done by application!
2.23      frystyk    75: **     The data objects are stored in temporary files before the external
                     76: **     program is called
                     77: */
2.38      frystyk    78: PUBLIC void HTPresenterInit (HTList * c)
2.1       timbl      79: {
                     80: #ifdef NeXT
2.38      frystyk    81:     HTPresentation_add(c,"application/postscript", "open %s",  NULL, 1.0, 2.0, 0.0);
2.10      luotonen   82:     /* The following needs the GIF previewer -- you might not have it. */
2.19      howcome    83: 
2.38      frystyk    84:     HTPresentation_add(c,"image/gif",          "open %s",      NULL, 0.3, 2.0, 0.0);
2.44      frystyk    85:     HTPresentation_add(c,"image/tiff",         "open %s",      NULL, 1.0, 2.0, 0.0);
2.41      frystyk    86:     HTPresentation_add(c,"audio/basic",        "open %s",      NULL, 1.0, 2.0, 0.0);
                     87:     HTPresentation_add(c,"*/*",                "open %s",      NULL, 0.05, 0.0, 0.0); 
2.1       timbl      88: #else
2.10      luotonen   89:     if (getenv("DISPLAY")) {   /* Must have X11 */
2.38      frystyk    90:        HTPresentation_add(c,"application/postscript", "ghostview %s",  NULL, 1.0, 3.0, 0.0);
2.41      frystyk    91:        HTPresentation_add(c,"image/gif",       "xv %s",        NULL, 1.0, 3.0, 0.0);
2.44      frystyk    92:        HTPresentation_add(c,"image/tiff",      "xv %s",        NULL, 1.0, 3.0, 0.0);
2.38      frystyk    93:        HTPresentation_add(c,"image/jpeg",      "xv %s",        NULL, 1.0, 3.0, 0.0);
2.44      frystyk    94:        HTPresentation_add(c,"image/png",       "xv %s",        NULL, 1.0, 3.0, 0.0);
2.10      luotonen   95:     }
2.1       timbl      96: #endif
2.15      frystyk    97: }
                     98: 
                     99: 
2.23      frystyk   100: /*     PRESENTERS AND CONVERTERS AT THE SAME TIME
                    101: **     ------------------------------------------
2.47      frystyk   102: **     Not done automaticly - may be done by application!
2.23      frystyk   103: **     This function is only defined in order to preserve backward
                    104: **     compatibility.
                    105: */
2.38      frystyk   106: PUBLIC void HTFormatInit (HTList * c)
2.15      frystyk   107: {
2.23      frystyk   108:     HTConverterInit(c);
                    109:     HTPresenterInit(c);
                    110: 
2.1       timbl     111: }
                    112: 
2.55      frystyk   113: /*     BINDINGS BETWEEN A ENCODING AND CODERS / DECODERS
                    114: **     --------------------------- ---------------------
                    115: **     Not done automaticly - may be done by application!
                    116: */
                    117: PUBLIC void HTEncoderInit (HTList * c)
                    118: {
                    119:     HTCoding_add(c, "chunked", NULL, HTChunkedDecoder, 1.0);
                    120: }
2.47      frystyk   121: 
                    122: /*     REGISTER CALLBACKS FOR THE NET MANAGER
                    123: **     --------------------------------------
                    124: **     We register two often used callback functions:
                    125: **     a BEFORE and a AFTER callback
                    126: **     Not done automaticly - may be done by application!
                    127: */
                    128: PUBLIC void HTNetInit (void)
                    129: {
2.54      frystyk   130:     HTNetCall_addBefore(HTLoadStart, NULL, 0);
                    131:     HTNetCall_addAfter(HTLoadTerminate, NULL, HT_ALL);
2.47      frystyk   132: }
                    133: 
                    134: 
                    135: /*     REGISTER CALLBACKS FOR THE ALERT MANAGER
                    136: **     ----------------------------------------
                    137: **     We register a set of alert messages
                    138: **     Not done automaticly - may be done by application!
                    139: */
                    140: PUBLIC void HTAlertInit (void)
                    141: {
                    142:     HTAlert_add(HTProgress, HT_A_PROGRESS);
                    143:     HTAlert_add(HTError_print, HT_A_MESSAGE);
                    144:     HTAlert_add(HTConfirm, HT_A_CONFIRM);
                    145:     HTAlert_add(HTPrompt, HT_A_PROMPT);
                    146:     HTAlert_add(HTPromptPassword, HT_A_SECRET);
                    147:     HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
                    148: }
                    149: 
2.53      frystyk   150: /*     REGISTER ALL KNOWN TRANSPORTS IN THE LIBRARY
                    151: **     --------------------------------------------
                    152: **     Not done automaticly - may be done by application!
                    153: */
                    154: PUBLIC void HTTransportInit (void)
                    155: {
2.54      frystyk   156:     HTTransport_add("tcp", HT_CH_SINGLE, HTReader_new, HTWriter_new);
                    157:     HTTransport_add("buffered_tcp", HT_CH_SINGLE, HTReader_new, HTBufferWriter_new);
                    158: #ifndef NO_UNIX_IO
                    159:     HTTransport_add("local", HT_CH_SINGLE, HTReader_new, HTWriter_new);
                    160: #else
                    161:     HTTransport_add("local", HT_CH_SINGLE, HTANSIReader_new, HTANSIWriter_new);
                    162: #endif
2.53      frystyk   163: }
2.47      frystyk   164: 
2.24      frystyk   165: /*     REGISTER ALL KNOWN PROTOCOLS IN THE LIBRARY
                    166: **     -------------------------------------------
2.47      frystyk   167: **     Not done automaticly - may be done by application!
2.24      frystyk   168: */
2.33      frystyk   169: PUBLIC void HTAccessInit (void)
2.24      frystyk   170: {
                    171: #ifndef DECNET
2.53      frystyk   172:     HTProtocol_add("ftp", "tcp", NO, HTLoadFTP, NULL);
                    173:     HTProtocol_add("nntp", "tcp", NO, HTLoadNews, NULL);
                    174:     HTProtocol_add("news", "tcp", NO, HTLoadNews, NULL);
                    175:     HTProtocol_add("gopher", "tcp", NO, HTLoadGopher, NULL);
2.24      frystyk   176: #ifdef HT_DIRECT_WAIS
2.53      frystyk   177:     HTProtocol_add("wais", "", YES, HTLoadWAIS, NULL);
2.24      frystyk   178: #endif
                    179: #endif /* DECNET */
                    180: 
2.54      frystyk   181:     HTProtocol_add("http", "buffered_tcp", NO, HTLoadHTTP, NULL);
2.53      frystyk   182:     HTProtocol_add("file", "local", NO, HTLoadFile, NULL);
                    183:     HTProtocol_add("telnet", "", YES, HTLoadTelnet, NULL);
                    184:     HTProtocol_add("tn3270", "", YES, HTLoadTelnet, NULL);
                    185:     HTProtocol_add("rlogin", "", YES, HTLoadTelnet, NULL);
2.24      frystyk   186: }
2.1       timbl     187: 
2.61    ! frystyk   188: /*     REGISTER DEFULT EVENT MANAGER
        !           189: **     -----------------------------
        !           190: **     Not done automaticly - may be done by application!
        !           191: */
        !           192: PUBLIC void HTEventInit (void)
        !           193: {
        !           194:     HTEvent_setRegisterCallback(HTEventrg_register);
        !           195:     HTEvent_setUnregisterCallback(HTEventrg_unregister);
        !           196: }
        !           197: 
2.48      frystyk   198: /*     BINDINGS BETWEEN ICONS AND MEDIA TYPES
                    199: **     --------------------------------------
                    200: **     Not done automaticly - may be done by application!
                    201: **     For directory listings etc. you can bind a set of icons to a set of
                    202: **     media types and special icons for directories and other objects that
                    203: **     do not have a media type.
                    204: */
2.61    ! frystyk   205: PUBLIC void HTIconInit (const char * url_prefix)
2.58      eric      206: {
2.61    ! frystyk   207:     const char * prefix = url_prefix ? url_prefix : "/internal-icon/";
2.58      eric      208: 
2.61    ! frystyk   209:     HTIcon_addBlank("blank.xbm",       prefix, NULL);
        !           210:     HTIcon_addDir("directory.xbm",     prefix, "DIR");
        !           211:     HTIcon_addParent("back.xbm",       prefix, "UP");
        !           212:     HTIcon_addUnknown("unknown.xbm",   prefix, NULL);
        !           213: 
        !           214:     HTIcon_add("unknown.xbm",  prefix, NULL,   "*/*");
        !           215:     HTIcon_add("binary.xbm",   prefix, "BIN",  "binary");
        !           216:     HTIcon_add("unknown.xbm",  prefix, NULL,   "www/unknown");
        !           217:     HTIcon_add("text.xbm",     prefix, "TXT",  "text/*");
        !           218:     HTIcon_add("image.xbm",    prefix, "IMG",  "image/*");
        !           219:     HTIcon_add("movie.xbm",    prefix, "MOV",  "video/*");
        !           220:     HTIcon_add("sound.xbm",    prefix, "AU",   "audio/*");
        !           221:     HTIcon_add("tar.xbm",      prefix, "TAR",  "multipart/x-tar");
        !           222:     HTIcon_add("tar.xbm",      prefix, "TAR",  "multipart/x-gtar");
        !           223:     HTIcon_add("compressed.xbm",prefix,        "CMP",  "x-compress");
        !           224:     HTIcon_add("compressed.xbm",prefix,        "GZP",  "x-gzip");
        !           225:     HTIcon_add("index.xbm",    prefix, "IDX",  "application/x-gopher-index");
        !           226:     HTIcon_add("index2.xbm",   prefix, "CSO",  "application/x-gopher-cso");
        !           227:     HTIcon_add("telnet.xbm",   prefix, "TEL",  "application/x-gopher-telnet");
        !           228:     HTIcon_add("unknown.xbm",  prefix, "DUP",  "application/x-gopher-duplicate");
        !           229:     HTIcon_add("unknown.xbm",  prefix, "TN",   "application/x-gopher-tn3270");
2.58      eric      230: }
                    231: 
2.57      eric      232: /*     REGISTER ALL HTTP/1.1 MIME HEADERS
                    233: **     --------------------------------------------
                    234: **     Not done automaticly - may be done by application!
                    235: */
                    236: PUBLIC void HTMIMEInit()
                    237: {
                    238:     struct {
                    239:         char * string;
                    240:        HTParserCallback * pHandler;
                    241:     } fixedHandlers[] = {
2.61    ! frystyk   242:        {"accept", &HTMIME_accept}, 
        !           243:        {"accept-charset", &HTMIME_acceptCharset}, 
        !           244:        {"accept-encoding", &HTMIME_acceptEncoding}, 
        !           245:        {"accept-language", &HTMIME_acceptLanguage}, 
        !           246:        {"accept-ranges", &HTMIME_acceptRanges}, 
        !           247:        {"age", &HTMIME_age}, 
        !           248:        {"allow", &HTMIME_allow},
        !           249:        {"authorization", NULL},
        !           250:        {"cache-control", NULL},
        !           251:        {"connection", &HTMIME_connection}, 
        !           252:        {"content-base", &HTMIME_contentBase}, 
        !           253:        {"content-encoding", &HTMIME_contentEncoding}, 
        !           254:        {"content-language", &HTMIME_contentLanguage}, 
        !           255:        {"content-length", &HTMIME_contentLength}, 
        !           256:        {"content-location", &HTMIME_contentLocation}, 
        !           257:        {"content-md5", &HTMIME_contentMD5},
        !           258:        {"content-range", &HTMIME_contentRange},
        !           259:        {"content-transfer-encoding", &HTMIME_contentTransferEncoding}, 
        !           260:        {"content-type", &HTMIME_contentType},
        !           261:        {"date", &HTMIME_date},
        !           262:        {"derived-from", &HTMIME_derivedFrom}, 
        !           263:        {"digest-MessageDigest", &HTMIME_messageDigest}, 
        !           264:        {"etag", &HTMIME_etag},
        !           265:         {"expires", &HTMIME_expires},
        !           266:        {"from", &HTMIME_from},
        !           267:        {"host", &HTMIME_host},
        !           268:        {"if-modified-since", &HTMIME_ifModifiedSince}, 
        !           269:        {"if-match", &HTMIME_ifMatch}, 
        !           270:        {"if-none-match", &HTMIME_ifNoneMatch}, 
        !           271:        {"if-range", &HTMIME_ifRange}, 
        !           272:        {"if-unmodified-since", &HTMIME_ifUnmodifiedSince}, 
2.57      eric      273:        {"keep-alive", NULL}, 
2.61    ! frystyk   274:        {"last-modified", &HTMIME_lastModified}, 
        !           275:        {"link", &HTMIME_link},
        !           276:        {"location", &HTMIME_location},
        !           277:        {"max-forwards", &HTMIME_maxForwards}, 
2.57      eric      278:        {"mime-version", NULL}, 
2.61    ! frystyk   279:        {"newsgroups", &HTMIME_newsGroups}, 
        !           280:        {"pragma", &HTMIME_pragma},
        !           281:        {"proxy-authenticate", &HTMIME_proxyAuthenticate},
        !           282:        {"proxy-authorization", &HTMIME_proxyAuthorization},
        !           283:        {"public", &HTMIME_public},
        !           284:        {"range", &HTMIME_range},
        !           285:        {"referer", &HTMIME_referer},
        !           286:        {"retry-after", &HTMIME_retryAfter}, 
2.57      eric      287:        {"server", NULL}, 
2.61    ! frystyk   288:        {"title", &HTMIME_title}, 
        !           289:        {"transfer-encoding", &HTMIME_contentTransferEncoding}, 
        !           290:        {"upgrade", &HTMIME_upgrade},
        !           291:        {"uri", &HTMIME_uri},
        !           292:        {"user-agent", &HTMIME_userAgent},
        !           293:        {"vary", &HTMIME_vary},
        !           294:        {"version", &HTMIME_version},
        !           295:        {"via", &HTMIME_via},
        !           296:        {"warning", &HTMIME_warning},
        !           297:        {"www-authenticate", &HTMIME_authenticate}, 
2.57      eric      298:     };
                    299:     int i;
                    300: 
                    301:     for (i = 0; i < sizeof(fixedHandlers)/sizeof(fixedHandlers[0]); i++)
                    302:         HTHeader_addParser(fixedHandlers[i].string, NO, 
                    303:                           fixedHandlers[i].pHandler);
                    304: }
                    305: 

Webmaster