Commit 1ce8302e authored by Tomáš Stefan's avatar Tomáš Stefan

output changes to libpdfsigil.so

Moved sigil_err_string to sigil.h, where all the public funcitons are
parent 6b8c06a3
......@@ -17,17 +17,17 @@ file(GLOB LIB_SRC "lib/*.c")
set (TEST_SRC "test/test.c")
# build both static and shared library
add_library(pdf-sigil_static STATIC ${LIB_SRC})
add_library(pdf-sigil_shared SHARED ${LIB_SRC})
add_library(pdfsigil_static STATIC ${LIB_SRC})
add_library(pdfsigil SHARED ${LIB_SRC})
#target_link_libraries(pdf-sigil_static ${OPENSSL_LIBRARIES} dl pthread)
#target_link_libraries(pdf-sigil_shared ${OPENSSL_LIBRARIES} dl pthread)
target_link_libraries(pdf-sigil_static crypto)
target_link_libraries(pdf-sigil_shared crypto)
target_link_libraries(pdfsigil_static crypto)
target_link_libraries(pdfsigil crypto)
# build selftest executable
add_executable(selftest ${TEST_SRC})
target_link_libraries(selftest pdf-sigil_static)
target_link_libraries(selftest pdfsigil)
# running selftest
add_custom_target(run_tests ALL
......
......@@ -10,15 +10,16 @@ Word **sigil** in name stands for latin word *sigillum*, which means **seal** or
Performs build with output into "build" directory. After those steps, there will be a **static and shared library** and also **selftest executable**.
```shell
cmake -E make_directory build
cmake -E chdir build cmake ..
cmake -E chdir build make
mkdir build
cd build
cmake ..
make
```
The selftest is run automatically during the make, but if you want to re-run it, use one of the following commands:
The selftest is run automatically during the make, but if you want to re-run it, use one of the following commands (from the build directory):
```shell
cmake -E chdir build make run_tests # producing default output level
cmake -E chdir build make run_tests_verbose # verbose output level
cmake -E chdir build make run_tests_quiet # without output
make run_tests # producing default output level
make run_tests_verbose # verbose output level
make run_tests_quiet # without output
```
......@@ -37,8 +37,6 @@ sigil_err_t parse_ref_array(sigil_t *sgl, ref_array_t *ref_array);
sigil_err_t reference_to_offset(sigil_t *sgl, const reference_t *ref, size_t *result);
const char *sigil_err_string(sigil_err_t err);
void print_module_name(const char *module_name, int verbosity);
void print_module_result(int result, int verbosity);
void print_test_item(const char *test_name, int verbosity);
......
......@@ -10,7 +10,7 @@ sigil_err_t sigil_set_pdf_file(sigil_t *sgl, FILE *pdf_file);
sigil_err_t sigil_set_pdf_path(sigil_t *sgl, const char *path_to_pdf);
sigil_err_t sigil_set_pdf_buffer(sigil_t *sgl, char *pdf_content, size_t size);
sigil_err_t sigil_set_trusted_default_system(sigil_t *sgl);
sigil_err_t sigil_set_trusted_system(sigil_t *sgl);
sigil_err_t sigil_set_trusted_file(sigil_t *sgl, const char *path_to_file);
sigil_err_t sigil_set_trusted_dir(sigil_t *sgl, const char *path_to_dir);
......@@ -29,6 +29,8 @@ void contents_free(sigil_t *sgl);
void sigil_free(sigil_t **sgl);
const char *sigil_err_string(sigil_err_t err);
int sigil_sigil_self_test(int verbosity);
#endif /* PDF_SIGIL_SIGIL_H */
......@@ -628,36 +628,6 @@ sigil_err_t reference_to_offset(sigil_t *sgl, const reference_t *ref, size_t *re
return ERR_NO_DATA;
}
const char *sigil_err_string(sigil_err_t err)
{
switch (err) {
case ERR_NO:
return "finished without any error";
case ERR_ALLOCATION:
return "ERROR during allocation";
case ERR_PARAMETER:
return "ERROR bad data between function parameters";
case ERR_IO:
return "ERROR during performing input/output operation";
case ERR_PDF_CONTENT:
return "ERROR unexpected data on input, probably corrupted PDF file";
case ERR_NOT_IMPLEMENTED:
return "ERROR this functionality is not currently available";
case ERR_NO_DATA:
return "ERROR no data available";
case ERR_END_OF_DICT:
return "ERROR end of dictionary occured while processing it's content";
case ERR_NO_SIGNATURE:
return "ERROR this file appears to be missing the signature";
case ERR_OPENSSL:
return "ERROR something bad happened inside of OpenSSL functionality";
case ERR_DIGEST_TYPE:
return "ERROR the signature is using not standard message digest";
default:
return "ERROR unknown";
}
}
void print_module_name(const char *module_name, int verbosity)
{
if (verbosity < 1 || module_name == NULL)
......
......@@ -237,7 +237,7 @@ sigil_err_t load_digest(sigil_t *sgl)
const X509_ALGOR *tmp_alg = NULL;
const ASN1_OCTET_STRING *tmp_hash = NULL;
if (sgl == NULL || sgl->contents == NULL || sgl->certificates)
if (sgl == NULL || sgl->contents == NULL || sgl->certificates == NULL)
return ERR_PARAMETER;
contents = sgl->contents->contents_hex;
......
......@@ -189,7 +189,7 @@ sigil_err_t sigil_set_pdf_buffer(sigil_t *sgl, char *pdf_content, size_t size)
return ERR_NO;
}
sigil_err_t sigil_set_trusted_default_system(sigil_t *sgl)
sigil_err_t sigil_set_trusted_system(sigil_t *sgl)
{
if (sgl == NULL)
return ERR_PARAMETER;
......@@ -510,6 +510,36 @@ void sigil_free(sigil_t **sgl)
*sgl = NULL;
}
const char *sigil_err_string(sigil_err_t err)
{
switch (err) {
case ERR_NO:
return "finished without any error";
case ERR_ALLOCATION:
return "ERROR during allocation";
case ERR_PARAMETER:
return "ERROR bad data between function parameters";
case ERR_IO:
return "ERROR during performing input/output operation";
case ERR_PDF_CONTENT:
return "ERROR unexpected data on input, probably corrupted PDF file";
case ERR_NOT_IMPLEMENTED:
return "ERROR this functionality is not currently available";
case ERR_NO_DATA:
return "ERROR no data available";
case ERR_END_OF_DICT:
return "ERROR end of dictionary occured while processing it's content";
case ERR_NO_SIGNATURE:
return "ERROR this file appears to be missing the signature";
case ERR_OPENSSL:
return "ERROR something bad happened inside of OpenSSL functionality";
case ERR_DIGEST_TYPE:
return "ERROR the signature is using not standard message digest";
default:
return "ERROR unknown";
}
}
int sigil_sigil_self_test(int verbosity)
{
sigil_err_t err;
......@@ -559,7 +589,7 @@ int sigil_sigil_self_test(int verbosity)
if (sgl == NULL)
goto failed;
if (sigil_set_trusted_default_system(sgl) != ERR_NO)
if (sigil_set_trusted_system(sgl) != ERR_NO)
goto failed;
if (sigil_verify(sgl) != ERR_NO)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment