w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pdfparse.c File Reference
#include <ctype.h>
#include <string.h>
#include <math.h>
#include "system.h"
#include "mem.h"
#include "error.h"
#include "numbers.h"
#include "mfileio.h"
#include "pdfobj.h"
#include "pdfdoc.h"
#include "pdfdev.h"
#include "pdfparse.h"
Include dependency graph for pdfparse.c:

Go to the source code of this file.

Macros

#define is_space(c)
 
#define is_delim(c)
 
#define PDF_TOKEN_END(p, e)   ((p) >= (e) || is_space(*(p)) || is_delim(*(p)))
 
#define istokensep(c)   (is_space((c)) || is_delim((c)))
 
#define DUMP_LIMIT   50
 
#define PDF_NAME_LEN_MAX   128
 
#define PDF_STRING_LEN_MAX   65535
 
#define STRING_BUFFER_SIZE   PDF_STRING_LEN_MAX+1
 
#define isodigit(c)   ((c) >= '0' && (c) <= '7')
 

Functions

static int xtoi (char ch)
 
void dump (const char *start, const char *end)
 
void pdfparse_skip_line (const char **start, const char *end)
 
void skip_white (const char **start, const char *end)
 
static char * parsed_string (const char *start, const char *end)
 
char * parse_number (const char **start, const char *end)
 
char * parse_unsigned (const char **start, const char *end)
 
static char * parse_gen_ident (const char **start, const char *end, const char *valid_chars)
 
char * parse_ident (const char **start, const char *end)
 
char * parse_val_ident (const char **start, const char *end)
 
char * parse_opt_ident (const char **start, const char *end)
 
pdf_objparse_pdf_number (const char **pp, const char *endptr)
 
static int pn_getc (const char **pp, const char *endptr)
 
pdf_objparse_pdf_name (const char **pp, const char *endptr)
 
pdf_objparse_pdf_boolean (const char **pp, const char *endptr)
 
pdf_objparse_pdf_null (const char **pp, const char *endptr)
 
static int ps_getescc (const char **pp, const char *endptr)
 
static pdf_objparse_pdf_literal_string (const char **pp, const char *endptr)
 
static pdf_objparse_pdf_hex_string (const char **pp, const char *endptr)
 
pdf_objparse_pdf_string (const char **pp, const char *endptr)
 
static pdf_objparse_pdf_dict_extended (const char **pp, const char *endptr, pdf_file *pf, pdf_obj *(*unknown_handler)(const char **pp, const char *endptr, void *user_data), void *user_data)
 
static pdf_objparse_pdf_array_extended (const char **pp, const char *endptr, pdf_file *pf, pdf_obj *(*unknown_handler)(const char **pp, const char *endptr, void *user_data), void *user_data)
 
static pdf_objparse_pdf_stream (const char **pp, const char *endptr, pdf_obj *dict)
 
static pdf_objtry_pdf_reference (const char *start, const char *end, const char **endptr, pdf_file *pf)
 
pdf_objparse_pdf_object_extended (const char **pp, const char *endptr, pdf_file *pf, pdf_obj *(*unknown_handler)(const char **pp, const char *endptr, void *user_data), void *user_data)
 
pdf_objparse_pdf_dict (const char **pp, const char *endptr, pdf_file *pf)
 
pdf_objparse_pdf_array (const char **pp, const char *endptr, pdf_file *pf)
 
pdf_objparse_pdf_object (const char **pp, const char *endptr, pdf_file *pf)
 
pdf_objparse_pdf_tainted_dict (const char **pp, const char *endptr, pdf_obj *(*unknown_handler)(const char **pp, const char *endptr, void *user_data), void *user_data)
 

Variables

struct {
   int   tainted
 
parser_state
 
static char sbuf [65535+1]
 

Macro Definition Documentation

◆ DUMP_LIMIT

#define DUMP_LIMIT   50

◆ is_delim

#define is_delim (   c)
Value:
((c) == '(' || (c) == ')' || \
(c) == '/' || \
(c) == '<' || (c) == '>' || \
(c) == '[' || (c) == ']' || \
(c) == '%')
#define c(n)
Definition: gpos-common.c:150

Definition at line 56 of file pdfparse.c.

◆ is_space

#define is_space (   c)
Value:
((c) == ' ' || (c) == '\t' || (c) == '\f' || \
(c) == '\r' || (c) == '\n' || (c) == '\0')

Definition at line 54 of file pdfparse.c.

◆ isodigit

#define isodigit (   c)    ((c) >= '0' && (c) <= '7')

Definition at line 414 of file pdfparse.c.

◆ istokensep

#define istokensep (   c)    (is_space((c)) || is_delim((c)))

Definition at line 63 of file pdfparse.c.

◆ PDF_NAME_LEN_MAX

#define PDF_NAME_LEN_MAX   128

Definition at line 315 of file pdfparse.c.

◆ PDF_STRING_LEN_MAX

#define PDF_STRING_LEN_MAX   65535

Definition at line 319 of file pdfparse.c.

◆ PDF_TOKEN_END

#define PDF_TOKEN_END (   p,
  e 
)    ((p) >= (e) || is_space(*(p)) || is_delim(*(p)))

Definition at line 61 of file pdfparse.c.

◆ STRING_BUFFER_SIZE

#define STRING_BUFFER_SIZE   PDF_STRING_LEN_MAX+1

