| |
| |
|
|
| |
| |
| |
|
|
| #include <string.h> |
| |
| #include <ctype.h> |
| #include <stddef.h> |
| #include <stdlib.h> |
| #include "fitsio2.h" |
| |
| int ffuky( fitsfile *fptr, |
| int datatype, |
| const char *keyname, |
| void *value, |
| const char *comm, |
| int *status) |
| |
| |
| |
| |
| { |
| if (*status > 0) |
| return(*status); |
|
|
| if (datatype == TSTRING) |
| { |
| ffukys(fptr, keyname, (char *) value, comm, status); |
| } |
| else if (datatype == TBYTE) |
| { |
| ffukyj(fptr, keyname, (LONGLONG) *(unsigned char *) value, comm, status); |
| } |
| else if (datatype == TSBYTE) |
| { |
| ffukyj(fptr, keyname, (LONGLONG) *(signed char *) value, comm, status); |
| } |
| else if (datatype == TUSHORT) |
| { |
| ffukyj(fptr, keyname, (LONGLONG) *(unsigned short *) value, comm, status); |
| } |
| else if (datatype == TSHORT) |
| { |
| ffukyj(fptr, keyname, (LONGLONG) *(short *) value, comm, status); |
| } |
| else if (datatype == TINT) |
| { |
| ffukyj(fptr, keyname, (LONGLONG) *(int *) value, comm, status); |
| } |
| else if (datatype == TUINT) |
| { |
| ffukyg(fptr, keyname, (double) *(unsigned int *) value, 0, |
| comm, status); |
| } |
| else if (datatype == TLOGICAL) |
| { |
| ffukyl(fptr, keyname, *(int *) value, comm, status); |
| } |
| else if (datatype == TULONG) |
| { |
| ffukyg(fptr, keyname, (double) *(unsigned long *) value, 0, |
| comm, status); |
| } |
| else if (datatype == TLONG) |
| { |
| ffukyj(fptr, keyname, (LONGLONG) *(long *) value, comm, status); |
| } |
| else if (datatype == TLONGLONG) |
| { |
| ffukyj(fptr, keyname, *(LONGLONG *) value, comm, status); |
| } |
| else if (datatype == TFLOAT) |
| { |
| ffukye(fptr, keyname, *(float *) value, -7, comm, status); |
| } |
| else if (datatype == TDOUBLE) |
| { |
| ffukyd(fptr, keyname, *(double *) value, -15, comm, status); |
| } |
| else if (datatype == TCOMPLEX) |
| { |
| ffukyc(fptr, keyname, (float *) value, -7, comm, status); |
| } |
| else if (datatype == TDBLCOMPLEX) |
| { |
| ffukym(fptr, keyname, (double *) value, -15, comm, status); |
| } |
| else |
| *status = BAD_DATATYPE; |
|
|
| return(*status); |
| } |
| |
| int ffukyu(fitsfile *fptr, |
| const char *keyname, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkyu(fptr, keyname, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkyu(fptr, keyname, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffukys(fitsfile *fptr, |
| const char *keyname, |
| const char *value, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkys(fptr, keyname, value, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkys(fptr, keyname, value, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffukls(fitsfile *fptr, |
| const char *keyname, |
| const char *value, |
| const char *comm, |
| int *status) |
| { |
| |
|
|
| int tstatus; |
| char junk[FLEN_ERRMSG]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkls(fptr, keyname, value, comm, status) == KEY_NO_EXIST) |
| { |
| |
| fits_read_errmsg(junk); |
| |
| *status = tstatus; |
| ffpkls(fptr, keyname, value, comm, status); |
| } |
| return(*status); |
| } |
| int ffukyl(fitsfile *fptr, |
| const char *keyname, |
| int value, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkyl(fptr, keyname, value, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkyl(fptr, keyname, value, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffukyj(fitsfile *fptr, |
| const char *keyname, |
| LONGLONG value, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkyj(fptr, keyname, value, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkyj(fptr, keyname, value, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffukyf(fitsfile *fptr, |
| const char *keyname, |
| float value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkyf(fptr, keyname, value, decim, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkyf(fptr, keyname, value, decim, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffukye(fitsfile *fptr, |
| const char *keyname, |
| float value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkye(fptr, keyname, value, decim, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkye(fptr, keyname, value, decim, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffukyg(fitsfile *fptr, |
| const char *keyname, |
| double value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkyg(fptr, keyname, value, decim, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkyg(fptr, keyname, value, decim, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffukyd(fitsfile *fptr, |
| const char *keyname, |
| double value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkyd(fptr, keyname, value, decim, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkyd(fptr, keyname, value, decim, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffukfc(fitsfile *fptr, |
| const char *keyname, |
| float *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkfc(fptr, keyname, value, decim, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkfc(fptr, keyname, value, decim, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffukyc(fitsfile *fptr, |
| const char *keyname, |
| float *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkyc(fptr, keyname, value, decim, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkyc(fptr, keyname, value, decim, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffukfm(fitsfile *fptr, |
| const char *keyname, |
| double *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkfm(fptr, keyname, value, decim, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkfm(fptr, keyname, value, decim, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffukym(fitsfile *fptr, |
| const char *keyname, |
| double *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmkym(fptr, keyname, value, decim, comm, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffpkym(fptr, keyname, value, decim, comm, status); |
| } |
| return(*status); |
| } |
| |
| int ffucrd(fitsfile *fptr, |
| const char *keyname, |
| const char *card, |
| int *status) |
| { |
| int tstatus; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| tstatus = *status; |
|
|
| if (ffmcrd(fptr, keyname, card, status) == KEY_NO_EXIST) |
| { |
| *status = tstatus; |
| ffprec(fptr, card, status); |
| } |
| return(*status); |
| } |
| |
| int ffmrec(fitsfile *fptr, |
| int nkey, |
| const char *card, |
| int *status) |
| { |
| if (*status > 0) |
| return(*status); |
|
|
| ffmaky(fptr, nkey+1, status); |
| ffmkey(fptr, card, status); |
| return(*status); |
| } |
| |
| int ffmcrd(fitsfile *fptr, |
| const char *keyname, |
| const char *card, |
| int *status) |
| { |
| char tcard[FLEN_CARD], valstring[FLEN_CARD], comm[FLEN_CARD], value[FLEN_CARD]; |
| char nextcomm[FLEN_COMMENT]; |
| int keypos, len; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgcrd(fptr, keyname, tcard, status) > 0) |
| return(*status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| |
| keypos = (int) ((((fptr->Fptr)->nextkey) - ((fptr->Fptr)->headstart[(fptr->Fptr)->curhdu])) / 80) + 1; |
|
|
| ffpsvc(tcard, valstring, comm, status); |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| |
| ffpmrk(); |
| ffc2s(valstring, value, status); |
|
|
| if (*status == VALUE_UNDEFINED) { |
| ffcmrk(); |
| *status = 0; |
| } else { |
| |
| len = strlen(value); |
|
|
| while (len && value[len - 1] == '&') |
| { |
| ffgcnt(fptr, value, nextcomm, status); |
| if (*value) |
| { |
| ffdrec(fptr, keypos, status); |
| len = strlen(value); |
| } |
| else |
| len = 0; |
| } |
| } |
|
|
| return(*status); |
| } |
| |
| int ffmnam(fitsfile *fptr, |
| const char *oldname, |
| const char *newname, |
| int *status) |
| { |
| char comm[FLEN_COMMENT]; |
| char value[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
| |
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, oldname, value, comm, status) > 0) |
| return(*status); |
|
|
| ffmkky(newname, value, comm, card, status); |
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmcom(fitsfile *fptr, |
| const char *keyname, |
| const char *comm, |
| int *status) |
| { |
| char oldcomm[FLEN_COMMENT]; |
| char value[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
| |
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, value, oldcomm, status) > 0) |
| return(*status); |
|
|
| ffmkky(keyname, value, comm, card, status); |
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffpunt(fitsfile *fptr, |
| const char *keyname, |
| const char *unit, |
| int *status) |
| |
| |
| |
| |
| |
| |
| |
| { |
| char oldcomm[FLEN_COMMENT]; |
| char newcomm[FLEN_COMMENT]; |
| char value[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
| char *loc; |
| size_t len; |
| |
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, value, oldcomm, status) > 0) |
| return(*status); |
|
|
| |
| if (*unit) |
| { |
| strcpy(newcomm, "["); |
| strncat(newcomm, unit, 45); |
| strcat(newcomm, "] "); |
| len = strlen(newcomm); |
| len = FLEN_COMMENT - len - 1; |
| } |
| else |
| { |
| newcomm[0] = '\0'; |
| len = FLEN_COMMENT - 1; |
| } |
|
|
| if (oldcomm[0] == '[') |
| { |
| loc = strchr(oldcomm, ']'); |
| if (loc) |
| { |
| loc++; |
| while (*loc == ' ') |
| loc++; |
|
|
| strncat(newcomm, loc, len); |
| } |
| else |
| { |
| strncat(newcomm, oldcomm, len); |
| } |
| } |
| else |
| { |
| strncat(newcomm, oldcomm, len); |
| } |
|
|
| ffmkky(keyname, value, newcomm, card, status); |
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmkyu(fitsfile *fptr, |
| const char *keyname, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) |
| return(*status); |
|
|
| strcpy(valstring," "); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmkys(fitsfile *fptr, |
| const char *keyname, |
| const char *value, |
| const char *comm, |
| int *status) |
| { |
| |
| |
| |
|
|
| char oldval[FLEN_VALUE], valstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD], nextcomm[FLEN_COMMENT]; |
| int len, keypos; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, oldval, oldcomm, status) > 0) |
| return(*status); |
|
|
| ffs2c(value, valstring, status); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| keypos = (int) (((((fptr->Fptr)->nextkey) - ((fptr->Fptr)->headstart[(fptr->Fptr)->curhdu])) / 80) + 1); |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| |
| ffpmrk(); |
| ffc2s(oldval, valstring, status); |
|
|
| if (*status == VALUE_UNDEFINED) { |
| ffcmrk(); |
| *status = 0; |
| } else { |
| |
| len = strlen(valstring); |
|
|
| while (len && valstring[len - 1] == '&') |
| { |
| ffgcnt(fptr, valstring, nextcomm, status); |
| if (*valstring) |
| { |
| ffdrec(fptr, keypos, status); |
| len = strlen(valstring); |
| } |
| else |
| len = 0; |
| } |
| } |
|
|
| return(*status); |
| } |
| |
| int ffmkls( fitsfile *fptr, |
| const char *keyname, |
| const char *value, |
| const char *incomm, |
| int *status) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| { |
| char valstring[FLEN_VALUE]; |
| char card[FLEN_CARD], tmpkeyname[FLEN_CARD]; |
| char comm[FLEN_COMMENT]; |
| char tstring[FLEN_VALUE], *cptr; |
| char *longval; |
| int next, remain, vlen, nquote, nchar, namelen, contin, tstatus = -1; |
| int nkeys, keypos; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (!incomm || incomm[0] == '&') |
| { |
| ffghps(fptr, &nkeys, &keypos, status); |
|
|
| if (ffgkls(fptr, keyname, &longval, comm, status) > 0) |
| return(*status); |
|
|
| free(longval); |
|
|
| |
| |
| |
| ffgrec(fptr, keypos - 1, card, status); |
| } else { |
| |
| strncpy(comm, incomm, FLEN_COMMENT-1); |
| comm[FLEN_COMMENT-1] = '\0'; |
| } |
|
|
| |
| if (ffdkey(fptr, keyname, status) > 0) |
| return(*status); |
|
|
| ffghps(fptr, &nkeys, &keypos, status); |
|
|
| |
| remain = strlen(value); |
| next = 0; |
| |
| |
| nquote = 0; |
| cptr = strchr(value, '\''); |
|
|
| while (cptr) |
| { |
| nquote++; |
| cptr++; |
| cptr = strchr(cptr, '\''); |
| } |
|
|
| strncpy(tmpkeyname, keyname, 80); |
| tmpkeyname[80] = '\0'; |
| |
| cptr = tmpkeyname; |
| while(*cptr == ' ') |
| cptr++; |
|
|
| |
| |
|
|
| namelen = strlen(cptr); |
| if (namelen <= 8 && (fftkey(cptr, &tstatus) <= 0) ) |
| { |
| |
| nchar = 68 - nquote; |
| } |
| else |
| { |
| nchar = 80 - nquote - namelen - 5; |
| } |
|
|
| contin = 0; |
| while (remain > 0) |
| { |
| if (nchar > FLEN_VALUE-1) |
| { |
| ffpmsg("longstr keyword value is too long (ffmkls)"); |
| return (*status=BAD_KEYCHAR); |
| } |
| strncpy(tstring, &value[next], nchar); |
| tstring[nchar] = '\0'; |
| ffs2c(tstring, valstring, status); |
|
|
| if (remain > nchar) |
| { |
| vlen = strlen(valstring); |
| nchar -= 1; |
|
|
| if (valstring[vlen-2] != '\'') |
| valstring[vlen-2] = '&'; |
| else |
| { |
| valstring[vlen-3] = '&'; |
| valstring[vlen-1] = '\0'; |
| } |
| } |
|
|
| if (contin) |
| { |
| ffmkky("CONTINUE", valstring, comm, card, status); |
| strncpy(&card[8], " ", 2); |
| } |
| else |
| { |
| ffmkky(keyname, valstring, comm, card, status); |
| } |
|
|
| ffirec(fptr, keypos, card, status); |
| |
| keypos++; |
| contin = 1; |
| remain -= nchar; |
| next += nchar; |
| nchar = 68 - nquote; |
| } |
| return(*status); |
| } |
| |
| int ffmkyl(fitsfile *fptr, |
| const char *keyname, |
| int value, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) |
| return(*status); |
|
|
| ffl2c(value, valstring, status); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmkyj(fitsfile *fptr, |
| const char *keyname, |
| LONGLONG value, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) |
| return(*status); |
|
|
| ffi2c(value, valstring, status); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmkyf(fitsfile *fptr, |
| const char *keyname, |
| float value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) |
| return(*status); |
|
|
| ffr2f(value, decim, valstring, status); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmkye(fitsfile *fptr, |
| const char *keyname, |
| float value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) |
| return(*status); |
|
|
| ffr2e(value, decim, valstring, status); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmkyg(fitsfile *fptr, |
| const char *keyname, |
| double value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) |
| return(*status); |
|
|
| ffd2f(value, decim, valstring, status); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmkyd(fitsfile *fptr, |
| const char *keyname, |
| double value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) |
| return(*status); |
|
|
| ffd2e(value, decim, valstring, status); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmkfc(fitsfile *fptr, |
| const char *keyname, |
| float *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE], tmpstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) |
| return(*status); |
|
|
| strcpy(valstring, "(" ); |
| ffr2f(value[0], decim, tmpstring, status); |
| if (strlen(tmpstring)+3 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffmkfc)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ", "); |
| ffr2f(value[1], decim, tmpstring, status); |
| if (strlen(valstring) + strlen(tmpstring)+1 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffmkfc)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ")"); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmkyc(fitsfile *fptr, |
| const char *keyname, |
| float *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE], tmpstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) |
| return(*status); |
|
|
| strcpy(valstring, "(" ); |
| ffr2e(value[0], decim, tmpstring, status); |
| if (strlen(tmpstring)+3 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffmkyc)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ", "); |
| ffr2e(value[1], decim, tmpstring, status); |
| if (strlen(valstring) + strlen(tmpstring)+1 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffmkyc)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ")"); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmkfm(fitsfile *fptr, |
| const char *keyname, |
| double *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE], tmpstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) |
| return(*status); |
|
|
| strcpy(valstring, "(" ); |
| ffd2f(value[0], decim, tmpstring, status); |
| if (strlen(tmpstring)+3 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffmkfm)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ", "); |
| ffd2f(value[1], decim, tmpstring, status); |
| if (strlen(valstring) + strlen(tmpstring)+1 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffmkfm)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ")"); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffmkym(fitsfile *fptr, |
| const char *keyname, |
| double *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE], tmpstring[FLEN_VALUE]; |
| char oldcomm[FLEN_COMMENT]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, oldcomm, status) > 0) |
| return(*status); |
|
|
| strcpy(valstring, "(" ); |
| ffd2e(value[0], decim, tmpstring, status); |
| if (strlen(tmpstring)+3 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffmkym)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ", "); |
| ffd2e(value[1], decim, tmpstring, status); |
| if (strlen(valstring) + strlen(tmpstring)+1 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffmkym)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ")"); |
|
|
| if (!comm || comm[0] == '&') |
| ffmkky(keyname, valstring, oldcomm, card, status); |
| else |
| ffmkky(keyname, valstring, comm, card, status); |
|
|
| ffmkey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikyu(fitsfile *fptr, |
| const char *keyname, |
| const char *comm, |
| int *status) |
| |
| |
| |
| { |
| char valstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| strcpy(valstring," "); |
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikys(fitsfile *fptr, |
| const char *keyname, |
| const char *value, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| ffs2c(value, valstring, status); |
|
|
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikls( fitsfile *fptr, |
| const char *keyname, |
| const char *value, |
| const char *comm, |
| int *status) |
| |
| |
| |
| |
| |
| |
| |
| |
| { |
| char valstring[FLEN_VALUE]; |
| char card[FLEN_CARD], tmpkeyname[FLEN_CARD]; |
| char tstring[FLEN_VALUE], *cptr; |
| int next, remain, vlen, nquote, nchar, namelen, contin, tstatus = -1; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| |
| remain = strlen(value); |
| next = 0; |
| |
| |
| nquote = 0; |
| cptr = strchr(value, '\''); |
|
|
| while (cptr) |
| { |
| nquote++; |
| cptr++; |
| cptr = strchr(cptr, '\''); |
| } |
|
|
|
|
| strncpy(tmpkeyname, keyname, 80); |
| tmpkeyname[80] = '\0'; |
| |
| cptr = tmpkeyname; |
| while(*cptr == ' ') |
| cptr++; |
|
|
| |
| |
|
|
| namelen = strlen(cptr); |
| if (namelen <= 8 && (fftkey(cptr, &tstatus) <= 0) ) |
| { |
| |
| nchar = 68 - nquote; |
| } |
| else |
| { |
| nchar = 80 - nquote - namelen - 5; |
| } |
|
|
| contin = 0; |
| while (remain > 0) |
| { |
| if (nchar > FLEN_VALUE-1) |
| { |
| ffpmsg("longstr keyword value is too long (ffikls)"); |
| return (*status=BAD_KEYCHAR); |
| } |
| strncpy(tstring, &value[next], nchar); |
| tstring[nchar] = '\0'; |
| ffs2c(tstring, valstring, status); |
|
|
| if (remain > nchar) |
| { |
| vlen = strlen(valstring); |
| nchar -= 1; |
|
|
| if (valstring[vlen-2] != '\'') |
| valstring[vlen-2] = '&'; |
| else |
| { |
| valstring[vlen-3] = '&'; |
| valstring[vlen-1] = '\0'; |
| } |
| } |
|
|
| if (contin) |
| { |
| ffmkky("CONTINUE", valstring, comm, card, status); |
| strncpy(&card[8], " ", 2); |
| } |
| else |
| { |
| ffmkky(keyname, valstring, comm, card, status); |
| } |
|
|
| ffikey(fptr, card, status); |
| |
| contin = 1; |
| remain -= nchar; |
| next += nchar; |
| nchar = 68 - nquote; |
| } |
| return(*status); |
| } |
| |
| int ffikyl(fitsfile *fptr, |
| const char *keyname, |
| int value, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| ffl2c(value, valstring, status); |
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikyj(fitsfile *fptr, |
| const char *keyname, |
| LONGLONG value, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| ffi2c(value, valstring, status); |
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikyf(fitsfile *fptr, |
| const char *keyname, |
| float value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| ffr2f(value, decim, valstring, status); |
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikye(fitsfile *fptr, |
| const char *keyname, |
| float value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| ffr2e(value, decim, valstring, status); |
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikyg(fitsfile *fptr, |
| const char *keyname, |
| double value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| ffd2f(value, decim, valstring, status); |
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikyd(fitsfile *fptr, |
| const char *keyname, |
| double value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| ffd2e(value, decim, valstring, status); |
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikfc(fitsfile *fptr, |
| const char *keyname, |
| float *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE], tmpstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| strcpy(valstring, "(" ); |
| ffr2f(value[0], decim, tmpstring, status); |
| if (strlen(tmpstring)+3 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffikfc)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ", "); |
| ffr2f(value[1], decim, tmpstring, status); |
| if (strlen(valstring) + strlen(tmpstring)+1 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffikfc)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ")"); |
|
|
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikyc(fitsfile *fptr, |
| const char *keyname, |
| float *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE], tmpstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| strcpy(valstring, "(" ); |
| ffr2e(value[0], decim, tmpstring, status); |
| if (strlen(tmpstring)+3 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffikyc)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ", "); |
| ffr2e(value[1], decim, tmpstring, status); |
| if (strlen(valstring) + strlen(tmpstring)+1 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffikyc)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ")"); |
|
|
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikfm(fitsfile *fptr, |
| const char *keyname, |
| double *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE], tmpstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
|
|
| strcpy(valstring, "(" ); |
| ffd2f(value[0], decim, tmpstring, status); |
| if (strlen(tmpstring)+3 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffikfm)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ", "); |
| ffd2f(value[1], decim, tmpstring, status); |
| if (strlen(valstring) + strlen(tmpstring)+1 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffikfm)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ")"); |
|
|
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikym(fitsfile *fptr, |
| const char *keyname, |
| double *value, |
| int decim, |
| const char *comm, |
| int *status) |
| { |
| char valstring[FLEN_VALUE], tmpstring[FLEN_VALUE]; |
| char card[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| strcpy(valstring, "(" ); |
| ffd2e(value[0], decim, tmpstring, status); |
| if (strlen(tmpstring)+3 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffikym)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ", "); |
| ffd2e(value[1], decim, tmpstring, status); |
| if (strlen(valstring) + strlen(tmpstring)+1 > FLEN_VALUE-1) |
| { |
| ffpmsg("complex key value too long (ffikym)"); |
| return(*status=BAD_F2C); |
| } |
| strcat(valstring, tmpstring); |
| strcat(valstring, ")"); |
|
|
| ffmkky(keyname, valstring, comm, card, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffirec(fitsfile *fptr, |
| int nkey, |
| const char *card, |
| int *status) |
| { |
| if (*status > 0) |
| return(*status); |
|
|
| ffmaky(fptr, nkey, status); |
| ffikey(fptr, card, status); |
|
|
| return(*status); |
| } |
| |
| int ffikey(fitsfile *fptr, |
| const char *card, |
| int *status) |
| |
| |
| |
| { |
| int ii, len, nshift, keylength; |
| long nblocks; |
| LONGLONG bytepos; |
| char *inbuff, *outbuff, *tmpbuff, buff1[FLEN_CARD], buff2[FLEN_CARD]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| |
| if (fptr->HDUposition != (fptr->Fptr)->curhdu) |
| ffmahd(fptr, (fptr->HDUposition) + 1, NULL, status); |
|
|
| if ( ((fptr->Fptr)->datastart - (fptr->Fptr)->headend) == 80) |
| { |
| nblocks = 1; |
| if (ffiblk(fptr, nblocks, 0, status) > 0) |
| return(*status); |
| } |
|
|
| |
| nshift= (int) (( (fptr->Fptr)->headend - (fptr->Fptr)->nextkey ) / 80); |
|
|
| strncpy(buff2, card, 80); |
| buff2[80] = '\0'; |
|
|
| len = strlen(buff2); |
|
|
| |
| for (ii=0; ii < len; ii++) |
| if (buff2[ii] < ' ' || buff2[ii] > 126) buff2[ii] = ' '; |
|
|
| for (ii=len; ii < 80; ii++) |
| buff2[ii] = ' '; |
|
|
| keylength = strcspn(buff2, "="); |
| if (keylength == 80) keylength = 8; |
| |
| |
| if ( !fits_strncasecmp( "COMMENT ", buff2, 8) || !fits_strncasecmp( "HISTORY ", buff2, 8) || |
| !fits_strncasecmp( " ", buff2, 8) || !fits_strncasecmp( "CONTINUE", buff2, 8) ) |
| keylength = 8; |
|
|
| for (ii=0; ii < keylength; ii++) |
| buff2[ii] = toupper(buff2[ii]); |
|
|
| fftkey(buff2, status); |
|
|
| |
| |
|
|
| inbuff = buff1; |
| outbuff = buff2; |
|
|
| bytepos = (fptr->Fptr)->nextkey; |
| ffmbyt(fptr, bytepos, REPORT_EOF, status); |
|
|
| for (ii = 0; ii < nshift; ii++) |
| { |
| ffgbyt(fptr, 80, inbuff, status); |
|
|
| ffmbyt(fptr, bytepos, REPORT_EOF, status); |
| ffpbyt(fptr, 80, outbuff, status); |
|
|
| tmpbuff = inbuff; |
| inbuff = outbuff; |
| outbuff = tmpbuff; |
|
|
| bytepos += 80; |
| } |
|
|
| ffpbyt(fptr, 80, outbuff, status); |
|
|
| (fptr->Fptr)->headend += 80; |
| (fptr->Fptr)->nextkey += 80; |
|
|
| return(*status); |
| } |
| |
| int ffdkey(fitsfile *fptr, |
| const char *keyname, |
| int *status) |
| |
| |
| |
| { |
| int keypos, len; |
| char valstring[FLEN_VALUE], comm[FLEN_COMMENT], value[FLEN_VALUE]; |
| char message[FLEN_ERRMSG], nextcomm[FLEN_COMMENT]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgkey(fptr, keyname, valstring, comm, status) > 0) |
| { |
| snprintf(message, FLEN_ERRMSG,"Could not find the %s keyword to delete (ffdkey)", |
| keyname); |
| ffpmsg(message); |
| return(*status); |
| } |
|
|
| |
| keypos = (int) ((((fptr->Fptr)->nextkey) - ((fptr->Fptr)->headstart[(fptr->Fptr)->curhdu])) / 80); |
|
|
| ffdrec(fptr, keypos, status); |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| |
| ffpmrk(); |
| ffc2s(valstring, value, status); |
|
|
| if (*status == VALUE_UNDEFINED) { |
| ffcmrk(); |
| *status = 0; |
| } else { |
| |
| len = strlen(value); |
|
|
| while (len && value[len - 1] == '&') |
| { |
| ffgcnt(fptr, value, nextcomm, status); |
| if (*value) |
| { |
| ffdrec(fptr, keypos, status); |
| len = strlen(value); |
| } |
| else |
| len = 0; |
| } |
| } |
|
|
| return(*status); |
| } |
| |
| int ffdstr(fitsfile *fptr, |
| const char *string, |
| int *status) |
| |
| |
| |
| { |
| int keypos, len; |
| char valstring[FLEN_VALUE], comm[FLEN_COMMENT], value[FLEN_VALUE]; |
| char card[FLEN_CARD], message[FLEN_ERRMSG], nextcomm[FLEN_COMMENT]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| if (ffgstr(fptr, string, card, status) > 0) |
| { |
| snprintf(message, FLEN_ERRMSG,"Could not find the %s keyword to delete (ffdkey)", |
| string); |
| ffpmsg(message); |
| return(*status); |
| } |
|
|
| |
| keypos = (int) ((((fptr->Fptr)->nextkey) - ((fptr->Fptr)->headstart[(fptr->Fptr)->curhdu])) / 80); |
|
|
| ffdrec(fptr, keypos, status); |
|
|
| |
| ffpsvc(card, valstring, comm, status); |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| |
| ffpmrk(); |
| ffc2s(valstring, value, status); |
|
|
| if (*status == VALUE_UNDEFINED) { |
| ffcmrk(); |
| *status = 0; |
| } else { |
| |
| len = strlen(value); |
|
|
| while (len && value[len - 1] == '&') |
| { |
| ffgcnt(fptr, value, nextcomm, status); |
| if (*value) |
| { |
| ffdrec(fptr, keypos, status); |
| len = strlen(value); |
| } |
| else |
| len = 0; |
| } |
| } |
|
|
| return(*status); |
| } |
| int ffdrec(fitsfile *fptr, |
| int keypos, |
| int *status) |
| |
| |
| |
| { |
| int ii, nshift; |
| LONGLONG bytepos; |
| char *inbuff, *outbuff, *tmpbuff, buff1[81], buff2[81]; |
| char message[FLEN_ERRMSG]; |
|
|
| if (*status > 0) |
| return(*status); |
|
|
| |
| if (fptr->HDUposition != (fptr->Fptr)->curhdu) |
| ffmahd(fptr, (fptr->HDUposition) + 1, NULL, status); |
|
|
| if (keypos < 1 || |
| keypos > (fptr->Fptr)->headend - (fptr->Fptr)->headstart[(fptr->Fptr)->curhdu] / 80 ) |
| return(*status = KEY_OUT_BOUNDS); |
|
|
| (fptr->Fptr)->nextkey = (fptr->Fptr)->headstart[(fptr->Fptr)->curhdu] + (keypos - 1) * 80; |
|
|
| nshift=(int) (( (fptr->Fptr)->headend - (fptr->Fptr)->nextkey ) / 80); |
|
|
| if (nshift <= 0) |
| { |
| snprintf(message, FLEN_ERRMSG,"Cannot delete keyword number %d. It does not exist.", |
| keypos); |
| ffpmsg(message); |
| return(*status = KEY_OUT_BOUNDS); |
| } |
|
|
| bytepos = (fptr->Fptr)->headend - 80; |
|
|
| |
| strcpy(buff2, " "); |
| strcat(buff2, " "); |
| inbuff = buff1; |
| outbuff = buff2; |
| for (ii = 0; ii < nshift; ii++) |
| { |
|
|
| ffmbyt(fptr, bytepos, REPORT_EOF, status); |
| ffgbyt(fptr, 80, inbuff, status); |
|
|
| ffmbyt(fptr, bytepos, REPORT_EOF, status); |
| ffpbyt(fptr, 80, outbuff, status); |
|
|
| tmpbuff = inbuff; |
| inbuff = outbuff; |
| outbuff = tmpbuff; |
|
|
| bytepos -= 80; |
| } |
|
|
| (fptr->Fptr)->headend -= 80; |
| return(*status); |
| } |
|
|
|
|