Browse Source

Merge branch 'development'

tags/v0.6.0
Andreas Romeyke 1 month ago
parent
commit
ce987fe864
48 changed files with 950 additions and 540 deletions
  1. +6
    -6
      README.compile
  2. +35
    -0
      README.testsuite
  3. +231
    -0
      example_configs/cit_tiff_testcase.cfg
  4. +102
    -30
      src/CMakeLists.txt
  5. +3
    -9
      src/checkit_tiff.c
  6. +0
    -4
      src/checkit_tiff_risk.c
  7. +22
    -11
      src/headers/check.h
  8. +3
    -3
      src/headers/check_helper.h
  9. +3
    -2
      src/headers/config_parser.h
  10. +2
    -3
      src/headers/tiff.h
  11. +7
    -19
      src/helper/check_helper.c
  12. +2
    -0
      src/helper/check_print.c
  13. +1
    -6
      src/helper/check_renderer.c
  14. +31
    -31
      src/helper/check_tiffparse.c
  15. +1
    -4
      src/helper/renderer/check_renderer_ansi.c
  16. +1
    -3
      src/helper/renderer/check_renderer_default.c
  17. +13
    -14
      src/ifdrules/check_all_IFDs_are_word_aligned.c
  18. +8
    -6
      src/ifdrules/check_all_geotiff_tags.c
  19. +3
    -4
      src/ifdrules/check_all_offsets_are_used_once_only.c
  20. +2
    -3
      src/ifdrules/check_all_offsets_are_word_aligned.c
  21. +5
    -4
      src/ifdrules/check_all_offsets_greater_zero.c
  22. +2
    -3
      src/ifdrules/check_has_only_one_ifd.c
  23. +3
    -4
      src/ifdrules/check_tagorder.c
  24. +40
    -0
      src/ifdrules/check_tags_with_corresponding_cardinality.c
  25. +6
    -0
      src/messages/msg_parser.c
  26. +153
    -131
      src/parser/config_dsl.grammar.c
  27. +24
    -5
      src/parser/config_dsl.grammar.peg
  28. +156
    -135
      src/parser/config_parser.c
  29. +18
    -20
      src/risk_analyzer/lst_offset_mappings.c
  30. +5
    -8
      src/tagrules/check_datetime.c
  31. +3
    -3
      src/tagrules/check_icc.c
  32. +2
    -2
      src/tagrules/check_notag.c
  33. +0
    -1
      src/tagrules/check_tag.c
  34. +7
    -7
      src/tagrules/check_tag_has_some_of_these_values.c
  35. +3
    -3
      src/tagrules/check_tag_has_valid_asciivalue.c
  36. +2
    -3
      src/tagrules/check_tag_has_valid_type.c
  37. +0
    -4
      src/tagrules/check_tag_has_value.c
  38. +3
    -3
      src/tagrules/check_tag_has_value_in_range.c
  39. +3
    -4
      src/tagrules/check_tag_has_value_matching_regex.c
  40. +14
    -8
      src/tagrules/check_tag_has_value_quiet.c
  41. +8
    -20
      src/tagrules/check_tag_has_valuelist.c
  42. +2
    -3
      src/tagrules/check_tag_quiet.c
  43. +6
    -5
      src/validate_icc/check_icc_header.c
  44. +4
    -3
      t/Testcall.pm
  45. +1
    -1
      t/test_config_examples.t
  46. +4
    -2
      t/test_grammar.t
  47. BIN
      tiffs_should_fail/minimal_different_cardinality_of_stripoffsets_and_stripbytescount.tiff
  48. BIN
      tiffs_should_pass/geotiff/minimal_geotiff.tiff

+ 6
- 6
README.compile View File

@@ -5,7 +5,7 @@
########################################################
mkdir build
cd build
cmake ../src/ -DCMAKE_C_FLAGS="-W -Wall -Wextra -ansi -pedantic -O3 -Wno-unused-function -fstack-check"
cmake ../src/ -DCMAKE_C_FLAGS="-W -Wall -Wextra -ansi -pedantic -O3 -flto -Wno-unused-function -fstack-check -fstack-protector-strong -Wformat -Werror=format-security"
make
###
# if you want to allow preferred CMM type "LINO", you should use the cmake-call
@@ -24,14 +24,14 @@ make
########################################################
# cmake ../src/ -DCMAKE_C_COMPILER=$(which gcc)
# cmake ../src/ -DCMAKE_C_FLAGS="-O0 -p -g"
# cmake ../src/ -DCMAKE_C_COMPILER=$(which clang-3.5) -DCMAKE_C_FLAGS="-Oz -pedantic"
# cmake ../src/ -DCMAKE_C_COMPILER=$(which clang-7) -DCMAKE_C_FLAGS="-Oz -pedantic"
#
########################################################
# example SANITIZE options
########################################################
#
# SANITIZE with clang++
# cmake ../src/ -DCMAKE_C_COMPILER=/usr/bin/clang-3.5 -DCMAKE_C_FLAGS="-O0 -g -fsanitize=address -fno-omit-frame-pointer"
# cmake ../src/ -DCMAKE_C_COMPILER=/usr/bin/clang-8 -DCMAKE_C_FLAGS="-O0 -g -fsanitize=address -fno-omit-frame-pointer"
# make
# ASAN_OPTIONS=detect_leaks=1 ./checkit_tiff ...
#
@@ -45,14 +45,14 @@ make
# example STATIC options
########################################################
#
# cmake ../src/ -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc" -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" -DPCRE_LIBRARY=/usr/lib/x86_64-linux-gnu/libpcre.a
# cmake ../src/ -DSTATIC=1 -DCMAKE_C_FLAGS="-O3 -s -flto -Wno-unused-function -fstack-check -fstack-protector-strong -Wformat -Werror=format-security"
#
########################################################
# example CLANG-TIDY
########################################################
# cmake ../src/ -DCMAKE_C_CLANG_TIDY:STRING="clang-tidy;-checks=-*,readability-*" -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DCMAKE_C_COMPILER=/usr/bin/clang-3.8 -DCMAKE_C_FLAGS="-O0 -g -fsanitize=address -fno-omit-frame-pointer"
# cmake ../src/ -DCMAKE_C_CLANG_TIDY:STRING="clang-tidy;-checks=-*,readability-*" -DCMAKE_EXPORT_COMPILE_COMMANDS=On -DCMAKE_C_COMPILER=/usr/bin/clang-8 -DCMAKE_C_FLAGS="-O0 -g -fsanitize=address -fno-omit-frame-pointer"
# make
# run-clang-tidy-3.8.py -clang-tidy-binary /usr/bin/clang-tidy-3.8
# run-clang-tidy-8.py -clang-tidy-binary /usr/bin/clang-tidy-8
#
#
########################################################


+ 35
- 0
README.testsuite View File

@@ -0,0 +1,35 @@
########################################################

the directory tiffs_should_pass/ contains TIFF-files that should generally be
valid. This does not mean that they have to be valid against every profile.

Rudimentary tests are available in the t/ directory to check the correctness of
checkit_tiff using Perl.

It needs the following Perl modules (in brackets the debian module):

* Data::Printer (libdata-printer-perl)
* Exporter (perl-base)
* File::Path (perl-base)
* File::Slurp (libfile-slurp-perl)
* File::Spec (perl-base)
* IPC::Open3 (perl-base)
* POSIX (perl-base)
* Test::More (perl-modules-XXX with XXX as Perl-version )


in cmake the test-target is enabled by default, you could run it via:
$> cmake ../src
$> make
$> make test


If you want to call it manually, you should try this instead:

$> cd t/
$> perl -I./ test_grammar.t && echo "fine!"
$> perl -I./ test_config_examples.t && echo "fine!"
$> perl -I./ test_should_pass.t && echo "fine!"
$> perl -I./ test_should_fail.t && echo "fine!"

the return code for all these runs should be zero and result in message "fine!"

+ 231
- 0
example_configs/cit_tiff_testcase.cfg View File

@@ -0,0 +1,231 @@
#0000000000000000000000
#
#0000000000000000000
#000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000

#000000000000000000000000000000000000000000000000
#0000000000000000000000000000000000000000000000000000000000000000000000000
#00000000000

mode(baseline)
mode(enable_type_checks)
mode(enable_offset_checks)
mode(enable_ifd_checks)
mode(enable_deep_geotiff_checks)

#0000
#00000000000000000000000
#0000

#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
256;mandatory; range(0, 0000000090)
#0000000000000000000000000000000000000000000000000000000000000000
257; mandatory; range(0, 0000000090)

#00000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000
#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
258; optdepends(262.0); logical_or(0,00,00)
258; optdepends(262.1); logical_or(1,00, 0)
258; depends(262.0); logical_or(ntupel(0,0,0), ntupel(00,00,00))
258; depends(262.0); logical_or(0, 0)

#0000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000
259; mandatory; only(1)

#0000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
262; mandatory; range(0, 2)

#000000000000000000000000000000000000000000000000000000000000000000000
273; mandatory; any

#0000000000000000000000000000000000000000000000000000000000000
#00000000000000000000000
#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
270; depends(262.0); only(0)
277; optdepends(262.1); only(1)
277; optdepends(262.0); only(0)

#0000000000000000000000000000000000000000000000000000
278; mandatory; range(0, 0000007000)

#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#0000000000000000000000000000000000000000000000000000000000
279; mandatory; any

#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
282; mandatory; range(000, 4000)

#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
283; mandatory; range(000, 4000)

#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
296; mandatory; only(2)

#0000
#0000000000000000
#0000

#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
254; optional; logical_or(0, 0)

#000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#00000000000000000000000000

#00000000000000000000000000000000000000000000000000000000000000000000000
#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#00000000000000000000000000

#000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000

#0000000000000000000000000000000000000000000000000000000000000000000000
#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000

#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000
266; optional; only(1)

#000000000000000000000000000
260; optional; printascii

#0000000000000000000000000000000000000000000000000000000000000000000000000000
270; optional; printascii

#0000000000000000000000000000000000000000
270; optional; printascii

#0000000000000000000000000000000000000000000000000
270; optional; printascii

#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000
274; optional; only(1)

#000000000000000000000000000000000000000000000000000000000000000000000000
280; optional; any

#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
280; optional; any

#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
284; optional; only(1)

