Browse Source

- removed xml renderer

development
art1pirat 2 months ago
committed by Andreas Romeyke
parent
commit
c3ea1c7064
  1. 3
      src/checkit_tiff.c
  2. 4
      src/headers/check_renderer.h
  3. 6
      src/helper/check_renderer.c
  4. 130
      src/helper/renderer/check_renderer_xml.c

3
src/checkit_tiff.c

@ -114,9 +114,6 @@ int main (int argc, char * argv[]) {
case 'c': /* colorize output */
set_renderer_to_ansi();
break;
case 'x': /* xml output */
set_renderer_to_xml( optarg);
break;
case 'd': /* check directory */
flag_check_directory = FLAGGED;
printf("\nCheck all files in given directory\n");

4
src/headers/check_renderer.h

@ -15,16 +15,14 @@
/* #define RENDERSIZE (65536*256 + 100*256) */
#define RENDERMINSIZE (1024)
#define RENDERMAXSIZE (33554432)
typedef enum{ render_default, render_ansi, render_xml} render_type;
typedef enum{ render_default, render_ansi} render_type;
typedef enum{ within_valid, within_error, within_file, within_summaryerror, within_harderror } render_context_t;
const char * renderer ( const retmsg_t * ret );
void set_renderer_to_ansi();
void set_renderer_to_xml(const char *);
void set_renderer_to_quiet();
const char * renderer_ansi ( const retmsg_t * ret, short int );
const char * renderer_default ( const retmsg_t * ret, short int );
const char * renderer_xml ( const retmsg_t * ret, const char * xml );
#endif

6
src/helper/check_renderer.c

@ -11,7 +11,6 @@
render_type render_engine=render_default;
short int is_quiet = 1;
const char * xmlfile = NULL;
void set_renderer_to_quiet() {
is_quiet=0;
@ -22,15 +21,10 @@ void set_renderer_to_ansi() {
render_engine=render_ansi;
}
}
void set_renderer_to_xml( const char * given_xmlfile) {
render_engine=render_xml;
xmlfile = given_xmlfile;
}
const char * renderer ( const retmsg_t * ret ) {
// call debug renderer
switch (render_engine) {
case render_xml: return renderer_xml( ret, xmlfile);
case render_ansi: return renderer_ansi( ret, is_quiet );
default: return renderer_default( ret, is_quiet );
}

130
src/helper/renderer/check_renderer_xml.c

@ -1,130 +0,0 @@
/* 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_xml ( const retmsg_t * ret, const char * xmlfile ) {
assert (ret != NULL);
if (xmlfile == NULL) {
fprintf(stderr, "no given XML file for option '-x'\n");
exit(EXIT_FAILURE);
}
FILE *f = fopen(xmlfile, "w");
if (NULL == f) {
fprintf(stderr, "Could not open file '%s' for writing\n", xmlfile);
exit(EXIT_FAILURE);
}
/*
char * res = malloc( sizeof(char) * RENDERSIZE);
if (NULL == res) {
exit(could_not_allocate_memory);
}
memset( res, '\0', RENDERSIZE);
*/
char * res = calloc(RENDERMAXSIZE, sizeof(char));
if (NULL == res) {
exit(could_not_allocate_memory);
}
size_t rendersize_res = RENDERMAXSIZE;
const retmsg_t * startp = ret;
res=secstrcat(res, "<checkit_tiff_result>\n", &rendersize_res);
render_context_t rc_is_valid=within_valid;
while (NULL != startp) {
assert(startp->rm_msg != NULL);
switch (startp->rm_type) {
case rm_rule: res=secstrcat(res, "<rule>", & rendersize_res);
res=secstrcat(res, startp->rm_msg, &rendersize_res);
res=secstrcat(res, "</rule>", & rendersize_res);
break;
case rm_tag: res=secstrcat(res, "<tag>", & rendersize_res );
res=secstrcat(res, startp->rm_msg, & rendersize_res);
res=secstrcat(res, "</tag>", & rendersize_res);
break;
case rm_mode: res=secstrcat(res, "<mode>", & rendersize_res );
res=secstrcat(res, startp->rm_msg, & rendersize_res);
res=secstrcat(res, "</mode>", & rendersize_res);
break;
case rm_value: res=secstrcat(res, "<value_found>", & rendersize_res);
res=secstrcat(res, startp->rm_msg, & rendersize_res);
res=secstrcat(res, "</value_found>", & rendersize_res);
break;
case rm_expected: res=secstrcat(res, "<value_expected>" , & rendersize_res);
res=secstrcat(res, startp->rm_msg, & rendersize_res);
res=secstrcat(res, "</value_expected>", & rendersize_res);
break;
case rm_hard_error: res=secstrcat(res, "<error level=\"critical\">", & rendersize_res);
res=secstrcat(res, startp->rm_msg, & rendersize_res);
rc_is_valid = within_harderror;
break;
case rm_error: if (strlen(startp->rm_msg) > 0) {
res=secstrcat(res, "<error level=\"summary\">", & rendersize_res);
res=secstrcat(res, startp->rm_msg, & rendersize_res);
res=secstrcat(res, "</error>", & rendersize_res);
rc_is_valid = within_summaryerror;
} else {
res=secstrcat(res, "<error level=\"error\">", & rendersize_res);
rc_is_valid = within_error;
}
break;
case rm_error_description:
res=secstrcat(res, "<description>", & rendersize_res );
res=secstrcat(res, startp->rm_msg, & rendersize_res);
res=secstrcat(res, "</description>", & rendersize_res);
break;
case rm_warning: res=secstrcat(res, "<error level=\"warning\">", & rendersize_res);
res=secstrcat(res, startp->rm_msg, & rendersize_res);
rc_is_valid = within_error;
break;
case rm_logicalor_error: res=secstrcat(res, "<error level=\"logical or error\">", & rendersize_res);
res=secstrcat(res, startp->rm_msg, & rendersize_res);
rc_is_valid = within_error;
break;
case rm_file: res=secstrcat(res, "<file>", & rendersize_res );
res=secstrcat(res, startp->rm_msg, & rendersize_res);
res=secstrcat(res, "</file>\n", & rendersize_res);
break;
case rm_lineno: res=secstrcat(res, "<lineno>", & rendersize_res);
res=secstrcat(res, startp->rm_msg, & rendersize_res);
res=secstrcat(res, "</lineno>", & rendersize_res);
break;
case rm_endrule:
case rm_endtiff:
if (rc_is_valid == within_valid) {
res=secstrcat(res, "</valid>", & rendersize_res);
} else if (rc_is_valid == within_error) {
res=secstrcat(res, "</error>", & rendersize_res);
} else if (rc_is_valid == within_harderror) {
res=secstrcat(res, "</error>", & rendersize_res);
}
res=secstrcat(res, "\n", & rendersize_res);
break;
case rm_is_valid: res=secstrcat(res, "<valid>", & rendersize_res);
rc_is_valid = within_valid;
break;
case rm_summary_valid:
case rm_summary_invalid: break;
default: res=secstrcat(res, "<dummy>", & rendersize_res);
res=secstrcat(res, startp->rm_msg, & rendersize_res);
res=secstrcat(res, "</dummy>", & rendersize_res);
}
startp=startp->next;
}
res=secstrcat(res, "</checkit_tiff_result>", & rendersize_res);
res=secstrcat(res, "\n", & rendersize_res);
fprintf(f, "%s", res);
fclose(f);
memset( res, '\0', RENDERMAXSIZE);
return res;
}
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 smarttab expandtab :*/
Loading…
Cancel
Save