|
|
/* $Id: dvi2xx.c,v 2.5 1997/12/08 20:52:20 neumann Exp $ */ | /* $Id: dvi2xx.c,v 2.5 1997/12/08 20:52:20 neumann Exp $ */ |
#define VERSION "2.6p2 (dviljk)" |
#define VERSION "dviljk (version 2.6p3)" |
/* | /* |
#define DEBUGGS 1 | #define DEBUGGS 1 |
*/ | */ |
|
|
# endif | # endif |
#endif | #endif |
| |
/* Initialize pixel_files */ |
/* Initialize pixel_files */ |
for (i = 0; i <= MAXOPEN; i++) | for (i = 0; i <= MAXOPEN; i++) |
pixel_files[i].pixel_file_id = FPNULL; | pixel_files[i].pixel_file_id = FPNULL; |
| |
|
|
y_origin = YDEFAULTOFF; /* y-origin in dots */ | y_origin = YDEFAULTOFF; /* y-origin in dots */ |
| |
setbuf(ERR_STREAM, NULL); | setbuf(ERR_STREAM, NULL); |
(void) strcpy(G_progname, argv[0]); |
G_progname = argv[0]; |
#ifdef KPATHSEA | #ifdef KPATHSEA |
kpse_set_progname(argv[0]); | kpse_set_progname(argv[0]); |
kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile); | kpse_set_program_enabled (kpse_pk_format, MAKE_TEX_PK_BY_DEFAULT, kpse_src_compile); |
|
|
EMIT1("@PJL SET PAGEPROTECT=OFF\012"); | EMIT1("@PJL SET PAGEPROTECT=OFF\012"); |
EMIT1("@PJL ENTER LANGUAGE=PCL\012"); | EMIT1("@PJL ENTER LANGUAGE=PCL\012"); |
if (econoMode && LJ6) | if (econoMode && LJ6) |
EMIT1("@PJL SET ECONOMODE=ON\012"); |
EMIT1("@PJL SET ECONOMODE=ON\012"); |
EMIT3("\033&u%dD\033*t%dR",RESOLUTION,RESOLUTION); | EMIT3("\033&u%dD\033*t%dR",RESOLUTION,RESOLUTION); |
if (econoMode && !LJ6) | if (econoMode && !LJ6) |
EMIT1("\033*v1T"); | EMIT1("\033*v1T"); |
|
|
/* | /* |
fprintf(ERR_STREAM,"FirstPart\n count %d, mod %d, pp %d\n",(int)count[0],(int)count[0]%2,PageParity); | fprintf(ERR_STREAM,"FirstPart\n count %d, mod %d, pp %d\n",(int)count[0],(int)count[0]%2,PageParity); |
*/ | */ |
SkipMode = |
SkipMode = |
(bool)(PageParity != (short)((count[0]<0 ? |
(bool)(PageParity != (short)((count[0]<0 ? |
labs(count[0])+1 : count[0])%2)); | labs(count[0])+1 : count[0])%2)); |
if (count[0] == 0) SkipMode = (bool)!SkipMode; | if (count[0] == 0) SkipMode = (bool)!SkipMode; |
} | } |
|
|
is not buffered. */ | is not buffered. */ |
| |
/* read a buffered byte */ | /* read a buffered byte */ |
char |
char |
#if NeedFunctionPrototypes | #if NeedFunctionPrototypes |
b_read(FILEPTR spfp) | b_read(FILEPTR spfp) |
#else | #else |
|
|
} | } |
| |
#ifdef RISC_BUFFER | #ifdef RISC_BUFFER |
void |
void |
#if NeedFunctionPrototypes | #if NeedFunctionPrototypes |
b_write(FILEPTR spfp, char c) /* write a buffered byte */ | b_write(FILEPTR spfp, char c) /* write a buffered byte */ |
#else | #else |
|
|
buffout[boact++] = c; | buffout[boact++] = c; |
} | } |
| |
void |
void |
#if NeedFunctionPrototypes | #if NeedFunctionPrototypes |
b_wrtmult(FILEPTR spfp, char *buf, int len) /* write a sequence of bytes to the output buffer */ | b_wrtmult(FILEPTR spfp, char *buf, int len) /* write a sequence of bytes to the output buffer */ |
#else | #else |
|
|
write_multi(buffout,1,boact,spfp); | write_multi(buffout,1,boact,spfp); |
/* Copy only small blocks; large ones are written directly */ | /* Copy only small blocks; large ones are written directly */ |
if (len < (BUFFSIZE/4)) { | if (len < (BUFFSIZE/4)) { |
for (i = 0; i<len; i++) |
for (i = 0; i<len; i++) |
buffout[i] = buf[i]; | buffout[i] = buf[i]; |
boact = len; | boact = len; |
} else { | } else { |
write_multi(buf,1,len,spfp); |
write_multi(buf,1,len,spfp); |
boact = 0; | boact = 0; |
} | } |
} | } |
else { | else { |
for (i = 0; i<len; i++) |
for (i = 0; i<len; i++) |
buffout[boact++] = buf[i]; | buffout[boact++] = buf[i]; |
} | } |
} | } |
| |
/* flush the output buffer */ | /* flush the output buffer */ |
void |
void |
#if NeedFunctionPrototypes | #if NeedFunctionPrototypes |
b_oflush(FILEPTR spfp) | b_oflush(FILEPTR spfp) |
#else | #else |
|
|
/***************************** CopyHPFile ******************************/ | /***************************** CopyHPFile ******************************/ |
/*********************************************************************/ | /*********************************************************************/ |
#if NeedFunctionPrototypes | #if NeedFunctionPrototypes |
int getnum(FILEPTR spfp, char *t, char *numstr) |
int getnum(FILEPTR spfp, char *t, char *numstr) |
#else | #else |
int getnum(spfp, t, numstr) |
int getnum(spfp, t, numstr) |
FILEPTR spfp; | FILEPTR spfp; |
char *t, *numstr; | char *t, *numstr; |
#endif | #endif |
|
|
} | } |
| |
#if NeedFunctionPrototypes | #if NeedFunctionPrototypes |
void setOffset(char dir, char sign, int pos) |
void setOffset(char dir, char sign, int pos) |
#else | #else |
void setOffset(dir, sign, pos, first) |
void setOffset(dir, sign, pos, first) |
char dir, sign; | char dir, sign; |
int pos; | int pos; |
#endif | #endif |
{ | { |
if ((sign == '+' || sign == '-') && pos > 0 ) { | if ((sign == '+' || sign == '-') && pos > 0 ) { |
EMIT4("\033*p%c%d%c",sign,pos,dir); | EMIT4("\033*p%c%d%c",sign,pos,dir); |
#ifdef DEBUGGS |
#ifdef DEBUGGS |
fprintf(stderr, "relative: *p%c%d%c\n", sign, pos, dir); | fprintf(stderr, "relative: *p%c%d%c\n", sign, pos, dir); |
#endif | #endif |
} else if (pos>0) { | } else if (pos>0) { |
EMIT3("\033*p%d%c",pos,dir); | EMIT3("\033*p%d%c",pos,dir); |
#ifdef DEBUGGS |
#ifdef DEBUGGS |
fprintf(stderr, "absolute: *p%d%c\n", pos, dir); | fprintf(stderr, "absolute: *p%d%c\n", pos, dir); |
#endif | #endif |
if (dir == 'X') |
if (dir == 'X') |
last_rx = pos; | last_rx = pos; |
else |
else |
last_ry = pos; | last_ry = pos; |
} else { | } else { |
/*EMIT3("\033*p%d%c",pos,dir);*/ | /*EMIT3("\033*p%d%c",pos,dir);*/ |
#ifdef DEBUGGS |
#ifdef DEBUGGS |
fprintf(stderr, "Relative: *p%d%c\n", pos, dir); | fprintf(stderr, "Relative: *p%d%c\n", pos, dir); |
#endif | #endif |
} | } |
|
|
unwanted commands from the input file and outputs the rest */ | unwanted commands from the input file and outputs the rest */ |
| |
/* reset the input buffer */ | /* reset the input buffer */ |
binumber = 0; |
binumber = 0; |
biact = 0; | biact = 0; |
| |
qfprintf(ERR_STREAM," [%s", str); | qfprintf(ERR_STREAM," [%s", str); |
|
|
/* of the commands (x first, y first) */ | /* of the commands (x first, y first) */ |
| |
if (t=='Y' || t=='y') { | if (t=='Y' || t=='y') { |
if (numstr[0]!='+' && numstr[0]!='-' && num<miny) |
if (numstr[0]!='+' && numstr[0]!='-' && num<miny) |
miny = num; | miny = num; |
if (t=='y') { | if (t=='y') { |
num = getnum(spfp, &t, numstr); | num = getnum(spfp, &t, numstr); |
if (numstr[0]!='+' && numstr[0]!='-' && num<minx) |
if (numstr[0]!='+' && numstr[0]!='-' && num<minx) |
minx = num; | minx = num; |
} | } |
} | } |
if (t=='X' || t=='x') { | if (t=='X' || t=='x') { |
if (numstr[0]!='+' && numstr[0]!='-' && num<minx) |
if (numstr[0]!='+' && numstr[0]!='-' && num<minx) |
minx = num; | minx = num; |
| |
if (t=='x') { | if (t=='x') { |
|
|
} | } |
qfprintf(ERR_STREAM," [%s", str); | qfprintf(ERR_STREAM," [%s", str); |
/* reset input buffer again */ | /* reset input buffer again */ |
binumber = 0; |
binumber = 0; |
biact = 0; | biact = 0; |
| |
| |
/* Pass through the input file again but this time output the */ | /* Pass through the input file again but this time output the */ |
/* retained PCL commands */ | /* retained PCL commands */ |
#ifdef DEBUGGS |
#ifdef DEBUGGS |
fprintf(stderr,"\nminx=%d, miny=%d, xg=%d, yg=%d\n", |
fprintf(stderr,"\nminx=%d, miny=%d, xg=%d, yg=%d\n", |
minx, miny, x_goffset, y_goffset); | minx, miny, x_goffset, y_goffset); |
#endif |
#endif |
do { | do { |
t = (char)b_read(spfp); | t = (char)b_read(spfp); |
if (t==0x1B) { | if (t==0x1B) { |
|
|
} else { | } else { |
setOffset('Y',numstr[0], num); | setOffset('Y',numstr[0], num); |
} | } |
|
|
if (t == 'y') { | if (t == 'y') { |
num = getnum(spfp, &t,numstr); | num = getnum(spfp, &t,numstr); |
if (numstr[0]!='+' && numstr[0]!='-') { | if (numstr[0]!='+' && numstr[0]!='-') { |
|
|
} | } |
} | } |
} | } |
|
|
if (t=='X' || t=='x') { | if (t=='X' || t=='x') { |
if (numstr[0]!='+' && numstr[0]!='-') { | if (numstr[0]!='+' && numstr[0]!='-') { |
/*Add in the correct horizontal offset*/ | /*Add in the correct horizontal offset*/ |
setOffset('X',numstr[0], | setOffset('X',numstr[0], |
num - minx + (int)PIXROUND(h,hconv) + x_goffset); | num - minx + (int)PIXROUND(h,hconv) + x_goffset); |
} else { |
} else { |
setOffset('X',numstr[0], num); | setOffset('X',numstr[0], num); |
} | } |
|
|
if (t=='x') { | if (t=='x') { |
num = getnum(spfp, &t,numstr); | num = getnum(spfp, &t,numstr); |
if (numstr[0]!='+' && numstr[0]!='-') { | if (numstr[0]!='+' && numstr[0]!='-') { |
|
|
case(0x63): | case(0x63): |
/* Rectangular draw commands */ | /* Rectangular draw commands */ |
EMIT1("\033*c"); | EMIT1("\033*c"); |
for (t = (char)b_read(spfp); t<0x40 || t>0x60; |
for (t = (char)b_read(spfp); t<0x40 || t>0x60; |
t = (char)b_read(spfp)) | t = (char)b_read(spfp)) |
EMITC(t); | EMITC(t); |
EMITC(t); | EMITC(t); |
|
|
long4 x = 0; /* number being constructed */ | long4 x = 0; /* number being constructed */ |
unsigned char h; | unsigned char h; |
while (n--) { | while (n--) { |
x <<= 8; |
x <<= 8; |
read_byte(fp,h); | read_byte(fp,h); |
x |= h; | x |= h; |
} | } |
|
|
#ifdef SIGN_DEBUG | #ifdef SIGN_DEBUG |
long4 x0; /* copy of x */ | long4 x0; /* copy of x */ |
#endif | #endif |
read_byte(fp,h); |
read_byte(fp,h); |
x = h; /* get first (high-order) byte */ | x = h; /* get first (high-order) byte */ |
n1 = n--; | n1 = n--; |
while (n--) { | while (n--) { |
|
|
/* ---> result in DX */ | /* ---> result in DX */ |
| |
if ( (regs.h.dl & 0x80) /* file handle points to a device */ | if ( (regs.h.dl & 0x80) /* file handle points to a device */ |
&& !(regs.h.dl & 0x07) ) { /* neither console i/o or null */ |
&& !(regs.h.dl & 0x07) ) { /* neither console i/o or null */ |
| |
regs.h.dl |= 0x20; /* set BINARY bit in device info */ | regs.h.dl |= 0x20; /* set BINARY bit in device info */ |
regs.h.ah = (unsigned char) 0x44; /* IOCTL */ | regs.h.ah = (unsigned char) 0x44; /* IOCTL */ |
|
|
/* For COMPRESSED CHARS */ | /* For COMPRESSED CHARS */ |
if (PrevSize < nbpl) { | if (PrevSize < nbpl) { |
PrevSize = nbpl; | PrevSize = nbpl; |
if (PrevLine != NULL) |
if (PrevLine != NULL) |
free(PrevLine); | free(PrevLine); |
if ((PrevLine = (unsigned char*)malloc(PrevSize*sizeof(char))) |
if ((PrevLine = (unsigned char*)malloc(PrevSize*sizeof(char))) |
== NULL) { | == NULL) { |
PrevSize = 0; |
PrevSize = 0; |
Fatal("EmitChar: Out of memory error!\n"); | Fatal("EmitChar: Out of memory error!\n"); |
} | } |
} | } |
/* Clear seed line */ | /* Clear seed line */ |
for (i = 0; i<nbpl; i++) |
for (i = 0; i<nbpl; i++) |
PrevLine[i] = 0; | PrevLine[i] = 0; |
CChar_Off = 0; |
CChar_Off = 0; |
CChar_Last = -1; | CChar_Last = -1; |
|
|
/* This bit copied from below... */ | /* This bit copied from below... */ |
# ifdef USEPXL | # ifdef USEPXL |
if (fontptr->id == pk89) | if (fontptr->id == pk89) |
|
|
CompressedCharLine(ce,nbpl,sl); | CompressedCharLine(ce,nbpl,sl); |
} | } |
# else | # else |
for (i = num_rows; i > 0; i--) |
for (i = num_rows; i > 0; i--) |
CompressedCharLine(ce,nbpl,(bits + (i-1)*nbpl)); | CompressedCharLine(ce,nbpl,(bits + (i-1)*nbpl)); |
# endif /* USEPXL */ | # endif /* USEPXL */ |
} | } |
else |
else |
CChar_Off = -1; | CChar_Off = -1; |
# endif /* LJ4 */ | # endif /* LJ4 */ |
| |
|
|
# ifdef LJ4 | # ifdef LJ4 |
/* printf("raw: %d (%d * %d), comp: %d\n", | /* printf("raw: %d (%d * %d), comp: %d\n", |
total,ce->width,ce->height,CChar_Off); */ | total,ce->width,ce->height,CChar_Off); */ |
/* Characters that don't compress well are usually rather small so |
/* Characters that don't compress well are usually rather small so |
reading them again and writing them uncompressed won't take |
reading them again and writing them uncompressed won't take |
much time anyway. */ | much time anyway. */ |
if (CChar_Off > total) |
if (CChar_Off > total) |
CChar_Off = -1; | CChar_Off = -1; |
if (CChar_Off >= 0) { | if (CChar_Off >= 0) { |
EMIT4("\033*c%sd%dE\033(s%ldW", cnv_buffer, | EMIT4("\033*c%sd%dE\033(s%ldW", cnv_buffer, |
|
|
} | } |
#endif | #endif |
} | } |
|
|
#ifdef IBM3812 | #ifdef IBM3812 |
#ifdef USEPXL | #ifdef USEPXL |
used_fontstorage += (long4)ce->height * ((ce->width + 15) >> 4) * 2 + 14; | used_fontstorage += (long4)ce->height * ((ce->width + 15) >> 4) * 2 + 14; |
|
|
int repeatcount; | int repeatcount; |
| |
void /* <Read and translate raster description@>*/ | void /* <Read and translate raster description@>*/ |
#if NeedFunctionPrototypes |
#if NeedFunctionPrototypes |
PkRaster(struct char_entry *ce, int raster) | PkRaster(struct char_entry *ce, int raster) |
#else | #else |
PkRaster(ce, raster) | PkRaster(ce, raster) |
|
|
if (wordweight < 31) { | if (wordweight < 31) { |
#ifdef COMMENT | #ifdef COMMENT |
# ifdef DRAWGLYPH | # ifdef DRAWGLYPH |
{ |
{ |
int k; | int k; |
for (k = 15; k>=0; k--) { | for (k = 15; k>=0; k--) { |
if ((power[k] & word)!=0) printf("Z"); | if ((power[k] & word)!=0) printf("Z"); |
|
|
for (j = 3; j >= (wordwidth * 4 - (long4)nbpl); j--) { | for (j = 3; j >= (wordwidth * 4 - (long4)nbpl); j--) { |
OUTCHAR(((word >> (j << 3)) & 0xff)); | OUTCHAR(((word >> (j << 3)) & 0xff)); |
#ifdef DRAWGLYPH | #ifdef DRAWGLYPH |
{ |
{ |
int k; | int k; |
for (k = 7; k>=0; k--) { | for (k = 7; k>=0; k--) { |
if ((power[k] & ((word >> (j << 3)) & 0xff))!=0) printf("M"); | if ((power[k] & ((word >> (j << 3)) & 0xff))!=0) printf("M"); |
|
|
} | } |
| |
} | } |
|
|
switch (raster) { | switch (raster) { |
case 1: |
case 1: |
RasterLine(ce, nbpl, current_line, raster_line_buf); | RasterLine(ce, nbpl, current_line, raster_line_buf); |
current_line++; | current_line++; |
break; | break; |
|
|
OUTCHAR((tl & 0xFF)); | OUTCHAR((tl & 0xFF)); |
| |
#ifdef DRAWGLYPH | #ifdef DRAWGLYPH |
{ |
{ |
int k; | int k; |
for (k = 31; k>=0; k--) { | for (k = 31; k>=0; k--) { |
if ((power[k] & row[ii])!=0) printf("M"); | if ((power[k] & row[ii])!=0) printf("M"); |
|
|
for (j = 3; j >= (wordwidth *4 - (long4)nbpl); j--) { | for (j = 3; j >= (wordwidth *4 - (long4)nbpl); j--) { |
OUTCHAR(((tl >> (j << 3)) & 0xff)); | OUTCHAR(((tl >> (j << 3)) & 0xff)); |
#ifdef DRAWGLYPH | #ifdef DRAWGLYPH |
{ |
{ |
int k; | int k; |
for (k = 7; k>=0; k--) { | for (k = 7; k>=0; k--) { |
if ((power[k] & ((tl >> (j << 3)) & 0xff))!=0) printf("M"); | if ((power[k] & ((tl >> (j << 3)) & 0xff))!=0) printf("M"); |
|
|
} | } |
| |
switch (raster) { | switch (raster) { |
case 1: |
case 1: |
RasterLine(ce, (unsigned int)nbpl, current_line, raster_line_buf); | RasterLine(ce, (unsigned int)nbpl, current_line, raster_line_buf); |
current_line++; | current_line++; |
break; | break; |
|
|
| |
#ifdef LJ4 | #ifdef LJ4 |
/* Compress a raster line in compression mode 2 */ | /* Compress a raster line in compression mode 2 */ |
int |
int |
#if NeedFunctionPrototypes | #if NeedFunctionPrototypes |
CompressLine2(unsigned char *buffer, unsigned char *buffout, int emitbytes) | CompressLine2(unsigned char *buffer, unsigned char *buffout, int emitbytes) |
#else | #else |
|
|
char last,c; | char last,c; |
| |
/* trap empty lines (otherwise problems with Packbits) */ | /* trap empty lines (otherwise problems with Packbits) */ |
if (emitbytes == 0) |
if (emitbytes == 0) |
return(0); | return(0); |
/* Use Packbits compression (mode 2) on raster line */ | /* Use Packbits compression (mode 2) on raster line */ |
pos = buffer; |
pos = buffer; |
litpos = buffer; |
litpos = buffer; |
pack = 1; |
pack = 1; |
ppos = buffout; |
ppos = buffout; |
last = *pos++; | last = *pos++; |
upper = buffer + emitbytes; | upper = buffer + emitbytes; |
while (pos < upper) { | while (pos < upper) { |
|
|
/* At least three equal bytes ==> write out preceding literal sequence */ | /* At least three equal bytes ==> write out preceding literal sequence */ |
if ((pack == 3) && ((lit = (int)(pos - litpos - 3)) != 0)) { | if ((pack == 3) && ((lit = (int)(pos - litpos - 3)) != 0)) { |
while (lit >= 128) { | while (lit >= 128) { |
*ppos++ = 127; |
*ppos++ = 127; |
for (i = 1; i<=128; i++) |
for (i = 1; i<=128; i++) |
*ppos++ = *litpos++; | *ppos++ = *litpos++; |
lit -= 128; | lit -= 128; |
} | } |
if (lit != 0) { | if (lit != 0) { |
*ppos++ = lit-1; |
*ppos++ = lit-1; |
while ((lit--) > 0) |
while ((lit--) > 0) |
*ppos++ = *litpos++; | *ppos++ = *litpos++; |
/* litpos is now pos-3 (i.e. first of the sequence) */ | /* litpos is now pos-3 (i.e. first of the sequence) */ |
} | } |
|
|
} | } |
else { | else { |
while (pack >= 128) { | while (pack >= 128) { |
*ppos++ = 129; |
*ppos++ = 129; |
*ppos++ = last; |
*ppos++ = last; |
litpos += 128; |
litpos += 128; |
pack -= 128; | pack -= 128; |
} | } |
/* At least 3 equal bytes or 2 that don't break a literal sequence | /* At least 3 equal bytes or 2 that don't break a literal sequence |
==> write out packed sequence */ | ==> write out packed sequence */ |
if ((pack >= 3) || ((pack == 2) && (litpos == pos-3))) { | if ((pack >= 3) || ((pack == 2) && (litpos == pos-3))) { |
*ppos++ = 257 - pack; |
*ppos++ = 257 - pack; |
*ppos++ = last; |
*ppos++ = last; |
litpos += pack; | litpos += pack; |
} | } |
pack = 1; |
pack = 1; |
last = c; | last = c; |
} | } |
if (ppos > (buffout + BUFFSIZE/2 - 129)) { | if (ppos > (buffout + BUFFSIZE/2 - 129)) { |
|
|
return(0); | return(0); |
} | } |
} | } |
|
|
while (pack >= 128) { | while (pack >= 128) { |
*ppos++ = 129; |
*ppos++ = 129; |
*ppos++ = last; |
*ppos++ = last; |
litpos += 128; |
litpos += 128; |
pack -= 128; | pack -= 128; |
} | } |
if ((pack >= 3) || ((pack == 2) && (litpos == pos-3))) { | if ((pack >= 3) || ((pack == 2) && (litpos == pos-3))) { |
*ppos++ = 257 - pack; |
*ppos++ = 257 - pack; |
*ppos++ = last; |
*ppos++ = last; |
litpos += pack; | litpos += pack; |
} | } |
else if ((lit = (int)(pos - litpos)) != 0) { | else if ((lit = (int)(pos - litpos)) != 0) { |
while (lit >= 128) { | while (lit >= 128) { |
*ppos++ = 127; |
*ppos++ = 127; |
for (i = 1; i<=128; i++) |
for (i = 1; i<=128; i++) |
*ppos++ = *litpos++; | *ppos++ = *litpos++; |
lit -= 128; | lit -= 128; |
} | } |
if (lit != 0) { | if (lit != 0) { |
*ppos++ = lit-1; |
*ppos++ = lit-1; |
while ((lit--) > 0) |
while ((lit--) > 0) |
*ppos++ = *litpos++; | *ppos++ = *litpos++; |
} | } |
} | } |
|
|
int lit,i,pack; | int lit,i,pack; |
| |
/* Use compression mode 3 */ | /* Use compression mode 3 */ |
pos = buffer; |
pos = buffer; |
ppos = buffout; |
ppos = buffout; |
upper = buffer + emitbytes; |
upper = buffer + emitbytes; |
prev = PrevLine; | prev = PrevLine; |
while(pos < upper) { | while(pos < upper) { |
litpos = pos; | litpos = pos; |
while ((*prev == *pos) && (pos < upper)) { | while ((*prev == *pos) && (pos < upper)) { |
prev++; |
prev++; |
pos++; | pos++; |
} | } |
if (pos < upper) { | if (pos < upper) { |
pack = (int)(pos - litpos); |
pack = (int)(pos - litpos); |
litpos = pos; | litpos = pos; |
i = upper - pos; |
i = upper - pos; |
if (i > 8) |
if (i > 8) |
i = 8; | i = 8; |
while ((*pos != *prev) && (i > 0)) { | while ((*pos != *prev) && (i > 0)) { |
*prev++ = *pos++; |
*prev++ = *pos++; |
i--; | i--; |
} | } |
i = (int)(pos - litpos - 1); | i = (int)(pos - litpos - 1); |
|
|
*ppos++ = lit + pack; | *ppos++ = lit + pack; |
} | } |
else { | else { |
*ppos++ = lit + 31; |
*ppos++ = lit + 31; |
pack -= 31; | pack -= 31; |
while (pack >= 255) { | while (pack >= 255) { |
*ppos++ = 255; |
*ppos++ = 255; |
pack -= 255; | pack -= 255; |
} | } |
*ppos++ = pack; | *ppos++ = pack; |
} | } |
while (i >= 0) { | while (i >= 0) { |
*ppos++ = *litpos++; |
*ppos++ = *litpos++; |
i--; | i--; |
} | } |
} | } |
|
|
/**********************************************************************/ | /**********************************************************************/ |
void | void |
#if NeedFunctionPrototypes | #if NeedFunctionPrototypes |
RasterLine(struct char_entry *ce, unsigned int nbpl, |
RasterLine(struct char_entry *ce, unsigned int nbpl, |
unsigned int current_line, unsigned char *buffer) | unsigned int current_line, unsigned char *buffer) |
#else | #else |
RasterLine(ce, nbpl, current_line, buffer) | RasterLine(ce, nbpl, current_line, buffer) |
|
|
EMIT2("\033*b%dW", emitbytes); | EMIT2("\033*b%dW", emitbytes); |
EMITL(emitbytes, buffer); | EMITL(emitbytes, buffer); |
break; | break; |
|
|
case 2: | case 2: |
i = CompressLine2(buffer,buffin,emitbytes); | i = CompressLine2(buffer,buffin,emitbytes); |
EMIT2("\033*b%dW", i); | EMIT2("\033*b%dW", i); |
EMITL(i,buffin); | EMITL(i,buffin); |
break; | break; |
|
|
case 3: | case 3: |
i = CompressLine3(buffer,buffin + BUFFSIZE/2,(int)nbpl); | i = CompressLine3(buffer,buffin + BUFFSIZE/2,(int)nbpl); |
EMIT2("\033*b%dW", i); | EMIT2("\033*b%dW", i); |
EMITL(i,buffin + BUFFSIZE/2); | EMITL(i,buffin + BUFFSIZE/2); |
break; | break; |
|
|
default: |
default: |
fprintf(ERR_STREAM,"Unsupported compression mode!\n"); |
fprintf(ERR_STREAM,"Unsupported compression mode!\n"); |
} | } |
# else | # else |
EMIT2("\033*b%dW", emitbytes); | EMIT2("\033*b%dW", emitbytes); |
|
|
if (CompressCharMode == 3) { | if (CompressCharMode == 3) { |
/* Check if PrevLine big enough; claim more space if not */ | /* Check if PrevLine big enough; claim more space if not */ |
if (((int)nbpl) > PrevSize) { | if (((int)nbpl) > PrevSize) { |
if (PrevLine != NULL) |
if (PrevLine != NULL) |
free(PrevLine); | free(PrevLine); |
if ((PrevLine = (unsigned char *)malloc(nbpl*sizeof(char))) == NULL) { | if ((PrevLine = (unsigned char *)malloc(nbpl*sizeof(char))) == NULL) { |
PrevSize = 0; |
PrevSize = 0; |
Fatal("RasterChar: out of memory!\n"); | Fatal("RasterChar: out of memory!\n"); |
} | } |
PrevSize = (int)nbpl; | PrevSize = (int)nbpl; |
|
|
if (bytes > 0) { | if (bytes > 0) { |
/* do NOT load Huge characters */ | /* do NOT load Huge characters */ |
if ((bytes > HUGE_CHAR_PATTERN) && (fontptr->id != pk89)) { | if ((bytes > HUGE_CHAR_PATTERN) && (fontptr->id != pk89)) { |
qfprintf(ERR_STREAM,"Huge Character <%c> (%ld Bytes)\n", |
qfprintf(ERR_STREAM,"Huge Character <%c> (%ld Bytes)\n", |
(char)c, bytes); | (char)c, bytes); |
ptr->charsize = HUGE_SIZE; | ptr->charsize = HUGE_SIZE; |
ptr->where.isloaded = _FALSE; | ptr->where.isloaded = _FALSE; |
|
|
SetPosn(h, v); | SetPosn(h, v); |
} | } |
| |
/* |
/* |
fprintf(ERR_STREAM, | fprintf(ERR_STREAM, |
"(%d) hh=%ld (+%ld/+%ld), h=%ld, xh=%ld,xhh=%ld, [%ld|%ld] ->%d\n", | "(%d) hh=%ld (+%ld/+%ld), h=%ld, xh=%ld,xhh=%ld, [%ld|%ld] ->%d\n", |
(int)do_posn,hh,(long4)ptr->cw,(long4)ptr->cw*(long4)hconv,h, | (int)do_posn,hh,(long4)ptr->cw,(long4)ptr->cw*(long4)hconv,h, |
|
|
int tmp; | int tmp; |
char sign; | char sign; |
| |
if (!do_posn) |
if (!do_posn) |
SetPosn(h, v); | SetPosn(h, v); |
| |
#ifdef USEPXL | #ifdef USEPXL |
|
|
#endif | #endif |
if (tmp != 0) { | if (tmp != 0) { |
if (tmp < 0) { | if (tmp < 0) { |
sign = '-'; |
sign = '-'; |
tmp = -tmp; | tmp = -tmp; |
} else | } else |
sign = '+'; | sign = '+'; |
|
|
#endif | #endif |
if (tmp != 0) { | if (tmp != 0) { |
if (tmp < 0) { | if (tmp < 0) { |
sign = '-'; |
sign = '-'; |
tmp = -tmp; | tmp = -tmp; |
} else | } else |
sign = '+'; | sign = '+'; |
|
|
fprintf(stderr,"--> hh(%ld) += cw(%ld) * hconv(%ld)", | fprintf(stderr,"--> hh(%ld) += cw(%ld) * hconv(%ld)", |
(long)hh, (long)ptr->cw, (long) hconv); | (long)hh, (long)ptr->cw, (long) hconv); |
*/ | */ |
#ifdef LJ |
#ifdef LJ |
/* the guessed position must be a multiple of pixels */ | /* the guessed position must be a multiple of pixels */ |
if (RESOLUTION == 300) | if (RESOLUTION == 300) |
hh += (long4) ((ptr->cw)/4)*4*hconv; | hh += (long4) ((ptr->cw)/4)*4*hconv; |
|
|
if (command <= SET4) | if (command <= SET4) |
h += ptr->tfmw; | h += ptr->tfmw; |
| |
if (pos_after) |
if (pos_after) |
SetPosn(h, v); | SetPosn(h, v); |
else | else |
last_rx = (int)PIXROUND(h, hconv) + x_goffset; | last_rx = (int)PIXROUND(h, hconv) + x_goffset; |
|
|
} | } |
fonts_used_on_this_page = 0; | fonts_used_on_this_page = 0; |
#endif | #endif |
for (p = hfontptr; p; p = p->next) |
for (p = hfontptr; p; p = p->next) |
p->used_on_this_page = _FALSE; | p->used_on_this_page = _FALSE; |
} | } |
| |
|
|
rx = (int)PIXROUND(x, hconv) + x_goffset; | rx = (int)PIXROUND(x, hconv) + x_goffset; |
ry = (int)PIXROUND(y, vconv) + y_goffset; | ry = (int)PIXROUND(y, vconv) + y_goffset; |
| |
/* |
/* |
fprintf(ERR_STREAM, | fprintf(ERR_STREAM, |
"setposn to %ld/%ld, %d/%d, last: %d/%d\n", | "setposn to %ld/%ld, %d/%d, last: %d/%d\n", |
(long)x,(long)y, | (long)x,(long)y, |
|
|
offset in the buffer, CChar_Last is the first byte of the last | offset in the buffer, CChar_Last is the first byte of the last |
compacted row (line repeat count). Updates the previous line | compacted row (line repeat count). Updates the previous line |
(PrevLine) if necessary. */ | (PrevLine) if necessary. */ |
void |
void |
#if NeedFunctionPrototypes | #if NeedFunctionPrototypes |
CompressedCharLine(struct char_entry *ce, int nbpl, unsigned char *buffer) | CompressedCharLine(struct char_entry *ce, int nbpl, unsigned char *buffer) |
#else | #else |
CompressedCharLine(ce, nbpl, buffer) | CompressedCharLine(ce, nbpl, buffer) |
struct char_entry *ce; | struct char_entry *ce; |
int nbpl; |
int nbpl; |
unsigned char *buffer; | unsigned char *buffer; |
#endif | #endif |
{ | { |
|
|
int t,mode,max; | int t,mode,max; |
register int x,y,i; | register int x,y,i; |
| |
prev = PrevLine; |
prev = PrevLine; |
obuf = buffer; |
obuf = buffer; |
end = buffer + nbpl; |
end = buffer + nbpl; |
x = 0; | x = 0; |
while (obuf < end) { | while (obuf < end) { |
if (*obuf != *prev) { | if (*obuf != *prev) { |
*prev = *obuf; |
*prev = *obuf; |
x = 1; | x = 1; |
} | } |
obuf++; |
obuf++; |
prev++; | prev++; |
} | } |
if (x == 0 && CChar_Last >= 0) { | if (x == 0 && CChar_Last >= 0) { |
(buffin[CChar_Last])++; |
(buffin[CChar_Last])++; |
return; /* line repeat count +1 */ | return; /* line repeat count +1 */ |
} | } |
| |
end = buffin + BUFFSIZE - 16; |
end = buffin + BUFFSIZE - 16; |
obuf = buffin + CChar_Off; |
obuf = buffin + CChar_Off; |
buff = buffer; | buff = buffer; |
*obuf++ = 0; /* Line repeat count = 0 */ | *obuf++ = 0; /* Line repeat count = 0 */ |
t = 0; | t = 0; |
CChar_Last = CChar_Off; /* Next line */ | CChar_Last = CChar_Off; /* Next line */ |
mode = 0; |
mode = 0; |
y = *buff++; |
y = *buff++; |
i = 7; /* i = current bit */ | i = 7; /* i = current bit */ |
while ((t < ce->width) && (obuf < end)) { | while ((t < ce->width) && (obuf < end)) { |
max = ce->width - t; /* maximum pixels left to do */ | max = ce->width - t; /* maximum pixels left to do */ |
|
|
if (mode == 0) { | if (mode == 0) { |
/* white run */ | /* white run */ |
while ((y & (1<<i)) == 0 && x < max) { | while ((y & (1<<i)) == 0 && x < max) { |
x++; |
x++; |
i--; |
i--; |
if (i < 0) { | if (i < 0) { |
i = 7; |
i = 7; |
y = *buff++; |
y = *buff++; |
while (y == 0 && x < max) { | while (y == 0 && x < max) { |
x += 8; |
x += 8; |
y = *buff++; | y = *buff++; |
} | } |
} | } |
|
|
else { | else { |
/* black run */ | /* black run */ |
while ((y & (1<<i)) != 0 && x < max) { | while ((y & (1<<i)) != 0 && x < max) { |
x++; |
x++; |
i--; |
i--; |
if (i < 0) { | if (i < 0) { |
i = 7; |
i = 7; |
y = *buff++; |
y = *buff++; |
while (y == 0xff && x < max) { | while (y == 0xff && x < max) { |
x += 8; |
x += 8; |
y = *buff++; | y = *buff++; |
} | } |
} | } |
} | } |
mode = 0; | mode = 0; |
} | } |
if (x > max) |
if (x > max) |
x = max; | x = max; |
t += x; | t += x; |
/* make precautions for very long runs */ | /* make precautions for very long runs */ |
while (x > 0xff) { | while (x > 0xff) { |
*obuf++ = 0xff; |
*obuf++ = 0xff; |
*obuf++ = 0; |
*obuf++ = 0; |
x -= 0xff; | x -= 0xff; |
} | } |
*obuf++ = x; | *obuf++ = x; |
|
|
#endif | #endif |
{ | { |
int argind; /* argument index for flags */ | int argind; /* argument index for flags */ |
char curarea[STRSIZE]; /* current file area */ |
char *curarea; /* current file area */ |
char curname[STRSIZE]; /* current file name */ |
char *curname; /* current file name */ |
char *tcp, *tcp1; /* temporary character pointers */ | char *tcp, *tcp1; /* temporary character pointers */ |
char *this_arg; | char *this_arg; |
double x_offset = 0.0, y_offset = 0.0; | double x_offset = 0.0, y_offset = 0.0; |
|
|
#endif | #endif |
#endif | #endif |
| |
if (argc == 2 && (strcmp (argv[1], "--version") == 0)) { |
if (argc == 2 && EQ(argv[1], "--version")) { |
extern KPSEDLL char *kpathsea_version_string; | extern KPSEDLL char *kpathsea_version_string; |
puts ("dvilj(k) 2.6"); |
puts (VERSION); |
puts (kpathsea_version_string); | puts (kpathsea_version_string); |
puts ("Copyright (C) 1997 Gustaf Neumann.\n\ | puts ("Copyright (C) 1997 Gustaf Neumann.\n\ |
There is NO warranty. You may redistribute this software\n\ | There is NO warranty. You may redistribute this software\n\ |
|
|
For more information about these matters, see the files\n\ | For more information about these matters, see the files\n\ |
named COPYING and dvi2xx.c.\n\ | named COPYING and dvi2xx.c.\n\ |
Primary author of Dvi2xx: Gustaf Neumann; -k maintainer: K. Berry."); | Primary author of Dvi2xx: Gustaf Neumann; -k maintainer: K. Berry."); |
exit (0); |
exit (0); |
} | } |
| |
#ifdef LJ4 | #ifdef LJ4 |
|
|
#ifdef LJ2P | #ifdef LJ2P |
case 'd': /* d selects DUPLEX mode */ | case 'd': /* d selects DUPLEX mode */ |
tcp++; | tcp++; |
if (*tcp == '1' ) |
if (*tcp == '1' ) |
DuplexMode = 1; | DuplexMode = 1; |
else if (*tcp == '2') |
else if (*tcp == '2') |
DuplexMode = 2; | DuplexMode = 2; |
else { | else { |
Warning("Invalid DUPLEX mode, assuming DUPLEX=1, Long-Edge Binding"); | Warning("Invalid DUPLEX mode, assuming DUPLEX=1, Long-Edge Binding"); |
|
|
DoublePage = _TRUE; | DoublePage = _TRUE; |
tcp++; | tcp++; |
if (*tcp == '1' || *tcp == '2') { | if (*tcp == '1' || *tcp == '2') { |
if (*tcp == '2') |
if (*tcp == '2') |
PrintFirstPart = _FALSE; | PrintFirstPart = _FALSE; |
else |
else |
PrintSecondPart = _FALSE; | PrintSecondPart = _FALSE; |
tcp++; | tcp++; |
} | } |
if (*tcp == '-') |
if (*tcp == '-') |
PrintEmptyPages = _FALSE; | PrintEmptyPages = _FALSE; |
break; | break; |
#ifdef LJ4 | #ifdef LJ4 |
|
|
#ifdef LJ | #ifdef LJ |
case 'V': /* bugfixes for various vendor's PCL emulations */ | case 'V': /* bugfixes for various vendor's PCL emulations */ |
tcp++; | tcp++; |
if (*tcp == 'K' || *tcp == 'k') |
if (*tcp == 'K' || *tcp == 'k') |
kyocera_mode = _TRUE; | kyocera_mode = _TRUE; |
else | else |
if (*tcp == 'B' || *tcp == 'b') |
if (*tcp == 'B' || *tcp == 'b') |
brother_mode = _TRUE; | brother_mode = _TRUE; |
# ifdef LJ4 | # ifdef LJ4 |
else | else |
if (*tcp == '6' || *tcp == '6') |
if (*tcp == '6' || *tcp == '6') |
LJ6 = _TRUE; | LJ6 = _TRUE; |
# endif | # endif |
break; | break; |
|
|
#endif | #endif |
#ifdef __riscos | #ifdef __riscos |
case 'i': /* name of directory to store diagrams in */ | case 'i': /* name of directory to store diagrams in */ |
tcp++; |
tcp++; |
ddi = 0; | ddi = 0; |
while (*tcp != ' ' && *tcp != '\0' && ddi < DIAGDIRSIZE-1) { | while (*tcp != ' ' && *tcp != '\0' && ddi < DIAGDIRSIZE-1) { |
diagdir[ddi++] = *tcp++; | diagdir[ddi++] = *tcp++; |
|
|
} | } |
} else { | } else { |
| |
(void) strcpy(filename, tcp); |
filename = tcp; |
if (!strcmp(filename, "-")) { |
if (EQ(filename, "-")) { |
EmitFileName = "-"; | EmitFileName = "-"; |
#ifdef RISC_USE_OSL | #ifdef RISC_USE_OSL |
dvifp = BINOPEN("Kbd:"); | dvifp = BINOPEN("Kbd:"); |
|
|
AssureBinary(fileno(dvifp)); | AssureBinary(fileno(dvifp)); |
#endif | #endif |
} else { | } else { |
|
/* Since this code is used only once during startup, we don't care |
|
about free()ing the allocated strings that represent filenames. |
|
It will be more work to realize proper deallocation handling than |
|
it's worth in terms of saving a few bytes. We consider these |
|
bytes actually static memory where we don't know the size in |
|
advance and don't add them to the allocated_storage count. |
|
[27 Jun 07 -js] */ |
#ifdef KPATHSEA | #ifdef KPATHSEA |
/* split into directory + file name */ | /* split into directory + file name */ |
int tcplen, argvlen; | int tcplen, argvlen; |
tcp = (char *)xbasename(argv[argind]);/* this knows about any kind of slashes */ | tcp = (char *)xbasename(argv[argind]);/* this knows about any kind of slashes */ |
tcplen = strlen(tcp); | tcplen = strlen(tcp); |
|
if ( tcplen == 0 ) { |
|
/* This happens when the DVI file name has a trailing slash; this |
|
is not a valid name. Then we terminate the argument parsing |
|
loop, a usage message will be output below. */ |
|
break; |
|
} |
argvlen = strlen(argv[argind]); | argvlen = strlen(argv[argind]); |
if (tcplen == argvlen) | if (tcplen == argvlen) |
curarea[0] = '\0'; |
curarea = ""; |
else { | else { |
(void) strcpy(curarea, argv[argind]); |
curarea = xstrdup(argv[argind]); |
curarea[argvlen-tcplen] = '\0'; | curarea[argvlen-tcplen] = '\0'; |
} | } |
#else | #else |
tcp = strrchr(argv[argind], '/'); | tcp = strrchr(argv[argind], '/'); |
/* split into directory + file name */ | /* split into directory + file name */ |
if (tcp == NULL) { | if (tcp == NULL) { |
curarea[0] = '\0'; |
curarea[0] = ""; |
tcp = argv[argind]; | tcp = argv[argind]; |
} else { | } else { |
(void) strcpy(curarea, argv[argind]); |
curarea = xstrdup(argv[argind]); |
curarea[tcp-argv[argind]+1] = '\0'; | curarea[tcp-argv[argind]+1] = '\0'; |
tcp += 1; | tcp += 1; |
} | } |
#endif | #endif |
| |
(void) strcpy(curname, tcp); |
curname = (char *) xmalloc(strlen(tcp)+5); /* + space for ".dvi" */ |
|
(void) strcpy(curname, tcp); |
/* split into file name + extension */ | /* split into file name + extension */ |
tcp1 = strrchr(tcp, '.'); |
tcp1 = strrchr(curname, '.'); |
if (tcp1 == NULL) { | if (tcp1 == NULL) { |
(void) strcpy(rootname, curname); |
rootname = xstrdup(curname); |
strcat(curname, ".dvi"); | strcat(curname, ".dvi"); |
} else { | } else { |
*tcp1 = '\0'; | *tcp1 = '\0'; |
(void) strcpy(rootname, curname); |
rootname = xstrdup(curname); |
*tcp1 = '.'; | *tcp1 = '.'; |
} | } |
| |
|
filename = (char *) xmalloc(strlen(curarea)+strlen(curname)+1); |
(void) strcpy(filename, curarea); | (void) strcpy(filename, curarea); |
(void) strcat(filename, curname); | (void) strcat(filename, curname); |
| |
if ((dvifp = BINOPEN(filename)) == FPNULL) { | if ((dvifp = BINOPEN(filename)) == FPNULL) { |
/* do not insist on .dvi */ | /* do not insist on .dvi */ |
if (tcp1 == NULL) { | if (tcp1 == NULL) { |
int l = strlen(curname); |
filename[strlen(filename) - 4] = '\0'; |
if (l > 4) |
dvifp = BINOPEN(filename); |
curname[l - 4] = '\0'; |
|
l = strlen(filename); |
|
if (l > 4) |
|
filename[l - 4] = '\0'; |
|
} | } |
if (tcp1 != NULL || (dvifp = BINOPEN(filename)) == FPNULL) { |
if (dvifp == FPNULL) { |
#ifdef MSC5 | #ifdef MSC5 |
Fatal("%s: can't find DVI file \"%s\"\n\n", | Fatal("%s: can't find DVI file \"%s\"\n\n", |
G_progname, filename); | G_progname, filename); |
|
|
y_goffset = (short) MM_TO_PXL(y_offset) + y_origin; | y_goffset = (short) MM_TO_PXL(y_offset) + y_origin; |
| |
if (dvifp == FPNULL) { | if (dvifp == FPNULL) { |
fprintf(ERR_STREAM,"\nThis is the DVI to %s converter version %s", |
fprintf(ERR_STREAM,"\nThis is the DVI to %s converter %s", |
PRINTER, VERSION); | PRINTER, VERSION); |
#ifdef SEVENBIT | #ifdef SEVENBIT |
fprintf(ERR_STREAM,", 7bit"); | fprintf(ERR_STREAM,", 7bit"); |
|
|
exit(1); | exit(1); |
} | } |
if (EQ(EmitFileName, "")) { | if (EQ(EmitFileName, "")) { |
if ((EmitFileName = (char *)malloc( STRSIZE )) != NULL) |
EmitFileName = (char *) xmalloc(strlen(rootname)+sizeof(EMITFILE_EXTENSION)); |
allocated_storage += STRSIZE; |
(void) strcpy(EmitFileName, rootname); |
else |
|
Fatal("Can't allocate storage of %d bytes\n",STRSIZE); |
|
(void) strcpy(EmitFileName, curname); |
|
if ((tcp1 = strrchr(EmitFileName, '.'))) |
|
*tcp1 = '\0'; |
|
strcat(EmitFileName, EMITFILE_EXTENSION); | strcat(EmitFileName, EMITFILE_EXTENSION); |
} | } |
if (G_quiet) | if (G_quiet) |
|
|
if (PrintTestPage) EMIT1("\033z"); | if (PrintTestPage) EMIT1("\033z"); |
#ifdef vms | #ifdef vms |
/* last record is not flushed to file, unless it is completely filled */ | /* last record is not flushed to file, unless it is completely filled */ |
for (kk = (int)((*outfp)->_cnt); kk > 0; --kk) |
for (kk = (int)((*outfp)->_cnt); kk > 0; --kk) |
putc('\0',outfp); | putc('\0',outfp); |
fflush(outfp); | fflush(outfp); |
#endif | #endif |
|
|
#endif | #endif |
} | } |
CloseFiles(); | CloseFiles(); |
|
if ( tmp_dir[0] != '\0' ) |
|
rmdir (tmp_dir); /* ignore errors */ |
exit(G_errenc); | exit(G_errenc); |
} | } |
| |
|
|
#endif | #endif |
{ | { |
char *a,*b; | char *a,*b; |
|
|
a = s1; |
a = s1; |
b = s2; | b = s2; |
while (*a != '\0') { | while (*a != '\0') { |
if (tolower(*a) != tolower(*b)) return(_FALSE); | if (tolower(*a) != tolower(*b)) return(_FALSE); |
a++; |
a++; |
b++; | b++; |
} | } |
*end = b; |
*end = b; |
return(_TRUE); | return(_TRUE); |
} | } |
| |
|
|
{ | { |
char *s; | char *s; |
int count = 0; | int count = 0; |
|
|
s = str; | s = str; |
while ((*s != '\0') && (count < number)) { | while ((*s != '\0') && (count < number)) { |
while ((*s == ' ') || (*s == ',') || (*s == '=')) |
while ((*s == ' ') || (*s == ',') || (*s == '=')) |
s++; | s++; |
if (*s != '\0') { | if (*s != '\0') { |
result[count++] = strtod(s,&s); | result[count++] = strtod(s,&s); |
} | } |
} | } |
while ((*s == ' ') || (*s == ',') || (*s == '=')) |
while ((*s == ' ') || (*s == ',') || (*s == '=')) |
s++; | s++; |
*end = s; |
*end = s; |
return(count); | return(count); |
} | } |
| |
|
|
int results[4],no; | int results[4],no; |
| |
s = str; | s = str; |
while (*s == ' ') |
while (*s == ' ') |
s++; | s++; |
if ((StrCompare("drawfile",s,&s)) || (StrCompare("DVIview_diagram",s,&s))) { | if ((StrCompare("drawfile",s,&s)) || (StrCompare("DVIview_diagram",s,&s))) { |
| |
if (printdiag == _FALSE) |
if (printdiag == _FALSE) |
return(_TRUE); /* it's a diagram, but don't print */ | return(_TRUE); /* it's a diagram, but don't print */ |
| |
while ((*s == ' ') || (*s == '=')) |
while ((*s == ' ') || (*s == '=')) |
s++; /* space or '=' separates keyword/keyval */ | s++; /* space or '=' separates keyword/keyval */ |
| |
if (*s == '\0') { | if (*s == '\0') { |
fprintf(ERR_STREAM,"No filename given for \\special-diagram!\n"); |
fprintf(ERR_STREAM,"No filename given for \\special-diagram!\n"); |
return(_TRUE); | return(_TRUE); |
} | } |
sh = diagname; | sh = diagname; |
while ((*s != ' ') && (*s != ',') && (*s != '\0')) |
while ((*s != ' ') && (*s != ',') && (*s != '\0')) |
*sh++ = *s++; | *sh++ = *s++; |
*sh = '\0'; | *sh = '\0'; |
| |
|
|
dt.scalex = dt.scaley = 100; | dt.scalex = dt.scaley = 100; |
dt.cropl = dt.cropb = dt.cropr = dt.cropt = 0; | dt.cropl = dt.cropb = dt.cropr = dt.cropt = 0; |
while (*s != '\0') { | while (*s != '\0') { |
while ((*s == ' ') || (*s == ',')) |
while ((*s == ' ') || (*s == ',')) |
s++; | s++; |
if (*s != '\0') { | if (*s != '\0') { |
if (StrCompare("scale",s,&s)) { | if (StrCompare("scale",s,&s)) { |
|
|
fprintf(ERR_STREAM, | fprintf(ERR_STREAM, |
"Too few arguments (%d) given for <scale> - ignored.\n",no); | "Too few arguments (%d) given for <scale> - ignored.\n",no); |
} | } |
dt.scalex = results[0]; |
dt.scalex = results[0]; |
dt.scaley = results[1]; | dt.scaley = results[1]; |
} | } |
else if (StrCompare("crop",s,&s)) { | else if (StrCompare("crop",s,&s)) { |
|
|
fprintf(ERR_STREAM, | fprintf(ERR_STREAM, |
"Too few arguments (%d) given for <crop> - ignored.\n",no); | "Too few arguments (%d) given for <crop> - ignored.\n",no); |
} | } |
dt.cropl = results[0]; |
dt.cropl = results[0]; |
dt.cropr = results[1]; | dt.cropr = results[1]; |
dt.cropt = results[2]; |
dt.cropt = results[2]; |
dt.cropb = results[3]; | dt.cropb = results[3]; |
} | } |
else { | else { |
fprintf(ERR_STREAM,"Bad \\special keyword - <%s> ignored\n",s); | fprintf(ERR_STREAM,"Bad \\special keyword - <%s> ignored\n",s); |
/* skip over this word */ | /* skip over this word */ |
while ((*s != ' ') && (*s != ',') && (*s != '=') && (*s != '\0')) |
while ((*s != ' ') && (*s != ',') && (*s != '=') && (*s != '\0')) |
s++; | s++; |
} | } |
} | } |
|
|
diagram(diagname,&dt); | diagram(diagname,&dt); |
return(_TRUE); | return(_TRUE); |
} | } |
else |
else |
return(_FALSE); | return(_FALSE); |
} | } |
# endif /* LJ */ | # endif /* LJ */ |
|
|
int n; | int n; |
#endif | #endif |
{ | { |
char spbuf[STRSIZE], xs[STRSIZE], ys[STRSIZE]; |
char xs[STRSIZE], ys[STRSIZE]; |
char *sf = NULL, *psfile = NULL; |
char *include_file = NULL; |
|
enum { VerbFile, HPFile, PSFile } file_type; |
float x,y; | float x,y; |
long4 x_pos, y_pos; | long4 x_pos, y_pos; |
KeyWord k; | KeyWord k; |
int i, j, j1; | int i, j, j1; |
static int GrayScale = 10, Pattern = 1; | static int GrayScale = 10, Pattern = 1; |
static bool GrayFill = _TRUE; | static bool GrayFill = _TRUE; |
static long4 p_x[80], p_y[80]; |
static long4 p_x[MAX_SPECIAL_DEFPOINTS], p_y[MAX_SPECIAL_DEFPOINTS]; |
int llx=0, lly=0, urx=0, ury=0, rwi=0, rhi=0; |
int llx=0, lly=0, urx=0, ury=0, rwi=0; |
#ifdef WIN32 |
|
char *gs_path; |
|
#endif |
|
| |
str[n] = '\0'; | str[n] = '\0'; |
spbuf[0] = '\0'; |
for ( i=0 ; i<MAX_SPECIAL_DEFPOINTS ; i++ ) |
|
p_x[i] = p_y[i] = -1; |
| |
SetPosn(h, v); | SetPosn(h, v); |
#ifdef __riscos | #ifdef __riscos |
#ifdef LJ | #ifdef LJ |
if (ParseDiagram(str)) |
if (ParseDiagram(str)) |
return; | return; |
#endif | #endif |
#endif | #endif |
|
|
while ( (str = GetKeyStr(str, &k)) != NULL ) { | while ( (str = GetKeyStr(str, &k)) != NULL ) { |
/* get all keyword-value pairs */ | /* get all keyword-value pairs */ |
/* for compatibility, single words are taken as file names */ | /* for compatibility, single words are taken as file names */ |
if ( k.vt == None && access(k.Key, 0) == 0) { | if ( k.vt == None && access(k.Key, 0) == 0) { |
if ( sf |
if ( include_file && !kpse_tex_hush ("special") ) { |
#ifdef KPATHSEA |
Warning("More than one \\special file name given. %s ignored", include_file); |
&& !kpse_tex_hush ("special") |
free (include_file); |
#endif |
} |
) |
include_file = xstrdup(k.Key); |
Warning("More than one \\special file name given. %s ignored", sf); |
file_type = VerbFile; |
(void) strcpy(spbuf, k.Key); |
} else if ( GetKeyVal( &k, KeyTab, NKEYS, &i ) && i != -1 ) { |
sf = spbuf; |
|
/* |
|
for (j = 1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++); |
|
*/ |
|
} else if ( GetKeyVal( &k, KeyTab, NKEYS, &i ) && i != -1 ) |
|
switch (i) { | switch (i) { |
case PSFILE: | case PSFILE: |
if (sf |
if ( include_file ) { |
#ifdef KPATHSEA |
Warning("More than one \\special file name given. %s ignored", include_file); |
&& !kpse_tex_hush ("special") |
free(include_file); |
#endif |
} |
) |
include_file = xstrdup(k.Val); |
Warning("More than one \\special file name given. %s ignored", sf); |
file_type = PSFile; |
(void) strcpy(spbuf, k.Val); |
|
psfile = spbuf; |
|
/* |
|
for (j=1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++); |
|
*/ |
|
break; | break; |
|
|
case HPFILE: | case HPFILE: |
if (sf) |
if ( include_file && !kpse_tex_hush ("special") ) { |
Warning("More than one \\special file name given. %s ignored", sf); |
Warning("More than one \\special file name given. %s ignored", include_file); |
(void) strcpy(spbuf, k.Val); |
free(include_file); |
sf = spbuf; |
} |
/* |
include_file = xstrdup(k.Val); |
for (j=1; ((sf[j]=='/' ? sf[j]='\\':sf[j]) != '\0'); j++); |
file_type = HPFile; |
*/ |
|
break; | break; |
| |
case ORIENTATION: | case ORIENTATION: |
|
|
EMIT2("\033&l%dO\033*rF", (unsigned char)k.v.i); | EMIT2("\033&l%dO\033*rF", (unsigned char)k.v.i); |
} | } |
#endif | #endif |
else |
else { |
#ifdef KPATHSEA |
Warning( "Invalid orientation (%d) given; ignored.", k.v.i); |
if (!kpse_tex_hush ("special")) |
} |
#endif |
|
Warning( "Invalid orientation (%d)given; ignored.", k.v.i); |
|
break; | break; |
| |
case RESETPOINTS: | case RESETPOINTS: |
(void) strcpy(spbuf, k.Val); |
for ( i=0 ; i<MAX_SPECIAL_DEFPOINTS ; i++ ) |
|
p_x[i] = p_y[i] = -1; |
sf = NULL; |
|
break; | break; |
| |
case DEFPOINT: | case DEFPOINT: |
(void) strcpy(spbuf, k.Val); |
/* 254 is STRSIZE-1. cpp should be used to construct that number. */ |
i = sscanf(spbuf,"%d(%[^,],%s)",&j,xs,ys); |
i = sscanf(k.Val,"%d(%254[^,],%254s)",&j,xs,ys); |
if (i>0) { | if (i>0) { |
x_pos = h; |
if ( j < 0 || j >= MAX_SPECIAL_DEFPOINTS ) { |
|
Warning ("defpoint %d ignored, must be between 0 and %d", |
|
j, MAX_SPECIAL_DEFPOINTS); |
|
break; |
|
} |
|
x_pos = h; |
y_pos = v; | y_pos = v; |
if (i>1) { | if (i>1) { |
if (sscanf(xs,"%fpt",&x)>0) { | if (sscanf(xs,"%fpt",&x)>0) { |
|
|
} | } |
p_x[j]=x_pos; | p_x[j]=x_pos; |
p_y[j]=y_pos; | p_y[j]=y_pos; |
} else |
} else { |
#ifdef KPATHSEA |
Warning("invalid point definition"); |
if (!kpse_tex_hush ("special")) |
} |
#endif |
|
Warning("invalid point definition\n"); |
|
|
|
sf = NULL; |
|
break; | break; |
| |
case FILL: | case FILL: |
(void) strcpy(spbuf, k.Val); |
/* 254 is STRSIZE-1. cpp should be used to construct that number. */ |
i = sscanf(spbuf,"%d/%d %s",&j,&j1,xs); |
i = sscanf(k.Val,"%d/%d %254s",&j,&j1,xs); |
if (i>1) { | if (i>1) { |
#ifdef LJ | #ifdef LJ |
|
if ( j < 0 || j >= MAX_SPECIAL_DEFPOINTS ) { |
|
Warning ("fill ignored, point %d must be between 0 and %d", |
|
j, MAX_SPECIAL_DEFPOINTS); |
|
break; |
|
} |
|
if ( p_x[j] == -1 ) { |
|
Warning ("fill ignored, point %d is undefined\n", j); |
|
break; |
|
} |
|
if ( j1 < 0 || j1 >= MAX_SPECIAL_DEFPOINTS ) { |
|
Warning ("fill ignored, point %d must be between 0 and %d", |
|
j1, MAX_SPECIAL_DEFPOINTS); |
|
break; |
|
} |
|
if ( p_x[j1] == -1 ) { |
|
Warning ("fill ignored, point %d is undefined\n", j1); |
|
break; |
|
} |
SetPosn(p_x[j], p_y[j]); | SetPosn(p_x[j], p_y[j]); |
x_pos = (long4)PIXROUND(p_x[j1]-p_x[j], hconv); | x_pos = (long4)PIXROUND(p_x[j1]-p_x[j], hconv); |
y_pos = (long4)PIXROUND(p_y[j1]-p_y[j], vconv); | y_pos = (long4)PIXROUND(p_y[j1]-p_y[j], vconv); |
|
|
if ((k.v.i >= 0) && (k.v.i < 101)) { | if ((k.v.i >= 0) && (k.v.i < 101)) { |
GrayScale = k.v.i; | GrayScale = k.v.i; |
GrayFill = _TRUE; | GrayFill = _TRUE; |
} else |
} else { |
#ifdef KPATHSEA |
|
if (!kpse_tex_hush ("special")) |
|
#endif |
|
Warning( "Invalid gray scale (%d) given; ignored.", k.v.i); | Warning( "Invalid gray scale (%d) given; ignored.", k.v.i); |
|
} |
break; | break; |
| |
case PATTERN: | case PATTERN: |
if ((k.v.i >= 0) && (k.v.i < 7)) { | if ((k.v.i >= 0) && (k.v.i < 7)) { |
Pattern = k.v.i; | Pattern = k.v.i; |
GrayFill = _FALSE; | GrayFill = _FALSE; |
} else |
} else { |
#ifdef KPATHSEA |
|
if (!kpse_tex_hush ("special")) |
|
#endif |
|
Warning( "Invalid pattern (%d) given; ignored.", k.v.i); | Warning( "Invalid pattern (%d) given; ignored.", k.v.i); |
|
} |
break; | break; |
| |
case LLX: llx = k.v.i; break; | case LLX: llx = k.v.i; break; |
|
|
case URX: urx = k.v.i; break; | case URX: urx = k.v.i; break; |
case URY: ury = k.v.i; break; | case URY: ury = k.v.i; break; |
case RWI: rwi = k.v.i; break; | case RWI: rwi = k.v.i; break; |
case RHI: rhi = k.v.i; break; |
case RHI: |
|
if (!kpse_tex_hush ("special")) |
|
Warning("Whatever rhi was good for once, it is ignored now."); |
|
break; |
| |
default: | default: |
#ifdef KPATHSEA |
if ( !kpse_tex_hush ("special") ) |
if (!kpse_tex_hush ("special")) |
Warning("Can't handle %s=%s command; ignored.", k.Key, k.Val); |
#endif |
|
Warning("Can't handle %s=%s command; ignored.", k.Key, k.Val); |
|
break; | break; |
} | } |
|
|
else |
} else if (!kpse_tex_hush ("special")) { |
#ifdef KPATHSEA |
|
if (!kpse_tex_hush ("special")) |
|
#endif |
|
Warning("Invalid keyword or value in \\special - <%s> ignored", k.Key); | Warning("Invalid keyword or value in \\special - <%s> ignored", k.Key); |
|
} |
|
|
|
free (k.Key); |
|
if ( k.Val != NULL ) free(k.Val); |
} | } |
| |
if ( sf || psfile ) { |
if ( include_file ) { |
last_rx = last_ry = UNKNOWN; | last_rx = last_ry = UNKNOWN; |
#ifdef IBM3812 | #ifdef IBM3812 |
PMPflush; | PMPflush; |
#endif | #endif |
if (sf) { |
|
if (i == HPFILE) |
|
CopyHPFile( sf ); |
|
else |
|
CopyFile( sf ); |
|
} |
|
else |
|
#ifdef LJ | #ifdef LJ |
if (psfile) { |
if ( file_type == PSFile) { |
/* int height = rwi * (urx - llx) / (ury - lly);*/ |
/* int height = rwi * (urx - llx) / (ury - lly);*/ |
int width = urx - llx; |
int width = urx - llx; |
int height = ury - lly; |
int height = ury - lly; |
char cmd[255]; |
char cmd[255]; |
int scale_factor = 3000 * width / rwi; |
char *cmd_format = "%s -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit"; |
int adjusted_height = height * 300/scale_factor; |
char *gs_cmd; |
int adjusted_llx = llx * 300/scale_factor; |
int scale_factor, adjusted_height, adjusted_llx; |
char *printer = "ljetplus"; /* use the most stupid one */ |
char *printer = "ljetplus"; /* use the most stupid one */ |
|
|
|
char pcl_file[STRSIZE]; |
char scale_file_name[255]; |
char scale_file[STRSIZE]; |
char *scale_file = tmpnam(scale_file_name); |
FILEPTR scalef; |
char *pcl_file = tmpnam(NULL); |
|
FILEPTR scalef; |
if ( urx == 0 || ury == 0 || rwi == 0 ) { |
|
/* Since dvips' psfile special has a different syntax, this might |
if ( (scalef = BOUTOPEN(scale_file)) == FPNULL ) { |
well be one of those specials, i.e., a non-dviljk special. Then |
Warning("Unable to open file %s for writing", scale_file ); |
the Warning should be suppressable. */ |
return; |
if ( !kpse_tex_hush ("special") ) |
} |
Warning ("Ignoring psfile special without urx, ury and rwi attributes"); |
fprintf(scalef, "%.2f %.2f scale\n%d %d translate\n", |
free (include_file); |
300.0/scale_factor, 300.0/scale_factor, |
return; |
0, adjusted_height == height ? 0 : ury); |
} |
BCLOSE( scalef ); |
scale_factor = 3000 * width / rwi; |
|
adjusted_height = height * 300/scale_factor; |
|
adjusted_llx = llx * 300/scale_factor; |
|
|
|
/* We cannot use mkstemp, as we cannot pass two open file descriptors |
|
portably to Ghostscript. We don't want to use tmpnam() or tempnam() |
|
either, as they have tempfile creation race conditions. Instead we |
|
create a temporary directory with mkdtemp() -- if that's available. |
|
If not, we are thrown back to tempnam(), to get our functionality |
|
at all. We need to create the temporary directory only once per |
|
run; it will be deleted in AllDone(). */ |
|
if ( tmp_dir[0] == '\0' ) { |
|
char * base_dir; |
|
if ( (base_dir = getenv("TMPDIR")) == NULL ) { |
|
base_dir = "/tmp"; |
|
} else if ( strlen(base_dir) > STRSIZE - sizeof("/dviljkXXXXXX/include.pcl") ) { |
|
Warning ("TMPDIR %s is too long, using /tmp instead", base_dir); |
|
base_dir = "/tmp"; |
|
} |
|
if ( base_dir[0] == '/' && base_dir[1] == '\0' ) { |
|
Warning ("Feeling naughty, do we? / is no temporary directory, dude"); |
|
base_dir = "/tmp"; |
|
} |
|
strcpy (tmp_dir, base_dir); |
|
strcat (tmp_dir, "/dviljkXXXXXX"); |
|
if ( mkdtemp(tmp_dir) == NULL ) { |
|
Warning ("Could not create temporary directory %s, errno = %d; ignoring include file special", |
|
tmp_dir, errno); |
|
return; |
|
} |
|
} |
|
strcpy(pcl_file, tmp_dir); |
|
strcat(pcl_file, "/include.pcl"); |
|
strcpy(scale_file, tmp_dir); |
|
strcat(scale_file, "/scale.ps"); |
|
|
|
if ( (scalef = BOUTOPEN(scale_file)) == FPNULL ) { |
|
Warning("Unable to open file %s for writing", scale_file ); |
|
free (include_file); |
|
unlink(scale_file); /* ignore error */ |
|
return; |
|
} |
|
fprintf(scalef, "%.2f %.2f scale\n%d %d translate\n", |
|
300.0/scale_factor, 300.0/scale_factor, |
|
0, adjusted_height == height ? 0 : ury); |
|
BCLOSE( scalef ); |
| |
#ifdef WIN32 | #ifdef WIN32 |
gs_path = getenv("GS_PATH"); |
if ( (gs_cmd = getenv("GS_PATH")) == NULL ) |
if (!gs_path) |
gs_cmd = "gswin32c.exe"; |
gs_path = "gswin32c.exe"; |
#else |
sprintf(cmd,"%s -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit", |
gs_cmd = "gs"; |
gs_path, printer, pcl_file, scale_file, psfile); |
|
#else |
|
sprintf(cmd,"gs -q -dSIMPLE -dSAFER -dNOPAUSE -sDEVICE=%s -sOutputFile=%s %s %s showpage.ps -c quit", |
|
printer, pcl_file, scale_file, psfile); |
|
#endif |
|
#ifdef DEBUGGS |
|
fprintf(stderr, |
|
"PS-file '%s' w=%d, h=%d, urx=%d, ury=%d, llx=%d, lly=%d, rwi=%d\n", |
|
psfile, urx - llx, height, urx,ury,llx,lly, rwi); |
|
fprintf(stderr,"%s\n",cmd); |
|
#endif | #endif |
if (system(cmd)) { |
if ( strlen(cmd_format)-10 + strlen(gs_cmd) + strlen(printer) + |
Warning("execution of '%s' returned an error", cmd); |
strlen(pcl_file) + strlen(scale_file) + strlen(include_file) +1 > |
} else { |
sizeof(cmd) ) { |
#ifdef DEBUGGS |
Warning ("Ghostscript command for %s would be too long, skipping special", include_file); |
fprintf(stderr, "o=%d, h=%d, so=%d, sh=%d\n", |
free (include_file); |
llx, height, adjusted_llx, adjusted_height); |
unlink(scale_file); /* ignore errors */ |
|
unlink(pcl_file); |
fprintf(stderr, "OLD x=%d, y=%d\n", |
return; |
(int)PIXROUND(h, hconv) + x_goffset, |
} |
(int)PIXROUND(v, vconv) + y_goffset); |
sprintf(cmd, cmd_format, |
#endif |
gs_cmd, printer, pcl_file, scale_file, include_file); |
v -= 65536l*adjusted_height; /**300/scale_factor;*/ |
#ifdef DEBUGGS |
h -= 65536l*adjusted_llx; /* *300/scale_factor;*/ |
fprintf(stderr, |
SetPosn(h, v); |
"PS-file '%s' w=%d, h=%d, urx=%d, ury=%d, llx=%d, lly=%d, rwi=%d\n", |
#ifdef DEBUGGS |
include_file, urx - llx, height, urx,ury,llx,lly, rwi); |
fprintf(stderr, "NEW x=%d, y=%d\n", |
fprintf(stderr,"%s\n",cmd); |
(int)PIXROUND(h, hconv) + x_goffset, |
#endif |
(int)PIXROUND(v, vconv) + y_goffset); |
if (system(cmd)) { |
#endif |
Warning("execution of '%s' returned an error", cmd); |
|
} else { |
CopyHPFile( pcl_file ); |
#ifdef DEBUGGS |
/* unlink(pcl_file); */ |
fprintf(stderr, "o=%d, h=%d, so=%d, sh=%d\n", |
/* unlink(scale_file); */ |
llx, height, adjusted_llx, adjusted_height); |
} |
|
|
fprintf(stderr, "OLD x=%d, y=%d\n", |
|
(int)PIXROUND(h, hconv) + x_goffset, |
|
(int)PIXROUND(v, vconv) + y_goffset); |
|
#endif |
|
v -= 65536l*adjusted_height; /**300/scale_factor;*/ |
|
h -= 65536l*adjusted_llx; /* *300/scale_factor;*/ |
|
SetPosn(h, v); |
|
#ifdef DEBUGGS |
|
fprintf(stderr, "NEW x=%d, y=%d\n", |
|
(int)PIXROUND(h, hconv) + x_goffset, |
|
(int)PIXROUND(v, vconv) + y_goffset); |
|
#endif |
|
|
|
CopyHPFile( pcl_file ); |
} | } |
|
unlink(scale_file); /* ignore errors */ |
|
unlink(pcl_file); |
|
} |
|
else |
#endif /* LJ */ | #endif /* LJ */ |
|
|
|
if ( file_type == HPFile ) |
|
CopyHPFile( include_file ); |
|
else if ( file_type == VerbFile ) |
|
CopyFile( include_file ); |
|
else |
|
Warning ("This can't happen: unknown file_type value %d", file_type); |
|
|
|
if ( include_file != NULL ) free(include_file); |
} | } |
} | } |
| |
|
|
/**********************************************************************/ | /**********************************************************************/ |
/***************************** GetKeyStr ****************************/ | /***************************** GetKeyStr ****************************/ |
/**********************************************************************/ | /**********************************************************************/ |
/* extract first keyword-value pair from string (value part may be null) |
/* Extract first keyword-value pair from string (value part may be null), |
* return pointer to remainder of string |
* keyword and value are allocated and must be free by caller. |
* return NULL if none found |
* Return pointer to remainder of string, |
|
* return NULL if none found. |
*/ | */ |
char KeyStr[STRSIZE]; |
|
char ValStr[STRSIZE]; |
|
#if NeedFunctionPrototypes | #if NeedFunctionPrototypes |
char *GetKeyStr(char *str, KeyWord *kw ) | char *GetKeyStr(char *str, KeyWord *kw ) |
#else | #else |
|
|
KeyWord *kw; | KeyWord *kw; |
#endif | #endif |
{ | { |
char *s, *k, *v, t; |
char *s, *start; |
|
char save_char, quote_char; |
if ( !str ) | if ( !str ) |
return( NULL ); | return( NULL ); |
for (s = str; *s == ' '; s++) | for (s = str; *s == ' '; s++) |
; /* skip over blanks */ | ; /* skip over blanks */ |
if (*s == '\0') | if (*s == '\0') |
return( NULL ); | return( NULL ); |
for (k = KeyStr; /* extract keyword portion */ |
start = s++; /* start of keyword */ |
*s != ' ' && *s != '\0' && *s != '='; |
while ( *s != ' ' && *s != '\0' && *s != '=' ) /* locate end */ |
*k++ = *s++) |
s++; |
; |
save_char = *s; |
*k = '\0'; |
*s = '\0'; |
kw->Key = KeyStr; |
kw->Key = xstrdup(start); |
kw->Val = v = NULL; |
kw->Val = NULL; |
kw->vt = None; | kw->vt = None; |
for ( ; *s == ' '; s++) |
if ( save_char == '\0' ) /* shortcut when we're at the end */ |
; /* skip over blanks */ |
return (s); |
if ( *s != '=' ) /* look for "=" */ |
*s = save_char; /* restore keyword end char */ |
|
while ( *s == ' ' ) s++ ; /* skip over blanks */ |
|
if ( *s != '=' ) /* no "=" means no value */ |
return( s ); | return( s ); |
for (s++; *s == ' '; s++); /* skip over blanks */ |
for (s++; *s == ' '; s++) |
if ( *s == '\'' || *s == '\"' ) /* get string delimiter */ |
; /* skip over blanks */ |
t = *s++; |
if ( *s == '\'' || *s == '\"' ) /* get string delimiter */ |
|
quote_char = *s++; |
else | else |
t = ' '; |
quote_char = ' '; |
for (v = ValStr; /* copy value portion up to delim */ |
start = s; /* no increment, might be "" as value */ |
*s != t && *s != '\0'; |
while ( *s != quote_char && *s != '\0' ) |
*v++ = *s++) |
s++; /* locate end of value portion */ |
; |
save_char = *s; |
if ( t != ' ' && *s == t ) |
*s = '\0'; |
s++; |
kw->Val = xstrdup(start); |
*v = '\0'; |
|
kw->Val = ValStr; |
|
kw->vt = String; | kw->vt = String; |
|
if ( save_char != '\0' ) { /* save_char is now quote_char */ |
|
*s = save_char; |
|
if ( quote_char != ' ' ) /* we had real quote chars */ |
|
s++; |
|
} |
return( s ); | return( s ); |
} | } |
| |
|
|
#endif | #endif |
{ | { |
char *x, *y; | char *x, *y; |
|
|
for (x = a, y = b; *a; a++, b++) | for (x = a, y = b; *a; a++, b++) |
if ( tolower(*a) != tolower(*b) ) | if ( tolower(*a) != tolower(*b) ) |
return( _FALSE ); | return( _FALSE ); |
|
|
* process for simplicity always horizontally | * process for simplicity always horizontally |
*/ | */ |
| |
/* |
/* |
fprintf(ERR_STREAM,"large box: w=%d,x=%d,y=%d\n",(int)yy,(int)xx,0); | fprintf(ERR_STREAM,"large box: w=%d,x=%d,y=%d\n",(int)yy,(int)xx,0); |
*/ | */ |
|
|
hor_offset = HOR_HALF(30); | hor_offset = HOR_HALF(30); |
MoveHor(hor_offset); | MoveHor(hor_offset); |
vert_offset = VERT_HALF(30); | vert_offset = VERT_HALF(30); |
|
|
yy += (long4)pgsiz_dots - (long4)last_ry; | yy += (long4)pgsiz_dots - (long4)last_ry; |
| |
if ((yy>0) && (xx>0)) | if ((yy>0) && (xx>0)) |
EMIT4("\033*p-%ldY\033*c%lda%ldbP", |
EMIT4("\033*p-%ldY\033*c%lda%ldbP", |
(long)yy - 1, (long)xx, (long)yy); | (long)yy - 1, (long)xx, (long)yy); |
#endif | #endif |
last_rx = last_ry = UNKNOWN; /* next time full positioning */ | last_rx = last_ry = UNKNOWN; /* next time full positioning */ |
|
|
if ((fid = pixel_files[least_used].pixel_file_id) != NO_FILE) { | if ((fid = pixel_files[least_used].pixel_file_id) != NO_FILE) { |
/* mark file as being closed in the entry */ | /* mark file as being closed in the entry */ |
fp = hfontptr; | fp = hfontptr; |
while (fp != NULL && fp->font_file_id != fid) |
while (fp != NULL && fp->font_file_id != fid) |
fp = fp->next; | fp = fp->next; |
if (fp == NULL) | if (fp == NULL) |
Fatal("Open file %x not found in font entry list.\n", fid); | Fatal("Open file %x not found in font entry list.\n", fid); |
|
|
while ((fp != NULL) && (fp->font_file_id != f)) | while ((fp != NULL) && (fp->font_file_id != f)) |
fp = fp->next; | fp = fp->next; |
| |
if (fp == NULL) |
if (fp == NULL) |
Fatal("Open file %x not found in font entry list.\n",f); | Fatal("Open file %x not found in font entry list.\n",f); |
else |
else |
fp->font_file_id = FPNULL; | fp->font_file_id = FPNULL; |
} | } |
BCLOSE(f); | BCLOSE(f); |
|
|
the resident fonts. */ | the resident fonts. */ |
if (tfm_read_info(fontptr->n, &tfm_info) | if (tfm_read_info(fontptr->n, &tfm_info) |
&& tfm_info.family[0] | && tfm_info.family[0] |
&& strcmp((char *)tfm_info.family, "HPAUTOTFM") == 0) { |
&& EQ((char *)tfm_info.family, "HPAUTOTFM")) { |
unsigned i; | unsigned i; |
double factor = fontptr->s / (double)0x100000; | double factor = fontptr->s / (double)0x100000; |
| |
resident_count++; | resident_count++; |
fontptr->resident_p = _TRUE; | fontptr->resident_p = _TRUE; |
strcpy(fontptr->symbol_set, (char *)tfm_info.coding_scheme); |
strncpy(fontptr->symbol_set, (char *)tfm_info.coding_scheme, 39); |
|
fontptr->symbol_set[39] = '\0'; |
fontptr->resid = tfm_info.typeface_id; | fontptr->resid = tfm_info.typeface_id; |
fontptr->spacing = tfm_info.spacing; | fontptr->spacing = tfm_info.spacing; |
fontptr->style = tfm_info.style; | fontptr->style = tfm_info.style; |
|
|
fontptr->resident_p = _FALSE; | fontptr->resident_p = _FALSE; |
| |
if (tfm_info.family[0] | if (tfm_info.family[0] |
&& strcmp((char *)tfm_info.family, "UNSPECIFIED") == 0) { |
&& EQ((char *)tfm_info.family, "UNSPECIFIED")) { |
Warning("font family for %s is UNSPECIFIED; need to run dvicopy?", | Warning("font family for %s is UNSPECIFIED; need to run dvicopy?", |
fontptr->n); | fontptr->n); |
fontptr->font_file_id = NO_FILE; | fontptr->font_file_id = NO_FILE; |
|
|
GetBytes(dvifp, tfontptr->n, tfontptr->a + tfontptr->l); | GetBytes(dvifp, tfontptr->n, tfontptr->a + tfontptr->l); |
tfontptr->n[tfontptr->a+tfontptr->l] = '\0'; | tfontptr->n[tfontptr->a+tfontptr->l] = '\0'; |
| |
tfontptr->font_mag = |
tfontptr->font_mag = |
(long4)((ActualFactor((long4)(1000.0*tfontptr->s/(double)tfontptr->d+0.5)) | (long4)((ActualFactor((long4)(1000.0*tfontptr->s/(double)tfontptr->d+0.5)) |
* ActualFactor(mag) | * ActualFactor(mag) |
#ifdef USEPXL | #ifdef USEPXL |
|
|
if (tfontptr->resident_p) | if (tfontptr->resident_p) |
return; | return; |
| |
if (!(resident_font_located)) { |
if (!(resident_font_located)) |
#endif | #endif |
| |
#ifdef KPATHSEA |
|
{ | { |
kpse_glyph_file_type font_ret; | kpse_glyph_file_type font_ret; |
char *name; | char *name; |
|
|
= kpse_magstep_fix ((unsigned) (tfontptr->font_mag / 5.0 + .5), | = kpse_magstep_fix ((unsigned) (tfontptr->font_mag / 5.0 + .5), |
RESOLUTION, NULL); | RESOLUTION, NULL); |
tfontptr->font_mag = dpi * 5; /* save correct dpi */ | tfontptr->font_mag = dpi * 5; /* save correct dpi */ |
|
|
name = kpse_find_pk (tfontptr->n, dpi, &font_ret); | name = kpse_find_pk (tfontptr->n, dpi, &font_ret); |
if (name) | if (name) |
{ | { |
font_found = _TRUE; | font_found = _TRUE; |
strcpy (tfontptr->name, name); |
tfontptr->name = name; |
free (name); |
allocated_storage += strlen(name)+1; |
|
|
if (!FILESTRCASEEQ (tfontptr->n, font_ret.name)) { | if (!FILESTRCASEEQ (tfontptr->n, font_ret.name)) { |
fprintf (stderr, | fprintf (stderr, |
"dvilj: Font %s not found, using %s at %d instead.\n", | "dvilj: Font %s not found, using %s at %d instead.\n", |
|
|
tfontptr->n, dpi); | tfontptr->n, dpi); |
} | } |
} | } |
#else /* not KPATHSEA */ |
|
if (!(findfile(PXLpath, |
|
tfontptr->n, |
|
tfontptr->font_mag, |
|
tfontptr->name, |
|
_FALSE, |
|
0))) { |
|
Warning(tfontptr->name); /* contains error messsage */ |
|
tfontptr->font_file_id = NO_FILE; |
|
#ifdef __riscos |
|
MakeMetafontFile(PXLpath, tfontptr->n, tfontptr->font_mag); |
|
#endif |
|
} |
|
else { |
|
font_found = _TRUE; |
|
if (G_verbose) |
|
fprintf(ERR_STREAM,"%d: using font <%s>\n", plusid, tfontptr->name); |
|
} |
|
#endif /* not KPATHSEA */ |
|
|
|
#ifdef LJ_RESIDENT_FONTS |
|
} |
|
#endif |
|
| |
tfontptr->plusid = plusid; | tfontptr->plusid = plusid; |
plusid++; | plusid++; |
|
|
HANDLE_MAX_FONTS); | HANDLE_MAX_FONTS); |
#endif | #endif |
if (tfontptr != pfontptr) { | if (tfontptr != pfontptr) { |
if (font_found) |
if (font_found) |
OpenFontFile(); | OpenFontFile(); |
else | else |
pxlfp = NO_FILE; | pxlfp = NO_FILE; |
|
|
if (t == PK_PRE) { | if (t == PK_PRE) { |
unsigned char temp_byte; | unsigned char temp_byte; |
temp_byte = (unsigned char) NoSignExtend(pxlfp, 1); | temp_byte = (unsigned char) NoSignExtend(pxlfp, 1); |
if (temp_byte != PK_ID) |
if (temp_byte != PK_ID) |
Fatal( "Wrong Version of pk file! (%d should be 89)\n", | Fatal( "Wrong Version of pk file! (%d should be 89)\n", |
(int)temp_byte); | (int)temp_byte); |
else | else |
|
|
| |
tfontptr->magnification = NoSignExtend(pxlfp, 4); | tfontptr->magnification = NoSignExtend(pxlfp, 4); |
tfontptr->designsize = NoSignExtend(pxlfp, 4); | tfontptr->designsize = NoSignExtend(pxlfp, 4); |
|
|
if (tfontptr->id == id1001) | if (tfontptr->id == id1001) |
FSEEK(pxlfp, (long)(NoSignExtend(pxlfp, 4) * 4), SEEK_SET); | FSEEK(pxlfp, (long)(NoSignExtend(pxlfp, 4) * 4), SEEK_SET); |
else | else |
|
|
hppp = NoSignExtend(pxlfp, 4); | hppp = NoSignExtend(pxlfp, 4); |
vppp = NoSignExtend(pxlfp, 4); | vppp = NoSignExtend(pxlfp, 4); |
if (hppp != vppp) | if (hppp != vppp) |
Warning("aspect ratio is %ld:%ld (should be 1:1)!", |
Warning("aspect ratio is %ld:%ld (should be 1:1)!", |
(long)hppp, (long)vppp); | (long)hppp, (long)vppp); |
tfontptr->magnification = (long4)(hppp * 72.27 * 5 / 65536l + 0.5); | tfontptr->magnification = (long4)(hppp * 72.27 * 5 / 65536l + 0.5); |
| |
|
|
{ | { |
int a, l; | int a, l; |
char n[STRSIZE]; | char n[STRSIZE]; |
|
|
(void) NoSignExtend(dvifp, 4); | (void) NoSignExtend(dvifp, 4); |
(void) NoSignExtend(dvifp, 4); | (void) NoSignExtend(dvifp, 4); |
(void) NoSignExtend(dvifp, 4); | (void) NoSignExtend(dvifp, 4); |
|
|
GetBytes(dvifp, n, a + l); | GetBytes(dvifp, n, a + l); |
} | } |
| |
|
|
| |
/*------------------------ end dvifont.c -------------------------------*/ | /*------------------------ end dvifont.c -------------------------------*/ |
| |
|
|
#endif | #endif |
if ( G_nowarn || G_quiet ) | if ( G_nowarn || G_quiet ) |
return; | return; |
|
|
fprintf(ERR_STREAM, "%s: warning: ", G_progname); | fprintf(ERR_STREAM, "%s: warning: ", G_progname); |
vfprintf(ERR_STREAM, fmt, args); | vfprintf(ERR_STREAM, fmt, args); |
fprintf(ERR_STREAM, "\n"); | fprintf(ERR_STREAM, "\n"); |