"checkit_tiff" is an incredibly fast conformance checker for baseline TIFFs (with various extensions), see http://andreas-romeyke.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

121 lines
4.3 KiB

/* rule based checks if given TIFF is a specific baseline TIFF
*
* author: Andreas Romeyke, 2015-2017
* licensed under conditions of libtiff
* (see http://libtiff.maptools.org/misc.html)
*
*/
#include "check_renderer.h"
#include <assert.h>
const char * renderer_default ( const retmsg_t * ret, short int is_quiet ) {
assert (ret != NULL);
strbuff_t * res = malloc(sizeof(strbuff_t));
if (NULL == res) {
exit(could_not_allocate_memory);
}
res->buf = calloc( RENDERMAXSIZE, sizeof(char));
if (NULL == res->buf) {
exit(could_not_allocate_memory);
}
res->bufpos = res->buf;
res->pos=0;
res->bufsize = RENDERMAXSIZE;
strbuff_t * tmp;
tmp = malloc( sizeof( strbuff_t ) );
if (NULL == tmp) {
exit(could_not_allocate_memory);
}
tmp->buf = calloc( RENDERMINSIZE, sizeof(char));
if (NULL == tmp->buf) {
exit(could_not_allocate_memory);
}
tmp->bufpos = tmp->buf;
tmp->pos=0;
tmp->bufsize = RENDERMINSIZE;
const retmsg_t * startp = ret;
short int rc_is_valid = 1;
while (NULL != startp) {
assert(startp->rm_msg != NULL);
switch (startp->rm_type) {
case rm_rule: tmp=secstrcat(tmp, "\t--> ");
tmp=secstrcat(tmp, startp->rm_msg);
break;
case rm_tag:
case rm_mode: tmp=secstrcat(tmp, "\t");
tmp=secstrcat(tmp, startp->rm_msg);
break;
case rm_value: tmp=secstrcat(tmp, "; found: ");
tmp=secstrcat(tmp, startp->rm_msg);
break;
case rm_expected: tmp=secstrcat(tmp, "; expected: ");
tmp=secstrcat(tmp, startp->rm_msg);
break;
case rm_hard_error: tmp=secstrcat(tmp, "(HE)");
tmp=secstrcat(tmp, startp->rm_msg);
break;
case rm_error: tmp=secstrcat(tmp, "(EE)");
tmp=secstrcat(tmp, startp->rm_msg);
break;
case rm_error_description:
tmp=secstrcat(tmp, " ");
tmp=secstrcat(tmp, startp->rm_msg);
break;
case rm_warning: tmp=secstrcat(tmp, "(WW)");
tmp=secstrcat(tmp, startp->rm_msg);
break;
case rm_logicalor_error: tmp=secstrcat(tmp, "(LE)");
tmp=secstrcat(tmp, startp->rm_msg);
break;
case rm_file: res=secstrcat(res, "file: ");
res=secstrcat(res, startp->rm_msg);
res=secstrcat(res, "\n");
break;
case rm_lineno: tmp=secstrcat(tmp, " (lineno: ");
tmp=secstrcat(tmp, startp->rm_msg);
tmp=secstrcat(tmp, ")");
break;
case rm_endrule:
case rm_endtiff:
tmp=secstrcat(tmp, "\n");
/* copy tmp to res, reset tmp */
if ((rc_is_valid == 0) && (is_quiet == 0)) {
} else {
res=secstrcat(res, tmp->buf);
}
memset(tmp->buf, 0, tmp->bufsize);
tmp->bufpos= tmp->buf;
tmp->pos = 0;
rc_is_valid =1;
break;
case rm_is_valid: tmp=secstrcat(tmp, "(./)");
rc_is_valid = 0;
break;
case rm_summary_valid:
tmp=secstrcat(tmp, "\n(./)");
tmp=secstrcat(tmp, startp->rm_msg);
break;
case rm_summary_invalid:
tmp=secstrcat(tmp, "\n(EE)");
tmp=secstrcat(tmp, startp->rm_msg);
break;
default: tmp=secstrcat(tmp, startp->rm_msg);
}
startp=startp->next;
}
res=secstrcat( res, "\n");
if (NULL != tmp->buf) {
free(tmp->buf);
}
if (NULL != tmp) {
free(tmp);
}
char * result_string = res->buf;
if (NULL != res) {
free(res);
}
return result_string;
}
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 smarttab expandtab :*/