summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/image/epdf.h
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2010-04-04 13:55:46 +0000
committerTaco Hoekwater <taco@elvenkind.com>2010-04-04 13:55:46 +0000
commitf372862c42d234710b6057449b46818e63181c90 (patch)
treea9ebec66dd31ac37aed442502ebd1b9fe76245ec /Build/source/texk/web2c/luatexdir/image/epdf.h
parent2dad291ab056f30816e0aea61970f38033c2f6a5 (diff)
import luatex 0.60.0 (with small local changes, see luatexdir/ChangeLog)
and do an autoreconf git-svn-id: svn://tug.org/texlive/trunk@17680 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/image/epdf.h')
-rw-r--r--Build/source/texk/web2c/luatexdir/image/epdf.h211
1 files changed, 132 insertions, 79 deletions
diff --git a/Build/source/texk/web2c/luatexdir/image/epdf.h b/Build/source/texk/web2c/luatexdir/image/epdf.h
index c619b20f08f..6d2632b0e54 100644
--- a/Build/source/texk/web2c/luatexdir/image/epdf.h
+++ b/Build/source/texk/web2c/luatexdir/image/epdf.h
@@ -1,8 +1,7 @@
/* epdf.h
Copyright 1996-2006 Han The Thanh <thanh@pdftex.org>
- Copyright 2006-2009 Taco Hoekwater <taco@luatex.org>
-
+ Copyright 2006-2010 Taco Hoekwater <taco@luatex.org>
This file is part of LuaTeX.
LuaTeX is free software; you can redistribute it and/or modify it under
@@ -18,11 +17,50 @@
You should have received a copy of the GNU General Public License along
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
-/* $Id: epdf.h 2327 2009-04-18 12:47:21Z hhenkel $ */
+/* $Id: epdf.h 3407 2010-01-28 16:27:39Z taco $ */
+
+// this is the common header file for C++ sources pdftoepdf.cc and lepdflib.cc
+
+#ifndef EPDF_H
+# define EPDF_H
+
+# include <stdlib.h>
+# include <math.h>
+# include <stddef.h>
+# include <stdio.h>
+# include <string.h>
+# include <kpathsea/c-ctype.h>
+# include <sys/stat.h>
+# ifdef POPPLER_VERSION
+# define GString GooString
+# include <dirent.h>
+# include <poppler-config.h>
+# include <goo/GooString.h>
+# include <goo/gmem.h>
+# include <goo/gfile.h>
+# else
+# include <aconf.h>
+# include <GString.h>
+# include <gmem.h>
+# include <gfile.h>
+# include <assert.h>
+# endif
+# include "Object.h"
+# include "Stream.h"
+# include "Array.h"
+# include "Dict.h"
+# include "XRef.h"
+# include "Catalog.h"
+# include "Link.h"
+# include "Page.h"
+# include "GfxFont.h"
+# include "PDFDoc.h"
+# include "GlobalParams.h"
+# include "Error.h"
extern "C" {
-#include <kpathsea/c-auto.h>
+# include <kpathsea/c-auto.h>
extern char *xstrdup(const char *);
@@ -30,91 +68,106 @@ extern "C" {
typedef const char *const_string; /* including kpathsea/types.h doesn't work on some systems */
-#define KPATHSEA_CONFIG_H /* avoid including other kpathsea header files */
+# define KPATHSEA_CONFIG_H /* avoid including other kpathsea header files */
/* from web2c/config.h */
-#ifdef CONFIG_H /* CONFIG_H has been defined by some xpdf */
-# undef CONFIG_H /* header file */
-#endif
+# ifdef CONFIG_H /* CONFIG_H has been defined by some xpdf */
+# undef CONFIG_H /* header file */
+# endif
-#include <web2c/c-auto.h> /* define SIZEOF_LONG */
-#include <web2c/config.h> /* define type integer */
+# include <web2c/c-auto.h> /* define SIZEOF_LONG */
-#include <web2c/luatexdir/ptexmac.h>
-#include "openbsd-compat.h"
-#include "image.h"
-#include "../utils/avlstuff.h"
+# include "openbsd-compat.h"
+# include "image.h"
+# include "utils/avlstuff.h"
+# include "pdf/pdftypes.h"
- extern void unrefPdfDocument(char *);
+# include "lua51/lua.h"
+# include "lua51/lauxlib.h"
- extern integer epdf_page_box;
- extern void *epdf_xref;
- extern integer epdf_lastGroupObjectNum;
-
- extern integer pdf_box_spec_media;
- extern integer pdf_box_spec_crop;
- extern integer pdf_box_spec_bleed;
- extern integer pdf_box_spec_trim;
- extern integer pdf_box_spec_art;
-
- extern longinteger pdf_stream_length;
- extern longinteger pdf_ptr;
- extern integer pool_ptr;
- typedef unsigned char eight_bits;
- extern eight_bits *pdf_buf;
- extern integer pdf_buf_size;
- extern integer pdf_os_mode;
- extern eight_bits pdf_last_byte;
- extern integer fixed_inclusion_copy_font;
-
- extern char notdef[];
-
- extern integer fixed_replace_font;
-
- extern int is_subsetable(struct fm_entry *);
- extern struct fm_entry *lookup_fontmap(char *);
- extern integer get_fontfile(struct fm_entry *);
- extern integer get_fontname(struct fm_entry *);
- extern integer pdf_new_objnum(void);
- extern void read_pdf_info(image_dict *, integer, integer);
- extern void embed_whole_font(struct fd_entry *);
- extern void epdf_check_mem(void);
+ /* pdfgen.c */
+ __attribute__ ((format(printf, 2, 3)))
+ extern void pdf_printf(PDF, const char *fmt, ...);
+ extern void pdf_puts(PDF, const char *);
+ extern void pdf_begin_obj(PDF, int, bool);
+ extern void pdf_end_obj(PDF);
+ extern void pdf_begin_stream(PDF);
+ extern void pdf_end_stream(PDF);
+ extern void pdf_room(PDF, int);
+# define pdf_out(B,A) do { pdf_room(B,1); B->buf[B->ptr++] = A; } while (0)
+
+ /* pdftables.c */
+ extern int pdf_new_objnum(PDF);
+
+ /* epdf.c */
extern void epdf_free(void);
+
+ /* pdftoepdf.cc */
+ extern void read_pdf_info(image_dict *, int, int, img_readtype_e);
+ extern void write_epdf(PDF, image_dict *);
+ extern void unrefPdfDocument(char *);
+ extern void epdf_check_mem(void);
+
+ /* utils.c */
__attribute__ ((format(printf, 1, 2)))
- extern void pdf_printf(const char *fmt, ...);
- extern void pdf_puts(const char *);
- extern void pdf_begin_stream(void);
- extern void pdf_end_obj(void);
- extern void pdf_end_stream(void);
- extern void pdf_flush(void);
+ extern void pdftex_warn(const char *fmt, ...);
__attribute__ ((noreturn, format(printf, 1, 2)))
extern void pdftex_fail(const char *fmt, ...);
- __attribute__ ((format(printf, 1, 2)))
- extern void pdftex_warn(const char *fmt, ...);
- __attribute__ ((format(printf, 1, 2)))
- extern void tex_printf(const char *, ...);
- extern void write_epdf(image_dict *);
- extern void write_additional_epdf_objects(void);
- extern void zpdf_begin_dict(integer, bool);
- extern void zpdf_begin_obj(integer, bool);
- extern void zpdf_create_obj(integer, integer);
- extern void zpdf_new_dict(integer, integer, bool);
- extern void zpdf_os_get_os_buf(integer);
-
-/* epdf.c */
- extern int get_fd_objnum(struct fd_entry *);
- extern int get_fn_objnum(struct fd_entry *);
-
-#include "../inc-epdf.h"
-
-/* utils.c */
extern char *convertStringToPDFString(char *in, int len);
extern char *stripzeros(char *a);
-/* config.c */
- extern integer cfgpar(integer);
-
-/* avlstuff.c */
- extern void avl_put_obj(integer, integer);
- extern integer avl_find_obj(integer, integer, integer);
-}
+ /* lepdflib.c */
+ int luaopen_epdf(lua_State * L);
+
+};
+
+/**********************************************************************/
+
+// PdfObject encapsulates the xpdf Object type,
+// and properly frees its resources on destruction.
+// Use obj-> to access members of the Object,
+// and &obj to get a pointer to the object.
+// It is no longer necessary to call Object::free explicitely.
+
+// *INDENT-OFF*
+class PdfObject {
+ public:
+ PdfObject() { // nothing
+ }
+ ~PdfObject() {
+ iObject.free();
+ }
+ Object *operator->() {
+ return &iObject;
+ }
+ Object *operator&() {
+ return &iObject;
+ }
+ private: // no copying or assigning
+ PdfObject(const PdfObject &);
+ void operator=(const PdfObject &);
+ public:
+ Object iObject;
+};
+// *INDENT-ON*
+
+/**********************************************************************/
+
+struct InObj {
+ Ref ref; // ref in original PDF
+ int num; // new object number in output PDF
+ InObj *next; // next entry in list of indirect objects
+};
+
+struct PdfDocument {
+ char *file_path; // full file name including path
+ char *checksum; // for reopening
+ PDFDoc *doc;
+ InObj *inObjList; // temporary linked list
+ avl_table *ObjMapTree; // permanent over luatex run
+ int occurences; // number of references to the PdfDocument; it can be deleted when occurences == 0
+};
+
+PdfDocument *refPdfDocument(char *file_path);
+
+#endif /* EPDF_H */