#000000000000000000000000000000000000000000000000000000000000000000000000
#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000

#0000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000

#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
290; optdepends(260.0); range(0, 0)
290; optdepends(260.0); range(0, 0)

#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
290; optdepends(260.0); any
290; optdepends(260.0); any

#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
297; optional; ntupel(0,1)

#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
300; optional; printascii

#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
300; optional; datetime

#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000

#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000

#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000
#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#00000000000000000000000
300;optional;any
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000
#00000000000000000000000000000000000000000000000000000000000000000000000000
#0000000000000000000000000000000000000000000000000000000
#0000000000000000000
#00000000000000000000
#00000000000000000000
300;optional;any

#000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#00000000000000000
#00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#0000000000000000000000000000000000000000000000000000000
#0000000000000000000000000

#00000000000000000000000000000000000000000000000000
700;optional;any

#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
300;optional;printascii

#0000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000000000000000000000000000000000000000
#00000000000000000000

#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#0000000000000000000000000000000000000000000000000000000000000000000000
#00000000000000000000

#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
300;optional;any

#0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
600;optdepends(260.0);iccprofile
34675;optdepends(262.1);iccprofile
34675;optdepends(262.0);iccprofile

#000000000000
#000000000000000000000000000000000
33550;mandatory;any
#000000000000000000000000
33922;mandatory;any
#00000000000000000000000000000000000000000000000000000000000000000000000000000000
#000000000000000000000
#000000000000000000000000000000000
34735;mandatory;any
#000000000000000000000000000000000
700;optional;any
#000000000000000000000000
300;optional;printascii
#00000000000000
300;optional;any
#00000000000000000000
400;optional;any
#000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
#00000000000000000000

#00000000000000000000000000000
#00000000000000000000000
#00000000000000000
300;optional;any

+ 102
- 30
src/CMakeLists.txt View File

@@ -1,11 +1,13 @@
cmake_minimum_required (VERSION 2.6)
cmake_minimum_required (VERSION 3.9.4)
project (checkit_tiff)
include_directories("${PROJECT_SOURCE_DIR}/headers")
include_directories("${PROJECT_SOURCE_DIR}/validate_icc")
include (CheckSymbolExists)
include (CheckFunctionExists)
include(CheckIPOSupported)

file( GLOB checkit_tiff_SOURCES

file( GLOB checkit_tiff_SOURCES
"${PROJECT_SOURCE_DIR}/tagrules/*.c"
"${PROJECT_SOURCE_DIR}/ifdrules/*.c"
"${PROJECT_SOURCE_DIR}/messages/*.c"
@@ -22,7 +24,7 @@ file( GLOB checkit_tiff_risk_SOURCES
"${PROJECT_SOURCE_DIR}/helper/check_tiffparse.c"
"${PROJECT_SOURCE_DIR}/messages/*.c"
"${PROJECT_SOURCE_DIR}/risk_analyzer/*.c"
)
)

#
# Make a version file containing the current version from git.
@@ -35,27 +37,47 @@ execute_process( COMMAND git describe --long --tags --dirty --always OUTPUT_VARI
add_definitions(-DVERSION="${BUILD_BRANCH}_${BUILD_TAG}")
add_definitions(-DREPO_REVISION="${REPO_REVISION}")

check_ipo_supported(RESULT LTO_IS_SUPPORTED OUTPUT LTO_CHECK_ERROR)
if (LTO_IS_SUPPORTED)
message(STATUS "IPO / LTO enabled")
set(INTERPROCEDURAL_OPTIMIZATIONS TRUE)
else()
message(STATUS "IPO / LTO unsupported: <${LTO_CHECK_ERROR}>")
endif()


# add default CFLAGS
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong -Wformat -Werror=format-security")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro -fPIE")

# Check for compatibility with gnu11
# Compile with gnu11 support.
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-std=gnu11" COMPILER_SUPPORTS_GNU11)
if(COMPILER_SUPPORTS_GNU11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
else()
message(STATUS "Your compiler (${CMAKE_C_COMPILER}) has no gnu11 support. If you are using clang on Apple OS X, please switch to gcc (version > 4.7) which is compliant with the C11 standard.")
message(STATUS "Your compiler (${CMAKE_C_COMPILER}) has no gnu11 support. If you are using clang on Apple OS X, please switch to gcc (version > 4.7) which is compliant with the C11 standard.")
endif()


if(WIN32)
add_definitions(-D__WIN32__=1)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(BUILD_SHARED_LIBRARIES OFF)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBRARIES OFF)
# needed to increase default stack, because Win7 has only 1MB
SET(CMAKE_EXE_LINKER_FLAGS "-static -Wl,--stack,20000000")
set(CMAKE_EXE_LINKER_FLAGS "-static -Wl,--stack,20000000")
add_definitions(-DPCRE_STATIC)
add_definitions(-D_POSIX_C_SOURCE=200809L)
# FIXME: needed for MingW only
add_definitions(-D_GNU_SOURCE=1)
endif(WIN32)
endif()
if(STATIC)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBRARIES OFF)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
add_definitions(-DPCRE_STATIC)
endif()

add_executable(checkit_tiff checkit_tiff.c ${checkit_tiff_SOURCES})
add_executable(checkit_check_config checkit_check_config.c ${checkit_tiff_SOURCES})
@@ -63,44 +85,94 @@ add_executable(checkit_tiff_risk checkit_tiff_risk.c ${checkit_tiff_risk_SOURCES
set(CMAKE_EXTRA_INCLUDE_FILES tiff.h)



#libpcre
#find_package(LIBPCRE REQUIRED)
FIND_PATH(PCRE_INCLUDE_DIR NAMES pcre.h)
FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
INCLUDE(FindPackageHandleStandardArgs)
find_path(PCRE_INCLUDE_DIR NAMES pcre.h)
find_library(PCRE_LIBRARY NAMES pcre)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR)
if (PCRE_FOUND)
SET(PCRE_LIBRARIES ${PCRE_LIBRARY})
SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIR})
else(PCRE_FOUND)
MESSAGE(FATAL_ERROR "No PCRE library found, add $PCRE_INCLUDE_DIR manually")
endif(PCRE_FOUND)
set(PCRE_LIBRARIES ${PCRE_LIBRARY})
if (STATIC)
set(PCRE_LIBRARIES ${PCRE_LIBRARIES} -lpthread)
endif()
set(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
include_directories(${PCRE_INCLUDE_DIR})
else()
message(FATAL_ERROR "No PCRE library found, add $PCRE_INCLUDE_DIR manually")
endif()

#find mmap
CHECK_FUNCTION_EXISTS(mmap _HAVE_MMAP)
CHECK_FUNCTION_EXISTS(munmap _HAVE_MUNMAP)
IF(_HAVE_MMAP AND _HAVE_MUNMAP)
MESSAGE(INFO "mmap found")
SET(_HAVE__MMAP 1)
ENDIF()

if(_HAVE_MMAP AND _HAVE_MUNMAP)
message(INFO "mmap found")
set(_HAVE__MMAP 1)
endif()


TARGET_LINK_LIBRARIES(checkit_tiff ${PCRE_LIBRARIES})
TARGET_LINK_LIBRARIES(checkit_check_config ${PCRE_LIBRARIES})
TARGET_LINK_LIBRARIES(checkit_tiff_risk)
target_link_libraries(checkit_tiff ${PCRE_LIBRARIES})
target_link_libraries(checkit_check_config ${PCRE_LIBRARIES})
target_link_libraries(checkit_tiff_risk)

install( TARGETS checkit_tiff
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
install(DIRECTORY
)
install(DIRECTORY
../example_configs
../tiffs_should_fail
../tiffs_should_pass
../tiffs_should_pass
DESTINATION share/checkit_tiff/
)
)

file( GLOB README_FILES "../README*" "../FAQ" "../LICENSE" "../TODO" "../BUGS")
install(FILES ${README_FILES} DESTINATION share/checkit_tiff/)

include(FindPerl)
if (PERL_FOUND)
enable_testing()
set(T_DIR ${PROJECT_SOURCE_DIR}/../t )
add_test(NAME grammar COMMAND ${PERL_EXECUTABLE} -I ${T_DIR} test_grammar.t WORKING_DIRECTORY ${T_DIR} )
add_test(NAME config COMMAND ${PERL_EXECUTABLE} -I ${T_DIR} test_config_examples.t WORKING_DIRECTORY ${T_DIR} )
add_test(NAME validfiles COMMAND ${PERL_EXECUTABLE} -I ${T_DIR} test_should_pass.t WORKING_DIRECTORY ${T_DIR} )
add_test(NAME invalidfiles COMMAND ${PERL_EXECUTABLE} -I ${T_DIR} test_should_fail.t WORKING_DIRECTORY ${T_DIR} )
else()
message(WARN "for testsuite an installed Perl is needed")
endif()

# CPACK definitions
include(InstallRequiredSystemLibraries)

set (CPACK_PACKAGE_VENDOR "Andreas Romeyke")
string(REGEX REPLACE "^v([0-9]+).*" "\\1" MAJOR_VERSION ${BUILD_TAG})
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+)\\.[0-9]+[^0-9].*" "\\1" MINOR_VERSION ${BUILD_TAG})
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+)[^0-9].*" "\\1" PATCH_VERSION ${BUILD_TAG})

