char *BuildSumInput (AsnInfo *asn, int prod, int posid) { int nchars; int acssum_len; int i; char *acssum_input; char tmpexp[CHAR_LINE_LENGTH]; char tmpflt[CHAR_LINE_LENGTH]; int MkName (char *, char *, char *, char *, char *, int); /* Determine how long this string needs to be... */ /*nchars = asn->spmems[posid] * CHAR_FNAME_LENGTH; */ nchars = 1; /* Keep track of individual filename lengths and total length*/ acssum_len = 0; /* Now, lets search the association table for all inputs... */ for (i=1; i <= asn->spmems[posid]; i++) { strcpy(tmpexp, asn->product[prod].subprod[posid].exp[i].expname); if (MkName (tmpexp, "_raw", "_flt", "", tmpflt, CHAR_LINE_LENGTH)) { strcpy (tmpflt,asn->product[prod].subprod[posid].exp[i].name); strcat (tmpflt, "_flt.fits"); } /* Sum together lengths of all filenames to be used as input to ACSSUM. */ acssum_len += strlen(tmpflt)+1; } /* Now that we know how long it will be, allocate space for input string. */ acssum_input = (char *) calloc(acssum_len + 1, sizeof(char)); /* Go back through the association table to string all inputs together... */ for (i=1; i <= asn->spmems[posid]; i++) { strcpy(tmpexp, asn->product[prod].subprod[posid].exp[i].expname); if (MkName (tmpexp, "_raw", "_flt", "", tmpflt, CHAR_LINE_LENGTH)) { strcpy (tmpflt,asn->product[prod].subprod[posid].exp[i].name); strcat (tmpflt, "_flt.fits"); } strcat(acssum_input, tmpflt); if (i < (asn->spmems[posid])) { /* Don't add a comma to the end of the last filename */ strcat(acssum_input, ","); } } strcat(acssum_input,"\0"); return(acssum_input); }
/* Construct output and temporary file names from outroot. Note that we do not construct the wavecal (_wav) file name. This is because it is either given on the command line or is gotten as the value of the WAVECAL keyword. */ int InsertACSSuffix (ACSInfo *acs) { extern int status; int MkName (char *, char *, char *, char *, char *, int); if (MkName (acs->crj_root, "_crj", "_crj", "", acs->crjfile, CHAR_LINE_LENGTH)) return (status); if (MkName (acs->crj_root, "_crj", "_crj_tmp", "", acs->crj_tmp, CHAR_LINE_LENGTH)) return (status); if (MkName (acs->rootname, "_raw", "_flt", "", acs->fltfile, CHAR_LINE_LENGTH)) return (status); if (MkName (acs->crj_root, "_crj", "_crc", "", acs->crcfile, CHAR_LINE_LENGTH)) return (status); if (MkName (acs->crj_root, "_crj", "_crc_tmp", "", acs->crc_tmp, CHAR_LINE_LENGTH)) return (status); if (MkName (acs->rootname, "_raw", "_flc", "", acs->flcfile, CHAR_LINE_LENGTH)) return (status); if (MkName (acs->asn_table, "_raw", "_dth", "", acs->dthfile, CHAR_LINE_LENGTH)) return (status); if (MkName (acs->rootname, "_raw", "_blv_tmp", "", acs->blv_tmp, CHAR_LINE_LENGTH)) return (status); if (MkName (acs->rootname, "_raw", "_blc_tmp", "", acs->blc_tmp, CHAR_LINE_LENGTH)) return (status); /*sprintf (MsgText,"AcsInit: blv_tmp = %s ",acs->blv_tmp); trlmessage (MsgText); */ return (status); }
int GetAsnTable (AsnInfo *asn) { /* Arguments: ** asn o: Association info structure */ extern int status; /* Local variables */ int i; /* loop index */ int nrows; /* number of rows in ASNTAB */ int col, row; /* loop indexes */ IRAFPointer tp; /* ASNTAB table pointer */ IRAFPointer colptr[NCOLS]; /* ASNTAB column pointers */ int numsp; /* number of sub-products in asn */ int posid; /* id of sub-product */ RowInfo *exp; /* Internal structure for table information */ int *spmems, *expmem; /* number of EXP for each sub-product */ int poslen; /* Length of memtype string minus POSID */ int prodid; /* id of product */ int expid; int defid; /* default position id for exposures */ int procprod; int maxspmems; /* max number of sub-product members */ char *word; Bool proddth; char spname_ext[SZ_CBUF+1]; /* Extension for sub-product */ char spname_ext_cte[SZ_CBUF+1]; /* Extension for sub-product */ char memtype[SZ_COLNAME+1]; char memsubtype[SZ_COLNAME+1]; /* ASNTAB column names */ char colname[NCOLS][SZ_COLNAME+1] = { "MEMNAME", "MEMTYPE", "MEMPRSNT" }; /* Function definitions */ void freeAsnInfo (AsnInfo *); int allocAsnInfo (AsnInfo *, int, int *); void trlopenerr (char *); void trlwarn (char *); char *lowcase (char *, char *); int MkName (char *, char *, char *, char *, char *, int); void initRowInfo (RowInfo *); int streq_ic (char *, char *); /* strings equal? (case insensitive) */ if (asn->debug) { sprintf (MsgText, "GetAsnTable: ASN_TABLE is %s",asn->asn_table); trlmessage (MsgText); } /* Open the ASN table */ tp = c_tbtopn (asn->asn_table, IRAF_READ_ONLY, 0); if (c_iraferr()) { trlopenerr (asn->asn_table); return (status = TABLE_ERROR); } /* Get pointers to columns in ASNTAB */ for (col=0; col < NCOLS; col++) { c_tbcfnd1 (tp, colname[col], &(colptr[col])); if (c_iraferr() || colptr[col] == 0) { sprintf (MsgText, "Can't find column %s in %s", colname[col], asn->asn_table); trlerror (MsgText); c_tbtclo (tp); return (status = COLUMN_NOT_FOUND); } } /* Find out how many rows are in ASNTAB */ nrows = 0; nrows = c_tbpsta (tp, TBL_NROWS); if (nrows <= 0) { sprintf (MsgText, "Invalid number of rows in %s", asn->asn_table); trlerror (MsgText); c_tbtclo (tp); return (status = TABLE_ERROR); } /* Initialize total number of members based on number of ** rows in table */ asn->numasn = nrows; poslen = 0; /* Allocate space for internal variables */ exp = NULL; exp = (RowInfo *)calloc(nrows, sizeof(RowInfo)); for (row = 0; row < nrows; row++) initRowInfo (&(exp[row])); /* Read each row of ASNTAB into a local structure */ for (row = 0; row < nrows; row++) { /* Get the MEMBER NAME in this row */ c_tbegtt (tp, colptr[0], row+1, exp[row].memname, SZ_CBUF); if (c_iraferr()) { sprintf (MsgText, "Can't read %s in row %d in %s", colname[0], row+1, asn->asn_table); trlerror (MsgText); c_tbtclo (tp); free (exp); return (status = ELEMENT_NOT_FOUND); } /* Convert to lowercase for use as a file name */ for (i = 0; i < strlen(exp[row].memname); i++) exp[row].memname[i] = tolower(exp[row].memname[i]); /* Get the TYPE in this row */ c_tbegtt (tp, colptr[1], row+1, exp[row].mtype, SZ_CBUF); if (c_iraferr()) { sprintf (MsgText, "Can't read %s in row %d in %s", colname[1], row+1, asn->asn_table); trlerror (MsgText); c_tbtclo (tp); free (exp); return (status = ELEMENT_NOT_FOUND); } /* Convert to lowercase for use later in routine. ** Also, if a value of MEMTYPE contains a UNDERLINE, then ** record conversion to DASH in trailer file and warn ** user to correct the value. */ lowcase (exp[row].type, exp[row].mtype); for (i = 0; i < strlen(exp[row].type); i++) { if (exp[row].type[i] == UNDERLINE_CHAR) { exp[row].type[i] = DASH_CHAR; sprintf(MsgText, "MEMTYPE %s in row %d was INVALID and needs to be corrected.", exp[row].mtype, row+1); trlwarn(MsgText); } } /* Get the STATUS in this row */ c_tbegtb (tp, colptr[2], row+1, &(exp[row].prsnt)); if (c_iraferr()) { sprintf (MsgText, "Can't read %s in row %d in %s", colname[2], row+1, asn->asn_table); trlerror (MsgText); c_tbtclo (tp); free (exp); return (status = ELEMENT_NOT_FOUND); } if (asn->debug) { sprintf (MsgText, "GetAsnTable: Read in row %d from ASN table", row); trlmessage (MsgText); } } /* ** Determine whether CRCORR or RPTOBS processing will be required ** by searching for MEMTYPE of EXP_CR* or EXP_RPT*, respectively. ** Once it is determined, go on to next step... */ for (row = 0; row < nrows; row++) { /* Check to see if we need to do CR-SPLIT combination ... */ if (strstr (exp[row].type, "-cr") != NULL) { asn->crcorr = PERFORM; asn->rptcorr = OMIT; poslen = CRLEN; break; /* ... or REPEAT-OBS combination ... */ } else if (strstr (exp[row].type, "-rp") != NULL) { asn->rptcorr = PERFORM; asn->crcorr = OMIT; poslen = RPTLEN; break; /* ... or neither at all */ } else { asn->rptcorr = OMIT; asn->crcorr = OMIT; poslen = DTHLEN; } } /* Default to always perform DRIZCORR step */ asn->dthcorr = PERFORM; if (asn->debug) { sprintf (MsgText, "GetAsnTable: CRCORR = %d, RPTCORR = %d", asn->crcorr,asn->rptcorr); trlmessage (MsgText); } /* Sort through the list figuring out which are input vs. output ** files, and see if any input files are missing. */ /* Initialize local variables */ numsp = 0; posid = 0; prodid = 0; proddth = False; defid = 1; /* Find out how many products/sub-products are in the association ** and determine the posid for each member. */ for (row = 0; row < nrows; row++) { memtype[0] = '\0'; memsubtype[0] = '\0'; /* As long as this is not the final product, ** count number of members in each product/sub-product...*/ if (strstr(exp[row].type,"prod-dth") != NULL) { exp[row].posid = 0; posid = 0; /* If we have a dither product listed, we want to eventually ** perform dither combining step... */ prodid++; proddth = True; /* We always want to produce a product, but if ** not set to PERFORM, then create an empty product... */ if (asn->dthcorr == OMIT) asn->dthcorr = DUMMY; } else { strcpy(memtype,exp[row].type); /* Let's start by breaking up the MEMTYPE string */ word = strtok(memtype,"-"); strcpy(memsubtype,word); /* The end of this second part of MEMTYPE has the POSID */ word = strtok(NULL,"\n"); /* If the last character of the memtype is a number or letter, ** convert to an integer value... */ if (streq_ic(word,"crj") || streq_ic(word,"rpt") || streq_ic(word,"crc") ) { posid = 1; } else { if (exp[row].prsnt || streq_ic(memsubtype,"prod")) { if (isalnum(word[poslen])) { /* Interpret the POSID from the second part ** of MEMTYPE */ posid=(int)strtol(&word[poslen],(char **)NULL,10); } else { /* Otherwise, assume it is a different pointing ** and assign an incremented position ID. After ** all, it is NOT a CR-SPLIT or RPT-OBS exposure.*/ posid = defid; defid++; } } } /* Keep track of how many sub-products there are based on ** POSID from MEMTYPE values */ if (posid > numsp) { if ((exp[row].prsnt && (strstr(memtype,"exp") != NULL)) || strstr(memtype,"prod") != NULL) { numsp++; } } exp[row].posid = posid; } if (asn->debug) { sprintf (MsgText, "GetAsnTable: Posid = %d for row %d",posid, row); trlmessage (MsgText); } /* If the member is missing, give a warning */ /* This implies that MEMPRSNT must be set to YES for EXP_* ** This is not fatal for WF3. Simply decrement tmembers. */ if (!exp[row].prsnt && strncmp(exp[row].type, "prod-",5) != 0) { sprintf (MsgText, "Member \"%s\" is not present", exp[row].memname); trlwarn (MsgText); asn->numasn--; /* Now flag row as being absent so it doesn't get passed ** along for further processing... */ exp[row].posid = MEMABSENT; } } if (asn->debug) { sprintf (MsgText, "GetAsnTable: NUMSP = %d, PRODID = %d",numsp, prodid); trlmessage (MsgText); } /* Check for existence of enough data to process */ if (asn->numasn < 1) { trlerror ("No data available for given assoc. table"); freeAsnInfo (asn); return (status = ERROR_RETURN); } /* Record the number of products found in association */ if (proddth) { asn->numprod = prodid; } else { /* If there are no PROD-DTH entries in ASN table, set ** numprod to 1 */ asn->numprod = prodid + 1; } /* Determine what elements should be processed based on ** initial input, either FULL or PARTIAL processing. */ procprod = 0; if (asn->process != FULL) { for (row=0; row < nrows; row++){ /* Look for entry with same name as input */ if (streq_ic(exp[row].memname, asn->rootname)) { /* We only want to process this product */ procprod = exp[row].posid; numsp = 1; } } } /* Allocate space to count number of exposures per sub-product ** with spmems[0] being reserved for final output product ** since POSID starts indexing at 1. */ spmems = (int *)calloc(numsp+1,sizeof(int)); expmem = (int *)calloc(numsp+1,sizeof(int)); /* Initialize arrays */ for (i=0; i <= numsp; i++) { spmems[i] = 0; expmem[i] = 0; } /* For each sub-product, ** identify each EXP that belongs to that posid and ** is present to be processed. */ for (row=0; row < nrows; row++) { if (strstr(exp[row].type, "exp-") && exp[row].posid > MEMABSENT) { if ((asn->process != FULL && exp[row].posid == procprod) || asn->process == FULL) { spmems[exp[row].posid]++; /* Exposure IDs will start at 1 to be consistent ** with POSID numbering. Initialize here, count later. */ expmem[exp[row].posid] = 1; } } } /* Allocate slots for all members in ASN info structure */ if (allocAsnInfo (asn, numsp, spmems)) { return (status = TABLE_ERROR); } asn->product[prodid].prodid = prodid; /* Reset prodid for filling ASN table */ prodid = 0; /* Copy summary information about ASN relationships to ASN structure. */ maxspmems = 0; asn->numsp = numsp; for (i=0; i <= numsp; i++) { asn->spmems[i] = spmems[i]; if (spmems[i] > maxspmems) maxspmems = spmems[i]; } /* If there aren't any sub-products with more than 1 member, then ** omit crcorr/rptcorr processing */ if ((maxspmems < 2) && asn->crcorr == PERFORM) { sprintf (MsgText, "No sub-product with more than 1 member; CRCORR will be skipped"); trlwarn (MsgText); asn->crcorr = DUMMY; } else if ((maxspmems < 2) && asn->rptcorr == PERFORM) { sprintf (MsgText, "No sub-product with more than 1 member; RPTCORR will be skipped"); trlwarn (MsgText); asn->rptcorr = DUMMY; } /* Copy information read-in into ASN structure now... */ for (row = 0; row < nrows; row++) { if (exp[row].posid != MEMABSENT) { if ((asn->process != FULL && exp[row].posid == procprod) || asn->process == FULL) { posid = exp[row].posid; /* Is this row the final product entry? */ if (strstr(exp[row].type, "prod-dth") != NULL) { strcpy (asn->product[prodid].name, exp[row].memname); strcpy (asn->product[prodid].mtype, exp[row].type); asn->product[prodid].prsnt = exp[row].prsnt; asn->product[prodid].numsp = numsp; asn->product[prodid].asnrow = row+1; /* Create full file name for this image */ if (MkName (exp[row].memname, "_raw", "_drz", "", asn->product[prodid].prodname, SZ_LINE)){ strcpy(asn->product[prodid].prodname, exp[row].memname); strcat (asn->product[prodid].prodname, "_drz.fits"); } /* Create full file name for this CTE image */ if (MkName (exp[row].memname, "_rac_tmp", "_drc", "", asn->product[prodid].prodname_cte, SZ_LINE)){ strcpy(asn->product[prodid].prodname_cte, exp[row].memname); strcat (asn->product[prodid].prodname_cte, "_drc.fits"); } /* Or, is this row an input exposure? */ } else if (strstr(exp[row].type, "exp-") != NULL) { if (exp[row].posid > MEMABSENT) { /* Internal counter for which exposure we want for ** a position */ expid = expmem[posid]; strcpy(asn->product[prodid].subprod[posid].exp[expid].name, exp[row].memname); strcpy(asn->product[prodid].subprod[posid].exp[expid].mtype, exp[row].type); asn->product[prodid].subprod[posid].exp[expid].prsnt = exp[row].prsnt; asn->product[prodid].subprod[posid].exp[expid].asnrow= row+1; /* Create full file name for this image */ if (MkName (exp[row].memname, "_raw", "_raw", "", asn->product[prodid].subprod[posid].exp[expid].expname, SZ_LINE)) { strcpy(asn->product[prodid].subprod[posid].exp[expid].expname, exp[row].memname); strcat(asn->product[prodid].subprod[posid].exp[expid].expname, "_raw.fits"); } /* Fill-in sub-product information for EXP-DTH ** exposures which don't create sub-products */ if (strstr(exp[row].type, "exp-dth") != NULL) { if (!MkName (exp[row].memname, "_raw", "_flt", "", asn->product[prodid].subprod[posid].spname, SZ_LINE) ) { strcpy(asn->product[prodid].subprod[posid].name, exp[row].memname); strcpy(asn->product[prodid].subprod[posid].mtype, exp[row].type); asn->product[prodid].subprod[posid].posid = exp[row].posid; } } /* Increment that counter for next exposure's id ** for this posid */ expmem[posid]++; } /* If neither, it must be a sub-product */ } else { if (spmems[posid] > 0) { strcpy(asn->product[prodid].subprod[posid].name, exp[row].memname); strcpy(asn->product[prodid].subprod[posid].mtype, exp[row].type); asn->product[prodid].subprod[posid].prsnt = exp[row].prsnt; asn->product[prodid].subprod[posid].asnrow = row+1; /* Create full file name for this image for ** DTHCORR input */ spname_ext[0] = '\0'; spname_ext_cte[0] = '\0'; if (asn->crcorr || asn->rptcorr) { strcpy (spname_ext, "_crj"); strcpy (spname_ext_cte,"_crc"); } else { strcpy (spname_ext, "_sfl"); strcpy (spname_ext_cte, "_sfl"); } if (MkName (exp[row].memname, "_raw", spname_ext, "", asn->product[prodid].subprod[posid].spname, SZ_LINE)) { strcpy(asn->product[prodid].subprod[posid].spname, exp[row].memname); strcat(asn->product[prodid].subprod[posid].spname, spname_ext); strcat(asn->product[prodid].subprod[posid].spname, ".fits"); } if (MkName (exp[row].memname, "_raw", spname_ext_cte, "", asn->product[prodid].subprod[posid].spname_cte, SZ_LINE)) { strcpy(asn->product[prodid].subprod[posid].spname_cte, exp[row].memname); strcat(asn->product[prodid].subprod[posid].spname_cte, spname_ext_cte); strcat(asn->product[prodid].subprod[posid].spname_cte, ".fits"); } asn->product[prodid].subprod[posid].numexp = spmems[posid]; asn->product[prodid].subprod[posid].posid = posid; } } } } /* Process only those exposures where MEMPRSNT == YES */ } /* Close the ASN table. We are done reading it in. */ c_tbtclo (tp); /* Clean up memory usage as well. */ free (spmems); free (expmem); free (exp); if (asn->debug) { trlmessage ("GetAsnTable: Info from ASN read into memory."); } /* Successful return */ return (status); }
int main (int argc, char **argv) { char *inlist; /* input file name */ char *outlist; /* output blev file name */ /*int switch_on = 0;*/ /* was any switch specified? */ int printtime = NO; /* print time after each step? */ int verbose = NO; /* print additional info? */ int quiet = NO; /* print additional info? */ int too_many = 0; /* too many command-line arguments? */ int i, j; /* loop indexes */ int k; IRAFPointer i_imt, o_imt; /* imt list pointers */ char *input; /* name of input science file */ char *output; /* name of output file */ int n_in, n_out; /* number of files in each list */ int n; /* Input and output suffixes. */ char isuffix[] = "_raw"; char osuffix[] = "_blv_tmp"; /* A structure to pass the calibration switches to ACSCCD */ CalSwitch ccd_sw; /* reference file keywords and names */ RefFileInfo refnames; void InitRefFile (RefFileInfo *); void FreeRefFile (RefFileInfo *); void initSwitch (CalSwitch *); int ACSccd (char *, char *, CalSwitch *, RefFileInfo *, int, int); int DefSwitch (char *); int MkName (char *, char *, char *, char *, char *, int); void WhichError (int); int CompareNumbers (int, int, char *); /* For image header access */ Hdr phdr; int LoadHdr (char *, Hdr *); int GetSwitch (Hdr *, char *, int *); c_irafinit (argc, argv); /* Allocate space for file names. */ inlist = calloc (ACS_LINE+1, sizeof (char)); outlist = calloc (ACS_LINE+1, sizeof (char)); input = calloc (ACS_LINE+1, sizeof (char)); output = calloc (ACS_LINE+1, sizeof (char)); if (inlist == NULL || outlist == NULL || input == NULL || output == NULL) { printf ("Can't even begin; out of memory.\n"); exit (ERROR_RETURN); } inlist[0] = '\0'; outlist[0] = '\0'; input[0] = '\0'; output[0] = '\0'; /* Initialize the lists of reference file keywords and names. */ InitRefFile (&refnames); /* Initial values. */ initSwitch (&ccd_sw); for (i = 1; i < argc; i++) { /********** if (strcmp (argv[i], "-dqi") == 0) { ccd_sw.dqicorr = PERFORM; switch_on = 1; } else if (strcmp (argv[i], "-atod") == 0) { ccd_sw.atodcorr = PERFORM; switch_on = 1; } else if (strcmp (argv[i], "-blev") == 0) { ccd_sw.blevcorr = PERFORM; switch_on = 1; } else if (strcmp (argv[i], "-bias") == 0) { ccd_sw.biascorr = PERFORM; switch_on = 1; } else if (argv[i][0] == '-') { **********/ if (argv[i][0] == '-') { for (j = 1; argv[i][j] != '\0'; j++) { if (argv[i][j] == 't') { printtime = YES; } else if (argv[i][j] == 'v') { verbose = YES; } else if (argv[i][j] == 'q') { quiet = YES; } else { printf (MsgText, "Unrecognized option %s\n", argv[i]); FreeNames (inlist, outlist, input, output); exit (1); } } } else if (inlist[0] == '\0') { strcpy (inlist, argv[i]); } else if (outlist[0] == '\0') { strcpy (outlist, argv[i]); } else { too_many = 1; } } if (inlist[0] == '\0' || too_many) { printf ("syntax: acsccd [-t] [-v] [-q] input output\n"); /* printf (" command-line switches:\n"); printf (" -dqi -atod -blev -bias\n"); */ FreeNames (inlist, outlist, input, output); exit (ERROR_RETURN); } /* Initialize the structure for managing trailer file comments */ InitTrlBuf (); /* Copy command-line value for QUIET to structure */ SetTrlQuietMode(quiet); /* Was no calibration switch specified on command line? default values (mostly PERFORM) except ATODCORR if (!switch_on) {*/ ccd_sw.dqicorr = DefSwitch ("dqicorr"); ccd_sw.atodcorr = DefSwitch ("atodcorr"); ccd_sw.blevcorr = DefSwitch ("blevcorr"); ccd_sw.biascorr = DefSwitch ("biascorr"); /*}*/ /* Expand the templates. */ i_imt = c_imtopen (inlist); o_imt = c_imtopen (outlist); n_in = c_imtlen (i_imt); n_out = c_imtlen (o_imt); /* The number of input and output files must be the same. */ if (CompareNumbers (n_in, n_out, "output")) status = 1; if (status) { FreeNames (inlist, outlist, input, output); CloseTrlBuf(); exit (ERROR_RETURN); } /* Loop over the list of input files. */ for (n = 0; n < n_in; n++) { k = c_imtgetim (i_imt, input, ACS_LINE); if (n_out > 0) k = c_imtgetim (o_imt, output, ACS_LINE); else output[0] = '\0'; /* Open input image in order to read its primary header. */ if (LoadHdr (input, &phdr)) { WhichError (status); sprintf (MsgText, "Skipping %s", input); trlmessage (MsgText); continue; } /* Determine osuffix. */ strcpy(osuffix, "_blv_tmp"); if (MkName (input, isuffix, osuffix, "", output, ACS_LINE)) { WhichError (status); sprintf (MsgText, "Skipping %s", input); trlmessage (MsgText); continue; } /* Calibrate the current input file. */ if (ACSccd (input, output, &ccd_sw, &refnames, printtime, verbose)) { sprintf (MsgText, "Error processing %s.", input); trlerror (MsgText); WhichError (status); } } /* Close lists of file names, and free name buffers. */ c_imtclose (i_imt); c_imtclose (o_imt); CloseTrlBuf(); FreeRefFile (&refnames); FreeNames (inlist, outlist, input, output); if (status) exit (ERROR_RETURN); else exit (0); }
void PPrintName(const TObject *o) { string name = MkName(o); uint16_t len = name.length(); fwrite(&len, sizeof(len), 1, fout); fwrite(name.data(), len, 1, fout); }
int main (int argc, char **argv) { int status; /* zero is OK */ char *input, *output; /* file names */ int printtime = 0; /* print time after each step? */ int verbose = 0; /* print additional info? */ int too_many = 0; /* too many command-line arguments? */ int i, j; /* loop indexes */ c_irafinit (argc, argv); input = calloc (STIS_LINE+1, sizeof (char)); output = calloc (STIS_LINE+1, sizeof (char)); if (input == NULL || output == NULL) { printf ("ERROR: Can't even begin: out of memory.\n"); exit (ERROR_RETURN); } /* Get names of input and output files. */ for (i = 1; i < argc; i++) { if (argv[i][0] == '-') { if (strcmp (argv[i], "--version") == 0) { PrVersion(); exit (0); } if (!(strcmp(argv[i],"--gitinfo"))) { printGitInfo(); exit(0); } if (!(strcmp(argv[i],"--help"))) { printHelp(); exit(0); } if (strcmp (argv[i], "-r") == 0) { PrFullVersion(); exit (0); } for (j = 1; argv[i][j] != '\0'; j++) { if (argv[i][j] == 't') { printtime = 1; } else if (argv[i][j] == 'v') { verbose = 1; } else { printf ("ERROR: Unrecognized option %s\n", argv[i]); printSyntax(); exit (1); } } } else if (input[0] == '\0') { strcpy (input, argv[i]); } else if (output[0] == '\0') { strcpy (output, argv[i]); } else { too_many = 1; } } if (input[0] == '\0' || too_many) { printSyntax(); exit (ERROR_RETURN); } if (output[0] == '\0') { if ((status = MkName (input, "_x2d", "_sx2", output, STIS_LINE))) exit (status); } /* Sum imsets. */ if ((status = CalStis8 (input, output, printtime, verbose))) { printf ("Error processing %s.\n", input); WhichError (status); } free (input); free (output); if (status) exit (ERROR_RETURN); else exit (0); }