|
|
@ -124,8 +124,8 @@ void v_push ( values_t v) { PUSH(&parser_state, val, v);} |
|
|
|
values_t v_pop () { values_t v; POP(&parser_state, val, v); return v; } |
|
|
|
|
|
|
|
void r_printstack () { PRINT(&parser_state, "%s", regex); } |
|
|
|
void r_push (const char * r) { PUSH(&parser_state, regex, r); } |
|
|
|
const char * r_pop () { const char * v; POP(&parser_state, regex, v); return v; } |
|
|
|
void r_push (char * r) { PUSH(&parser_state, regex, r); } |
|
|
|
char * r_pop () { char * v; POP(&parser_state, regex, v); return v; } |
|
|
|
void exe_push (internal_entry_t i) { PUSH(&parser_state, exe, i);} |
|
|
|
internal_entry_t exe_pop () { internal_entry_t e; POP(&parser_state, exe, e); return e; } |
|
|
|
|
|
|
@ -217,6 +217,14 @@ void reduce_results() { |
|
|
|
if (l_full_result.returncode == parser_logical_combine_close) { |
|
|
|
if (one_result_is_ok == true) { |
|
|
|
full_result.returncode = is_valid; |
|
|
|
/* free all combined values */ |
|
|
|
/* iterate and free all "ignored" entries */ |
|
|
|
for (int k=i+1; k<j; k++) { |
|
|
|
if (NULL != parser_state.result_stack[k].found_value) { |
|
|
|
free( parser_state.result_stack[k].found_value); |
|
|
|
parser_state.result_stack[k].found_value = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
i=j; |
|
|
|
#ifdef DEBUG |
|
|
|
printf("\tend combine i=%i j=%i\n", i, j); |
|
|
@ -237,11 +245,12 @@ void reduce_results() { |
|
|
|
|
|
|
|
/* push to tmp */ |
|
|
|
tmp[tmpc++]=full_result; |
|
|
|
} |
|
|
|
} /* end for loop */ |
|
|
|
/* copy back */ |
|
|
|
for (int i = 0; i <= tmpc; i++) { |
|
|
|
parser_state.result_stack[i]= tmp[i]; |
|
|
|
} |
|
|
|
|
|
|
|
free(tmp); |
|
|
|
tmp=NULL; |
|
|
|
/* copy size */ |
|
|
@ -271,8 +280,8 @@ internal_entry_t * exe_regex_push (internal_entry_t * ep, const char * s) { |
|
|
|
#endif |
|
|
|
return ep; |
|
|
|
} |
|
|
|
const char * exe_regex_pop(internal_entry_t * ep) { |
|
|
|
const char * s; |
|
|
|
char * exe_regex_pop(internal_entry_t * ep) { |
|
|
|
char * s; |
|
|
|
POP( ep, regex, s); |
|
|
|
#ifdef EXE_DEBUG |
|
|
|
printf("-------------------\n"); |
|
|
@ -285,11 +294,10 @@ const char * exe_regex_pop(internal_entry_t * ep) { |
|
|
|
|
|
|
|
char * __ch_malloc(char * msg) { |
|
|
|
assert( msg == NULL); |
|
|
|
msg = malloc(sizeof(char) * VALUESTRLEN ); |
|
|
|
msg = calloc(VALUESTRLEN, sizeof(char)); |
|
|
|
if (NULL == msg) { |
|
|
|
fprintf(stderr, "Could not allocate memory, code=%s, line=%i\n", __FILE__, __LINE__); exit(could_not_allocate_memory); |
|
|
|
} |
|
|
|
memset(msg, '\0', VALUESTRLEN); |
|
|
|
return msg; |
|
|
|
} |
|
|
|
|
|
|
@ -369,10 +377,11 @@ ret_t call_exec_function(ctiff_t * ctif, ret_t * retp, internal_entry_t * exep) |
|
|
|
case fc_has_only_one_ifd: { ret = check_has_only_one_ifd(ctif); break;} |
|
|
|
case fc_tagorder: { ret = check_tagorder(ctif); break;} |
|
|
|
case fc_tag_has_valid_asciivalue: { ret = check_tag_has_valid_asciivalue(ctif, exe.tag); break;} |
|
|
|
case fc_tag_has_value_matching_regex: { const char * regex_string = exe_regex_pop( &exe); |
|
|
|
case fc_tag_has_value_matching_regex: { char * regex_string = exe_regex_pop( &exe); |
|
|
|
expected_value = __ch_malloc(expected_value); |
|
|
|
snprintf(expected_value, VALUESTRLEN, "regex=%s", regex_string); |
|
|
|
ret = check_tag_has_value_matching_regex(ctif, exe.tag, regex_string); |
|
|
|
free( regex_string ); |
|
|
|
break; |
|
|
|
} |
|
|
|
case fc_all_offsets_are_word_aligned: { ret = check_all_offsets_are_word_aligned(ctif); break;} |
|
|
@ -381,7 +390,7 @@ ret_t call_exec_function(ctiff_t * ctif, ret_t * retp, internal_entry_t * exep) |
|
|
|
case fc_internal_logic_combine_open: { ret.returncode = parser_logical_combine_open ; break; } |
|
|
|
case fc_internal_logic_combine_close: { ret.returncode = parser_logical_combine_close ; break; } |
|
|
|
case fc_all_offsets_are_not_zero: { ret = check_all_offsets_are_greater_zero(ctif); break;} |
|
|
|
case fc_all_geotiff_tags_have_same_count_of_values: { |
|
|
|
case fc_all_geotiff_tags_have_same_count_of_values: { |
|
|
|
ret = check_all_geotiff_tags(ctif); break; |
|
|
|
} |
|
|
|
|
|
|
@ -512,7 +521,7 @@ void execute_plan (ctiff_t * ctif) { |
|
|
|
*/ |
|
|
|
if (ret.returncode != is_valid) { |
|
|
|
full.found_value = ret.value_found; |
|
|
|
} |
|
|
|
} else { free( ret.value_found ); ret.value_found=NULL; } |
|
|
|
result_push( full ); |
|
|
|
precondition_result=is_valid; |
|
|
|
precondition_function = exe.function; |
|
|
@ -577,6 +586,7 @@ void execute_plan (ctiff_t * ctif) { |
|
|
|
full.found_value=NULL; |
|
|
|
result_push( full ); |
|
|
|
} |
|
|
|
free( res.value_found ); |
|
|
|
} |
|
|
|
} |
|
|
|
#endif /* NOTAGCHECK */ |
|
|
@ -670,7 +680,7 @@ void set_optdepends() { |
|
|
|
|
|
|
|
|
|
|
|
/* helper function for parser */ |
|
|
|
void regex_push( const char * regex_string) { |
|
|
|
void regex_push( char * regex_string) { |
|
|
|
pcre *re; |
|
|
|
int erroffset; |
|
|
|
const char * errorcode; |
|
|
|