Verified Commit 6bbfd2d7 authored by Tomáš Stefan's avatar Tomáš Stefan
Browse files

Squashed commit of the following:

// It started as branch for adding UTF-8 support, but ended differently

commit 3615313dcba1e70a7fec91df1c2f022a99bfd09a
Author: Tomáš Stefan <ts@stdin.cz>
Date:   Sat Mar 10 21:06:23 2018 +0100

    read all xref sections

    add fn parse_word and replace with it other specific ones
    store all xref entries for one object (different generation number)
    add fn skip_array

commit 98ecb7ab1cf17465e295d47b1bb2f12d62c28d78
Author: Tomáš Stefan <ts@stdin.cz>
Date:   Thu Mar 8 17:11:18 2018 +0100

    CMake improvements, Build instructions

commit f85f88dbee46453b6475269274734998e85e470d
Author: Tomáš Stefan <ts@stdin.cz>
Date:   Wed Mar 7 16:56:02 2018 +0100

    Minor corrections

    - add missing semicolon on WIN
    - no colour on platforms other than unix
    - signed/unsigned comparison corrections
    - processing fread in loop

commit 2513508e6397af93d0d89783e56744105ef7546a
Author: Tomáš Stefan <ts@stdin.cz>
Date:   Wed Mar 7 14:36:15 2018 +0100

    working on Windows support

commit 05fdbc0c01a25af0c357659504a42dbb5c2b85c9
Author: Tomáš Stefan <ts@stdin.cz>
Date:   Wed Mar 7 00:24:58 2018 +0100

    UTF-8 paths, CMake support

    utf-8 path support
    CMake support
    open file on Windows - work in progress

commit 7e8f520d0b269eb566a6187ab0f2bd64a4b04925
Author: Tomáš Stefan <ts@stdin.cz>
Date:   Tue Mar 6 17:28:08 2018 +0100

    remove char_t, using UTF-8 narrow strings
parent 2f78f75d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -59,3 +59,6 @@ Module.symvers
Mkfile.old
dkms.conf

# Editor files
.idea
cmake-build-debug

CMakeLists.txt

0 → 100644
+35 −0
Original line number Diff line number Diff line
cmake_minimum_required(VERSION 3.9)
project(pdf_sigil)

set(CMAKE_C_STANDARD 11)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic")

# header files
include_directories(include)


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})

# build selftest executable
add_executable(selftest ${TEST_SRC})
target_link_libraries(selftest pdf-sigil_static)

# running selftest
add_custom_target(run_tests ALL
    COMMAND selftest
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})

add_custom_target(run_tests_verbose
    COMMAND selftest --verbose
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)

add_custom_target(run_tests_quiet
    COMMAND selftest --quiet
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
 No newline at end of file
+18 −0
Original line number Diff line number Diff line
@@ -4,3 +4,21 @@ pdf-sigil
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Word **sigil** in name stands for latin word *sigillum*, which means **seal** or **stamp**.

### Build

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
```

The selftest is run automatically during the make, but if you want to re-run it, use one of the following commands:

```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
```
+4 −4
Original line number Diff line number Diff line
@@ -11,8 +11,8 @@
// Shouldn't be optimized out by the compiler
void sigil_zeroize(void *a, size_t bytes);

int is_digit(const char_t c);
int is_whitespace(const char_t c);
int is_digit(const char c);
int is_whitespace(const char c);

sigil_err_t pdf_read(sigil_t *sgl, size_t size, char *result, size_t *res_size);
sigil_err_t pdf_get_char(sigil_t *sgl, char *result);
@@ -22,12 +22,12 @@ sigil_err_t pdf_move_pos_rel(sigil_t *sgl, ssize_t shift_bytes);
sigil_err_t pdf_move_pos_abs(sigil_t *sgl, size_t position);

sigil_err_t skip_leading_whitespaces(sigil_t *sgl);
sigil_err_t skip_array(sigil_t *sgl);
sigil_err_t skip_dictionary(sigil_t *sgl);
sigil_err_t skip_dict_unknown_value(sigil_t *sgl);

sigil_err_t parse_number(sigil_t *sgl, size_t *number);
sigil_err_t parse_keyword(sigil_t *sgl, keyword_t *keyword);
sigil_err_t parse_free_indicator(sigil_t *sgl, free_indicator_t *result);
sigil_err_t parse_word(sigil_t *sgl, const char *word);
sigil_err_t parse_indirect_reference(sigil_t *sgl, reference_t *ref);
sigil_err_t parse_dict_key(sigil_t *sgl, dict_key_t *dict_key);

+4 −0
Original line number Diff line number Diff line
@@ -14,6 +14,10 @@
// threshold in bytes for loading whole file into buffer
#define THRESHOLD_FILE_BUFFERING    10485760

// maximum number of file updates, preventing forever loop in processing
// previous cross-reference sections (caused by cyclic links)
#define MAX_FILE_UPDATES            1024

// validate values
int sigil_config_self_test(int verbosity);

Loading