Definition at line 322 of file pdfparse.c.

Function Documentation

◆ dump()

◆ parse_gen_ident()

static char* parse_gen_ident ( const char **  start,
const char *  end,
const char *  valid_chars 
)
static

Definition at line 178 of file pdfparse.c.

References end, ident, p, parsed_string(), start, and strchr.

Referenced by parse_ident(), and parse_val_ident().

◆ parse_ident()

◆ parse_number()

◆ parse_opt_ident()

◆ parse_pdf_array()

◆ parse_pdf_array_extended()

static pdf_obj* parse_pdf_array_extended ( const char **  pp,
const char *  endptr,
pdf_file pf,
pdf_obj *(*)(const char **pp, const char *endptr, void *user_data)  unknown_handler,
void user_data 
)
static

◆ parse_pdf_boolean()

pdf_obj* parse_pdf_boolean ( const char **  pp,
const char *  endptr 
)

Definition at line 365 of file pdfparse.c.

References istokensep, NULL, pdf_new_boolean(), pp, skip_white(), strncmp(), and WARN().

Referenced by parse_pdf_object_extended().

◆ parse_pdf_dict()

◆ parse_pdf_dict_extended()

static pdf_obj* parse_pdf_dict_extended ( const char **  pp,
const char *  endptr,
pdf_file pf,
pdf_obj *(*)(const char **pp, const char *endptr, void *user_data)  unknown_handler,
void user_data 
)
static

◆ parse_pdf_hex_string()

static pdf_obj* parse_pdf_hex_string ( const char **  pp,
const char *  endptr 
)
static

◆ parse_pdf_literal_string()

static pdf_obj* parse_pdf_literal_string ( const char **  pp,
const char *  endptr 
)
static

Definition at line 468 of file pdfparse.c.

References ch, len, NULL, p, pdf_new_string(), PDF_STRING_LEN_MAX, pp, ps_getescc(), skip_white(), and WARN().

Referenced by parse_pdf_string().

◆ parse_pdf_name()

◆ parse_pdf_null()

pdf_obj* parse_pdf_null ( const char **  pp,
const char *  endptr 
)

Definition at line 390 of file pdfparse.c.

References istokensep, NULL, pdf_new_null(), pp, skip_white(), strncmp(), and WARN().

Referenced by parse_pdf_object_extended().

◆ parse_pdf_number()

pdf_obj* parse_pdf_number ( const char **  pp,
const char *  endptr 
)

◆ parse_pdf_object()

◆ parse_pdf_object_extended()

◆ parse_pdf_stream()

◆ parse_pdf_string()

◆ parse_pdf_tainted_dict()

pdf_obj* parse_pdf_tainted_dict ( const char **  pp,
const char *  endptr,
pdf_obj *(*)(const char **pp, const char *endptr, void *user_data)  unknown_handler,
void user_data 
)

Definition at line 995 of file pdfparse.c.

References NULL, parse_pdf_dict_extended(), pp, and check-static-inits::result.

Referenced by parse_pdf_dict_with_tounicode().

◆ parse_unsigned()

char* parse_unsigned ( const char **  start,
const char *  end 
)

Definition at line 161 of file pdfparse.c.

References end, isdigit, number, p, parsed_string(), skip_white(), and start.

Referenced by do_args(), parse_xref_table(), pdf_read_object(), and select_pages().

◆ parse_val_ident()

char* parse_val_ident ( const char **  start,
const char *  end 
)

◆ parsed_string()

static char* parsed_string ( const char *  start,
const char *  end 
)
static

Definition at line 122 of file pdfparse.c.

References end, len, memcpy, NEW, NULL, check-static-inits::result, and start.

Referenced by parse_gen_ident(), parse_number(), and parse_unsigned().

◆ pdfparse_skip_line()

void pdfparse_skip_line ( const char **  start,
const char *  end 
)

Definition at line 88 of file pdfparse.c.

References end, and start.

Referenced by load_encoding_file(), mps_scan_bbox(), and skip_white().

◆ pn_getc()

static int pn_getc ( const char **  pp,
const char *  endptr 
)
static

Definition at line 288 of file pdfparse.c.

References ch, p, pp, and xtoi().

Referenced by parse_pdf_name().

◆ ps_getescc()

static int ps_getescc ( const char **  pp,
const char *  endptr 
)
static

Definition at line 417 of file pdfparse.c.

References ch, i, isodigit, p, and pp.

Referenced by parse_pdf_literal_string().

◆ skip_white()

◆ try_pdf_reference()

static pdf_obj* try_pdf_reference ( const char *  start,
const char *  end,
const char **  endptr,
pdf_file pf 
)
static

Definition at line 847 of file pdfparse.c.

References ASSERT, end, is_space, isdigit, NULL, pdf_new_indirect(), PDF_TOKEN_END, pf(), skip_white(), and start.

Referenced by parse_pdf_object_extended().

◆ xtoi()

static int xtoi ( char  ch)
static

Definition at line 560 of file pdfparse.c.

References ch.

Referenced by parse_pdf_hex_string(), and pn_getc().

Variable Documentation

◆ 

parser_state { ... } struct
Initial value:
= {
0
}

◆ sbuf

char sbuf[65535+1]
static

Definition at line 323 of file pdfparse.c.

◆ tainted

int tainted

Definition at line 66 of file pdfparse.c.