110
110
/* Get PRO CATG of this product */
111
111
procatg_proplist = cpl_propertylist_load(filename, 0);
112
this_pro_catg = cpl_propertylist_get_string
113
(procatg_proplist, CPL_DFS_PRO_CATG);
112
this_pro_catg = cpl_propertylist_get_string(procatg_proplist, CPL_DFS_PRO_CATG);
114
114
if(this_pro_catg == NULL)
116
cpl_msg_error(er_func,"Could not get PRO CATG in file %s",
118
er_paf_config_delete(paf_configuration);
120
paf_err = cpl_error_get_code();
116
cpl_msg_error(er_func,"Could not get PRO CATG in file %s",
118
er_paf_config_delete(paf_configuration);
120
paf_err = cpl_error_get_code();
124
125
cpl_msg_debug(er_func, "Product with PRO CATG=%s", this_pro_catg);
125
126
cpl_msg_indent_more();
134
135
cpl_msg_debug(er_func, "Matched with regexp =%s",
135
config_item->pro_catg_regexp);
136
config_item->pro_catg_regexp);
139
* Try to get ARCFILE from the product itself. If it is not present
140
* fall back to retrieving it from the first raw file in the frame
144
arcfile = cpl_strdup(cpl_propertylist_get_string(procatg_proplist,
145
"ESO PRO ANCESTOR"));
137
/* Read the ARCFILE keyword from the first raw file */
140
arcfile = er_paf_get_arcfile(frames);
143
cpl_msg_error(er_func, "Could not read ARCFILE from raw frames");
144
er_paf_config_delete(paf_configuration);
145
return CPL_ERROR_DATA_NOT_FOUND;
149
arcfile = er_paf_get_arcfile(frames);
152
cpl_msg_error(er_func,
153
"Could not read ARCFILE information from "
155
er_paf_config_delete(paf_configuration);
156
return CPL_ERROR_DATA_NOT_FOUND;
149
160
/* Decide what to do depending on number of extensions */
150
161
next = cpl_frame_get_nextensions(frame);
615
627
char * er_paf_get_arcfile(const cpl_frameset * frames)
617
629
const cpl_frame * frame;
618
630
char * arcfile = NULL;
619
631
cpl_propertylist * all_keywords;
620
632
const char * filename;
622
634
/* Loop into all the products */
623
frame = cpl_frameset_get_first_const(frames);
624
while (frame != NULL)
626
if (cpl_frame_get_group(frame) == CPL_FRAME_GROUP_RAW)
628
filename = cpl_frame_get_filename(frame);
629
all_keywords = cpl_propertylist_load(filename, 0);
630
if(all_keywords == NULL)
632
cpl_msg_error(er_func,"Could not read the main header of %s",
637
(cpl_propertylist_get_string(all_keywords, "ARCFILE"));
638
cpl_propertylist_delete(all_keywords);
641
frame = cpl_frameset_get_next_const(frames);;
636
cpl_frameset_iterator *it = cpl_frameset_iterator_new(frames);
638
while ((frame = cpl_frameset_iterator_get_const(it)) != NULL)
640
if (cpl_frame_get_group(frame) == CPL_FRAME_GROUP_RAW)
642
filename = cpl_frame_get_filename(frame);
643
all_keywords = cpl_propertylist_load(filename, 0);
644
if(all_keywords == NULL)
646
cpl_frameset_iterator_delete(it);
647
cpl_msg_error(er_func,"Could not read the main header of %s",
652
const char *_arcfile = cpl_propertylist_get_string(all_keywords,
655
if (!_arcfile && !cpl_propertylist_has(all_keywords, "ESO PRO CATG")) {
656
_arcfile = cpl_propertylist_get_string(all_keywords, "ARCFILE");
660
cpl_msg_error(er_func,"Could not get ARCFILE information from "
661
"the main header of %s", filename);
662
cpl_frameset_iterator_delete(it);
663
cpl_propertylist_delete(all_keywords);
667
arcfile = cpl_strdup(_arcfile);
669
cpl_propertylist_delete(all_keywords);
670
cpl_frameset_iterator_delete(it);
675
cpl_frameset_iterator_advance(it, 1);
679
cpl_frameset_iterator_delete(it);
643
681
cpl_msg_error(er_func,"There are no RAW frames");
648
687
/**********************************************************************/