home *** CD-ROM | disk | FTP | other *** search
/ ftp.update.uu.se / ftp.update.uu.se.2014.03.zip / ftp.update.uu.se / pub / rainbow / msdos / decus / RB140 / grlib03a.arj / CREQ.C < prev    next >
Text File  |  1988-12-19  |  5KB  |  130 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /*  HIGHER LEVEL 'C' FUNCTIONS FOR THE GRAPHICS LIBRARY    */
  4. /*                                                         */
  5. /***********************************************************/
  6.  
  7. #include <stdio.h>
  8. #include <graph.h>
  9.  
  10. /************************************************************************/
  11. /*                                                                      */
  12. /*      F U N C T I O N    ld_font(font_fn, font_number)                */
  13. /*                         char *font_fn;                               */
  14. /*                         int  font_number;                            */
  15. /*                                                                      */
  16. /*      purpose:        load data in a file into one of the graphics    */
  17. /*                      font arrays.                                    */
  18. /*                                                                      */
  19. /*      entry:          font_fn is the name of the file.                */
  20. /*                      font_number number to be loaded. [0 to 3]       */
  21. /*                                                                      */
  22. /*      exit:           NULL if font loaded OK.                         */
  23. /*                      EOF if an error occured                */
  24. /*                                                                      */
  25. /************************************************************************/
  26.  
  27. ld_font(font_fn,font_number)
  28. char *font_fn;
  29. int   font_number;
  30. {
  31.    FILE *ffile;
  32.    int i;
  33.  
  34.    if ( (ffile = fopen(font_fn,"rb")) == NULL) {
  35.     fprintf(stderr,"cannot open font file %s\n",font_fn);
  36.     return(EOF);
  37.    }
  38.    font_number &= 3;
  39.    if (tfonts[font_number] == NULL) {
  40.     if ((tfonts[font_number] = malloc(2560)) == NULL) {
  41.         fprintf(stderr,"Can't allocate memory for %s\n",font_fn);
  42.         return(EOF);
  43.     }
  44.    }
  45.    if ( (i = fread(tfonts[font_number],2560,1,ffile)) == NULL || i < 1) {
  46.     fprintf(stderr,"Incomplete read of font file - %s\n",font_fn);
  47.     return(EOF);
  48.    }
  49.    fclose(ffile);
  50.    return(NULL);
  51. }
  52.  
  53. /************************************************************************/
  54. /*                                                                      */
  55. /*      F U N C T I O N    ld_wsdets(ws_num, type, ws_file)             */
  56. /*               int ws_num, type;                */
  57. /*               char *ws_file;                */
  58. /*                                                                      */
  59. /*      purpose:        load work_station data from file                */
  60. /*                                                                      */
  61. /*      exit:           NULL work_station loaded OK.                    */
  62. /*                      EOF if work_station file could not be found.    */
  63. /*                                                                      */
  64. /************************************************************************/
  65.  
  66. static char ws_no_err[] = {"Cannot open Work_station file %s\n"};
  67. static char *notice =
  68.     "MSDOS Graphics Library 3.00 25-Apr-85 (c) Digital Equipment Co. Ltd.\n";
  69.  
  70. static char *wsdrivers[] = {
  71.     /*01*/    "SMIDMON.GRA",
  72.     /*02*/    "SHIGHMON.GRA",
  73.     /*03*/    "SMIDCOL.GRA",
  74.     /*04*/    "SHIGHCOL.GRA",
  75.     /*05*/    "DMID.GRA",
  76.     /*06*/    "DHIGH.GRA"
  77. };
  78.  
  79. ld_wsdets(ws_num, type, ws_file)
  80. int  ws_num, type;
  81. char *ws_file;
  82. {
  83.     FILE *wfile;
  84.     int fsz, i;
  85.     unsigned char *mws;
  86.  
  87.     for(i = 0; i < MAX_WS; i++) {
  88.     if (gr_data[i].ws_ty) break;
  89.     }
  90.     if (i == MAX_WS) fprintf(stderr,notice);
  91.     if (type < 0) {
  92.     if ((wfile = fopen(ws_file, "rb")) == NULL ) {
  93.         fprintf(stderr, ws_no_err, ws_file);
  94.         return(EOF);
  95.     }
  96.     }
  97.     else if (type == 0 || type > 6) {
  98.     fprintf(stderr,"Work_station %d out of range\n", type);
  99.     return(EOF);
  100.     }
  101.     else if ((wfile = fopen(wsdrivers[--type],"rb")) == NULL) {
  102.     fprintf(stderr, ws_no_err, wsdrivers[type]);
  103.     return(EOF);
  104.     }
  105.     mws = (char *) &cur_ws;
  106.     fsz = sizeof(struct work_station);
  107.     fread(mws, fsz, 1, wfile);
  108.     fclose(wfile);
  109.     return(NULL);
  110. }
  111.  
  112. /************************************************************************/
  113. /*                                                                      */
  114. /*      F U N C T I O N    conout_(char)                                */
  115. /*                                                                      */
  116. /*      purpose:        output character to console                     */
  117. /*                                                                      */
  118. /*      entry:          char to be output                               */
  119. /*                                                                      */
  120. /*      exit:           none.                                           */
  121. /*                                                                      */
  122. /************************************************************************/
  123.  
  124. conout_(c)
  125. unsigned char c;
  126. {
  127.     putc(c, stderr);
  128. }
  129. 
  130.