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

Add parsing cross-reference table

for now without tests
parent 137cdbb6
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
#ifndef PDF_SIGIL_AUXILIARY_H
#define PDF_SIGIL_AUXILIARY_H

#include <stdlib.h>
#include <stdio.h>

#ifndef CHAR_T
#define CHAR_T
@@ -20,9 +20,11 @@ typedef char char_t;
void sigil_zeroize(void *a, size_t bytes);

int is_digit(const char_t c);

int is_whitespace(const char_t c);

int parse_number(FILE *in, size_t *number);
int parse_free_indicator(FILE *in, char_t *result);

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);
+3 −0
Original line number Diff line number Diff line
@@ -8,6 +8,9 @@
// maximum bytes to read from the end of file to look for the "startxref"
#define XREF_SEARCH_OFFSET      1024

// capacity to choose for the first xref allocation
#define XREF_PREALLOCATION      10

// validate values
int sigil_config_self_test(int verbosity);

+2 −2
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@ typedef char char_t;
#define ERR_PARAM        0x0002 // [_|_|_|x] 0000 0010
#define ERR_IO           0x0004 // [_|_|_|x] 0000 0100
#define ERR_PDF_CONT     0x0008 // [_|_|_|x] 0000 1000
#define ERR_5            0x0010 // [_|_|_|x] 0001 0000
#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
+16 −1
Original line number Diff line number Diff line
@@ -9,6 +9,19 @@
    typedef char char_t;
#endif /* CHAR_T */

#ifndef XREF_T
#define XREF_T
    typedef struct {
        size_t byte_offset;
        size_t generation_num;
    } xref_entry_t;

    typedef struct {
        xref_entry_t **entry;
        size_t capacity;
    } xref_t;
#endif /* XREF_T */

#define XREF_TYPE_UNSET    0
#define XREF_TYPE_TABLE    1
#define XREF_TYPE_STREAM   2
@@ -18,6 +31,7 @@ typedef char char_t;
#define MODE_SIGN      2

typedef uint32_t mode_t;
struct xref_t;

typedef struct {
    FILE   *file;
@@ -26,6 +40,7 @@ typedef struct {
    short   pdf_x,             /* numbers from PDF header */
            pdf_y;             /*   %PDF-<pdf_x>.<pdf_y>  */
    short   xref_type;
    xref_t *xref;
    size_t  file_size;
    size_t  pdf_start_offset;  /* offset of %PDF-x.y      */
    size_t  startxref;
+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@

#include "error.h"


sigil_err_t process_trailer(sigil_t *sgl);

int sigil_trailer_self_test(int verbosity);
Loading