23 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
24 if(verbose>0) {printf(
"%s('%s', ...)\n", __func__, hdrfile); fflush(stdout);}
28 if(hdrfile==NULL ||
strnlen(hdrfile, 6)<5) {
36 if(header==NULL) local_hdr=&ift;
else local_hdr=header;
38 if((fp=fopen(hdrfile,
"r"))==NULL) {
39 if(verbose>1) printf(
" cannot open header file.\n");
44 if(verbose>1) printf(
" cannot read header file.\n");
52 if(verbose>1) printf(
" checking header contents...\n");
61 if(
iftFindKey(local_hdr,
"institution", 0)<0) {
65 if(
iftFindKey(local_hdr,
"number_of_dimensions", 0)<0) {
100 int verbose=0;
if(status!=NULL) verbose=status->
verbose;
101 if(verbose>0) {printf(
"%s('%s', ...)\n", __func__, filename); fflush(stdout);}
105 if(hdrfile!=NULL) hdrfile[0]=(char)0;
106 if(imgfile!=NULL) imgfile[0]=(char)0;
107 if(header!=NULL)
iftFree(header);
110 if(filename==NULL ||
strnlen(filename, 2)<1) {
115 char local_imgfile[FILENAME_MAX], local_hdrfile[FILENAME_MAX+4];
120 if(verbose>1) {printf(
" last extension := '%s'\n", last_extension); fflush(stdout);}
121 if(last_extension==NULL) {
122 strcpy(local_imgfile, filename);
strlcat(local_imgfile,
".img", FILENAME_MAX);
123 strcpy(local_hdrfile, local_imgfile);
strlcat(local_hdrfile,
".hdr", FILENAME_MAX);
124 }
else if(strcasecmp(last_extension,
".IMG")==0) {
125 strcpy(local_imgfile, filename);
126 strcpy(local_hdrfile, local_imgfile);
strlcat(local_hdrfile,
".hdr", FILENAME_MAX);
127 }
else if(strcasecmp(last_extension,
".HDR")==0) {
129 strcpy(local_hdrfile, filename);
131 strcpy(local_imgfile, filename);
strlcat(local_imgfile,
".img", FILENAME_MAX);
132 strcpy(local_hdrfile, local_imgfile);
strlcat(local_hdrfile,
".hdr", FILENAME_MAX);
135 printf(
" tentative image file name := '%s'\n", local_imgfile);
136 printf(
" tentative header file name := '%s'\n", local_hdrfile);
145 if(verbose>1) printf(
" '%s' does not exist.\n", local_hdrfile);
149 if(verbose>1) printf(
" '%s' does not exist.\n", local_imgfile);
160 if(header==NULL) local_hdr=&ift;
else local_hdr=header;
173 if(verbose>1) {printf(
" version := %g\n", version); fflush(stdout);}
176 if(hdrfile!=NULL)
strlcpy(hdrfile, local_hdrfile, FILENAME_MAX);
177 if(imgfile!=NULL)
strlcpy(imgfile, local_imgfile, FILENAME_MAX);
180 return((
int)version);
int micropetExists(const char *filename, char *hdrfile, char *imgfile, IFT *header, TPCSTATUS *status)
Verify if specified file name refers to an existing microPET file.