/* @(#) fitspass.c 1.4 98/07/09 13:40:43 */ /* Copyright (c) 1993 Association of Universities for Research * in Astronomy. All rights reserved. Produced under National * Aeronautics and Space Administration Contract No. NAS5-26555. */ /* fitspass.c Read FITS header from infile and pass it to outfile, * Adds blank lines to make header a multiple of 36 lines. * This may exit with error status if some problem is found. * * Parameters: * FILE *infile input file * int passthru non-zero -> copy header to outfile * FILE *outfile output file * * Programmer: R. White Date: 16 April 1992 */ #include #include #include extern int myread(FILE *infile, char *line, int n); extern void fitspass(FILE *infile, int passthru, FILE *outfile) { char line[80]; int i, j; /* * Note that the SIMPLE line has already been stripped off and written * to outfile for FITS files, so we start at i=1 */ for (i = 1; ; i++) { if (myread(infile, line, 80) != 80) { fprintf(stderr,"FITS header has no END statement\n"); exit(-1); } if (passthru) { if (fwrite(line,1,80,outfile) != 80) { perror("stdout"); fprintf(stderr, "fitspass: error writing output file\n"); exit(-1); } } if (strncmp(line,"END ",4) == 0) break; } /* * write blank lines to make a multiple of 36 lines in header * number of lines written so far is i+1 */ if (passthru) { for (j=0; j<80; j++) line[j]=' '; for (i = 35 - (i % 36); i>0; i--) { if (fwrite(line,1,80,outfile) != 80) { perror("stdout"); fprintf(stderr, "fitspass: error writing output file\n"); exit(-1); } } } }