--- ray/src/meta/meta2tga.c 2003/10/27 10:28:59 1.4 +++ ray/src/meta/meta2tga.c 2019/11/18 22:12:32 1.8 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: meta2tga.c,v 1.4 2003/10/27 10:28:59 schorsch Exp $"; +static const char RCSid[] = "$Id: meta2tga.c,v 1.8 2019/11/18 22:12:32 greg Exp $"; #endif /* * Program to convert meta-files to Targa 8-bit color-mapped format @@ -13,7 +13,7 @@ static const char RCSid[] = "$Id: meta2tga.c,v 1.4 200 #include "rast.h" #include "targa.h" -#define MAXALLOC 5000 +#define MAXALLOC 100000 #define DXSIZE 400 /* default x resolution */ #define DYSIZE 400 /* default y resolution */ #define XCOM "pexpand +vOCImsp -DP %s | psort +y" @@ -23,7 +23,7 @@ char *progname; SCANBLOCK outblock; -int dxsize = DXSIZE, dysize = DYSIZE; +int dxsiz = DXSIZE, dysiz = DYSIZE; int maxalloc = MAXALLOC; @@ -39,6 +39,10 @@ static int lineno = 0; static short condonly = FALSE, conditioned = FALSE; +static int putthead(struct hdStruct *hp, char *ip, FILE *fp); + + + char * findtack(s) /* find place to tack on suffix */ register char *s; @@ -49,11 +53,12 @@ register char *s; } -main(argc, argv) +int +main( + int argc, + char **argv +) -int argc; -char **argv; - { FILE *fp; char comargs[200], command[300]; @@ -78,11 +83,11 @@ char **argv; argc--; break; case 'x': - dxsize = atoi(*++argv); + dxsiz = atoi(*++argv); argc--; break; case 'y': - dysize = atoi(*++argv); + dysiz = atoi(*++argv); argc--; break; case 'o': @@ -137,18 +142,16 @@ char **argv; - - - -thispage() /* rewind current file */ +void +thispage(void) /* rewind current file */ { if (lineno) error(USER, "cannot restart page in thispage"); } - -initfile() /* initialize this file */ +void +initfile(void) /* initialize this file */ { static int filenum = 0; /* @@ -173,8 +176,8 @@ initfile() /* initialize this file */ thead.CMapBits = 24; thead.XOffset = 0; thead.YOffset = 0; - thead.x = dxsize; - thead.y = dysize; + thead.x = dxsiz; + thead.y = dysiz; thead.dataBits = 8; thead.imType = 0; putthead(&thead, NULL, fout); @@ -186,15 +189,15 @@ initfile() /* initialize this file */ +void +nextpage(void) /* advance to next page */ -nextpage() /* advance to next page */ - { if (lineno == 0) return; if (fout != NULL) { - while (lineno < dysize) { + while (lineno < dysiz) { nextblock(); outputblock(); } @@ -209,17 +212,17 @@ nextpage() /* advance to next page */ #define MINRUN 4 +extern void +printblock(void) /* output scanline block to file */ -printblock() /* output scanline block to file */ - { int i, c2; register unsigned char *scanline; - register int j, beg, cnt; + register int j, beg, cnt = 0; if (lineno == 0) initfile(); - for (i = outblock.ybot; i <= outblock.ytop && i < dysize; i++) { + for (i = outblock.ybot; i <= outblock.ytop && i < dysiz; i++) { scanline = outblock.cols[i-outblock.ybot]; for (j = outblock.xleft; j <= outblock.xright; j += cnt) { for (beg = j; beg <= outblock.xright; beg += cnt) { @@ -247,19 +250,23 @@ printblock() /* output scanline block to file */ } -putint2(i, fp) /* put a 2-byte positive integer */ -register int i; -register FILE *fp; +void +putint2( /* put a 2-byte positive integer */ + register int i, + register FILE *fp +) { putc(i&0xff, fp); putc(i>>8&0xff, fp); } -putthead(hp, ip, fp) /* write header to output */ -struct hdStruct *hp; -char *ip; -register FILE *fp; +int +putthead( /* write header to output */ + struct hdStruct *hp, + char *ip, + register FILE *fp +) { if (ip != NULL) putc(strlen(ip), fp);