Commit 0c0bf2b3 authored by Tomáš Stefan's avatar Tomáš Stefan

code refactoring - comment unused labels, make fn static, ..

parent ec58ca86
......@@ -4,14 +4,8 @@ project(pdf_sigil)
set(CMAKE_C_STANDARD 11)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic")
# add OpenSSL
#set (OPENSSL_USE_STATIC_LIBS TRUE)
#include(FindOpenSSL)
#find_package(OpenSSL REQUIRED)
# header files
include_directories(include)
#include_directories(${OPENSSL_INCLUDE_DIR})
file(GLOB LIB_SRC "lib/*.c")
set (TEST_SRC "test/test.c")
......@@ -20,8 +14,6 @@ set (TEST_SRC "test/test.c")
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(pdfsigil_static crypto)
target_link_libraries(pdfsigil crypto)
......@@ -29,6 +21,17 @@ target_link_libraries(pdfsigil crypto)
add_executable(selftest ${TEST_SRC})
target_link_libraries(selftest pdfsigil)
# find Doxygen package for generating the documentation
find_package(Doxygen)
if (DOXYGEN_FOUND)
add_custom_target(doc ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating Doxygen documentation")
else (DOXYGEN_FOUND)
message("Install Doxygen for generation of the documentation")
endif (DOXYGEN_FOUND)
# running selftest
add_custom_target(run_tests ALL
COMMAND selftest
......
......@@ -15,6 +15,11 @@
*/
sigil_err_t parse_certs(sigil_t *sgl);
/** @brief Cleans-up the provided cert_t structure
*
*/
void cert_free(cert_t *cert);
/** @brief Tests for the cert module
*
* @param verbosity output level - 0 means nothing, 1 prints module names with
......
......@@ -14,6 +14,12 @@
*/
sigil_err_t parse_contents(sigil_t *sgl);
/** Cleans-up the contents entry from the context
*
* @param sgl context
*/
void contents_free(sigil_t *sgl);
/** @brief Tests for the contents module
*
* @param verbosity output level - 0 means nothing, 1 prints module names with
......
......@@ -7,17 +7,6 @@
#include "types.h"
/** @brief Converts hexadecimal characters to the decimal value. Operates with
* characters both on input and output, 2 chars on the input produces
* 1 char on the output
*
* @param in input - hexadecimal characters
* @param in_len length of the input
* @param out output buffer
* @param out_len length of the output written (without the terminating null)
* @return ERR_NONE if success
*/
sigil_err_t hex_to_dec(const char *in, size_t in_len, unsigned char *out, size_t *out_len);
void print_computed_hash(sigil_t *sgl);
......
......@@ -129,17 +129,6 @@ sigil_err_t sigil_get_computed_digest(sigil_t *sgl, ASN1_OCTET_STRING **digest);
*/
sigil_err_t sigil_get_subfilter(sigil_t *sgl, int *subfilter);
/** @brief Cleans-up the provided cert_t structure
*
*/
void cert_free(cert_t *cert);
/** Cleans-up the contents entry from the context
*
* @param sgl context
*/
void contents_free(sigil_t *sgl);
/** @brief Cleans-up the provided sigil context
*
* @param sgl context
......
......@@ -26,13 +26,6 @@ void xref_free(xref_t *xref);
*/
sigil_err_t read_startxref(sigil_t *sgl);
/** @brief Reads all the entries from the cross-reference table to the context
*
* @param sgl context
* @return ERR_NONE if success
*/
sigil_err_t read_xref_table(sigil_t *sgl);
/** @brief Does processing of the cross-reference section - determines type and
* reads the entries
*
......
......@@ -66,9 +66,11 @@ int sigil_acroform_self_test(int verbosity)
print_module_result(1, verbosity);
return 0;
/*
failed:
print_test_result(0, verbosity);
print_module_result(0, verbosity);
return 1;
*/
}
......@@ -82,9 +82,11 @@ int sigil_catalog_self_test(int verbosity)
print_module_result(1, verbosity);
return 0;
/*
failed:
print_test_result(0, verbosity);
print_module_result(0, verbosity);
return 1;
*/
}
\ No newline at end of file
......@@ -8,7 +8,7 @@
#include "sigil.h"
sigil_err_t parse_one_cert(sigil_t *sgl, cert_t **result)
static sigil_err_t parse_one_cert(sigil_t *sgl, cert_t **result)
{
sigil_err_t err;
char c;
......@@ -129,6 +129,22 @@ sigil_err_t parse_certs(sigil_t *sgl)
}
}
void cert_free(cert_t *cert)
{
if (cert == NULL)
return;
cert_free(cert->next);
if (cert->cert_hex != NULL)
free(cert->cert_hex);
if (cert->x509 != NULL)
X509_free(cert->x509);
free(cert);
}
int sigil_cert_self_test(int verbosity)
{
print_module_name("cert", verbosity);
......@@ -140,9 +156,11 @@ int sigil_cert_self_test(int verbosity)
print_module_result(1, verbosity);
return 0;
/*
failed:
print_test_result(0, verbosity);
print_module_result(0, verbosity);
return 1;
*/
}
\ No newline at end of file
......@@ -72,6 +72,18 @@ sigil_err_t parse_contents(sigil_t *sgl)
}
}
void contents_free(sigil_t *sgl)
{
if (sgl == NULL || sgl->contents == NULL)
return;
if (sgl->contents->contents_hex != NULL)
free(sgl->contents->contents_hex);
free(sgl->contents);
sgl->contents = NULL;
}
int sigil_contents_self_test(int verbosity)
{
print_module_name("contents", verbosity);
......@@ -83,9 +95,11 @@ int sigil_contents_self_test(int verbosity)
print_module_result(1, verbosity);
return 0;
/*
failed:
print_test_result(0, verbosity);
print_module_result(0, verbosity);
return 1;
*/
}
\ No newline at end of file
......@@ -10,7 +10,17 @@
#include "types.h"
sigil_err_t hex_to_dec(const char *in, size_t in_len, unsigned char *out, size_t *out_len)
/** @brief Converts hexadecimal characters to the decimal value. Operates with
* characters both on input and output, 2 chars on the input produces
* 1 char on the output
*
* @param in input - hexadecimal characters
* @param in_len length of the input
* @param out output buffer
* @param out_len length of the output written (without the terminating null)
* @return ERR_NONE if success
*/
static sigil_err_t hex_to_dec(const char *in, size_t in_len, unsigned char *out, size_t *out_len)
{
int first,
second;
......@@ -410,9 +420,11 @@ int sigil_cryptography_self_test(int verbosity)
print_module_result(1, verbosity);
return 0;
/*
failed:
print_test_result(0, verbosity);
print_module_result(0, verbosity);
return 1;
*/
}
\ No newline at end of file
......@@ -168,9 +168,11 @@ int sigil_sig_dict_self_test(int verbosity)
print_module_result(1, verbosity);
return 0;
/*
failed:
print_test_result(0, verbosity);
print_module_result(0, verbosity);
return 1;
*/
}
......@@ -130,9 +130,11 @@ int sigil_sig_field_self_test(int verbosity)
print_module_result(1, verbosity);
return 0;
/*
failed:
print_test_result(0, verbosity);
print_module_result(0, verbosity);
return 1;
*/
}
\ No newline at end of file
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <types.h>
#include "acroform.h"
#include "auxiliary.h"
#include "catalog.h"
#include "cert.h"
#include "config.h"
#include "constants.h"
#include "contents.h"
#include "cryptography.h"
#include "header.h"
#include "sig_dict.h"
......@@ -432,34 +433,6 @@ static void range_free(range_t *range)
free(range);
}
void cert_free(cert_t *cert)
{
if (cert == NULL)
return;
cert_free(cert->next);
if (cert->cert_hex != NULL)
free(cert->cert_hex);
if (cert->x509 != NULL)
X509_free(cert->x509);
free(cert);
}
void contents_free(sigil_t *sgl)
{
if (sgl == NULL || sgl->contents == NULL)
return;
if (sgl->contents->contents_hex != NULL)
free(sgl->contents->contents_hex);
free(sgl->contents);
sgl->contents = NULL;
}
void sigil_free(sigil_t **sgl)
{
if (sgl == NULL || *sgl == NULL)
......
......@@ -73,9 +73,11 @@ int sigil_trailer_self_test(int verbosity)
print_module_result(1, verbosity);
return 0;
/*
failed:
print_test_result(0, verbosity);
print_module_result(0, verbosity);
return 1;
*/
}
\ No newline at end of file
......@@ -147,7 +147,12 @@ sigil_err_t read_startxref(sigil_t *sgl)
return ERR_PDF_CONTENT;
}
sigil_err_t read_xref_table(sigil_t *sgl)
/** @brief Reads all the entries from the cross-reference table to the context
*
* @param sgl context
* @return ERR_NONE if success
*/
static sigil_err_t read_xref_table(sigil_t *sgl)
{
size_t section_start = 0,
section_cnt = 0,
......
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