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

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

Webmaster