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

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.95    ! frystyk     6: **     @(#) $Id: HTInit.c,v 2.94 1999/02/01 18:46:37 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.89      frystyk    12: #include "wwwsys.h"
2.59      frystyk    13: #include "WWWUtil.h"
                     14: #include "WWWCore.h"
2.83      frystyk    15: 
                     16: #ifdef HT_MUX
2.75      frystyk    17: #include "WWWMux.h"
2.83      frystyk    18: #endif
2.75      frystyk    19: 
2.22      frystyk    20: #include "HTInit.h"                                     /* Implemented here */
2.1       timbl      21: 
2.65      frystyk    22: #ifndef W3C_ICONS
2.87      frystyk    23: #define W3C_ICONS      "w3c-icons"
2.65      frystyk    24: #endif
                     25: 
2.87      frystyk    26: #define ICON_LOCATION  "/icons/"
2.65      frystyk    27: 
2.29      frystyk    28: /* ------------------------------------------------------------------------- */
                     29: 
2.23      frystyk    30: /*     BINDINGS BETWEEN A SOURCE MEDIA TYPE AND A DEST MEDIA TYPE (CONVERSION)
                     31: **     ----------------------------------------------------------------------
2.47      frystyk    32: **     Not done automaticly - may be done by application!
2.23      frystyk    33: */
2.38      frystyk    34: PUBLIC void HTConverterInit (HTList * c)
2.23      frystyk    35: {
2.31      frystyk    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.95    ! frystyk    43:     **  Set our own local file save stream for the MIME parser so that 
        !            44:     **  we know how to dump to local disk in case we get content type
        !            45:     **  application/octect stream, or an encoding that we don't know.
        !            46:     */
        !            47:     HTMIME_setSaveStream (HTSaveLocally);
        !            48: 
        !            49:     /*
2.31      frystyk    50:     ** These are converters that converts to something other than www/present,
                     51:     ** that is not directly outputting someting to the user on the screen
                     52:     */
2.43      frystyk    53:     HTConversion_add(c,"message/rfc822",       "*/*",          HTMIMEConvert,  1.0, 0.0, 0.0);
2.55      frystyk    54:     HTConversion_add(c,"message/x-rfc822-foot",        "*/*",          HTMIMEFooter,   1.0, 0.0, 0.0);
2.72      frystyk    55:     HTConversion_add(c,"message/x-rfc822-head",        "*/*",          HTMIMEHeader,   1.0, 0.0, 0.0);
2.80      frystyk    56:     HTConversion_add(c,"message/x-rfc822-cont",        "*/*",          HTMIMEContinue, 1.0, 0.0, 0.0);
                     57:     HTConversion_add(c,"message/x-rfc822-partial","*/*",       HTMIMEPartial,  1.0, 0.0, 0.0);
2.43      frystyk    58:     HTConversion_add(c,"multipart/*",          "*/*",          HTBoundary,     1.0, 0.0, 0.0);
2.38      frystyk    59:     HTConversion_add(c,"text/plain",           "text/html",    HTPlainToHTML,  1.0, 0.0, 0.0);
2.39      frystyk    60: 
                     61:     /*
                     62:     ** The following conversions are converting ASCII output from various
                     63:     ** protocols to HTML objects.
                     64:     */
2.51      frystyk    65:     HTConversion_add(c,"text/x-http",          "*/*",          HTTPStatus_new, 1.0, 0.0, 0.0);
2.68      frystyk    66: 
2.42      frystyk    67: #if 0
                     68:     HTConversion_add(c,"text/x-gopher",                "www/present",  HTGopherMenu,   1.0, 0.0, 0.0);
                     69:     HTConversion_add(c,"text/x-cso",           "www/present",  HTGopherCSO,    1.0, 0.0, 0.0);
2.68      frystyk    70:     HTConversion_add(c,"text/x-wais-source",   "*/*",          HTWSRCConvert,  1.0, 0.0, 0.0);
                     71: #endif
                     72: 
2.48      frystyk    73:     HTConversion_add(c,"text/x-nntp-list",     "*/*",          HTNewsList,     1.0, 0.0, 0.0);
                     74:     HTConversion_add(c,"text/x-nntp-over",     "*/*",          HTNewsGroup,    1.0, 0.0, 0.0);
2.92      frystyk    75: 
                     76:     /*
                     77:     ** If we have the XML expat parser linked in
                     78:     */
                     79: #ifdef HT_EXPAT
                     80:     HTConversion_add(c, "text/xml",            "*/*",          HTXML_new,      1.0, 0.0, 0.0);
                     81:     HTConversion_add(c, "application/xml",     "*/*",          HTXML_new,      1.0, 0.0, 0.0);
                     82: #endif
2.43      frystyk    83: 
2.31      frystyk    84:     /*
2.45      frystyk    85:     ** We also register a special content type guess stream that can figure out
                     86:     ** the content type by reading the first bytes of the stream
                     87:     */
                     88:     HTConversion_add(c,"www/unknown",          "*/*",          HTGuess_new,    1.0, 0.0, 0.0);
2.46      frystyk    89: 
                     90:     /*
2.72      frystyk    91:     ** Register a persistent cache stream which can save an object to local
                     92:     ** file
                     93:     */
                     94:     HTConversion_add(c,"www/cache",            "*/*",          HTCacheWriter,  1.0, 0.0, 0.0);
2.73      frystyk    95:     HTConversion_add(c,"www/cache-append",     "*/*",          HTCacheAppend,  1.0, 0.0, 0.0);
2.72      frystyk    96: 
                     97:     /*
2.46      frystyk    98:     ** Handling Rule files is handled just like any other stream
                     99:     ** This converter reads a rule file and generates the rules
                    100:     */
2.48      frystyk   101:     HTConversion_add(c,"application/x-www-rules","*/*",                HTRules,        1.0, 0.0, 0.0);
2.46      frystyk   102: 
2.45      frystyk   103:     /*
2.34      frystyk   104:     ** This dumps all other formats to local disk without any further
2.31      frystyk   105:     ** action taken
                    106:     */
2.85      frystyk   107:     HTConversion_add(c,"*/*",                  "www/present",  HTSaveConverter, 0.3, 0.0, 0.0);
2.23      frystyk   108: }
                    109: 
                    110: /*     BINDINGS BETWEEN MEDIA TYPES AND EXTERNAL VIEWERS/PRESENTERS
                    111: **     ------------------------------------------------------------
2.47      frystyk   112: **     Not done automaticly - may be done by application!
2.23      frystyk   113: **     The data objects are stored in temporary files before the external
                    114: **     program is called
                    115: */
2.38      frystyk   116: PUBLIC void HTPresenterInit (HTList * c)
2.1       timbl     117: {
2.95    ! frystyk   118:     /*
        !           119:     **  First we set the special "presenter" stream that writes to a
        !           120:     **  temporary file before executing the external presenter
        !           121:     */
        !           122:     HTPresentation_setConverter(HTSaveAndExecute);
        !           123: 
2.1       timbl     124: #ifdef NeXT
2.38      frystyk   125:     HTPresentation_add(c,"application/postscript", "open %s",  NULL, 1.0, 2.0, 0.0);
2.10      luotonen  126:     /* The following needs the GIF previewer -- you might not have it. */
2.19      howcome   127: 
2.38      frystyk   128:     HTPresentation_add(c,"image/gif",          "open %s",      NULL, 0.3, 2.0, 0.0);
2.44      frystyk   129:     HTPresentation_add(c,"image/tiff",         "open %s",      NULL, 1.0, 2.0, 0.0);
2.41      frystyk   130:     HTPresentation_add(c,"audio/basic",        "open %s",      NULL, 1.0, 2.0, 0.0);
                    131:     HTPresentation_add(c,"*/*",                "open %s",      NULL, 0.05, 0.0, 0.0); 
2.1       timbl     132: #else
2.10      luotonen  133:     if (getenv("DISPLAY")) {   /* Must have X11 */
2.38      frystyk   134:        HTPresentation_add(c,"application/postscript", "ghostview %s",  NULL, 1.0, 3.0, 0.0);
2.41      frystyk   135:        HTPresentation_add(c,"image/gif",       "xv %s",        NULL, 1.0, 3.0, 0.0);
2.44      frystyk   136:        HTPresentation_add(c,"image/tiff",      "xv %s",        NULL, 1.0, 3.0, 0.0);
2.38      frystyk   137:        HTPresentation_add(c,"image/jpeg",      "xv %s",        NULL, 1.0, 3.0, 0.0);
2.44      frystyk   138:        HTPresentation_add(c,"image/png",       "xv %s",        NULL, 1.0, 3.0, 0.0);
2.10      luotonen  139:     }
2.1       timbl     140: #endif
2.15      frystyk   141: }
                    142: 
                    143: 
2.23      frystyk   144: /*     PRESENTERS AND CONVERTERS AT THE SAME TIME
                    145: **     ------------------------------------------
2.47      frystyk   146: **     Not done automaticly - may be done by application!
2.23      frystyk   147: **     This function is only defined in order to preserve backward
                    148: **     compatibility.
                    149: */
2.38      frystyk   150: PUBLIC void HTFormatInit (HTList * c)
2.15      frystyk   151: {
2.23      frystyk   152:     HTConverterInit(c);
                    153:     HTPresenterInit(c);
                    154: 
2.1       timbl     155: }
                    156: 
2.78      frystyk   157: /*     BINDINGS BETWEEN A TRANSFER ENCODING AND CODERS / DECODERS
                    158: **     ----------------------------------------------------------
2.55      frystyk   159: **     Not done automaticly - may be done by application!
                    160: */
2.78      frystyk   161: PUBLIC void HTTransferEncoderInit (HTList * c)
2.55      frystyk   162: {
2.90      frystyk   163: #ifdef HT_ZLIB
                    164:     HTCoding_add(c, "deflate", NULL, HTZLib_inflate, 1.0);
                    165: #endif
2.63      frystyk   166:     HTCoding_add(c, "chunked", HTChunkedEncoder, HTChunkedDecoder, 1.0);
2.55      frystyk   167: }
2.47      frystyk   168: 
2.78      frystyk   169: /*     BINDINGS BETWEEN A CONTENT ENCODING AND CODERS / DECODERS
                    170: **     ---------------------------------------------------------
                    171: **     Not done automaticly - may be done by application!
                    172: */
                    173: PUBLIC void HTContentEncoderInit (HTList * c)
                    174: {
2.79      frystyk   175: #ifdef HT_ZLIB
2.78      frystyk   176:     HTCoding_add(c, "deflate", NULL, HTZLib_inflate, 1.0);
2.79      frystyk   177: #endif /* HT_ZLIB */
2.78      frystyk   178: }
                    179: 
2.64      frystyk   180: /*     REGISTER BEFORE FILTERS
                    181: **     -----------------------
                    182: **     The BEFORE filters handle proxies, caches, rule files etc.
                    183: **     The filters are called in the order by which the are registered
                    184: **     Not done automaticly - may be done by application!
                    185: */
                    186: PUBLIC void HTBeforeInit (void)
                    187: {
2.86      frystyk   188: #if 0
                    189:     /* Often handled better by the application */
2.74      frystyk   190:     HTNet_addBefore(HTMemoryCacheFilter,       NULL,           NULL, HT_FILTER_MIDDLE);
2.86      frystyk   191: #endif
2.94      frystyk   192: 
                    193: #if 0
                    194:     /* This is now done by HTCacheInit */
2.74      frystyk   195:     HTNet_addBefore(HTCacheFilter,             "http://*",     NULL, HT_FILTER_MIDDLE);
2.94      frystyk   196: #endif
                    197: 
2.74      frystyk   198:     HTNet_addBefore(HTCredentialsFilter,       "http://*",     NULL, HT_FILTER_LATE);
                    199:     HTNet_addBefore(HTPEP_beforeFilter,        "http://*",     NULL, HT_FILTER_LATE);
                    200:     HTNet_addBefore(HTRuleFilter,              NULL,           NULL, HT_FILTER_LATE);
                    201:     HTNet_addBefore(HTProxyFilter,             NULL,           NULL, HT_FILTER_LATE);
2.64      frystyk   202: }
                    203: 
                    204: /*     REGISTER AFTER FILTERS
                    205: **     ----------------------
                    206: **     The AFTER filters handle error messages, logging, redirection,
                    207: **     authentication etc.
                    208: **     The filters are called in the order by which the are registered
                    209: **     Not done automaticly - may be done by application!
                    210: */
                    211: PUBLIC void HTAfterInit (void)
                    212: {
2.74      frystyk   213:     HTNet_addAfter(HTAuthFilter,       "http://*",     NULL, HT_NO_ACCESS,     HT_FILTER_MIDDLE);
2.81      frystyk   214:     HTNet_addAfter(HTAuthFilter,       "http://*",     NULL, HT_REAUTH,        HT_FILTER_MIDDLE);
2.74      frystyk   215:     HTNet_addAfter(HTPEP_afterFilter,  "http://*",     NULL, HT_ALL,           HT_FILTER_MIDDLE);
2.81      frystyk   216:     HTNet_addAfter(HTRedirectFilter,   "http://*",     NULL, HT_PERM_REDIRECT, HT_FILTER_MIDDLE);
                    217:     HTNet_addAfter(HTRedirectFilter,   "http://*",     NULL, HT_FOUND,         HT_FILTER_MIDDLE);
                    218:     HTNet_addAfter(HTRedirectFilter,   "http://*",     NULL, HT_SEE_OTHER,     HT_FILTER_MIDDLE);
2.74      frystyk   219:     HTNet_addAfter(HTRedirectFilter,   "http://*",     NULL, HT_TEMP_REDIRECT, HT_FILTER_MIDDLE);
2.93      kahan     220:     HTNet_addAfter(HTAuthInfoFilter,   "http://*",     NULL, HT_ALL,           HT_FILTER_MIDDLE);
2.74      frystyk   221:     HTNet_addAfter(HTUseProxyFilter,   "http://*",     NULL, HT_USE_PROXY,     HT_FILTER_MIDDLE);
2.94      frystyk   222: 
                    223: #if 0
                    224:     /* This is now done by HTCacheInit */
2.74      frystyk   225:     HTNet_addAfter(HTCacheUpdateFilter, "http://*",    NULL, HT_NOT_MODIFIED,  HT_FILTER_MIDDLE);
2.94      frystyk   226: #endif
                    227: 
2.74      frystyk   228:     HTNet_addAfter(HTInfoFilter,       NULL,           NULL, HT_ALL,           HT_FILTER_LATE);
2.64      frystyk   229: }
                    230: 
                    231: /*     REGISTER DEFAULT AUTHENTICATION SCHEMES
                    232: **     ---------------------------------------
                    233: **     This function registers the BASIC access authentication
                    234: */
                    235: PUBLIC void HTAAInit (void)
                    236: {
2.93      kahan     237:     HTAA_newModule ("basic", HTBasic_generate, HTBasic_parse, NULL,
                    238:                     HTBasic_delete);
2.91      kahan     239:     HTAA_newModule ("digest", HTDigest_generate, HTDigest_parse, 
2.93      kahan     240:                     HTDigest_updateInfo,  HTDigest_delete);
2.64      frystyk   241: }
                    242: 
                    243: /*     REGISTER BEFORE AND AFTER FILTERS
                    244: **     ---------------------------------
                    245: **     We register a commonly used set of BEFORE and AFTER filters.
2.47      frystyk   246: **     Not done automaticly - may be done by application!
                    247: */
                    248: PUBLIC void HTNetInit (void)
                    249: {
2.64      frystyk   250:     HTBeforeInit();
                    251:     HTAfterInit();
2.47      frystyk   252: }
                    253: 
                    254: 
                    255: /*     REGISTER CALLBACKS FOR THE ALERT MANAGER
                    256: **     ----------------------------------------
                    257: **     We register a set of alert messages
                    258: **     Not done automaticly - may be done by application!
                    259: */
                    260: PUBLIC void HTAlertInit (void)
                    261: {
                    262:     HTAlert_add(HTProgress, HT_A_PROGRESS);
                    263:     HTAlert_add(HTError_print, HT_A_MESSAGE);
                    264:     HTAlert_add(HTConfirm, HT_A_CONFIRM);
                    265:     HTAlert_add(HTPrompt, HT_A_PROMPT);
                    266:     HTAlert_add(HTPromptPassword, HT_A_SECRET);
                    267:     HTAlert_add(HTPromptUsernameAndPassword, HT_A_USER_PW);
                    268: }
                    269: 
2.53      frystyk   270: /*     REGISTER ALL KNOWN TRANSPORTS IN THE LIBRARY
                    271: **     --------------------------------------------
                    272: **     Not done automaticly - may be done by application!
                    273: */
                    274: PUBLIC void HTTransportInit (void)
                    275: {
2.69      frystyk   276:     HTTransport_add("tcp", HT_TP_SINGLE, HTReader_new, HTWriter_new);
                    277:     HTTransport_add("buffered_tcp", HT_TP_SINGLE, HTReader_new, HTBufferWriter_new);
2.75      frystyk   278: #ifdef HT_MUX
2.76      frystyk   279:     HTTransport_add("mux", HT_TP_INTERLEAVE, HTReader_new, HTBufferWriter_new);
2.75      frystyk   280: #endif /* HT_MUX */
2.54      frystyk   281: #ifndef NO_UNIX_IO
2.69      frystyk   282:     HTTransport_add("local", HT_TP_SINGLE, HTReader_new, HTWriter_new);
2.54      frystyk   283: #else
2.69      frystyk   284:     HTTransport_add("local", HT_TP_SINGLE, HTANSIReader_new, HTANSIWriter_new);
2.54      frystyk   285: #endif
2.53      frystyk   286: }
2.47      frystyk   287: 
2.24      frystyk   288: /*     REGISTER ALL KNOWN PROTOCOLS IN THE LIBRARY
                    289: **     -------------------------------------------
2.47      frystyk   290: **     Not done automaticly - may be done by application!
2.24      frystyk   291: */
2.63      frystyk   292: PUBLIC void HTProtocolInit (void)
2.24      frystyk   293: {
                    294: #ifndef DECNET
2.75      frystyk   295:     HTProtocol_add("ftp",      "tcp",  FTP_PORT,       NO,     HTLoadFTP,      NULL);
                    296:     HTProtocol_add("nntp",     "tcp",  NEWS_PORT,      NO,     HTLoadNews,     NULL);
                    297:     HTProtocol_add("news",     "tcp",  NEWS_PORT,      NO,     HTLoadNews,     NULL);
                    298:     HTProtocol_add("gopher",   "tcp",  GOPHER_PORT,    NO,     HTLoadGopher,   NULL);
2.24      frystyk   299: #ifdef HT_DIRECT_WAIS
2.88      frystyk   300:     HTProtocol_add("wais",     "tcp",  WAIS_PORT,      YES,    HTLoadWAIS,     NULL);
2.24      frystyk   301: #endif
                    302: #endif /* DECNET */
2.75      frystyk   303: #ifdef HT_MUX
                    304:     HTProtocol_add("http",     "mux",  HTTP_PORT,      NO,     HTLoadHTTP,     NULL);
                    305: #else
                    306:     HTProtocol_add("http",     "buffered_tcp", HTTP_PORT,      NO,     HTLoadHTTP,     NULL);
                    307: #endif /* !HT_MUX */
2.84      frystyk   308: #ifndef NO_UNIX_IO
                    309:     HTProtocol_add("file",     "local",        0,      NO,     HTLoadFile,     NULL);
                    310:     HTProtocol_add("cache",    "local",        0,      NO,     HTLoadCache,    NULL);
                    311: #else
                    312:     HTProtocol_add("file",     "local",        0,      YES,    HTLoadFile,     NULL);
                    313:     HTProtocol_add("cache",    "local",        0,      YES,    HTLoadCache,    NULL);
                    314: #endif
2.75      frystyk   315:     HTProtocol_add("telnet",   "",             0,      YES,    HTLoadTelnet,   NULL);
                    316:     HTProtocol_add("tn3270",   "",             0,      YES,    HTLoadTelnet,   NULL);
                    317:     HTProtocol_add("rlogin",   "",             0,      YES,    HTLoadTelnet,   NULL);
2.24      frystyk   318: }
2.1       timbl     319: 
2.65      frystyk   320: /*     REGISTER ALL KNOWN PROTOCOLS IN THE LIBRARY PREEMPTIVELY
                    321: **     --------------------------------------------------------
                    322: **     Not done automaticly - may be done by application!
                    323: */
                    324: PUBLIC void HTProtocolPreemptiveInit (void)
                    325: {
                    326: #ifndef DECNET
2.75      frystyk   327:     HTProtocol_add("ftp", "tcp", FTP_PORT, YES, HTLoadFTP, NULL);
                    328:     HTProtocol_add("nntp", "tcp", NEWS_PORT, YES, HTLoadNews, NULL);
                    329:     HTProtocol_add("news", "tcp", NEWS_PORT, YES, HTLoadNews, NULL);
                    330:     HTProtocol_add("gopher", "tcp", GOPHER_PORT, YES, HTLoadGopher, NULL);
2.65      frystyk   331: #ifdef HT_DIRECT_WAIS
2.75      frystyk   332:     HTProtocol_add("wais", "", WAIS_PORT, YES, HTLoadWAIS, NULL);
2.65      frystyk   333: #endif
                    334: #endif /* DECNET */
                    335: 
2.75      frystyk   336:     HTProtocol_add("http", "buffered_tcp", HTTP_PORT, YES, HTLoadHTTP, NULL);
                    337:     HTProtocol_add("file", "local", 0, YES, HTLoadFile, NULL);
                    338:     HTProtocol_add("telnet", "", 0, YES, HTLoadTelnet, NULL);
                    339:     HTProtocol_add("tn3270", "", 0, YES, HTLoadTelnet, NULL);
                    340:     HTProtocol_add("rlogin", "", 0, YES, HTLoadTelnet, NULL);
                    341:     HTProtocol_add("cache","local",0,YES,HTLoadCache,  NULL);
2.61      frystyk   342: }
                    343: 
2.48      frystyk   344: /*     BINDINGS BETWEEN ICONS AND MEDIA TYPES
                    345: **     --------------------------------------
                    346: **     Not done automaticly - may be done by application!
                    347: **     For directory listings etc. you can bind a set of icons to a set of
                    348: **     media types and special icons for directories and other objects that
                    349: **     do not have a media type.
                    350: */
2.61      frystyk   351: PUBLIC void HTIconInit (const char * url_prefix)
2.58      eric      352: {
2.65      frystyk   353:     const char * prefix = url_prefix ? url_prefix : ICON_LOCATION;
2.58      eric      354: 
2.61      frystyk   355:     HTIcon_addBlank("blank.xbm",       prefix, NULL);
                    356:     HTIcon_addDir("directory.xbm",     prefix, "DIR");
                    357:     HTIcon_addParent("back.xbm",       prefix, "UP");
                    358:     HTIcon_addUnknown("unknown.xbm",   prefix, NULL);
                    359: 
                    360:     HTIcon_add("unknown.xbm",  prefix, NULL,   "*/*");
                    361:     HTIcon_add("binary.xbm",   prefix, "BIN",  "binary");
                    362:     HTIcon_add("unknown.xbm",  prefix, NULL,   "www/unknown");
                    363:     HTIcon_add("text.xbm",     prefix, "TXT",  "text/*");
                    364:     HTIcon_add("image.xbm",    prefix, "IMG",  "image/*");
                    365:     HTIcon_add("movie.xbm",    prefix, "MOV",  "video/*");
                    366:     HTIcon_add("sound.xbm",    prefix, "AU",   "audio/*");
                    367:     HTIcon_add("tar.xbm",      prefix, "TAR",  "multipart/x-tar");
                    368:     HTIcon_add("tar.xbm",      prefix, "TAR",  "multipart/x-gtar");
                    369:     HTIcon_add("compressed.xbm",prefix,        "CMP",  "x-compress");
                    370:     HTIcon_add("compressed.xbm",prefix,        "GZP",  "x-gzip");
                    371:     HTIcon_add("index.xbm",    prefix, "IDX",  "application/x-gopher-index");
                    372:     HTIcon_add("index2.xbm",   prefix, "CSO",  "application/x-gopher-cso");
                    373:     HTIcon_add("telnet.xbm",   prefix, "TEL",  "application/x-gopher-telnet");
                    374:     HTIcon_add("unknown.xbm",  prefix, "DUP",  "application/x-gopher-duplicate");
                    375:     HTIcon_add("unknown.xbm",  prefix, "TN",   "application/x-gopher-tn3270");
2.65      frystyk   376: 
                    377:     /* Add global  mapping to where to find the internal icons */
2.87      frystyk   378:     {
                    379:        char * curdir = HTGetCurrentDirectoryURL();
                    380:        char * virtual = HTParse(ICON_LOCATION, curdir,
                    381:                                 PARSE_ACCESS|PARSE_HOST|PARSE_PATH|PARSE_PUNCTUATION);
                    382:        char * physical = NULL;
                    383:        StrAllocCat(virtual, "*");
                    384: 
                    385:        {
                    386:            char * str = NULL;
                    387:            if ((str = (char *) HT_MALLOC(strlen(W3C_ICONS) + 4)) == NULL)
                    388:                HT_OUTOFMEM("HTIconInit");
                    389:            strcpy(str, W3C_ICONS);
                    390:            if (*(str + strlen(str) - 1) != '/') strcat(str, "/");
                    391:            strcat(str, "*");
                    392:            physical = HTParse(str, curdir,
                    393:                               PARSE_ACCESS|PARSE_HOST|PARSE_PATH|PARSE_PUNCTUATION);
                    394:            HT_FREE(str);
                    395:        }
                    396:        HTRule_addGlobal(HT_Pass, virtual, physical);
                    397:        HT_FREE(virtual);
                    398:        HT_FREE(physical);
                    399:        HT_FREE(curdir);
                    400:     }
2.58      eric      401: }
                    402: 
2.57      eric      403: /*     REGISTER ALL HTTP/1.1 MIME HEADERS
                    404: **     --------------------------------------------
                    405: **     Not done automaticly - may be done by application!
                    406: */
2.64      frystyk   407: PUBLIC void HTMIMEInit (void)
2.57      eric      408: {
                    409:     struct {
                    410:         char * string;
                    411:        HTParserCallback * pHandler;
                    412:     } fixedHandlers[] = {
2.61      frystyk   413:        {"accept", &HTMIME_accept}, 
                    414:        {"accept-charset", &HTMIME_acceptCharset}, 
                    415:        {"accept-encoding", &HTMIME_acceptEncoding}, 
                    416:        {"accept-language", &HTMIME_acceptLanguage}, 
                    417:        {"accept-ranges", &HTMIME_acceptRanges}, 
                    418:        {"authorization", NULL},
2.72      frystyk   419:        {"cache-control", &HTMIME_cacheControl},
2.61      frystyk   420:        {"connection", &HTMIME_connection}, 
                    421:        {"content-encoding", &HTMIME_contentEncoding}, 
                    422:        {"content-length", &HTMIME_contentLength}, 
                    423:        {"content-range", &HTMIME_contentRange},
                    424:        {"content-transfer-encoding", &HTMIME_contentTransferEncoding}, 
                    425:        {"content-type", &HTMIME_contentType},
                    426:        {"digest-MessageDigest", &HTMIME_messageDigest}, 
2.77      eric      427:        {"keep-alive", &HTMIME_keepAlive}, 
2.61      frystyk   428:        {"link", &HTMIME_link},
                    429:        {"location", &HTMIME_location},
                    430:        {"max-forwards", &HTMIME_maxForwards}, 
2.57      eric      431:        {"mime-version", NULL}, 
2.61      frystyk   432:        {"pragma", &HTMIME_pragma},
2.73      frystyk   433:         {"protocol", &HTMIME_protocol},
                    434:         {"protocol-info", &HTMIME_protocolInfo},
                    435:         {"protocol-request", &HTMIME_protocolRequest},
2.66      frystyk   436:        {"proxy-authenticate", &HTMIME_authenticate},
2.61      frystyk   437:        {"proxy-authorization", &HTMIME_proxyAuthorization},
                    438:        {"public", &HTMIME_public},
                    439:        {"range", &HTMIME_range},
                    440:        {"referer", &HTMIME_referer},
                    441:        {"retry-after", &HTMIME_retryAfter}, 
2.62      frystyk   442:        {"server", &HTMIME_server}, 
2.81      frystyk   443:        {"trailer", &HTMIME_trailer},
2.85      frystyk   444:        {"transfer-encoding", &HTMIME_transferEncoding}, 
2.61      frystyk   445:        {"upgrade", &HTMIME_upgrade},
                    446:        {"user-agent", &HTMIME_userAgent},
                    447:        {"vary", &HTMIME_vary},
                    448:        {"via", &HTMIME_via},
                    449:        {"warning", &HTMIME_warning},
                    450:        {"www-authenticate", &HTMIME_authenticate}, 
2.91      kahan     451:         {"authentication-info", &HTMIME_authenticationInfo},
                    452:         {"proxy-authentication-info", &HTMIME_proxyAuthenticationInfo}
2.57      eric      453:     };
                    454:     int i;
                    455: 
                    456:     for (i = 0; i < sizeof(fixedHandlers)/sizeof(fixedHandlers[0]); i++)
                    457:         HTHeader_addParser(fixedHandlers[i].string, NO, 
                    458:                           fixedHandlers[i].pHandler);
                    459: }
                    460: 

Webmaster