Back to index

tetex-bin  3.0
dviinput.c
Go to the documentation of this file.
00001 /*
00002  *   Input bytes from the dvi file or the current virtual character.
00003  *   These routines could probably be sped up significantly; but they are
00004  *   very machine dependent, so I will leave such tuning to the installer.
00005  *   They simply get and return bytes in batches of one, two, three, and four,
00006  *   updating the current position as necessary.
00007  */
00008 #include "dvips.h" /* The copyright notice in that file is included too! */
00009 #include "protos.h"
00010 extern FILE *dvifile ;
00011 extern quarterword *curpos, *curlim ;
00012 
00013 void
00014 abortpage P1H(void)
00015 {
00016    error("! unexpected eof on DVI file") ;
00017 }
00018 
00019 shalfword  /* the value returned is, however, between 0 and 255 */
00020 dvibyte P1H(void)
00021 {
00022   register shalfword i ;
00023   if (curpos) {
00024      if (curpos>=curlim) return((shalfword)140) ;
00025      return (*curpos++) ;
00026   }
00027   if ((i=getc(dvifile))==EOF)
00028     abortpage() ;
00029   return(i) ;
00030 }
00031 
00032 halfword
00033 twobytes P1H(void)
00034 {
00035   register halfword i ;
00036   i = dvibyte() ;
00037   return(i*256+dvibyte()) ; }
00038 
00039 integer
00040 threebytes P1H(void)
00041 {
00042   register integer i ;
00043   i = twobytes() ;
00044   return(i*256+dvibyte()) ; }
00045 
00046 shalfword
00047 signedbyte P1H(void)
00048 {
00049   register shalfword i ;
00050   if (curpos) {
00051      if (curpos>=curlim)
00052        error("! unexpected end of virtual packet") ;
00053      i = *curpos++ ;
00054   } else if ((i=getc(dvifile))==EOF)
00055     abortpage() ;
00056   if (i<128) return(i) ;
00057   else return(i-256) ;
00058 }
00059 
00060 shalfword
00061 signedpair P1H(void)
00062 {
00063   register shalfword i ;
00064   i = signedbyte() ;
00065   return(i*256+dvibyte()) ;
00066 }
00067 
00068 integer
00069 signedtrio P1H(void)
00070 {
00071   register integer i ;
00072   i = signedpair() ;
00073   return(i*256+dvibyte()) ;
00074 }
00075 
00076 integer
00077 signedquad P1H(void)
00078 {
00079   register integer i ;
00080   i = signedpair() ;
00081   return(i*65536+twobytes()) ;
00082 }
00083 
00084 void
00085 skipover P1C(int, i)
00086 {
00087   while (i-->0) (void)dvibyte() ;
00088 }