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

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

Webmaster