Back to index

tetex-bin  3.0
dvipscms.h
Go to the documentation of this file.
00001 /*
00002  *  These are changes needed for the VM/CMS version of dvips as of
00003  *  May 21, 1991.   Revised 12/1/92.
00004  *  This was written by J. Hafner, E. Blanz and M. Flickner of IBM Research,
00005  *  Almaden Research Center.  Contact hafner@almaden.ibm.com.
00006  *  The changes to the rest of the code can be found by searching for
00007  *  "VMCMS".
00008  *
00009  *  This code can be included in dvips, subject to the same restrictions as
00010  *  in the copyright notice.
00011  */
00012 extern char *malloc();
00013 /*
00014  *  Added ascii to ebcdic conversion table for VMCMS.
00015  *  Only for the printable characters.  This is used by DVIPS.
00016 */
00017 char ascii2ebcdic[256] = {
00018        0,  1,  2,  3, 53, 45, 46, 47,
00019       22,  5, 37, 11, 12, 64, 14, 15,
00020       16, 17, 18, 19, 60, 61, 50, 38,
00021       24, 25, 63, 39,111,111,111,111,
00022       64, 90,127,123, 91,108, 80,125,
00023       77, 93, 92, 78,107, 96, 75, 97,
00024      240,241,242,243,244,245,246,247,
00025      248,249,122, 94, 76,126,110,111,
00026      124,193,194,195,196,197,198,199,
00027      200,201,209,210,211,212,213,214,
00028      215,216,217,226,227,228,229,230,
00029      231,232,233,173,224,189, 95,109,
00030      121,129,130,131,132,133,134,135,
00031      136,137,145,146,147,148,149,150,
00032      151,152,153,162,163,164,165,166,
00033      167,168,169,192, 79,208,161,  7,
00034      128,129,130,131,132,133,134,135,
00035      136,137,138,139,140,141,142,143,
00036      144,145,146,147,148,149,150,151,
00037      152,153,154,155,156,157,158,159,
00038      160,161,162,163,164,165,166,167,
00039      168,169,170,171,172,173,174,175,
00040      176,177,178,179,180,181,182,183,
00041      184,185,186,187,188,189,190,191,
00042      192,193,194,195,196,197,198,199,
00043      200,201,202,203,204,205,206,207,
00044      208,209,210,211,212,213,214,215,
00045      216,217,218,219,220,221,222,223,
00046      224,225,226,227,228,229,230,231,
00047      232,233,234,235,236,237,238,239,
00048      240,241,242,243,244,245,246,247,
00049      248,249,250,251,252,253,254,255
00050 };
00051 /*
00052  *  Added ebcdic to ascii conversion table for VMCMS.
00053  *  Only for the printable characters.  This inverts the
00054  *  table above and is used by AFM2TFM.
00055 */
00056 char ebcdic2ascii[256] = {
00057        0,  1,  2,  3,  4,  9,  6,127,
00058        8,  9, 10, 11, 12, 13, 14, 15,
00059       16, 17, 18, 19, 20, 21,  8, 23,
00060       24, 25, 26, 27, 28, 29, 30, 31,
00061       32, 33, 34, 35, 36, 10, 23, 27,
00062       40, 41, 42, 43, 44,  5,  6,  7,
00063       48, 49, 22, 51, 52,  4, 54, 55,
00064       56, 57, 58, 59, 20, 21, 62, 26,
00065       32, 65, 66, 67, 68, 69, 70, 71,
00066       72, 73, 74, 46, 60, 40, 43,124,
00067       38, 81, 82, 83, 84, 85, 86, 87,
00068       88, 89, 33, 36, 42, 41, 59, 94,
00069       45, 47, 98, 99,100,101,102,103,
00070      104,105,124, 44, 37, 95, 62, 63,
00071      112,113,114,115,116,117,118,119,
00072      120, 96, 58, 35, 64, 39, 61, 34,
00073      128, 97, 98, 99,100,101,102,103,
00074      104,105,138,123,140,141,142,143,
00075      144,106,107,108,109,110,111,112,
00076      113,114,154,125,156,157,158,159,
00077      160,161,115,116,117,118,119,120,
00078      121,122,170,171,172, 91,174,175,
00079      176,177,178,179,180,181,182,183,
00080      184,185,186,187,188, 93,190,191,
00081      192, 65, 66, 67, 68, 69, 70, 71,
00082       72, 73,202,203,204,205,206,207,
00083      208, 74, 75, 76, 77, 78, 79, 80,
00084       81, 82,218,219,220,221,222,223,
00085       92,225, 83, 84, 85, 86, 87, 88,
00086       89, 90,234,235,236,237,238,239,
00087       48, 49, 50, 51, 52, 53, 54, 55,
00088       56, 57,250,251,252,253,254,255
00089       };
00090 /*
00091  *   This redefines fopen for VMCMS, truncating long filenames for
00092  *   portability of TeX source.
00093  */
00094 #ifdef fopen
00095 #undef fopen
00096 #endif
00097 FILE *cmsfopen(filename, mode)
00098 char *filename, *mode ;
00099 {
00100    char cmsfile[21] ;
00101    char *save_file;
00102    char *ptr;
00103    void exit() ;
00104 
00105    if (!(save_file =
00106        (char *)malloc(strlen(filename) + 1, sizeof(char)))) {
00107       fprintf (stderr, "sorry---out of memory\n");
00108       exit(10);
00109    }
00110 
00111    strcpy(save_file, filename);
00112 
00113    cmsfile[0] = '\0' ;
00114 
00115    ptr = strtok(save_file, ". ") ;
00116    strncat(cmsfile, ptr, 8) ;
00117 
00118    strcat(cmsfile, ".");
00119 
00120    if (!(ptr = strtok(NULL, ". "))) {
00121 /*  Remove this, not much help anyway since most filenames are built
00122     internally. */
00123 /*
00124      fprintf(stderr, "\n<%s> is not a legitimate VM/CMS file name\n",
00125              filename);
00126      fprintf(stderr, "...we'll try to continue...\n");
00127 */
00128      return(NULL);
00129    }
00130 
00131    strncat(cmsfile, ptr, 8);
00132 
00133    if (ptr = strtok(NULL, ". ")) {
00134       strcat(cmsfile, ".");
00135       strncat(cmsfile, ptr, 2);
00136    }
00137 
00138    free(save_file);
00139 
00140    return(fopen(cmsfile, mode));
00141 
00142 }
00143 
00144 
00145 /*
00146  * access.c for VMCMS
00147  */
00148 int access (path, amode)
00149 char *path;
00150 int amode;
00151 {
00152   return(1);
00153 }