8#include "tpcclibConfig.h"
23static char *info[] = {
24 "Add isotope to the scan information files (SIF), if they do not contain",
25 "it already. If isotope code is not given by user, then program shows",
26 "the current isotope in SIF.",
28 "Usage: @P [options] filename(s) [isotope code]",
32 " Isotope is set even if it already exists in SIF.",
38 "See also: sifcat, taclist, eframe, tacframe, tacweigh",
40 "Keywords: SIF, isotope, physical decay, image, Analyze",
59int main(
int argc,
char *argv[])
61 int ai, help=0, version=0, verbose=1;
63 int ret, si, ffi=0, fileNr=0, isotope_code=0, forceMode=0;
69 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
70 siffile[0]=isotope_name[0]=(char)0;
72 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
74 cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(!*cptr)
continue;
75 if(strcasecmp(cptr,
"F")==0 || strcasecmp(cptr,
"FORCE")==0) {
76 forceMode=1;
continue;
78 fprintf(stderr,
"Error: invalid option '%s'\n", argv[ai]);
83 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
93 for(; ai<argc; ai++) {
98 if(fileNr<1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
100 if(fileNr>1 && access(argv[ai-1],0)==-1) {
110 printf(
"fileNr := %d\n", fileNr);
112 printf(
"isotope_name := %s\n", isotope_name);
113 printf(
"forceMode := %d\n", forceMode);
122 int old_isotope_code=0;
124 for(ai=ffi, si=0; ai<argc && si<fileNr; ai++) {
125 strlcpy(siffile, argv[ai], FILENAME_MAX); si++;
128 if(verbose>0) fprintf(stdout,
"SIF_filename := %s\n", siffile);
131 ret=
tacRead(&tac, siffile, &status);
134 if(verbose>1) printf(
"ret := %d\n", ret);
138 fprintf(stderr,
"Error: file is not in SIF format.\n");
146 strcpy(old_isotope_name,
isotopeName(old_isotope_code));
150 printf(
"tacNr := %d\n", tac.
tacNr);
151 printf(
"sampleNr := %d\n", tac.
sampleNr);
152 printf(
"old_isotope := %s\n", old_isotope_name);
156 if(isotope_code==old_isotope_code) {
157 if(verbose>0) fprintf(stderr,
"Note: isotope was already correct.\n");
164 fprintf(stdout,
"isotope := %s\n", old_isotope_name);
171 fprintf(stderr,
"Warning: isotope was set already; not changed.\n");
180 printf(
"isotope changed from %s to %s\n",
181 old_isotope_name, isotope_name);
183 fprintf(stderr,
"Error: cannot set isotope.\n");
190 if(verbose>1) printf(
"writing %s\n", siffile);
191 FILE *fp; fp=fopen(siffile,
"w");
193 fprintf(stderr,
"Error: cannot open file for writing.\n");
200 if(verbose>1) printf(
"ret := %d\n", ret);
203 if(verbose>0) printf(
"modified %s saved.\n", siffile);
char * isotopeName(int isotope_code)
int isotopeIdentify(const char *isotope)
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
int tpcHtmlUsage(const char *program, char *text[], const char *path)
void tpcPrintBuild(const char *program, FILE *fp)
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
void statusInit(TPCSTATUS *s)
char * errorMsg(tpcerror e)
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
size_t strlcpy(char *dst, const char *src, size_t dstsize)
IFT h
Optional (but often useful) header information.
int verbose
Verbose level, used by statusPrint() etc.
tpcerror error
Error code.
int tacSetHeaderIsotope(IFT *h, const char *s)
int tacGetHeaderIsotope(IFT *h, char *s, TPCSTATUS *status)
int tacRead(TAC *d, const char *fname, TPCSTATUS *status)
char * tacFormattxt(tacformat c)
int tacWrite(TAC *tac, FILE *fp, tacformat format, int extra, TPCSTATUS *status)
Header file for library libtpccsv.
Header file for library libtpcextensions.
Header file for library libtpcift.
#define MAX_ISOTOPE_LEN
Max string length for PET isotope.
@ ISOTOPE_UNKNOWN
Unknown.
Header file for library libtpctac.
@ TAC_FORMAT_SIF
Scan information file.