--- ray/src/meta/meta2tga.c 2003/02/22 02:07:26 1.1 +++ ray/src/meta/meta2tga.c 2003/11/15 02:13:37 1.5 @@ -1,33 +1,24 @@ #ifndef lint -static const char RCSid[] = "$Id: meta2tga.c,v 1.1 2003/02/22 02:07:26 greg Exp $"; +static const char RCSid[] = "$Id: meta2tga.c,v 1.5 2003/11/15 02:13:37 schorsch Exp $"; #endif /* * Program to convert meta-files to Targa 8-bit color-mapped format */ +#include "copyright.h" -#define MAXALLOC 5000 - -#define DXSIZE 400 /* default x resolution */ - -#define DYSIZE 400 /* default y resolution */ - -#define XCOM "pexpand +vOCImsp -DP %s | psort +y" - - - - +#include "rtprocess.h" #include "meta.h" - #include "plot.h" - #include "rast.h" - #include "targa.h" +#define MAXALLOC 5000 +#define DXSIZE 400 /* default x resolution */ +#define DYSIZE 400 /* default y resolution */ +#define XCOM "pexpand +vOCImsp -DP %s | psort +y" - char *progname; SCANBLOCK outblock; @@ -48,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; @@ -58,43 +53,31 @@ register char *s; } -main(argc, argv) +int +main( + int argc, + char **argv +) -int argc; -char **argv; - { FILE *fp; -#ifdef UNIX - FILE *popen(); -#endif char comargs[200], command[300]; -#ifdef CPM - fixargs("meta2tga", &argc, &argv); -#endif - fout = stdout; progname = *argv++; argc--; condonly = FALSE; -#ifdef CPM - conditioned = TRUE; -#else conditioned = FALSE; -#endif while (argc && **argv == '-') { switch (*(*argv+1)) { -#ifdef UNIX case 'c': condonly = TRUE; break; case 'r': conditioned = TRUE; break; -#endif case 'm': minwidth = atoi(*++argv); argc--; @@ -142,7 +125,6 @@ char **argv; argc--; } sprintf(command, XCOM, comargs); -#ifdef UNIX if (condonly) return(system(command)); else { @@ -153,7 +135,6 @@ char **argv; if (lineno) nextpage(); } -#endif } return(0); @@ -161,22 +142,24 @@ 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; + /* static unsigned char cmap[24] = {255,255,255, 255,152,0, 0,188,0, 0,0,255, 179,179,0, 255,0,255, 0,200,200, 0,0,0}; + */ + static unsigned char cmap[24] = {0,0,0, 0,0,255, 0,188,0, 255,152,0, + 0,200,200, 255,0,255, 179,179,0, 255,255,255}; struct hdStruct thead; register int i; @@ -206,9 +189,9 @@ initfile() /* initialize this file */ +void +nextpage(void) /* advance to next page */ -nextpage() /* advance to next page */ - { if (lineno == 0) @@ -229,13 +212,13 @@ 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(); @@ -267,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);