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

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.9       duns        6: **
2.20      frystyk     7: **     Define a basic set of suffixes and presentations
2.1       timbl       8: */
                      9: 
2.22      frystyk    10: /* Library include files */
                     11: #include "tcp.h"
                     12: #include "HTUtils.h"
2.24      frystyk    13: #include "HTFormat.h"
                     14: #include "HTList.h"
2.28      frystyk    15: 
                     16: /* Binding Managers */
2.24      frystyk    17: #include "HTBind.h"
2.28      frystyk    18: #include "HTProt.h"
2.24      frystyk    19: 
                     20: /* Converters and Presenters */
2.31      frystyk    21: #include "HTML.h"                      /* Uses HTML/HText interface */
                     22: #include "HTPlain.h"                   /* Uses HTML/HText interface */
                     23: 
                     24: #include "HTTeXGen.h"
2.1       timbl      25: #include "HTMLGen.h"
                     26: #include "HTMIME.h"
2.2       timbl      27: #include "HTWSRC.h"
2.22      frystyk    28: #include "HTFWrite.h"
2.39      frystyk    29: #include "HTNewsLs.h"
2.24      frystyk    30: 
                     31: /* Protocol Modules */
                     32: #include "HTTP.h"
                     33: #include "HTFile.h"
                     34: #include "HTFTP.h"
                     35: #include "HTGopher.h"
                     36: #include "HTTelnet.h"
2.18      frystyk    37: #include "HTNews.h"
2.24      frystyk    38: 
                     39: #ifdef HT_DIRECT_WAIS
2.27      frystyk    40: #include "HTWAIS.h"
2.24      frystyk    41: #endif
                     42: 
2.22      frystyk    43: #include "HTInit.h"                                     /* Implemented here */
2.1       timbl      44: 
2.29      frystyk    45: /* ------------------------------------------------------------------------- */
                     46: 
2.23      frystyk    47: /*     BINDINGS BETWEEN A SOURCE MEDIA TYPE AND A DEST MEDIA TYPE (CONVERSION)
                     48: **     ----------------------------------------------------------------------
                     49: **
                     50: **     Not done automaticly - must be done by application!
                     51: */
2.38      frystyk    52: PUBLIC void HTConverterInit (HTList * c)
2.23      frystyk    53: {
2.31      frystyk    54:     /*
                     55:     ** This set of converters uses the HTML/HText interface.
2.34      frystyk    56:     ** If you do not want this interface then replace them!
2.31      frystyk    57:     */
2.38      frystyk    58:     HTConversion_add(c,"text/html",            "www/present",  HTMLPresent,    1.0, 0.0, 0.0);
                     59:     HTConversion_add(c,"text/plain",           "www/present",  HTPlainPresent, 1.0, 0.0, 0.0);
                     60:     HTConversion_add(c,"text/html",            "text/x-c",     HTMLToC,        0.5, 0.0, 0.0);
                     61:     HTConversion_add(c,"text/html",            "text/plain",   HTMLToPlain,    0.5, 0.0, 0.0);
                     62:     HTConversion_add(c,"text/html",            "text/latex",   HTMLToTeX,      1.0, 0.0, 0.0);
2.31      frystyk    63: 
                     64:     /*
                     65:     ** These are converters that converts to something other than www/present,
                     66:     ** that is not directly outputting someting to the user on the screen
                     67:     */
2.38      frystyk    68:     HTConversion_add(c,"www/mime",             "*/*",          HTMIMEConvert,  1.0, 0.0, 0.0);
                     69:     HTConversion_add(c,"text/plain",           "text/html",    HTPlainToHTML,  1.0, 0.0, 0.0);
                     70:     HTConversion_add(c,"application/x-wais-source","*/*",      HTWSRCConvert,  1.0, 0.0, 0.0);
2.39      frystyk    71: 
                     72:     /*
                     73:     ** The following conversions are converting ASCII output from various
                     74:     ** protocols to HTML objects.
                     75:     */
                     76:     HTConversion_add(c,"text/x-nntp-list",     "www/present",  HTNewsList,     1.0, 0.0, 0.0);
                     77:     HTConversion_add(c,"text/x-nntp-over",     "www/present",  HTNewsGroup,    1.0, 0.0, 0.0);
2.31      frystyk    78: 
                     79:     /*
2.34      frystyk    80:     ** This dumps all other formats to local disk without any further
2.31      frystyk    81:     ** action taken
                     82:     */
2.38      frystyk    83:     HTConversion_add(c,"*/*",                  "www/present",  HTSaveLocally,  0.3, 0.0, 0.0);
2.23      frystyk    84: }
                     85: 
                     86: /*     BINDINGS BETWEEN MEDIA TYPES AND EXTERNAL VIEWERS/PRESENTERS
                     87: **     ------------------------------------------------------------
                     88: **
                     89: **     The data objects are stored in temporary files before the external
                     90: **     program is called
                     91: **
                     92: **     Not done automaticly - must be done by application!
                     93: */
