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

Cleanup

removed error module
added module types + constants
other small improvements
parent 4c74de7d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -15,8 +15,8 @@ INCLUDE_DIR=include
TEST_DIR=test
BUILD_DIR=build
# library files
LIB_SRC=auxiliary.c config.c error.c header.c sigil.c trailer.c xref.c
LIB_H=$(LIB_SRC:%.c=%.h)
LIB_SRC=auxiliary.c config.c header.c sigil.c trailer.c xref.c
LIB_H=$(LIB_SRC:%.c=%.h) types.h constants.h
LIB_O=$(LIB_SRC:%.c=$(BUILD_DIR)/$(LIB_DIR)/%.o)
# test files
TEST_SRC=test.c
+4 −49
Original line number Diff line number Diff line
#ifndef PDF_SIGIL_AUXILIARY_H
#define PDF_SIGIL_AUXILIARY_H

#include <stdio.h>
#include <stdint.h>
#include <stdio.h> // size_t, FILE
#include "types.h"

#ifndef CHAR_T
#define CHAR_T
    typedef unsigned char char_t;
#endif /* CHAR_T */

#ifndef SIGIL_ERR_T
#define SIGIL_ERR_T
    typedef uint32_t sigil_err_t;
#endif /* SIGIL_ERR_T */

#ifndef KEYWORD_T
#define KEYWORD_T
    typedef uint32_t keyword_t;
#endif /* KEYWORD_T */

#ifndef FREE_INDICATOR_T
#define FREE_INDICATOR_T
    typedef uint32_t free_indicator_t;
#endif /* FREE_INDICATOR_T */

#ifndef REREFENCE_T
#define REREFENCE_T
    typedef struct {
        size_t object_num;
        size_t generation_num;
    } reference_t;
#endif /* REREFENCE_T */

#ifndef DICT_KEY_T
#define DICT_KEY_T
    typedef uint32_t dict_key_t;
#endif /* DICT_KEY_T */

#define KEYWORD_xref     0
#define KEYWORD_trailer  1

#define IN_USE_ENTRY     0
#define FREE_ENTRY       1

#define DICT_KEY_Size      0
#define DICT_KEY_Prev      1
#define DICT_KEY_Root      2
#define DICT_KEY_unknown   3

#define COLOR_RED        "\x1b[31m"
#define COLOR_GREEN      "\x1b[32m"
#define COLOR_RESET      "\x1b[0m"

#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
@@ -71,6 +24,8 @@ sigil_err_t parse_free_indicator(FILE *in, free_indicator_t *result);
sigil_err_t parse_indirect_reference(FILE *in, reference_t *ref);
sigil_err_t parse_dict_key(FILE *in, dict_key_t *dict_key);

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

include/constants.h

0 → 100644
+42 −0
Original line number Diff line number Diff line
#ifndef PDF_SIGIL_CONSTANTS_H
#define PDF_SIGIL_CONSTANTS_H


#define COLOR_RED          "\x1b[31m"
#define COLOR_GREEN        "\x1b[32m"
#define COLOR_RESET        "\x1b[0m"

#define KEYWORD_xref       0
#define KEYWORD_trailer    1

#define XREF_TYPE_UNSET    0
#define XREF_TYPE_TABLE    1
#define XREF_TYPE_STREAM   2

#define IN_USE_ENTRY       0
#define FREE_ENTRY         1

#define DICT_KEY_Size      0
#define DICT_KEY_Prev      1
#define DICT_KEY_Root      2
#define DICT_KEY_unknown   3

#define ERR_NO             0
#define ERR_ALLOC          1
#define ERR_PARAM          2
#define ERR_IO             3
#define ERR_PDF_CONT       4
#define ERR_NOT_IMPL       5
#define ERR_6              6
#define ERR_7              7
#define ERR_8              8
#define ERR_9              9
#define ERR_10            10
#define ERR_11            11
#define ERR_12            12
#define ERR_13            13
#define ERR_14            14
#define ERR_15            15
#define ERR_16            16

#endif /* PDF_SIGIL_CONSTANTS_H */

include/error.h

deleted100644 → 0
+0 −38
Original line number Diff line number Diff line
#ifndef PDF_SIGIL_ERROR_H
#define PDF_SIGIL_ERROR_H

#include <stdint.h>

#ifndef CHAR_T
#define CHAR_T
    typedef unsigned char char_t;
#endif /* CHAR_T */

#ifndef SIGIL_ERR_T
#define SIGIL_ERR_T
    typedef uint32_t sigil_err_t;
#endif /* SIGIL_ERR_T */

#define ERR_NO           0x0000 // [_|_|_|x] 0000 0000
#define ERR_ALLOC        0x0001 // [_|_|_|x] 0000 0001
#define ERR_PARAM        0x0002 // [_|_|_|x] 0000 0010
#define ERR_IO           0x0004 // [_|_|_|x] 0000 0100
#define ERR_PDF_CONT     0x0008 // [_|_|_|x] 0000 1000
#define ERR_NOT_IMPL     0x0010 // [_|_|_|x] 0001 0000
#define ERR_6            0x0020 // [_|_|_|x] 0010 0000
#define ERR_7            0x0040 // [_|_|_|x] 0100 0000
#define ERR_8            0x0080 // [_|_|_|x] 1000 0000
#define ERR_9            0x0100 // [_|_|x|_] 0000 0001
#define ERR_10           0x0200 // [_|_|x|_] 0000 0010
#define ERR_11           0x0400 // [_|_|x|_] 0000 0100
#define ERR_12           0x0800 // [_|_|x|_] 0000 1000
#define ERR_13           0x1000 // [_|_|x|_] 0001 0000
#define ERR_14           0x2000 // [_|_|x|_] 0010 0000
#define ERR_15           0x4000 // [_|_|x|_] 0100 0000
#define ERR_16           0x8000 // [_|_|x|_] 1000 0000

const char *sigil_err_string(sigil_err_t err);

int sigil_error_self_test(int verbosity);

#endif /* PDF_SIGIL_ERROR_H */
+1 −6
Original line number Diff line number Diff line
#ifndef PDF_SIGIL_HEADER_H
#define PDF_SIGIL_HEADER_H

#include "sigil.h"

#ifndef SIGIL_ERR_T
#define SIGIL_ERR_T
    typedef uint32_t sigil_err_t;
#endif /* SIGIL_ERR_T */
#include "types.h"


sigil_err_t process_header(sigil_t *sgl);
Loading