int main(int argc, char **argv){ int i, c, args, hdutype, ncard; int status=0; int mode=1; int x0=1, x1=0, y0=1, y1=0, block=1; long naxes[2]; char *cards=NULL; char regstr[SZ_LINE]; fitsfile *fptr=NULL, *nfptr=NULL; /* we want the args in the same order in which they arrived, and gnu getopt sometimes changes things without this */ putenv("POSIXLY_CORRECT=true"); /* process switch arguments */ while ((c = getopt(argc, argv, "hlms:")) != -1){ switch(c){ case 'h': regdispUsage(argv[0]); break; case 'l': mode = 0; break; case 'm': mode = 1; break; case 's': if( sscanf(optarg, "%d %d %d %d %d", &x0, &x1, &y0, &y1, &block) != 5 ){ xerror(stderr, "for sections: -s 'x0 x1 y0 y1 block'\n"); } break; } } args = argc - optind; if( args <= 0 ){ regdispUsage(argv[0]); } fptr = openFITSFile(argv[optind+0], READONLY, EXTLIST, &hdutype, &status); regcntsErrchk(status); if( (x1 == 0) || (y1 == 0) ){ switch(hdutype){ case IMAGE_HDU: break; default: nfptr = filterTableToImage(fptr, NULL, NULL, NULL, NULL, 1, &status); regcntsErrchk(status); closeFITSFile(fptr, &status); regcntsErrchk(status); fptr = nfptr; break; } fits_get_img_size(fptr, 2, naxes, &status); regcntsErrchk(status); x1 = naxes[0]; y1 = naxes[1]; } getHeaderToString(fptr, &cards, &ncard, &status); regcntsErrchk(status); if( args > 1 ){ for(i=1; i<args; i++){ doreg(cards, argv[optind+i], x0, x1, y0, y1, block, mode); } } else { while( fgets(regstr, SZ_LINE, stdin) ){ doreg(cards, regstr, x0, x1, y0, y1, block, mode); } } closeFITSFile(fptr, &status); regcntsErrchk(status); xfree(cards); return 0; }
int isreg() { if (eqstr(symbol,"_AH")) {doreg("ah"); goto r1;} if (eqstr(symbol,"_AL")) {doreg("al"); goto r1;} if (eqstr(symbol,"_AX")) {doreg("ax"); goto r1;} if (eqstr(symbol,"_BH")) {doreg("bh"); goto r1;} if (eqstr(symbol,"_BL")) {doreg("bl"); goto r1;} if (eqstr(symbol,"_BX")) {doreg("bx"); goto r1;} if (eqstr(symbol,"_CH")) {doreg("ch"); goto r1;} if (eqstr(symbol,"_CL")) {doreg("cl"); goto r1;} if (eqstr(symbol,"_CX")) {doreg("cx"); goto r1;} if (eqstr(symbol,"_DH")) {doreg("dh"); goto r1;} if (eqstr(symbol,"_DL")) {doreg("dl"); goto r1;} if (eqstr(symbol,"_DX")) {doreg("dx"); goto r1;} if (eqstr(symbol,"_FLAGS")) {doreg("flags"); goto r1;} return 0; r1: return 1; }