2.38      frystyk    94: PUBLIC void HTPresenterInit (HTList * c)
2.1       timbl      95: {
                     96: #ifdef NeXT
2.38      frystyk    97:     HTPresentation_add(c,"application/postscript", "open %s",  NULL, 1.0, 2.0, 0.0);
2.10      luotonen   98:     /* The following needs the GIF previewer -- you might not have it. */
2.19      howcome    99: 
2.38      frystyk   100:     HTPresentation_add(c,"image/gif",          "open %s",      NULL, 0.3, 2.0, 0.0);
                    101:     HTPresentation_add(c,"image/x-tiff",       "open %s",      NULL, 1.0, 2.0, 0.0);
                    102:     HTPresentation_add(c,"audio/basic",                "open %s",      NULL, 1.0, 2.0, 0.0);
                    103:     HTPresentation_add(c,"*/*",                        "open %s",      NULL, 0.05, 0.0, 0.0); 
2.1       timbl     104: #else
2.10      luotonen  105:     if (getenv("DISPLAY")) {   /* Must have X11 */
2.38      frystyk   106:        HTPresentation_add(c,"application/postscript", "ghostview %s",  NULL, 1.0, 3.0, 0.0);
                    107:        HTPresentation_add(c,"image/gif",               "xv %s",        NULL, 1.0, 3.0, 0.0);
                    108:        HTPresentation_add(c,"image/x-tiff",    "xv %s",        NULL, 1.0, 3.0, 0.0);
                    109:        HTPresentation_add(c,"image/jpeg",      "xv %s",        NULL, 1.0, 3.0, 0.0);
                    110:        HTPresentation_add(c,"image/x-png",     "xv %s",        NULL, 1.0, 3.0, 0.0);
2.10      luotonen  111:     }
2.1       timbl     112: #endif
2.15      frystyk   113: }
                    114: 
                    115: 
2.23      frystyk   116: /*     PRESENTERS AND CONVERTERS AT THE SAME TIME
                    117: **     ------------------------------------------
                    118: **
                    119: **     This function is only defined in order to preserve backward
                    120: **     compatibility.
                    121: */
2.38      frystyk   122: PUBLIC void HTFormatInit (HTList * c)
2.15      frystyk   123: {
2.23      frystyk   124:     HTConverterInit(c);
                    125:     HTPresenterInit(c);
                    126: 
2.1       timbl     127: }
                    128: 
2.24      frystyk   129: /*     REGISTER ALL KNOWN PROTOCOLS IN THE LIBRARY
                    130: **     -------------------------------------------
                    131: **
                    132: **     Add to or subtract from this list if you add or remove protocol
                    133: **     modules. This function is called from HTLibInit()
                    134: **     Compiling with HT_NO_INIT prevents all known protocols from being
                    135: **     force in at link time.
                    136: */