message( "BUILDTAG (after) : '${BUILD_TAG}'")
message( "MAJOR VERSION: ${MAJOR_VERSION}")
message( "MINOR VERSION: ${MINOR_VERSION}")
message( "PATCH VERSION: ${PATCH_VERSION}")
set (CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
set (CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
set (CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION})



set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/../LICENSE")
set (CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/../README.1st_checkit")
set (CPACK_GENERATOR "TGZ;STGZ;TZ;DEB;RPM")
#set (CPACK_GENERATOR "DEB")
set (CPACK_PACKAGE_CONTACT "Andreas Romeyke checkit_tiff@andreas-romeyke.de")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
#set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc (>= 6.0)")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "checkit_tiff is a policy-oriented conformance checker for baseline TIFFs")
set(CPACK_PACKAGE_DESCRIPTION "checkit_tiff is a conformance checker for baseline TIFFs (with various
extensions). It works in different way than other tools. Instead to use a
hardcoded rule set with predefined values, you are able to define tags and
corresponding values more fine granulary. The rulesets are human readable and
could be adapted to own needs.")
set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
set(CPACK_DEBIAN_COMPRESSION_TYPE "xz")
include(CPack)

+ 3
- 9
src/checkit_tiff.c View File

@@ -8,20 +8,14 @@


#include "config_parser.h"
#include "check.h"
#include "check_helper.h"
#include "check_renderer.h"
#include <unistd.h>
#include <assert.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef __unix__
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#else
/* #include <sys\stat.h> */
#include <sys/stat.h>
@@ -111,7 +105,7 @@ int main (int argc, char * argv[]) {
int c;
int flag_check_directory=UNFLAGGED;
int flag_use_memorymapped_io=UNFLAGGED;
while ((c = getopt (argc, argv, "chmdx:q")) != -1) {
while ((c = getopt(argc, argv, "chmdx:q")) != -1) {
switch (c)
{
case 'h': /* help */
@@ -139,7 +133,7 @@ int main (int argc, char * argv[]) {
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
return (-1);
}
else*/ if (isprint (optopt)) {
else*/ if (isprint(optopt)) {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
return (-1);
}


+ 0
- 4
src/checkit_tiff_risk.c View File

@@ -10,14 +10,10 @@
#include "check_helper.h"
#include <ctype.h>
#ifdef __unix__
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#else
/* #include <sys\stat.h> */
#include <sys/stat.h>
#endif
#include <unistd.h>

#define FLAGGED 1
#define UNFLAGGED 0


+ 22
- 11
src/headers/check.h View File

@@ -129,8 +129,7 @@ typedef enum {
parser_logical_combine_open, /* if fc_logicalcombine was called first (no error) */
parser_logical_combine_close, /* if fc_logicalcombine was called first (no error) */
tagerror_offset_is_zero,


ifderror_different_cardinality,
} returncode_t;

typedef struct ret_s {
@@ -225,12 +224,23 @@ typedef struct mem_map_s {
} mem_map_t;


#define MAXSTRLEN 1024
#define EXPECTSTRLEN 500
#define VALUESTRLEN 500
#define TIFFAILSTRLEN (EXPECTSTRLEN + VALUESTRLEN)
#define MAXRESULT 200000
returncode_t tifp_check( ctiff_t * ctif);

#ifdef HARDEN
#define TIFP_CHECK( ctif, ret ) \
if (NULL == ctif) { ret.returncode = code_error_ctif_empty; ret.value_found="code error, empty ctif-structure"; return ret; };\
if ((0 > ctif->fd) && (NULL == ctif->streamp)) {\
if (0 > ctif->fd) { ret.returncode = code_error_filedescriptor_empty; ret.value_found="empty filedescriptor"; return ret; };\
if (NULL == ctif->streamp) { ret.returncode = code_error_streampointer_empty; ret.value_found="empty stream pointer"; return ret; }; \
}
#else
#define TIFP_CHECK( ctif, ret ) ;
#endif

//returncode_t tifp_check( ctiff_t * ctif);
/*
ret_t tif_returns(tag_t tag, const char* expected, const char* value);
ret_t tif_fails_tag(tag_t tag, const char* expected, const char* value);
@@ -243,15 +253,15 @@ ret_t tif_no_tag(tag_t tag);
ret_t _empty_result();
*/

const char * float2str(float v);
const char* tag2str(tag_t tag);
const char* int2str(int v);
const char* frac2str(int d, int n);
const char* range2str(int d, int n);
char* float2str(float v);
char* tag2str(tag_t tag);
char* int2str(int v);
char* frac2str(int d, int n);
char* range2str(int d, int n);
off_t ct_seek(ctiff_t * ctif, off_t pos, int whence);
ssize_t ct_read(ctiff_t * ctif, void *buf, size_t count);
ret_t check_tag_has_some_of_these_values( ctiff_t * ctif, tag_t tag, int count, const unsigned int * values);
ret_t check_tag_has_valuelist( ctiff_t * ctif, tag_t tag, int count, const unsigned int * values);
ret_t check_tag_has_some_of_these_values( ctiff_t * ctif, tag_t tag, unsigned int count, const unsigned int * values);
ret_t check_tag_has_valuelist( ctiff_t * ctif, tag_t tag, unsigned int count, const unsigned int * values);
ret_t check_tag_has_value_in_range(ctiff_t * ctif, tag_t tag, unsigned int a, unsigned int b);
ret_t check_tag_has_value(ctiff_t * ctif, tag_t tag, unsigned int value);
ret_t check_tag_has_value_quiet(ctiff_t * ctif, tag_t tag, unsigned int expected_value);
@@ -270,6 +280,7 @@ ret_t check_all_offsets_are_used_once_only(ctiff_t * ctif);
ret_t check_all_offsets_are_greater_zero(ctiff_t * ctif);
ret_t check_all_IFDs_are_word_aligned(ctiff_t * ctif);
ret_t check_all_geotiff_tags( ctiff_t * ctif);
ret_t check_cardinality_of_some_tags_are_equal( ctiff_t * ctif);

mem_map_t * scan_mem_map(ctiff_t * ctif) ;
void print_mem_map( mem_map_t * memmap_p);


+ 3
- 3
src/headers/check_helper.h View File

@@ -49,7 +49,7 @@ void __clean_render_pipeline( retmsg_t ** pointer );

#define GET_EMPTY_RET(ret) \
ret_t ret; \
ret.value_found = NULL; \
ret.logical_or_count = 0; \
ret.returncode = should_not_occur;
(ret).value_found = NULL; \
(ret).logical_or_count = 0; \
(ret).returncode = should_not_occur;
#endif

+ 3
- 2
src/headers/config_parser.h View File

@@ -58,6 +58,7 @@ typedef enum {
fc_internal_logic_combine_close,
fc_all_offsets_are_not_zero,
fc_all_geotiff_tags_have_same_count_of_values,
fc_check_cardinality,
fc_dummy
} function_t;

@@ -68,7 +69,7 @@ typedef struct internal_entry_s {
tag_t tag;
function_t function;
values_t val_stack[INTERNALSTACKDEPTH];
const char * regex_stack[INTERNALSTACKDEPTH];
char * regex_stack[INTERNALSTACKDEPTH];
unsigned int i_stack[INTERNALSTACKDEPTH];
int i_stackp;
int val_stackp;
@@ -91,7 +92,7 @@ typedef struct parser_state_s {
tag_t tag;
tag_t tagref;
values_t val_stack[MAXSTACKDEPTH];
const char * regex_stack[MAXSTACKDEPTH];
char * regex_stack[MAXSTACKDEPTH];
requirements_t req;
unsigned int i_stack[MAXSTACKDEPTH];
int i_stackp;


+ 2
- 3
src/headers/tiff.h View File

@@ -139,7 +139,8 @@ typedef enum {
TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */
TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */
TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */
TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */
TIFF_IFD8 = 18, /* BigTIFF 64-bit unsigned integer (offset) */
TIFF_ERROR = 0,
} TIFFDataType;

/*
@@ -662,8 +663,6 @@ typedef enum {
#define EXIFTAG_SHARPNESS 41994 /* Sharpness */
#define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */
#define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */
#define EXIFTAG_GAINCONTROL 41991 /* Gain control */
#define EXIFTAG_GAINCONTROL 41991 /* Gain control */
#define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */

#endif /* _TIFF_ */


+ 7
- 19
src/helper/check_helper.c View File

@@ -7,15 +7,11 @@
*/

#define _GNU_SOURCE
#include <math.h>
#include "check.h"
#include "check_helper.h"
#include "check_renderer.h"
#include <unistd.h>
#include <sys/stat.h>
#include <assert.h>
#include <fcntl.h>
#include <string.h>
#include <byteswap.h>
/*
#define DEBUG
*/
@@ -43,36 +39,30 @@ char * secstrcat (char * dest, const char * src, const size_t * maxsize_p) {
return dest;
}

const char * float2str(float v) {
char * float2str(float v) {
char array[VALUESTRLEN];
snprintf(array, sizeof(array), "%f", v);
return strdup(array);
}

const char* int2str(int v) {
char* int2str(int v) {
char array[VALUESTRLEN];
snprintf(array, sizeof(array), "%i", v);
return strdup(array);
}

const char* frac2str(int d, int n) {
char* frac2str(int d, int n) {
char array[VALUESTRLEN];
snprintf(array, sizeof(array), "%i/%i", d, n);
return strdup(array);
}

void TIFFSwabShort(uint16 *a) {
uint16 b = ((*a & 0xff) << 8) | ((*a >> 8) & 0xff);
*a=b;
*a = bswap_16( *a );
}

void TIFFSwabLong(uint32 *a) {
uint8 b0 = (*a) & 0xff;
uint8 b1 = (*a >> 8) & 0xff;
uint8 b2 = (*a >> 16) & 0xff;
uint8 b3 = (*a >> 24) & 0xff;
uint32 b = (b0 << 24) | (b1 << 16) | (b2 << 8) | b3;
*a=b;
*a = bswap_32( *a );
}

long long fsize(int fd) {
@@ -85,12 +75,10 @@ long long fsize(int fd) {
ret_t set_value_found_ret (ret_t * rp, const char * msg) {
assert( NULL != rp);
assert( NULL != msg);
rp->value_found=malloc(sizeof(char) * VALUESTRLEN);
rp->value_found=calloc(VALUESTRLEN, sizeof(char));
if (NULL == rp->value_found) {
rp->returncode=could_not_allocate_memory;
} else {
memset(rp->value_found, '\0', VALUESTRLEN);
// printf("DEBUG='%s'\n", msg);
strncpy(rp->value_found, msg, VALUESTRLEN-1);
// printf("DEBUG2='%s'\n", rp->value_found);
}


+ 2
- 0
src/helper/check_print.c View File

@@ -72,11 +72,13 @@ void __clean_render_pipeline( retmsg_t ** pointer ) {
}
}

/*
returncode_t tifp_check( ctiff_t * ctif) {
if (NULL == ctif) { return code_error_ctif_empty; };
if (0 > ctif->fd) { return code_error_filedescriptor_empty; };
if (NULL == ctif->streamp) { return code_error_streampointer_empty; };
return should_not_occur;
}
*/

/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 smarttab expandtab :*/

+ 1
- 6
src/helper/check_renderer.c View File

@@ -7,14 +7,9 @@
*/

#define _GNU_SOURCE
#include <math.h>
#include "check.h"
#include "check_helper.h"
#include "check_renderer.h"
#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
#include <string.h>

render_type render_engine=render_default;
short int is_quiet = 1;


+ 31
- 31
src/helper/check_tiffparse.c View File

@@ -10,21 +10,13 @@
#include <math.h>
#include "check.h"
#include "check_helper.h"
#include "msg_tiffparse.h"
#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
#include <string.h>
#include <math.h>

#ifdef _HAVE__MMAP
#include <sys/mman.h>
#endif

#include <errno.h>
/*
#define DEBUG
*/

off_t ct_seek(ctiff_t * ctif, off_t pos, int whence) {
#ifdef _HAVE__MMAP
@@ -149,8 +141,8 @@ int TIFFGetRawTagListIndex(ctiff_t * ctif, tag_t tag) { /* find n-th entry in IF

//------------------------------------------------------------------------------
ret_t check_tag_has_fvalue(ctiff_t * ctif, tag_t tag, float value) {
GET_EMPTY_RET(ret)
tifp_check( ctif);
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);

float * valp = NULL;
uint32 found;
@@ -161,7 +153,9 @@ ret_t check_tag_has_fvalue(ctiff_t * ctif, tag_t tag, float value) {
ret.returncode=is_valid;
return ret;
} else {
ret = set_value_found_ret(&ret, float2str(val)) ;
char * msg = float2str(val);
ret = set_value_found_ret(&ret, msg ) ;
free ( msg );
ret.returncode = tagerror_value_differs;
}
}
@@ -170,8 +164,8 @@ ret_t check_tag_has_fvalue(ctiff_t * ctif, tag_t tag, float value) {

//------------------------------------------------------------------------------
ret_t check_tag_has_u16value(ctiff_t * ctif, tag_t tag, uint16 value) {
GET_EMPTY_RET(ret)
tifp_check( ctif);
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);

uint16 * valp = NULL;
uint32 found;
@@ -182,7 +176,9 @@ ret_t check_tag_has_u16value(ctiff_t * ctif, tag_t tag, uint16 value) {
ret.returncode=is_valid;
return ret;
} else {
ret = set_value_found_ret(&ret, int2str(val));
char * msg = int2str(val);
ret = set_value_found_ret(&ret, msg );
free ( msg );
ret.returncode = tagerror_value_differs;
return ret;
}
@@ -194,9 +190,8 @@ ret_t check_tag_has_u16value(ctiff_t * ctif, tag_t tag, uint16 value) {

//------------------------------------------------------------------------------
ret_t check_tag_has_u32value(ctiff_t * ctif, tag_t tag, uint32 value) {
GET_EMPTY_RET(ret)

tifp_check( ctif);
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);

uint32 * valp = NULL;
uint32 found;
@@ -207,7 +202,9 @@ ret_t check_tag_has_u32value(ctiff_t * ctif, tag_t tag, uint32 value) {
ret.returncode=is_valid;
return ret;
} else {
ret = set_value_found_ret(&ret, int2str(val));
char * msg = int2str(val);
ret = set_value_found_ret(&ret, msg );
free ( msg );
ret.returncode = tagerror_value_differs;
return ret;
}
@@ -217,7 +214,8 @@ ret_t check_tag_has_u32value(ctiff_t * ctif, tag_t tag, uint32 value) {


ret_t parse_header_and_endianess(ctiff_t * ctif) {
GET_EMPTY_RET(ret)
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);

/* seek the image file directory (bytes 4-7) */
//ct_seek(fd, (off_t) 0, SEEK_SET);
@@ -285,7 +283,9 @@ ret_t parse_header_and_endianess(ctiff_t * ctif) {
}

ret_t get_first_IFD(ctiff_t * ctif, uint32 * ifd) {
GET_EMPTY_RET(ret)
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);

int isByteSwapped = ctif->isbyteswapped;
/* seek the image file directory (bytes 4-7) */
if (ct_seek(ctif, 4, SEEK_SET) != 4 ) {
@@ -418,7 +418,7 @@ ret_t read_offsetdata(ctiff_t * ctif, const uint32 address, const uint32 count,
ret_p->returncode = is_valid;
/* ct_read and seek to IFD address */
if (ct_seek(ctif, address, SEEK_SET) != (off_t) address) {
offset_p->count = -1;
offset_p->count = 0;
ret_p->returncode = tiff_seek_error_offset;
return * ret_p;
}
@@ -568,10 +568,10 @@ ifd_entry_t TIFFGetRawTagIFDListEntry( ctiff_t * ctif, int tagidx ) {
ifd_entry.data32offset=value_or_offset;
} else { /* values */
ifd_entry.value_or_offset=is_value;
ifd_entry.data8[0] = value_or_offset & 0x000000ff;
ifd_entry.data8[1] = (value_or_offset >> 8) & 0x000000ff;
ifd_entry.data8[2] = (value_or_offset >> 16) & 0x000000ff;
ifd_entry.data8[3] = (value_or_offset >> 24) & 0x000000ff;
ifd_entry.data8[0] = (uint8) (value_or_offset & 0x000000ff);
ifd_entry.data8[1] = (uint8) ((value_or_offset >> 8) & 0x000000ff);
ifd_entry.data8[2] = (uint8) ((value_or_offset >> 16) & 0x000000ff);
ifd_entry.data8[3] = (uint8) ((value_or_offset >> 24) & 0x000000ff);
#ifdef DEBUG
printf("data8[0]=%u\n", ifd_entry.data8[0] );
printf("data8[1]=%u\n", ifd_entry.data8[1] );
@@ -590,8 +590,8 @@ ifd_entry_t TIFFGetRawTagIFDListEntry( ctiff_t * ctif, int tagidx ) {
if (byteswapped) {
TIFFSwabLong( &value_or_offset);
}
uint16 w0 = value_or_offset & 0x0000ffff;
uint16 w1 = (value_or_offset >> 16) & 0x0000ffff;;
uint16 w0 = (uint16) (value_or_offset & 0x0000ffff);
uint16 w1 = (uint16) ((value_or_offset >> 16) & 0x0000ffff);;
if (byteswapped) { /* swap correctly 16bit */
TIFFSwabShort( &w0 );
TIFFSwabShort( &w1 );
@@ -688,7 +688,7 @@ TIFFDataType TIFFGetRawTagType(ctiff_t * ctif, tag_t tag) {
return datatype;
} else { /* tag not defined */
printf("\ttag %u (%s) was not found, but requested because defined\n", tag, TIFFTagName(tag));
return -1;
return TIFF_ERROR;
}
}

@@ -709,7 +709,7 @@ ctiff_t * initialize_ctif(const char * tiff_file, ct_ioflag_t ioflag) {
exit (EXIT_FAILURE);
};
ctif->fd = tif;
ctif->streamlen = fsize(tif);
ctif->streamlen = (uint32) fsize(tif);
ctif->streamp = NULL;
ctif->actual_streamp = NULL;
ctif->tagorder=unknown_tag_order;
@@ -876,7 +876,7 @@ ret_t TIFFGetFieldASCII(ctiff_t * ctif, const tag_t tag, char** string_pp, uint3
ret_t TIFFGetFieldLONG(ctiff_t * ctif, const tag_t tag, uint32 ** long_pp, uint32 * countp) {
assert( *long_pp == NULL);
assert( countp != NULL);
*countp = -1; /* init */
*countp = 0; /* init */
GET_EMPTY_RET(ret)
int tagidx = TIFFGetRawTagListIndex(ctif, tag);
if (tagidx >= 0) { /* there exists the tag */
@@ -933,7 +933,7 @@ ret_t TIFFGetFieldLONG(ctiff_t * ctif, const tag_t tag, uint32 ** long_pp, uint3
ret_t TIFFGetFieldSHORT(ctiff_t * ctif, const tag_t tag, uint16 ** short_pp, uint32 * countp) {
assert( *short_pp == NULL);
assert( countp != NULL);
*countp = -1; /* init */
*countp = 0; /* init */
GET_EMPTY_RET(ret)
int tagidx = TIFFGetRawTagListIndex(ctif, tag);
if (tagidx >= 0) { /* there exists the tag */


+ 1
- 4
src/helper/renderer/check_renderer_ansi.c View File

@@ -88,10 +88,7 @@ const char * renderer_ansi ( const retmsg_t * ret, short int is_quiet ) {
tmp=secstrcat(tmp, "\t--> ", & rendersize_tmp);
tmp=secstrcat(tmp, startp->rm_msg, & rendersize_tmp);
break;
case rm_tag: tmp=secstrcat(tmp, "\t", & rendersize_tmp );
tmp=secstrcat(tmp, ANSI_BOLD , & rendersize_tmp);
tmp=secstrcat(tmp, startp->rm_msg, & rendersize_tmp);
break;
case rm_tag:
case rm_mode: tmp=secstrcat(tmp, "\t", & rendersize_tmp );
tmp=secstrcat(tmp, ANSI_BOLD , & rendersize_tmp);
tmp=secstrcat(tmp, startp->rm_msg, & rendersize_tmp);


+ 1
- 3
src/helper/renderer/check_renderer_default.c View File

@@ -46,9 +46,7 @@ const char * renderer_default ( const retmsg_t * ret, short int is_quiet ) {
case rm_rule: tmp=secstrcat(tmp, "\t--> ", & rendersize_tmp);
tmp=secstrcat(tmp, startp->rm_msg, & rendersize_tmp);
break;
case rm_tag: tmp=secstrcat(tmp, "\t", & rendersize_tmp );
tmp=secstrcat(tmp, startp->rm_msg, & rendersize_tmp);
break;
case rm_tag:
case rm_mode: tmp=secstrcat(tmp, "\t", & rendersize_tmp );
tmp=secstrcat(tmp, startp->rm_msg, & rendersize_tmp);
break;


+ 13
- 14
src/ifdrules/check_all_IFDs_are_word_aligned.c View File

@@ -8,25 +8,24 @@

#include "check.h"
#include "check_helper.h"
#include <unistd.h>
#include <assert.h>


/* check if IFDs are word aligned */
ret_t check_all_IFDs_are_word_aligned(ctiff_t * ctif) {
GET_EMPTY_RET(ret)
tifp_check( ctif);
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);

uint32 ifd = get_ifd0_pos( ctif ); /* TODO: check all other IFDs, too */
if ( 0 != (ifd & 1)) {
// FIXME: tif_fails?
char array[VALUESTRLEN];
snprintf(array, sizeof(array), "offset of first IFD points to 0x%08x and is not word-aligned", ifd);
ret = set_value_found_ret (&ret, array);
ret.returncode = ifderror_offset_not_word_aligned;
return ret;
}
ret.returncode=is_valid;
return ret;
if (0 == (ifd & 1)) {
ret.returncode = is_valid;
return ret;
} else {
// FIXME: tif_fails?
char array[VALUESTRLEN];
snprintf(array, sizeof(array), "offset of first IFD points to 0x%08x and is not word-aligned", ifd);
ret = set_value_found_ret(&ret, array);
ret.returncode = ifderror_offset_not_word_aligned;
return ret;
}
}
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 smarttab expandtab :*/

+ 8
- 6
src/ifdrules/check_all_geotiff_tags.c View File

@@ -8,8 +8,6 @@

#include "check.h"
#include "check_helper.h"
#include <unistd.h>
#include <errno.h>

/* checks the geo tiff tags:
* - geokey directory tag (34735) -> geokeys
@@ -52,8 +50,8 @@
*/

ret_t check_all_geotiff_tags(ctiff_t * ctif) {
GET_EMPTY_RET(ret)
tifp_check( ctif);
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);
/* first, detect if geokey directory tag exists */
/* mark n
* find offset for geokeys
@@ -64,12 +62,16 @@ ret_t check_all_geotiff_tags(ctiff_t * ctif) {
ifd_entry_t ifd_entry = TIFFGetRawIFDEntry(ctif, 34735);
/* only one ifd? */
if (ifd_entry.count < 4) {
ret = set_value_found_ret(&ret, int2str(ifd_entry.count));
char * msg = int2str(ifd_entry.count);
ret = set_value_found_ret(&ret, msg );
free( msg );
ret.returncode = tagerror_expected_count_less_than_four;
return ret;
}
if (ifd_entry.count % 4 != 0) {
ret = set_value_found_ret(&ret, int2str(ifd_entry.count));
char * msg = int2str(ifd_entry.count);
ret = set_value_found_ret(&ret, msg );
free( msg );
ret.returncode = tagerror_expected_count_not_a_multiple_of_four;
return ret;
}


+ 3
- 4
src/ifdrules/check_all_offsets_are_used_once_only.c View File

@@ -8,13 +8,12 @@

#include "check.h"
#include "check_helper.h"
#include <unistd.h>


/* check if offsets are used only once */
ret_t check_all_offsets_are_used_once_only(ctiff_t * ctif) {
GET_EMPTY_RET(ret)
tifp_check( ctif);
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);
uint16 count = get_ifd0_count( ctif);
if (count > 0) {
uint16 tagidx;
@@ -31,7 +30,7 @@ ret_t check_all_offsets_are_used_once_only(ctiff_t * ctif) {
ifd_entry_t ifd_entry = TIFFGetRawTagIFDListEntry( ctif, tagidx );
if (ifd_entry.value_or_offset==is_offset) {
uint32 offset = ifd_entry.data32offset;
uint32 tag = TIFFGetRawTagListEntry( ctif, tagidx);
tag_t tag = TIFFGetRawTagListEntry( ctif, tagidx);
for (i=0; i< count_of_offsets; i++) {
if (offsets[ i ] == offset) {
// FIXME: tif_fails?


+ 2
- 3
src/ifdrules/check_all_offsets_are_word_aligned.c View File

@@ -8,13 +8,12 @@

#include "check.h"
#include "check_helper.h"
#include <unistd.h>


/* check if offsets are word aligned */
ret_t check_all_offsets_are_word_aligned(ctiff_t * ctif) {
GET_EMPTY_RET(ret)
tifp_check( ctif);
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);
uint16 count = get_ifd0_count( ctif);
int tagidx;
for (tagidx = 0; tagidx< count; tagidx++) {


+ 5
- 4
src/ifdrules/check_all_offsets_greater_zero.c View File

@@ -8,13 +8,12 @@

#include "check.h"
#include "check_helper.h"
#include <unistd.h>


/* check if offsets are greater zero */
ret_t check_all_offsets_are_greater_zero(ctiff_t * ctif) {
GET_EMPTY_RET(ret)
tifp_check( ctif);
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);
uint16 count = get_ifd0_count( ctif);
int tagidx;
for (tagidx = 0; tagidx< count; tagidx++) {
@@ -25,7 +24,9 @@ ret_t check_all_offsets_are_greater_zero(ctiff_t * ctif) {
if (ifd_entry.value_or_offset==is_offset) offset = ifd_entry.data32offset;
else if (tag == TIFFTAG_EXIFIFD) {
if (ifd_entry.count > 1) {
ret = set_value_found_ret(&ret, int2str(ifd_entry.count));
char * msg = int2str(ifd_entry.count);
ret = set_value_found_ret(&ret, msg);
free(msg);
ret.returncode = tagerror_expected_count_isgreaterone;
return ret;
}


+ 2
- 3
src/ifdrules/check_has_only_one_ifd.c View File

@@ -8,12 +8,11 @@

#include "check.h"
#include "check_helper.h"
#include <unistd.h>

/* check if only one IFD exists */
ret_t check_has_only_one_ifd(ctiff_t * ctif) {
GET_EMPTY_RET(ret)
tifp_check( ctif);
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);
/* next commented lines, because TIFFNumberOfDirectories are in endless loop,
* if the TIFF file from https://github.com/EasyinnovaSL/DPFManager/blob/develop/src/test/resources/IFD%20struct/Circular%20E.tif
*/


+ 3
- 4
src/ifdrules/check_tagorder.c View File

@@ -8,12 +8,11 @@

#include "check.h"
#include "check_helper.h"
#include <unistd.h>
#include <errno.h>

ret_t check_tagorder(ctiff_t * ctif) {
GET_EMPTY_RET(ret)
tifp_check( ctif);
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);
if (has_sorted_tags != ctif->tagorder) {
uint32 offset = get_ifd0_pos(ctif);
uint16 count = get_ifd0_count(ctif);
@@ -34,7 +33,7 @@ ret_t check_tagorder(ctiff_t * ctif) {
free(ifdentries);
return ret;
}
if ( ct_read( ctif, ifdentries, 12 * count) != 12*count ) {
if (ct_read(ctif, ifdentries, (size_t) (12 * count)) != 12 * count ) {
char array[VALUESTRLEN];
snprintf(array, VALUESTRLEN, "%i bytes, errorcode=%i", 12*count, errno);
ret = set_value_found_ret(&ret, array);


+ 40
- 0
src/ifdrules/check_tags_with_corresponding_cardinality.c View File

@@ -0,0 +1,40 @@
/* rule based checks if given TIFF is a specific baseline TIFF
*
* author: Andreas Romeyke, 2020
* licensed under conditions of libtiff
* (see http://libtiff.maptools.org/misc.html)
*
*/

#include "check.h"
#include "check_helper.h"


/* check if cardinality of tags are equal */
ret_t check_cardinality_of_some_tags_are_equal(ctiff_t * ctif) {
/* we need to check following tag groups:
* StripOffset and StripBytesCounts
*/
GET_EMPTY_RET(ret);
TIFP_CHECK( ctif, ret);
/* check if both values exist */
ret_t rc_stripoffsets=check_tag_quiet(ctif, TIFFTAG_STRIPOFFSETS);
ret_t rc_stripbytecounts =check_tag_quiet(ctif, TIFFTAG_STRIPBYTECOUNTS);
if ((rc_stripoffsets.returncode == is_valid) && (rc_stripbytecounts.returncode == is_valid)) {

/* find stripoffset */
ifd_entry_t stripoffsets_entry = TIFFGetRawIFDEntry(ctif, TIFFTAG_STRIPOFFSETS);
ifd_entry_t stripbytescounts_entry = TIFFGetRawIFDEntry(ctif, TIFFTAG_STRIPBYTECOUNTS);
if (stripoffsets_entry.count != stripbytescounts_entry.count) {
char array[TIFFAILSTRLEN];
snprintf(array, sizeof(array), "tag %u count=%u, tag %u count=%u", TIFFTAG_STRIPOFFSETS,
stripoffsets_entry.count, TIFFTAG_STRIPBYTECOUNTS, stripbytescounts_entry.count);
ret = set_value_found_ret(&ret, array);
ret.returncode = ifderror_different_cardinality;
return ret;
}
}
ret.returncode=is_valid;
return ret;
}
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 smarttab expandtab :*/

+ 6
- 0
src/messages/msg_parser.c View File

@@ -34,7 +34,9 @@ const char * get_parser_function_name( function_t f ) {
case fc_internal_logic_combine_close: return "fc_internal_logic_combine_close"; break;
case fc_all_offsets_are_not_zero: return "fc_all_offsets_are_not_zero"; break;
case fc_all_geotiff_tags_have_same_count_of_values: return "fc_all_geotiff_tags_have_same_count_of_values"; break;
case fc_check_cardinality: return "fc_check_cardinality"; break;
case fc_dummy: return "fc_dummy"; break;
default: ;
}
return "missed function description, should not occur";
}
@@ -65,7 +67,9 @@ const char * get_parser_function_description( function_t f ) {
case fc_internal_logic_combine_close: return "One or more conditions needs to be combined in a logical_or operation (close)"; break;
case fc_all_offsets_are_not_zero: return "All tag offsets should be greater than zero,"; break;
case fc_all_geotiff_tags_have_same_count_of_values: return "All GeoTIFF tags should have same amount of values,"; break;
case fc_check_cardinality: return "Cardinality of tags should be equal,"; break;
case fc_dummy: return "Dummy."; break;
default: ;
}
return "missed function description, should not occur";
}
@@ -130,6 +134,8 @@ const char * get_parser_error_description( returncode_t r ) {
case tagerror_offset_is_zero: return "but an offset zero is used."; break;
case tagerror_expected_count_not_a_multiple_of_four: return "unexpected tag count value, should be a multiple of four."; break;
case tagerror_expected_count_less_than_four: return "unexpected tag count value, should be at least four."; break;
case ifderror_different_cardinality: return "but counts of values are different."; break;
default: ;
}
assert( r == is_valid ); /* missed error description, should not occur */
return "missed error description, should not occur";


+ 153
- 131
src/parser/config_dsl.grammar.c View File

@@ -3,7 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define YYRULECOUNT 43
#define YYRULECOUNT 46
#ifndef YY_MALLOC
#define YY_MALLOC(C, N) malloc(N)
#endif
@@ -272,42 +272,45 @@ YY_LOCAL(void) yySet(yycontext *yy, char *text, int count) { yy->__val[count]=

#define YYACCEPT yyAccept(yy, yythunkpos0)

YY_RULE(int) yy_EscapedPCRE(yycontext *yy); /* 43 */
YY_RULE(int) yy_PCRE(yycontext *yy); /* 42 */
YY_RULE(int) yy_Value(yycontext *yy); /* 41 */
YY_RULE(int) yy_ValueList(yycontext *yy); /* 40 */
YY_RULE(int) yy_Digit(yycontext *yy); /* 39 */
YY_RULE(int) yy_Iccprofile(yycontext *yy); /* 38 */
YY_RULE(int) yy_Datetime(yycontext *yy); /* 37 */
YY_RULE(int) yy_ValueReference(yycontext *yy); /* 36 */
YY_RULE(int) yy_Dot(yycontext *yy); /* 35 */
YY_RULE(int) yy_OptDepends(yycontext *yy); /* 34 */
YY_RULE(int) yy_IfDepends(yycontext *yy); /* 33 */
YY_RULE(int) yy_Space(yycontext *yy); /* 32 */
YY_RULE(int) yy_TagReference(yycontext *yy); /* 31 */
YY_RULE(int) yy_Content(yycontext *yy); /* 30 */
YY_RULE(int) yy_Requirements(yycontext *yy); /* 29 */
YY_RULE(int) yy_Semicolon(yycontext *yy); /* 28 */
YY_RULE(int) yy_Tag(yycontext *yy); /* 27 */
YY_RULE(int) yy_Colon(yycontext *yy); /* 26 */
YY_RULE(int) yy_PrintableAscii(yycontext *yy); /* 25 */
YY_RULE(int) yy_RegEx(yycontext *yy); /* 24 */
YY_RULE(int) yy_NTupel(yycontext *yy); /* 23 */
YY_RULE(int) yy_Number(yycontext *yy); /* 22 */
YY_RULE(int) yy_Only(yycontext *yy); /* 21 */
YY_RULE(int) yy_Range(yycontext *yy); /* 20 */
YY_RULE(int) yy_Any(yycontext *yy); /* 19 */
YY_RULE(int) yy_LogicalOrListElement(yycontext *yy); /* 18 */
YY_RULE(int) yy_LogicalOrClose(yycontext *yy); /* 17 */
YY_RULE(int) yy_LogicalOrList(yycontext *yy); /* 16 */
YY_RULE(int) yy_LogicalOrOpen(yycontext *yy); /* 15 */
YY_RULE(int) yy_LogicalOr(yycontext *yy); /* 14 */
YY_RULE(int) yy_Mode(yycontext *yy); /* 13 */
YY_RULE(int) yy_ClosingBracket(yycontext *yy); /* 12 */
YY_RULE(int) yy_EscapedPCRE(yycontext *yy); /* 46 */
YY_RULE(int) yy_PCRE(yycontext *yy); /* 45 */
YY_RULE(int) yy_Value(yycontext *yy); /* 44 */
YY_RULE(int) yy_ValueList(yycontext *yy); /* 43 */
YY_RULE(int) yy_Digit(yycontext *yy); /* 42 */
YY_RULE(int) yy_Iccprofile(yycontext *yy); /* 41 */
YY_RULE(int) yy_Datetime(yycontext *yy); /* 40 */
YY_RULE(int) yy_ValueReference(yycontext *yy); /* 39 */
YY_RULE(int) yy_Dot(yycontext *yy); /* 38 */
YY_RULE(int) yy_OptDepends(yycontext *yy); /* 37 */
YY_RULE(int) yy_IfDepends(yycontext *yy); /* 36 */
YY_RULE(int) yy_Space(yycontext *yy); /* 35 */
YY_RULE(int) yy_TagReference(yycontext *yy); /* 34 */
YY_RULE(int) yy_Content(yycontext *yy); /* 33 */
YY_RULE(int) yy_Requirements(yycontext *yy); /* 32 */
YY_RULE(int) yy_Semicolon(yycontext *yy); /* 31 */
YY_RULE(int) yy_Tag(yycontext *yy); /* 30 */
YY_RULE(int) yy_Colon(yycontext *yy); /* 29 */
YY_RULE(int) yy_PrintableAscii(yycontext *yy); /* 28 */
YY_RULE(int) yy_RegEx(yycontext *yy); /* 27 */
YY_RULE(int) yy_NTupel(yycontext *yy); /* 26 */
YY_RULE(int) yy_Number(yycontext *yy); /* 25 */
YY_RULE(int) yy_Only(yycontext *yy); /* 24 */
YY_RULE(int) yy_Range(yycontext *yy); /* 23 */
YY_RULE(int) yy_Any(yycontext *yy); /* 22 */
YY_RULE(int) yy_LogicalOrListElement(yycontext *yy); /* 21 */
YY_RULE(int) yy_LogicalOrClose(yycontext *yy); /* 20 */
YY_RULE(int) yy_LogicalOrList(yycontext *yy); /* 19 */
YY_RULE(int) yy_LogicalOrOpen(yycontext *yy); /* 18 */
YY_RULE(int) yy_LogicalOr(yycontext *yy); /* 17 */
YY_RULE(int) yy_Mode(yycontext *yy); /* 16 */
YY_RULE(int) yy_Subpath(yycontext *yy); /* 15 */
YY_RULE(int) yy_SlashorBackslash(yycontext *yy); /* 14 */
YY_RULE(int) yy_ClosingBracket(yycontext *yy); /* 13 */
YY_RULE(int) yy_Path(yycontext *yy); /* 12 */
YY_RULE(int) yy_OpenBracket(yycontext *yy); /* 11 */
YY_RULE(int) yy_SpaceLine(yycontext *yy); /* 10 */
YY_RULE(int) yy_IncludeLine(yycontext *yy); /* 9 */
YY_RULE(int) yy_CommentLine(yycontext *yy); /* 8 */
YY_RULE(int) yy_CommentLine(yycontext *yy); /* 9 */
YY_RULE(int) yy_IncludeLine(yycontext *yy); /* 8 */
YY_RULE(int) yy_ModeLine(yycontext *yy); /* 7 */
YY_RULE(int) yy_TagLine(yycontext *yy); /* 6 */
YY_RULE(int) yy_EndOfLine(yycontext *yy); /* 5 */
@@ -906,7 +909,7 @@ YY_ACTION(void) yy_1_ModeLine(yycontext *yy, char *yytext, int yyleng)
#define yythunkpos yy->__thunkpos
yyprintf((stderr, "do yy_1_ModeLine\n"));
{
int i = i_pop(); set_mode( i ); ;
unsigned int i = i_pop(); set_mode( i ); ;
}
#undef yythunkpos
#undef yypos
@@ -919,7 +922,7 @@ YY_ACTION(void) yy_1_IncludeLine(yycontext *yy, char *yytext, int yyleng)
#define yythunkpos yy->__thunkpos
yyprintf((stderr, "do yy_1_IncludeLine\n"));
{
set_include ( yytext ); ;
set_include ( yytext ); ;
}
#undef yythunkpos
#undef yypos
@@ -938,19 +941,6 @@ YY_ACTION(void) yy_1_CommentLine(yycontext *yy, char *yytext, int yyleng)
#undef yypos
#undef yy
}
YY_ACTION(void) yy_1_Line(yycontext *yy, char *yytext, int yyleng)
{
#define __ yy->__
#define yypos yy->__pos
#define yythunkpos yy->__thunkpos
yyprintf((stderr, "do yy_1_Line\n"));
{
fprintf(stderr, "grammar parser error at line %i (error at '%s')\n", parser_state.lineno, yytext); exit(EXIT_FAILURE); ;
}
#undef yythunkpos
#undef yypos
#undef yy
}

YY_RULE(int) yy_EscapedPCRE(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
@@ -1397,185 +1387,217 @@ YY_RULE(int) yy_Mode(yycontext *yy)
yyprintf((stderr, " fail %s @ %s\n", "Mode", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_Subpath(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "Subpath"));
{ int yypos91= yy->__pos, yythunkpos91= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l92; goto l91;
l92:; yy->__pos= yypos91; yy->__thunkpos= yythunkpos91; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\000\000\000\000\000\000\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l93; goto l91;
l93:; yy->__pos= yypos91; yy->__thunkpos= yythunkpos91; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l94; goto l91;
l94:; yy->__pos= yypos91; yy->__thunkpos= yythunkpos91; if (!yymatchChar(yy, '.')) goto l95; goto l91;
l95:; yy->__pos= yypos91; yy->__thunkpos= yythunkpos91; if (!yymatchChar(yy, '_')) goto l96; goto l91;
l96:; yy->__pos= yypos91; yy->__thunkpos= yythunkpos91; if (!yymatchChar(yy, '-')) goto l97; goto l91;
l97:; yy->__pos= yypos91; yy->__thunkpos= yythunkpos91; if (!yy_SlashorBackslash(yy)) goto l90;
}
l91:;
yyprintf((stderr, " ok %s @ %s\n", "Subpath", yy->__buf+yy->__pos));
return 1;
l90:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "Subpath", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_SlashorBackslash(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "SlashorBackslash"));
{ int yypos99= yy->__pos, yythunkpos99= yy->__thunkpos; if (!yymatchChar(yy, '/')) goto l100; goto l99;
l100:; yy->__pos= yypos99; yy->__thunkpos= yythunkpos99; if (!yymatchChar(yy, '\\')) goto l98;
}
l99:;
yyprintf((stderr, " ok %s @ %s\n", "SlashorBackslash", yy->__buf+yy->__pos));
return 1;
l98:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "SlashorBackslash", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_ClosingBracket(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "ClosingBracket")); if (!yymatchChar(yy, ')')) goto l90;
yyprintf((stderr, "%s\n", "ClosingBracket")); if (!yymatchChar(yy, ')')) goto l101;
yyprintf((stderr, " ok %s @ %s\n", "ClosingBracket", yy->__buf+yy->__pos));
return 1;
l90:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
l101:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "ClosingBracket", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_Path(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "Path")); if (!yy_Subpath(yy)) goto l102;
l103:;
{ int yypos104= yy->__pos, yythunkpos104= yy->__thunkpos; if (!yy_Subpath(yy)) goto l104; goto l103;
l104:; yy->__pos= yypos104; yy->__thunkpos= yythunkpos104;
}
yyprintf((stderr, " ok %s @ %s\n", "Path", yy->__buf+yy->__pos));
return 1;
l102:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "Path", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_OpenBracket(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "OpenBracket")); if (!yymatchChar(yy, '(')) goto l91;
yyprintf((stderr, "%s\n", "OpenBracket")); if (!yymatchChar(yy, '(')) goto l105;
yyprintf((stderr, " ok %s @ %s\n", "OpenBracket", yy->__buf+yy->__pos));
return 1;
l91:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
l105:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "OpenBracket", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_SpaceLine(yycontext *yy)
{
yyprintf((stderr, "%s\n", "SpaceLine"));
l93:;
{ int yypos94= yy->__pos, yythunkpos94= yy->__thunkpos; if (!yy_Space(yy)) goto l94; goto l93;
l94:; yy->__pos= yypos94; yy->__thunkpos= yythunkpos94;
l107:;
{ int yypos108= yy->__pos, yythunkpos108= yy->__thunkpos; if (!yy_Space(yy)) goto l108; goto l107;
l108:; yy->__pos= yypos108; yy->__thunkpos= yythunkpos108;
}
yyprintf((stderr, " ok %s @ %s\n", "SpaceLine", yy->__buf+yy->__pos));
return 1;
}
YY_RULE(int) yy_IncludeLine(yycontext *yy)
YY_RULE(int) yy_CommentLine(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "IncludeLine")); if (!yymatchString(yy, "include")) goto l95; if (!yy_OpenBracket(yy)) goto l95; yyText(yy, yy->__begin, yy->__end); {
yyprintf((stderr, "%s\n", "CommentLine")); if (!yymatchChar(yy, '#')) goto l109; yyText(yy, yy->__begin, yy->__end); {
#define yytext yy->__text
#define yyleng yy->__textlen
if (!(YY_BEGIN)) goto l95;
if (!(YY_BEGIN)) goto l109;
#undef yytext
#undef yyleng
} if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\340\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l95;
l96:;
{ int yypos97= yy->__pos, yythunkpos97= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\000\000\000\000\000\340\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l97; goto l96;
l97:; yy->__pos= yypos97; yy->__thunkpos= yythunkpos97;
}
l110:;
{ int yypos111= yy->__pos, yythunkpos111= yy->__thunkpos;
{ int yypos112= yy->__pos, yythunkpos112= yy->__thunkpos; if (!yy_EndOfLine(yy)) goto l112; goto l111;
l112:; yy->__pos= yypos112; yy->__thunkpos= yythunkpos112;
} if (!yymatchDot(yy)) goto l111; goto l110;
l111:; yy->__pos= yypos111; yy->__thunkpos= yythunkpos111;
} yyText(yy, yy->__begin, yy->__end); {
#define yytext yy->__text
#define yyleng yy->__textlen
if (!(YY_END)) goto l95;
if (!(YY_END)) goto l109;
#undef yytext
#undef yyleng
} if (!yy_ClosingBracket(yy)) goto l95; yyDo(yy, yy_1_IncludeLine, yy->__begin, yy->__end);
yyprintf((stderr, " ok %s @ %s\n", "IncludeLine", yy->__buf+yy->__pos));
} yyDo(yy, yy_1_CommentLine, yy->__begin, yy->__end);
yyprintf((stderr, " ok %s @ %s\n", "CommentLine", yy->__buf+yy->__pos));
return 1;
l95:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "IncludeLine", yy->__buf+yy->__pos));
l109:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "CommentLine", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_CommentLine(yycontext *yy)
YY_RULE(int) yy_IncludeLine(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "CommentLine")); if (!yymatchChar(yy, '#')) goto l98;
l99:;
{ int yypos100= yy->__pos, yythunkpos100= yy->__thunkpos;
{ int yypos101= yy->__pos, yythunkpos101= yy->__thunkpos; if (!yy_EndOfLine(yy)) goto l101; goto l100;
l101:; yy->__pos= yypos101; yy->__thunkpos= yythunkpos101;
} if (!yymatchDot(yy)) goto l100; goto l99;
l100:; yy->__pos= yypos100; yy->__thunkpos= yythunkpos100;
} yyDo(yy, yy_1_CommentLine, yy->__begin, yy->__end);
yyprintf((stderr, " ok %s @ %s\n", "CommentLine", yy->__buf+yy->__pos));
yyprintf((stderr, "%s\n", "IncludeLine")); if (!yymatchString(yy, "include")) goto l113; if (!yy_OpenBracket(yy)) goto l113; yyText(yy, yy->__begin, yy->__end); {
#define yytext yy->__text
#define yyleng yy->__textlen
if (!(YY_BEGIN)) goto l113;
#undef yytext
#undef yyleng
} if (!yy_Path(yy)) goto l113; yyText(yy, yy->__begin, yy->__end); {
#define yytext yy->__text
#define yyleng yy->__textlen
if (!(YY_END)) goto l113;
#undef yytext
#undef yyleng
} if (!yy_ClosingBracket(yy)) goto l113; yyDo(yy, yy_1_IncludeLine, yy->__begin, yy->__end);
yyprintf((stderr, " ok %s @ %s\n", "IncludeLine", yy->__buf+yy->__pos));
return 1;
l98:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "CommentLine", yy->__buf+yy->__pos));
l113:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "IncludeLine", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_ModeLine(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "ModeLine")); if (!yymatchString(yy, "mode")) goto l102; if (!yy_OpenBracket(yy)) goto l102; yyText(yy, yy->__begin, yy->__end); {
yyprintf((stderr, "%s\n", "ModeLine")); if (!yymatchString(yy, "mode")) goto l114; if (!yy_OpenBracket(yy)) goto l114; yyText(yy, yy->__begin, yy->__end); {
#define yytext yy->__text
#define yyleng yy->__textlen
if (!(YY_BEGIN)) goto l102;
if (!(YY_BEGIN)) goto l114;
#undef yytext
#undef yyleng
} if (!yy_Mode(yy)) goto l102; yyText(yy, yy->__begin, yy->__end); {
} if (!yy_Mode(yy)) goto l114; yyText(yy, yy->__begin, yy->__end); {
#define yytext yy->__text
#define yyleng yy->__textlen
if (!(YY_END)) goto l102;
if (!(YY_END)) goto l114;
#undef yytext
#undef yyleng
} if (!yy_ClosingBracket(yy)) goto l102; yyDo(yy, yy_1_ModeLine, yy->__begin, yy->__end);
} if (!yy_ClosingBracket(yy)) goto l114; yyDo(yy, yy_1_ModeLine, yy->__begin, yy->__end);
yyprintf((stderr, " ok %s @ %s\n", "ModeLine", yy->__buf+yy->__pos));
return 1;
l102:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
l114:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "ModeLine", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_TagLine(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "TagLine"));
{ int yypos104= yy->__pos, yythunkpos104= yy->__thunkpos; if (!yy_Tag(yy)) goto l105; if (!yy_Semicolon(yy)) goto l105; if (!yy_Requirements(yy)) goto l105; if (!yy_Semicolon(yy)) goto l105; if (!yy_Content(yy)) goto l105; yyDo(yy, yy_1_TagLine, yy->__begin, yy->__end); goto l104;
l105:; yy->__pos= yypos104; yy->__thunkpos= yythunkpos104; if (!yy_Tag(yy)) goto l103; if (!yy_Semicolon(yy)) goto l103; if (!yy_Requirements(yy)) goto l103; if (!yy_Semicolon(yy)) goto l103; if (!yy_LogicalOr(yy)) goto l103; yyDo(yy, yy_2_TagLine, yy->__begin, yy->__end);
{ int yypos116= yy->__pos, yythunkpos116= yy->__thunkpos; if (!yy_Tag(yy)) goto l117; if (!yy_Semicolon(yy)) goto l117; if (!yy_Requirements(yy)) goto l117; if (!yy_Semicolon(yy)) goto l117; if (!yy_Content(yy)) goto l117; yyDo(yy, yy_1_TagLine, yy->__begin, yy->__end); goto l116;
l117:; yy->__pos= yypos116; yy->__thunkpos= yythunkpos116; if (!yy_Tag(yy)) goto l115; if (!yy_Semicolon(yy)) goto l115; if (!yy_Requirements(yy)) goto l115; if (!yy_Semicolon(yy)) goto l115; if (!yy_LogicalOr(yy)) goto l115; yyDo(yy, yy_2_TagLine, yy->__begin, yy->__end);
}
l104:;
l116:;
yyprintf((stderr, " ok %s @ %s\n", "TagLine", yy->__buf+yy->__pos));
return 1;
l103:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
l115:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "TagLine", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_EndOfLine(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "EndOfLine")); if (!yymatchClass(yy, (unsigned char *)"\000\044\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l106; yyDo(yy, yy_1_EndOfLine, yy->__begin, yy->__end);
yyprintf((stderr, "%s\n", "EndOfLine")); if (!yymatchClass(yy, (unsigned char *)"\000\044\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l118; yyDo(yy, yy_1_EndOfLine, yy->__begin, yy->__end);
yyprintf((stderr, " ok %s @ %s\n", "EndOfLine", yy->__buf+yy->__pos));
return 1;
l106:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
l118:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "EndOfLine", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_LineType(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "LineType"));
{ int yypos108= yy->__pos, yythunkpos108= yy->__thunkpos; if (!yy_TagLine(yy)) goto l109; goto l108;
l109:; yy->__pos= yypos108; yy->__thunkpos= yythunkpos108; if (!yy_ModeLine(yy)) goto l110; goto l108;
l110:; yy->__pos= yypos108; yy->__thunkpos= yythunkpos108; if (!yy_CommentLine(yy)) goto l111; goto l108;
l111:; yy->__pos= yypos108; yy->__thunkpos= yythunkpos108; if (!yy_IncludeLine(yy)) goto l112; goto l108;
l112:; yy->__pos= yypos108; yy->__thunkpos= yythunkpos108; if (!yy_SpaceLine(yy)) goto l107;
{ int yypos120= yy->__pos, yythunkpos120= yy->__thunkpos; if (!yy_TagLine(yy)) goto l121; goto l120;
l121:; yy->__pos= yypos120; yy->__thunkpos= yythunkpos120; if (!yy_ModeLine(yy)) goto l122; goto l120;
l122:; yy->__pos= yypos120; yy->__thunkpos= yythunkpos120; if (!yy_IncludeLine(yy)) goto l123; goto l120;
l123:; yy->__pos= yypos120; yy->__thunkpos= yythunkpos120; if (!yy_CommentLine(yy)) goto l124; goto l120;
l124:; yy->__pos= yypos120; yy->__thunkpos= yythunkpos120; if (!yy_SpaceLine(yy)) goto l119;
}
l108:;
l120:;
yyprintf((stderr, " ok %s @ %s\n", "LineType", yy->__buf+yy->__pos));
return 1;
l107:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
l119:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "LineType", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_EndOfFile(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "EndOfFile"));
{ int yypos114= yy->__pos, yythunkpos114= yy->__thunkpos; if (!yymatchDot(yy)) goto l114; goto l113;
l114:; yy->__pos= yypos114; yy->__thunkpos= yythunkpos114;
{ int yypos126= yy->__pos, yythunkpos126= yy->__thunkpos; if (!yymatchDot(yy)) goto l126; goto l125;
l126:; yy->__pos= yypos126; yy->__thunkpos= yythunkpos126;
}
yyprintf((stderr, " ok %s @ %s\n", "EndOfFile", yy->__buf+yy->__pos));
return 1;
l113:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
l125:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "EndOfFile", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_Line(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "Line"));
{ int yypos116= yy->__pos, yythunkpos116= yy->__thunkpos; if (!yy_LineType(yy)) goto l117; if (!yy_EndOfLine(yy)) goto l117; goto l116;
l117:; yy->__pos= yypos116; yy->__thunkpos= yythunkpos116; yyText(yy, yy->__begin, yy->__end); {
#define yytext yy->__text
#define yyleng yy->__textlen
if (!(YY_BEGIN)) goto l115;
#undef yytext
#undef yyleng
} if (!yymatchClass(yy, (unsigned char *)"\377\333\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l115;
l118:;
{ int yypos119= yy->__pos, yythunkpos119= yy->__thunkpos; if (!yymatchClass(yy, (unsigned char *)"\377\333\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377")) goto l119; goto l118;
l119:; yy->__pos= yypos119; yy->__thunkpos= yythunkpos119;
} yyText(yy, yy->__begin, yy->__end); {
#define yytext yy->__text
#define yyleng yy->__textlen
if (!(YY_END)) goto l115;
#undef yytext
#undef yyleng
} if (!yy_EndOfLine(yy)) goto l115; yyDo(yy, yy_1_Line, yy->__begin, yy->__end);
}
l116:;
yyprintf((stderr, "%s\n", "Line")); if (!yy_LineType(yy)) goto l127; if (!yy_EndOfLine(yy)) goto l127;
yyprintf((stderr, " ok %s @ %s\n", "Line", yy->__buf+yy->__pos));
return 1;
l115:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
l127:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "Line", yy->__buf+yy->__pos));
return 0;
}
YY_RULE(int) yy_start(yycontext *yy)
{ int yypos0= yy->__pos, yythunkpos0= yy->__thunkpos;
yyprintf((stderr, "%s\n", "start")); if (!yy_Line(yy)) goto l120;
l121:;
{ int yypos122= yy->__pos, yythunkpos122= yy->__thunkpos; if (!yy_Line(yy)) goto l122; goto l121;
l122:; yy->__pos= yypos122; yy->__thunkpos= yythunkpos122;
} if (!yy_EndOfFile(yy)) goto l120;
yyprintf((stderr, "%s\n", "start")); if (!yy_Line(yy)) goto l128;
l129:;
{ int yypos130= yy->__pos, yythunkpos130= yy->__thunkpos; if (!yy_Line(yy)) goto l130; goto l129;
l130:; yy->__pos= yypos130; yy->__thunkpos= yythunkpos130;
} if (!yy_EndOfFile(yy)) goto l128;
yyprintf((stderr, " ok %s @ %s\n", "start", yy->__buf+yy->__pos));
return 1;
l120:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
l128:; yy->__pos= yypos0; yy->__thunkpos= yythunkpos0;
yyprintf((stderr, " fail %s @ %s\n", "start", yy->__buf+yy->__pos));
return 0;
}


+ 24
- 5
src/parser/config_dsl.grammar.peg View File

@@ -8,14 +8,30 @@
#
start <- ( Line )+ EndOfFile
Line <- LineType EndOfLine
/ < [^\r\n]+ > EndOfLine {fprintf(stderr, "grammar parser error at line %i (error at '%s')\n", parser_state.lineno, yytext); exit(EXIT_FAILURE); }
# / < [^\r\n]+ > EndOfLine {fprintf(stderr, "grammar parser error at line %i (error at '%s')\n", parser_state.lineno, yytext); exit(EXIT_FAILURE); }
LineType <- TagLine
/ ModeLine
/ CommentLine
/ IncludeLine
/ CommentLine
/ SpaceLine
CommentLine <- '#' ( !EndOfLine .)* { commentline(); }
IncludeLine <- 'include' OpenBracket < ( [A-Za-z0-9_./\-]+ ) > ClosingBracket { set_include ( yytext ); }
CommentLine <- '#' < ( !EndOfLine .)* > { commentline(); }

IncludeLine <- 'include' OpenBracket < Path > ClosingBracket { set_include ( yytext ); }

SlashorBackslash <- '/'
/ '\\'

Path <- ( Subpath )+

Subpath <- [A-Z]
/ [a-z]
/ [0-9]
/ '.'
/ '_'
/ '-'
/ SlashorBackslash

ModeLine <- 'mode' OpenBracket < Mode > ClosingBracket { int i = i_pop(); set_mode( i ); }
LogicalOr <- 'logical_or' LogicalOrOpen LogicalOrList LogicalOrClose

@@ -72,10 +88,13 @@ Content <- Any { v_push( any );
/ Datetime { v_push( datetime ); }
/ Iccprofile { v_push( iccprofile ); }
# / SBit { v_push( sbit ); }

Range <- 'range' OpenBracket Number Colon Number ClosingBracket
Number <- < '0x' ( [0-9a-f]+ ) > { i_push(strtol(yytext, NULL, 0) ); }

Number <- < '0x' [0-9a-f]+ > { i_push(strtol(yytext, NULL, 0) ); }
/ '2^' < ( Digit )+ > { i_push(2<<atol(yytext) ); }
/ < ( Digit )+ > { i_push(atol(yytext) );}

Colon <- ',' (Space )*
Dot <- '.' (Space )*
OpenBracket <- '('


+ 156
- 135
src/parser/config_parser.c View File

@@ -12,7 +12,6 @@
#include <string.h>
#include <assert.h>
#include "config_parser.h"
#include "check.h"
#include "check_helper.h"
#include "msg_parser.h"
#include <pcre.h>
@@ -32,7 +31,7 @@ parser_state_t parser_state;
#define YY_INPUT(yyctx, buf, result, max_size) \
{ \
int yyc= fgetc(parser_state.stream); \
result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \
(result)= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \
yyprintf((stderr, "<%c>", yyc)); \
}

@@ -84,7 +83,7 @@ void print_plan () {
CHECKOVERFLOW(SPACE_P, NAME) \
CHECKUNDERFLOW(SPACE_P, NAME) \
for (int j=0; j< (SPACE_P)->NAME ## _stackp; j++)\
printf(" " #SPACE_P "->" #NAME "-stack value[ %i ] --> %s\n", j, VSTRINGARRAY[(SPACE_P)->NAME ## _stack[j]]);\
printf(" " #SPACE_P "->" #NAME "-stack value[ %i ] --> %s\n", j, (VSTRINGARRAY)[(SPACE_P)->NAME ## _stack[j]]);\
//endmacro PRINTV


@@ -124,8 +123,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 +216,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 +244,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 +279,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,14 +293,14 @@ 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;
}


ret_t call_exec_function(ctiff_t * ctif, ret_t * retp, internal_entry_t * exep) {
ret_t ret = *retp;
internal_entry_t exe = *exep;
@@ -300,34 +308,34 @@ ret_t call_exec_function(ctiff_t * ctif, ret_t * retp, internal_entry_t * exep)
switch (exe.function) {
case fc_true: { ret.returncode=is_valid; break;}
case fc_false: { ret.returncode=is_error; break; }
case fc_tag_has_some_of_these_values: { int count = exe_i_pop(&exe);
case fc_tag_has_some_of_these_values: { unsigned int count = exe_i_pop(&exe);
unsigned int values[count];
expected_value = __ch_malloc(expected_value);
char * strp = expected_value;
for (int j=0; j<count; j++) values[j]=exe_i_pop(&exe);
for (unsigned int j=0; j<count; j++) values[j]=exe_i_pop(&exe);
int all_printed = 0;
int printed = snprintf(strp, VALUESTRLEN, "count=%i, values ", count);
strp+=printed;
all_printed+=printed;
for (int j=0; j<count; j++) {
for (unsigned int j=0; j<count; j++) {
/* reduce VALUESTRLEN with n*printed */
printed = snprintf(strp, VALUESTRLEN-all_printed, " [%i]=%u",j, values[j]);
printed = snprintf(strp, (size_t) (VALUESTRLEN - all_printed), " [%i]=%u", j, values[j]);
strp+=printed;
all_printed+=printed;
}
ret = check_tag_has_some_of_these_values(ctif, exe.tag, count, values);
break;
}
case fc_tag_has_valuelist: { int count = exe_i_pop(&exe);
case fc_tag_has_valuelist: { unsigned int count = exe_i_pop(&exe);