Beispiel #1
0
/*--------------------------------------------------------------------------*/
int ffcopy(fitsfile *infptr,    /* I - FITS file pointer to input file  */
           fitsfile *outfptr,   /* I - FITS file pointer to output file */
           int morekeys,        /* I - reserve space in output header   */
           int *status)         /* IO - error status     */
/*
  copy the CHDU from infptr to the CHDU of outfptr.
  This will also allocate space in the output header for MOREKY keywords
*/
{
    if (*status > 0)
        return(*status);

    if (infptr == outfptr)
        return(*status = SAME_FILE);

    if (ffcphd(infptr, outfptr, status) )  /* copy the header keywords */
       return(*status);

    if (morekeys > 0)
      ffhdef(outfptr, morekeys, status); /* reserve space for more keywords */

    ffcpdt(infptr, outfptr, status);  /* now copy the data unit */

    return(*status);
}
/*--------------------------------------------------------------------------*/
int ffcopy(fitsfile *infptr,    /* I - FITS file pointer to input file  */
           fitsfile *outfptr,   /* I - FITS file pointer to output file */
           int morekeys,        /* I - reserve space in output header   */
           int *status)         /* IO - error status     */
/*
  copy the CHDU from infptr to the CHDU of outfptr.
  This will also allocate space in the output header for MOREKY keywords
*/
{
    int nspace;
    
    if (*status > 0)
        return(*status);

    if (infptr == outfptr)
        return(*status = SAME_FILE);

    if (ffcphd(infptr, outfptr, status) )  /* copy the header keywords */
       return(*status);

    if (morekeys > 0) {
      ffhdef(outfptr, morekeys, status); /* reserve space for more keywords */

    } else {
        if (ffghsp(infptr, NULL, &nspace, status) > 0) /* get existing space */
            return(*status);

        if (nspace > 0) {
            ffhdef(outfptr, nspace, status); /* preserve same amount of space */
            if (nspace >= 35) {  

	        /* There is at least 1 full empty FITS block in the header. */
	        /* Physically write the END keyword at the beginning of the */
	        /* last block to preserve this extra space now rather than */
		/* later.  This is needed by the stream: driver which cannot */
		/* seek back to the header to write the END keyword later. */

	        ffwend(outfptr, status);
            }
        }
    }

    ffcpdt(infptr, outfptr, status);  /* now copy the data unit */

    return(*status);
}