home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / printer / dvi2pcl.lha / preamble.c < prev    next >
C/C++ Source or Header  |  1992-11-25  |  2KB  |  75 lines

  1. /* $Log:    preamble.c,v $
  2.  * Revision 0.8  92/11/23  19:46:54  19:46:54  bt (Bo Thide')
  3.  * Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support
  4.  * 
  5.  * Revision 0.7  92/11/13  02:41:39  02:41:39  bt (Bo Thide')
  6.  * More bug fixes and improvements. Support for PaintJet XL
  7.  * 
  8.  * Revision 0.6  92/11/10  21:48:37  21:48:37  bt (Bo Thide')
  9.  * Bug fixes. Added -R option. Better font handling.
  10.  * 
  11.  * Revision 0.5  92/11/09  16:25:43  16:25:43  bt (Bo Thide')
  12.  * Rewrite of dospecial.c. Extended \special support
  13.  * 
  14.  * Revision 0.4  92/11/08  02:45:59  02:45:59  bt (Bo Thide')
  15.  * Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's.
  16.  * 
  17.  * Revision 0.3  92/08/24  12:45:49  12:45:49  bt (Bo Thide')
  18.  * Fixed 8 bit (dc font) support.
  19.  * 
  20.  * Revision 0.2  92/08/23  17:29:00  17:29:00  bt (Bo Thide')
  21.  * Source cleaned up.  Changed certain function calls.  Removed globals.
  22.  * 
  23.  * Revision 0.1  92/08/22  23:58:48  23:58:48  bt (Bo Thide')
  24.  * First Release.
  25.  *  */
  26.  
  27. /*
  28.  * This routine processes the preamble and determines the global variables
  29.  * 'conv' and 'magnification'. It exits if a fatal error is found in the
  30.  * preamble.
  31.  */
  32.  
  33. #include <stdio.h>
  34. #include "dvi.h"
  35. #include "globals.h"
  36. #include "macros.h"
  37.  
  38. static char rcsid[] = "$Header: preamble.c,v 0.8 92/11/23 19:46:54 bt Exp $";
  39.  
  40. preamble(dvifile, resolution)
  41. FILE    *dvifile;
  42. short    resolution;
  43.     ubyte    p;
  44.  
  45.     if(getubyte(dvifile) != DVI_PRE)
  46.         sterror("Bad %s file: First byte is not start of preamble\n",
  47.           DVIFILE_SUFFIX);
  48.     if(getubyte(dvifile) != 2)
  49.         fprintf(stderr,"Identifier in byte 1 should be '2'");
  50.     numerator   = (long)getsquad(dvifile);
  51.     denominator = (long)getsquad(dvifile);
  52.  
  53. #ifdef DEBUG
  54.     fprintf (stderr,"preamble: numerator=%d, denominator=%d\n",numerator,denominator);
  55. #endif /* DEBUG */
  56.  
  57.     if(numerator <= 0)
  58.         valerror("Bad .dvi file: Numerator is %d\n" , numerator);
  59.     if(denominator <= 0 )
  60.         valerror("Bad .dvi file: Denominator is %d\n" , denominator);
  61.     magnification = (long)getsquad(dvifile);
  62.     conv = ((double)numerator/254000.0)*(double)resolution*(double)magnification/((double)denominator*1000.0) ;
  63.  
  64. #ifdef DEBUG
  65.     fprintf (stderr,"preamble: magnification=%d, conv=%g\n",magnification,conv);
  66. #endif /* DEBUG */
  67.  
  68.     p = getubyte(dvifile);
  69.  
  70. #ifdef DEBUG2
  71.     fprintf (stderr,"preamble: p = %d\n",p);
  72. #endif /* DEBUG2 */
  73. }
  74.