This is dviinput.c in view mode; [Download] [Up]
/*
* dviinput.c of dvisw software package. This code is copyright (C) 1986
* by Radical Eye Software.
*
* Input files for the dvi file. These routines could probably be
* sped up significantly; they are very machine dependent, though, so
* I will leave such tuning to the installer. They simply get and
* return bytes of the dvifile in batches of one, two, three, and four,
* updateing the current position as necessary.
*/
#include "structures.h"
void error() ;
extern integer curpos ;
extern FILE *dvifile ;
extern quarterword *virpos, *virlim ;
void
abortpage()
{
printf("Tried to get byte %ld\n", curpos-1) ;
error("! unexpected eof on DVI file") ;
}
shalfword
dvibyte()
{
register shalfword i ;
if (virpos) {
if (virpos >= virlim)
return 140 ;
else
return *virpos++ ;
} else {
curpos++ ;
i = getc(dvifile) ;
if (i==EOF)
abortpage() ;
return(i) ;
}
}
halfword
twobytes()
{
register halfword i ;
i = dvibyte() ;
return(i*256+dvibyte()) ; }
integer
threebytes()
{
register integer i ;
i = twobytes() ;
return(i*256+dvibyte()) ; }
shalfword
signedbyte()
{
register shalfword i ;
if (virpos) {
if (virpos >= virlim) {
i = 0 ;
error("! unexpected end of virtual packet") ;
} else
i = *virpos++ ;
} else {
curpos++ ;
if ((i=getc(dvifile))==EOF)
abortpage() ;
}
if (i<128) return(i) ;
else return(i-256) ;
}
shalfword
signedpair()
{
register shalfword i ;
i = signedbyte() ;
return(i*256+dvibyte()) ;
}
integer
signedtrio()
{
register integer i ;
i = signedpair() ;
return(i*256+dvibyte()) ;
}
integer
signedquad()
{
register integer i ;
i = signedpair() ;
return(i*65536+twobytes()) ;
}
void
skipover(i)
int i ;
{
while (i-->0) (void)dvibyte() ;
}
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.