--- ray/src/hd/rhcopy.c 1999/01/09 09:16:31 3.12 +++ ray/src/hd/rhcopy.c 2003/07/27 22:12:02 3.19 @@ -1,23 +1,19 @@ -/* Copyright (c) 1999 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: rhcopy.c,v 3.19 2003/07/27 22:12:02 schorsch Exp $"; #endif - /* * Copy data into a holodeck file */ #include "holo.h" #include "view.h" -#include "resolu.h" #ifndef BKBSIZE #define BKBSIZE 256 /* beam clump size (kilobytes) */ #endif -int checkdepth = 1; /* check depth (!-f option)? */ -int checkrepeats = 0; /* check for repeats (-c option)? */ +int checkdepth = 1; /* check depth (!-d option)? */ +int checkrepeats = 0; /* check for repeats (-u option)? */ int frompicz; /* input from pictures & depth-buffers? */ int noutsects; /* number of output sections */ char obstr, unobstr; /* flag pointer values */ @@ -95,9 +91,9 @@ int *hf; if (!strncmp(s, "OBSTRUCTIONS=", 13)) { s += 13; while (*s == ' ') s++; - if (*s == 't' | *s == 'T') + if ((*s == 't') | (*s == 'T')) *hf |= H_OBST; - else if (*s == 'f' | *s == 'F') + else if ((*s == 'f') | (*s == 'F')) *hf |= H_OBSF; else error(WARNING, "bad OBSTRUCTIONS value in holodeck"); @@ -111,7 +107,6 @@ openholo(fname, append) /* open existing holodeck fil char *fname; int append; { - extern long ftell(); FILE *fp; int fd; int hflags = 0; @@ -124,7 +119,7 @@ int append; error(SYSTEM, errmsg); } /* check header and magic number */ - if (getheader(fp, holheadline, &hflags) < 0 || + if (getheader(fp, holheadline, (char *)&hflags) < 0 || hflags&H_BADF || getw(fp) != HOLOMAGIC) { sprintf(errmsg, "file \"%s\" not in holodeck format", fname); error(USER, errmsg); @@ -133,7 +128,7 @@ int append; nextloc = ftell(fp); /* get stdio position */ fclose(fp); /* done with stdio */ for (n = 0; nextloc > 0L; n++) { /* initialize each section */ - lseek(fd, nextloc, 0); + lseek(fd, (off_t)nextloc, 0); read(fd, (char *)&nextloc, sizeof(nextloc)); hdinit(fd, NULL)->priv = hflags&H_OBST ? &obstr : hflags&H_OBSF ? &unobstr : (char *)NULL; @@ -199,7 +194,7 @@ static int bpcmp(b1p, b2p) /* compare beam positions on disk */ int *b1p, *b2p; { - register long pdif = beamdir[*b1p].fo - beamdir[*b2p].fo; + register off_t pdif = beamdir[*b1p].fo - beamdir[*b2p].fo; if (pdif > 0L) return(1); if (pdif < 0L) return(-1); @@ -236,7 +231,6 @@ int *bq, nb; } hdfreebeam(hp, bq[i]); /* free the beam */ } - hdflush(NULL); /* write & free clump */ return(0); } @@ -253,6 +247,7 @@ char *hdf; hddone(hdlist[noutsects]); /* free the section */ } close(fd); /* close input file */ + hdflush(NULL); /* flush output */ } @@ -303,7 +298,7 @@ char *pcf, *zbf; int eshft; double emult; RESOLU prs; - FLOAT vl[2]; + RREAL vl[2]; FVECT ro, rd; double aftd; COLOR ctmp; @@ -319,10 +314,10 @@ char *pcf, *zbf; error(SYSTEM, pcf); } /* load picture header */ - copystruct(&phd.vw, &stdview); + phd.vw = stdview; phd.expos = 1.0; phd.badfmt = phd.gotview = phd.altprims = 0; - if (getheader(pfp, picheadline, &phd) < 0 || + if (getheader(pfp, picheadline, (char *)&phd) < 0 || phd.badfmt || !fgetsresolu(&prs, pfp)) { sprintf(errmsg, "bad format for picture file \"%s\"", pcf); error(USER, errmsg); @@ -338,11 +333,11 @@ char *pcf, *zbf; error(WARNING, errmsg); } /* figure out what to do about exposure */ - if (phd.expos < 0.99 | phd.expos > 1.01) { + if ((phd.expos < 0.99) | (phd.expos > 1.01)) { emult = -log(phd.expos)/log(2.); eshft = emult >= 0. ? emult+.5 : emult-.5; emult -= (double)eshft; - if (emult <= 0.01 & emult >= -0.01) + if ((emult <= 0.01) & (emult >= -0.01)) emult = -1.; else { emult = 1./phd.expos; @@ -355,7 +350,7 @@ char *pcf, *zbf; /* allocate buffers */ cscn = (COLR *)malloc(scanlen(&prs)*sizeof(COLR)); zscn = (float *)malloc(scanlen(&prs)*sizeof(float)); - if (cscn == NULL | zscn == NULL) + if ((cscn == NULL) | (zscn == NULL)) error(SYSTEM, "out of memory in addpicz"); /* read and process each scanline */ for (j = 0; j < numscans(&prs); j++) { @@ -390,13 +385,14 @@ char *pcf, *zbf; /* write output and free beams */ hdflush(NULL); /* clean up */ - free((char *)cscn); - free((char *)zscn); + free((void *)cscn); + free((void *)zscn); fclose(pfp); close(zfd); } +void eputs(s) /* put error message to stderr */ register char *s; { @@ -416,6 +412,7 @@ register char *s; } +void quit(code) /* exit the program gracefully */ int code; {