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

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

Webmaster