/*--------------------------------------------------------------------------*/ int ffmkyd(fitsfile *fptr, /* I - FITS file pointer */ char *keyname, /* I - keyword name */ double value, /* I - keyword value */ int decim, /* I - no of decimals */ char *comm, /* I - keyword comment */ int *status) /* IO - error status */ { char valstring[FLEN_VALUE]; char oldcomm[FLEN_COMMENT]; char card[FLEN_CARD]; if (*status > 0) /* inherit input status value if > 0 */ return(*status); if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) return(*status); /* get old comment */ ffd2e(value, decim, valstring, status); /* convert value to a string */ if (comm[0] == '&') /* preserve the current comment string */ ffmkky(keyname, valstring, oldcomm, card); else ffmkky(keyname, valstring, comm, card); ffmkey(fptr, card, status); return(*status); }
void FSGKEY_U (fitsfile **fptr, short sppkey[], short sppvalue[], short sppcomm[], int *status) { strpak (sppkey, c_keyword, FLEN_KEYWORD); ffgkey (*fptr, c_keyword, c_value, c_comment, status); if (*status == 0) { strupk (c_value, sppvalue, FLEN_VALUE); strupk (c_comment, sppcomm, FLEN_COMMENT); } }
/*--------------------------------------------------------------------------*/ int ffmkys(fitsfile *fptr, /* I - FITS file pointer */ char *keyname, /* I - keyword name */ char *value, /* I - keyword value */ char *comm, /* I - keyword comment */ int *status) /* IO - error status */ { /* NOTE: This routine does not support long continued strings */ char oldval[FLEN_VALUE],valstring[FLEN_VALUE]; char oldcomm[FLEN_COMMENT]; char card[FLEN_CARD]; int len, keypos; if (*status > 0) /* inherit input status value if > 0 */ return(*status); if (ffgkey(fptr, keyname, oldval, oldcomm, status) > 0) return(*status); /* get old comment */ ffs2c(value, valstring, status); /* convert value to a string */ if (comm[0] == '&') /* preserve the current comment string */ ffmkky(keyname, valstring, oldcomm, card); else ffmkky(keyname, valstring, comm, card); ffmkey(fptr, card, status); /* overwrite the previous keyword */ keypos = (((fptr->nextkey) - (fptr->headstart[fptr->curhdu])) / 80) + 1; /* check if old string value was continued over multiple keywords */ ffc2s(oldval, valstring, status); /* remove quotes and trailing spaces */ len = strlen(valstring); while (valstring[len - 1] == '&') /* ampersand is continuation char */ { ffgcnt(fptr, valstring, status); if (valstring) { ffdrec(fptr, keypos, status); /* delete the continuation */ len = strlen(valstring); } else /* a null valstring indicates no continuation */ len = 1; } return(*status); }
/*--------------------------------------------------------------------------*/ int ffdkey(fitsfile *fptr, /* I - FITS file pointer */ char *keyname, /* I - keyword name */ int *status) /* IO - error status */ /* delete a specified header keyword */ { int keypos, len; char valstring[FLEN_VALUE], comm[FLEN_COMMENT], value[FLEN_VALUE]; char message[FLEN_ERRMSG]; if (*status > 0) /* inherit input status value if > 0 */ return(*status); if (ffgkey(fptr, keyname, valstring, comm, status) > 0) /* read keyword */ { sprintf(message, "Could not find the %s keyword to delete (ffdkey)", keyname); ffpmsg(message); return(*status); } /* calc position of keyword in header */ keypos = ((fptr->nextkey) - (fptr->headstart[fptr->curhdu])) / 80; ffdrec(fptr, keypos, status); /* delete the keyword */ /* check for string value which may be continued over multiple keywords */ ffc2s(valstring, value, status); /* remove quotes and trailing spaces */ len = strlen(value); while (value[len - 1] == '&') /* ampersand used as continuation char */ { ffgcnt(fptr, value, status); if (value) { ffdrec(fptr, keypos, status); /* delete the keyword */ len = strlen(value); } else /* a null valstring indicates no continuation */ len = 1; } return(*status); }
/*--------------------------------------------------------------------------*/ int ffmcom(fitsfile *fptr, /* I - FITS file pointer */ char *keyname, /* I - keyword name */ char *comm, /* I - keyword comment */ int *status) /* IO - error status */ { char oldcomm[FLEN_COMMENT]; char value[FLEN_VALUE]; char card[FLEN_CARD]; if (*status > 0) /* inherit input status value if > 0 */ return(*status); if (ffgkey(fptr, keyname, value, oldcomm, status) > 0) return(*status); ffmkky(keyname, value, comm, card); /* construct the card */ ffmkey(fptr, card, status); /* rewrite with new name */ return(*status); }