2.33      frystyk   137: PUBLIC void HTAccessInit (void)
2.24      frystyk   138: {
                    139: #ifndef DECNET
2.34      frystyk   140:     HTProtocol_add("ftp", NO, HTLoadFTP);
2.37      frystyk   141:     HTProtocol_add("nntp", NO, HTLoadNews);
                    142:     HTProtocol_add("news", NO, HTLoadNews);
2.33      frystyk   143:     HTProtocol_add("gopher", NO, HTLoadGopher);
2.24      frystyk   144: #ifdef HT_DIRECT_WAIS
2.33      frystyk   145:     HTProtocol_add("wais", YES, HTLoadWAIS);
2.24      frystyk   146: #endif
                    147: #endif /* DECNET */
                    148: 
2.33      frystyk   149:     HTProtocol_add("http", NO, HTLoadHTTP);
                    150:     HTProtocol_add("file", NO, HTLoadFile);
                    151:     HTProtocol_add("telnet", YES, HTLoadTelnet);
                    152:     HTProtocol_add("tn3270", YES, HTLoadTelnet);
                    153:     HTProtocol_add("rlogin", YES, HTLoadTelnet);
2.24      frystyk   154: }
2.1       timbl     155: 
2.23      frystyk   156: /*     BINDINGS BETWEEN FILE EXTENSIONS AND MEDIA TYPES
                    157: **     ------------------------------------------------
2.1       timbl     158: **
2.23      frystyk   159: **     The LAST suffix for a type is that used for temporary files of that
                    160: **     type. The quality is an apriori bias as to whether the file should be
2.1       timbl     161: **     used.  Not that different suffixes can be used to represent files
                    162: **     which are of the same format but are originals or regenerated,
2.24      frystyk   163: **     with different values. Called from HTLibraryInit().
2.1       timbl     164: */
                    165: 
2.38      frystyk   166: PUBLIC void HTFileInit (void)
2.10      luotonen  167: {
2.24      frystyk   168:     /*                Suffix    Content-Type                   Encoding  Lang  Quality */
2.12      luotonen  169: 
2.40    ! frystyk   170:     HTBind_add("mime",   "www/mime",                   "8bit",   NULL, 1.0);   /* Internal -- MIME is  */
2.24      frystyk   171:                                                                        /* not recursive        */
2.40    ! frystyk   172:     HTBind_add("bin",    "application/octet-stream",   "binary", NULL, 1.0); /* Uninterpreted binary   */
        !           173:     HTBind_add("oda",    "application/oda",            "binary", NULL, 1.0);
        !           174:     HTBind_add("pdf",    "application/pdf",            "binary", NULL, 1.0);
        !           175:     HTBind_add("ai",     "application/postscript",     "8bit",   NULL, 0.5);   /* Adobe Illustrator    */
        !           176:     HTBind_add("PS",     "application/postscript",     "8bit",   NULL, 0.8);   /* PostScript           */
        !           177:     HTBind_add("eps",    "application/postscript",     "8bit",   NULL, 0.8);
        !           178:     HTBind_add("ps",     "application/postscript",     "8bit",   NULL, 0.8);
        !           179:     HTBind_add("gtar",   "application/x-gtar",         "binary", NULL, 1.0);   /* Gnu tar              */
        !           180:     HTBind_add("rtf",    "application/x-rtf",          "7bit",   NULL, 1.0);   /* RTF                  */
        !           181:     HTBind_add("csh",    "application/x-csh",          "7bit",   NULL, 0.5);   /* C-shell script       */
        !           182:     HTBind_add("dvi",    "application/x-dvi",          "binary", NULL, 1.0);   /* TeX DVI              */
        !           183:     HTBind_add("hdf",    "application/x-hdf",          "binary", NULL, 1.0);   /* NCSA HDF data file   */
        !           184:     HTBind_add("latex",  "application/x-latex",                "8bit",   NULL, 1.0);   /* LaTeX source         */
        !           185:     HTBind_add("nc",     "application/x-netcdf",       "binary", NULL, 1.0);   /* Unidata netCDF data  */
        !           186:     HTBind_add("cdf",    "application/x-netcdf",       "binary", NULL, 1.0);
        !           187:     HTBind_add("sh",     "application/x-sh",           "7bit",   NULL, 0.5);   /* Shell-script         */
        !           188:     HTBind_add("tar",    "application/x-tar",          "binary", NULL, 1.0);   /* 4.3BSD tar           */
        !           189:     HTBind_add("tcl",    "application/x-tcl",          "7bit",   NULL, 0.5);   /* TCL-script           */
        !           190:     HTBind_add("tex",    "application/x-tex",          "8bit",   NULL, 1.0);   /* TeX source           */
        !           191:     HTBind_add("texi",   "application/x-texinfo",      "7bit",   NULL, 1.0);   /* Texinfo              */
        !           192:     HTBind_add("texinfo","application/x-texinfo",      "7bit",   NULL, 1.0);
        !           193:     HTBind_add("t",      "application/x-troff",                "7bit",   NULL, 0.5);   /* Troff                */
        !           194:     HTBind_add("roff",   "application/x-troff",                "7bit",   NULL, 0.5);
        !           195:     HTBind_add("tr",     "application/x-troff",                "7bit",   NULL, 0.5);
        !           196:     HTBind_add("man",    "application/x-troff-man",    "7bit",   NULL, 0.5);   /* Troff with man macros*/
        !           197:     HTBind_add("me",     "application/x-troff-me",     "7bit",   NULL, 0.5);   /* Troff with me macros */
        !           198:     HTBind_add("ms",     "application/x-troff-ms",     "7bit",   NULL, 0.5);   /* Troff with ms macros */
        !           199:     HTBind_add("src",    "application/x-wais-source",  "7bit",   NULL, 1.0);   /* WAIS source          */
        !           200:     HTBind_add("bcpio",  "application/x-bcpio",                "binary", NULL, 1.0);   /* Old binary CPIO      */
        !           201:     HTBind_add("cpio",   "application/x-cpio",         "binary", NULL, 1.0);   /* POSIX CPIO           */
        !           202:     HTBind_add("shar",   "application/x-shar",         "8bit",   NULL, 1.0);   /* Shell archive        */
        !           203:     HTBind_add("sv4cpio","application/x-sv4cpio",      "binary", NULL, 1.0);   /* SVR4 CPIO            */
        !           204:     HTBind_add("sv4crc", "application/x-sv4crc",       "binary", NULL, 1.0);   /* SVR4 CPIO with CRC   */
        !           205:     HTBind_add("ustar",  "application/x-ustar",                "binary", NULL, 1.0);   /* POSIX tar            */
        !           206:     HTBind_add("snd",    "audio/basic",                        "binary", NULL, 1.0);   /* Audio                */
        !           207:     HTBind_add("au",     "audio/basic",                        "binary", NULL, 1.0);
        !           208:     HTBind_add("aiff",   "audio/x-aiff",               "binary", NULL, 1.0);
        !           209:     HTBind_add("aifc",   "audio/x-aiff",               "binary", NULL, 1.0);
        !           210:     HTBind_add("aif",    "audio/x-aiff",               "binary", NULL, 1.0);
        !           211:     HTBind_add("wav",    "audio/x-wav",                        "binary", NULL, 1.0);   /* Windows+ WAVE format */
        !           212:     HTBind_add("gif",    "image/gif",                  "binary", NULL, 1.0);   /* GIF                  */
        !           213:     HTBind_add("png",    "image/x-png",                        "binary", NULL, 1.0);   /* PNG                  */
        !           214:     HTBind_add("ief",    "image/ief",                  "binary", NULL, 1.0);   /* Image Exchange fmt   */
        !           215:     HTBind_add("jpg",    "image/jpeg",                 "binary", NULL, 1.0);   /* JPEG                 */
        !           216:     HTBind_add("JPG",    "image/jpeg",                 "binary", NULL, 1.0);
        !           217:     HTBind_add("JPE",    "image/jpeg",                 "binary", NULL, 1.0);
        !           218:     HTBind_add("jpe",    "image/jpeg",                 "binary", NULL, 1.0);
        !           219:     HTBind_add("JPEG",   "image/jpeg",                 "binary", NULL, 1.0);
        !           220:     HTBind_add("jpeg",   "image/jpeg",                 "binary", NULL, 1.0);
        !           221:     HTBind_add("tif",    "image/tiff",                 "binary", NULL, 1.0);   /* TIFF                 */
        !           222:     HTBind_add("tiff",   "image/tiff",                 "binary", NULL, 1.0);
        !           223:     HTBind_add("ras",    "image/cmu-raster",           "binary", NULL, 1.0);
        !           224:     HTBind_add("pnm",    "image/x-portable-anymap",    "binary", NULL, 1.0);   /* PBM Anymap format    */
        !           225:     HTBind_add("pbm",    "image/x-portable-bitmap",    "binary", NULL, 1.0);   /* PBM Bitmap format    */
        !           226:     HTBind_add("pgm",    "image/x-portable-graymap",   "binary", NULL, 1.0);   /* PBM Graymap format   */
        !           227:     HTBind_add("ppm",    "image/x-portable-pixmap",    "binary", NULL, 1.0);   /* PBM Pixmap format    */
        !           228:     HTBind_add("rgb",    "image/x-rgb",                        "binary", NULL, 1.0);
        !           229:     HTBind_add("xbm",    "image/x-xbitmap",            "binary", NULL, 1.0);   /* X bitmap             */
        !           230:     HTBind_add("xpm",    "image/x-xpixmap",            "binary", NULL, 1.0);   /* X pixmap format      */
        !           231:     HTBind_add("xwd",    "image/x-xwindowdump",                "binary", NULL, 1.0);   /* X window dump (xwd)  */
        !           232:     HTBind_add("html",   "text/html",                  "8bit",   NULL, 1.0);   /* HTML                 */
        !           233:     HTBind_add("c",      "text/plain",                 "7bit",   NULL, 0.5);   /* C source             */
        !           234:     HTBind_add("h",      "text/plain",                 "7bit",   NULL, 0.5);   /* C headers            */
        !           235:     HTBind_add("C",      "text/plain",                 "7bit",   NULL, 0.5);   /* C++ source           */
        !           236:     HTBind_add("cc",     "text/plain",                 "7bit",   NULL, 0.5);   /* C++ source           */
        !           237:     HTBind_add("hh",     "text/plain",                 "7bit",   NULL, 0.5);   /* C++ headers          */
        !           238:     HTBind_add("m",      "text/plain",                 "7bit",   NULL, 0.5);   /* Objective-C source   */
        !           239:     HTBind_add("f90",    "text/plain",                 "7bit",   NULL, 0.5);   /* Fortran 90 source    */
        !           240:     HTBind_add("txt",    "text/plain",                 "7bit",   NULL, 0.5);   /* Plain text           */
        !           241:     HTBind_add("rtx",    "text/richtext",              "7bit",   NULL, 1.0);   /* MIME Richtext format */
        !           242:     HTBind_add("tsv",    "text/tab-separated-values",  "7bit",   NULL, 1.0);   /* Tab-separated values */
        !           243:     HTBind_add("etx",    "text/x-setext",              "7bit",   NULL, 0.9);   /* Struct Enchanced Txt */
        !           244:     HTBind_add("MPG",    "video/mpeg",                 "binary", NULL, 1.0);   /* MPEG                 */
        !           245:     HTBind_add("mpg",    "video/mpeg",                 "binary", NULL, 1.0);
        !           246:     HTBind_add("MPE",    "video/mpeg",                 "binary", NULL, 1.0);
        !           247:     HTBind_add("mpe",    "video/mpeg",                 "binary", NULL, 1.0);
        !           248:     HTBind_add("MPEG",   "video/mpeg",                 "binary", NULL, 1.0);
        !           249:     HTBind_add("mpeg",   "video/mpeg",                 "binary", NULL, 1.0);
        !           250:     HTBind_add("qt",     "video/quicktime",            "binary", NULL, 1.0);   /* QuickTime            */
        !           251:     HTBind_add("mov",    "video/quicktime",            "binary", NULL, 1.0);
        !           252:     HTBind_add("avi",    "video/x-msvideo",            "binary", NULL, 1.0);   /* MS Video for Windows */
        !           253:     HTBind_add("movie",  "video/x-sgi-movie",          "binary", NULL, 1.0);   /* SGI "moviepalyer"    */
2.24      frystyk   254: 
2.40    ! frystyk   255:     HTBind_add("zip",    NULL,                         "zip",      NULL, 1.0); /* PKZIP                */
        !           256:     HTBind_add("Z",    NULL,                           "compress", NULL, 1.0); /* Compressed data      */
        !           257:     HTBind_add("gz",   NULL,                           "gzip",     NULL, 1.0); /* Gnu Compressed data  */
2.1       timbl     258: 
2.40    ! frystyk   259:     HTBind_add("*.*",     "www/unknown",                       "binary", NULL, 0.1);   /* Unknown suffix */
        !           260:     HTBind_add("*",       "www/unknown",                       "7bit",   NULL, 0.5);   /* No suffix */
2.1       timbl     261: }
                    262: 

Webmaster